dev-utils-cli
v1.0.7
Published
A collection of useful development utility commands for git operations and project cleanup
Maintainers
Readme
Dev Utils CLI
A collection of useful development utility commands for git operations and project cleanup.
🚀 Quick Start
You can use these tools directly with npx without installing them globally:
# Git branch sync
npx git-sync-branches [remote-name]
# Delete node_modules folders
npx delete-node-modules [path]
# Or use the main CLI
npx dev-utils-cli --help📦 Available Commands
1. Git Branch Sync (git-sync-branches)
Syncs all branches from the origin remote to another remote repository.
# Sync all branches from origin to 'bu' remote (default)
npx git-sync-branches
# Sync all branches from origin to a custom remote
npx git-sync-branches backup
npx git-sync-branches upstreamWhat it does: Replicates this bash command with enhanced features:
git branch -r | grep "origin/" | grep -v "origin/HEAD" | sed 's/origin\///' | while read branch; do
echo "Pushing branch: $branch"
git push bu origin/$branch:$branch
doneFeatures:
- ✅ Error handling and validation
- ✅ Progress reporting
- ✅ Summary statistics
- ✅ Cross-platform compatibility
- ✅ Customizable target remote
- ✅ Help documentation
2. Delete Node Modules (delete-node-modules)
Recursively finds and deletes all node_modules folders in a directory tree.
# Interactive mode - will ask for path
npx delete-node-modules
# Delete from specific path
npx delete-node-modules /path/to/project
# Delete from current directory
npx delete-node-modules .Features:
- ✅ Recursive directory scanning
- ✅ Safety confirmation before deletion
- ✅ Progress reporting
- ✅ Error handling for permission issues
- ✅ Summary statistics
🛠️ Usage Examples
Git Branch Sync
# Basic usage - sync to 'bu' remote
npx git-sync-branches
# Sync to a different remote
npx git-sync-branches backup
# Show help
npx git-sync-branches --helpDelete Node Modules
# Interactive mode
npx delete-node-modules
# Clean specific directory
npx delete-node-modules ~/projects
# Clean current directory
npx delete-node-modules .
# Show help
npx delete-node-modules --helpMain CLI
# Show all available commands
npx dev-utils-cli --help
# Show version
npx dev-utils-cli --version📋 Requirements
- Node.js 12.0.0 or higher
- For git commands: Git repository with configured remotes
- For delete-node-modules: Appropriate file system permissions
🏗️ Project Structure
dev-utils-cli/
├── package.json # NPM package configuration
├── cli.js # Main CLI entry point
├── commands/ # Individual command modules
│ ├── sync-branches.js # Git branch sync command
│ └── delete-node-modules.js # Node modules cleanup command
├── lib/ # Shared utilities
│ ├── git-utils.js # Git-related helper functions
│ └── fs-utils.js # File system helper functions
└── README.md # This file🔧 Local Development
If you want to modify or contribute to these tools:
# Clone/download the files
# No dependencies required for basic functionality
# Test individual commands
node commands/sync-branches.js --help
node commands/delete-node-modules.js --help
# Test main CLI
node cli.js --help🚀 Publishing
To publish this as an npm package:
# Publish to npm (requires npm account)
npm publish
# Then anyone can use the commands
npx dev-utils-cli --help
npx git-sync-branches
npx delete-node-modules🤝 Adding New Commands
To add a new command:
- Create a new file in
commands/your-command.js - Add the shebang:
#!/usr/bin/env node - Export a function that handles the command logic
- Add the command to
package.jsonbin section - Update the main CLI help text
Example:
#!/usr/bin/env node
function showHelp() {
console.log("Your command help text");
}
module.exports = function (args) {
if (args.includes("-h") || args.includes("--help")) {
showHelp();
process.exit(0);
}
// Your command logic here
};📝 License
MIT
