Skip to content
Merged
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
15 changes: 15 additions & 0 deletions docs/guides/running-locally.md
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,21 @@ a code a script can branch on:

Each command's piped lines are listed in [Piped output](#piped-output).

Prisma 7's `prisma dev ls`, `prisma dev rm` and `prisma dev start` fail with
`CLI.V7_COMMAND`. Its `--port`, `--db-port`, `--shadow-db-port` and `--debug`
on `prisma dev`, and `--debug` on `prisma dev stop`, fail with `CLI.V7_FLAG`.
Both exit with status 2 and say why. `dev ls` points to `prisma emulator list`,
`dev start` to `prisma dev --detach`, and `dev rm` to `prisma dev --fresh`,
which deletes the app's local services, databases and buckets in one
environment, and their data, then starts the app again. The flags point to the
command's help. There is no port to pass: `prisma dev` gives each environment
its own ports and keeps them between runs, and `prisma dev url` prints where a
node answers.
Each error also says how to keep using Prisma 7: install its CLI with
`npm install --save-dev @prisma/prisma7@7` and run the Prisma 7 command with
`prisma7`, with a placeholder for each value it needs, such as
`prisma7 dev rm <name>` or `prisma7 dev --port <port>`.

`--fresh` is also the fix when a framework upgrade leaves stale rows in this
app's local dev state — the symptom is a plan-time error naming an
unregistered resource type (for example
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"pnpm": {
"overrides": {
"@prisma/composer-cli": "workspace:*",
"@prisma/cli-engine": "0.9.0"
"@prisma/cli-engine": "0.10.0"
},
"onlyBuiltDependencies": [
"prisma",
Expand Down
2 changes: 1 addition & 1 deletion packages/0-framework/3-tooling/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@internal/assemble": "workspace:0.38.0",
"@internal/core": "workspace:0.38.0",
"@internal/foundation": "workspace:0.38.0",
"@prisma/cli-engine": "0.9.0",
"@prisma/cli-engine": "0.10.0",
"chokidar": "^4.0.3",
"cross-spawn": "^7.0.6",
"dotenv-flow": "4.1.0"
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ import * as os from 'node:os';
import * as path from 'node:path';
import { CliStructuredError } from '@internal/foundation/errors';
import { notOk, ok } from '@internal/foundation/result';
import type { NextAction } from '@prisma/cli-engine/protocol';
import type { ScriptedChildProgram, TestCli } from '@prisma/cli-engine/testing';
import { createTestCli, mintTestJwt } from '@prisma/cli-engine/testing';
import { createOperationsDouble, type OperationsDouble } from '../../testing/operations-double.ts';
import { createComposerFamily } from '../family.ts';
import { commandAt } from './command-at.ts';
import { validComposerSection } from './fixtures/composer-section.ts';
import { mountAsHost } from './host-mount.ts';

type Fixtures = Parameters<typeof createOperationsDouble>[0];

Expand Down Expand Up @@ -71,10 +72,7 @@ function composerCli(
const family = createComposerFamily({ operations: double.operations });
const cli = createTestCli({
commandFamilies: [family],
// The two product verbs, at the root. `dev url` and `dev stop` mount
// beneath `dev`, which needs an engine that lets a command also be a
// group; their own tests mount them alone.
commands: { deploy: commandAt(family, 'deploy'), dev: commandAt(family, 'dev') },
...mountAsHost(family),
config: { composer: validComposerSection() },
...(spec.signedIn === false ? {} : { credential: activeCredential() }),
...(spec.spawnScript === undefined ? {} : { spawnScript: spec.spawnScript }),
Expand Down Expand Up @@ -165,9 +163,16 @@ describe('argument validation', () => {
if (last?.kind !== 'result' || last.envelope.ok) throw new Error('expected an errored result');
expect(last.envelope.error.code).toBe('CLI.COMMAND_MOVED');
expect(last.envelope.error.summary).toBe('`--stage` on `deploy` has been replaced');
expect(last.envelope.nextActions).toEqual([
expect.objectContaining({ command: expect.stringContaining('deploy --environment <name>') }),
]);
expect(last.envelope.error.why).toBe('A place the app runs is now called an environment.');
const nextActions: NextAction[] = [
{
kind: 'run-command',
label: 'Use the replacement',
command: 'prisma-test deploy --environment <name>',
},
];
expect(last.envelope.nextActions).toEqual(nextActions);
expect(last.envelope.error.nextActions).toEqual(nextActions);
expect(double.calls.deploy).toEqual([]);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
type OperationsDoubleFixtures,
} from '../../testing/operations-double.ts';
import { createComposerFamily } from '../family.ts';
import { commandAt } from './command-at.ts';
import { mountAsHost } from './host-mount.ts';

function composerConfig() {
return {
Expand All @@ -26,12 +26,7 @@ function cliWith(fixtures: OperationsDoubleFixtures = {}) {
const family = createComposerFamily({ operations: double.operations });
const cli = createTestCli({
commandFamilies: [family],
commands: {
deploy: commandAt(family, 'deploy'),
'dev url': commandAt(family, 'dev url'),
'dev stop': commandAt(family, 'dev stop'),
},
groups: { dev: { brief: 'Run the app on this machine.' } },
...mountAsHost(family),
config: { composer: composerConfig() },
});
return { cli, calls: double.calls };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ import type { EngineEvent } from '@prisma/cli-engine';
import { createTestCli } from '@prisma/cli-engine/testing';
import { createOperationsDouble } from '../../testing/operations-double.ts';
import { createComposerFamily } from '../family.ts';
import { commandAt } from './command-at.ts';
import { validComposerSection } from './fixtures/composer-section.ts';
import { mountAsHost } from './host-mount.ts';

const AS_TTY = { isTty: { stdout: true, stderr: true } } as const;

function cliOver(double: ReturnType<typeof createOperationsDouble>) {
const family = createComposerFamily({ operations: double.operations });
return createTestCli({
commandFamilies: [family],
commands: { deploy: commandAt(family, 'deploy'), dev: commandAt(family, 'dev') },
...mountAsHost(family),
config: { composer: validComposerSection() },
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { createTestCli } from '@prisma/cli-engine/testing';
import * as Layer from 'effect/Layer';
import { devWithDeps } from '../../operations/dev.ts';
import { createComposerFamily, realOperations } from '../family.ts';
import { commandAt } from './command-at.ts';
import { mountAsHost } from './host-mount.ts';

const coreIndex = path.resolve(import.meta.dir, '../../../../../1-core/core/src/exports/index.ts');

Expand Down Expand Up @@ -127,7 +127,7 @@ describe.skipIf(process.platform === 'win32')(
});
const cli = createTestCli({
commandFamilies: [family],
commands: { deploy: commandAt(family, 'deploy'), dev: commandAt(family, 'dev') },
...mountAsHost(family),
config: { composer: configWhoseEmulatorsThrow() },
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import type { EngineEvent } from '@prisma/cli-engine';
import { createTestCli } from '@prisma/cli-engine/testing';
import { createOperationsDouble } from '../../testing/operations-double.ts';
import { createComposerFamily } from '../family.ts';
import { commandAt } from './command-at.ts';
import { validComposerSection } from './fixtures/composer-section.ts';
import { mountAsHost } from './host-mount.ts';

const AS_TTY = { isTty: { stdout: true, stderr: true } } as const;

Expand All @@ -27,7 +27,7 @@ describe('dev, interrupted', () => {
const family = createComposerFamily({ operations: double.operations });
const cli = createTestCli({
commandFamilies: [family],
commands: { deploy: commandAt(family, 'deploy'), dev: commandAt(family, 'dev') },
...mountAsHost(family),
config: { composer: validComposerSection() },
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import type { EngineEvent } from '@prisma/cli-engine';
import { createTestCli } from '@prisma/cli-engine/testing';
import { createOperationsDouble } from '../../testing/operations-double.ts';
import { createComposerFamily } from '../family.ts';
import { commandAt } from './command-at.ts';
import { validComposerSection } from './fixtures/composer-section.ts';
import { mountAsHost } from './host-mount.ts';

const AS_TTY = { isTty: { stdout: true, stderr: true } } as const;

Expand All @@ -32,7 +32,7 @@ describe('dev — dev servers', () => {
const family = createComposerFamily({ operations: double.operations });
const cli = createTestCli({
commandFamilies: [family],
commands: { deploy: commandAt(family, 'deploy'), dev: commandAt(family, 'dev') },
...mountAsHost(family),
config: { composer: validComposerSection() },
});
const interrupt = new AbortController();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import type { EngineEvent } from '@prisma/cli-engine';
import { createTestCli } from '@prisma/cli-engine/testing';
import { createOperationsDouble } from '../../testing/operations-double.ts';
import { createComposerFamily } from '../family.ts';
import { commandAt } from './command-at.ts';
import { validComposerSection } from './fixtures/composer-section.ts';
import { mountAsHost } from './host-mount.ts';

const WARNING =
'shop.site names the hostname shop.com. prisma dev ignores it and serves the service on its local URL.';
Expand All @@ -19,7 +19,7 @@ describe('dev — target warnings', () => {
const family = createComposerFamily({ operations: double.operations });
const cli = createTestCli({
commandFamilies: [family],
commands: { deploy: commandAt(family, 'deploy'), dev: commandAt(family, 'dev') },
...mountAsHost(family),
config: { composer: validComposerSection() },
});
const interrupt = new AbortController();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import type { EngineEvent } from '@prisma/cli-engine';
import { createTestCli } from '@prisma/cli-engine/testing';
import { createOperationsDouble } from '../../testing/operations-double.ts';
import { createComposerFamily } from '../family.ts';
import { commandAt } from './command-at.ts';
import { validComposerSection } from './fixtures/composer-section.ts';
import { mountAsHost } from './host-mount.ts';

const WARNING =
'The values the config or secrets adapters return changed since dev started. Restart dev to apply them; rebuilds are paused until then.';
Expand All @@ -19,7 +19,7 @@ describe('dev — changed adapter values', () => {
const family = createComposerFamily({ operations: double.operations });
const cli = createTestCli({
commandFamilies: [family],
commands: { deploy: commandAt(family, 'deploy'), dev: commandAt(family, 'dev') },
...mountAsHost(family),
config: { composer: validComposerSection() },
});
const interrupt = new AbortController();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,43 @@ describe('createComposerFamily()', () => {
).toEqual(['deploy', 'dev', 'dev stop', 'dev url', 'emulator list']);
});

test('the family redirects only the retired --stage on deploy', () => {
expect(createComposerFamily().redirects).toEqual([
{
from: 'deploy',
flag: 'stage',
replacement: 'deploy --environment <name>',
reason: 'A place the app runs is now called an environment.',
},
]);
test('the family redirects the retired --stage on deploy and the Prisma 7 dev subcommands and flags', () => {
const redirects = createComposerFamily().redirects;
expect(redirects[0]).toEqual({
from: 'deploy',
flag: 'stage',
replacement: ['deploy --environment <name>'],
reason: 'A place the app runs is now called an environment.',
code: undefined,
summary: undefined,
help: undefined,
docsUrl: undefined,
});
expect(
redirects
.slice(1)
.map((redirect) => [redirect.code, redirect.from, redirect.flag])
.sort(),
).toEqual(
[
['CLI.V7_COMMAND', 'dev ls', undefined],
['CLI.V7_COMMAND', 'dev rm', undefined],
['CLI.V7_COMMAND', 'dev start', undefined],
['CLI.V7_FLAG', 'dev', 'dbPort'],
['CLI.V7_FLAG', 'dev', 'debug'],
['CLI.V7_FLAG', 'dev', 'port'],
['CLI.V7_FLAG', 'dev', 'shadowDbPort'],
['CLI.V7_FLAG', 'dev stop', 'debug'],
].sort(),
);
});

test('a host’s redirects follow the family’s own', () => {
const extra = { from: 'emulator ls', replacement: 'emulator list' };
expect(createComposerFamily({ redirects: [extra] }).redirects.at(-1)).toMatchObject({
from: 'emulator ls',
replacement: ['emulator list'],
});
});

test('the operations seam defaults to the real control operations', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type { CommandFamily } from '@prisma/cli-engine';

export function mountAsHost(family: CommandFamily) {
return {
commands: family.commands,
groups: { dev: { brief: 'Run the app on this machine.' } },
};
}
Loading
Loading