ProjectAnalyzer is a Node.js CLI tool designed to analyze a project directory. It counts the total number of files, folders, and lines of code, providing a detailed summary of the project structure. The tool supports excluding the .git
directory and displays the analysis in a user-friendly format for the CLI output.
- File and Folder Count: Counts the total number of files and folders in the project directory.
- Lines of Code: Calculates the total number of lines in all files.
- Git Directory Exclusion: Optionally exclude the
.git
directory from the analysis. - CLI Output: Presents the analysis results with an attractive ASCII art design.
- Customizable: Easily extendable to include more metrics or modifications.
To use ProjectAnalyzer, follow these steps:
- Ensure you have Node.js installed on your system. You can download it from nodejs.org.
- Clone or download the project:
git clone [email protected]:DevT045T/ProjectAnalyzer.git
cd ProjectAnalyzer
- Install dependencies via npm:
npm install
To analyze a project, you can use the following command format:
node main.js --path=/path/to/project --exclude-git
--path=/path/to/project
: Specifies the path to the project you want to analyze.--exclude-git
: Optionally exclude the.git
directory from the analysis.
Project Analysis Complete:
-----------------------------------
Total Files: 132
Total Folders: 12
Total Lines of Code: 3,245
-----------------------------------
-
excludeGit(exclude: boolean)
: Allows you to exclude the.git
directory from the analysis ifexclude
is set totrue
. Defaults tofalse
. -
analyzeProject()
: Initiates the project analysis, traverses through all files and directories, and outputs the analysis summary. -
traverseDirectory(currentPath: string)
: Recursively traverses the project directory to count files and directories. -
countLinesInFile(filePath: string)
: Counts the number of lines in a specific file.
const ProjectAnalyzer = require('./src/ProjectAnalyzer.js');
const analyzer = new ProjectAnalyzer('/path/to/your/project');
// Exclude the .git directory
analyzer.excludeGit(true);
// Analyze the project
analyzer.analyzeProject();
This project is licensed under the MIT License - see the LICENSE file for details.
Feel free to fork this project, make improvements, and submit pull requests. Contributions are always welcome!