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
9 changes: 2 additions & 7 deletions docs/product/command-principles.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ Display one resource or one current context.
Examples:

- `project show`
- `branch show`
- `app show-deploy`

### `list`
Expand All @@ -87,9 +86,7 @@ Change local CLI context only.

`use` changes local active context only.

Example:

- `branch use production`
No current branch command uses `use`; branch targeting follows explicit flags or source context.

### `deploy`

Expand Down Expand Up @@ -156,9 +153,7 @@ MVP rule:
2. local active context is next
3. safe command defaults come last

Only `branch use` changes local active branch context.

Other commands may act on remote state, but they must not silently mutate local context.
Commands may act on remote state, but they must not silently mutate local context.

## Production Must Be Intentionally Harder

Expand Down
26 changes: 3 additions & 23 deletions docs/product/command-spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -533,14 +533,14 @@ prisma-cli git disconnect --json

Purpose:

- list active Platform branches for the resolved project
- list Platform branches for the resolved project

Behavior:

- shows known remote branches for the resolved project
- marks active context
- shows each branch's name, role, and role-derived env map (`production` for `role=production`, `preview` for `role=preview`)
- does not create remote state
- does not expose branch `role` or `durability` fields yet
- does not include branch-specific env overrides, durability, protection, or deployment metadata

Examples:

Expand All @@ -549,26 +549,6 @@ prisma-cli branch list
prisma-cli branch list --json
```

## `prisma-cli branch show`

Purpose:

- show the Platform branch matching your current Git branch

Behavior:

- reads local branch context
- shows resolved project context when known
- does not mutate local or remote state
- does not expose branch `role` or `durability` fields yet

Examples:

```bash
prisma-cli branch show
prisma-cli branch show --json
```

## `prisma-cli app build --entry <path> --build-type <auto|bun|nextjs|nuxt|astro|tanstack-start>`

Purpose:
Expand Down
2 changes: 0 additions & 2 deletions docs/product/output-conventions.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,6 @@ Current MVP commands map to patterns like this:
| `git connect` | `mutate` |
| `git disconnect` | `mutate` |
| `branch list` | `list` |
| `branch show` | `show` |
| `branch use` | `mutate` |

No current MVP command uses `verify` or `inspect`, but new commands must still choose one existing pattern rather than inventing a new one casually.

Expand Down
15 changes: 7 additions & 8 deletions docs/product/resource-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,8 @@ Rules:
- preview branches are disposable by default
- non-production branches can become durable later
- `local` is local CLI context only, not a branch
- active branch context is local CLI state, not `prisma.config.ts`
- selecting a branch changes local CLI context only; it does not create remote
state by itself
- branch context comes from explicit targeting, Git, or safe command defaults,
not `prisma.config.ts`

Examples of preview branches:

Expand All @@ -71,8 +70,8 @@ Examples of preview branches:
- `pr-123`

Branch role and durability are product concepts in the current docs. The preview
command JSON for `branch list` and `branch show` does not expose dedicated
`role` or `durability` fields yet.
command JSON for `branch list` exposes `role`; `durability` remains target-model
until the Management API returns it everywhere.

### Branch Role And Durability

Expand Down Expand Up @@ -231,13 +230,13 @@ feature-branch code into a service owned by another branch.
Commands that use branch context resolve it in this order:

1. explicit branch argument when the command accepts one
2. active branch context in local CLI state
3. `preview`
2. local Git branch when available
3. `main`

Consequences:

- `local` never becomes a branch or deploy target
- first remote app work defaults to `preview`
- first remote app work falls back to `main` when no Git branch is available
- production requires explicit user intent

### Inspect Resolution
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ The beta package exposes `prisma-cli` so it can coexist with the existing
| `auth` | Log in, log out, and inspect the active Prisma account. |
| `project` | List projects, show the resolved project, and manage project environment variables. |
| `git` | Connect or disconnect a project from a GitHub repository. |
| `branch` | Inspect the Prisma branch that maps to the current work context. |
| `branch` | List Prisma branches for the resolved project. |
| `app` | Build, run, deploy, inspect, open, stream logs, promote, roll back, and remove apps. |

Common examples:
Expand All @@ -82,7 +82,7 @@ Common examples:
npx prisma-cli version
npx prisma-cli auth whoami
npx prisma-cli project show
npx prisma-cli branch show
npx prisma-cli branch list
npx prisma-cli app deploy --branch feat-login --framework nextjs
npx prisma-cli app promote <deployment-id>
```
Expand Down
5 changes: 5 additions & 0 deletions packages/cli/fixtures/mock-api.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,30 +71,35 @@
"id": "br_123",
"projectId": "proj_123",
"name": "preview",
"role": "preview",
"currentDeploymentId": "dep_123"
},
{
"id": "br_234",
"projectId": "proj_123",
"name": "pr-123",
"role": "preview",
"currentDeploymentId": "dep_234"
},
{
"id": "br_345",
"projectId": "proj_123",
"name": "staging",
"role": "preview",
"currentDeploymentId": null
},
{
"id": "br_456",
"projectId": "proj_123",
"name": "production",
"role": "production",
"currentDeploymentId": "dep_456"
},
{
"id": "br_789",
"projectId": "proj_456",
"name": "preview",
"role": "preview",
"currentDeploymentId": "dep_789"
}
],
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/adapters/mock-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ interface BranchRecord {
id: string;
projectId: string;
name: string;
role: "production" | "preview";
currentDeploymentId: string | null;
}

