Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/lsp-playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"ws": "^8.21.2"
},
"devDependencies": {
"@prisma/cli-engine": "0.6.1",
"@prisma/cli-engine": "0.6.2",
"@repo/tsconfig": "workspace:8.0.0-rc.13",
"@types/node": "catalog:",
"@types/ws": "^8.5.13",
Expand Down
2 changes: 1 addition & 1 deletion apps/telemetry-backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"evlog": "^2.24.0"
},
"devDependencies": {
"@prisma/cli-engine": "0.6.1",
"@prisma/cli-engine": "0.6.2",
"@prisma/compute-sdk": "^0.43.0",
"@prisma/management-api-sdk": "^1.76.0",
"@repo/test-utils": "workspace:8.0.0-rc.13",
Expand Down
2 changes: 1 addition & 1 deletion examples/bundle-size/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"pg": "catalog:"
},
"devDependencies": {
"@prisma/cli-engine": "0.6.1",
"@prisma/cli-engine": "0.6.2",
"@prisma/dev": "catalog:",
"@repo/test-utils": "workspace:8.0.0-rc.13",
"@repo/tsconfig": "workspace:8.0.0-rc.13",
Expand Down
2 changes: 1 addition & 1 deletion examples/mongo-blog-leaderboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"mongodb": "catalog:"
},
"devDependencies": {
"@prisma/cli-engine": "0.6.1",
"@prisma/cli-engine": "0.6.2",
"@repo/tsconfig": "workspace:8.0.0-rc.13",
"@types/node": "catalog:",
"mongodb-memory-server": "catalog:",
Expand Down
2 changes: 1 addition & 1 deletion examples/mongo-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"react-dom": "^19.2.8"
},
"devDependencies": {
"@prisma/cli-engine": "0.6.1",
"@prisma/cli-engine": "0.6.2",
"@repo/test-utils": "workspace:8.0.0-rc.13",
"@repo/tsconfig": "workspace:8.0.0-rc.13",
"@types/node": "catalog:",
Expand Down
2 changes: 1 addition & 1 deletion examples/multi-extension-monorepo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@prisma/orm-postgres": "workspace:8.0.0-rc.13"
},
"devDependencies": {
"@prisma/cli-engine": "0.6.1",
"@prisma/cli-engine": "0.6.2",
"@repo/test-utils": "workspace:8.0.0-rc.13",
"@repo/tsconfig": "workspace:8.0.0-rc.13",
"@types/node": "catalog:",
Expand Down
2 changes: 1 addition & 1 deletion examples/paradedb-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"pg": "catalog:"
},
"devDependencies": {
"@prisma/cli-engine": "0.6.1",
"@prisma/cli-engine": "0.6.2",
"@repo/test-utils": "workspace:8.0.0-rc.13",
"@repo/tsconfig": "workspace:8.0.0-rc.13",
"@types/node": "catalog:",
Expand Down
2 changes: 1 addition & 1 deletion examples/prisma-8-cloudflare-worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"devDependencies": {
"@cloudflare/vitest-pool-workers": "0.20.3",
"@cloudflare/workers-types": "5.20260804.1",
"@prisma/cli-engine": "0.6.1",
"@prisma/cli-engine": "0.6.2",
"@repo/tsconfig": "workspace:8.0.0-rc.13",
"@types/node": "catalog:",
"@types/pg": "catalog:",
Expand Down
2 changes: 1 addition & 1 deletion examples/prisma-8-demo-sqlite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"dotenv": "^17.4.2"
},
"devDependencies": {
"@prisma/cli-engine": "0.6.1",
"@prisma/cli-engine": "0.6.2",
"@repo/tsconfig": "workspace:8.0.0-rc.13",
"@types/node": "catalog:",
"tsx": "catalog:",
Expand Down
2 changes: 1 addition & 1 deletion examples/prisma-8-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"react-dom": "^19.2.8"
},
"devDependencies": {
"@prisma/cli-engine": "0.6.1",
"@prisma/cli-engine": "0.6.2",
"@prisma/dev": "catalog:",
"@repo/test-utils": "workspace:8.0.0-rc.13",
"@repo/tsconfig": "workspace:8.0.0-rc.13",
Expand Down
2 changes: 1 addition & 1 deletion examples/prisma-8-postgis-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"react-leaflet": "^5.0.0"
},
"devDependencies": {
"@prisma/cli-engine": "0.6.1",
"@prisma/cli-engine": "0.6.2",
"@repo/test-utils": "workspace:8.0.0-rc.13",
"@repo/tsconfig": "workspace:8.0.0-rc.13",
"@types/leaflet": "^1.9.22",
Expand Down
2 changes: 1 addition & 1 deletion examples/prisma7-adoption/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"temporal-polyfill": "^1.0.4"
},
"devDependencies": {
"@prisma/cli-engine": "0.6.1",
"@prisma/cli-engine": "0.6.2",
"@prisma/dev": "catalog:",
"@prisma/prisma7": "7.10.0",
"@repo/test-utils": "workspace:8.0.0-rc.13",
Expand Down
2 changes: 1 addition & 1 deletion examples/react-router-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"react-router": "^8.1.0"
},
"devDependencies": {
"@prisma/cli-engine": "0.6.1",
"@prisma/cli-engine": "0.6.2",
"@prisma/dev": "catalog:",
"@react-router/dev": "^8.1.0",
"@repo/test-utils": "workspace:8.0.0-rc.13",
Expand Down
2 changes: 1 addition & 1 deletion examples/retail-store/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"tailwindcss": "^4.3.3"
},
"devDependencies": {
"@prisma/cli-engine": "0.6.1",
"@prisma/cli-engine": "0.6.2",
"@repo/test-utils": "workspace:8.0.0-rc.13",
"@repo/tsconfig": "workspace:8.0.0-rc.13",
"@types/node": "catalog:",
Expand Down
2 changes: 1 addition & 1 deletion examples/supabase/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"pg": "catalog:"
},
"devDependencies": {
"@prisma/cli-engine": "0.6.1",
"@prisma/cli-engine": "0.6.2",
"@repo/test-utils": "workspace:8.0.0-rc.13",
"@repo/tsconfig": "workspace:8.0.0-rc.13",
"@types/node": "catalog:",
Expand Down
4 changes: 2 additions & 2 deletions packages/1-framework/3-tooling/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"@internal/sql-contract-ts": "workspace:8.0.0-rc.13",
"@internal/sql-operations": "workspace:8.0.0-rc.13",
"@internal/sql-runtime": "workspace:8.0.0-rc.13",
"@prisma/cli-engine": "0.6.1",
"@prisma/cli-engine": "0.6.2",
"@repo/test-utils": "workspace:8.0.0-rc.13",
"@repo/tsconfig": "workspace:8.0.0-rc.13",
"@repo/tsdown": "workspace:8.0.0-rc.13",
Expand All @@ -62,7 +62,7 @@
"vitest": "catalog:"
},
"peerDependencies": {
"@prisma/cli-engine": "0.6.1",
"@prisma/cli-engine": "0.6.2",
"typescript": ">=5.9"
},
"peerDependenciesMeta": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import { CliStructuredError } from '@internal/errors/control';
import { ok } from '@prisma/cli-engine/protocol';
import { createTestCli } from '@prisma/cli-engine/testing';
import stripAnsi from 'strip-ansi';
import { describe, expect, it } from 'vitest';
import { defineOrmCommand } from '../../src/orm/define-command';
import { runCommandAction } from '../../src/utils/next-actions';

/**
* The engine harness always names the binary `prisma-test`. The real
* `prisma` bin uses that same substitution with its own name.
*/
const TEST_BIN = 'prisma-test';

describe('the running binary name replaces {bin} when the CLI renders', () => {
it('prints the binary in human next-step lines instead of a literal {bin}', async () => {
const cli = createTestCli({
commands: {
hint: defineOrmCommand({
help: { summary: 'Presents a follow-up command' },
handler: async (_args, ctx) =>
ok(
ctx.present(
{ data: { ok: true }, exitCode: 0 },
{
human: () => [{ kind: 'summary', status: 'ok', text: 'Done.' }],
stdout: () => [],
json: () => ({ ok: true }),
next: () => [runCommandAction('Apply the planned operations', '{bin} db update')],
},
),
),
}),
},
});

const run = await cli.run(['hint'], {
cwd: process.cwd(),
isTty: { stdout: true, stderr: true },
});
const rendered = stripAnsi(run.stderr);

expect(run.exitCode).toBe(0);
expect(rendered).not.toContain('{bin}');
expect(rendered).toContain(`${TEST_BIN} db update`);
expect(run.presented?.presentation.next).toEqual([
{
kind: 'run-command',
label: 'Apply the planned operations',
command: `${TEST_BIN} db update`,
},
]);
});

it('substitutes {bin} in error advice before the envelope is serialized', async () => {
const cli = createTestCli({
commands: {
boom: defineOrmCommand({
help: { summary: 'Throws a structured error' },
handler: async () => {
throw new CliStructuredError(
'CLI.CONSENT_TOKEN_UNRESOLVED',
'Could not resolve consent',
{
why: 'Name the database in `db.connection` (or pass `--db <url>`) and run `{bin} db update` again.',
nextActions: [runCommandAction('Sign the database', '{bin} db sign --db <url>')],
},
);
},
}),
},
});

const human = await cli.run(['boom'], {
cwd: process.cwd(),
isTty: { stdout: true, stderr: true },
});
const rendered = stripAnsi(human.stderr);
const json = await cli.run(['boom', '--json'], { cwd: process.cwd() });
const terminal = json.json.at(-1);
const envelope =
terminal !== undefined && terminal.kind === 'result' ? terminal.envelope : undefined;

expect(human.exitCode).toBe(2);
expect(rendered).not.toContain('{bin}');
expect(rendered).toContain(`${TEST_BIN} db update`);
expect(rendered).toContain(`${TEST_BIN} db sign --db <url>`);
expect(envelope).toMatchObject({
ok: false,
nextActions: [
{
kind: 'run-command',
label: 'Sign the database',
command: `${TEST_BIN} db sign --db <url>`,
},
],
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ describe('contract print', () => {
label:
'Write the PSL to a file with --output <path>, then point contract in prisma.config.ts at that file',
},
{ kind: 'run-command', label: 'Emit the printed contract', command: '{bin} contract emit' },
{
kind: 'run-command',
label: 'Emit the printed contract',
command: 'prisma-test contract emit',
},
]);
expect(await readdir(dir)).toEqual([]);
});
Expand Down Expand Up @@ -215,7 +219,11 @@ describe('contract print', () => {
kind: 'user-choice',
label: 'Point contract in prisma.config.ts at generated/contract.prisma',
},
{ kind: 'run-command', label: 'Emit the printed contract', command: '{bin} contract emit' },
{
kind: 'run-command',
label: 'Emit the printed contract',
command: 'prisma-test contract emit',
},
]);
expect(run.presented?.presentation.stdout).toEqual([]);
expect(stripAnsi(run.stderr)).toContain('Contract written to generated/contract.prisma');
Expand Down Expand Up @@ -250,7 +258,11 @@ describe('contract print', () => {
label:
"Point contract in prisma.config.ts at generated/contract.prisma, through a PSL source that sets defaultControlPolicy: 'external'",
},
{ kind: 'run-command', label: 'Emit the printed contract', command: '{bin} contract emit' },
{
kind: 'run-command',
label: 'Emit the printed contract',
command: 'prisma-test contract emit',
},
]);
});

