DepHealth π
A comprehensive dependency health analyzer for Node.js projects that provides detailed insights into package health, security, and maintenance status.
β¨ Features
- π Security Analysis: Comprehensive vulnerability assessment with severity weighting
- π¦ Version Tracking: Detects outdated packages using semantic versioning
- π Repository Analysis: GitHub and GitLab integration for open issues count
- π Multi-Metric Scoring: Evaluates maturity, update frequency, deprecation, dependency health, downloads, and more
- π¨ Professional Output: Beautiful colored console tables with detailed metrics
- β‘ Concurrent Processing: Up to 10 parallel package analyses for better performance
- π§ Optional Authentication: Support for GitHub and GitLab tokens for enhanced API access
- π Boosted Scoring: Customizable score boosters for different metrics
π Quick Start
npm install -g dephealth
npx dephealth
cd your-project
npx dephealth
npx dephealth --github-token YOUR_GITHUB_TOKEN --gitlab-token YOUR_GITLAB_TOKEN
π What It Analyzes
π Security Vulnerabilities
- Critical vulnerabilities: Weighted penalty of 0.6 each
- High vulnerabilities: Weighted penalty of 0.4 each
- Moderate vulnerabilities: Weighted penalty of 0.2 each
- Low vulnerabilities: Weighted penalty of 0.1 each
- Total penalty: Capped at 1.0 (score = 1 - total penalty)
π¦ Version Health
- Major updates: Exponential penalty for breaking changes
- Minor updates: Linear penalty for new features
- Patch updates: Minimal penalty for bug fixes
π Repository Metrics
- Maturity: Based on repository age (years active, capped at 10) and release cadence (releases per year, capped at 4)
- Update Frequency: Releases per year (0 if β€1/year, 1 if β₯12/year)
- Deprecation: 0 if deprecated, 1 if not deprecated
- Dependency Health: Runtime deps (ideal β€5, poor β₯40) and dev deps (ideal β€10, poor β₯80)
- Download Count: Log-scaled popularity based on weekly downloads (0 to 1M+)
- Issue Count: Open issues normalized by popularity (issues per 10k downloads)
π― Health Score (0-1)
- 0.8-1.0: Excellent - Your project is in great shape!
- 0.6-0.79: Good - Some improvements recommended
- 0.0-0.59: Needs attention - Consider reviewing dependencies
π Output Example
π (1/4) Analyzing packages...
π (2/4) Analyzing packages...
π (3/4) Analyzing packages...
π (4/4) Analyzing packages...
β
Analysis complete! Analyzed 4 packages
π DEPENDENCY HEALTH REPORT
================================================================================
βββββββββββββββ¬βββββββββββ¬ββββββββββ¬βββββββββββ¬βββββββββββ¬βββββββββββ¬βββββββββββ¬βββββββββββ¬βββββββββββ¬βββββββββββ
β Package β Current β Latest β Maturity β Updates β Deprec. βDep.Healthβ Downloadsβ Vuln. β Issues β
βββββββββββββββΌβββββββββββΌββββββββββΌβββββββββββΌβββββββββββΌβββββββββββΌβββββββββββΌβββββββββββΌβββββββββββΌβββββββββββ€
β express β 4.18.2 β 4.18.2 β 0.95 β 0.90 β 1.00 β 0.85 β 0.98 β 1.00 β 0.92 β
β lodash β 4.17.21 β 4.17.21 β 0.98 β 0.85 β 1.00 β 0.90 β 0.99 β 1.00 β 0.88 β
β request β 2.88.2 β 2.88.2 β 0.80 β 0.70 β 0.00 β 0.60 β 0.85 β 0.40 β 0.75 β
β outdated β 1.0.0 β 2.0.0 β 0.60 β 0.50 β 1.00 β 0.70 β 0.30 β 1.00 β 0.65 β
βββββββββββββββ΄βββββββββββ΄ββββββββββ΄βββββββββββ΄βββββββββββ΄βββββββββββ΄βββββββββββ΄βββββββββββ΄βββββββββββ΄βββββββββββ
π οΈ Usage
Basic Usage
npx dephealth
With Authentication Tokens
npx dephealth --github-token YOUR_GITHUB_TOKEN
npx dephealth --gitlab-token YOUR_GITLAB_TOKEN
npx dephealth --github-token YOUR_GITHUB_TOKEN --gitlab-token YOUR_GITLAB_TOKEN
Configuration Files
npx dephealth --init-config
npx dephealth --init-config myconfig.json
npx dephealth --config dephealth-config.json
npx dephealth --config dephealth-config.json --github-token YOUR_TOKEN
Help
npx dephealth --help
π― Scoring Algorithm
The health score is calculated using multiple metrics, each returning a value between 0 and 1:
π¦ Version Lag Score
- Major updates: Exponential penalty for breaking changes
- Minor updates: Linear penalty for new features
- Patch updates: Minimal penalty for bug fixes
π Vulnerability Score
- Critical: Weighted penalty of 0.6 each
- High: Weighted penalty of 0.4 each
- Moderate: Weighted penalty of 0.2 each
- Low: Weighted penalty of 0.1 each
- Total penalty: Capped at 1.0 (score = 1 - total penalty)
π Repository Metrics
- Maturity: Age (years active, capped at 10) Γ 0.6 + Release rate (releases/year, capped at 4) Γ 0.4
- Update Frequency: (releasesPerYear - 1) / (12 - 1), clamped to 0-1
- Deprecation: 0 if deprecated, 1 if not deprecated
- Dependency Health: Runtime deps (log-scaled, ideal β€5, poor β₯40) Γ 0.7 + Dev deps (log-scaled, ideal β€10, poor β₯80) Γ 0.3
- Downloads: log10(weeklyDownloads) / 6, capped at 1
- Issues: Normalized by popularity (issues per 10k downloads), log-scaled
π Score Boosters
Each metric can be boosted using multipliers:
- Booster > 1.0: Emphasizes the metric (higher scores become more important)
- Booster = 1.0: No change (default)
- Booster < 1.0: De-emphasizes the metric (lower scores become less important)
Example: A vulnerability booster of 5.0 means vulnerabilities have 5x more impact on the final score.
π§ Configuration
The tool works out of the box with sensible defaults. You can customize boosters using configuration files.
Configuration File Format
Create a configuration file using --init-config
:
{
"boosters": {
"maturity": 2,
"updateFrequency": 1,
"deprecation": 4,
"dependency": 1,
"download": 1,
"vulnerability": 2,
"issues": 1
}
}
Note: Configuration files are only for boosters. Tokens must be provided via CLI arguments.
Authentication Tokens
GitHub Token
- Create a personal access token at: https://github.com/settings/tokens
- Required scopes:
public_repo
(for public repositories)
- Helps avoid rate limiting and access private repositories
GitLab Token
Booster Configuration
Each metric can be customized with boosters:
- maturity: Repository age and activity (default: 2.0)
- updateFrequency: How often packages are updated (default: 1.0)
- deprecation: Penalty for deprecated packages (default: 4.0)
- dependency: Health of package dependencies (default: 1.0)
- download: Popularity based on downloads (default: 1.0)
- vulnerability: Security vulnerability impact (default: 2.0)
- issues: Open issues impact (default: 1.0)
π¦ Installation
Global Installation
npm install -g dephealth
Local Development
git clone https://github.com/your-username/dephealth.git
cd dephealth
npm install
npm run build
npm start
π Performance Features
- Concurrent Processing: Up to 10 parallel package analyses
- Progress Tracking: Real-time progress display with package count
- Error Recovery: Graceful handling of API failures
- Rate Limit Handling: Automatic handling of API rate limits
π€ Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
)
- Commit your changes (
git commit -m 'Add amazing feature'
)
- Push to the branch (
git push origin feature/amazing-feature
)
- Open a Pull Request
π License
This project is licensed under the MIT License - see the LICENSE file for details.
π Acknowledgments
- Built with TypeScript for type safety
- Uses
semver
for semantic versioning analysis
- Powered by
npm audit
and npm outdated
- Beautiful output with
chalk
and console-table-printer
- Concurrent processing with
p-limit
- GitHub and GitLab API integration