Expand Down
51 changes: 3 additions & 48 deletions packages/cli/src/commands/branch/index.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
import { Command } from "commander";

import { runBranchList, runBranchShow, runBranchUse } from "../../controllers/branch";
import { renderBranchList, renderBranchShow, renderBranchUse, serializeBranchList, serializeBranchShow } from "../../presenters/branch";
import { runBranchList } from "../../controllers/branch";
import { renderBranchList, serializeBranchList } from "../../presenters/branch";
import { attachCommandDescriptor } from "../../shell/command-meta";
import { addCompactGlobalFlags, addGlobalFlags } from "../../shell/global-flags";
import { runCommand } from "../../shell/command-runner";
import { configureRuntimeCommand, type CliRuntime } from "../../shell/runtime";
import type { BranchListResult, BranchShowResult } from "../../types/branch";
import type { BranchListResult } from "../../types/branch";

export function createBranchCommand(runtime: CliRuntime): Command {
const branch = attachCommandDescriptor(configureRuntimeCommand(new Command("branch"), runtime), "branch");

addCompactGlobalFlags(branch);

branch.addCommand(createBranchListCommand(runtime));
branch.addCommand(createBranchShowCommand(runtime));
branch.addCommand(createBranchUseCommand(runtime));

return branch;
}
Expand All @@ -40,46 +38,3 @@ function createBranchListCommand(runtime: CliRuntime): Command {

return command;
}

function createBranchShowCommand(runtime: CliRuntime): Command {
const command = attachCommandDescriptor(configureRuntimeCommand(new Command("show"), runtime), "branch.show");

addGlobalFlags(command);

command.action(async (options) => {
await runCommand<BranchShowResult>(
runtime,
"branch.show",
options as Record<string, unknown>,
(context) => runBranchShow(context),
{
renderHuman: (context, descriptor, result) => renderBranchShow(context, descriptor, result),
renderJson: (result) => serializeBranchShow(result),
},
);
});

return command;
}

function createBranchUseCommand(runtime: CliRuntime): Command {
const command = attachCommandDescriptor(configureRuntimeCommand(new Command("use"), runtime), "branch.use");

command.argument("[name]", "Branch name");
addGlobalFlags(command);

command.action(async (branchName: string | undefined, options) => {
await runCommand<BranchShowResult>(
runtime,
"branch.use",
options as Record<string, unknown>,
(context) => runBranchUse(context, branchName),
{
renderHuman: (context, descriptor, result) => renderBranchUse(context, descriptor, result),
renderJson: (result) => serializeBranchShow(result),
},
);
});

return command;
}
Loading
Loading