A CLI tool to track the usage of React/Next.js components and Node.js functions across an entire codebase. This package provides insights into function definitions, imports, and calls, allowing developers to analyze their codebase efficiently.
Just install it globally and use a simple command to generate report
1. install globally
npm i -g codebase-tracker
2. Generate Report
npx codebase-tracker --directory ./ --output component-function-usage-report.txt
3. Access the reoprt in your project directory
- Comprehensive Tracking: Analyze all JavaScript files in the specified directory to track function usage.
- Detailed Reports: Generate reports that include:
- Each function's definition location.
- All import statements.
- Call locations with total counts and line numbers.
- Project Structure Representation: Display the project directory tree along with function usage statistics.
To use codebase-tracker
, you can install it globally using npm:
npm install -g codebase-tracker
Or clone the repository and link it locally:
git clone https://github.com/Kanai2003/codebase-tracker.git
cd codebase-tracker
npm link
Run the CLI command in your terminal:
npx codebase-tracker --directory <path_to_your_codebase> --output <output_file_name>
Example
npx codebase-tracker --directory ./ --output component-function-usage-report.txt
===== Component and Function Usage Report =====
Generated by: codebase-tracker
Project: youtube_clone
Total Files: 35
Total Directories: 7
Total Lines of Code: 2472
--- Project Dependencies ---
bcrypt: ^5.1.1
cloudinary: ^1.41.1
cookie-parser: ^1.4.6
cors: ^2.8.5
dotenv: ^16.3.1
express: ^4.18.2
jsonwebtoken: ^9.0.2
mongoose: ^8.0.3
mongoose-aggregate-paginate-v2: ^1.0.6
multer: ^1.4.5-lts.1
==============================================
--- Project File Structure ---
└── src/
└── index.js (26 LOC)
└── constants.js (1 LOC)
└── app.js (44 LOC)
└── utils/
└── cloudinary.js (30 LOC)
└── asyncHandler.js (30 LOC)
...more
└── routes/
└── video.routes.js (57 LOC)
└── user.routes.js (77 LOC)
...more
└── models/
└── video.model.js (45 LOC)
...more
└── middlewares/
└── multer.middleware.js (16 LOC)
└── auth.middleware.js (27 LOC)
└── db/
└── index.js (15 LOC)
└── controllers/
└── video.controller.js (240 LOC)
...more
==============================================
Backend/Frontend Functions Usage:
Function: app
- Imported at: src/index.js, Line: 3
- Called at: src/app.js, Total Calls: 30, Line: 8
Function: connectDB
- Called at: src/index.js, Total Calls: 1, Line: 12
- Defined at: src/db/index.js, Line: 5
Function: uploadOnCloudinary
- Defined at: src/utils/cloudinary.js, Line: 13
- Imported at: src/controllers/video.controller.js, Line: 6
- Imported at: src/controllers/user.controller.js, Line: 4
----------------------Many more-------------------------
Contributions are welcome! If you have suggestions or improvements, feel free to create a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.
Kanailal Manna
github: https://github.com/kanai2003