@prisma/cli 3.0.0-alpha.1 → 3.0.0-alpha.3

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.
@@ -0,0 +1,129 @@
1
+ import { renderList, renderShow, serializeList } from "../output/patterns.js";
2
+ //#region src/presenters/app-env.ts
3
+ function scopeLabel(scope) {
4
+ return scope.role;
5
+ }
6
+ function renderEnvAdd(context, descriptor, result) {
7
+ return renderShow({
8
+ title: "Setting a new environment variable.",
9
+ descriptor,
10
+ fields: [
11
+ {
12
+ key: "project",
13
+ value: result.projectId
14
+ },
15
+ {
16
+ key: "scope",
17
+ value: scopeLabel(result.scope)
18
+ },
19
+ {
20
+ key: "key",
21
+ value: result.variable.key
22
+ },
23
+ {
24
+ key: "id",
25
+ value: result.variable.id,
26
+ tone: "dim"
27
+ },
28
+ {
29
+ key: "last updated",
30
+ value: result.variable.updatedAt,
31
+ tone: "dim"
32
+ }
33
+ ]
34
+ }, context.ui);
35
+ }
36
+ function serializeEnvAdd(result) {
37
+ return result;
38
+ }
39
+ function renderEnvUpdate(context, descriptor, result) {
40
+ return renderShow({
41
+ title: "Replacing the environment variable's value.",
42
+ descriptor,
43
+ fields: [
44
+ {
45
+ key: "project",
46
+ value: result.projectId
47
+ },
48
+ {
49
+ key: "scope",
50
+ value: scopeLabel(result.scope)
51
+ },
52
+ {
53
+ key: "key",
54
+ value: result.variable.key
55
+ },
56
+ {
57
+ key: "id",
58
+ value: result.variable.id,
59
+ tone: "dim"
60
+ },
61
+ {
62
+ key: "last updated",
63
+ value: result.variable.updatedAt,
64
+ tone: "dim"
65
+ }
66
+ ]
67
+ }, context.ui);
68
+ }
69
+ function serializeEnvUpdate(result) {
70
+ return result;
71
+ }
72
+ function renderEnvList(context, descriptor, result) {
73
+ return renderList({
74
+ title: "Listing environment variables for the selected scope.",
75
+ descriptor,
76
+ parentContext: {
77
+ key: "scope",
78
+ value: scopeLabel(result.scope)
79
+ },
80
+ items: result.variables.map((variable) => ({
81
+ noun: "variable",
82
+ label: variable.key,
83
+ id: variable.id,
84
+ status: variable.isManagedBySystem ? "default" : null
85
+ })),
86
+ emptyMessage: "No environment variables defined in this scope."
87
+ }, context.ui);
88
+ }
89
+ function serializeEnvList(result) {
90
+ return {
91
+ projectId: result.projectId,
92
+ scope: result.scope,
93
+ ...serializeList({
94
+ context: { scope: scopeLabel(result.scope) },
95
+ items: result.variables.map((variable) => ({
96
+ noun: "variable",
97
+ label: variable.key,
98
+ id: variable.id,
99
+ status: variable.isManagedBySystem ? "default" : null
100
+ }))
101
+ }),
102
+ variables: result.variables
103
+ };
104
+ }
105
+ function renderEnvRm(context, descriptor, result) {
106
+ return renderShow({
107
+ title: "Removing the environment variable from the scope.",
108
+ descriptor,
109
+ fields: [
110
+ {
111
+ key: "project",
112
+ value: result.projectId
113
+ },
114
+ {
115
+ key: "scope",
116
+ value: scopeLabel(result.scope)
117
+ },
118
+ {
119
+ key: "key",
120
+ value: result.key
121
+ }
122
+ ]
123
+ }, context.ui);
124
+ }
125
+ function serializeEnvRm(result) {
126
+ return result;
127
+ }
128
+ //#endregion
129
+ export { renderEnvAdd, renderEnvList, renderEnvRm, renderEnvUpdate, serializeEnvAdd, serializeEnvList, serializeEnvRm, serializeEnvUpdate };
@@ -9,7 +9,7 @@ function renderAuthSuccess(context, descriptor, command, result) {
9
9
  });
10
10
  if (result.user) rows.push({
11
11
  key: "user",
12
- value: `${result.user.name} <${result.user.email}>`
12
+ value: result.user.email
13
13
  });
