3 releases (breaking)
new 0.7.1 | May 7, 2025 |
---|---|
0.6.0 | May 7, 2025 |
0.1.0 | Dec 23, 2024 |
#5 in #first
105 downloads per month
225KB
226 lines
Node Size Analyzer
A fast CLI tool to analyze and visualize the size of your node_modules dependencies using a terminal UI.
Features
- Interactive terminal UI using ratatui
- Real-time size calculation of node_modules
- Sorted display by size (largest modules first)
- Human-readable size formatting (B, KB, MB)
- Cross-platform support (Windows, MacOS, Linux)
- Fast directory traversal for quick analysis
Installation
Using Cargo
The latest stable version is automatically published to crates.io:
cargo install node-size-analyzer
From GitHub Releases
Pre-built binaries for all major platforms are automatically generated for each release and available from the releases page.
Linux/MacOS
# Download the latest release for your platform
curl -L https://github.com/Caryyon/node-size-analyzer/releases/latest/download/node-size-linux -o node-size
# or for macOS:
# curl -L https://github.com/Caryyon/node-size-analyzer/releases/latest/download/node-size-macos -o node-size
chmod +x node-size
./node-size
Windows
# Download using PowerShell
Invoke-WebRequest -Uri https://github.com/Caryyon/node-size-analyzer/releases/latest/download/node-size-windows.exe -OutFile node-size.exe
.\node-size.exe
New releases are automatically published when changes are merged to the main branch.
Usage
- Navigate to your project directory containing node_modules
- Run
node-size
- The terminal UI will display all modules sorted by size
- Use the following key controls:
- Press 'q' to exit
- Arrow Up/Down or 'k'/'j' to scroll one line
- Page Up/Down to scroll a full page
- Home/End to jump to beginning/end of the list
Example Output
The tool displays a table with:
- Module names (left column)
- Size in human-readable format (right column)
- Sorted from largest to smallest
Building from Source
git clone https://github.com/Caryyon/node-size-analyzer.git
cd node-size-analyzer
cargo build --release
The compiled binary will be available at target/release/node-size
.
Development
Project Structure
src/main.rs
- Main application codeCargo.toml
- Project dependencies and configuration
Running Tests
This project includes unit tests for core functionality. To run the tests:
cargo test
The test suite includes:
- Tests for size formatting
- Tests for directory size calculation
- Tests for module scanning and sorting
Adding Features
When adding new features, please ensure:
- All tests pass (run
cargo test
) - Code follows Rust formatting standards (run
cargo fmt
) - No clippy warnings (run
cargo clippy
)
Contributing
This project uses Semantic Versioning and Conventional Commits.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Add tests for your changes
- Ensure all tests pass (
cargo test
) - Commit your changes using the conventional commit format:
feat: add new feature
(triggers minor version bump)fix: resolve bug issue
(triggers patch version bump)docs: update documentation
(triggers patch version bump)feat!: redesign API
(triggers major version bump)
- Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
See CONTRIBUTING.md for detailed guidelines on commit messages and the release process.
How It Works
The tool:
- Scans your
node_modules
directory recursively - Calculates the size of each top-level module
- Sorts modules by size (largest first)
- Renders an interactive table UI with the results
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
Dependencies
~4–9.5MB
~84K SLoC