@prisma/cli-engine 0.6.1 → 0.6.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.
- package/dist/{engine-ChihWB8y.js → engine-BLU1DuVo.js} +280 -200
- package/dist/index.js +1 -1
- package/dist/testing.js +1 -1
- package/package.json +5 -5
|
@@ -2461,6 +2461,261 @@ function resolveSectionPath(provenance, key, path) {
|
|
|
2461
2461
|
return resolve(dirname(provenance.keys[key]), path);
|
|
2462
2462
|
}
|
|
2463
2463
|
//#endregion
|
|
2464
|
+
//#region src/execution/stricli-adapter.ts
|
|
2465
|
+
/**
|
|
2466
|
+
* The stricli boundary — fully internal: no stricli type appears in the
|
|
2467
|
+
* public surface, and stricli never owns process lifetime. Maps command
|
|
2468
|
+
* definitions onto stricli commands and captures stricli's own text so
|
|
2469
|
+
* it can be re-shaped into engine envelopes.
|
|
2470
|
+
*/
|
|
2471
|
+
function parseNumberInput(input) {
|
|
2472
|
+
if (input.trim() === "") throw new Error("expected a number, received an empty value");
|
|
2473
|
+
const value = Number(input);
|
|
2474
|
+
if (!Number.isFinite(value)) throw new Error(`expected a number, received '${input}'`);
|
|
2475
|
+
return value;
|
|
2476
|
+
}
|
|
2477
|
+
function identity(input) {
|
|
2478
|
+
return input;
|
|
2479
|
+
}
|
|
2480
|
+
function stricliFlagParameter(spec) {
|
|
2481
|
+
switch (spec.type) {
|
|
2482
|
+
case "boolean": return {
|
|
2483
|
+
kind: "boolean",
|
|
2484
|
+
brief: spec.brief,
|
|
2485
|
+
default: false
|
|
2486
|
+
};
|
|
2487
|
+
case "optionalBoolean": return {
|
|
2488
|
+
kind: "boolean",
|
|
2489
|
+
brief: spec.brief,
|
|
2490
|
+
optional: true,
|
|
2491
|
+
withNegated: true
|
|
2492
|
+
};
|
|
2493
|
+
case "enum": return {
|
|
2494
|
+
kind: "enum",
|
|
2495
|
+
brief: spec.brief,
|
|
2496
|
+
values: spec.values ?? [],
|
|
2497
|
+
...spec.default === void 0 ? { optional: true } : { default: spec.default }
|
|
2498
|
+
};
|
|
2499
|
+
case "repeated": return {
|
|
2500
|
+
kind: "parsed",
|
|
2501
|
+
parse: identity,
|
|
2502
|
+
brief: spec.brief,
|
|
2503
|
+
placeholder: spec.placeholder,
|
|
2504
|
+
variadic: true,
|
|
2505
|
+
optional: true
|
|
2506
|
+
};
|
|
2507
|
+
case "number": return {
|
|
2508
|
+
kind: "parsed",
|
|
2509
|
+
parse: parseNumberInput,
|
|
2510
|
+
brief: spec.brief,
|
|
2511
|
+
placeholder: spec.placeholder,
|
|
2512
|
+
...spec.default === void 0 ? { optional: true } : { default: String(spec.default) }
|
|
2513
|
+
};
|
|
2514
|
+
case "requiredString": return {
|
|
2515
|
+
kind: "parsed",
|
|
2516
|
+
parse: identity,
|
|
2517
|
+
brief: spec.brief,
|
|
2518
|
+
placeholder: spec.placeholder
|
|
2519
|
+
};
|
|
2520
|
+
case "string": return {
|
|
2521
|
+
kind: "parsed",
|
|
2522
|
+
parse: identity,
|
|
2523
|
+
brief: spec.brief,
|
|
2524
|
+
placeholder: spec.placeholder,
|
|
2525
|
+
...spec.default === void 0 ? { optional: true } : { default: spec.default }
|
|
2526
|
+
};
|
|
2527
|
+
}
|
|
2528
|
+
}
|
|
2529
|
+
function stricliPositional(entries) {
|
|
2530
|
+
if (entries.length === 0) return;
|
|
2531
|
+
const variadic = entries.find(([, spec]) => spec.type === "variadic");
|
|
2532
|
+
if (variadic === void 0) return {
|
|
2533
|
+
kind: "tuple",
|
|
2534
|
+
parameters: entries.map(([, spec]) => ({
|
|
2535
|
+
brief: spec.brief,
|
|
2536
|
+
placeholder: spec.placeholder,
|
|
2537
|
+
parse: identity,
|
|
2538
|
+
...spec.type === "optionalString" ? { optional: true } : {}
|
|
2539
|
+
}))
|
|
2540
|
+
};
|
|
2541
|
+
const minimum = entries.filter(([, spec]) => spec.type === "string").length;
|
|
2542
|
+
return {
|
|
2543
|
+
kind: "array",
|
|
2544
|
+
parameter: {
|
|
2545
|
+
brief: variadic[1].brief,
|
|
2546
|
+
placeholder: variadic[1].placeholder,
|
|
2547
|
+
parse: identity,
|
|
2548
|
+
optional: true
|
|
2549
|
+
},
|
|
2550
|
+
...minimum > 0 ? { minimum } : {}
|
|
2551
|
+
};
|
|
2552
|
+
}
|
|
2553
|
+
function commandParameters(def) {
|
|
2554
|
+
const declaredFlags = {};
|
|
2555
|
+
const aliases = {};
|
|
2556
|
+
for (const [key, spec] of Object.entries(def.args.flags)) {
|
|
2557
|
+
const runtime = flagRuntime(spec);
|
|
2558
|
+
declaredFlags[key] = stricliFlagParameter(runtime);
|
|
2559
|
+
if (runtime.alias !== void 0) aliases[runtime.alias] = key;
|
|
2560
|
+
}
|
|
2561
|
+
const injectShared = def.kind !== "server-command";
|
|
2562
|
+
const positional = stricliPositional(Object.entries(def.args.positionals).map(([key, spec]) => [key, positionalRuntime(spec)]));
|
|
2563
|
+
return {
|
|
2564
|
+
flags: injectShared ? {
|
|
2565
|
+
...SHARED_FLAG_PARAMETERS,
|
|
2566
|
+
...declaredFlags
|
|
2567
|
+
} : declaredFlags,
|
|
2568
|
+
aliases: injectShared ? {
|
|
2569
|
+
...SHARED_ALIASES,
|
|
2570
|
+
...aliases
|
|
2571
|
+
} : aliases,
|
|
2572
|
+
...positional === void 0 ? {} : { positional }
|
|
2573
|
+
};
|
|
2574
|
+
}
|
|
2575
|
+
/** Help examples never contain the binary name (operator ruling,
|
|
2576
|
+
* 2026-08-09): `{bin}` is substituted with the CLI name; an example
|
|
2577
|
+
* without `{bin}` gets the name prepended. A redirect's replacement is
|
|
2578
|
+
* written the same way and rendered by the same rule. */
|
|
2579
|
+
function resolveExample(example, cliName) {
|
|
2580
|
+
return example.includes("{bin}") ? substituteBinName(example, cliName) : `${cliName} ${example}`;
|
|
2581
|
+
}
|
|
2582
|
+
/** Settlement hands this values nothing has validated, so anything that
|
|
2583
|
+
* is not a string is returned as it came. */
|
|
2584
|
+
function substituteBinName(text, cliName) {
|
|
2585
|
+
return typeof text === "string" ? text.replaceAll("{bin}", cliName) : text;
|
|
2586
|
+
}
|
|
2587
|
+
function commandDocs(def, cliName) {
|
|
2588
|
+
const examples = def.help.examples.map((example) => resolveExample(example, cliName));
|
|
2589
|
+
if (examples.length === 0) return {
|
|
2590
|
+
brief: def.help.summary,
|
|
2591
|
+
fullDescription: def.help.description
|
|
2592
|
+
};
|
|
2593
|
+
return {
|
|
2594
|
+
brief: def.help.summary,
|
|
2595
|
+
fullDescription: [def.help.description ?? def.help.summary, ...examples.length === 0 ? [] : [
|
|
2596
|
+
"",
|
|
2597
|
+
"Examples:",
|
|
2598
|
+
...examples.map((example) => ` ${example}`)
|
|
2599
|
+
]].join("\n")
|
|
2600
|
+
};
|
|
2601
|
+
}
|
|
2602
|
+
function toStricliCommand(entry, cliName, runEntry) {
|
|
2603
|
+
return buildCommand({
|
|
2604
|
+
async func(flags, ...values) {
|
|
2605
|
+
await runEntry(this.invocation, entry, flags, values);
|
|
2606
|
+
},
|
|
2607
|
+
parameters: commandParameters(entry.def),
|
|
2608
|
+
docs: commandDocs(entry.def, cliName)
|
|
2609
|
+
});
|
|
2610
|
+
}
|
|
2611
|
+
function buildRoutes(spec, node, groupPath, runEntry) {
|
|
2612
|
+
const routes = {};
|
|
2613
|
+
for (const [name, entry] of node.commands) routes[name] = toStricliCommand(entry, spec.name, runEntry);
|
|
2614
|
+
for (const [name, child] of node.children) routes[name] = buildRoutes(spec, child, groupPath === "" ? name : `${groupPath} ${name}`, runEntry);
|
|
2615
|
+
return buildRouteMap({
|
|
2616
|
+
routes,
|
|
2617
|
+
docs: groupPath === "" ? { brief: spec.name } : {
|
|
2618
|
+
brief: spec.groups[groupPath].brief,
|
|
2619
|
+
fullDescription: spec.groups[groupPath].description
|
|
2620
|
+
}
|
|
2621
|
+
});
|
|
2622
|
+
}
|
|
2623
|
+
function capturingText(state) {
|
|
2624
|
+
return {
|
|
2625
|
+
...text_en,
|
|
2626
|
+
exceptionWhileParsingArguments(exc, ansiColor) {
|
|
2627
|
+
if (exc instanceof FlagNotFoundError) state.unresolvedFlagNames.push(exc.input);
|
|
2628
|
+
const message = text_en.exceptionWhileParsingArguments.call(text_en, exc, ansiColor);
|
|
2629
|
+
state.usageErrorText = message;
|
|
2630
|
+
return message;
|
|
2631
|
+
},
|
|
2632
|
+
noCommandRegisteredForInput(args) {
|
|
2633
|
+
const message = text_en.noCommandRegisteredForInput(args);
|
|
2634
|
+
state.usageErrorText = message;
|
|
2635
|
+
return message;
|
|
2636
|
+
},
|
|
2637
|
+
exceptionWhileLoadingCommandFunction(exc, ansiColor) {
|
|
2638
|
+
const message = text_en.exceptionWhileLoadingCommandFunction.call(text_en, exc, ansiColor);
|
|
2639
|
+
state.internalErrorText = message;
|
|
2640
|
+
return message;
|
|
2641
|
+
},
|
|
2642
|
+
exceptionWhileRunningCommand(exc, ansiColor) {
|
|
2643
|
+
const message = text_en.exceptionWhileRunningCommand.call(text_en, exc, ansiColor);
|
|
2644
|
+
state.internalErrorText = message;
|
|
2645
|
+
return message;
|
|
2646
|
+
}
|
|
2647
|
+
};
|
|
2648
|
+
}
|
|
2649
|
+
function usageErrorCode(stricliExitCode) {
|
|
2650
|
+
if (stricliExitCode === -5) return "CLI.UNKNOWN_COMMAND";
|
|
2651
|
+
if (stricliExitCode === -4) return "CLI.INVALID_ARGUMENTS";
|
|
2652
|
+
}
|
|
2653
|
+
//#endregion
|
|
2654
|
+
//#region src/execution/bin-name.ts
|
|
2655
|
+
function isRecord(value) {
|
|
2656
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2657
|
+
}
|
|
2658
|
+
function inText(text, cliName) {
|
|
2659
|
+
if (!Array.isArray(text)) return substituteBinName(text, cliName);
|
|
2660
|
+
return text.map((span) => isRecord(span) ? {
|
|
2661
|
+
...span,
|
|
2662
|
+
text: substituteBinName(span.text, cliName)
|
|
2663
|
+
} : span);
|
|
2664
|
+
}
|
|
2665
|
+
function inBlock(block, cliName) {
|
|
2666
|
+
switch (block.kind) {
|
|
2667
|
+
case "summary": return {
|
|
2668
|
+
...block,
|
|
2669
|
+
text: inText(block.text, cliName)
|
|
2670
|
+
};
|
|
2671
|
+
case "list": return {
|
|
2672
|
+
...block,
|
|
2673
|
+
items: block.items.map((item) => inText(item, cliName))
|
|
2674
|
+
};
|
|
2675
|
+
case "fields":
|
|
2676
|
+
case "table":
|
|
2677
|
+
case "tree":
|
|
2678
|
+
case "drawing": return block;
|
|
2679
|
+
}
|
|
2680
|
+
}
|
|
2681
|
+
function nextActionWithBinName(action, cliName) {
|
|
2682
|
+
if (!isRecord(action)) return action;
|
|
2683
|
+
return {
|
|
2684
|
+
...action,
|
|
2685
|
+
...action.label === void 0 ? {} : { label: substituteBinName(action.label, cliName) },
|
|
2686
|
+
...action.reason === void 0 ? {} : { reason: substituteBinName(action.reason, cliName) },
|
|
2687
|
+
...action.command === void 0 ? {} : { command: substituteBinName(action.command, cliName) },
|
|
2688
|
+
...Array.isArray(action.commands) ? { commands: action.commands.map((command) => substituteBinName(command, cliName)) } : {}
|
|
2689
|
+
};
|
|
2690
|
+
}
|
|
2691
|
+
function nextActionsWithBinName(actions, cliName) {
|
|
2692
|
+
return Array.isArray(actions) ? actions.map((action) => nextActionWithBinName(action, cliName)) : actions;
|
|
2693
|
+
}
|
|
2694
|
+
function diagnosticWithBinName(diagnostic, cliName) {
|
|
2695
|
+
if (!isRecord(diagnostic)) return diagnostic;
|
|
2696
|
+
return {
|
|
2697
|
+
...diagnostic,
|
|
2698
|
+
...diagnostic.summary === void 0 ? {} : { summary: substituteBinName(diagnostic.summary, cliName) },
|
|
2699
|
+
...diagnostic.why === void 0 ? {} : { why: substituteBinName(diagnostic.why, cliName) },
|
|
2700
|
+
...diagnostic.nextActions === void 0 ? {} : { nextActions: nextActionsWithBinName(diagnostic.nextActions, cliName) }
|
|
2701
|
+
};
|
|
2702
|
+
}
|
|
2703
|
+
/** Only summary and list blocks are rewritten. Every other block, the
|
|
2704
|
+
* data, the json result and the stdout lines can hold user data and
|
|
2705
|
+
* pass through unchanged. */
|
|
2706
|
+
function presentedWithBinName(presented, cliName) {
|
|
2707
|
+
return {
|
|
2708
|
+
...presented,
|
|
2709
|
+
[PRESENTED]: true,
|
|
2710
|
+
diagnostics: presented.diagnostics.map((diagnostic) => diagnosticWithBinName(diagnostic, cliName)),
|
|
2711
|
+
presentation: {
|
|
2712
|
+
...presented.presentation,
|
|
2713
|
+
human: presented.presentation.human.map((block) => inBlock(block, cliName)),
|
|
2714
|
+
next: nextActionsWithBinName(presented.presentation.next, cliName)
|
|
2715
|
+
}
|
|
2716
|
+
};
|
|
2717
|
+
}
|
|
2718
|
+
//#endregion
|
|
2464
2719
|
//#region src/execution/palette.ts
|
|
2465
2720
|
/**
|
|
2466
2721
|
* Tones into bytes, and text into a display width. Basic 16-colour SGR
|
|
@@ -2719,9 +2974,15 @@ function writeDiagnostic(stream, diagnostic, paint = PLAIN) {
|
|
|
2719
2974
|
const code = paint("muted", `[${diagnostic.code}]`);
|
|
2720
2975
|
stream.write(`${glyph} ${code} ${diagnostic.summary}\n`);
|
|
2721
2976
|
if (diagnostic.why !== void 0) stream.write(` ${paint("muted", `why: ${diagnostic.why}`)}\n`);
|
|
2722
|
-
for (const action of diagnostic.nextActions) stream.write(`${renderNextAction(action, paint)}\n`);
|
|
2977
|
+
for (const action of renderableNextActions(diagnostic.nextActions)) stream.write(`${renderNextAction(action, paint)}\n`);
|
|
2723
2978
|
if (diagnostic.docsUrl !== void 0) stream.write(` ${paint("muted", "docs:")} ${paint("link", diagnostic.docsUrl)}\n`);
|
|
2724
2979
|
}
|
|
2980
|
+
/** A diagnostic reaches the renderers unvalidated: a list that is
|
|
2981
|
+
* missing renders as no next actions, and an entry that is not an
|
|
2982
|
+
* object is skipped. */
|
|
2983
|
+
function renderableNextActions(actions) {
|
|
2984
|
+
return Array.isArray(actions) ? actions.filter((action) => typeof action === "object" && action !== null && !Array.isArray(action)) : [];
|
|
2985
|
+
}
|
|
2725
2986
|
/** `label` is required, so a mapper building an action out of a bare
|
|
2726
2987
|
* command string — a legacy error's follow-up step, with no prose
|
|
2727
2988
|
* beside it — has nothing to put in the label but the command itself.
|
|
@@ -2802,7 +3063,8 @@ function longestBacktickRun(text) {
|
|
|
2802
3063
|
}
|
|
2803
3064
|
/** An inline code span whose delimiter is one backtick longer than any
|
|
2804
3065
|
* run inside it, padded when the content starts or ends with one. */
|
|
2805
|
-
function codeSpan(
|
|
3066
|
+
function codeSpan(value) {
|
|
3067
|
+
const text = String(value);
|
|
2806
3068
|
const delimiter = "`".repeat(longestBacktickRun(text) + 1);
|
|
2807
3069
|
return `${delimiter}${text.startsWith("`") || text.endsWith("`") ? ` ${text} ` : text}${delimiter}`;
|
|
2808
3070
|
}
|
|
@@ -2859,7 +3121,7 @@ function renderTreeNode(node, depth) {
|
|
|
2859
3121
|
}
|
|
2860
3122
|
function renderNextActionMarkdown(action) {
|
|
2861
3123
|
const target = action.command ?? action.url;
|
|
2862
|
-
if (target === void 0 && action.commands
|
|
3124
|
+
if (target === void 0 && Array.isArray(action.commands)) return [`- ${action.label}`, ...action.commands.map((command) => ` - ${codeSpan(command)}`)];
|
|
2863
3125
|
if (target === void 0 || target === action.label) return [action.command !== void 0 ? `- ${codeSpan(action.label)}` : `- ${action.label}`];
|
|
2864
3126
|
return [action.command !== void 0 ? `- ${action.label}: ${codeSpan(target)}` : `- ${action.label}: ${target}`];
|
|
2865
3127
|
}
|
|
@@ -2874,7 +3136,7 @@ function renderDiagnosticMarkdown(diagnostic) {
|
|
|
2874
3136
|
if (diagnostic.why !== void 0) lines.push(`why: ${diagnostic.why}`);
|
|
2875
3137
|
const where = whereLine(diagnostic.where);
|
|
2876
3138
|
if (where !== void 0) lines.push(where);
|
|
2877
|
-
for (const action of diagnostic.nextActions) lines.push(...renderNextActionMarkdown(action));
|
|
3139
|
+
for (const action of renderableNextActions(diagnostic.nextActions)) lines.push(...renderNextActionMarkdown(action));
|
|
2878
3140
|
if (diagnostic.docsUrl !== void 0) lines.push(`docs: ${diagnostic.docsUrl}`);
|
|
2879
3141
|
return lines;
|
|
2880
3142
|
}
|
|
@@ -3239,7 +3501,7 @@ function sectionInvalidError(name, contributors, files) {
|
|
|
3239
3501
|
* or the envelope. */
|
|
3240
3502
|
function writeSectionWarnings(invocation, diagnostics) {
|
|
3241
3503
|
const state = invocation.state;
|
|
3242
|
-
const shown = diagnostics.filter((diagnostic) => SEVERITY_RANK[diagnostic.severity] <= SEVERITY_RANK[state.logLevel]).map((diagnostic) => withDocsUrl(state, diagnostic));
|
|
3504
|
+
const shown = diagnostics.filter((diagnostic) => SEVERITY_RANK[diagnostic.severity] <= SEVERITY_RANK[state.logLevel]).map((diagnostic) => withDocsUrl(state, diagnosticWithBinName(diagnostic, invocation.cliName)));
|
|
3243
3505
|
if (state.format === "markdown") {
|
|
3244
3506
|
renderWarningsMarkdown(invocation, shown);
|
|
3245
3507
|
return;
|
|
@@ -4290,191 +4552,6 @@ function buildCommandSnapshot(entryId, def, argv, positionalValues) {
|
|
|
4290
4552
|
};
|
|
4291
4553
|
}
|
|
4292
4554
|
//#endregion
|
|
4293
|
-
//#region src/execution/stricli-adapter.ts
|
|
4294
|
-
/**
|
|
4295
|
-
* The stricli boundary — fully internal: no stricli type appears in the
|
|
4296
|
-
* public surface, and stricli never owns process lifetime. Maps command
|
|
4297
|
-
* definitions onto stricli commands and captures stricli's own text so
|
|
4298
|
-
* it can be re-shaped into engine envelopes.
|
|
4299
|
-
*/
|
|
4300
|
-
function parseNumberInput(input) {
|
|
4301
|
-
if (input.trim() === "") throw new Error("expected a number, received an empty value");
|
|
4302
|
-
const value = Number(input);
|
|
4303
|
-
if (!Number.isFinite(value)) throw new Error(`expected a number, received '${input}'`);
|
|
4304
|
-
return value;
|
|
4305
|
-
}
|
|
4306
|
-
function identity(input) {
|
|
4307
|
-
return input;
|
|
4308
|
-
}
|
|
4309
|
-
function stricliFlagParameter(spec) {
|
|
4310
|
-
switch (spec.type) {
|
|
4311
|
-
case "boolean": return {
|
|
4312
|
-
kind: "boolean",
|
|
4313
|
-
brief: spec.brief,
|
|
4314
|
-
default: false
|
|
4315
|
-
};
|
|
4316
|
-
case "optionalBoolean": return {
|
|
4317
|
-
kind: "boolean",
|
|
4318
|
-
brief: spec.brief,
|
|
4319
|
-
optional: true,
|
|
4320
|
-
withNegated: true
|
|
4321
|
-
};
|
|
4322
|
-
case "enum": return {
|
|
4323
|
-
kind: "enum",
|
|
4324
|
-
brief: spec.brief,
|
|
4325
|
-
values: spec.values ?? [],
|
|
4326
|
-
...spec.default === void 0 ? { optional: true } : { default: spec.default }
|
|
4327
|
-
};
|
|
4328
|
-
case "repeated": return {
|
|
4329
|
-
kind: "parsed",
|
|
4330
|
-
parse: identity,
|
|
4331
|
-
brief: spec.brief,
|
|
4332
|
-
placeholder: spec.placeholder,
|
|
4333
|
-
variadic: true,
|
|
4334
|
-
optional: true
|
|
4335
|
-
};
|
|
4336
|
-
case "number": return {
|
|
4337
|
-
kind: "parsed",
|
|
4338
|
-
parse: parseNumberInput,
|
|
4339
|
-
brief: spec.brief,
|
|
4340
|
-
placeholder: spec.placeholder,
|
|
4341
|
-
...spec.default === void 0 ? { optional: true } : { default: String(spec.default) }
|
|
4342
|
-
};
|
|
4343
|
-
case "requiredString": return {
|
|
4344
|
-
kind: "parsed",
|
|
4345
|
-
parse: identity,
|
|
4346
|
-
brief: spec.brief,
|
|
4347
|
-
placeholder: spec.placeholder
|
|
4348
|
-
};
|
|
4349
|
-
case "string": return {
|
|
4350
|
-
kind: "parsed",
|
|
4351
|
-
parse: identity,
|
|
4352
|
-
brief: spec.brief,
|
|
4353
|
-
placeholder: spec.placeholder,
|
|
4354
|
-
...spec.default === void 0 ? { optional: true } : { default: spec.default }
|
|
4355
|
-
};
|
|
4356
|
-
}
|
|
4357
|
-
}
|
|
4358
|
-
function stricliPositional(entries) {
|
|
4359
|
-
if (entries.length === 0) return;
|
|
4360
|
-
const variadic = entries.find(([, spec]) => spec.type === "variadic");
|
|
4361
|
-
if (variadic === void 0) return {
|
|
4362
|
-
kind: "tuple",
|
|
4363
|
-
parameters: entries.map(([, spec]) => ({
|
|
4364
|
-
brief: spec.brief,
|
|
4365
|
-
placeholder: spec.placeholder,
|
|
4366
|
-
parse: identity,
|
|
4367
|
-
...spec.type === "optionalString" ? { optional: true } : {}
|
|
4368
|
-
}))
|
|
4369
|
-
};
|
|
4370
|
-
const minimum = entries.filter(([, spec]) => spec.type === "string").length;
|
|
4371
|
-
return {
|
|
4372
|
-
kind: "array",
|
|
4373
|
-
parameter: {
|
|
4374
|
-
brief: variadic[1].brief,
|
|
4375
|
-
placeholder: variadic[1].placeholder,
|
|
4376
|
-
parse: identity,
|
|
4377
|
-
optional: true
|
|
4378
|
-
},
|
|
4379
|
-
...minimum > 0 ? { minimum } : {}
|
|
4380
|
-
};
|
|
4381
|
-
}
|
|
4382
|
-
function commandParameters(def) {
|
|
4383
|
-
const declaredFlags = {};
|
|
4384
|
-
const aliases = {};
|
|
4385
|
-
for (const [key, spec] of Object.entries(def.args.flags)) {
|
|
4386
|
-
const runtime = flagRuntime(spec);
|
|
4387
|
-
declaredFlags[key] = stricliFlagParameter(runtime);
|
|
4388
|
-
if (runtime.alias !== void 0) aliases[runtime.alias] = key;
|
|
4389
|
-
}
|
|
4390
|
-
const injectShared = def.kind !== "server-command";
|
|
4391
|
-
const positional = stricliPositional(Object.entries(def.args.positionals).map(([key, spec]) => [key, positionalRuntime(spec)]));
|
|
4392
|
-
return {
|
|
4393
|
-
flags: injectShared ? {
|
|
4394
|
-
...SHARED_FLAG_PARAMETERS,
|
|
4395
|
-
...declaredFlags
|
|
4396
|
-
} : declaredFlags,
|
|
4397
|
-
aliases: injectShared ? {
|
|
4398
|
-
...SHARED_ALIASES,
|
|
4399
|
-
...aliases
|
|
4400
|
-
} : aliases,
|
|
4401
|
-
...positional === void 0 ? {} : { positional }
|
|
4402
|
-
};
|
|
4403
|
-
}
|
|
4404
|
-
/** Help examples never contain the binary name (operator ruling,
|
|
4405
|
-
* 2026-08-09): `{bin}` is substituted with the CLI name; an example
|
|
4406
|
-
* without `{bin}` gets the name prepended. A redirect's replacement is
|
|
4407
|
-
* written the same way and rendered by the same rule. */
|
|
4408
|
-
function resolveExample(example, cliName) {
|
|
4409
|
-
return example.includes("{bin}") ? example.replaceAll("{bin}", cliName) : `${cliName} ${example}`;
|
|
4410
|
-
}
|
|
4411
|
-
function commandDocs(def, cliName) {
|
|
4412
|
-
const examples = def.help.examples.map((example) => resolveExample(example, cliName));
|
|
4413
|
-
if (examples.length === 0) return {
|
|
4414
|
-
brief: def.help.summary,
|
|
4415
|
-
fullDescription: def.help.description
|
|
4416
|
-
};
|
|
4417
|
-
return {
|
|
4418
|
-
brief: def.help.summary,
|
|
4419
|
-
fullDescription: [def.help.description ?? def.help.summary, ...examples.length === 0 ? [] : [
|
|
4420
|
-
"",
|
|
4421
|
-
"Examples:",
|
|
4422
|
-
...examples.map((example) => ` ${example}`)
|
|
4423
|
-
]].join("\n")
|
|
4424
|
-
};
|
|
4425
|
-
}
|
|
4426
|
-
function toStricliCommand(entry, cliName, runEntry) {
|
|
4427
|
-
return buildCommand({
|
|
4428
|
-
async func(flags, ...values) {
|
|
4429
|
-
await runEntry(this.invocation, entry, flags, values);
|
|
4430
|
-
},
|
|
4431
|
-
parameters: commandParameters(entry.def),
|
|
4432
|
-
docs: commandDocs(entry.def, cliName)
|
|
4433
|
-
});
|
|
4434
|
-
}
|
|
4435
|
-
function buildRoutes(spec, node, groupPath, runEntry) {
|
|
4436
|
-
const routes = {};
|
|
4437
|
-
for (const [name, entry] of node.commands) routes[name] = toStricliCommand(entry, spec.name, runEntry);
|
|
4438
|
-
for (const [name, child] of node.children) routes[name] = buildRoutes(spec, child, groupPath === "" ? name : `${groupPath} ${name}`, runEntry);
|
|
4439
|
-
return buildRouteMap({
|
|
4440
|
-
routes,
|
|
4441
|
-
docs: groupPath === "" ? { brief: spec.name } : {
|
|
4442
|
-
brief: spec.groups[groupPath].brief,
|
|
4443
|
-
fullDescription: spec.groups[groupPath].description
|
|
4444
|
-
}
|
|
4445
|
-
});
|
|
4446
|
-
}
|
|
4447
|
-
function capturingText(state) {
|
|
4448
|
-
return {
|
|
4449
|
-
...text_en,
|
|
4450
|
-
exceptionWhileParsingArguments(exc, ansiColor) {
|
|
4451
|
-
if (exc instanceof FlagNotFoundError) state.unresolvedFlagNames.push(exc.input);
|
|
4452
|
-
const message = text_en.exceptionWhileParsingArguments.call(text_en, exc, ansiColor);
|
|
4453
|
-
state.usageErrorText = message;
|
|
4454
|
-
return message;
|
|
4455
|
-
},
|
|
4456
|
-
noCommandRegisteredForInput(args) {
|
|
4457
|
-
const message = text_en.noCommandRegisteredForInput(args);
|
|
4458
|
-
state.usageErrorText = message;
|
|
4459
|
-
return message;
|
|
4460
|
-
},
|
|
4461
|
-
exceptionWhileLoadingCommandFunction(exc, ansiColor) {
|
|
4462
|
-
const message = text_en.exceptionWhileLoadingCommandFunction.call(text_en, exc, ansiColor);
|
|
4463
|
-
state.internalErrorText = message;
|
|
4464
|
-
return message;
|
|
4465
|
-
},
|
|
4466
|
-
exceptionWhileRunningCommand(exc, ansiColor) {
|
|
4467
|
-
const message = text_en.exceptionWhileRunningCommand.call(text_en, exc, ansiColor);
|
|
4468
|
-
state.internalErrorText = message;
|
|
4469
|
-
return message;
|
|
4470
|
-
}
|
|
4471
|
-
};
|
|
4472
|
-
}
|
|
4473
|
-
function usageErrorCode(stricliExitCode) {
|
|
4474
|
-
if (stricliExitCode === -5) return "CLI.UNKNOWN_COMMAND";
|
|
4475
|
-
if (stricliExitCode === -4) return "CLI.INVALID_ARGUMENTS";
|
|
4476
|
-
}
|
|
4477
|
-
//#endregion
|
|
4478
4555
|
//#region src/execution/help.ts
|
|
4479
4556
|
/**
|
|
4480
4557
|
* Engine-rendered help: the command tree drawn with the same tones the
|
|
@@ -4835,16 +4912,17 @@ function undocumentedExitCode(def, exitCode) {
|
|
|
4835
4912
|
if ((def.kind === "result-command" ? Object.keys(def.exitCodes).map(Number) : []).includes(exitCode)) return;
|
|
4836
4913
|
return /* @__PURE__ */ new Error(`@prisma/cli-engine: the handler completed with exit code ${exitCode}, which is not 0 or one of the command's documented exit codes`);
|
|
4837
4914
|
}
|
|
4838
|
-
function settleCompleted(invocation, def,
|
|
4839
|
-
if (typeof
|
|
4915
|
+
function settleCompleted(invocation, def, returned) {
|
|
4916
|
+
if (typeof returned !== "object" || returned === null || returned[PRESENTED] !== true) {
|
|
4840
4917
|
settleBug(invocation, /* @__PURE__ */ new Error("@prisma/cli-engine: a handler returned ok(...) without a PresentedResult built by ctx.present"));
|
|
4841
4918
|
return;
|
|
4842
4919
|
}
|
|
4843
|
-
const violation = undocumentedExitCode(def,
|
|
4920
|
+
const violation = undocumentedExitCode(def, returned.exitCode);
|
|
4844
4921
|
if (violation !== void 0) {
|
|
4845
4922
|
settleBug(invocation, violation);
|
|
4846
4923
|
return;
|
|
4847
4924
|
}
|
|
4925
|
+
const presented = presentedWithBinName(returned, invocation.cliName);
|
|
4848
4926
|
const state = invocation.state;
|
|
4849
4927
|
invocation.hooks.onPresented?.(presented);
|
|
4850
4928
|
const exitCode = runExitCode(invocation, presented.exitCode);
|
|
@@ -4890,9 +4968,9 @@ function settleErrored(invocation, error, diagnostics = []) {
|
|
|
4890
4968
|
emitErrored(invocation, {
|
|
4891
4969
|
ok: false,
|
|
4892
4970
|
commandId: state.commandId,
|
|
4893
|
-
error: diagnosticOf(error),
|
|
4894
|
-
diagnostics: accompanyingFindings(diagnostics),
|
|
4895
|
-
nextActions: error.nextActions
|
|
4971
|
+
error: diagnosticWithBinName(diagnosticOf(error), invocation.cliName),
|
|
4972
|
+
diagnostics: accompanyingFindings(diagnostics).map((diagnostic) => diagnosticWithBinName(diagnostic, invocation.cliName)),
|
|
4973
|
+
nextActions: nextActionsWithBinName(error.nextActions, invocation.cliName)
|
|
4896
4974
|
});
|
|
4897
4975
|
}
|
|
4898
4976
|
/** The conventional code for a delivered signal: 128 + its number, so
|
|
@@ -4974,11 +5052,12 @@ function settleChildStatus(invocation, def, settlement) {
|
|
|
4974
5052
|
const child = invocation.state.lastChild;
|
|
4975
5053
|
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`);
|
|
4976
5054
|
const exitCode = childExitCode(child);
|
|
5055
|
+
const nextActions = nextActionsWithBinName(settlement.nextActions, invocation.cliName);
|
|
4977
5056
|
if (invocation.state.format === "json") {
|
|
4978
|
-
settleStructuredChildStatus(invocation,
|
|
5057
|
+
settleStructuredChildStatus(invocation, nextActions, child, exitCode);
|
|
4979
5058
|
return;
|
|
4980
5059
|
}
|
|
4981
|
-
if (child.signal === null) renderChildNextActions(invocation,
|
|
5060
|
+
if (child.signal === null) renderChildNextActions(invocation, nextActions);
|
|
4982
5061
|
settleVerbatimExitCode(invocation, exitCode);
|
|
4983
5062
|
}
|
|
4984
5063
|
function renderChildNextActions(invocation, actions) {
|
|
@@ -4989,9 +5068,9 @@ function renderChildNextActions(invocation, actions) {
|
|
|
4989
5068
|
const paint = makePaint(invocation.state.colorEnabled);
|
|
4990
5069
|
for (const action of actions) invocation.runtime.stderr.write(`${renderNextAction(action, paint)}\n`);
|
|
4991
5070
|
}
|
|
4992
|
-
function settleStructuredChildStatus(invocation,
|
|
5071
|
+
function settleStructuredChildStatus(invocation, actions, child, exitCode) {
|
|
4993
5072
|
settleVerbatimExitCode(invocation, exitCode);
|
|
4994
|
-
const nextActions = child.signal === null ?
|
|
5073
|
+
const nextActions = child.signal === null ? actions : [];
|
|
4995
5074
|
if (exitCode === 0) {
|
|
4996
5075
|
emitFrame(invocation, {
|
|
4997
5076
|
kind: "result",
|
|
@@ -5319,6 +5398,7 @@ var EngineImpl = class {
|
|
|
5319
5398
|
};
|
|
5320
5399
|
const unsubscribe = runtime.onSignal(deliverSignal);
|
|
5321
5400
|
const invocation = {
|
|
5401
|
+
cliName: this.spec.name,
|
|
5322
5402
|
runtime,
|
|
5323
5403
|
hooks: { ...hooks },
|
|
5324
5404
|
now: this.now,
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as ok, r as notOk, t as CliStructuredError } from "./protocol-TtNVkeVS.js";
|
|
2
|
-
import { C as credentialWorkspaceId, D as credentialsRequiredError, E as credentialWorkspaceMismatchError, O as emptyServiceTokenError, S as claimedIdentity, T as credentialRejectedError, _ as detectCI, a as definePrismaConfig, b as readActiveAccessToken, c as PRISMA_CONFIG_VERSION, d as PRESENTED, f as readUserConfig, g as exitWithChildStatus, h as resolveGating, k as noSessionForWorkspaceError, l as SERVICE_TOKEN_ENV_VAR, m as writeUserConfig, n as resolveSectionOverChain, o as loadConfig, p as userConfigPath, r as resolveSectionPath, s as realpathOr, t as buildEngine, u as WORKSPACE_ID_ENV_VAR, v as flag, w as authServiceError, x as claimedExpiresAt, y as positional } from "./engine-
|
|
2
|
+
import { C as credentialWorkspaceId, D as credentialsRequiredError, E as credentialWorkspaceMismatchError, O as emptyServiceTokenError, S as claimedIdentity, T as credentialRejectedError, _ as detectCI, a as definePrismaConfig, b as readActiveAccessToken, c as PRISMA_CONFIG_VERSION, d as PRESENTED, f as readUserConfig, g as exitWithChildStatus, h as resolveGating, k as noSessionForWorkspaceError, l as SERVICE_TOKEN_ENV_VAR, m as writeUserConfig, n as resolveSectionOverChain, o as loadConfig, p as userConfigPath, r as resolveSectionPath, s as realpathOr, t as buildEngine, u as WORKSPACE_ID_ENV_VAR, v as flag, w as authServiceError, x as claimedExpiresAt, y as positional } from "./engine-BLU1DuVo.js";
|
|
3
3
|
import { dirname, isAbsolute, resolve } from "node:path";
|
|
4
4
|
import { scope, type } from "arktype";
|
|
5
5
|
//#region src/cli.ts
|
package/dist/testing.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as credentialWorkspaceId, D as credentialsRequiredError, E as credentialWorkspaceMismatchError, S as claimedIdentity, b as readActiveAccessToken, k as noSessionForWorkspaceError, t as buildEngine, x as claimedExpiresAt } from "./engine-
|
|
1
|
+
import { C as credentialWorkspaceId, D as credentialsRequiredError, E as credentialWorkspaceMismatchError, S as claimedIdentity, b as readActiveAccessToken, k as noSessionForWorkspaceError, t as buildEngine, x as claimedExpiresAt } from "./engine-BLU1DuVo.js";
|
|
2
2
|
import { Buffer } from "node:buffer";
|
|
3
3
|
import { resolve } from "node:path";
|
|
4
4
|
//#region src/in-memory-credential-manager.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma/cli-engine",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"description": "The execution engine of the unified Prisma CLI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@clack/prompts": "1.5.0",
|
|
44
44
|
"@stricli/core": "1.3.0",
|
|
45
|
-
"arktype": "2.2.
|
|
45
|
+
"arktype": "^2.2.7",
|
|
46
46
|
"c12": "3.3.4",
|
|
47
47
|
"colorette": "^2.0.20",
|
|
48
48
|
"package-manager-detector": "1.8.0",
|
|
@@ -52,9 +52,9 @@
|
|
|
52
52
|
"@prisma/management-api-sdk": "^1.55.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@prisma/management-api-sdk": "1.
|
|
56
|
-
"@repo/cli-conformance": "8.0.0-rc.
|
|
57
|
-
"@repo/tsconfig": "8.0.0-rc.
|
|
55
|
+
"@prisma/management-api-sdk": "1.80.0",
|
|
56
|
+
"@repo/cli-conformance": "8.0.0-rc.20",
|
|
57
|
+
"@repo/tsconfig": "8.0.0-rc.20",
|
|
58
58
|
"@types/node": "^22.19.19",
|
|
59
59
|
"ci-info": "^4.3.1",
|
|
60
60
|
"tsdown": "^0.21.10",
|