safe-npm-updater
v1.0.2
Published
Intelligent npm package updater with safety checks, impact analysis, and rollback capabilities
Downloads
31
Maintainers
Readme
safe-npm-updater
Intelligent npm package updater with safety checks, impact analysis, and rollback capabilities.
Features
- 📊 Smart Analysis: Analyze outdated packages with risk categorization
- 🔒 Safety First: Create automatic snapshots before updates
- 🧪 Impact Testing: Test updates in isolation before applying
- ⏮️ Easy Rollback: Restore previous package states instantly
- 🔍 Dependency Insights: Understand why packages are installed
- 🎯 Interactive Mode: Choose exactly which packages to update
- 🚨 Security Focused: Prioritize security vulnerability fixes
Installation
npm install -g safe-npm-updaterOr use with npx:
npx safe-npm-updaterUsage
Analyze Packages
Check for outdated packages and security issues:
safe-npm-updater analyzeOptions:
-s, --security- Show only security updates-v, --verbose- Show detailed information
Update Packages
Update packages with interactive selection:
safe-npm-updater updateOptions:
-i, --interactive- Select packages interactively (default)-s, --security- Update only security fixes--safe- Update only patch versions--all- Update all packages (with confirmation)--skip-tests- Skip running tests
Examples:
# Interactive mode
safe-npm-updater update
# Only security updates
safe-npm-updater update --security
# Only safe patch updates
safe-npm-updater update --safe
# Update all packages
safe-npm-updater update --allTest Package Updates
Test the impact of updating a specific package before applying:
safe-npm-updater test [email protected]This will:
- Create a temporary git branch (if using git)
- Apply the update
- Run your test suite
- Check TypeScript compilation (if applicable)
- Report results without affecting your current state
Rollback
Restore packages to a previous snapshot:
safe-npm-updater rollbackInteractively select from available snapshots to restore.
Why Command
Get detailed information about a package:
safe-npm-updater why lodashShows:
- Package information
- Whether it's a direct or transitive dependency
- Dependency tree
- Deprecation status
How It Works
Risk Categorization
safe-npm-updater categorizes updates by risk level:
- 🚨 CRITICAL - Security vulnerabilities
- ⚠️ BREAKING - Major version updates
- 📝 MODERATE - Minor version updates
- ✓ SAFE - Patch version updates
Snapshot System
Before every update, safe-npm-updater automatically creates a snapshot of:
package.jsonpackage-lock.json
Snapshots are stored in .smart-updater/snapshots/ (added to .gitignore automatically).
Impact Testing
The test command creates an isolated environment to verify updates:
- Creates a temporary git branch
- Applies the package update
- Runs
npm test - Checks TypeScript compilation (if
tsconfig.jsonexists) - Reports results
- Cleans up (switches back and deletes test branch)
Configuration
safe-npm-updater works with your existing project configuration:
- Reads test command from
package.jsonscripts - Detects TypeScript projects automatically
- Works with both npm and yarn (detects from lock file)
- Integrates with git for advanced features
Requirements
- Node.js >= 18.0.0
- npm or yarn
- Git (optional, for advanced features)
Project Structure
safe-npm-updater/
├── src/
│ ├── cli/ # CLI entry point
│ ├── commands/ # Command implementations
│ ├── core/ # Core logic (analyzer, updater, tester)
│ ├── utils/ # Utilities (npm, git, files, logger)
│ └── types/ # TypeScript interfaces
├── dist/ # Compiled output
└── package.jsonDevelopment
Build the project:
npm run buildRun in development mode:
npm run devLink for local testing:
npm linkSecurity
safe-npm-updater follows security best practices:
- Input validation for all user inputs
- Sanitized package names before registry calls
- No code execution from external sources
- Read-only operations where possible
- Confirmation required for destructive operations
License
ISC
Contributing
Contributions are welcome! Please feel free to submit issues and pull requests to the GitHub repository:
Repository: https://github.com/zubair-ra/smart-updater
- 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) - Open a Pull Request
Author
Created with ❤️ for safer npm package updates by @mzubair746r