Expand Down Expand Up @@ -315,7 +327,11 @@ describe('contract print', () => {
label:
"With contract: './prisma/contract.prisma' and no output in prisma.config.ts, contract emit writes prisma/contract.json and prisma/contract.d.ts, not prisma/schema.json and prisma/schema.d.ts",
},
{ kind: 'run-command', label: 'Emit the printed contract', command: '{bin} contract emit' },
{
kind: 'run-command',
label: 'Emit the printed contract',
command: 'prisma-test contract emit',
},
]);
});

Expand Down Expand Up @@ -347,7 +363,11 @@ describe('contract print', () => {
label:
"With contract: './src/prisma/contract.prisma' and no output in prisma.config.ts, contract emit writes src/prisma/contract.json and src/prisma/contract.d.ts, not prisma/schema.json and prisma/schema.d.ts",
},
{ kind: 'run-command', label: 'Emit the printed contract', command: '{bin} contract emit' },
{
kind: 'run-command',
label: 'Emit the printed contract',
command: 'prisma-test contract emit',
},
]);
});

Expand Down
4 changes: 2 additions & 2 deletions packages/1-framework/3-tooling/cli/test/orm/db-init.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ describe('db init', () => {
{
kind: 'run-command',
label: 'Confirm the space is up to date',
command: '{bin} migration status',
command: 'prisma-test migration status',
},
]);
});
Expand Down Expand Up @@ -314,7 +314,7 @@ describe('db init', () => {
{
kind: 'run-command',
label: 'Apply the planned operations',
command: '{bin} db init',
command: 'prisma-test db init',
},
]);
});
Expand Down
4 changes: 2 additions & 2 deletions packages/1-framework/3-tooling/cli/test/orm/db-sign.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ describe('db sign', () => {
{
kind: 'run-command',
label: 'Change the database to match the contract, then sign again',
command: '{bin} db update',
command: 'prisma-test db update',
},
{
kind: 'user-choice',
Expand All @@ -177,7 +177,7 @@ describe('db sign', () => {
{
kind: 'run-command',
label: 'Change the database to match the contract, then sign again',
command: '{bin} db update --to "staging"',
command: 'prisma-test db update --to "staging"',
},
{
kind: 'user-choice',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ describe('db update', () => {
{
kind: 'run-command',
label: 'Confirm the space is up to date',
command: '{bin} migration status',
command: 'prisma-test migration status',
},
]);
});
Expand Down Expand Up @@ -326,7 +326,7 @@ describe('db update', () => {
{
kind: 'run-command',
label: 'Apply the planned operations',
command: '{bin} db update',
command: 'prisma-test db update',
},
]);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ describe('db verify', () => {
{
kind: 'run-command',
label: 'Change the database to match the contract, then verify again',
command: '{bin} db update',
command: 'prisma-test db update',
},
{
kind: 'user-choice',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('defineOrmCommand', () => {
const envelope = erroredEnvelope(run);

expect(envelope.nextActions).toEqual([
{ kind: 'user-choice', label: 'Run `{bin} migration list` to see every space.' },
{ kind: 'user-choice', label: 'Run `prisma-test migration list` to see every space.' },
]);
expect(envelope.error).not.toHaveProperty('fix');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ describe('migrate', () => {
{
kind: 'run-command',
label: 'Check every space against the database',
command: '{bin} migration status',
command: 'prisma-test migration status',
},
]);
});
Expand Down
Loading