Dependencies Evolution Analyzer
π Advanced CLI tool to analyze dependency evolution, release frequency, and semver patterns in JavaScript/Node.js projects.
Features
- π Auto-discovery: Finds package.json files in directories or glob patterns
- π NPM Analysis: Fetches release data from NPM registry with smart filtering
- π·οΈ Semver Analysis: Detailed breakdown of major/minor/patch releases
- π
Time-based Analysis: Compares releases from different time periods (12m vs 12-24m)
- π Multiple Outputs: Generates both JSON and Markdown reports
- π Multiple Projects: Analyze multiple patterns/projects in one command
- β‘ Fast: Built-in NPM CLI integration and efficient processing
- π‘οΈ Robust: Handles errors gracefully and continues processing
- π§ Smart Filtering: Automatically filters dev/beta/alpha/nightly versions
Installation
Local Development
git clone <repository-url>
cd deps-analyzer
npm install
Using npm link for testing
npm run link
deps-analyzer --help
npm run unlink
π Documentation
For detailed information on specific topics:
Usage
Basic Usage
deps-analyzer ./templates
deps-analyzer ./package.json
deps-analyzer "projects/**/package.json"
Multiple Projects
deps-analyzer templates/next-app templates/react-spa-vite --output selected-projects
deps-analyzer ./frontend ./backend/package.json --output fullstack-analysis
Advanced Options
deps-analyzer ./templates --months 18
deps-analyzer ./templates --output my-report
deps-analyzer ./templates --no-npm
deps-analyzer ./templates --use-http
deps-analyzer ./templates --internal-libs "@akad/*,design-system*"
deps-analyzer ./templates --ignore-filter alpha,beta,rc
deps-analyzer ./templates --internal-libs "@company/*" --ignore-filter canary,nightly
deps-analyzer ./templates --max-deps-config ./my-constraints.json
echo '{"react": "^18.0.0", "typescript": "^5.0.0"}' > max-deps.json
deps-analyzer ./project --max-deps-config max-deps.json
deps-analyzer --help
deps-analyzer --version
Scope Filtering
Analyze only internal or external dependencies using --scope:
deps-analyzer ./templates --scope=internal --internal-libs "@company/*"
deps-analyzer ./templates --scope=external --internal-libs "@company/*"
deps-analyzer ./templates --scope=all --internal-libs "@company/*"
Max-Deps Configuration Examples
Strategic version control with custom configuration files:
deps-analyzer ./templates --max-deps-config ./configs/production.json
deps-analyzer ./templates --max-deps-config /shared/team-constraints.json
deps-analyzer ./templates --max-deps-config ./benchmarks/zero-drift.json --output benchmark
deps-analyzer ./microservices --max-deps-config ./security/approved-versions.json
Output
The tool generates two files with comprehensive analysis:
JSON Report (<output>.json)
{
"metadata": {
"generatedAt": "2025-08-14T00:26:31.877Z",
"period": "24 months",
"totalProjects": 2,
"totalDependencies": 52,
"uniqueDependencies": 36,
"globalUniqueReleases": {
"totalLast12m": 1130,
"totalLast12to24m": 983,
"avgPerMonthLast12m": 94.17,
"avgPerMonthLast12to24m": 81.92,
"semverBreakdown": {
"majorLast12m": 26,
"minorLast12m": 165,
"patchLast12m": 597,
"avgMajorPerMonthLast12m": 2.17,
"avgMinorPerMonthLast12m": 13.75,
"avgPatchPerMonthLast12m": 49.75
}
}
},
"projects": {
"react-spa-vite": {
"packagePath": "/path/to/package.json",
"dependencyCount": 32,
"dependencies": {
"react": {
"currentVersion": "19.1.1",
"last12Months": 3,
"months12to24": 2,
"totalReleases": 345,
"avgReleasesPerMonthLast12m": 0.25,
"avgReleasesPerMonthLast12to24m": 0.17,
"avgDaysBetweenReleases": 14.6,
"semverBreakdown": {
"majorLast12m": 1,
"minorLast12m": 1,
"patchLast12m": 1,
"majorLast12to24m": 0,
"minorLast12to24m": 1,
"patchLast12to24m": 1
},
"monthlyBreakdown": {
"2024-12": ["19.0.0"],
"2025-03": ["19.1.0"],
"2025-07": ["19.1.1"]
},
"mostActiveMonth": "2024-12 (1)"
}
},
"metadata": {
"totalReleasesLast12m": 672,
"totalReleasesLast12to24m": 655,
"totalReleases": 6429,
"avgReleasesPerMonthLast12m": 56,
"avgReleasesPerMonthLast12to24m": 54.58,
"semverBreakdown": {
"totalMajorLast12m": 22,
"totalMinorLast12m": 140,
"totalPatchLast12m": 419,
"avgMajorPerMonthLast12m": 1.83,
"avgMinorPerMonthLast12m": 11.67,
"avgPatchPerMonthLast12m": 34.92
}
}
}
}
}
Markdown Report (<output>.md)
# Dependencies Evolution Report
## Summary
- **Generated at:** 2025-08-14 00:26:31 UTC
- **Analysis period:** 24 months
- **Projects analyzed:** 2
- **Total dependencies:** 52
- **Unique dependencies:** 36
## Global Statistics
- **Total releases (12m):** 1,130 (avg: 94.17/month)
- **Total releases (12-24m):** 983 (avg: 81.92/month)
- **Semver breakdown (12m):** 26 major, 165 minor, 597 patch
## Project: react-spa-vite (32 dependencies)
### Dependencies Release Activity (Last 12m vs 12-24m)
| Package | Current | 12m | 12-24m | Major | Minor | Patch | Most Active Month |
|---------|---------|-----|--------|-------|-------|-------|-------------------|
| react | 19.1.1 | 3 | 2 | 1 | 1 | 1 | 2024-12 (1) |
API
Programmatic Usage
const { main } = require('deps-analyzer');
const result = await main(['./templates']);
const result = await main([
'./templates/next-app',
'./templates/react-spa-vite'
]);
const result = await main(['./templates'], {
months: 18,
output: 'custom-report',
analyzeNpm: true,
useNpmCli: true
});
Options Reference
--months <number> | 24 | Analysis period in months |
--output <path>, -o | dependency-report | Output file base name |
--scope <type> | all | Filter dependencies by scope: internal, external, all |
--no-npm | false | Skip NPM registry analysis (discovery only) |
--use-http | false | Use HTTP requests instead of npm CLI (slower) |
--ignore-filter <list> | [] | Skip filtering specific version types (alpha,beta,rc,etc) |
--internal-libs <list> | [] | Libraries to include alpha/beta versions (supports wildcards: @akad/,design-system) |
--max-deps-config <path> | null | Custom max-deps.json file path for strategic version control |
--help, -h | - | Show help information |
--version, -v | - | Show version |
Examples
Template Repository Analysis
deps-analyzer ./templates --months 12 --output templates-report
deps-analyzer templates/next-app templates/react-spa-vite --output selected-templates
Monorepo Analysis
deps-analyzer "packages/*/package.json" --months 18
deps-analyzer packages/frontend packages/backend packages/shared --output monorepo-analysis
Quick Dependency Discovery
deps-analyzer ./project --no-npm
deps-analyzer ./project --no-npm --use-http
Enterprise Usage
deps-analyzer ./microservices ./shared-libs --months 36 --output enterprise-deps
Advanced Filtering
Filtering Strategy Hierarchy
The tool applies filtering in a specific order to ensure predictable results:
- Scope Filtering (
--scope): First, filter dependencies by scope (internal, external, all)
- Internal Library Classification (
--internal-libs): Classify remaining dependencies as internal/external
- Selective Version Filtering: Apply different filtering rules based on classification
- Filter Overrides (
--ignore-filter): Override specific version type filtering
Internal vs External Dependencies
The tool implements selective filtering that treats internal and external dependencies differently:
- External Dependencies: Automatically filters out pre-release versions (alpha, beta, rc, etc.)
- Internal Dependencies: Can include pre-release versions when specified via
--internal-libs
Scope Filtering Behavior
--scope=internal: Analyze only dependencies matching --internal-libs patterns
--scope=external: Analyze only dependencies NOT matching --internal-libs patterns
--scope=all: Analyze all dependencies (default), but still apply selective filtering logic
Pattern Matching
The --internal-libs flag supports wildcard patterns:
deps-analyzer ./project --internal-libs "my-package"
deps-analyzer ./project --internal-libs "@company/*"
deps-analyzer ./project --internal-libs "@company/*,design-system*,@internal/*"
Filtering Override
Use --ignore-filter to skip specific version type filtering:
deps-analyzer ./project --ignore-filter alpha
deps-analyzer ./project --ignore-filter alpha,beta,rc
deps-analyzer ./project --internal-libs "@company/*" --ignore-filter canary,nightly
Practical Examples
Enterprise Monorepo Analysis
deps-analyzer ./packages/* \
--internal-libs "@acme/*,design-tokens*" \
--ignore-filter canary \
--output enterprise-analysis
Mixed Public/Private Dependencies
deps-analyzer ./apps/frontend ./apps/backend \
--internal-libs "@company/*,internal-*" \
--output mixed-dependencies
Historical Analysis with Custom Filters
deps-analyzer ./legacy-projects \
--ignore-filter alpha,beta,rc,canary,experimental \
--output legacy-comprehensive
Understanding the Output
Portfolio vs Project Metrics
The tool provides two different types of drift/pulse calculations that serve different purposes:
π’ Global/Portfolio Metrics (Unique Dependencies)
- What it measures: Drift/pulse for each dependency once per portfolio
- Calculation: Sums drift only from unique dependencies across all projects
- Example: If
react appears in 4 projects, its drift is counted only once
- Use case: Strategic decisions - "Which dependencies should we prioritize updating?"
π Project Metrics (Total Across Projects)
- What it measures: Drift/pulse for every occurrence of each dependency
- Calculation: Sums drift from all dependencies in all projects
- Example: If
react appears in 4 projects, its drift is counted 4 times
- Use case: Effort estimation - "How much total work is needed to update everything?"
π‘ Example: 4 Projects with React (2y drift)
Scenario:
- 4 projects each use
react with 2 years of drift
- Each project also has
lodash with 1 year of drift
Global Drift (Unique Dependencies):
react: 2 years (counted once)
lodash: 1 year (counted once)
- Total: 3 years
Project Drift (Sum Across Projects):
- Project 1:
react (2y) + lodash (1y) = 3y
- Project 2:
react (2y) + lodash (1y) = 3y
- Project 3:
react (2y) + lodash (1y) = 3y
- Project 4:
react (2y) + lodash (1y) = 3y
- Total: 12 years
π― When to Use Each Metric
| Prioritizing which deps to update | β
Focus on unique deps | β May mislead priorities |
| Estimating update effort/time | β Underestimates work | β
Shows true scope |
| Executive reporting | β
Clear strategic view | β May seem inflated |
| Sprint planning | β Doesn't show full work | β
Shows actual tasks |
| Ecosystem health assessment | β
True portfolio state | β Duplicated concerns |
Semver Analysis
The tool performs intelligent semver analysis:
- Major: Breaking changes (1.0.0 β 2.0.0)
- Minor: New features (1.0.0 β 1.1.0)
- Patch: Bug fixes (1.0.0 β 1.0.1)
Smart Filtering
Automatically filters out:
- Development versions (
-dev, -nightly)
- Alpha/Beta releases (
-alpha, -beta)
- Release candidates (
-rc)
- Experimental builds (
-experimental, -canary)
- Malformed versions (
0.0.0-*)
Backport Detection
The tool detects version backports/downgrades:
- Total releases include all stable versions
- Semver breakdown only counts progressive releases
- Difference represents maintenance releases for older versions
Technical Details
- Rate Limiting: Intelligent batching with NPM CLI
- Error Handling: Continues processing even if some packages fail
- Ignores:
node_modules/, public/, dist/, build/ directories
- Node Version: Requires Node.js >= 16.0.0
- NPM Version: Works with npm >= 7.0.0
Development
Project Structure
deps-analyzer/
βββ package.json
βββ README.md
βββ bin/
β βββ deps-analyzer.js # CLI entry point
βββ lib/
β βββ index.js # Core logic & discovery
β βββ npm-client.js # NPM registry client
β βββ libyear.js # Drift/pulse calculations
β βββ reporter.js # Report generation
βββ utils/ # Utility functions
βββ chunkArray.js # Array chunking
βββ cleanVersion.js # Version cleaning
βββ filterDependenciesByScope.js # Dependency filtering
βββ findMaxAllowedVersion.js # Version constraint parsing
βββ findWorkspaceRoot.js # Workspace detection
βββ isInternalLib.js # Internal library matching
βββ parsePnpmLock.js # PNPM lock file parsing
βββ parseYarnLock.js # Yarn lock file parsing
βββ versionSatisfiesConstraint.js # Semver constraint checking
Scripts
npm run start
npm run test
npm run dev
npm run link
npm run unlink
Debugging
DEBUG=1 deps-analyzer ./templates
deps-analyzer ./templates --use-http
Troubleshooting
Common Issues
npm CLI not found
deps-analyzer ./templates --use-http
Permission errors
npm config get prefix
npm config get cache
Network timeouts
npm config set timeout 60000
deps-analyzer ./templates
Memory issues with large projects
deps-analyzer ./project1 --output report1
deps-analyzer ./project2 --output report2
Performance
Benchmarks
- Small project (10 deps): ~2-5 seconds
- Medium project (50 deps): ~10-20 seconds
- Large monorepo (200+ deps): ~1-3 minutes
Optimization Tips
- Use npm CLI mode (default) for better performance
- Analyze fewer projects simultaneously for large codebases
- Use
--no-npm for quick dependency discovery
License
MIT
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature)
- Commit your changes (
git commit -m 'Add some amazing feature')
- Push to the branch (
git push origin feature/amazing-feature)
- Create a Pull Request
Development Guidelines
- Maintain backward compatibility
- Add tests for new features
- Update documentation
- Follow existing code style
Built with β€οΈ for better dependency management and DevOps insights