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
4 changes: 4 additions & 0 deletions docs/product/command-spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ Out of scope for the current beta:
- Long flags use kebab-case.
- Boolean negation uses `--no-<flag>`.
- `--json` and non-interactive mode must not block on prompts.
- Automatic update checks are advisory and skipped in CI, `--json`, `--quiet`,
non-TTY stderr, and when `NO_UPDATE_NOTIFIER` is set. When shown, update
notifications are stderr-only human output and do not change the original
command result.
- Public Beta does not read or write committed config files such as `prisma.config.ts` or `.prisma/settings.json` for Project -> Branch -> App resolution. `.prisma/local.json` is a gitignored local pin/cache, not a declarative repo config file.
- Remote commands do not silently change local context.

Expand Down
33 changes: 33 additions & 0 deletions docs/product/output-conventions.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Human-oriented stderr output may include:
- command headers
- progress
- warnings
- automatic update notifications
- help text
- target context
- final human-readable success or failure summaries
Expand Down Expand Up @@ -45,6 +46,38 @@ Non-TTY or piped behavior:

This keeps pipes, captures, and automation clean.

## Automatic Update Notifications

The CLI may print an advisory update notification before normal command output
when all of these are true:

- stderr is a TTY
- `--json` is not active
- `--quiet` is not active
- CI is not detected
- `NO_UPDATE_NOTIFIER` is not set
- cached update-check state already shows a newer official `@prisma/cli`
version

The notification is human-only stderr output. It must never be written to
stdout, must not change the original command exit code, and must not block the
original command on network discovery.

Recommended shape:

```text
Update available: prisma-cli <current> -> <latest>
Run <package-manager command> to update.
```

When the CLI cannot confidently infer the install context, link to installation
docs instead of guessing a package-manager command:

```text
Update available: prisma-cli <current> -> <latest>
See https://www.prisma.io/docs/orm/tools/prisma-cli for update instructions.
```

## Human Output

Human-facing output should follow `cli-style-guide.md` and optimize for:
Expand Down
13 changes: 10 additions & 3 deletions packages/cli/src/bin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@
import process from "node:process";

import { runCli } from "./cli";
import { runUpdateDiscoveryWorker } from "./shell/update-check";

runCli().then((exitCode) => {
process.exitCode = exitCode;
});
if (process.env.PRISMA_CLI_RUN_UPDATE_CHECK_WORKER === "1") {
runUpdateDiscoveryWorker().then(() => {
process.exitCode = 0;
});
} else {
runCli().then((exitCode) => {
process.exitCode = exitCode;
});
}
3 changes: 3 additions & 0 deletions packages/cli/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { writeHumanError, writeJsonError, writeJsonSuccess } from "./shell/outpu
import { disposePromptState } from "./shell/prompt";
import { configureRuntimeCommand, createCommandContext, type CliRuntime } from "./shell/runtime";
import { createShellUi } from "./shell/ui";
import { maybeWriteCachedUpdateNotification } from "./shell/update-check";

export interface RunCliOptions extends Partial<CliRuntime> {
argv?: string[];
Expand All @@ -28,6 +29,8 @@ export async function runCli(options: RunCliOptions = {}): Promise<number> {
process.exitCode = 0;

try {
await maybeWriteCachedUpdateNotification(runtime);

if (runtime.argv.includes("--version")) {
return await handleVersionFlag(runtime);
}
Expand Down
Loading
Loading