Skip to content

Kanai2003/codebase-tracker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Codebase Tracker

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 report in your project directory

Features

  • Comprehensive Tracking: Analyze all JavaScript and TypeScript files (.js, .jsx, .ts, .tsx) in the specified directory.
  • Smart Ignoring: Automatically respects your project's .gitignore file to skip unwanted files (like node_modules, build artifacts, etc.).
  • 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.

Installation

To use codebase-tracker, you can install it globally using npm:

npm install -g codebase-tracker

Or you can use it directly with npx without installing globally:

npx codebase-tracker --help

Usage

Run the CLI command in your terminal. You can run it from the root of your project:

npx codebase-tracker --directory ./ --output report.txt

Options

  • --directory <path>: The directory to scan (default: ./)
  • --output <path>: The file to save the report (default: component-function-usage-report.txt)

Example

npx codebase-tracker --directory ./src --output ./reports/usage-report.txt

Sample Output

===== 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-------------------------

Contributing

Contributions are welcome! If you have suggestions or improvements, feel free to create a pull request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

Kanailal Manna

github: https://github.com/kanai2003

repo: https://github.com/Kanai2003/codebase-tracker

About

A tool to track React/Next.js component usage and Node.js function usage across a full codebase.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors