Enterprise-grade dependency analysis with environmental impact reporting
DepSweep is a production-ready CLI tool that identifies unused dependencies in Node.js projects and calculates their environmental impact. Designed for enterprise use and high-traffic open source projects.
- Dependency Analysis: Identifies unused dependencies across JavaScript, TypeScript, JSX, and TSX files using AST parsing
- Environmental Impact Reporting: Calculates carbon savings, energy consumption, and water usage based on scientific research
- Safe Cleanup: Protected dependencies prevent breaking changes
- Performance Optimized: Fast analysis with memory optimization and parallel processing
- Flexible Configuration: Customizable ignore patterns and safe dependencies
- Professional Output: Structured tables and progress indicators
- Enterprise Ready: Comprehensive error handling, rate limiting, and security features
npm install -g depsweep# Analyze dependencies and measure environmental impact
depsweep --measure-impact --dry-run
# Run with verbose output for detailed information
depsweep --measure-impact --dry-run --verbose
# Get help
depsweep --help# Analyze current project
depsweep --measure-impact --dry-run# Ignore specific directories
depsweep --measure-impact --ignore "tests/**,docs/**" --dry-run
# Protect specific dependencies
depsweep --measure-impact --safe "lodash,moment" --dry-run
# Aggressive cleanup (removes protected dependencies)
depsweep --measure-impact --aggressive --dry-run
# Combine multiple options
depsweep --measure-impact --aggressive --safe "express" --ignore "src/**,tests/**" --verboseDepSweep calculates the environmental impact of removing unused dependencies using scientifically validated methodologies:
- Carbon Savings: CO2 equivalent reduction (kg CO2e)
- Energy Savings: Reduced data center energy consumption (kWh)
- Water Savings: Reduced cooling water usage (liters)
- Tree Equivalents: Trees that would need to be planted to offset carbon
- Car Miles: Equivalent miles driven to produce the same CO2
Environmental Impact Analysis
Total Environmental Impact
βββββββββββββββββββββββββββ¬βββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββ
β Metric β Value β Impact β
βββββββββββββββββββββββββββΌβββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββ€
β Carbon Savings β 0.492 kg CO2e β Equivalent to 0.02 trees/year β
β β β trees planted β
βββββββββββββββββββββββββββΌβββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββ€
β Energy Savings β 1.273 kWh β Reduced data center energy β
β β β consumption β
βββββββββββββββββββββββββββΌβββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββ€
β Water Savings β 2.4 L β Reduced data center cooling needs β
βββββββββββββββββββββββββββΌβββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββ€
β Car Miles Equivalent β 1.3 miles β CO2 savings equivalent to driving β
βββββββββββββββββββββββββββΌβββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββ€
β Efficiency Gain β 18.5% β Improved build and runtime β
β β β performance β
βββββββββββββββββββββββββββ΄βββββββββββββββββββββ΄ββββββββββββββββββββββββββββββββββββ
DepSweep automatically protects critical dependencies:
- Runtime Dependencies: express, react, vue, angular
- Build Tools: webpack, typescript, babel
- Testing Frameworks: jest, mocha, cypress
- Code Quality: eslint, prettier, husky
Protect specific packages from removal:
depsweep --safe "lodash,moment,axios" --measure-impact --dry-runAlways test before making changes:
depsweep --measure-impact --dry-run # Safe - no changes made
depsweep --measure-impact # Actually removes dependencies| Option | Short | Description |
|---|---|---|
--measure-impact |
-m |
Calculate environmental impact |
--dry-run |
-d |
Run without making changes |
--verbose |
-v |
Display detailed information |
--aggressive |
-a |
Allow removal of protected dependencies |
--safe <deps> |
-s |
Dependencies that will not be removed |
--ignore <paths> |
-i |
Patterns to ignore during scanning |
--no-progress |
-n |
Disable progress bar |
--version |
Display version information | |
--help |
-h |
Display help information |
# Ignore multiple directories
depsweep --ignore "src/**,tests/**,docs/**" --measure-impact --dry-run
# Ignore specific file types
depsweep --ignore "*.test.js,*.spec.js" --measure-impact --dry-runDepSweep automatically detects and analyzes:
- Monorepos with workspaces
- Lerna projects
- Yarn workspaces
- pnpm workspaces
DepSweep includes a GitHub Actions workflow that allows you to analyze any repository or npm package without cloning it locally. Results are automatically posted as a comment on your issue and the issue is closed.
- Go to the Issues tab in the DepSweep repository
- Click New Issue
- Select Analyze Repository template
- Fill in the form:
- Repository URL or Package Name: Enter either:
- A GitHub repository URL:
https://github.com/user/repo - An npm package name:
express,lodash, etc.
- A GitHub repository URL:
- Branch (optional): Branch to analyze for GitHub repos (default:
main) - Ignore Patterns (optional): Comma-separated patterns to ignore
- Verbose output (optional): Check for detailed output
- Repository URL or Package Name: Enter either:
- Click Submit new issue
The workflow will automatically:
- Clone the repository (if GitHub URL) or install the package
- Run DepSweep analysis with environmental impact reporting
- Generate a comprehensive report
- Post results as a comment on the issue
- Close the issue automatically
- Upload detailed report as a downloadable artifact
For manual workflow execution:
- Go to the Actions tab
- Select Analyze Repository workflow
- Click Run workflow
- Enter repository URL or package name
- Configure options and run
Note: The issue template method is recommended as it provides better tracking and automatic result posting.
- Memory Efficient: Uses optimized caching and memory management
- Concurrent Processing: Parallel file analysis for faster results
- Smart Caching: Caches dependency analysis results
- Node.js: Express, Koa, Fastify applications
- React: Create React App, Next.js, Gatsby
- Vue: Vue CLI, Nuxt.js
- Angular: Angular CLI applications
- TypeScript: Pure TypeScript projects
- Monorepos: Lerna, Yarn workspaces, pnpm workspaces
# Run all tests
npm test
# Run with coverage
npm run test:coverage
# Run specific test suites
npm run test:unit
npm run test:e2eDepSweep is optimized for performance:
- Memory Usage: 25-44MB for large projects
- Processing Speed: 1-2 seconds for complex projects
- Concurrent Operations: Parallel file processing
- Smart Caching: Reduces redundant operations
We welcome contributions! Please see our Contributing Guide for details.
# Clone the repository
git clone https://github.com/yourusername/depsweep.git
cd depsweep
# Install dependencies
npm install
# Build the project
npm run build
# Run tests
npm test
# Link for local development
npm linkThis project is licensed under the MIT License - see the LICENSE file for details.
- Environmental impact calculations based on peer-reviewed research from IEA, EPA, USDA, and other scientific organizations
- Built with enterprise-grade security and reliability standards
- Thanks to all contributors and the open-source community
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: GitHub Wiki
DepSweep - Optimizing dependencies, reducing waste, building sustainably