Skip to content

devemit/npm-dependency-checker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

cli-depsnap

A high-performance CLI tool for checking npm dependencies, security vulnerabilities, and update recommendations.

πŸš€ Features

  • High Performance: Parallel processing, intelligent caching, and connection pooling
  • Comprehensive Analysis: Check dependencies, security vulnerabilities, and update recommendations
  • Multiple Output Formats: Table, JSON, and CSV output formats
  • Security Auditing: Built-in security vulnerability scanning
  • Update Recommendations: Smart update suggestions with breaking change warnings
  • Flexible Configuration: Customizable depth, concurrency, and filtering options

πŸ“¦ Installation

# Install globally
npm install -g cli-depsnap

# Or use npx
npx cli-depsnap

# Or install locally
npm install cli-depsnap

🎯 Quick Start

# Check dependencies in current directory
depsnap check

# Check with custom options
depsnap check --path ./package.json --depth 2 --parallel 20

# Security audit
depsnap audit --severity moderate

# Get update recommendations
depsnap update --major --dry-run

πŸ“‹ Commands

Check Dependencies

depsnap check [options]

Options:

  • -p, --path <path> - Path to package.json file (default: ./package.json)
  • -d, --depth <number> - Depth of dependency tree to check (default: 1)
  • --no-cache - Disable caching for fresh results
  • --parallel <number> - Number of parallel requests (default: 10)
  • --format <format> - Output format: table, json, csv (default: table)

Examples:

# Basic check
depsnap check

# Deep dependency analysis
depsnap check --depth 3 --parallel 20

# JSON output for CI/CD
depsnap check --format json

# Check specific package.json
depsnap check --path ./frontend/package.json

Security Audit

depsnap audit [options]

Options:

  • -p, --path <path> - Path to package.json file (default: ./package.json)
  • --severity <level> - Minimum severity level: low, moderate, high, critical (default: moderate)
  • --fix - Automatically fix vulnerabilities where possible

Examples:

# Basic security audit
depsnap audit

# High severity only
depsnap audit --severity high

# Auto-fix vulnerabilities
depsnap audit --fix

Update Recommendations

depsnap update [options]

Options:

  • -p, --path <path> - Path to package.json file (default: ./package.json)
  • --major - Include major version updates
  • --dry-run - Show what would be updated without making changes

Examples:

# Get update recommendations
depsnap update

# Include major updates
depsnap update --major

# Preview changes
depsnap update --dry-run

⚑ Performance Features

Parallel Processing

  • Configurable concurrency limits for API requests
  • Batch processing of dependency checks
  • Efficient dependency tree traversal

Intelligent Caching

  • In-memory caching with configurable TTL
  • Cache statistics and hit/miss ratios
  • Cache bypass option for fresh results

Connection Pooling

  • HTTP/HTTPS connection reuse
  • Configurable socket limits
  • Keep-alive connections for better performance

Memory Optimization

  • Streaming file processing for large package.json files
  • Efficient data structures for dependency trees
  • Garbage collection friendly code patterns

πŸ“Š Output Formats

Table Format (Default)

πŸ“¦ Dependency Check Report
────────────────────────────────────────────────────────────────────────────────
Package: [email protected]
Path: /path/to/package.json

πŸ“Š Summary:
  Total dependencies: 15
  Up to date: 12
  Outdated: 3
  Major updates: 1
  Minor updates: 1
  Patch updates: 1
  Vulnerabilities: 0

πŸ“‹ Dependencies:
────────────────────────────────────────────────────────────────────────────────
Package                    Current         Latest          Update     Type            Vulns   Status
────────────────────────────────────────────────────────────────────────────────
lodash                     4.17.20         4.17.21         patch      dependencies    0       πŸ”§
axios                      1.5.0           1.6.0           minor      dependencies    0       πŸ”„
react                      17.0.2          18.2.0          major      dependencies    0       ⚠️

JSON Format

{
  "package": {
    "name": "my-app",
    "version": "1.0.0"
  },
  "summary": {
    "total": 15,
    "upToDate": 12,
    "outdated": 3,
    "majorUpdates": 1,
    "minorUpdates": 1,
    "patchUpdates": 1,
    "vulnerabilities": 0
  },
  "dependencies": [...]
}

CSV Format

Package,Current Version,Latest Version,Update Type,Dependency Type,Vulnerabilities,Update Available
lodash,4.17.20,4.17.21,patch,dependencies,0,true
axios,1.5.0,1.6.0,minor,dependencies,0,true

πŸ”§ Configuration

Environment Variables

  • DEBUG - Enable debug logging
  • NPM_REGISTRY - Custom npm registry URL
  • CACHE_TTL - Cache time-to-live in seconds

Performance Tuning

# High concurrency for large projects
depsnap check --parallel 50

# Disable cache for fresh results
depsnap check --no-cache

# Shallow dependency tree for speed
depsnap check --depth 1

πŸ› οΈ Development

Prerequisites

  • Node.js >= 18.0.0
  • npm >= 8.0.0

Setup

# Clone repository
git clone https://github.com/devemit/npm-dependency-checker.git
cd npm-dependency-checker

# Install dependencies
npm install

# Run in development mode
npm run dev

# Run tests
npm test

# Lint code
npm run lint

# Format code
npm run format

Project Structure

npm-dependency-checker/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ cli.js              # Main CLI entry point
β”‚   β”œβ”€β”€ commands/
β”‚   β”‚   β”œβ”€β”€ check.js        # Dependency check logic
β”‚   β”‚   β”œβ”€β”€ audit.js        # Security audit
β”‚   β”‚   └── update.js       # Update recommendations
β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”œβ”€β”€ npm-registry.js # npm registry API client
β”‚   β”‚   β”œβ”€β”€ cache.js        # Caching layer
β”‚   β”‚   └── parser.js       # Package.json parser
β”‚   └── utils/
β”‚       └── output.js       # Output formatting
β”œβ”€β”€ tests/
β”œβ”€β”€ package.json
└── README.md

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the ISC License.

πŸ™ Acknowledgments

About

www.npmjs.com/package/cli-depsnap

Releases

No releases published

Packages

No packages published