From db73714309c9a91b0244ca98049f873faff4b97f Mon Sep 17 00:00:00 2001 From: Steven McClankerton Date: Mon, 16 Nov 2026 17:30:32 +0000 Subject: [PATCH 1/2] test(cli): prove every Prisma 7 path and flag settles as the v7 error Adds an in-process inventory test that builds the CLI with the released families the shell mounts and checks all 24 Prisma 7 command paths and 13 Prisma 7-only flags answer with CLI.V7_COMMAND or CLI.V7_FLAG, exit 2, the prisma7 install sentence, and next actions that name mounted commands and appear in human output. Removes the engine-peer conformance exceptions for composer-cli and orm-toolchain: both pinned releases now peer @prisma/cli-engine 0.10.0. Documents the conditional install sentence the ORM's migrate entries use. Co-Authored-By: Claude Opus 5.5 --- docs/reference/error-reference.md | 2 +- packages/cli/scripts/conformance.ts | 19 +-- packages/cli/tests/v7-inventory.test.ts | 182 ++++++++++++++++++++++++ 3 files changed, 184 insertions(+), 19 deletions(-) create mode 100644 packages/cli/tests/v7-inventory.test.ts diff --git a/docs/reference/error-reference.md b/docs/reference/error-reference.md index 9c2379d8..c197eee8 100644 --- a/docs/reference/error-reference.md +++ b/docs/reference/error-reference.md @@ -250,7 +250,7 @@ The typed path routed to no command (stricli's route failure, mapped at the adap ### CLI.V7_COMMAND -The user typed a Prisma 7 command path that Prisma 8 does not have, such as `prisma bootstrap` or `prisma postgres link`; instead of failing as unknown, the redirect table settles it with the summary "`prisma ` is a Prisma 7 command and is not available in Prisma 8". `why` says what the suggested Prisma 8 commands do and what they do not cover, and ends with how to install and run Prisma 7's CLI: "To keep using Prisma 7, install its CLI with `npm install --save-dev @prisma/prisma7@7` and run `prisma7 `." The `prisma7` command line in that sentence has a placeholder for every argument Prisma 7 requires, such as `prisma7 complete `. Next actions, in order: the replacement commands as run-command actions (labelled "Use the replacement" for one, "Step 1", "Step 2", … for several), a run-command pointing at the suggested command's `--help`, and an open-url action to the CLI docs when Prisma 8 has no equivalent. Each command family declares the Prisma 7 paths that relate to its own commands. Exits 2. Meta: none. +The user typed a Prisma 7 command path that Prisma 8 does not have, such as `prisma bootstrap` or `prisma postgres link`; instead of failing as unknown, the redirect table settles it with the summary "`prisma ` is a Prisma 7 command and is not available in Prisma 8". `why` says what the suggested Prisma 8 commands do and what they do not cover, and ends with how to install and run Prisma 7's CLI: "To keep using Prisma 7, install its CLI with `npm install --save-dev @prisma/prisma7@7` and run `prisma7 `." The `prisma7` command line in that sentence has a placeholder for every argument Prisma 7 requires, such as `prisma7 complete `. The ORM's `migrate dev`, `migrate deploy`, `migrate status`, `migrate reset` and `migrate resolve` entries end with a conditional form instead: "While Prisma 7 still owns this project's migrations, install its CLI with `npm install --save-dev @prisma/prisma7@7` and run `prisma7 ` instead." Next actions, in order: the replacement commands as run-command actions (labelled "Use the replacement" for one, "Step 1", "Step 2", … for several), a run-command pointing at the suggested command's `--help`, and an open-url action to the CLI docs when Prisma 8 has no equivalent. Each command family declares the Prisma 7 paths that relate to its own commands. Exits 2. Meta: none. ### CLI.V7_FLAG diff --git a/packages/cli/scripts/conformance.ts b/packages/cli/scripts/conformance.ts index 370eb7ce..3403120d 100644 --- a/packages/cli/scripts/conformance.ts +++ b/packages/cli/scripts/conformance.ts @@ -109,24 +109,7 @@ async function tarball(): Promise { shellPackage: "@prisma/cli", enginePackage: "@prisma/cli-engine", familyPackages: ["@prisma/composer-cli", "@prisma/orm-toolchain"], - exceptions: [ - { - familyPackage: "@prisma/composer-cli", - familyPin: "0.9.0", - shellPin: "0.10.0", - reason: "engine 0.10.0 must publish before composer-cli can peer it", - removeWhen: - "composer-cli releases peering 0.10.0 and the follow-up bump PR pins that release", - }, - { - familyPackage: "@prisma/orm-toolchain", - familyPin: "0.9.0", - shellPin: "0.10.0", - reason: "engine 0.10.0 must publish before orm-toolchain can peer it", - removeWhen: - "orm-toolchain releases peering 0.10.0 and the follow-up bump PR pins that release", - }, - ], + exceptions: [], channel: CHANNEL, sandboxDir: join(WORK_DIR, "sandbox"), }, diff --git a/packages/cli/tests/v7-inventory.test.ts b/packages/cli/tests/v7-inventory.test.ts new file mode 100644 index 00000000..a9512ed0 --- /dev/null +++ b/packages/cli/tests/v7-inventory.test.ts @@ -0,0 +1,182 @@ +import { mkdtempSync, rmSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; +import type { StreamEvent } from "@prisma/cli-engine"; +import { afterAll, describe, expect, it } from "vitest"; +import { buildCli, mountedCommands } from "../src/cli"; +import { assembleRuntime, type HostProcess } from "../src/runtime"; + +const WORK_DIR = mkdtempSync(join(tmpdir(), "v7-inventory-")); +const CONFIG_HOME = join(WORK_DIR, "config-home"); +const WHITESPACE = /\s+/; +const INSTALL = "npm install --save-dev @prisma/prisma7@7"; +const NPX = /\bnpx\b/; + +const V7_COMMANDS = [ + "bootstrap", + "version", + "debug", + "mcp", + "complete", + "platform status", + "postgres link", + "migrate dev", + "migrate deploy", + "migrate status", + "migrate diff", + "migrate reset", + "migrate resolve", + "generate", + "validate", + "format", + "studio", + "db pull", + "db push", + "db seed", + "db execute", + "dev ls", + "dev rm", + "dev start", +] as const; + +const V7_FLAGS = [ + "init --db", + "init --no-skills", + "init --datasource-provider x", + "init --generator-provider x", + "init --preview-feature x", + "init --output x", + "init --url x", + "init --with-model", + "dev --port 1", + "dev --db-port 1", + "dev --shadow-db-port 1", + "dev --debug", + "dev stop --debug", +] as const; + +const CASES: readonly (readonly [string, string])[] = [ + ...V7_COMMANDS.map((path) => [path, "CLI.V7_COMMAND"] as const), + ...V7_FLAGS.map((invocation) => [invocation, "CLI.V7_FLAG"] as const), +]; + +afterAll(() => { + rmSync(WORK_DIR, { recursive: true, force: true }); +}); + +function makeProcess(argv: readonly string[]) { + const proc = { + argv: ["node", "bin.js", ...argv], + version: "v22.12.0", + versions: { node: "22.12.0" }, + platform: "linux", + arch: "x64", + env: { + PRISMA_DISABLE_TELEMETRY: "1", + XDG_CONFIG_HOME: CONFIG_HOME, + APPDATA: CONFIG_HOME, + }, + cwd: () => WORK_DIR, + stdoutText: "", + stderrText: "", + stdout: { + isTTY: false, + write(text: string) { + proc.stdoutText += text; + }, + }, + stderr: { + isTTY: false, + write(text: string) { + proc.stderrText += text; + }, + }, + stdin: { + isTTY: false, + async *[Symbol.asyncIterator]() {}, + } as unknown as HostProcess["stdin"], + on() { + return proc; + }, + off() { + return proc; + }, + exit(code: number): never { + throw new Error(`process.exit(${code})`); + }, + }; + return proc; +} + +async function run(argv: readonly string[]) { + const proc = makeProcess(argv); + const runtime = await assembleRuntime(proc as unknown as HostProcess); + const exitCode = await buildCli().run(argv, runtime); + return { exitCode, stdout: proc.stdoutText, stderr: proc.stderrText }; +} + +function failedEnvelope(stdout: string) { + const frames = stdout + .split("\n") + .filter((line) => line !== "") + .map((line) => JSON.parse(line) as StreamEvent); + const last = frames.at(-1); + if (last?.kind !== "result" || last.envelope.ok) { + throw new Error(`expected a failed result frame, got: ${stdout}`); + } + return last.envelope; +} + +function commandPath(command: string): string { + const words = command.split(WHITESPACE); + expect(words[0]).toBe("prisma"); + const path: string[] = []; + for (const word of words.slice(1)) { + if (word.startsWith("-") || word.startsWith("<")) { + break; + } + path.push(word); + } + return path.join(" "); +} + +describe("every Prisma 7 command path and flag settles as the v7 error", () => { + it.each(CASES)("`prisma %s` settles as %s", async (invocation, code) => { + const args = invocation.split(" "); + + const json = await run([...args, "--json"]); + expect(json.exitCode).toBe(2); + const error = failedEnvelope(json.stdout).error; + expect(error.code).toBe(code); + expect(error.why).toContain(INSTALL); + expect(error.why).toContain("prisma7 "); + expect(error.why).not.toMatch(NPX); + expect(error.nextActions.length).toBeGreaterThan(0); + + const paths = error.nextActions + .map((action) => action.command) + .filter((command) => command !== undefined) + .filter((command) => command !== "prisma --version") + .map(commandPath); + for (const path of paths) { + expect(Object.keys(mountedCommands)).toContain(path); + } + const helps = await Promise.all( + paths.map((path) => run([...path.split(" "), "--help"])), + ); + for (const target of helps) { + expect(target.exitCode).toBe(0); + expect(target.stdout + target.stderr).not.toContain( + "CLI.UNKNOWN_COMMAND", + ); + expect(target.stdout + target.stderr).not.toContain("CLI.V7_"); + } + + const human = await run(args); + expect(human.exitCode).toBe(2); + const output = human.stdout + human.stderr; + for (const action of error.nextActions) { + expect(output).toContain(action.command ?? action.url); + } + }); +}); From d450f0fdaa35a948670990d5ef492357133aa45e Mon Sep 17 00:00:00 2001 From: Steven McClankerton Date: Mon, 16 Nov 2026 17:40:32 +0000 Subject: [PATCH 2/2] test(cli): assert the exact Prisma 7 install sentence for each v7 case Each of the 37 cases now carries the prisma7 invocation the released families print, placeholders included, and whether it uses the default or the migrations form. The test asserts why ends with exactly that sentence. Co-Authored-By: Claude Opus 5.5 --- packages/cli/tests/v7-inventory.test.ts | 291 ++++++++++++++++++++---- 1 file changed, 244 insertions(+), 47 deletions(-) diff --git a/packages/cli/tests/v7-inventory.test.ts b/packages/cli/tests/v7-inventory.test.ts index a9512ed0..7c2f180e 100644 --- a/packages/cli/tests/v7-inventory.test.ts +++ b/packages/cli/tests/v7-inventory.test.ts @@ -12,54 +12,246 @@ const WHITESPACE = /\s+/; const INSTALL = "npm install --save-dev @prisma/prisma7@7"; const NPX = /\bnpx\b/; -const V7_COMMANDS = [ - "bootstrap", - "version", - "debug", - "mcp", - "complete", - "platform status", - "postgres link", - "migrate dev", - "migrate deploy", - "migrate status", - "migrate diff", - "migrate reset", - "migrate resolve", - "generate", - "validate", - "format", - "studio", - "db pull", - "db push", - "db seed", - "db execute", - "dev ls", - "dev rm", - "dev start", -] as const; +type InstallForm = "keep" | "migrations"; -const V7_FLAGS = [ - "init --db", - "init --no-skills", - "init --datasource-provider x", - "init --generator-provider x", - "init --preview-feature x", - "init --output x", - "init --url x", - "init --with-model", - "dev --port 1", - "dev --db-port 1", - "dev --shadow-db-port 1", - "dev --debug", - "dev stop --debug", -] as const; +interface V7Case { + readonly invocation: string; + readonly code: "CLI.V7_COMMAND" | "CLI.V7_FLAG"; + readonly prisma7: string; + readonly form: InstallForm; +} -const CASES: readonly (readonly [string, string])[] = [ - ...V7_COMMANDS.map((path) => [path, "CLI.V7_COMMAND"] as const), - ...V7_FLAGS.map((invocation) => [invocation, "CLI.V7_FLAG"] as const), +const CASES: readonly V7Case[] = [ + { + invocation: "bootstrap", + code: "CLI.V7_COMMAND", + prisma7: "bootstrap", + form: "keep", + }, + { + invocation: "version", + code: "CLI.V7_COMMAND", + prisma7: "version", + form: "keep", + }, + { + invocation: "debug", + code: "CLI.V7_COMMAND", + prisma7: "debug", + form: "keep", + }, + { + invocation: "mcp", + code: "CLI.V7_COMMAND", + prisma7: "mcp", + form: "keep", + }, + { + invocation: "complete", + code: "CLI.V7_COMMAND", + prisma7: "complete ", + form: "keep", + }, + { + invocation: "platform status", + code: "CLI.V7_COMMAND", + prisma7: "platform status", + form: "keep", + }, + { + invocation: "postgres link", + code: "CLI.V7_COMMAND", + prisma7: "postgres link", + form: "keep", + }, + { + invocation: "migrate dev", + code: "CLI.V7_COMMAND", + prisma7: "migrate dev", + form: "migrations", + }, + { + invocation: "migrate deploy", + code: "CLI.V7_COMMAND", + prisma7: "migrate deploy", + form: "migrations", + }, + { + invocation: "migrate status", + code: "CLI.V7_COMMAND", + prisma7: "migrate status", + form: "migrations", + }, + { + invocation: "migrate diff", + code: "CLI.V7_COMMAND", + prisma7: "migrate diff --from-config-datasource --to-schema ", + form: "keep", + }, + { + invocation: "migrate reset", + code: "CLI.V7_COMMAND", + prisma7: "migrate reset", + form: "migrations", + }, + { + invocation: "migrate resolve", + code: "CLI.V7_COMMAND", + prisma7: "migrate resolve --applied ", + form: "migrations", + }, + { + invocation: "generate", + code: "CLI.V7_COMMAND", + prisma7: "generate", + form: "keep", + }, + { + invocation: "validate", + code: "CLI.V7_COMMAND", + prisma7: "validate", + form: "keep", + }, + { + invocation: "format", + code: "CLI.V7_COMMAND", + prisma7: "format", + form: "keep", + }, + { + invocation: "studio", + code: "CLI.V7_COMMAND", + prisma7: "studio", + form: "keep", + }, + { + invocation: "db pull", + code: "CLI.V7_COMMAND", + prisma7: "db pull", + form: "keep", + }, + { + invocation: "db push", + code: "CLI.V7_COMMAND", + prisma7: "db push", + form: "keep", + }, + { + invocation: "db seed", + code: "CLI.V7_COMMAND", + prisma7: "db seed", + form: "keep", + }, + { + invocation: "db execute", + code: "CLI.V7_COMMAND", + prisma7: "db execute --file ", + form: "keep", + }, + { + invocation: "dev ls", + code: "CLI.V7_COMMAND", + prisma7: "dev ls", + form: "keep", + }, + { + invocation: "dev rm", + code: "CLI.V7_COMMAND", + prisma7: "dev rm ", + form: "keep", + }, + { + invocation: "dev start", + code: "CLI.V7_COMMAND", + prisma7: "dev start ", + form: "keep", + }, + { + invocation: "init --db", + code: "CLI.V7_FLAG", + prisma7: "init --db", + form: "keep", + }, + { + invocation: "init --no-skills", + code: "CLI.V7_FLAG", + prisma7: "init --no-skills", + form: "keep", + }, + { + invocation: "init --datasource-provider x", + code: "CLI.V7_FLAG", + prisma7: "init --datasource-provider ", + form: "keep", + }, + { + invocation: "init --generator-provider x", + code: "CLI.V7_FLAG", + prisma7: "init --generator-provider ", + form: "keep", + }, + { + invocation: "init --preview-feature x", + code: "CLI.V7_FLAG", + prisma7: "init --preview-feature ", + form: "keep", + }, + { + invocation: "init --output x", + code: "CLI.V7_FLAG", + prisma7: "init --output ", + form: "keep", + }, + { + invocation: "init --url x", + code: "CLI.V7_FLAG", + prisma7: "init --url ", + form: "keep", + }, + { + invocation: "init --with-model", + code: "CLI.V7_FLAG", + prisma7: "init --with-model", + form: "keep", + }, + { + invocation: "dev --port 1", + code: "CLI.V7_FLAG", + prisma7: "dev --port ", + form: "keep", + }, + { + invocation: "dev --db-port 1", + code: "CLI.V7_FLAG", + prisma7: "dev --db-port ", + form: "keep", + }, + { + invocation: "dev --shadow-db-port 1", + code: "CLI.V7_FLAG", + prisma7: "dev --shadow-db-port ", + form: "keep", + }, + { + invocation: "dev --debug", + code: "CLI.V7_FLAG", + prisma7: "dev --debug", + form: "keep", + }, + { + invocation: "dev stop --debug", + code: "CLI.V7_FLAG", + prisma7: "dev stop --debug", + form: "keep", + }, ]; +function installSentence(prisma7: string, form: InstallForm): string { + return form === "migrations" + ? `While Prisma 7 still owns this project's migrations, install its CLI with \`${INSTALL}\` and run \`prisma7 ${prisma7}\` instead.` + : `To keep using Prisma 7, install its CLI with \`${INSTALL}\` and run \`prisma7 ${prisma7}\`.`; +} + afterAll(() => { rmSync(WORK_DIR, { recursive: true, force: true }); }); @@ -141,15 +333,20 @@ function commandPath(command: string): string { } describe("every Prisma 7 command path and flag settles as the v7 error", () => { - it.each(CASES)("`prisma %s` settles as %s", async (invocation, code) => { + it.each(CASES)("`prisma $invocation` settles as $code", async ({ + invocation, + code, + prisma7, + form, + }) => { const args = invocation.split(" "); const json = await run([...args, "--json"]); expect(json.exitCode).toBe(2); const error = failedEnvelope(json.stdout).error; expect(error.code).toBe(code); - expect(error.why).toContain(INSTALL); - expect(error.why).toContain("prisma7 "); + const sentence = ` ${installSentence(prisma7, form)}`; + expect(error.why?.slice(-sentence.length)).toBe(sentence); expect(error.why).not.toMatch(NPX); expect(error.nextActions.length).toBeGreaterThan(0);