Skip to content

CodeTree 🌳 is a powerful Node.js tool that creates a detailed tree visualization of your codebase. It recursively scans your project directory, identifies code files, and generates a comprehensive analysis including file contents and line counts, all while respecting common ignore patterns.

License

Notifications You must be signed in to change notification settings

hmahmodi/CodeTree

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

CodeTree 🌳

CodeTree is a powerful Node.js tool that creates a detailed tree visualization of your codebase with smart configuration and customization options. It recursively scans your project directory, identifies code files, and generates a comprehensive analysis while respecting user-defined patterns and preferences.

🌟 Features

  • πŸ“ Generates tree-style directory visualization
  • πŸ“Š Includes line count and file size analysis
  • πŸ“ Shows file contents for supported code files
  • ⚑ Smart binary/text file detection
  • 🎯 Supports 40+ programming languages and config files
  • 🚫 Smart file and directory filtering
  • πŸ”§ Highly configurable through JSON config files
  • 🌍 Global and project-specific configurations
  • 🎨 Built-in extension groups for easy management
  • πŸ” Debug mode for troubleshooting

πŸš€ Installation

Prerequisites

  • Node.js (v12.0.0 or higher)
  • npm (v6.0.0 or higher)
  • Git (for installation from source)

System Requirements

Linux & macOS

  • Write permission for /usr/local/bin (or use sudo)
  • Bash shell (pre-installed on most systems)

Quick Install

# Clone the repository
git clone https://github.com/mimalef70/codetree.git

# Navigate to the codetree directory
cd codetree

# Make the installation script executable
chmod +x install.sh

# Run the installation script (might need sudo)
./install.sh

NPM Installation

npm install -g codetree-cli

πŸ“– Usage

Basic Usage

# Analyze current directory
codetree .

# Analyze specific directory
codetree /path/to/project

# Create local configuration
codetree init

# Create global configuration
codetree init --global

# Enable debug output
DEBUG=true codetree .

Configuration

CodeTree can be customized using configuration files in multiple locations:

  1. Global configuration: ~/.codetreerc
  2. Project configuration: .codetreerc or codetree.config.json
  3. Package.json: "codetree" field

Configuration File Example

{
  "output": {
    "filename": "custom-analysis.txt",
    "maxFileSize": 10,
    "showContent": true,
    "showSize": true,
    "showLineCount": true
  },
  
  "groups": {
    "programming": {
      "enabled": true,
      "extensions": [".custom", ".specific"]
    },
    "web": {
      "enabled": false
    }
  },

  "include": {
    "extensions": [".myext"],
    "files": ["specific-file.txt"],
    "patterns": ["**/*.custom"]
  },

  "exclude": {
    "extensions": [".test.js"],
    "files": ["debug.log"],
    "patterns": ["**/*.min.js"]
  },

  "ignore": {
    "defaults": true,
    "custom": ["my-temp-dir"],
    "patterns": ["**/build-*/**"]
  }
}

Extension Groups

CodeTree organizes file extensions into groups that can be enabled/disabled:

  • programming: General programming languages
  • web: Web development files
  • config: Configuration files
  • docs: Documentation files
  • scripts: Shell and script files
  • data: Data and database files

Each group can be customized or disabled in your configuration.

Pattern Matching

CodeTree supports glob patterns for flexible file matching:

{
  "include": {
    "patterns": [
      "src/**/*.js",
      "lib/*.{js,ts}"
    ]
  },
  "exclude": {
    "patterns": [
      "**/*.test.js",
      "**/*.spec.js"
    ]
  }
}

Output Format

project/
β”œβ”€β”€ src/ (1.2 MB)
β”‚   β”œβ”€β”€ index.js (100 lines, 2.5 KB)
β”‚   β”‚   Content:
β”‚   β”‚       // File contents here
β”‚   └── utils/
β”‚       └── helper.js (50 lines, 1.1 KB)
β”‚           Content:
β”‚               // File contents here
└── package.json (30 lines, 750 B)

πŸ› οΈ Advanced Usage

Debug Mode

Enable detailed logging:

DEBUG=true codetree .

Custom Extension Groups

Create your own extension group in .codetreerc:

{
  "groups": {
    "myCustomGroup": {
      "enabled": true,
      "extensions": [".custom", ".specific"]
    }
  }
}

Configuration Priority

  1. Command-line arguments
  2. Project-specific config
  3. Global config
  4. Default settings

πŸ”§ Troubleshooting

Common Issues

  1. Permission Denied

    sudo ./install.sh
  2. Command Not Found

    source ~/.bashrc  # For Bash
    source ~/.zshrc   # For Zsh
  3. File Size Limits

    • Default limit: 5MB
    • Customize in config:
    {
      "output": {
        "maxFileSize": 10
      }
    }

🀝 Contributing

Contributions are welcome! Here's how:

  1. Fork the repository
  2. Create your branch: git checkout -b feature/AmazingFeature
  3. Make changes and commit: git commit -m 'Add AmazingFeature'
  4. Push to your branch: git push origin feature/AmazingFeature
  5. Open a Pull Request

Development Setup

# Install dependencies
npm install

# Run tests
npm test

# Run linter
npm run lint

# Format code
npm run format

πŸ“ License

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

πŸ”„ Changelog

Version 1.0.0

  • Initial release
  • Smart configuration system
  • Extension group management
  • Glob pattern support
  • Advanced file filtering
  • Size and line count analysis
  • Debug mode
  • Global and local configs

Made with ❀️ by Mostafa Alahyari

About

CodeTree 🌳 is a powerful Node.js tool that creates a detailed tree visualization of your codebase. It recursively scans your project directory, identifies code files, and generates a comprehensive analysis including file contents and line counts, all while respecting common ignore patterns.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 87.1%
  • Shell 12.9%