Skip to content

Add file migration system with CLI and comprehensive test coverage#3

Merged
rwdaigle merged 7 commits intomainfrom
ryan/fix-cli-global-install
Jan 21, 2026
Merged

Add file migration system with CLI and comprehensive test coverage#3
rwdaigle merged 7 commits intomainfrom
ryan/fix-cli-global-install

Conversation

@rwdaigle
Copy link
Copy Markdown
Contributor

@rwdaigle rwdaigle commented Jan 21, 2026

Summary

  • Implement file migration system with CLI for applying ordered transformations to project directories
  • Add status, up, and create CLI commands for managing migrations
  • Bundle CLI with esbuild for reliable global installation
  • Support .ts, .mjs, and .js migration file extensions
  • Add comprehensive test coverage for all core modules (engine, loader, state, cli)

Changes

  • Core migration engine with state tracking via .history file
  • Migration loader supporting TypeScript and JavaScript files
  • CLI commands: status, up (with --dry-run), create
  • esbuild bundling for self-contained CLI distribution
  • CI workflow with build, lint, format, and test checks
  • Project tooling: ESLint, Prettier, Husky, lint-staged

Test Plan

  • Unit tests for engine, loader, and state modules
  • Integration tests for CLI commands
  • Tests for migration file format compatibility (.ts, .mjs, .js)
  • All tests pass: npm test

🤖 Generated with Claude Code

rwdaigle and others added 7 commits January 21, 2026 07:56
Bundle the CLI into a self-contained CommonJS file using esbuild to ensure reliable execution when installed globally. This resolves runtime dependency resolution issues by:
- Bundling all dependencies into a single file (dist/cli.cjs)
- Injecting the version at build time via esbuild defines
- Using .cjs extension to ensure Node treats it as CommonJS in an ESM package

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Merged linting/prettier setup from main while keeping esbuild bundling changes.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Test that builds the CLI and verifies all commands execute correctly:
- Binary execution with help and version output
- status command showing pending/applied migrations
- up command applying migrations and dry-run mode
- create command generating migration files
- Error handling with proper exit codes
- Custom migrations directory support

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Build scripts use Node.js globals (console) that ESLint doesn't recognize
without additional configuration. Simplest fix is to exclude them.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The bundled CLI couldn't load TypeScript migration files in plain Node.js
environments because Node.js doesn't natively understand .ts files.

Changes:
- Update loader to support .ts, .mjs, and .js migration file extensions
- Update CLI tests to use .mjs files which work in all Node.js environments
- Add tests for the new extension support

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Document `npm run format` in CLAUDE.md and clarify auto-fix commands
in the final-review skill.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add explicit tests that verify .mjs and .js migration files work correctly
with the bundled CLI. These tests clear NODE_OPTIONS to simulate a clean
environment without TypeScript loaders.

Background: The CI failure occurred because Node.js 20 (used in CI) cannot
natively import .ts files, while Node.js 24 (used locally) has experimental
TypeScript support. The tests document this behavior and ensure .mjs/.js
files work across all Node versions.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@rwdaigle rwdaigle changed the title Fix CLI global installation with esbuild bundling Add file migration system with CLI and comprehensive test coverage Jan 21, 2026
@rwdaigle rwdaigle merged commit efe41f7 into main Jan 21, 2026
2 checks passed
@rwdaigle rwdaigle deleted the ryan/fix-cli-global-install branch January 21, 2026 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant