You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(version): implement --version flag and version subcommand
Closes PRO-174.
Adds two surfaces over the same model:
- `prisma-cli --version` — universal early-exit utility flag at the root.
Prints `prisma-cli <version>` to stdout in human mode; emits the standard
success envelope (`command: "version"`, `result: {version}`) when
combined with `--json`. Requires no auth, no project context, no network.
- `prisma-cli version` — top-level subcommand (peer to auth / branch /
project / app) that uses the `show` output pattern. Reports the full
environment block: CLI name + version, Node version, OS platform/arch,
best-effort invocation label (bunx | npx | global | dev | unknown).
Implementation:
- New `lib/version.ts` reads the bundled package metadata via
`createRequire(import.meta.url)` so it works under both tsx dev mode and
the tsdown-unbundled `dist/` output. Throws `VERSION_UNAVAILABLE`
(defensive; not expected) if metadata cannot be read.
- New `controllers/version.ts`, `presenters/version.ts`, `commands/version/`
follow the same controller / presenter / command shape as `auth`.
- New `types/version.ts` defines `VersionResult` and `VersionInvocation`.
- `cli.ts` intercepts `--version` in argv before commander dispatches
(mirrors the existing bare-help short-circuit). The bare-help resolver
now skips leaf commands so `prisma-cli version` runs its action instead
of being treated as a group-help command.
- `shell/command-meta.ts` registers the `version` descriptor.
- `shell/global-flags.ts` adds `--version` to `COMPACT_GLOBAL_OPTION_FLAGS`
so help rendering still surfaces the "Global options:" header at the
program root.
Tests:
- `tests/version.test.ts` — 8 cases covering the flag, the subcommand,
both with `--json`, no-auth/no-project/no-network preconditions, help
inclusion, and `--version` overriding subcommand parsing when both
appear in argv.
All 178 existing + new tests pass. Build clean. No regressions on auth,
project, branch, or app surfaces.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0 commit comments