|
| 1 | +# Commander Migration Status |
| 2 | + |
| 3 | +Goal: remove the abandoned `args` package, keep CLI behavior stable, and support packaging to a single bundled executable (Node SEA or similar). See `AGENTS.md` for broader architecture traps. |
| 4 | + |
| 5 | +## Migration Outcome |
| 6 | +- `src/lib/cli/command.js` is the active Commander-backed compatibility wrapper for all bins that call `command()`. |
| 7 | +- `args` has been removed from `package.json` and `npm-shrinkwrap.json`. |
| 8 | +- Root command flow (`src/bin/vip.js`) now dispatches via the shared Commander wrapper again, preserving login gating and subcommand chaining. |
| 9 | +- Temporary side-path wrapper work has been removed (`src/lib/cli/command-commander.ts` deleted). |
| 10 | + |
| 11 | +## Compatibility Behaviors Preserved |
| 12 | +- Legacy command contract stays the same: `command(opts).option(...).argv(process.argv, handler)`. |
| 13 | +- Alias behavior remains pre-parse: `@app` and `@app.env` are stripped before `--`; alias + `--app/--env` still errors. |
| 14 | +- `_opts` controls are still honored: app/env context fetch, confirmation gating, output formatting, wildcard command handling, required positional args. |
| 15 | +- Shared formatting/output and telemetry hooks are still in the wrapper path. |
| 16 | +- Local nested subcommand dispatch still works via sibling executable resolution. |
| 17 | + |
| 18 | +## Post-Migration Hardening |
| 19 | +- Short-flag compatibility was restored for long options without explicit aliases: |
| 20 | + - Example: `--elasticsearch` accepts `-e`, `--phpmyadmin` accepts `-p`, etc. |
| 21 | + - Auto-short generation skips reserved global flags (`-h`, `-v`, `-d`) and avoids duplicate collisions. |
| 22 | +- `vip dev-env exec` now performs bounded readiness checks before deciding an environment is not running. |
| 23 | +- `startEnvironment()` now includes bounded post-start readiness checks and one recovery `landoStart` retry if the environment stays `DOWN` after rebuild/start. |
| 24 | + |
| 25 | +## Remaining Technical Debt |
| 26 | +- `_opts` is still module-level state in `src/lib/cli/command.js` and can leak between command instances in one process. |
| 27 | +- Help text parity against historical `args` output is close but still a verification target for high-traffic commands. |
| 28 | +- Full dev-env E2E can still show Docker/Lando infrastructure flakiness (network cleanup and startup latency), which is environment-level, not parser-level. |
| 29 | + |
| 30 | +## Verification Commands |
| 31 | +- `npm run build` |
| 32 | +- `npm run check-types` |
| 33 | +- `npm run test:e2e:dev-env -- --runInBand __tests__/devenv-e2e/001-create.spec.js __tests__/devenv-e2e/005-update.spec.js` |
| 34 | +- `npm run test:e2e:dev-env -- --runInBand __tests__/devenv-e2e/008-exec.spec.js __tests__/devenv-e2e/010-import-sql.spec.js` |
| 35 | + |
| 36 | +## Single-Bundle Direction |
| 37 | +- Preferred: `esbuild` bundle rooted at `src/bin/vip.js`. |
| 38 | +- Keep native deps external (`@postman/node-keytar`) for SEA/packaging workflows. |
| 39 | +- Candidate build target: |
| 40 | + - `dist/vip.bundle.cjs` for SEA ingestion or launcher wrapping. |
| 41 | +- Example command: |
| 42 | + - `esbuild src/bin/vip.js --bundle --platform=node --target=node20 --format=cjs --outfile=dist/vip.bundle.cjs --banner:js="#!/usr/bin/env node" --external:@postman/node-keytar` |
| 43 | + |
| 44 | +## Next Refactor Steps |
| 45 | +1. Remove global `_opts` state from `src/lib/cli/command.js` by moving to per-instance configuration. |
| 46 | +2. Add parser contract tests for aliasing, wildcard behavior, and short/long boolean coercion. |
| 47 | +3. Add stable startup/readiness integration checks around dev-env commands in CI environments with Docker. |
| 48 | +4. Add bundling script(s) and SEA config proof-of-concept for a single-file executable artifact. |
0 commit comments