hero-migration
v1.3.5
Published
Automatically clean migration-generated file changes while preserving your own changes
Maintainers
Readme
hero-migration
Automatically clean migration-generated file changes while preserving your own changes. Zero configuration required!
Installation
Local Installation (Recommended)
npm install --save-dev hero-migration
# or
yarn add -D hero-migrationGlobal Installation (Optional)
npm install -g hero-migration
# or
yarn global add hero-migrationThat's it! The package will automatically:
- ✅ Install pre-commit hook
- ✅ Create
.git-exclude-list.exampletemplate - ✅ Set up everything you need
Note: After local installation, use npx hero-migration or add ./node_modules/.bin to your PATH.
Quick Start
Copy the exclude list template:
cp .git-exclude-list.example .git-exclude-listEdit
.git-exclude-listand add files you want to exclude (one per line):package.json babel.config.json .gitlab-ci.ymlRun migration and save snapshot:
# Run migration (automatically saves snapshot and adds files to exclude list) hero-migration # or with npx (if installed locally) npx hero-migration # Or manually save snapshot after migration hero-migration saveCommit normally - changes will be auto-cleaned! 🎉
Commands
hero-migration (default)
Run momo-migration, automatically save snapshot, and add changed files to .git-exclude-list.
Usage:
hero-migration
# or with npx (if installed locally)
npx hero-migrationhero-migration save
Save snapshot of migration files. Run this immediately after running your migration tool.
hero-migration clean
Manually clean migration changes while preserving your changes.
hero-migration status
Show which files have user changes vs migration-only changes.
Legacy commands (still available):
git-migration-save→hero-migration savegit-migration-clean→hero-migration cleangit-migration-status→hero-migration status
How It Works
- After migration: Run
git-migration-saveto snapshot migration-generated files - Make your changes: Edit files normally
- On commit: Pre-commit hook automatically:
- Discards files that only have migration changes
- Cleans migration changes from files that have your changes
- Preserves your changes automatically
Example Workflow
# 1. Run migration (automatically saves snapshot and adds files to exclude list)
hero-migration
# This will:
# - Run momo-migration
# - Detect changed files
# - Add them to .git-exclude-list
# - Save migration snapshot
# 2. Make your changes
vim package.json # Add your dependencies
# 3. Commit - hook automatically handles cleanup!
git add .
git commit -m "Add my feature"
# ✅ Only your changes are committed!Alternative workflow (manual steps):
# 1. Run your migration tool
momo-migration
# 2. Save snapshot manually
hero-migration save
# 3. Make your changes and commitConfiguration
.git-exclude-list
List of files to exclude from commits (one per line). Comments start with #.
Example:
# Migration-generated files
package.json
babel.config.json
.gitlab-ci.yml
# Build artifacts
sourcemap/
coverage/.git-exclude-list.local
Personal exclude list (not tracked in git). Same format as .git-exclude-list.
Features
- 🚀 Zero configuration - Works out of the box
- 🧹 Automatic cleanup - Pre-commit hook handles everything
- 💾 Smart detection - Only cleans migration changes, preserves yours
- 🔄 Works with any migration tool - Not tied to specific tools
- 📦 Lightweight - No heavy dependencies
Troubleshooting
Hook not running?
# Make sure hook is executable
chmod +x .git/hooks/pre-commit
# Test hook manually
.git/hooks/pre-commitNeed to commit excluded file anyway?
# Temporarily remove from exclude list, commit, then add back
# Or use --no-verify to skip hooks (not recommended)
git commit --no-verifySee what files are staged?
git status
git diff --cached --name-onlyLicense
MIT