14
14
  if (result.workspace?.name) rows.push({
15
15
  key: "workspace",
@@ -47,7 +47,7 @@ function renderAuthSuccess(context, descriptor, command, result) {
47
47
  },
48
48
  ...result.user ? [{
49
49
  key: "user",
50
- value: `${result.user.name} <${result.user.email}>`
50
+ value: result.user.email
51
51
  }] : [],
52
52
  ...result.provider ? [{
53
53
  key: "provider",
@@ -4,17 +4,15 @@ const DESCRIPTORS = [
4
4
  {
5
5
  id: "root",
6
6
  path: ["prisma"],
7
- description: "Unified Prisma CLI.",
8
- docsPath: "docs/product/command-principles.md",
9
- examples: ["prisma auth login", "prisma project list"],
10
- longDescription: "The Prisma CLI groups commands by developer workflow and keeps human and agent behavior aligned."
7
+ description: "The Prisma Developer Platform, from your terminal",
8
+ examples: ["prisma-cli auth login", "prisma-cli app deploy"],
9
+ longDescription: "Deploy your app with isolated infrastructure for every branch"
11
10
  },
12
11
  {
13
12
  id: "auth",
14
13
  path: ["prisma", "auth"],
15
- description: "Authentication and identity commands.",
16
- docsPath: "docs/product/command-spec.md#prisma-auth-login",
17
- examples: ["prisma auth login", "prisma auth whoami"]
14
+ description: "Manage local authentication for the CLI",
15
+ examples: ["prisma-cli auth login", "prisma-cli auth whoami"]
18
16
  },
19
17
  {
20
18
  id: "auth.login",
@@ -23,9 +21,8 @@ const DESCRIPTORS = [
23
21
  "auth",
24
22
  "login"
25
23
  ],
26
- description: "Start an authenticated CLI session.",
27
- docsPath: "docs/product/command-spec.md#prisma-auth-login",
28
- examples: ["prisma auth login"]
24
+ description: "Log in to your Prisma platform account",
25
+ examples: ["prisma-cli auth login"]
29
26
  },
30
27
  {
31
28
  id: "auth.logout",
@@ -34,9 +31,8 @@ const DESCRIPTORS = [
34
31
  "auth",
35
32
  "logout"
36
33
  ],
37
- description: "Clear the current CLI session.",
38
- docsPath: "docs/product/command-spec.md#prisma-auth-logout",
39
- examples: ["prisma auth logout"]
34
+ description: "Clear stored authentication credentials",
35
+ examples: ["prisma-cli auth logout"]
40
36
  },
41
37
  {
42
38
  id: "auth.whoami",
@@ -45,34 +41,26 @@ const DESCRIPTORS = [
45
41
  "auth",
46
42
  "whoami"
47
43
  ],
48
- description: "Show the current authenticated identity.",
49
- docsPath: "docs/product/command-spec.md#prisma-auth-whoami",
50
- examples: ["prisma auth whoami", "prisma auth whoami --json"]
44
+ description: "Show the authenticated user and accessible workspace",
45
+ examples: ["prisma-cli auth whoami", "prisma-cli auth whoami --json"]
51
46
  },
52
47
  {
53
48
  id: "project",
54
49
  path: ["prisma", "project"],
55
- description: "Project discovery and repo linking commands.",
56
- docsPath: "docs/product/command-spec.md#prisma-project-list",
57
- examples: ["prisma project list", "prisma project show"]
50
+ description: "Manage the link between this directory and a Prisma project",
51
+ examples: ["prisma-cli project list", "prisma-cli project show"]
58
52
  },
59
53
  {
60
54
  id: "app",
61
55
  path: ["prisma", "app"],
62
- description: "App deployment and release commands.",
63
- docsPath: "docs/product/command-spec.md#prisma-app-deploy---app-name---entry-path---build-type-autobunnextjsnuxtastrotanstack-start---http-port-port---env-namevalue",
64
- examples: [
65
- "prisma app build --build-type nextjs",
66
- "prisma app deploy --app hello-world --build-type nextjs --http-port 3000",
67
- "prisma app deploy --app hello-world --build-type nuxt"
68
- ]
56
+ description: "Manage apps and deployments for a project",
57
+ examples: ["prisma-cli app deploy", "prisma-cli app deploy --app hello-world --build-type nextjs --http-port 3000"]
69
58
  },
70
59
  {
71
60
  id: "branch",
72
61
  path: ["prisma", "branch"],
73
- description: "Branch context and safety commands.",
74
- docsPath: "docs/product/command-spec.md#prisma-branch-list",
75
- examples: ["prisma branch list", "prisma branch use production"]
62
+ description: "View your active Platform branches",
63
+ examples: ["prisma-cli branch list", "prisma-cli branch show"]
76
64
  },
77
65
  {
78
66
  id: "project.list",
@@ -81,9 +69,8 @@ const DESCRIPTORS = [
81
69
  "project",
82
70
  "list"
83
71
  ],
84
- description: "List projects for the authenticated workspace.",
85
- docsPath: "docs/product/command-spec.md#prisma-project-list",
86
- examples: ["prisma project list", "prisma project list --json"]
72
+ description: "List all projects in your workspace",
73
+ examples: ["prisma-cli project list", "prisma-cli project list --json"]
87
74
  },
88
75
  {
89
76
  id: "project.show",
@@ -92,9 +79,8 @@ const DESCRIPTORS = [
92
79
  "project",
93
80
  "show"
94
81
  ],
95
- description: "Show the linked project for the current repo.",
96
- docsPath: "docs/product/command-spec.md#prisma-project-show",
97
- examples: ["prisma project show", "prisma project show --json"]
82
+ description: "Show the Prisma project linked to this directory",
83
+ examples: ["prisma-cli project show", "prisma-cli project show --json"]
98
84
  },
99
85
  {
100
86
  id: "project.link",
@@ -103,9 +89,8 @@ const DESCRIPTORS = [
103
89
  "project",
104
90
  "link"
105
91
  ],
106
- description: "Link the current repo to an existing project.",
107
- docsPath: "docs/product/command-spec.md#prisma-project-link-project",
108
- examples: ["prisma project link", "prisma project link proj_123"]
92
+ description: "Link this directory to a Prisma project",
93
+ examples: ["prisma-cli project link", "prisma-cli project link proj_123"]
109
94
  },
110
95
  {
111
96
  id: "branch.list",
@@ -114,9 +99,8 @@ const DESCRIPTORS = [
114
99
  "branch",
115
100
  "list"
116
101
  ],
117
- description: "List branches for the linked project.",
118
- docsPath: "docs/product/command-spec.md#prisma-branch-list",
119
- examples: ["prisma branch list", "prisma branch list --json"]
102
+ description: "List active Platform branches linked to this project",
103
+ examples: ["prisma-cli branch list", "prisma-cli branch list --json"]
120
104
  },
121
105
  {
122
106
  id: "branch.show",
@@ -125,9 +109,8 @@ const DESCRIPTORS = [
125
109
  "branch",
126
110
  "show"
127
111
  ],
128
- description: "Show the current active branch context.",
129
- docsPath: "docs/product/command-spec.md#prisma-branch-show",
130
- examples: ["prisma branch show", "prisma branch show --json"]
112
+ description: "Show the Platform branch matching your current Git branch",
113
+ examples: ["prisma-cli branch show", "prisma-cli branch show --json"]
131
114
  },
132
115
  {
133
116
  id: "branch.use",
@@ -137,8 +120,7 @@ const DESCRIPTORS = [
137
120
  "use"
138
121
  ],
139
122
  description: "Change the local default branch context.",
140
- docsPath: "docs/product/command-spec.md#prisma-branch-use-name",
141
- examples: ["prisma branch use", "prisma branch use production"]
123
+ examples: ["prisma-cli branch use", "prisma-cli branch use production"]
142
124
  },
143
125
  {
144
126
  id: "app.build",
@@ -147,12 +129,11 @@ const DESCRIPTORS = [
147
129
  "app",
148
130
  "build"
149
131
  ],
150
- description: "Build the local app into a deployable artifact.",
151
- docsPath: "docs/product/command-spec.md#prisma-app-build---entry-path---build-type-autobunnextjsnuxtastrotanstack-start",
132
+ description: "Build the app locally into a deployable artifact",
152
133
  examples: [
153
- "prisma app build --build-type nextjs",
154
- "prisma app build --build-type nuxt",
155
- "prisma app build --build-type bun --entry server.ts"
134
+ "prisma-cli app build --build-type nextjs",
135
+ "prisma-cli app build --build-type nuxt",
136
+ "prisma-cli app build --build-type bun --entry server.ts"
156
137
  ]
157
138
  },
158
139
  {
@@ -162,9 +143,8 @@ const DESCRIPTORS = [
162
143
  "app",
163
144
  "run"
164
145
  ],
165
- description: "Start a local framework dev server.",
166
- docsPath: "docs/product/command-spec.md#prisma-app-run---entry-path---build-type-autobunnextjs---port-port",
167
- examples: ["prisma app run --build-type nextjs", "prisma app run --build-type bun --entry server.ts --port 3000"]
146
+ description: "Run your app locally",
147
+ examples: ["prisma-cli app run --build-type nextjs", "prisma-cli app run --build-type bun --entry server.ts --port 3000"]
168
148
  },
169
149
  {
170
150
  id: "app.deploy",
@@ -173,13 +153,12 @@ const DESCRIPTORS = [
173
153
  "app",
174
154
  "deploy"
175
155
  ],
176
- description: "Build and release the selected app.",
177
- docsPath: "docs/product/command-spec.md#prisma-app-deploy---app-name---entry-path---build-type-autobunnextjsnuxtastrotanstack-start---http-port-port---env-namevalue",
156
+ description: "Creates a new deployment for the app",
178
157
  examples: [
179
- "prisma app deploy",
180
- "prisma app deploy --app hello-world --env DATABASE_URL=postgresql://example",
181
- "prisma app deploy --app hello-world --build-type nextjs --http-port 3000",
182
- "prisma app deploy --app hello-world --build-type nuxt"
158
+ "prisma-cli app deploy",
159
+ "prisma-cli app deploy --app hello-world --env DATABASE_URL=postgresql://example",
160
+ "prisma-cli app deploy --app hello-world --build-type nextjs --http-port 3000",
161
+ "prisma-cli app deploy --app hello-world --build-type nuxt"
183
162
  ]
184
163
  },
185
164
  {
@@ -190,8 +169,7 @@ const DESCRIPTORS = [
190
169
  "update-env"
191
170
  ],
192
171
  description: "Create a new deployment with updated environment variables.",
193
- docsPath: "docs/product/command-spec.md#prisma-app-update-env---app-name---env-namevalue",
194
- examples: ["prisma app update-env --env DATABASE_URL=postgresql://example", "prisma app update-env --app hello-world --env DATABASE_URL=postgresql://another"]
172
+ examples: ["prisma-cli app update-env --env DATABASE_URL=postgresql://example", "prisma-cli app update-env --app hello-world --env DATABASE_URL=postgresql://another"]
195
173
  },
196
174
  {
197
175
  id: "app.list-env",
@@ -201,8 +179,7 @@ const DESCRIPTORS = [
201
179
  "list-env"
202
180
  ],
203
181
  description: "List environment variable names for the selected app.",
204
- docsPath: "docs/product/command-spec.md#prisma-app-list-env---app-name",
205
- examples: ["prisma app list-env", "prisma app list-env --app hello-world"]
182
+ examples: ["prisma-cli app list-env", "prisma-cli app list-env --app hello-world"]
206
183
  },
207
184
  {
208
185
  id: "app.show",
@@ -211,9 +188,8 @@ const DESCRIPTORS = [
211
188
  "app",
212
189
  "show"
213
190
  ],
214
- description: "Show the current state of the selected app.",
215
- docsPath: "docs/product/command-spec.md#prisma-app-show---app-name",
216
- examples: ["prisma app show", "prisma app show --app hello-world"]
191
+ description: "Show the app and its current deployment",
192
+ examples: ["prisma-cli app show", "prisma-cli app show --app hello-world"]
217
193
  },
218
194
  {
219
195
  id: "app.open",
@@ -222,9 +198,8 @@ const DESCRIPTORS = [
222
198
  "app",
223
199
  "open"
224
200
  ],
225
- description: "Open the live URL for the selected app.",
226
- docsPath: "docs/product/command-spec.md#prisma-app-open---app-name",
227
- examples: ["prisma app open", "prisma app open --app hello-world"]
201
+ description: "Open the app's live URL",
202
+ examples: ["prisma-cli app open", "prisma-cli app open --app hello-world"]
228
203
  },
229
204
  {
230
205
  id: "app.logs",
@@ -233,9 +208,8 @@ const DESCRIPTORS = [
233
208
  "app",
234
209
  "logs"
235
210
  ],
236
- description: "Show or stream logs for a deployment.",
237
- docsPath: "docs/product/command-spec.md#prisma-app-logs---app-name---deployment-id",
238
- examples: ["prisma app logs", "prisma app logs --deployment dep_123"]
211
+ description: "Stream logs for the app's current deployment",
212
+ examples: ["prisma-cli app logs", "prisma-cli app logs --deployment dep_123"]
239
213
  },
240
214
  {
241
215
  id: "app.list-deploys",
@@ -244,9 +218,8 @@ const DESCRIPTORS = [
244
218
  "app",
245
219
  "list-deploys"
246
220
  ],
247
- description: "List deployments for the selected app.",
248
- docsPath: "docs/product/command-spec.md#prisma-app-list-deploys---app-name",
249
- examples: ["prisma app list-deploys", "prisma app list-deploys --app hello-world"]
221
+ description: "List deployments for the app",
222
+ examples: ["prisma-cli app list-deploys", "prisma-cli app list-deploys --app hello-world"]
250
223
  },
251
224
  {
252
225
  id: "app.show-deploy",
@@ -255,9 +228,8 @@ const DESCRIPTORS = [
255
228
  "app",
256
229
  "show-deploy"
257
230
  ],
258
- description: "Show one deployment in detail.",
259
- docsPath: "docs/product/command-spec.md#prisma-app-show-deploy-deployment",
260
- examples: ["prisma app show-deploy dep_123"]
231
+ description: "Show a deployment in detail",
232
+ examples: ["prisma-cli app show-deploy dep_123"]
261
233
  },
262
234
  {
263
235
  id: "app.promote",
@@ -266,9 +238,8 @@ const DESCRIPTORS = [
266
238
  "app",
267
239
  "promote"
268
240
  ],
269
- description: "Switch the live deployment for the selected app.",
270
- docsPath: "docs/product/command-spec.md#prisma-app-promote-deployment---app-name",
271
- examples: ["prisma app promote dep_123", "prisma app promote dep_123 --app hello-world"]
241
+ description: "Promote a deployment to production by rebuilding with production env vars",
242
+ examples: ["prisma-cli app promote dep_123", "prisma-cli app promote dep_123 --app hello-world"]
272
243
  },
273
244
  {
274
245
  id: "app.rollback",
@@ -277,9 +248,8 @@ const DESCRIPTORS = [
277
248
  "app",
278
249
  "rollback"
279
250
  ],
280
- description: "Restore the selected app to an earlier deployment.",
281
- docsPath: "docs/product/command-spec.md#prisma-app-rollback---app-name---to-deployment",
282
- examples: ["prisma app rollback", "prisma app rollback --app hello-world --to dep_123"]
251
+ description: "Roll back production to a previous deployment",
252
+ examples: ["prisma-cli app rollback", "prisma-cli app rollback --app hello-world --to dep_123"]
283
253
  },
284
254
  {
285
255
  id: "app.remove",
@@ -288,9 +258,66 @@ const DESCRIPTORS = [
288
258
  "app",
289
259
  "remove"
290
260
  ],
291
- description: "Remove the selected app from the linked project.",
292
- docsPath: "docs/product/command-spec.md#prisma-app-remove---app-name--y---yes",
293
- examples: ["prisma app remove --app hello-world", "prisma app remove --app hello-world --yes"]
261
+ description: "Remove the app from the current branch",
262
+ examples: ["prisma-cli app remove --app hello-world", "prisma-cli app remove --app hello-world --yes"]
263
+ },
264
+ {
265
+ id: "project.env",
266
+ path: [
267
+ "prisma",
268
+ "project",
269
+ "env"
270
+ ],
271
+ description: "Manage environment variables for the linked project.",
272
+ examples: [
273
+ "prisma-cli project env list --role production",
274
+ "prisma-cli project env add STRIPE_KEY=sk_test_xxx --role production",
275
+ "prisma-cli project env rm STRIPE_KEY --role preview"
276
+ ]
277
+ },
278
+ {
279
+ id: "project.env.add",
280
+ path: [
281
+ "prisma",
282
+ "project",
283
+ "env",
284
+ "add"
285
+ ],
286
+ description: "Create a new environment variable.",
287
+ examples: ["prisma-cli project env add STRIPE_KEY=sk_test_xxx --role production", "prisma-cli project env add STRIPE_KEY=sk_test_xxx --role preview"]
288
+ },
289
+ {
290
+ id: "project.env.update",
291
+ path: [
292
+ "prisma",
293
+ "project",
294
+ "env",
295
+ "update"
296
+ ],
297
+ description: "Replace an existing environment variable's value.",
298
+ examples: ["prisma-cli project env update STRIPE_KEY=sk_new_xxx --role production", "prisma-cli project env update STRIPE_KEY=sk_new_xxx --role preview"]
299
+ },
300
+ {
301
+ id: "project.env.list",
302
+ path: [
303
+ "prisma",
304
+ "project",
305
+ "env",
306
+ "list"
307
+ ],
308
+ description: "List environment variable metadata for a scope (no values).",
309
+ examples: ["prisma-cli project env list --role production", "prisma-cli project env list --role preview"]
310
+ },
311
+ {
312
+ id: "project.env.rm",
313
+ path: [
314
+ "prisma",
315
+ "project",
316
+ "env",
317
+ "rm"
318
+ ],
319
+ description: "Remove an environment variable from a scope.",
320
+ examples: ["prisma-cli project env rm STRIPE_KEY --role production", "prisma-cli project env rm STRIPE_KEY --role preview"]
294
321
  }
295
322
  ];
296
323
  const DESCRIPTORS_BY_ID = new Map(DESCRIPTORS.map((descriptor) => [descriptor.id, descriptor]));
@@ -1,8 +1,8 @@
1
1
  import { CliError } from "./errors.js";
2
+ import { cliErrorToJson, writeHumanError, writeHumanLines, writeJsonError, writeJsonEvent, writeJsonSuccess } from "./output.js";
2
3
  import { getCommandDescriptor } from "./command-meta.js";
3
4
  import { resolveGlobalFlags } from "./global-flags.js";
4
5
  import { createCommandContext } from "./runtime.js";
5
- import { writeHumanError, writeHumanLines, writeJsonError, writeJsonSuccess } from "./output.js";
6
6
  //#region src/shell/command-runner.ts
7
7
  async function runCommand(runtime, commandName, options, handler, presenter) {
8
8
  const flags = resolveGlobalFlags(runtime.argv, options);
@@ -29,5 +29,35 @@ async function runCommand(runtime, commandName, options, handler, presenter) {
29
29
  throw error;
30
30
  }
31
31
  }
32
+ async function runStreamingCommand(runtime, commandName, options, handler) {
33
+ const flags = resolveGlobalFlags(runtime.argv, options);
34
+ const context = await createCommandContext(runtime, flags);
35
+ try {
36
+ await handler(context);
37
+ if (flags.json) writeJsonEvent(context.output, {
38
+ type: "success",
39
+ command: commandName,
40
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
41
+ result: null,
42
+ warnings: [],
43
+ nextSteps: []
44
+ });
45
+ } catch (error) {
46
+ if (error instanceof CliError) {
47
+ if (flags.json) writeJsonEvent(context.output, {
48
+ type: "error",
49
+ command: commandName,
50
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
51
+ error: cliErrorToJson(error),
52
+ warnings: [],
53
+ nextSteps: error.nextSteps
54
+ });
55
+ else writeHumanError(context.output, context.ui, error, { trace: flags.trace });
56
+ process.exitCode = error.exitCode;
57
+ return;
58
+ }
59
+ throw error;
60
+ }
61
+ }
32
62
  //#endregion
33
- export { runCommand };
63
+ export { runCommand, runStreamingCommand };
@@ -40,13 +40,13 @@ function usageError(summary, why, fix, nextSteps = [], domain = "cli") {
40
40
  nextSteps
41
41
  });
42
42
  }
43
- function authRequiredError(nextSteps = ["prisma auth login"]) {
43
+ function authRequiredError(nextSteps = ["prisma-cli auth login"]) {
44
44
  return new CliError({
45
45
  code: "AUTH_REQUIRED",
46
46
  domain: "auth",
47
47
  summary: "Authentication required",
48
48
  why: "This command needs an authenticated session.",
49
- fix: "Run prisma auth login, or rerun the command in a TTY to sign in interactively.",
49
+ fix: "Run prisma-cli auth login, or rerun the command in a TTY to sign in interactively.",
50
50
  exitCode: 1,
51
51
  nextSteps
52
52
  });
@@ -1,8 +1,19 @@
1
1
  import { Option } from "commander";
2
2
  //#region src/shell/global-flags.ts
3
+ const COMPACT_GLOBAL_OPTION_FLAGS = [
4
+ "--json",
5
+ "-q, --quiet",
6
+ "-v, --verbose",
7
+ "--trace",
8
+ "--no-interactive",
9
+ "-y, --yes"
10
+ ];
3
11
  function addGlobalFlags(command) {
4
12
  return command.option("--json", "Emit structured JSON output.").option("-q, --quiet", "Reduce human-oriented output.").option("-v, --verbose", "Increase human-oriented output detail.").option("--trace", "Show deeper diagnostics for failures.").option("-y, --yes", "Accept supported confirmation prompts.").addOption(new Option("--interactive", "Force interactive behavior when prompts are supported.")).addOption(new Option("--no-interactive", "Disable interactive behavior and prompts.")).addOption(new Option("--color", "Force color output in supported terminals.")).addOption(new Option("--no-color", "Disable color output."));
5
13
  }
14
+ function addCompactGlobalFlags(command) {
15
+ return command.option("--json", "Emit structured JSON output.").option("-q, --quiet", "Reduce human-oriented output.").option("-v, --verbose", "Increase human-oriented output detail.").option("--trace", "Show deeper diagnostics for failures.").addOption(new Option("--no-interactive", "Disable interactive behavior and prompts.")).option("-y, --yes", "Accept supported confirmation prompts.");
16
+ }
6
17
  function getExplicitBoolean(argv, positive, negative) {
7
18
  for (let index = argv.length - 1; index >= 0; index -= 1) {
8
19
  const value = argv[index];
@@ -22,4 +33,4 @@ function resolveGlobalFlags(argv, options) {
22
33
  };
23
34
  }
24
35
  //#endregion
25
- export { addGlobalFlags, resolveGlobalFlags };
36
+ export { COMPACT_GLOBAL_OPTION_FLAGS, addCompactGlobalFlags, addGlobalFlags, resolveGlobalFlags };
@@ -1,6 +1,6 @@
1
- import { formatDescriptorLabel, getDescriptorForCommand } from "./command-meta.js";
2
- import { resolveGlobalFlags } from "./global-flags.js";
3
1
  import { createShellUi, padDisplay, wrapText } from "./ui.js";
2
+ import { formatDescriptorLabel, getDescriptorForCommand } from "./command-meta.js";
3
+ import { COMPACT_GLOBAL_OPTION_FLAGS, resolveGlobalFlags } from "./global-flags.js";
4
4
  //#region src/shell/help.ts
5
5
  function renderHelp(command, runtime) {
6
6
  const descriptor = getDescriptorForCommand(command);
@@ -10,8 +10,14 @@ function renderHelp(command, runtime) {
10
10
  const visibleCommands = command.commands.filter((candidate) => candidate.name() !== "help" && !candidate.hidden);
11
11
  const visibleOptions = command.options.filter((candidate) => !candidate.hidden);
12
12
  if (visibleCommands.length > 0) lines.push(...renderCommandRows(rail, ui, visibleCommands));
13
+ if (descriptor.longDescription) {
14
+ lines.push(`${rail}`);
15
+ const wrapped = wrapText(descriptor.longDescription, Math.max(ui.width - 3, 40));
16
+ for (const line of wrapped) lines.push(`${rail} ${line}`);
17
+ }
13
18
  if (visibleOptions.length > 0) {
14
19
  if (visibleCommands.length > 0) lines.push(`${rail}`);
20
+ if (visibleCommands.length > 0 && visibleOptions.every((option) => COMPACT_GLOBAL_OPTION_FLAGS.includes(option.flags))) lines.push(`${rail} Global options:`);
15
21
  lines.push(...renderOptionRows(rail, ui, visibleOptions));
16
22
  }
17
23
  if (descriptor.examples && descriptor.examples.length > 0) {
@@ -19,11 +25,6 @@ function renderHelp(command, runtime) {
19
25
  lines.push(`${rail} Examples:`);
20
26
  for (const example of descriptor.examples) lines.push(`${rail} $ ${example}`);
21
27
  }
22
- if (descriptor.longDescription) {
23
- lines.push(`${rail}`);
24
- const wrapped = wrapText(descriptor.longDescription, Math.max(ui.width - 3, 40));
25
- for (const line of wrapped) lines.push(`${rail} ${line}`);
26
- }
27
28
  if (descriptor.docsPath) {
28
29
  lines.push(`${rail}`);
29
30
  lines.push(`${rail} ${ui.accent(padDisplay("Read more", 16))} ${ui.link(descriptor.docsPath)}`);