@prisma/cli 3.0.0-beta.3 → 3.0.0-beta.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -15
- package/dist/adapters/local-state.js +15 -4
- package/dist/adapters/mock-api.js +244 -0
- package/dist/adapters/token-storage.js +335 -34
- package/dist/cli.js +7 -7
- package/dist/cli2.js +24 -5
- package/dist/commands/agent/index.js +60 -0
- package/dist/commands/app/index.js +91 -61
- package/dist/commands/auth/index.js +55 -2
- package/dist/commands/branch/index.js +2 -27
- package/dist/commands/bucket/index.js +123 -0
- package/dist/commands/build/index.js +29 -0
- package/dist/commands/database/index.js +249 -0
- package/dist/commands/env.js +8 -4
- package/dist/commands/feedback/index.js +20 -0
- package/dist/commands/git/index.js +1 -1
- package/dist/commands/init/index.js +33 -0
- package/dist/commands/project/index.js +54 -5
- package/dist/controllers/agent-setup.js +52 -0
- package/dist/controllers/agent.js +228 -0
- package/dist/controllers/app-env-api.js +55 -0
- package/dist/controllers/app-env-file.js +181 -0
- package/dist/controllers/app-env.js +227 -104
- package/dist/controllers/app.js +746 -306
- package/dist/controllers/auth.js +247 -3
- package/dist/controllers/branch.js +78 -48
- package/dist/controllers/bucket.js +278 -0
- package/dist/controllers/build.js +88 -0
- package/dist/controllers/database.js +567 -0
- package/dist/controllers/feedback.js +86 -0
- package/dist/controllers/init.js +753 -0
- package/dist/controllers/project.js +377 -22
- package/dist/controllers/select-prompt-port.js +1 -0
- package/dist/lib/agent/cli-command.js +20 -0
- package/dist/lib/agent/constants.js +12 -0
- package/dist/lib/agent/package-manager.js +99 -0
- package/dist/lib/agent/setup-status.js +83 -0
- package/dist/lib/app/{preview-provider.js → app-provider.js} +137 -88
- package/dist/lib/app/branch-database-api.js +102 -0
- package/dist/lib/app/branch-database-deploy.js +326 -0
- package/dist/lib/app/branch-database.js +216 -0
- package/dist/lib/app/build-settings.js +93 -0
- package/dist/lib/app/build.js +83 -0
- package/dist/lib/app/bun-project.js +3 -4
- package/dist/lib/app/compute-config.js +145 -0
- package/dist/lib/app/deploy-plan.js +59 -0
- package/dist/lib/app/{preview-progress.js → deploy-progress.js} +12 -12
- package/dist/lib/app/env-config.js +1 -1
- package/dist/lib/app/env-file.js +82 -0
- package/dist/lib/app/env-vars.js +28 -2
- package/dist/lib/app/local-dev.js +3 -60
- package/dist/lib/app/production-deploy-gate.js +162 -0
- package/dist/lib/app/read-branch.js +30 -0
- package/dist/lib/auth/auth-ops.js +10 -4
- package/dist/lib/auth/guard.js +4 -1
- package/dist/lib/auth/login.js +33 -26
- package/dist/lib/auth/recipient.js +42 -0
- package/dist/lib/bucket/provider.js +139 -0
- package/dist/lib/database/provider.js +378 -0
- package/dist/lib/diagnostics.js +15 -0
- package/dist/lib/fs/home-path.js +24 -0
- package/dist/lib/git/local-branch.js +53 -0
- package/dist/lib/git/local-status.js +57 -0
- package/dist/lib/project/interactive-setup.js +5 -4
- package/dist/lib/project/local-pin.js +171 -41
- package/dist/lib/project/provider.js +92 -0
- package/dist/lib/project/resolution.js +199 -48
- package/dist/lib/project/setup.js +67 -20
- package/dist/output/patterns.js +1 -1
- package/dist/presenters/agent.js +74 -0
- package/dist/presenters/app-env.js +149 -14
- package/dist/presenters/app.js +208 -27
- package/dist/presenters/auth.js +99 -2
- package/dist/presenters/branch.js +37 -102
- package/dist/presenters/bucket.js +174 -0
- package/dist/presenters/database.js +448 -0
- package/dist/presenters/feedback.js +26 -0
- package/dist/presenters/init.js +30 -0
- package/dist/presenters/project.js +139 -27
- package/dist/presenters/verbose-context.js +64 -0
- package/dist/shell/cli-command.js +12 -0
- package/dist/shell/command-arguments.js +7 -1
- package/dist/shell/command-meta.js +458 -17
- package/dist/shell/command-runner.js +58 -18
- package/dist/shell/diagnostics-output.js +57 -0
- package/dist/shell/errors.js +56 -1
- package/dist/shell/help.js +31 -20
- package/dist/shell/output.js +72 -1
- package/dist/shell/prompt.js +12 -5
- package/dist/shell/runtime.js +8 -4
- package/dist/shell/ui.js +42 -3
- package/dist/shell/update-check.js +2 -2
- package/dist/use-cases/auth.js +68 -1
- package/dist/use-cases/branch.js +20 -68
- package/dist/use-cases/create-cli-gateways.js +2 -17
- package/dist/use-cases/project.js +2 -1
- package/package.json +21 -4
- package/dist/lib/app/preview-build.js +0 -312
- package/dist/lib/app/preview-interaction.js +0 -5
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
import { resolvePrismaCliPackageCommandFormatterSync } from "../lib/agent/cli-command.js";
|
|
2
|
+
import { PRISMA_AGENT_INSTALL_ARGS, PRISMA_AGENT_STATUS_ARGS, PRISMA_AGENT_UPDATE_ARGS, PRISMA_COMPUTE_AGENT_SKILL } from "../lib/agent/constants.js";
|
|
1
3
|
//#region src/shell/command-meta.ts
|
|
2
4
|
const COMMAND_DESCRIPTOR_ID = Symbol("prisma.commandDescriptorId");
|
|
5
|
+
function agentCommandExamples(runtime, commands) {
|
|
6
|
+
const formatCommand = resolvePrismaCliPackageCommandFormatterSync(runtime.cwd);
|
|
7
|
+
return commands.map((command) => formatCommand(command));
|
|
8
|
+
}
|
|
3
9
|
const DESCRIPTORS = [
|
|
4
10
|
{
|
|
5
11
|
id: "root",
|
|
@@ -14,6 +20,99 @@ const DESCRIPTORS = [
|
|
|
14
20
|
description: "Show CLI build and environment",
|
|
15
21
|
examples: ["prisma-cli version", "prisma-cli version --json"]
|
|
16
22
|
},
|
|
23
|
+
{
|
|
24
|
+
id: "feedback",
|
|
25
|
+
path: ["prisma", "feedback"],
|
|
26
|
+
description: "Send feedback to the Prisma CLI team",
|
|
27
|
+
longDescription: "Anonymous unless --email is passed. Every submission includes the CLI version, node version, and OS platform/arch, and nothing else.",
|
|
28
|
+
examples: ["prisma-cli feedback \"the deploy flow is great\"", "prisma-cli feedback \"please add X\" --email you@example.com"]
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
id: "init",
|
|
32
|
+
path: ["prisma", "init"],
|
|
33
|
+
description: "Write a committed compute config for this app",
|
|
34
|
+
examples: (runtime) => agentCommandExamples(runtime, [
|
|
35
|
+
["init"],
|
|
36
|
+
[
|
|
37
|
+
"init",
|
|
38
|
+
"--framework",
|
|
39
|
+
"hono",
|
|
40
|
+
"--entry",
|
|
41
|
+
"src/index.ts"
|
|
42
|
+
],
|
|
43
|
+
[
|
|
44
|
+
"init",
|
|
45
|
+
"--format",
|
|
46
|
+
"json"
|
|
47
|
+
],
|
|
48
|
+
["init", "--no-link"]
|
|
49
|
+
])
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
id: "agent",
|
|
53
|
+
path: ["prisma", "agent"],
|
|
54
|
+
description: "Install Prisma context for AI coding agents",
|
|
55
|
+
examples: (runtime) => agentCommandExamples(runtime, [
|
|
56
|
+
PRISMA_AGENT_INSTALL_ARGS,
|
|
57
|
+
PRISMA_AGENT_UPDATE_ARGS,
|
|
58
|
+
PRISMA_AGENT_STATUS_ARGS
|
|
59
|
+
])
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
id: "agent.install",
|
|
63
|
+
path: [
|
|
64
|
+
"prisma",
|
|
65
|
+
"agent",
|
|
66
|
+
"install"
|
|
67
|
+
],
|
|
68
|
+
description: "Install Prisma skills for AI coding agents",
|
|
69
|
+
examples: (runtime) => agentCommandExamples(runtime, [
|
|
70
|
+
PRISMA_AGENT_INSTALL_ARGS,
|
|
71
|
+
[
|
|
72
|
+
...PRISMA_AGENT_INSTALL_ARGS,
|
|
73
|
+
"--agent",
|
|
74
|
+
"codex"
|
|
75
|
+
],
|
|
76
|
+
[...PRISMA_AGENT_INSTALL_ARGS, "--all-agents"],
|
|
77
|
+
[
|
|
78
|
+
...PRISMA_AGENT_INSTALL_ARGS,
|
|
79
|
+
"--skill",
|
|
80
|
+
PRISMA_COMPUTE_AGENT_SKILL
|
|
81
|
+
]
|
|
82
|
+
])
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
id: "agent.update",
|
|
86
|
+
path: [
|
|
87
|
+
"prisma",
|
|
88
|
+
"agent",
|
|
89
|
+
"update"
|
|
90
|
+
],
|
|
91
|
+
description: "Refresh Prisma skills for AI coding agents",
|
|
92
|
+
examples: (runtime) => agentCommandExamples(runtime, [
|
|
93
|
+
PRISMA_AGENT_UPDATE_ARGS,
|
|
94
|
+
[
|
|
95
|
+
...PRISMA_AGENT_UPDATE_ARGS,
|
|
96
|
+
"--agent",
|
|
97
|
+
"codex"
|
|
98
|
+
],
|
|
99
|
+
[...PRISMA_AGENT_UPDATE_ARGS, "--all-agents"]
|
|
100
|
+
])
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
id: "agent.status",
|
|
104
|
+
path: [
|
|
105
|
+
"prisma",
|
|
106
|
+
"agent",
|
|
107
|
+
"status"
|
|
108
|
+
],
|
|
109
|
+
description: "Show installed Prisma skills",
|
|
110
|
+
examples: (runtime) => agentCommandExamples(runtime, [
|
|
111
|
+
PRISMA_AGENT_STATUS_ARGS,
|
|
112
|
+
[...PRISMA_AGENT_STATUS_ARGS, "--json"],
|
|
113
|
+
[...PRISMA_AGENT_STATUS_ARGS, "--global"]
|
|
114
|
+
])
|
|
115
|
+
},
|
|
17
116
|
{
|
|
18
117
|
id: "auth",
|
|
19
118
|
path: ["prisma", "auth"],
|
|
@@ -50,6 +149,58 @@ const DESCRIPTORS = [
|
|
|
50
149
|
description: "Show the authenticated user and accessible workspace",
|
|
51
150
|
examples: ["prisma-cli auth whoami", "prisma-cli auth whoami --json"]
|
|
52
151
|
},
|
|
152
|
+
{
|
|
153
|
+
id: "auth.workspace",
|
|
154
|
+
path: [
|
|
155
|
+
"prisma",
|
|
156
|
+
"auth",
|
|
157
|
+
"workspace"
|
|
158
|
+
],
|
|
159
|
+
description: "Manage local authenticated workspaces",
|
|
160
|
+
examples: [
|
|
161
|
+
"prisma-cli auth workspace list",
|
|
162
|
+
"prisma-cli auth workspace use",
|
|
163
|
+
"prisma-cli auth workspace use wksp_123",
|
|
164
|
+
"prisma-cli auth workspace logout wksp_123"
|
|
165
|
+
]
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
id: "auth.workspace.list",
|
|
169
|
+
path: [
|
|
170
|
+
"prisma",
|
|
171
|
+
"auth",
|
|
172
|
+
"workspace",
|
|
173
|
+
"list"
|
|
174
|
+
],
|
|
175
|
+
description: "List locally authenticated workspaces",
|
|
176
|
+
examples: ["prisma-cli auth workspace list", "prisma-cli auth workspace list --json"]
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
id: "auth.workspace.use",
|
|
180
|
+
path: [
|
|
181
|
+
"prisma",
|
|
182
|
+
"auth",
|
|
183
|
+
"workspace",
|
|
184
|
+
"use"
|
|
185
|
+
],
|
|
186
|
+
description: "Switch the local CLI workspace",
|
|
187
|
+
examples: [
|
|
188
|
+
"prisma-cli auth workspace use",
|
|
189
|
+
"prisma-cli auth workspace use wksp_123",
|
|
190
|
+
"prisma-cli auth workspace use \"Acme Inc\""
|
|
191
|
+
]
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
id: "auth.workspace.logout",
|
|
195
|
+
path: [
|
|
196
|
+
"prisma",
|
|
197
|
+
"auth",
|
|
198
|
+
"workspace",
|
|
199
|
+
"logout"
|
|
200
|
+
],
|
|
201
|
+
description: "Remove one local OAuth workspace session",
|
|
202
|
+
examples: ["prisma-cli auth workspace logout wksp_123", "prisma-cli auth workspace logout \"Acme Inc\""]
|
|
203
|
+
},
|
|
53
204
|
{
|
|
54
205
|
id: "project",
|
|
55
206
|
path: ["prisma", "project"],
|
|
@@ -69,8 +220,133 @@ const DESCRIPTORS = [
|
|
|
69
220
|
{
|
|
70
221
|
id: "branch",
|
|
71
222
|
path: ["prisma", "branch"],
|
|
72
|
-
description: "View your
|
|
73
|
-
examples: ["prisma-cli branch list"
|
|
223
|
+
description: "View your Platform branches",
|
|
224
|
+
examples: ["prisma-cli branch list"]
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
id: "build",
|
|
228
|
+
path: ["prisma", "build"],
|
|
229
|
+
description: "Inspect builds",
|
|
230
|
+
examples: ["prisma-cli build logs <build_id>"]
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
id: "build.logs",
|
|
234
|
+
path: [
|
|
235
|
+
"prisma",
|
|
236
|
+
"build",
|
|
237
|
+
"logs"
|
|
238
|
+
],
|
|
239
|
+
description: "Stream the logs for a build",
|
|
240
|
+
examples: ["prisma-cli build logs <build_id>", "prisma-cli build logs <build_id> --follow"]
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
id: "database",
|
|
244
|
+
path: ["prisma", "database"],
|
|
245
|
+
description: "Manage Prisma Postgres databases for a project",
|
|
246
|
+
examples: [
|
|
247
|
+
"prisma-cli database list",
|
|
248
|
+
"prisma-cli database create my-db",
|
|
249
|
+
"prisma-cli database connection create db_123"
|
|
250
|
+
]
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
id: "bucket",
|
|
254
|
+
path: ["prisma", "bucket"],
|
|
255
|
+
description: "Manage object-store buckets for a project",
|
|
256
|
+
examples: [
|
|
257
|
+
"prisma-cli bucket list",
|
|
258
|
+
"prisma-cli bucket create",
|
|
259
|
+
"prisma-cli bucket key create bkt_123"
|
|
260
|
+
]
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
id: "bucket.list",
|
|
264
|
+
path: [
|
|
265
|
+
"prisma",
|
|
266
|
+
"bucket",
|
|
267
|
+
"list"
|
|
268
|
+
],
|
|
269
|
+
description: "List object-store buckets for the resolved project",
|
|
270
|
+
examples: [
|
|
271
|
+
"prisma-cli bucket list",
|
|
272
|
+
"prisma-cli bucket list --branch preview",
|
|
273
|
+
"prisma-cli bucket list --json"
|
|
274
|
+
]
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
id: "bucket.create",
|
|
278
|
+
path: [
|
|
279
|
+
"prisma",
|
|
280
|
+
"bucket",
|
|
281
|
+
"create"
|
|
282
|
+
],
|
|
283
|
+
description: "Create an object-store bucket",
|
|
284
|
+
examples: [
|
|
285
|
+
"prisma-cli bucket create",
|
|
286
|
+
"prisma-cli bucket create --name my-store",
|
|
287
|
+
"prisma-cli bucket create --branch preview --json"
|
|
288
|
+
]
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
id: "bucket.delete",
|
|
292
|
+
path: [
|
|
293
|
+
"prisma",
|
|
294
|
+
"bucket",
|
|
295
|
+
"delete"
|
|
296
|
+
],
|
|
297
|
+
description: "Delete a bucket and all its access keys",
|
|
298
|
+
examples: ["prisma-cli bucket delete bkt_123"]
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
id: "bucket.key",
|
|
302
|
+
path: [
|
|
303
|
+
"prisma",
|
|
304
|
+
"bucket",
|
|
305
|
+
"key"
|
|
306
|
+
],
|
|
307
|
+
description: "Manage access keys for an object-store bucket",
|
|
308
|
+
examples: [
|
|
309
|
+
"prisma-cli bucket key list bkt_123",
|
|
310
|
+
"prisma-cli bucket key create bkt_123",
|
|
311
|
+
"prisma-cli bucket key delete bkt_123 bkey_456"
|
|
312
|
+
]
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
id: "bucket.key.list",
|
|
316
|
+
path: [
|
|
317
|
+
"prisma",
|
|
318
|
+
"bucket",
|
|
319
|
+
"key",
|
|
320
|
+
"list"
|
|
321
|
+
],
|
|
322
|
+
description: "List access keys for a bucket",
|
|
323
|
+
examples: ["prisma-cli bucket key list bkt_123", "prisma-cli bucket key list bkt_123 --json"]
|
|
324
|
+
},
|
|
325
|
+
{
|
|
326
|
+
id: "bucket.key.create",
|
|
327
|
+
path: [
|
|
328
|
+
"prisma",
|
|
329
|
+
"bucket",
|
|
330
|
+
"key",
|
|
331
|
+
"create"
|
|
332
|
+
],
|
|
333
|
+
description: "Create a bucket access key and print its one-time credentials",
|
|
334
|
+
examples: [
|
|
335
|
+
"prisma-cli bucket key create bkt_123",
|
|
336
|
+
"prisma-cli bucket key create bkt_123 --role read",
|
|
337
|
+
"prisma-cli bucket key create bkt_123 --name ci-key --role read_write"
|
|
338
|
+
]
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
id: "bucket.key.delete",
|
|
342
|
+
path: [
|
|
343
|
+
"prisma",
|
|
344
|
+
"bucket",
|
|
345
|
+
"key",
|
|
346
|
+
"delete"
|
|
347
|
+
],
|
|
348
|
+
description: "Revoke and delete a bucket access key",
|
|
349
|
+
examples: ["prisma-cli bucket key delete bkt_123 bkey_456"]
|
|
74
350
|
},
|
|
75
351
|
{
|
|
76
352
|
id: "git",
|
|
@@ -122,6 +398,36 @@ const DESCRIPTORS = [
|
|
|
122
398
|
"prisma-cli project link \"Acme Dashboard\" --json"
|
|
123
399
|
]
|
|
124
400
|
},
|
|
401
|
+
{
|
|
402
|
+
id: "project.rename",
|
|
403
|
+
path: [
|
|
404
|
+
"prisma",
|
|
405
|
+
"project",
|
|
406
|
+
"rename"
|
|
407
|
+
],
|
|
408
|
+
description: "Rename the resolved Project",
|
|
409
|
+
examples: ["prisma-cli project rename \"Acme Dashboard v2\"", "prisma-cli project rename billing-api --project proj_123"]
|
|
410
|
+
},
|
|
411
|
+
{
|
|
412
|
+
id: "project.remove",
|
|
413
|
+
path: [
|
|
414
|
+
"prisma",
|
|
415
|
+
"project",
|
|
416
|
+
"remove"
|
|
417
|
+
],
|
|
418
|
+
description: "Remove a Project permanently after exact id confirmation",
|
|
419
|
+
examples: ["prisma-cli project remove proj_123 --confirm proj_123"]
|
|
420
|
+
},
|
|
421
|
+
{
|
|
422
|
+
id: "project.transfer",
|
|
423
|
+
path: [
|
|
424
|
+
"prisma",
|
|
425
|
+
"project",
|
|
426
|
+
"transfer"
|
|
427
|
+
],
|
|
428
|
+
description: "Transfer a Project to another workspace after exact id confirmation",
|
|
429
|
+
examples: ["prisma-cli project transfer proj_123 --to-workspace \"Prisma Labs\" --confirm proj_123", "prisma-cli project transfer proj_123 --recipient-token <token> --confirm proj_123"]
|
|
430
|
+
},
|
|
125
431
|
{
|
|
126
432
|
id: "git.connect",
|
|
127
433
|
path: [
|
|
@@ -153,28 +459,151 @@ const DESCRIPTORS = [
|
|
|
153
459
|
"branch",
|
|
154
460
|
"list"
|
|
155
461
|
],
|
|
156
|
-
description: "List
|
|
462
|
+
description: "List Platform branches for the resolved project",
|
|
157
463
|
examples: ["prisma-cli branch list", "prisma-cli branch list --json"]
|
|
158
464
|
},
|
|
159
465
|
{
|
|
160
|
-
id: "
|
|
466
|
+
id: "database.list",
|
|
161
467
|
path: [
|
|
162
468
|
"prisma",
|
|
163
|
-
"
|
|
469
|
+
"database",
|
|
470
|
+
"list"
|
|
471
|
+
],
|
|
472
|
+
description: "List Prisma Postgres databases for the resolved project",
|
|
473
|
+
examples: [
|
|
474
|
+
"prisma-cli database list",
|
|
475
|
+
"prisma-cli database list --branch feature/foo",
|
|
476
|
+
"prisma-cli database list --json"
|
|
477
|
+
]
|
|
478
|
+
},
|
|
479
|
+
{
|
|
480
|
+
id: "database.show",
|
|
481
|
+
path: [
|
|
482
|
+
"prisma",
|
|
483
|
+
"database",
|
|
164
484
|
"show"
|
|
165
485
|
],
|
|
166
|
-
description: "Show
|
|
167
|
-
examples: ["prisma-cli
|
|
486
|
+
description: "Show database metadata without secret values",
|
|
487
|
+
examples: ["prisma-cli database show db_123", "prisma-cli database show acme-preview --branch preview --json"]
|
|
168
488
|
},
|
|
169
489
|
{
|
|
170
|
-
id: "
|
|
490
|
+
id: "database.create",
|
|
171
491
|
path: [
|
|
172
492
|
"prisma",
|
|
173
|
-
"
|
|
174
|
-
"
|
|
493
|
+
"database",
|
|
494
|
+
"create"
|
|
175
495
|
],
|
|
176
|
-
description: "
|
|
177
|
-
examples: ["prisma-cli
|
|
496
|
+
description: "Create a Prisma Postgres database and print its one-time connection URL",
|
|
497
|
+
examples: ["prisma-cli database create my-db", "prisma-cli database create my-db --branch feature/foo --region eu-central-1"]
|
|
498
|
+
},
|
|
499
|
+
{
|
|
500
|
+
id: "database.usage",
|
|
501
|
+
path: [
|
|
502
|
+
"prisma",
|
|
503
|
+
"database",
|
|
504
|
+
"usage"
|
|
505
|
+
],
|
|
506
|
+
description: "Show usage metrics for a database",
|
|
507
|
+
examples: ["prisma-cli database usage db_123", "prisma-cli database usage acme-production --from 2026-06-01 --to 2026-06-30"]
|
|
508
|
+
},
|
|
509
|
+
{
|
|
510
|
+
id: "database.restore",
|
|
511
|
+
path: [
|
|
512
|
+
"prisma",
|
|
513
|
+
"database",
|
|
514
|
+
"restore"
|
|
515
|
+
],
|
|
516
|
+
description: "Restore a database from a backup after exact id confirmation",
|
|
517
|
+
examples: ["prisma-cli database restore db_123 --backup bkp_456 --confirm db_123"]
|
|
518
|
+
},
|
|
519
|
+
{
|
|
520
|
+
id: "database.remove",
|
|
521
|
+
path: [
|
|
522
|
+
"prisma",
|
|
523
|
+
"database",
|
|
524
|
+
"remove"
|
|
525
|
+
],
|
|
526
|
+
description: "Remove a database after exact id confirmation",
|
|
527
|
+
examples: ["prisma-cli database remove db_123 --confirm db_123"]
|
|
528
|
+
},
|
|
529
|
+
{
|
|
530
|
+
id: "database.backup",
|
|
531
|
+
path: [
|
|
532
|
+
"prisma",
|
|
533
|
+
"database",
|
|
534
|
+
"backup"
|
|
535
|
+
],
|
|
536
|
+
description: "Inspect platform-created database backups",
|
|
537
|
+
examples: ["prisma-cli database backup list db_123"]
|
|
538
|
+
},
|
|
539
|
+
{
|
|
540
|
+
id: "database.backup.list",
|
|
541
|
+
path: [
|
|
542
|
+
"prisma",
|
|
543
|
+
"database",
|
|
544
|
+
"backup",
|
|
545
|
+
"list"
|
|
546
|
+
],
|
|
547
|
+
description: "List backups for a database",
|
|
548
|
+
examples: ["prisma-cli database backup list db_123", "prisma-cli database backup list acme-production --limit 50"]
|
|
549
|
+
},
|
|
550
|
+
{
|
|
551
|
+
id: "database.connection",
|
|
552
|
+
path: [
|
|
553
|
+
"prisma",
|
|
554
|
+
"database",
|
|
555
|
+
"connection"
|
|
556
|
+
],
|
|
557
|
+
description: "Manage one-time-view database connection strings",
|
|
558
|
+
examples: [
|
|
559
|
+
"prisma-cli database connection list db_123",
|
|
560
|
+
"prisma-cli database connection create db_123",
|
|
561
|
+
"prisma-cli database connection remove conn_123 --confirm conn_123"
|
|
562
|
+
]
|
|
563
|
+
},
|
|
564
|
+
{
|
|
565
|
+
id: "database.connection.list",
|
|
566
|
+
path: [
|
|
567
|
+
"prisma",
|
|
568
|
+
"database",
|
|
569
|
+
"connection",
|
|
570
|
+
"list"
|
|
571
|
+
],
|
|
572
|
+
description: "List database connection metadata without secret values",
|
|
573
|
+
examples: ["prisma-cli database connection list db_123", "prisma-cli database connection list acme-preview --branch preview --json"]
|
|
574
|
+
},
|
|
575
|
+
{
|
|
576
|
+
id: "database.connection.create",
|
|
577
|
+
path: [
|
|
578
|
+
"prisma",
|
|
579
|
+
"database",
|
|
580
|
+
"connection",
|
|
581
|
+
"create"
|
|
582
|
+
],
|
|
583
|
+
description: "Create a database connection and print its one-time connection URL",
|
|
584
|
+
examples: ["prisma-cli database connection create db_123", "prisma-cli database connection create db_123 --name readonly"]
|
|
585
|
+
},
|
|
586
|
+
{
|
|
587
|
+
id: "database.connection.rotate",
|
|
588
|
+
path: [
|
|
589
|
+
"prisma",
|
|
590
|
+
"database",
|
|
591
|
+
"connection",
|
|
592
|
+
"rotate"
|
|
593
|
+
],
|
|
594
|
+
description: "Rotate connection credentials and print the new one-time connection URL",
|
|
595
|
+
examples: ["prisma-cli database connection rotate conn_123 --confirm conn_123"]
|
|
596
|
+
},
|
|
597
|
+
{
|
|
598
|
+
id: "database.connection.remove",
|
|
599
|
+
path: [
|
|
600
|
+
"prisma",
|
|
601
|
+
"database",
|
|
602
|
+
"connection",
|
|
603
|
+
"remove"
|
|
604
|
+
],
|
|
605
|
+
description: "Remove a database connection after exact id confirmation",
|
|
606
|
+
examples: ["prisma-cli database connection remove conn_123 --confirm conn_123"]
|
|
178
607
|
},
|
|
179
608
|
{
|
|
180
609
|
id: "app.build",
|
|
@@ -208,15 +637,18 @@ const DESCRIPTORS = [
|
|
|
208
637
|
"deploy"
|
|
209
638
|
],
|
|
210
639
|
description: "Creates a new deployment for the app",
|
|
211
|
-
longDescription: "Agent skills for guided Next.js deploys are available from the Prisma CLI skill cluster.",
|
|
212
640
|
examples: [
|
|
213
641
|
"prisma-cli app deploy",
|
|
214
642
|
"prisma-cli app deploy --project proj_123",
|
|
215
643
|
"prisma-cli app deploy --create-project my-app --yes",
|
|
216
644
|
"prisma-cli app deploy --app my-app --env DATABASE_URL=postgresql://example",
|
|
645
|
+
"prisma-cli app deploy --env .env",
|
|
646
|
+
"prisma-cli app deploy --db",
|
|
647
|
+
"prisma-cli app deploy --db --yes",
|
|
217
648
|
"prisma-cli app deploy --app my-app --framework nextjs --http-port 3000",
|
|
649
|
+
"prisma-cli app deploy --app my-app --region us-west-1",
|
|
218
650
|
"prisma-cli app deploy --branch feat-login --framework hono",
|
|
219
|
-
"
|
|
651
|
+
"prisma-cli app deploy --prod --yes",
|
|
220
652
|
"prisma-cli app deploy --framework bun --entry src/server.ts"
|
|
221
653
|
]
|
|
222
654
|
},
|
|
@@ -366,8 +798,12 @@ const DESCRIPTORS = [
|
|
|
366
798
|
"app",
|
|
367
799
|
"remove"
|
|
368
800
|
],
|
|
369
|
-
description: "Remove the app from the
|
|
370
|
-
examples: [
|
|
801
|
+
description: "Remove the app from the resolved branch",
|
|
802
|
+
examples: [
|
|
803
|
+
"prisma-cli app remove --app hello-world",
|
|
804
|
+
"prisma-cli app remove --app hello-world --yes",
|
|
805
|
+
"prisma-cli app remove --app hello-world --branch feature/foo --yes"
|
|
806
|
+
]
|
|
371
807
|
},
|
|
372
808
|
{
|
|
373
809
|
id: "project.env",
|
|
@@ -378,8 +814,9 @@ const DESCRIPTORS = [
|
|
|
378
814
|
],
|
|
379
815
|
description: "Manage environment variables for the active project",
|
|
380
816
|
examples: [
|
|
381
|
-
"prisma-cli project env list
|
|
817
|
+
"prisma-cli project env list",
|
|
382
818
|
"prisma-cli project env add STRIPE_KEY=sk_test_xxx --role production",
|
|
819
|
+
"prisma-cli project env add --file .env --role preview",
|
|
383
820
|
"prisma-cli project env add DATABASE_URL=postgresql://branch --branch feature/foo",
|
|
384
821
|
"prisma-cli project env remove STRIPE_KEY --role preview"
|
|
385
822
|
]
|
|
@@ -396,7 +833,9 @@ const DESCRIPTORS = [
|
|
|
396
833
|
examples: [
|
|
397
834
|
"prisma-cli project env add STRIPE_KEY=sk_test_xxx --role production",
|
|
398
835
|
"prisma-cli project env add STRIPE_KEY=sk_test_xxx --role preview",
|
|
836
|
+
"prisma-cli project env add --file .env --role preview",
|
|
399
837
|
"prisma-cli project env add DATABASE_URL=postgresql://branch --branch feature/foo",
|
|
838
|
+
"prisma-cli project env add --file .env.local --branch feature/foo",
|
|
400
839
|
"API_URL=https://api.example prisma-cli project env add API_URL --project proj_123 --role preview"
|
|
401
840
|
]
|
|
402
841
|
},
|
|
@@ -412,6 +851,7 @@ const DESCRIPTORS = [
|
|
|
412
851
|
examples: [
|
|
413
852
|
"prisma-cli project env update STRIPE_KEY=sk_new_xxx --role production",
|
|
414
853
|
"prisma-cli project env update STRIPE_KEY=sk_new_xxx --role preview",
|
|
854
|
+
"prisma-cli project env update --file .env --role production",
|
|
415
855
|
"prisma-cli project env update DATABASE_URL=postgresql://branch --branch feature/foo"
|
|
416
856
|
]
|
|
417
857
|
},
|
|
@@ -425,6 +865,7 @@ const DESCRIPTORS = [
|
|
|
425
865
|
],
|
|
426
866
|
description: "List environment variable metadata for a scope (no values).",
|
|
427
867
|
examples: [
|
|
868
|
+
"prisma-cli project env list",
|
|
428
869
|
"prisma-cli project env list --role production",
|
|
429
870
|
"prisma-cli project env list --role preview",
|
|
430
871
|
"prisma-cli project env list --branch feature/foo"
|
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
import { CliError, authRequiredError, commandCanceledError } from "./errors.js";
|
|
2
|
-
import { cliErrorToJson, writeHumanError, writeHumanLines, writeJsonError, writeJsonEvent, writeJsonSuccess } from "./output.js";
|
|
1
|
+
import { CliError, authConfigInvalidError, authRequiredError, commandCanceledError } from "./errors.js";
|
|
3
2
|
import { getCommandDescriptor } from "./command-meta.js";
|
|
3
|
+
import { renderSummaryLine } from "./ui.js";
|
|
4
4
|
import { resolveGlobalFlags } from "./global-flags.js";
|
|
5
5
|
import { createCommandContext } from "./runtime.js";
|
|
6
|
+
import { collectCommandDiagnostics } from "../lib/diagnostics.js";
|
|
7
|
+
import { renderCommandDiagnostics } from "./diagnostics-output.js";
|
|
8
|
+
import { cliErrorToJson, writeHumanError, writeHumanLines, writeJsonError, writeJsonEvent, writeJsonSuccess } from "./output.js";
|
|
6
9
|
import { AuthError } from "@prisma/management-api-sdk";
|
|
7
10
|
//#region src/shell/command-runner.ts
|
|
8
11
|
function toCliError(error, runtime) {
|
|
9
12
|
if (isCancellationError(error) || runtime.signal.aborted) return commandCanceledError();
|
|
10
13
|
if (error instanceof CliError) return error;
|
|
11
14
|
if (error instanceof AuthError) return authRequiredError(["prisma-cli auth login"], { debug: error.message });
|
|
15
|
+
if (error instanceof Error && error.message.startsWith("PRISMA_SERVICE_TOKEN is set but empty")) return authConfigInvalidError(error.message);
|
|
12
16
|
return null;
|
|
13
17
|
}
|
|
14
18
|
function isCancellationError(error) {
|
|
@@ -16,37 +20,73 @@ function isCancellationError(error) {
|
|
|
16
20
|
return error.name === "AbortError" || error.name === "CancelledError";
|
|
17
21
|
}
|
|
18
22
|
async function runCommand(runtime, commandName, options, handler, presenter) {
|
|
19
|
-
const
|
|
20
|
-
const context = await createCommandContext(runtime, flags);
|
|
23
|
+
const context = await createCommandContext(runtime, resolveGlobalFlags(runtime.argv, options));
|
|
21
24
|
const descriptor = getCommandDescriptor(commandName);
|
|
25
|
+
const startedAt = Date.now();
|
|
22
26
|
try {
|
|
23
|
-
|
|
24
|
-
if (flags.json) {
|
|
25
|
-
writeJsonSuccess(context.output, {
|
|
26
|
-
...success,
|
|
27
|
-
result: presenter.renderJson ? presenter.renderJson(success.result) : success.result
|
|
28
|
-
});
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
if (flags.quiet) return;
|
|
32
|
-
writeHumanLines(context.output, presenter.renderHuman(context, descriptor, success.result));
|
|
27
|
+
await writeCommandSuccess(context, descriptor, await handler(context), presenter, Date.now() - startedAt);
|
|
33
28
|
} catch (error) {
|
|
34
29
|
const cliError = toCliError(error, runtime);
|
|
35
30
|
if (cliError) {
|
|
36
|
-
|
|
37
|
-
else writeHumanError(context.output, context.ui, cliError, { trace: flags.trace });
|
|
31
|
+
writeCommandError(context, commandName, cliError);
|
|
38
32
|
process.exitCode = cliError.exitCode;
|
|
39
33
|
return;
|
|
40
34
|
}
|
|
41
35
|
throw error;
|
|
42
36
|
}
|
|
43
37
|
}
|
|
44
|
-
async function
|
|
38
|
+
async function writeCommandSuccess(context, descriptor, success, presenter, durationMs) {
|
|
39
|
+
if (context.flags.json) {
|
|
40
|
+
writeJsonSuccess(context.output, {
|
|
41
|
+
...success,
|
|
42
|
+
result: presenter.renderJson ? presenter.renderJson(success.result) : success.result
|
|
43
|
+
});
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const stdout = presenter.renderStdout?.(context, descriptor, success.result) ?? [];
|
|
47
|
+
if (context.flags.quiet) {
|
|
48
|
+
writeStdoutLines(context, stdout);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const rendered = presenter.renderHuman(context, descriptor, success.result);
|
|
52
|
+
const warningLines = success.warnings.map((warning) => renderSummaryLine(context.ui, "warning", warning));
|
|
53
|
+
const diagnostics = await renderBestEffortCommandDiagnostics(context, {
|
|
54
|
+
enabled: context.flags.verbose && rendered.length > 0,
|
|
55
|
+
durationMs
|
|
56
|
+
});
|
|
57
|
+
const humanLines = [
|
|
58
|
+
...rendered,
|
|
59
|
+
...warningLines,
|
|
60
|
+
...diagnostics
|
|
61
|
+
];
|
|
62
|
+
if (stdout.length > 0 && humanLines.length > 0) humanLines.push("");
|
|
63
|
+
writeHumanLines(context.output, humanLines);
|
|
64
|
+
writeStdoutLines(context, stdout);
|
|
65
|
+
}
|
|
66
|
+
function writeCommandError(context, commandName, cliError) {
|
|
67
|
+
if (context.flags.json) {
|
|
68
|
+
writeJsonError(context.output, commandName, cliError);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
writeHumanError(context.output, context.ui, cliError, { trace: context.flags.trace });
|
|
72
|
+
}
|
|
73
|
+
function writeStdoutLines(context, lines) {
|
|
74
|
+
if (lines.length > 0) context.output.stdout.write(`${lines.join("\n")}\n`);
|
|
75
|
+
}
|
|
76
|
+
async function renderBestEffortCommandDiagnostics(context, options) {
|
|
77
|
+
if (!options.enabled) return [];
|
|
78
|
+
try {
|
|
79
|
+
return renderCommandDiagnostics(context, await collectCommandDiagnostics(context, { durationMs: options.durationMs }));
|
|
80
|
+
} catch {
|
|
81
|
+
return [];
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
async function runStreamingCommand(runtime, commandName, options, handler, streamOptions) {
|
|
45
85
|
const flags = resolveGlobalFlags(runtime.argv, options);
|
|
46
86
|
const context = await createCommandContext(runtime, flags);
|
|
47
87
|
try {
|
|
48
88
|
await handler(context);
|
|
49
|
-
if (flags.json) writeJsonEvent(context.output, {
|
|
89
|
+
if (flags.json && (streamOptions?.emitJsonSuccessEvent ?? true)) writeJsonEvent(context.output, {
|
|
50
90
|
type: "success",
|
|
51
91
|
command: commandName,
|
|
52
92
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|