Skip to content

Commit def09c5

Browse files
committed
Doc updates
1 parent fc7ba9a commit def09c5

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

AGENTS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Guide for future agents working on this codebase. Focus on traps, cross-cutting
1414
- `_opts` knobs: `appContext`/`envContext`/`childEnvContext` run GraphQL lookups (using `appQuery` + optional fragments) and interactive prompts when `--app/--env` are missing; `childEnvContext` forbids production. `requiredArgs` enforces positional count; `wildcardCommand` disables subcommand validation. `format` adds `--format` defaulting to table and postprocesses handler results; `requireConfirm` + `--force` gates destructive paths with `enquirer` prompts; `skipConfirmPrompt` bypasses the prompt (used in tests).
1515
- Alias handling happens before parsing: `@app` or `@app.env` is stripped from `argv` in `envAlias.ts` (only before `--`) and populates `options.app/options.env`. Using both alias and `--app/--env` exits with an error.
1616
- Global flags injected everywhere: `--help/--version/--debug`. `--debug` enables `debug` namespaces (`*` when boolean). `update-notifier` runs after validation unless `NODE_ENV=test`.
17+
- Short-flag parity detail: if an option has no explicit short alias, the wrapper can auto-assign one from the first long-option character (for `args` compatibility), except reserved globals (`h`, `v`, `d`) and already-used short names.
1718
- Nested subcommands are dispatched by the wrapper to sibling bin scripts (`vip-config` -> `vip-config-envvar` -> `vip-config-envvar-set`) using local `dist/bin` paths when available.
1819
- Output contract: if handler returns `{header,data}` it prints header as key/value then formats `data`; if it returns an array it strips `__typename` and formats; returning `undefined` skips printing. Formatting uses `formatData` with `table|csv|json`.
1920
- Caveat: `_opts` is shared. Instantiating multiple command runners in one process (tests, composite commands) can leak settings—avoid or refactor.
@@ -49,6 +50,9 @@ Guide for future agents working on this codebase. Focus on traps, cross-cutting
4950
- Implemented under `src/lib/dev-environment/**`; shells out to Lando and Docker, renders templates from `assets/dev-env.*.ejs`, and writes to per-environment folders inside `xdgData()/vip-cli` (overridden by `XDG_DATA_HOME`). Running these commands mutates local docker networks and may fetch WP/PHP version metadata from GitHub constants.
5051
- Proxy helpers live in `src/lib/http/proxy-*`; dev-env code constructs agents automatically using `VIP_PROXY`/`SOCKS_PROXY`/`HTTP_PROXY`/`VIP_USE_SYSTEM_PROXY`. Unexpected proxies can break downloads—clear those env vars when debugging.
5152
- Avoid invoking dev-env logic in unit tests unless you mock `lando`, filesystem, and network; the E2E suite covers the real paths.
53+
- Runtime resilience safeguards:
54+
- `startEnvironment()` performs bounded readiness checks after start/rebuild and attempts one recovery `landoStart` pass if status remains down.
55+
- `vip-dev-env-exec` performs bounded readiness polling before failing with "running environment required", reducing false negatives under heavy Docker/Lando load.
5256

5357
## Import/Export/Sync Commands (high validation)
5458
- Heavy validators live in `src/lib/site-import/**` and `src/lib/validations/**`. `vip import sql` enforces file name rules, extension checks, size caps (`SQL_IMPORT_FILE_SIZE_LIMIT*`), and detects multisite; it may upload to S3 via `src/lib/client-file-uploader.ts` (expects readable file or URL and optional MD5). These paths also emit analytics; use `NODE_ENV=test` and stubs to avoid network.

docs/COMMANDER-MIGRATION.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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

Comments
 (0)