migration-cleaner
v1.0.0
Published
Automatically clean migration-generated file changes while preserving your own changes
Maintainers
Readme
migration-cleaner
Automatically clean migration-generated file changes while preserving your own changes. Zero configuration required!
Installation
npm install --save-dev migration-cleaner
# or
yarn add -D migration-cleanerThat's it! The package will automatically:
- ✅ Install pre-commit hook
- ✅ Create
.git-exclude-list.exampletemplate - ✅ Set up everything you need
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.ymlAfter running migration, save snapshot:
git-migration-save # or migration-cleaner saveCommit normally - changes will be auto-cleaned! 🎉
Commands
git-migration-save or migration-cleaner save
Save snapshot of migration files. Run this immediately after running your migration tool.
git-migration-clean or migration-cleaner clean
Manually clean migration changes while preserving your changes.
git-migration-status or migration-cleaner status
Show which files have user changes vs migration-only changes.
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 your migration tool
momo-migration
# 2. Save snapshot
git-migration-save
# 3. Make your changes
vim package.json # Add your dependencies
# 4. Commit - hook automatically handles cleanup!
git add .
git commit -m "Add my feature"
# ✅ Only your changes are committed!Configuration
.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
