@prisma/cli-engine 0.0.9 → 0.1.1
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.
|
@@ -56,6 +56,17 @@ const flag = {
|
|
|
56
56
|
...spec
|
|
57
57
|
});
|
|
58
58
|
},
|
|
59
|
+
/**
|
|
60
|
+
* A boolean the user can leave unsaid: `--flag`, `--no-flag`, or
|
|
61
|
+
* neither, which arrives as undefined. Use it when absence means
|
|
62
|
+
* something of its own — "ask me" rather than "no".
|
|
63
|
+
*/
|
|
64
|
+
optionalBoolean(spec) {
|
|
65
|
+
return brandFlag({
|
|
66
|
+
type: "optionalBoolean",
|
|
67
|
+
...spec
|
|
68
|
+
});
|
|
69
|
+
},
|
|
59
70
|
enum(spec) {
|
|
60
71
|
return brandFlag({
|
|
61
72
|
type: "enum",
|
|
@@ -157,6 +168,390 @@ function isChildStatusSettlement(value) {
|
|
|
157
168
|
return typeof value === "object" && value !== null && value[CHILD_STATUS] === true;
|
|
158
169
|
}
|
|
159
170
|
//#endregion
|
|
171
|
+
//#region src/ci.ts
|
|
172
|
+
/**
|
|
173
|
+
* ci-info's provider table. Its `isCI` export is unusable — it reads
|
|
174
|
+
* the real `process.env` at import; the engine reads only host-injected
|
|
175
|
+
* env. The table is inlined into the build (tsdown `noExternal`): the
|
|
176
|
+
* file is CJS-owned by ci-info, and loading it as ESM at runtime breaks
|
|
177
|
+
* hosts that also require ci-info (Bun's dual registry; composer#234).
|
|
178
|
+
* Pinned by tests/no-esm-json-import-in-dist.test.ts.
|
|
179
|
+
*/
|
|
180
|
+
const VENDORS = [
|
|
181
|
+
{
|
|
182
|
+
"name": "Agola CI",
|
|
183
|
+
"constant": "AGOLA",
|
|
184
|
+
"env": "AGOLA_GIT_REF",
|
|
185
|
+
"pr": "AGOLA_PULL_REQUEST_ID"
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
"name": "Alpic",
|
|
189
|
+
"constant": "ALPIC",
|
|
190
|
+
"env": "ALPIC_HOST"
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
"name": "Appcircle",
|
|
194
|
+
"constant": "APPCIRCLE",
|
|
195
|
+
"env": "AC_APPCIRCLE",
|
|
196
|
+
"pr": {
|
|
197
|
+
"env": "AC_GIT_PR",
|
|
198
|
+
"ne": "false"
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
"name": "AppVeyor",
|
|
203
|
+
"constant": "APPVEYOR",
|
|
204
|
+
"env": "APPVEYOR",
|
|
205
|
+
"pr": "APPVEYOR_PULL_REQUEST_NUMBER"
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
"name": "AWS CodeBuild",
|
|
209
|
+
"constant": "CODEBUILD",
|
|
210
|
+
"env": "CODEBUILD_BUILD_ARN",
|
|
211
|
+
"pr": {
|
|
212
|
+
"env": "CODEBUILD_WEBHOOK_EVENT",
|
|
213
|
+
"any": [
|
|
214
|
+
"PULL_REQUEST_CREATED",
|
|
215
|
+
"PULL_REQUEST_UPDATED",
|
|
216
|
+
"PULL_REQUEST_REOPENED"
|
|
217
|
+
]
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
"name": "Azure Pipelines",
|
|
222
|
+
"constant": "AZURE_PIPELINES",
|
|
223
|
+
"env": "TF_BUILD",
|
|
224
|
+
"pr": { "BUILD_REASON": "PullRequest" }
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
"name": "Bamboo",
|
|
228
|
+
"constant": "BAMBOO",
|
|
229
|
+
"env": "bamboo_planKey"
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
"name": "Bitbucket Pipelines",
|
|
233
|
+
"constant": "BITBUCKET",
|
|
234
|
+
"env": "BITBUCKET_COMMIT",
|
|
235
|
+
"pr": "BITBUCKET_PR_ID"
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
"name": "Bitrise",
|
|
239
|
+
"constant": "BITRISE",
|
|
240
|
+
"env": "BITRISE_IO",
|
|
241
|
+
"pr": "BITRISE_PULL_REQUEST"
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
"name": "Buddy",
|
|
245
|
+
"constant": "BUDDY",
|
|
246
|
+
"env": "BUDDY_WORKSPACE_ID",
|
|
247
|
+
"pr": "BUDDY_EXECUTION_PULL_REQUEST_ID"
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
"name": "Buildkite",
|
|
251
|
+
"constant": "BUILDKITE",
|
|
252
|
+
"env": "BUILDKITE",
|
|
253
|
+
"pr": {
|
|
254
|
+
"env": "BUILDKITE_PULL_REQUEST",
|
|
255
|
+
"ne": "false"
|
|
256
|
+
}
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
"name": "CircleCI",
|
|
260
|
+
"constant": "CIRCLE",
|
|
261
|
+
"env": "CIRCLECI",
|
|
262
|
+
"pr": "CIRCLE_PULL_REQUEST"
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
"name": "Cirrus CI",
|
|
266
|
+
"constant": "CIRRUS",
|
|
267
|
+
"env": "CIRRUS_CI",
|
|
268
|
+
"pr": "CIRRUS_PR"
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
"name": "Cloudflare Pages",
|
|
272
|
+
"constant": "CLOUDFLARE_PAGES",
|
|
273
|
+
"env": "CF_PAGES"
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
"name": "Cloudflare Workers",
|
|
277
|
+
"constant": "CLOUDFLARE_WORKERS",
|
|
278
|
+
"env": "WORKERS_CI"
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
"name": "Codefresh",
|
|
282
|
+
"constant": "CODEFRESH",
|
|
283
|
+
"env": "CF_BUILD_ID",
|
|
284
|
+
"pr": { "any": ["CF_PULL_REQUEST_NUMBER", "CF_PULL_REQUEST_ID"] }
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
"name": "Codemagic",
|
|
288
|
+
"constant": "CODEMAGIC",
|
|
289
|
+
"env": "CM_BUILD_ID",
|
|
290
|
+
"pr": "CM_PULL_REQUEST"
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
"name": "Codeship",
|
|
294
|
+
"constant": "CODESHIP",
|
|
295
|
+
"env": { "CI_NAME": "codeship" }
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
"name": "Drone",
|
|
299
|
+
"constant": "DRONE",
|
|
300
|
+
"env": "DRONE",
|
|
301
|
+
"pr": { "DRONE_BUILD_EVENT": "pull_request" }
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
"name": "dsari",
|
|
305
|
+
"constant": "DSARI",
|
|
306
|
+
"env": "DSARI"
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
"name": "Earthly",
|
|
310
|
+
"constant": "EARTHLY",
|
|
311
|
+
"env": "EARTHLY_CI"
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
"name": "Expo Application Services",
|
|
315
|
+
"constant": "EAS",
|
|
316
|
+
"env": "EAS_BUILD"
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
"name": "Gerrit",
|
|
320
|
+
"constant": "GERRIT",
|
|
321
|
+
"env": "GERRIT_PROJECT"
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
"name": "Gitea Actions",
|
|
325
|
+
"constant": "GITEA_ACTIONS",
|
|
326
|
+
"env": "GITEA_ACTIONS"
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
"name": "GitHub Actions",
|
|
330
|
+
"constant": "GITHUB_ACTIONS",
|
|
331
|
+
"env": "GITHUB_ACTIONS",
|
|
332
|
+
"pr": { "GITHUB_EVENT_NAME": "pull_request" }
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
"name": "GitLab CI",
|
|
336
|
+
"constant": "GITLAB",
|
|
337
|
+
"env": "GITLAB_CI",
|
|
338
|
+
"pr": "CI_MERGE_REQUEST_ID"
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
"name": "GoCD",
|
|
342
|
+
"constant": "GOCD",
|
|
343
|
+
"env": "GO_PIPELINE_LABEL"
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
"name": "Google Cloud Build",
|
|
347
|
+
"constant": "GOOGLE_CLOUD_BUILD",
|
|
348
|
+
"env": "BUILDER_OUTPUT"
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
"name": "Harness CI",
|
|
352
|
+
"constant": "HARNESS",
|
|
353
|
+
"env": "HARNESS_BUILD_ID"
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
"name": "Heroku",
|
|
357
|
+
"constant": "HEROKU",
|
|
358
|
+
"env": {
|
|
359
|
+
"env": "NODE",
|
|
360
|
+
"includes": "/app/.heroku/node/bin/node"
|
|
361
|
+
}
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
"name": "Hudson",
|
|
365
|
+
"constant": "HUDSON",
|
|
366
|
+
"env": "HUDSON_URL"
|
|
367
|
+
},
|
|
368
|
+
{
|
|
369
|
+
"name": "Jenkins",
|
|
370
|
+
"constant": "JENKINS",
|
|
371
|
+
"env": ["JENKINS_URL", "BUILD_ID"],
|
|
372
|
+
"pr": { "any": ["ghprbPullId", "CHANGE_ID"] }
|
|
373
|
+
},
|
|
374
|
+
{
|
|
375
|
+
"name": "LayerCI",
|
|
376
|
+
"constant": "LAYERCI",
|
|
377
|
+
"env": "LAYERCI",
|
|
378
|
+
"pr": "LAYERCI_PULL_REQUEST"
|
|
379
|
+
},
|
|
380
|
+
{
|
|
381
|
+
"name": "Magnum CI",
|
|
382
|
+
"constant": "MAGNUM",
|
|
383
|
+
"env": "MAGNUM"
|
|
384
|
+
},
|
|
385
|
+
{
|
|
386
|
+
"name": "Netlify CI",
|
|
387
|
+
"constant": "NETLIFY",
|
|
388
|
+
"env": "NETLIFY",
|
|
389
|
+
"pr": {
|
|
390
|
+
"env": "PULL_REQUEST",
|
|
391
|
+
"ne": "false"
|
|
392
|
+
}
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
"name": "Nevercode",
|
|
396
|
+
"constant": "NEVERCODE",
|
|
397
|
+
"env": "NEVERCODE",
|
|
398
|
+
"pr": {
|
|
399
|
+
"env": "NEVERCODE_PULL_REQUEST",
|
|
400
|
+
"ne": "false"
|
|
401
|
+
}
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
"name": "Prow",
|
|
405
|
+
"constant": "PROW",
|
|
406
|
+
"env": "PROW_JOB_ID"
|
|
407
|
+
},
|
|
408
|
+
{
|
|
409
|
+
"name": "ReleaseHub",
|
|
410
|
+
"constant": "RELEASEHUB",
|
|
411
|
+
"env": "RELEASE_BUILD_ID"
|
|
412
|
+
},
|
|
413
|
+
{
|
|
414
|
+
"name": "Render",
|
|
415
|
+
"constant": "RENDER",
|
|
416
|
+
"env": "RENDER",
|
|
417
|
+
"pr": { "IS_PULL_REQUEST": "true" }
|
|
418
|
+
},
|
|
419
|
+
{
|
|
420
|
+
"name": "Sail CI",
|
|
421
|
+
"constant": "SAIL",
|
|
422
|
+
"env": "SAILCI",
|
|
423
|
+
"pr": "SAIL_PULL_REQUEST_NUMBER"
|
|
424
|
+
},
|
|
425
|
+
{
|
|
426
|
+
"name": "Screwdriver",
|
|
427
|
+
"constant": "SCREWDRIVER",
|
|
428
|
+
"env": "SCREWDRIVER",
|
|
429
|
+
"pr": {
|
|
430
|
+
"env": "SD_PULL_REQUEST",
|
|
431
|
+
"ne": "false"
|
|
432
|
+
}
|
|
433
|
+
},
|
|
434
|
+
{
|
|
435
|
+
"name": "Semaphore",
|
|
436
|
+
"constant": "SEMAPHORE",
|
|
437
|
+
"env": "SEMAPHORE",
|
|
438
|
+
"pr": "PULL_REQUEST_NUMBER"
|
|
439
|
+
},
|
|
440
|
+
{
|
|
441
|
+
"name": "Sourcehut",
|
|
442
|
+
"constant": "SOURCEHUT",
|
|
443
|
+
"env": { "CI_NAME": "sourcehut" }
|
|
444
|
+
},
|
|
445
|
+
{
|
|
446
|
+
"name": "Strider CD",
|
|
447
|
+
"constant": "STRIDER",
|
|
448
|
+
"env": "STRIDER"
|
|
449
|
+
},
|
|
450
|
+
{
|
|
451
|
+
"name": "TaskCluster",
|
|
452
|
+
"constant": "TASKCLUSTER",
|
|
453
|
+
"env": ["TASK_ID", "RUN_ID"]
|
|
454
|
+
},
|
|
455
|
+
{
|
|
456
|
+
"name": "TeamCity",
|
|
457
|
+
"constant": "TEAMCITY",
|
|
458
|
+
"env": "TEAMCITY_VERSION"
|
|
459
|
+
},
|
|
460
|
+
{
|
|
461
|
+
"name": "Travis CI",
|
|
462
|
+
"constant": "TRAVIS",
|
|
463
|
+
"env": "TRAVIS",
|
|
464
|
+
"pr": {
|
|
465
|
+
"env": "TRAVIS_PULL_REQUEST",
|
|
466
|
+
"ne": "false"
|
|
467
|
+
}
|
|
468
|
+
},
|
|
469
|
+
{
|
|
470
|
+
"name": "Vela",
|
|
471
|
+
"constant": "VELA",
|
|
472
|
+
"env": "VELA",
|
|
473
|
+
"pr": { "VELA_PULL_REQUEST": "1" }
|
|
474
|
+
},
|
|
475
|
+
{
|
|
476
|
+
"name": "Vercel",
|
|
477
|
+
"constant": "VERCEL",
|
|
478
|
+
"env": { "any": ["NOW_BUILDER", "VERCEL"] },
|
|
479
|
+
"pr": "VERCEL_GIT_PULL_REQUEST_ID"
|
|
480
|
+
},
|
|
481
|
+
{
|
|
482
|
+
"name": "Visual Studio App Center",
|
|
483
|
+
"constant": "APPCENTER",
|
|
484
|
+
"env": "APPCENTER_BUILD_ID"
|
|
485
|
+
},
|
|
486
|
+
{
|
|
487
|
+
"name": "Woodpecker",
|
|
488
|
+
"constant": "WOODPECKER",
|
|
489
|
+
"env": { "CI": "woodpecker" },
|
|
490
|
+
"pr": { "CI_BUILD_EVENT": "pull_request" }
|
|
491
|
+
},
|
|
492
|
+
{
|
|
493
|
+
"name": "Xcode Cloud",
|
|
494
|
+
"constant": "XCODE_CLOUD",
|
|
495
|
+
"env": "CI_XCODE_PROJECT",
|
|
496
|
+
"pr": "CI_PULL_REQUEST_NUMBER"
|
|
497
|
+
},
|
|
498
|
+
{
|
|
499
|
+
"name": "Xcode Server",
|
|
500
|
+
"constant": "XCODE_SERVER",
|
|
501
|
+
"env": "XCS"
|
|
502
|
+
}
|
|
503
|
+
];
|
|
504
|
+
/**
|
|
505
|
+
* The variables ci-info checks outside the vendor table, catching CI
|
|
506
|
+
* systems that set a conventional variable but have no table entry.
|
|
507
|
+
* These are cross-vendor conventions rather than per-vendor facts,
|
|
508
|
+
* which is why this list holds still while the table grows.
|
|
509
|
+
*/
|
|
510
|
+
const CONVENTIONAL_CI_VARS = [
|
|
511
|
+
"BUILD_ID",
|
|
512
|
+
"BUILD_NUMBER",
|
|
513
|
+
"CI",
|
|
514
|
+
"CI_APP_ID",
|
|
515
|
+
"CI_BUILD_ID",
|
|
516
|
+
"CI_BUILD_NUMBER",
|
|
517
|
+
"CI_NAME",
|
|
518
|
+
"CONTINUOUS_INTEGRATION",
|
|
519
|
+
"RUN_ID"
|
|
520
|
+
];
|
|
521
|
+
function isSet(value) {
|
|
522
|
+
return value !== void 0 && value !== "";
|
|
523
|
+
}
|
|
524
|
+
function checkMatches(check, env) {
|
|
525
|
+
if (typeof check === "string") return isSet(env[check]);
|
|
526
|
+
const { env: variable, includes, any } = check;
|
|
527
|
+
if (typeof variable === "string" && typeof includes === "string") return env[variable]?.includes(includes) === true;
|
|
528
|
+
if (Array.isArray(any)) return any.some((name) => isSet(env[String(name)]));
|
|
529
|
+
return Object.entries(check).every(([name, value]) => env[name] === value);
|
|
530
|
+
}
|
|
531
|
+
function vendorMatches(vendor, env) {
|
|
532
|
+
return (Array.isArray(vendor.env) ? vendor.env : [vendor.env]).every((check) => checkMatches(check, env));
|
|
533
|
+
}
|
|
534
|
+
/**
|
|
535
|
+
* Whether this environment is a CI environment, by ci-info's rules
|
|
536
|
+
* applied to the environment the host injected rather than to
|
|
537
|
+
* `process.env`. `CI=false` is an explicit denial that stops every
|
|
538
|
+
* other check, exactly as ci-info treats it.
|
|
539
|
+
*/
|
|
540
|
+
function detectCI(env) {
|
|
541
|
+
if (env.CI === "false") return false;
|
|
542
|
+
if (CONVENTIONAL_CI_VARS.some((name) => isSet(env[name]))) return true;
|
|
543
|
+
return VENDORS.some((vendor) => vendorMatches(vendor, env));
|
|
544
|
+
}
|
|
545
|
+
/**
|
|
546
|
+
* The engine's one answer to "is this run in CI", read by telemetry
|
|
547
|
+
* gating, `ctx.isCI` and the default interactivity decision. A host
|
|
548
|
+
* that says nothing gets detection, so forgetting to answer cannot turn
|
|
549
|
+
* a CI run into a reporting one.
|
|
550
|
+
*/
|
|
551
|
+
function resolveIsCI(host) {
|
|
552
|
+
return host.isCIOverride ?? detectCI(host.env);
|
|
553
|
+
}
|
|
554
|
+
//#endregion
|
|
160
555
|
//#region src/telemetry/endpoint.ts
|
|
161
556
|
/**
|
|
162
557
|
* Production endpoint pinned to the deployed Prisma Compute backend.
|
|
@@ -466,7 +861,7 @@ function reportCommandStart(inputs) {
|
|
|
466
861
|
if (!resolveGating({
|
|
467
862
|
env: host.env,
|
|
468
863
|
config,
|
|
469
|
-
inCI: host
|
|
864
|
+
inCI: resolveIsCI(host)
|
|
470
865
|
}).enabled) return;
|
|
471
866
|
const stored = config.installationId;
|
|
472
867
|
const installationId = typeof stored === "string" && stored.length > 0 ? stored : discloseAndMint(inputs);
|
|
@@ -787,6 +1182,26 @@ function buildManagementApiClient(invocation) {
|
|
|
787
1182
|
};
|
|
788
1183
|
} });
|
|
789
1184
|
}
|
|
1185
|
+
/**
|
|
1186
|
+
* Loads the SDK, surviving a Node ESM resolver fault observed in the
|
|
1187
|
+
* wild: the resolver can return the package's un-realpathed pnpm
|
|
1188
|
+
* symlink URL (instead of the .pnpm real path), from which the SDK's
|
|
1189
|
+
* own 'openapi-fetch' import cannot resolve. The fault is
|
|
1190
|
+
* state-dependent — two fstatSync calls at process start reliably
|
|
1191
|
+
* provoke it, and a module-loader hook masks it — so nothing here can
|
|
1192
|
+
* rule it out. The fallback resolves through CJS require, which
|
|
1193
|
+
* realpaths, and imports the real location directly; it never fires
|
|
1194
|
+
* when the normal import works.
|
|
1195
|
+
*/
|
|
1196
|
+
async function importManagementApiSdk() {
|
|
1197
|
+
try {
|
|
1198
|
+
return await import("@prisma/management-api-sdk");
|
|
1199
|
+
} catch {
|
|
1200
|
+
const { createRequire } = await import("node:module");
|
|
1201
|
+
const { pathToFileURL } = await import("node:url");
|
|
1202
|
+
return await import(pathToFileURL(createRequire(import.meta.url).resolve("@prisma/management-api-sdk")).href);
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
790
1205
|
async function constructClient(invocation, debug, probe) {
|
|
791
1206
|
const manager = invocation.runtime.credentialManager;
|
|
792
1207
|
if (manager === void 0) throw credentialsRequiredError();
|
|
@@ -795,7 +1210,7 @@ async function constructClient(invocation, debug, probe) {
|
|
|
795
1210
|
const config = invocation.runtime.managementApiClientConfig;
|
|
796
1211
|
if (config === void 0) throw new Error("@prisma/cli-engine: ctx.api requires Runtime.managementApiClientConfig when a credentialManager is wired");
|
|
797
1212
|
const storage = observedTokenStorage(await manager.activeCredentialStorage(), active, debug, probe);
|
|
798
|
-
const { createManagementApiSdk } = await
|
|
1213
|
+
const { createManagementApiSdk } = await importManagementApiSdk();
|
|
799
1214
|
return {
|
|
800
1215
|
client: createManagementApiSdk({
|
|
801
1216
|
clientId: config.clientId,
|
|
@@ -1013,14 +1428,17 @@ function reservedConfigSectionName(name) {
|
|
|
1013
1428
|
* top-level key names a config section, and the recognised section
|
|
1014
1429
|
* names are exactly the ones the CLI's command families declare. Never
|
|
1015
1430
|
* throws — bad section values are the section validator's problem, not
|
|
1016
|
-
*
|
|
1431
|
+
* definePrismaConfig's.
|
|
1017
1432
|
*/
|
|
1018
|
-
function
|
|
1433
|
+
function definePrismaConfig(config) {
|
|
1019
1434
|
return Object.freeze({
|
|
1020
1435
|
...config,
|
|
1021
1436
|
$prismaConfig: 1
|
|
1022
1437
|
});
|
|
1023
1438
|
}
|
|
1439
|
+
/** @deprecated Renamed to {@link definePrismaConfig}: every family's
|
|
1440
|
+
* config helper carries a unique name, so none needs an import alias. */
|
|
1441
|
+
const defineConfig = definePrismaConfig;
|
|
1024
1442
|
function hasVersionMarker(value) {
|
|
1025
1443
|
return typeof value === "object" && value !== null && typeof value[MARKER_KEY] === "number";
|
|
1026
1444
|
}
|
|
@@ -1039,10 +1457,10 @@ function missingMarkerDiagnostic(path) {
|
|
|
1039
1457
|
code: "CLI.CONFIG_MISSING_MARKER",
|
|
1040
1458
|
severity: "error",
|
|
1041
1459
|
summary: `${path} was not written for this version of the Prisma CLI, so it cannot be used.`,
|
|
1042
|
-
why: "Configs for this CLI are created with
|
|
1460
|
+
why: "Configs for this CLI are created with definePrismaConfig, which records a version marker on the exported object. This file's default export has no marker — it is most likely a Prisma 7 config, which uses the same filename — and the CLI stops rather than misread it.",
|
|
1043
1461
|
nextActions: [{
|
|
1044
1462
|
kind: "user-choice",
|
|
1045
|
-
label: "Migrate the file: wrap the exported object in
|
|
1463
|
+
label: "Migrate the file: wrap the exported object in definePrismaConfig from @prisma/cli-engine and export the result as the default export."
|
|
1046
1464
|
}],
|
|
1047
1465
|
where: { path }
|
|
1048
1466
|
};
|
|
@@ -1058,7 +1476,7 @@ function unsupportedVersionDiagnostic(path, found) {
|
|
|
1058
1476
|
summary: `${path} declares config version ${found}, but this CLI supports only version 1.`,
|
|
1059
1477
|
nextActions: [{
|
|
1060
1478
|
kind: "user-choice",
|
|
1061
|
-
label: "Regenerate the config with a
|
|
1479
|
+
label: "Regenerate the config with a definePrismaConfig matching this CLI, or update the CLI to a version that supports the declared config version."
|
|
1062
1480
|
}],
|
|
1063
1481
|
where: { path }
|
|
1064
1482
|
};
|
|
@@ -1181,12 +1599,12 @@ async function loadConfig(cwd, configPath) {
|
|
|
1181
1599
|
}
|
|
1182
1600
|
//#endregion
|
|
1183
1601
|
//#region src/execution/pre-parse-argv.ts
|
|
1184
|
-
function flagTokens(argv) {
|
|
1602
|
+
function flagTokens$1(argv) {
|
|
1185
1603
|
const terminator = argv.indexOf("--");
|
|
1186
1604
|
return terminator === -1 ? argv : argv.slice(0, terminator);
|
|
1187
1605
|
}
|
|
1188
1606
|
function versionFlagGiven(argv) {
|
|
1189
|
-
return flagTokens(argv).includes("--version");
|
|
1607
|
+
return flagTokens$1(argv).includes("--version");
|
|
1190
1608
|
}
|
|
1191
1609
|
/**
|
|
1192
1610
|
* The one malformed `--config` shape the parser cannot see. stricli
|
|
@@ -1204,12 +1622,12 @@ function versionFlagGiven(argv) {
|
|
|
1204
1622
|
* data, and `--` remains the way to pass it.
|
|
1205
1623
|
*/
|
|
1206
1624
|
function configFlagGivenNoValue(argv) {
|
|
1207
|
-
return flagTokens(argv).includes("--config=");
|
|
1625
|
+
return flagTokens$1(argv).includes("--config=");
|
|
1208
1626
|
}
|
|
1209
1627
|
/** The format requested by --json / --format / --format=<value>, if
|
|
1210
1628
|
* any. */
|
|
1211
1629
|
function formatFlagGiven(argv) {
|
|
1212
|
-
const tokens = flagTokens(argv);
|
|
1630
|
+
const tokens = flagTokens$1(argv);
|
|
1213
1631
|
for (const [index, token] of tokens.entries()) {
|
|
1214
1632
|
if (token === "--json" || token === "--format=json") return "json";
|
|
1215
1633
|
if (token === "--format=human") return "human";
|
|
@@ -1363,9 +1781,13 @@ function resolveColorEnabled(shared, runtime) {
|
|
|
1363
1781
|
* --no-interactive override in either direction. Format never decides
|
|
1364
1782
|
* interactivity (operator ruling, 2026-08-09): an interactive json run
|
|
1365
1783
|
* may prompt — the prompt UI writes to stderr, so stdout stays a clean
|
|
1366
|
-
* frame stream.
|
|
1784
|
+
* frame stream.
|
|
1785
|
+
*
|
|
1786
|
+
* This asks the engine's CI detection rather than testing `CI` for
|
|
1787
|
+
* being set at all: a Jenkins, TeamCity or Azure Pipelines job sets no
|
|
1788
|
+
* `CI` variable, and used to be offered a prompt no one could answer. */
|
|
1367
1789
|
function defaultInteractive(runtime) {
|
|
1368
|
-
return runtime.isTty.stdin && runtime
|
|
1790
|
+
return runtime.isTty.stdin && !resolveIsCI(runtime);
|
|
1369
1791
|
}
|
|
1370
1792
|
function resolveAutoFormat(shared, runtime) {
|
|
1371
1793
|
if (shared.json === true) return "json";
|
|
@@ -1603,9 +2025,9 @@ const TONE_VERB = {
|
|
|
1603
2025
|
"color-6": "green"
|
|
1604
2026
|
};
|
|
1605
2027
|
const COLORED = createColors({ useColor: true });
|
|
1606
|
-
const PLAIN = createColors({ useColor: false });
|
|
2028
|
+
const PLAIN$1 = createColors({ useColor: false });
|
|
1607
2029
|
function makePaint(colorEnabled) {
|
|
1608
|
-
const colors = colorEnabled ? COLORED : PLAIN;
|
|
2030
|
+
const colors = colorEnabled ? COLORED : PLAIN$1;
|
|
1609
2031
|
return (tone, text) => colors[TONE_VERB[tone]](text);
|
|
1610
2032
|
}
|
|
1611
2033
|
function renderText(text, paint) {
|
|
@@ -1689,7 +2111,7 @@ const STATUS_SYMBOL = {
|
|
|
1689
2111
|
};
|
|
1690
2112
|
const MASK = "********";
|
|
1691
2113
|
const COLUMN_GAP = " ";
|
|
1692
|
-
const RAIL = "│";
|
|
2114
|
+
const RAIL$1 = "│";
|
|
1693
2115
|
const BRANCH = "├─";
|
|
1694
2116
|
const LAST_BRANCH = "└─";
|
|
1695
2117
|
const TRAILING_SPACES = / +$/;
|
|
@@ -1759,10 +2181,10 @@ function toned(text, tone) {
|
|
|
1759
2181
|
function writeFields(rows, rail, paint, write) {
|
|
1760
2182
|
const cells = rows.map((row) => ({
|
|
1761
2183
|
label: toned(extend(row.label, ":"), "heading"),
|
|
1762
|
-
value: row.sensitive === true ? MASK : row.value
|
|
2184
|
+
value: row.sensitive === true ? MASK : orPlaceholder(row.value)
|
|
1763
2185
|
}));
|
|
1764
2186
|
const width = Math.max(0, ...cells.map((cell) => textWidth(cell.label)));
|
|
1765
|
-
const prefix = rail ? `${paint("structure", RAIL)}${COLUMN_GAP}` : "";
|
|
2187
|
+
const prefix = rail ? `${paint("structure", RAIL$1)}${COLUMN_GAP}` : "";
|
|
1766
2188
|
for (const cell of cells) write(`${prefix}${renderText(padTo(cell.label, width), paint)}${COLUMN_GAP}${renderText(cell.value, paint)}`);
|
|
1767
2189
|
}
|
|
1768
2190
|
/**
|
|
@@ -1770,8 +2192,23 @@ function writeFields(rows, rail, paint, write) {
|
|
|
1770
2192
|
* than the bytes so colour cannot shift a column. The last column is
|
|
1771
2193
|
* never padded, so no line carries trailing whitespace.
|
|
1772
2194
|
*/
|
|
2195
|
+
/** One header convention for every table: plain-string headers are
|
|
2196
|
+
* normalized to sentence case, so casing is not a per-command choice. */
|
|
2197
|
+
function sentenceCase(text) {
|
|
2198
|
+
if (typeof text !== "string" || text === "") return text;
|
|
2199
|
+
return `${text[0].toUpperCase()}${text.slice(1)}`;
|
|
2200
|
+
}
|
|
2201
|
+
const PLACEHOLDER = "—";
|
|
2202
|
+
/** An absent value renders as a dim em dash rather than invented prose
|
|
2203
|
+
* ("none", "n/a") in data tone. */
|
|
2204
|
+
function orPlaceholder(cell) {
|
|
2205
|
+
return cell === "" || typeof cell !== "string" && textWidth(cell) === 0 ? [{
|
|
2206
|
+
text: PLACEHOLDER,
|
|
2207
|
+
tone: "placeholder"
|
|
2208
|
+
}] : cell;
|
|
2209
|
+
}
|
|
1773
2210
|
function writeTable(columns, rows, paint, write) {
|
|
1774
|
-
const all = [columns.map((column) => toned(column, "heading")), ...rows];
|
|
2211
|
+
const all = [columns.map((column) => toned(sentenceCase(column), "heading")), ...rows.map((row) => row.map(orPlaceholder))];
|
|
1775
2212
|
const widths = [];
|
|
1776
2213
|
for (const row of all) for (const [index, cell] of row.entries()) widths[index] = Math.max(widths[index] ?? 0, textWidth(cell));
|
|
1777
2214
|
for (const row of all) write(row.map((cell, index) => renderText(index === row.length - 1 ? cell : padTo(cell, widths[index]), paint)).join(COLUMN_GAP).replace(TRAILING_SPACES, ""));
|
|
@@ -1782,7 +2219,7 @@ function writeBranches(nodes, prefix, paint, write) {
|
|
|
1782
2219
|
for (const [index, node] of nodes.entries()) {
|
|
1783
2220
|
const last = index === nodes.length - 1;
|
|
1784
2221
|
write(`${prefix}${paint("structure", last ? LAST_BRANCH : BRANCH)} ${treeLabel(node, paint)}`);
|
|
1785
|
-
const continuation = last ? " " : `${paint("structure", RAIL)}${COLUMN_GAP}`;
|
|
2222
|
+
const continuation = last ? " " : `${paint("structure", RAIL$1)}${COLUMN_GAP}`;
|
|
1786
2223
|
writeBranches(node.children ?? [], `${prefix}${continuation}`, paint, write);
|
|
1787
2224
|
}
|
|
1788
2225
|
}
|
|
@@ -1797,21 +2234,27 @@ const DIAGNOSTIC_SYMBOL = {
|
|
|
1797
2234
|
warn: "⚠",
|
|
1798
2235
|
info: "ℹ"
|
|
1799
2236
|
};
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
2237
|
+
const PLAIN = makePaint(false);
|
|
2238
|
+
function writeDiagnostic(stream, diagnostic, paint = PLAIN) {
|
|
2239
|
+
const glyph = paint(diagnostic.severity, DIAGNOSTIC_SYMBOL[diagnostic.severity]);
|
|
2240
|
+
const code = paint("muted", `[${diagnostic.code}]`);
|
|
2241
|
+
stream.write(`${glyph} ${code} ${diagnostic.summary}\n`);
|
|
2242
|
+
if (diagnostic.why !== void 0) stream.write(` ${paint("muted", `why: ${diagnostic.why}`)}\n`);
|
|
2243
|
+
for (const action of diagnostic.nextActions) stream.write(`${renderNextAction(action, paint)}\n`);
|
|
2244
|
+
if (diagnostic.docsUrl !== void 0) stream.write(` ${paint("muted", "docs:")} ${paint("link", diagnostic.docsUrl)}\n`);
|
|
1805
2245
|
}
|
|
1806
2246
|
/** `label` is required, so a mapper building an action out of a bare
|
|
1807
2247
|
* command string — a legacy error's follow-up step, with no prose
|
|
1808
2248
|
* beside it — has nothing to put in the label but the command itself.
|
|
1809
2249
|
* Only the renderer sees both fields, so only it can tell they are the
|
|
1810
2250
|
* same string and print it once. */
|
|
1811
|
-
function renderNextAction(action) {
|
|
2251
|
+
function renderNextAction(action, paint = PLAIN) {
|
|
1812
2252
|
const target = action.command ?? action.url;
|
|
1813
2253
|
const repeatsTheLabel = target === void 0 || target === action.label;
|
|
1814
|
-
|
|
2254
|
+
const arrow = paint("heading", "→");
|
|
2255
|
+
if (repeatsTheLabel) return `${arrow} ${action.command !== void 0 ? paint("identifier", action.label) : action.label}`;
|
|
2256
|
+
const painted = action.command !== void 0 ? paint("identifier", target) : paint("link", target);
|
|
2257
|
+
return `${arrow} ${action.label}: ${painted}`;
|
|
1815
2258
|
}
|
|
1816
2259
|
/** Populates docsUrl from the owning family's docsBaseUrl (base + code)
|
|
1817
2260
|
* when the diagnostic does not carry its own — a per-raise docsUrl wins. */
|
|
@@ -1823,6 +2266,27 @@ function withDocsUrl(state, diagnostic) {
|
|
|
1823
2266
|
docsUrl: `${base}${diagnostic.code}`
|
|
1824
2267
|
};
|
|
1825
2268
|
}
|
|
2269
|
+
const TRAILING_NEWLINE = /\n$/;
|
|
2270
|
+
function diagnosticSection(diagnostic, paint) {
|
|
2271
|
+
const lines = [];
|
|
2272
|
+
writeDiagnostic({ write: (text) => lines.push(...text.replace(TRAILING_NEWLINE, "").split("\n")) }, diagnostic, paint);
|
|
2273
|
+
return {
|
|
2274
|
+
lines,
|
|
2275
|
+
compact: lines.length === 1
|
|
2276
|
+
};
|
|
2277
|
+
}
|
|
2278
|
+
/** A blank line between sections wherever a multi-line one is involved,
|
|
2279
|
+
* so a card, a table and the next actions each read as their own
|
|
2280
|
+
* paragraph; adjacent compact sections keep hugging. */
|
|
2281
|
+
function writeSections(sections, stream) {
|
|
2282
|
+
let previous;
|
|
2283
|
+
for (const section of sections) {
|
|
2284
|
+
if (section.lines.length === 0) continue;
|
|
2285
|
+
if (previous !== void 0 && !(previous.compact && section.compact)) stream.write("\n");
|
|
2286
|
+
for (const line of section.lines) stream.write(`${line}\n`);
|
|
2287
|
+
previous = section;
|
|
2288
|
+
}
|
|
2289
|
+
}
|
|
1826
2290
|
/** Channel discipline (operator ruling, 2026-08-09): human Blocks,
|
|
1827
2291
|
* next-action lines, and diagnostics are presentation prose on stderr;
|
|
1828
2292
|
* the materialized `stdout` presentation lines are the machine-usable
|
|
@@ -1830,10 +2294,21 @@ function withDocsUrl(state, diagnostic) {
|
|
|
1830
2294
|
function renderCompletedHuman(invocation, presented) {
|
|
1831
2295
|
const { runtime, state } = invocation;
|
|
1832
2296
|
const paint = makePaint(state.colorEnabled);
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
2297
|
+
const sections = presented.presentation.human.map((block) => {
|
|
2298
|
+
const lines = [];
|
|
2299
|
+
renderBlock(block, paint, (line) => lines.push(line));
|
|
2300
|
+
return {
|
|
2301
|
+
lines,
|
|
2302
|
+
compact: block.kind === "summary"
|
|
2303
|
+
};
|
|
2304
|
+
});
|
|
2305
|
+
if (presented.presentation.next.length > 0) sections.push({
|
|
2306
|
+
lines: presented.presentation.next.map((action) => renderNextAction(action, paint)),
|
|
2307
|
+
compact: true
|
|
2308
|
+
});
|
|
2309
|
+
for (const diagnostic of presented.diagnostics) sections.push(diagnosticSection(withDocsUrl(state, diagnostic), paint));
|
|
2310
|
+
writeSections(sections, runtime.stderr);
|
|
2311
|
+
if (!(runtime.isTty.stdout && runtime.isTty.stderr && runtime.outputStreamsShareDevice !== false)) for (const line of presented.presentation.stdout) runtime.stdout.write(`${line}\n`);
|
|
1837
2312
|
}
|
|
1838
2313
|
const SEVERITY_RANK = {
|
|
1839
2314
|
error: 0,
|
|
@@ -2065,7 +2540,7 @@ function writeSectionWarnings(invocation, diagnostics) {
|
|
|
2065
2540
|
const state = invocation.state;
|
|
2066
2541
|
for (const diagnostic of diagnostics) {
|
|
2067
2542
|
if (SEVERITY_RANK[diagnostic.severity] > SEVERITY_RANK[state.logLevel]) continue;
|
|
2068
|
-
writeDiagnostic(invocation.runtime.stderr, withDocsUrl(state, diagnostic));
|
|
2543
|
+
writeDiagnostic(invocation.runtime.stderr, withDocsUrl(state, diagnostic), makePaint(state.colorEnabled));
|
|
2069
2544
|
}
|
|
2070
2545
|
}
|
|
2071
2546
|
function dependencyResolvable(specifier, cwd) {
|
|
@@ -2914,12 +3389,31 @@ function makeUi(colorEnabled, stderr) {
|
|
|
2914
3389
|
};
|
|
2915
3390
|
}
|
|
2916
3391
|
/** Materializes ONLY the active format's presentation functions, at the
|
|
2917
|
-
* return site: human → human + stdout + next; json → json + next.
|
|
3392
|
+
* return site: human → human + stdout + next; json → json + next.
|
|
3393
|
+
*
|
|
3394
|
+
* `stdout` and `next` may be absent at runtime, so both are called with
|
|
3395
|
+
* `?.()`. `Presentations` requires all four, so no command compiled
|
|
3396
|
+
* against this engine can omit one — but `@prisma/orm-toolchain` is
|
|
3397
|
+
* built against engine `0.0.9`, where three of the four were optional,
|
|
3398
|
+
* and its published commands took that up: `migration list` declares
|
|
3399
|
+
* `human` and `json` and neither of the others. Calling them
|
|
3400
|
+
* unconditionally makes it exit 2 — `stdout` in human mode, `next` in
|
|
3401
|
+
* both.
|
|
3402
|
+
*
|
|
3403
|
+
* `json` is called unconditionally, and stays that way: a missing json
|
|
3404
|
+
* presentation is the defect this change removes, and every ORM command
|
|
3405
|
+
* already declares one.
|
|
3406
|
+
*
|
|
3407
|
+
* This is version skew in our own code, not a foreign contract. The fix
|
|
3408
|
+
* is in prisma/prisma: declare the missing presentations in the ORM
|
|
3409
|
+
* commands and build orm-toolchain against this engine, where the type
|
|
3410
|
+
* refuses to compile without them. Delete both `?.()` when that
|
|
3411
|
+
* version is pinned here. */
|
|
2918
3412
|
function materializePresentation(state, ui, presentations) {
|
|
2919
3413
|
if (state.format === "json") return {
|
|
2920
3414
|
human: [],
|
|
2921
3415
|
stdout: [],
|
|
2922
|
-
json: presentations.json
|
|
3416
|
+
json: presentations.json(),
|
|
2923
3417
|
next: presentations.next?.() ?? []
|
|
2924
3418
|
};
|
|
2925
3419
|
return {
|
|
@@ -2962,7 +3456,8 @@ function makeContext(invocation, def, config, capabilities) {
|
|
|
2962
3456
|
signal: invocation.signal,
|
|
2963
3457
|
cwd: invocation.runtime.cwd,
|
|
2964
3458
|
env: invocation.runtime.env,
|
|
2965
|
-
|
|
3459
|
+
host: invocation.runtime.host,
|
|
3460
|
+
isCI: resolveIsCI(invocation.runtime),
|
|
2966
3461
|
requireDependency: async (specifier) => {
|
|
2967
3462
|
if (dependencyResolvable(specifier, invocation.runtime.cwd)) return okVoid();
|
|
2968
3463
|
return notOk(missingDependencyError(specifier, await resolvePackageManager({
|
|
@@ -3092,6 +3587,12 @@ function stricliFlagParameter(spec) {
|
|
|
3092
3587
|
brief: spec.brief,
|
|
3093
3588
|
default: false
|
|
3094
3589
|
};
|
|
3590
|
+
case "optionalBoolean": return {
|
|
3591
|
+
kind: "boolean",
|
|
3592
|
+
brief: spec.brief,
|
|
3593
|
+
optional: true,
|
|
3594
|
+
withNegated: true
|
|
3595
|
+
};
|
|
3095
3596
|
case "enum": return {
|
|
3096
3597
|
kind: "enum",
|
|
3097
3598
|
brief: spec.brief,
|
|
@@ -3256,6 +3757,315 @@ function usageErrorCode(stricliExitCode) {
|
|
|
3256
3757
|
if (stricliExitCode === -4) return "CLI.INVALID_ARGUMENTS";
|
|
3257
3758
|
}
|
|
3258
3759
|
//#endregion
|
|
3760
|
+
//#region src/execution/help.ts
|
|
3761
|
+
/**
|
|
3762
|
+
* Engine-rendered help: the command tree drawn with the same tones the
|
|
3763
|
+
* block renderer uses, so help is themed like every other surface.
|
|
3764
|
+
* stricli's text_en renderer is never consulted — root and group help
|
|
3765
|
+
* list `name brief` rows, and full signatures appear only on the leaf
|
|
3766
|
+
* that owns them.
|
|
3767
|
+
*/
|
|
3768
|
+
const RAIL = "│";
|
|
3769
|
+
const GAP = " ";
|
|
3770
|
+
const WRAP_WIDTH = 76;
|
|
3771
|
+
function flagTokens(argv) {
|
|
3772
|
+
const terminator = argv.indexOf("--");
|
|
3773
|
+
return terminator === -1 ? argv : argv.slice(0, terminator);
|
|
3774
|
+
}
|
|
3775
|
+
function helpFlagGiven(argv) {
|
|
3776
|
+
return flagTokens(argv).some((token) => token === "-h" || token === "--help" || token === "--help-all");
|
|
3777
|
+
}
|
|
3778
|
+
/** The colour decision available before the shared flags are parsed,
|
|
3779
|
+
* read from raw argv: explicit flag, then NO_COLOR, then the TTY of
|
|
3780
|
+
* the stream about to be written. Help and pre-mount failures both
|
|
3781
|
+
* render through this; applySharedFlags re-resolves once a command
|
|
3782
|
+
* actually parses. */
|
|
3783
|
+
function preParseColorEnabled(argv, runtime, stream) {
|
|
3784
|
+
const tokens = flagTokens(argv);
|
|
3785
|
+
if (tokens.includes("--no-color")) return false;
|
|
3786
|
+
if (tokens.includes("--color")) return true;
|
|
3787
|
+
if (runtime.env.NO_COLOR !== void 0) return false;
|
|
3788
|
+
return runtime.isTty[stream];
|
|
3789
|
+
}
|
|
3790
|
+
/** The command path the user asked help for: the leading non-flag
|
|
3791
|
+
* tokens, resolved as far as the tree recognizes them. */
|
|
3792
|
+
function helpPath(argv) {
|
|
3793
|
+
const segments = [];
|
|
3794
|
+
for (const token of argv) {
|
|
3795
|
+
if (token.startsWith("-")) break;
|
|
3796
|
+
segments.push(token);
|
|
3797
|
+
}
|
|
3798
|
+
return segments;
|
|
3799
|
+
}
|
|
3800
|
+
/** Walks as far as the segments stay recognized; help for `project
|
|
3801
|
+
* frobnicate` is project's help, not a dead end. */
|
|
3802
|
+
function resolveTarget(root, segments) {
|
|
3803
|
+
let node = root;
|
|
3804
|
+
const path = [];
|
|
3805
|
+
for (const segment of segments) {
|
|
3806
|
+
const entry = node.commands.get(segment);
|
|
3807
|
+
if (entry !== void 0) return {
|
|
3808
|
+
target: {
|
|
3809
|
+
kind: "leaf",
|
|
3810
|
+
entry
|
|
3811
|
+
},
|
|
3812
|
+
path: [...path, segment]
|
|
3813
|
+
};
|
|
3814
|
+
const child = node.children.get(segment);
|
|
3815
|
+
if (child === void 0) break;
|
|
3816
|
+
node = child;
|
|
3817
|
+
path.push(segment);
|
|
3818
|
+
}
|
|
3819
|
+
return {
|
|
3820
|
+
target: {
|
|
3821
|
+
kind: "node",
|
|
3822
|
+
node
|
|
3823
|
+
},
|
|
3824
|
+
path
|
|
3825
|
+
};
|
|
3826
|
+
}
|
|
3827
|
+
/** A BARE group invocation (`prisma-cli project`, or no argv at all)
|
|
3828
|
+
* is a help request; anything carrying flags or extra tokens is not —
|
|
3829
|
+
* `cli --unknown` and `cli project --frobnicate` must reach routing
|
|
3830
|
+
* and usage validation, not exit 0 with a help card. A bare leaf is a
|
|
3831
|
+
* command run and is left alone. */
|
|
3832
|
+
function bareGroupInvocation(root, argv) {
|
|
3833
|
+
const segments = helpPath(argv);
|
|
3834
|
+
if (segments.length !== argv.length) return false;
|
|
3835
|
+
if (segments.length === 0) return true;
|
|
3836
|
+
const { target, path } = resolveTarget(root, segments);
|
|
3837
|
+
return target.kind === "node" && path.length === segments.length;
|
|
3838
|
+
}
|
|
3839
|
+
function renderHelp(spec, root, argv, colorEnabled, out) {
|
|
3840
|
+
const paint = makePaint(colorEnabled);
|
|
3841
|
+
const { target, path } = resolveTarget(root, helpPath(argv));
|
|
3842
|
+
const lines = [];
|
|
3843
|
+
if (target.kind === "leaf") renderLeafHelp(spec, target.entry, path, paint, lines);
|
|
3844
|
+
else renderNodeHelp(spec, target.node, path, paint, lines);
|
|
3845
|
+
out.write(`${lines.join("\n")}\n`);
|
|
3846
|
+
}
|
|
3847
|
+
/** `prisma-cli project → Manage and inspect your Prisma projects` */
|
|
3848
|
+
function header(spec, path, tagline, paint) {
|
|
3849
|
+
const name = paint("emphasis", [spec.name, ...path].join(" "));
|
|
3850
|
+
if (tagline === void 0 || tagline === "") return name;
|
|
3851
|
+
return `${name} ${paint("muted", `→ ${tagline}`)}`;
|
|
3852
|
+
}
|
|
3853
|
+
function rail(paint, rest = "") {
|
|
3854
|
+
return rest === "" ? paint("structure", RAIL) : `${paint("structure", RAIL)}${GAP}${rest}`;
|
|
3855
|
+
}
|
|
3856
|
+
function sectionLabel(paint, label) {
|
|
3857
|
+
return rail(paint, paint("muted", label));
|
|
3858
|
+
}
|
|
3859
|
+
/** Two-column rows under the rail: name in the accent, brief plain. */
|
|
3860
|
+
function railRows(rows, paint, lines) {
|
|
3861
|
+
const width = Math.max(0, ...rows.map((row) => textWidth(row.name)));
|
|
3862
|
+
for (const row of rows) {
|
|
3863
|
+
const pad = " ".repeat(width - textWidth(row.name));
|
|
3864
|
+
const suffix = row.suffix === void 0 || row.suffix === "" ? "" : ` ${paint("muted", row.suffix)}`;
|
|
3865
|
+
lines.push(rail(paint, `${paint("identifier", row.name)}${pad}${GAP}${row.brief}${suffix}`));
|
|
3866
|
+
}
|
|
3867
|
+
}
|
|
3868
|
+
function wrap(text, width) {
|
|
3869
|
+
const lines = [];
|
|
3870
|
+
for (const paragraph of text.split("\n")) {
|
|
3871
|
+
if (paragraph === "") {
|
|
3872
|
+
lines.push("");
|
|
3873
|
+
continue;
|
|
3874
|
+
}
|
|
3875
|
+
let line = "";
|
|
3876
|
+
for (const word of paragraph.split(" ")) if (line !== "" && line.length + 1 + word.length > width) {
|
|
3877
|
+
lines.push(line);
|
|
3878
|
+
line = word;
|
|
3879
|
+
} else line = line === "" ? word : `${line} ${word}`;
|
|
3880
|
+
if (line !== "") lines.push(line);
|
|
3881
|
+
}
|
|
3882
|
+
return lines;
|
|
3883
|
+
}
|
|
3884
|
+
function proseLines(text, paint, lines, tone = "plain") {
|
|
3885
|
+
for (const line of wrap(text, WRAP_WIDTH)) lines.push(rail(paint, tone === "muted" ? paint("muted", line) : line));
|
|
3886
|
+
}
|
|
3887
|
+
function exampleLines(examples, cliName, paint, lines) {
|
|
3888
|
+
if (examples.length === 0) return;
|
|
3889
|
+
lines.push(rail(paint));
|
|
3890
|
+
lines.push(sectionLabel(paint, "Examples"));
|
|
3891
|
+
for (const example of examples) lines.push(rail(paint, `${GAP}${paint("muted", "$")} ${resolveExample(example, cliName)}`));
|
|
3892
|
+
}
|
|
3893
|
+
function docsLine(url, paint, lines) {
|
|
3894
|
+
if (url === void 0) return;
|
|
3895
|
+
lines.push(rail(paint));
|
|
3896
|
+
lines.push(rail(paint, `${paint("muted", "Docs")}${GAP}${paint("link", url)}`));
|
|
3897
|
+
}
|
|
3898
|
+
/** `--interactive/--no-interactive`, `-q, --quiet`, `--config <path>` —
|
|
3899
|
+
* one spelling rule for shared and declared flags alike. */
|
|
3900
|
+
function flagLabel(key, spec) {
|
|
3901
|
+
const kebab = kebabCase(key);
|
|
3902
|
+
return `${spec.alias === void 0 ? " " : `-${spec.alias},`} --${kebab}${spec.withNegated === true ? `/--no-${kebab}` : ""}${spec.placeholder === void 0 ? "" : ` <${spec.placeholder}>`}${spec.variadic === true ? "..." : ""}`;
|
|
3903
|
+
}
|
|
3904
|
+
function sharedFlagRows() {
|
|
3905
|
+
const aliasByKey = new Map(Object.entries(SHARED_ALIASES).map(([alias, key]) => [key, alias]));
|
|
3906
|
+
return [
|
|
3907
|
+
...Object.entries(SHARED_FLAG_PARAMETERS).map(([key, spec]) => {
|
|
3908
|
+
const record = spec;
|
|
3909
|
+
return {
|
|
3910
|
+
name: flagLabel(key, {
|
|
3911
|
+
...record,
|
|
3912
|
+
alias: aliasByKey.get(key)
|
|
3913
|
+
}),
|
|
3914
|
+
brief: record.brief,
|
|
3915
|
+
suffix: record.values === void 0 ? void 0 : record.values.join("|")
|
|
3916
|
+
};
|
|
3917
|
+
}),
|
|
3918
|
+
{
|
|
3919
|
+
name: `-h, --help`,
|
|
3920
|
+
brief: "Print help for a command"
|
|
3921
|
+
},
|
|
3922
|
+
{
|
|
3923
|
+
name: ` --version`,
|
|
3924
|
+
brief: "Print the CLI version and exit"
|
|
3925
|
+
}
|
|
3926
|
+
];
|
|
3927
|
+
}
|
|
3928
|
+
function declaredFlagRows(def) {
|
|
3929
|
+
return Object.entries(def.args.flags).map(([key, spec]) => {
|
|
3930
|
+
const runtime = flagRuntime(spec);
|
|
3931
|
+
return {
|
|
3932
|
+
name: flagLabel(key, {
|
|
3933
|
+
alias: runtime.alias,
|
|
3934
|
+
placeholder: runtime.type === "boolean" || runtime.type === "optionalBoolean" ? void 0 : runtime.placeholder ?? "value",
|
|
3935
|
+
withNegated: runtime.type === "optionalBoolean",
|
|
3936
|
+
variadic: runtime.type === "repeated"
|
|
3937
|
+
}),
|
|
3938
|
+
brief: runtime.brief,
|
|
3939
|
+
suffix: flagSuffix(runtime)
|
|
3940
|
+
};
|
|
3941
|
+
});
|
|
3942
|
+
}
|
|
3943
|
+
function flagSuffix(runtime) {
|
|
3944
|
+
const parts = [];
|
|
3945
|
+
if (runtime.values !== void 0 && runtime.values.length > 0) parts.push(runtime.values.join("|"));
|
|
3946
|
+
if (runtime.type === "requiredString") parts.push("required");
|
|
3947
|
+
if (runtime.default !== void 0) parts.push(`default: ${String(runtime.default)}`);
|
|
3948
|
+
return parts.length === 0 ? void 0 : `(${parts.join("; ")})`;
|
|
3949
|
+
}
|
|
3950
|
+
function positionalUsage(def) {
|
|
3951
|
+
return Object.values(def.args.positionals).map((spec) => {
|
|
3952
|
+
const runtime = positionalRuntime(spec);
|
|
3953
|
+
if (runtime.type === "optionalString") return `[${runtime.placeholder}]`;
|
|
3954
|
+
if (runtime.type === "variadic") return `[${runtime.placeholder}...]`;
|
|
3955
|
+
return `<${runtime.placeholder}>`;
|
|
3956
|
+
}).join(" ");
|
|
3957
|
+
}
|
|
3958
|
+
function requiredFlagUsage(def) {
|
|
3959
|
+
return Object.entries(def.args.flags).flatMap(([key, spec]) => {
|
|
3960
|
+
const runtime = flagRuntime(spec);
|
|
3961
|
+
return runtime.type === "requiredString" ? [`--${kebabCase(key)} <${runtime.placeholder ?? "value"}>`] : [];
|
|
3962
|
+
}).join(" ");
|
|
3963
|
+
}
|
|
3964
|
+
/** Mount order, not map-partition order: a leaf and a group list in
|
|
3965
|
+
* the order their first command was mounted. */
|
|
3966
|
+
function nodeRows(spec, node, path) {
|
|
3967
|
+
const groupPath = path.join(" ");
|
|
3968
|
+
const depth = path.length;
|
|
3969
|
+
const seen = /* @__PURE__ */ new Set();
|
|
3970
|
+
const rows = [];
|
|
3971
|
+
for (const mounted of Object.keys(spec.commands)) {
|
|
3972
|
+
const segments = mounted.split(" ");
|
|
3973
|
+
if (segments.length <= depth || segments.slice(0, depth).join(" ") !== groupPath) continue;
|
|
3974
|
+
const name = segments[depth];
|
|
3975
|
+
if (seen.has(name)) continue;
|
|
3976
|
+
seen.add(name);
|
|
3977
|
+
const entry = node.commands.get(name);
|
|
3978
|
+
if (entry !== void 0) rows.push({
|
|
3979
|
+
name: usageName(name, entry.def),
|
|
3980
|
+
brief: entry.def.help.summary
|
|
3981
|
+
});
|
|
3982
|
+
else if (node.children.has(name)) {
|
|
3983
|
+
const childPath = depth === 0 ? name : `${groupPath} ${name}`;
|
|
3984
|
+
rows.push({
|
|
3985
|
+
name,
|
|
3986
|
+
brief: spec.groups[childPath]?.brief ?? ""
|
|
3987
|
+
});
|
|
3988
|
+
}
|
|
3989
|
+
}
|
|
3990
|
+
return rows;
|
|
3991
|
+
}
|
|
3992
|
+
function renderNodeHelp(spec, node, path, paint, lines) {
|
|
3993
|
+
const atRoot = path.length === 0;
|
|
3994
|
+
const groupPath = path.join(" ");
|
|
3995
|
+
const tagline = atRoot ? spec.help?.tagline : spec.groups[groupPath]?.brief;
|
|
3996
|
+
lines.push(header(spec, path, tagline, paint));
|
|
3997
|
+
lines.push("");
|
|
3998
|
+
railRows(nodeRows(spec, node, path), paint, lines);
|
|
3999
|
+
const description = atRoot ? spec.help?.description : spec.groups[groupPath]?.description;
|
|
4000
|
+
if (description !== void 0) {
|
|
4001
|
+
lines.push(rail(paint));
|
|
4002
|
+
proseLines(description, paint, lines);
|
|
4003
|
+
}
|
|
4004
|
+
if (atRoot) {
|
|
4005
|
+
lines.push(rail(paint));
|
|
4006
|
+
lines.push(sectionLabel(paint, "Global options"));
|
|
4007
|
+
railRows(sharedFlagRows(), paint, lines);
|
|
4008
|
+
exampleLines(spec.help?.examples ?? [], spec.name, paint, lines);
|
|
4009
|
+
docsLine(spec.help?.docsUrl, paint, lines);
|
|
4010
|
+
} else {
|
|
4011
|
+
lines.push(rail(paint));
|
|
4012
|
+
lines.push(rail(paint, paint("muted", `Run '${spec.name} ${groupPath} <command> --help' for details on a command.`)));
|
|
4013
|
+
}
|
|
4014
|
+
lines.push("");
|
|
4015
|
+
}
|
|
4016
|
+
/** `link [id-or-name]` — the row a group lists for a leaf: name plus
|
|
4017
|
+
* positional shape, briefs carry the rest. */
|
|
4018
|
+
function usageName(name, def) {
|
|
4019
|
+
const positionals = positionalUsage(def);
|
|
4020
|
+
return positionals === "" ? name : `${name} ${positionals}`;
|
|
4021
|
+
}
|
|
4022
|
+
function renderLeafHelp(spec, entry, path, paint, lines) {
|
|
4023
|
+
const def = entry.def;
|
|
4024
|
+
lines.push(header(spec, path, def.help.summary, paint));
|
|
4025
|
+
lines.push("");
|
|
4026
|
+
const usageParts = [
|
|
4027
|
+
spec.name,
|
|
4028
|
+
...path,
|
|
4029
|
+
requiredFlagUsage(def),
|
|
4030
|
+
"[options]",
|
|
4031
|
+
positionalUsage(def)
|
|
4032
|
+
].filter((part) => part !== "");
|
|
4033
|
+
lines.push(sectionLabel(paint, "Usage"));
|
|
4034
|
+
lines.push(rail(paint, `${GAP}${paint("muted", "$")} ${paint("emphasis", usageParts.join(" "))}`));
|
|
4035
|
+
if (def.help.description !== void 0) {
|
|
4036
|
+
lines.push(rail(paint));
|
|
4037
|
+
proseLines(def.help.description, paint, lines);
|
|
4038
|
+
}
|
|
4039
|
+
if (def.maySpawn) {
|
|
4040
|
+
lines.push(rail(paint));
|
|
4041
|
+
lines.push(rail(paint, paint("muted", NO_JSON_NOTE)));
|
|
4042
|
+
}
|
|
4043
|
+
const positionalEntries = Object.values(def.args.positionals).map((spec) => positionalRuntime(spec));
|
|
4044
|
+
if (positionalEntries.length > 0) {
|
|
4045
|
+
lines.push(rail(paint));
|
|
4046
|
+
lines.push(sectionLabel(paint, "Arguments"));
|
|
4047
|
+
railRows(positionalEntries.map((runtime) => ({
|
|
4048
|
+
name: runtime.placeholder,
|
|
4049
|
+
brief: runtime.brief,
|
|
4050
|
+
suffix: runtime.type === "optionalString" ? "(optional)" : void 0
|
|
4051
|
+
})), paint, lines);
|
|
4052
|
+
}
|
|
4053
|
+
const flagRows = declaredFlagRows(def);
|
|
4054
|
+
if (flagRows.length > 0) {
|
|
4055
|
+
lines.push(rail(paint));
|
|
4056
|
+
lines.push(sectionLabel(paint, "Options"));
|
|
4057
|
+
railRows(flagRows, paint, lines);
|
|
4058
|
+
}
|
|
4059
|
+
if (def.kind !== "server-command") {
|
|
4060
|
+
const sharedNames = [...Object.keys(SHARED_FLAG_PARAMETERS).map((key) => `--${kebabCase(key)}`)].join(", ");
|
|
4061
|
+
lines.push(rail(paint));
|
|
4062
|
+
proseLines(`Global options also apply: ${sharedNames}. Run '${spec.name} --help' for details.`, paint, lines, "muted");
|
|
4063
|
+
}
|
|
4064
|
+
exampleLines(def.help.examples, spec.name, paint, lines);
|
|
4065
|
+
docsLine(entry.docsBaseUrl, paint, lines);
|
|
4066
|
+
lines.push("");
|
|
4067
|
+
}
|
|
4068
|
+
//#endregion
|
|
3259
4069
|
//#region src/execution/settlement.ts
|
|
3260
4070
|
function undocumentedExitCode(def, exitCode) {
|
|
3261
4071
|
if (exitCode === 0) return;
|
|
@@ -3282,7 +4092,7 @@ function settleCompleted(invocation, def, presented) {
|
|
|
3282
4092
|
envelope: {
|
|
3283
4093
|
ok: true,
|
|
3284
4094
|
commandId: state.commandId,
|
|
3285
|
-
result: presented.presentation.json
|
|
4095
|
+
result: presented.presentation.json,
|
|
3286
4096
|
exitCode,
|
|
3287
4097
|
diagnostics: presented.diagnostics.map((diagnostic) => withDocsUrl(state, diagnostic)),
|
|
3288
4098
|
nextActions: presented.presentation.next
|
|
@@ -3397,7 +4207,7 @@ function settleChildStatus(invocation, def, settlement) {
|
|
|
3397
4207
|
if (!def.maySpawn) throw new Error(`@prisma/cli-engine: command '${invocation.state.commandId}' returned exitWithChildStatus without declaring maySpawn — only a command that hands the terminal to another program may settle with that program's status`);
|
|
3398
4208
|
const child = invocation.state.lastChild;
|
|
3399
4209
|
if (child === void 0) throw new Error(`@prisma/cli-engine: command '${invocation.state.commandId}' returned exitWithChildStatus without a child having run — that settlement reports the status of a child ctx.spawn started, and this run started none`);
|
|
3400
|
-
if (child.signal === null) for (const action of settlement.nextActions) invocation.runtime.stderr.write(`${renderNextAction(action)}\n`);
|
|
4210
|
+
if (child.signal === null) for (const action of settlement.nextActions) invocation.runtime.stderr.write(`${renderNextAction(action, makePaint(invocation.state.colorEnabled))}\n`);
|
|
3401
4211
|
settleVerbatimExitCode(invocation, childExitCode(child));
|
|
3402
4212
|
}
|
|
3403
4213
|
/** A session command that returned ok shut down cleanly: no
|
|
@@ -3456,9 +4266,8 @@ function emitErrored(invocation, raw) {
|
|
|
3456
4266
|
});
|
|
3457
4267
|
return;
|
|
3458
4268
|
}
|
|
3459
|
-
const
|
|
3460
|
-
|
|
3461
|
-
for (const diagnostic of envelope.diagnostics) writeDiagnostic(stderr, diagnostic);
|
|
4269
|
+
const paint = makePaint(invocation.state.colorEnabled);
|
|
4270
|
+
writeSections([envelope.error, ...envelope.diagnostics].map((diagnostic) => diagnosticSection(diagnostic, paint)), invocation.runtime.stderr);
|
|
3462
4271
|
}
|
|
3463
4272
|
/** `--version` prints createCli's version and exits 0. In json mode the
|
|
3464
4273
|
* version travels as the run's single result frame. */
|
|
@@ -3535,21 +4344,63 @@ function settleUnhandled(spec, invocation, stricliExitCode) {
|
|
|
3535
4344
|
const full = captured.length > 0 ? captured : "The command failed unexpectedly";
|
|
3536
4345
|
const summary = firstLine(full);
|
|
3537
4346
|
const remainder = full.slice(full.indexOf("\n") + 1).trim();
|
|
4347
|
+
const code = usageErrorCode(raw) ?? "CLI.INTERNAL_ERROR";
|
|
4348
|
+
const nextActions = code === "CLI.UNKNOWN_COMMAND" ? unknownCommandActions(spec, state) : [];
|
|
3538
4349
|
emitErrored(invocation, {
|
|
3539
4350
|
ok: false,
|
|
3540
4351
|
commandId: segments.join("."),
|
|
3541
4352
|
error: {
|
|
3542
|
-
code
|
|
4353
|
+
code,
|
|
3543
4354
|
severity: "error",
|
|
3544
4355
|
summary,
|
|
3545
4356
|
...usage && full.includes("\n") && remainder.length > 0 ? { why: remainder } : {},
|
|
3546
|
-
nextActions
|
|
4357
|
+
nextActions
|
|
3547
4358
|
},
|
|
3548
4359
|
diagnostics: [],
|
|
3549
|
-
nextActions
|
|
4360
|
+
nextActions
|
|
3550
4361
|
});
|
|
3551
4362
|
return usage ? 2 : 1;
|
|
3552
4363
|
}
|
|
4364
|
+
function editDistance(a, b) {
|
|
4365
|
+
const rows = a.length + 1;
|
|
4366
|
+
const cols = b.length + 1;
|
|
4367
|
+
const d = Array.from({ length: rows * cols }, () => 0);
|
|
4368
|
+
for (let i = 0; i < rows; i += 1) d[i * cols] = i;
|
|
4369
|
+
for (let j = 0; j < cols; j += 1) d[j] = j;
|
|
4370
|
+
for (let i = 1; i < rows; i += 1) for (let j = 1; j < cols; j += 1) {
|
|
4371
|
+
const substitution = a[i - 1] === b[j - 1] ? 0 : 1;
|
|
4372
|
+
d[i * cols + j] = Math.min(d[(i - 1) * cols + j] + 1, d[i * cols + j - 1] + 1, d[(i - 1) * cols + j - 1] + substitution);
|
|
4373
|
+
}
|
|
4374
|
+
return d[rows * cols - 1];
|
|
4375
|
+
}
|
|
4376
|
+
/** A misspelling is close (edit distance ≤ 2, and short paths tighter);
|
|
4377
|
+
* anything further is not a suggestion worth making. Every unknown
|
|
4378
|
+
* command at least learns where the command list is. */
|
|
4379
|
+
function unknownCommandActions(spec, state) {
|
|
4380
|
+
const attempted = [];
|
|
4381
|
+
for (const token of state.argv) {
|
|
4382
|
+
if (token.startsWith("-")) break;
|
|
4383
|
+
attempted.push(token);
|
|
4384
|
+
}
|
|
4385
|
+
const typed = attempted.join(" ");
|
|
4386
|
+
const candidates = new Set(Object.keys(spec.commands));
|
|
4387
|
+
for (const path of Object.keys(spec.commands)) {
|
|
4388
|
+
const segments = path.split(" ");
|
|
4389
|
+
for (let depth = 1; depth < segments.length; depth += 1) candidates.add(segments.slice(0, depth).join(" "));
|
|
4390
|
+
}
|
|
4391
|
+
return [...[...candidates].map((path) => ({
|
|
4392
|
+
path,
|
|
4393
|
+
distance: editDistance(typed, path)
|
|
4394
|
+
})).filter(({ path, distance }) => distance <= Math.max(path.length >= 8 ? 3 : 1, Math.min(2, path.length - 1))).sort((a, b) => a.distance - b.distance).slice(0, 3).map(({ path }) => ({
|
|
4395
|
+
kind: "run-command",
|
|
4396
|
+
label: "Did you mean",
|
|
4397
|
+
command: `${spec.name} ${path}`
|
|
4398
|
+
})), {
|
|
4399
|
+
kind: "run-command",
|
|
4400
|
+
label: "List every command",
|
|
4401
|
+
command: `${spec.name} --help`
|
|
4402
|
+
}];
|
|
4403
|
+
}
|
|
3553
4404
|
//#endregion
|
|
3554
4405
|
//#region src/execution/engine.ts
|
|
3555
4406
|
function buildEngine(spec, options) {
|
|
@@ -3571,6 +4422,7 @@ function waitFor(ms, signal) {
|
|
|
3571
4422
|
}
|
|
3572
4423
|
var EngineImpl = class {
|
|
3573
4424
|
spec;
|
|
4425
|
+
tree;
|
|
3574
4426
|
root;
|
|
3575
4427
|
redirects;
|
|
3576
4428
|
now;
|
|
@@ -3581,20 +4433,25 @@ var EngineImpl = class {
|
|
|
3581
4433
|
this.now = now;
|
|
3582
4434
|
this.delay = delay;
|
|
3583
4435
|
this.configSections = declaredConfigSections(spec);
|
|
3584
|
-
this.
|
|
4436
|
+
this.tree = buildCommandTree(spec);
|
|
4437
|
+
this.root = buildRoutes(spec, this.tree, "", (invocation, entry, flags, values) => this.executeMounted(invocation, entry, flags, values));
|
|
3585
4438
|
this.redirects = buildRedirectTable(spec);
|
|
3586
4439
|
}
|
|
3587
4440
|
async execute(argv, runtime, hooks) {
|
|
4441
|
+
const format = sniffFormat(argv, runtime);
|
|
3588
4442
|
const state = {
|
|
3589
4443
|
commandId: "",
|
|
3590
4444
|
docsBaseUrl: void 0,
|
|
3591
4445
|
prefix: [],
|
|
3592
|
-
format
|
|
4446
|
+
format,
|
|
3593
4447
|
logLevel: "info",
|
|
3594
4448
|
yes: false,
|
|
3595
4449
|
confirmValues: [],
|
|
3596
4450
|
interactive: defaultInteractive(runtime),
|
|
3597
|
-
|
|
4451
|
+
/** Pre-parse resolution so a run that never mounts a command — an
|
|
4452
|
+
* unknown command, a parse failure — still colours its
|
|
4453
|
+
* diagnostics; applySharedFlags re-resolves after parsing. */
|
|
4454
|
+
colorEnabled: preParseColorEnabled(argv, runtime, "stderr"),
|
|
3598
4455
|
configPath: void 0,
|
|
3599
4456
|
resolved: false,
|
|
3600
4457
|
settledExitCode: void 0,
|
|
@@ -3650,6 +4507,15 @@ var EngineImpl = class {
|
|
|
3650
4507
|
settleErrored(invocation, configFlagGivenNoValueError());
|
|
3651
4508
|
return 2;
|
|
3652
4509
|
}
|
|
4510
|
+
if (helpFlagGiven(argv) || bareGroupInvocation(this.tree, argv)) {
|
|
4511
|
+
unsubscribe();
|
|
4512
|
+
/** Help prose follows stricli's channel rule: stdout in human
|
|
4513
|
+
* mode, stderr in json mode so stdout stays a clean frame
|
|
4514
|
+
* stream. Never fires telemetry, like --version. */
|
|
4515
|
+
const stream = format === "human" ? runtime.stdout : runtime.stderr;
|
|
4516
|
+
renderHelp(this.spec, this.tree, argv, preParseColorEnabled(argv, runtime, format === "human" ? "stdout" : "stderr"), stream);
|
|
4517
|
+
return 0;
|
|
4518
|
+
}
|
|
3653
4519
|
const stricliProcess = {
|
|
3654
4520
|
/** stricli writes only help text here. In json mode stdout carries
|
|
3655
4521
|
* exactly the frame stream, so help prose goes to stderr instead. */
|
|
@@ -4014,4 +4880,4 @@ function claimedIdentity(token) {
|
|
|
4014
4880
|
};
|
|
4015
4881
|
}
|
|
4016
4882
|
//#endregion
|
|
4017
|
-
export {
|
|
4883
|
+
export { exitWithChildStatus as C, resolveGating as S, positional as T, noSessionForWorkspaceError as _, CONFIG_FILE_NAME as a, userConfigPath as b, loadConfig as c, WORKSPACE_ID_ENV_VAR as d, authServiceError as f, emptyServiceTokenError as g, credentialsRequiredError as h, buildEngine as i, PRISMA_CONFIG_VERSION as l, credentialWorkspaceMismatchError as m, claimedIdentity as n, defineConfig as o, credentialRejectedError as p, credentialWorkspaceId as r, definePrismaConfig as s, claimedExpiresAt as t, SERVICE_TOKEN_ENV_VAR as u, PRESENTED as v, flag as w, writeUserConfig as x, readUserConfig as y };
|