@prisma/cli-engine 0.6.0 → 0.6.2
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.
|
@@ -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;
|
|
@@ -3829,10 +4091,8 @@ function makePromptSurface(invocation) {
|
|
|
3829
4091
|
},
|
|
3830
4092
|
consent: async (question, opts) => {
|
|
3831
4093
|
const token = opts?.token;
|
|
3832
|
-
if (
|
|
3833
|
-
|
|
3834
|
-
throw consentUnavailable(question, state, token);
|
|
3835
|
-
}
|
|
4094
|
+
if (token !== void 0 && consumeConfirmValue(state, token)) return true;
|
|
4095
|
+
if (state.yes || !state.interactive) throw consentUnavailable(question, state, token);
|
|
3836
4096
|
if (token !== void 0) return confirmByTyping(question, token);
|
|
3837
4097
|
if (useClack()) return renderWithClack(question, (r) => r.consent(question));
|
|
3838
4098
|
return isExplicitYes(await ask(question, `? ${question} (y/n) `));
|
|
@@ -4292,191 +4552,6 @@ function buildCommandSnapshot(entryId, def, argv, positionalValues) {
|
|
|
4292
4552
|
};
|
|
4293
4553
|
}
|
|
4294
4554
|
//#endregion
|
|
4295
|
-
//#region src/execution/stricli-adapter.ts
|
|
4296
|
-
/**
|
|
4297
|
-
* The stricli boundary — fully internal: no stricli type appears in the
|
|
4298
|
-
* public surface, and stricli never owns process lifetime. Maps command
|
|
4299
|
-
* definitions onto stricli commands and captures stricli's own text so
|
|
4300
|
-
* it can be re-shaped into engine envelopes.
|
|
4301
|
-
*/
|
|
4302
|
-
function parseNumberInput(input) {
|
|
4303
|
-
if (input.trim() === "") throw new Error("expected a number, received an empty value");
|
|
4304
|
-
const value = Number(input);
|
|
4305
|
-
if (!Number.isFinite(value)) throw new Error(`expected a number, received '${input}'`);
|
|
4306
|
-
return value;
|
|
4307
|
-
}
|
|
4308
|
-
function identity(input) {
|
|
4309
|
-
return input;
|
|
4310
|
-
}
|
|
4311
|
-
function stricliFlagParameter(spec) {
|
|
4312
|
-
switch (spec.type) {
|
|
4313
|
-
case "boolean": return {
|
|
4314
|
-
kind: "boolean",
|
|
4315
|
-
brief: spec.brief,
|
|
4316
|
-
default: false
|
|
4317
|
-
};
|
|
4318
|
-
case "optionalBoolean": return {
|
|
4319
|
-
kind: "boolean",
|
|
4320
|
-
brief: spec.brief,
|
|
4321
|
-
optional: true,
|
|
4322
|
-
withNegated: true
|
|
4323
|
-
};
|
|
4324
|
-
case "enum": return {
|
|
4325
|
-
kind: "enum",
|
|
4326
|
-
brief: spec.brief,
|
|
4327
|
-
values: spec.values ?? [],
|
|
4328
|
-
...spec.default === void 0 ? { optional: true } : { default: spec.default }
|
|
4329
|
-
};
|
|
4330
|
-
case "repeated": return {
|
|
4331
|
-
kind: "parsed",
|
|
4332
|
-
parse: identity,
|
|
4333
|
-
brief: spec.brief,
|
|
4334
|
-
placeholder: spec.placeholder,
|
|
4335
|
-
variadic: true,
|
|
4336
|
-
optional: true
|
|
4337
|
-
};
|
|
4338
|
-
case "number": return {
|
|
4339
|
-
kind: "parsed",
|
|
4340
|
-
parse: parseNumberInput,
|
|
4341
|
-
brief: spec.brief,
|
|
4342
|
-
placeholder: spec.placeholder,
|
|
4343
|
-
...spec.default === void 0 ? { optional: true } : { default: String(spec.default) }
|
|
4344
|
-
};
|
|
4345
|
-
case "requiredString": return {
|
|
4346
|
-
kind: "parsed",
|
|
4347
|
-
parse: identity,
|
|
4348
|
-
brief: spec.brief,
|
|
4349
|
-
placeholder: spec.placeholder
|
|
4350
|
-
};
|
|
4351
|
-
case "string": return {
|
|
4352
|
-
kind: "parsed",
|
|
4353
|
-
parse: identity,
|
|
4354
|
-
brief: spec.brief,
|
|
4355
|
-
placeholder: spec.placeholder,
|
|
4356
|
-
...spec.default === void 0 ? { optional: true } : { default: spec.default }
|
|
4357
|
-
};
|
|
4358
|
-
}
|
|
4359
|
-
}
|
|
4360
|
-
function stricliPositional(entries) {
|
|
4361
|
-
if (entries.length === 0) return;
|
|
4362
|
-
const variadic = entries.find(([, spec]) => spec.type === "variadic");
|
|
4363
|
-
if (variadic === void 0) return {
|
|
4364
|
-
kind: "tuple",
|
|
4365
|
-
parameters: entries.map(([, spec]) => ({
|
|
4366
|
-
brief: spec.brief,
|
|
4367
|
-
placeholder: spec.placeholder,
|
|
4368
|
-
parse: identity,
|
|
4369
|
-
...spec.type === "optionalString" ? { optional: true } : {}
|
|
4370
|
-
}))
|
|
4371
|
-
};
|
|
4372
|
-
const minimum = entries.filter(([, spec]) => spec.type === "string").length;
|
|
4373
|
-
return {
|
|
4374
|
-
kind: "array",
|
|
4375
|
-
parameter: {
|
|
4376
|
-
brief: variadic[1].brief,
|
|
4377
|
-
placeholder: variadic[1].placeholder,
|
|
4378
|
-
parse: identity,
|
|
4379
|
-
optional: true
|
|
4380
|
-
},
|
|
4381
|
-
...minimum > 0 ? { minimum } : {}
|
|
4382
|
-
};
|
|
4383
|
-
}
|
|
4384
|
-
function commandParameters(def) {
|
|
4385
|
-
const declaredFlags = {};
|
|
4386
|
-
const aliases = {};
|
|
4387
|
-
for (const [key, spec] of Object.entries(def.args.flags)) {
|
|
4388
|
-
const runtime = flagRuntime(spec);
|
|
4389
|
-
declaredFlags[key] = stricliFlagParameter(runtime);
|
|
4390
|
-
if (runtime.alias !== void 0) aliases[runtime.alias] = key;
|
|
4391
|
-
}
|
|
4392
|
-
const injectShared = def.kind !== "server-command";
|
|
4393
|
-
const positional = stricliPositional(Object.entries(def.args.positionals).map(([key, spec]) => [key, positionalRuntime(spec)]));
|
|
4394
|
-
return {
|
|
4395
|
-
flags: injectShared ? {
|
|
4396
|
-
...SHARED_FLAG_PARAMETERS,
|
|
4397
|
-
...declaredFlags
|
|
4398
|
-
} : declaredFlags,
|
|
4399
|
-
aliases: injectShared ? {
|
|
4400
|
-
...SHARED_ALIASES,
|
|
4401
|
-
...aliases
|
|
4402
|
-
} : aliases,
|
|
4403
|
-
...positional === void 0 ? {} : { positional }
|
|
4404
|
-
};
|
|
4405
|
-
}
|
|
4406
|
-
/** Help examples never contain the binary name (operator ruling,
|
|
4407
|
-
* 2026-08-09): `{bin}` is substituted with the CLI name; an example
|
|
4408
|
-
* without `{bin}` gets the name prepended. A redirect's replacement is
|
|
4409
|
-
* written the same way and rendered by the same rule. */
|
|
4410
|
-
function resolveExample(example, cliName) {
|
|
4411
|
-
return example.includes("{bin}") ? example.replaceAll("{bin}", cliName) : `${cliName} ${example}`;
|
|
4412
|
-
}
|
|
4413
|
-
function commandDocs(def, cliName) {
|
|
4414
|
-
const examples = def.help.examples.map((example) => resolveExample(example, cliName));
|
|
4415
|
-
if (examples.length === 0) return {
|
|
4416
|
-
brief: def.help.summary,
|
|
4417
|
-
fullDescription: def.help.description
|
|
4418
|
-
};
|
|
4419
|
-
return {
|
|
4420
|
-
brief: def.help.summary,
|
|
4421
|
-
fullDescription: [def.help.description ?? def.help.summary, ...examples.length === 0 ? [] : [
|
|
4422
|
-
"",
|
|
4423
|
-
"Examples:",
|
|
4424
|
-
...examples.map((example) => ` ${example}`)
|
|
4425
|
-
]].join("\n")
|
|
4426
|
-
};
|
|
4427
|
-
}
|
|
4428
|
-
function toStricliCommand(entry, cliName, runEntry) {
|
|
4429
|
-
return buildCommand({
|
|
4430
|
-
async func(flags, ...values) {
|
|
4431
|
-
await runEntry(this.invocation, entry, flags, values);
|
|
4432
|
-
},
|
|
4433
|
-
parameters: commandParameters(entry.def),
|
|
4434
|
-
docs: commandDocs(entry.def, cliName)
|
|
4435
|
-
});
|
|
4436
|
-
}
|
|
4437
|
-
function buildRoutes(spec, node, groupPath, runEntry) {
|
|
4438
|
-
const routes = {};
|
|
4439
|
-
for (const [name, entry] of node.commands) routes[name] = toStricliCommand(entry, spec.name, runEntry);
|
|
4440
|
-
for (const [name, child] of node.children) routes[name] = buildRoutes(spec, child, groupPath === "" ? name : `${groupPath} ${name}`, runEntry);
|
|
4441
|
-
return buildRouteMap({
|
|
4442
|
-
routes,
|
|
4443
|
-
docs: groupPath === "" ? { brief: spec.name } : {
|
|
4444
|
-
brief: spec.groups[groupPath].brief,
|
|
4445
|
-
fullDescription: spec.groups[groupPath].description
|
|
4446
|
-
}
|
|
4447
|
-
});
|
|
4448
|
-
}
|
|
4449
|
-
function capturingText(state) {
|
|
4450
|
-
return {
|
|
4451
|
-
...text_en,
|
|
4452
|
-
exceptionWhileParsingArguments(exc, ansiColor) {
|
|
4453
|
-
if (exc instanceof FlagNotFoundError) state.unresolvedFlagNames.push(exc.input);
|
|
4454
|
-
const message = text_en.exceptionWhileParsingArguments.call(text_en, exc, ansiColor);
|
|
4455
|
-
state.usageErrorText = message;
|
|
4456
|
-
return message;
|
|
4457
|
-
},
|
|
4458
|
-
noCommandRegisteredForInput(args) {
|
|
4459
|
-
const message = text_en.noCommandRegisteredForInput(args);
|
|
4460
|
-
state.usageErrorText = message;
|
|
4461
|
-
return message;
|
|
4462
|
-
},
|
|
4463
|
-
exceptionWhileLoadingCommandFunction(exc, ansiColor) {
|
|
4464
|
-
const message = text_en.exceptionWhileLoadingCommandFunction.call(text_en, exc, ansiColor);
|
|
4465
|
-
state.internalErrorText = message;
|
|
4466
|
-
return message;
|
|
4467
|
-
},
|
|
4468
|
-
exceptionWhileRunningCommand(exc, ansiColor) {
|
|
4469
|
-
const message = text_en.exceptionWhileRunningCommand.call(text_en, exc, ansiColor);
|
|
4470
|
-
state.internalErrorText = message;
|
|
4471
|
-
return message;
|
|
4472
|
-
}
|
|
4473
|
-
};
|
|
4474
|
-
}
|
|
4475
|
-
function usageErrorCode(stricliExitCode) {
|
|
4476
|
-
if (stricliExitCode === -5) return "CLI.UNKNOWN_COMMAND";
|
|
4477
|
-
if (stricliExitCode === -4) return "CLI.INVALID_ARGUMENTS";
|
|
4478
|
-
}
|
|
4479
|
-
//#endregion
|
|
4480
4555
|
//#region src/execution/help.ts
|
|
4481
4556
|
/**
|
|
4482
4557
|
* Engine-rendered help: the command tree drawn with the same tones the
|
|
@@ -4837,16 +4912,17 @@ function undocumentedExitCode(def, exitCode) {
|
|
|
4837
4912
|
if ((def.kind === "result-command" ? Object.keys(def.exitCodes).map(Number) : []).includes(exitCode)) return;
|
|
4838
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`);
|
|
4839
4914
|
}
|
|
4840
|
-
function settleCompleted(invocation, def,
|
|
4841
|
-
if (typeof
|
|
4915
|
+
function settleCompleted(invocation, def, returned) {
|
|
4916
|
+
if (typeof returned !== "object" || returned === null || returned[PRESENTED] !== true) {
|
|
4842
4917
|
settleBug(invocation, /* @__PURE__ */ new Error("@prisma/cli-engine: a handler returned ok(...) without a PresentedResult built by ctx.present"));
|
|
4843
4918
|
return;
|
|
4844
4919
|
}
|
|
4845
|
-
const violation = undocumentedExitCode(def,
|
|
4920
|
+
const violation = undocumentedExitCode(def, returned.exitCode);
|
|
4846
4921
|
if (violation !== void 0) {
|
|
4847
4922
|
settleBug(invocation, violation);
|
|
4848
4923
|
return;
|
|
4849
4924
|
}
|
|
4925
|
+
const presented = presentedWithBinName(returned, invocation.cliName);
|
|
4850
4926
|
const state = invocation.state;
|
|
4851
4927
|
invocation.hooks.onPresented?.(presented);
|
|
4852
4928
|
const exitCode = runExitCode(invocation, presented.exitCode);
|
|
@@ -4892,9 +4968,9 @@ function settleErrored(invocation, error, diagnostics = []) {
|
|
|
4892
4968
|
emitErrored(invocation, {
|
|
4893
4969
|
ok: false,
|
|
4894
4970
|
commandId: state.commandId,
|
|
4895
|
-
error: diagnosticOf(error),
|
|
4896
|
-
diagnostics: accompanyingFindings(diagnostics),
|
|
4897
|
-
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)
|
|
4898
4974
|
});
|
|
4899
4975
|
}
|
|
4900
4976
|
/** The conventional code for a delivered signal: 128 + its number, so
|
|
@@ -4976,11 +5052,12 @@ function settleChildStatus(invocation, def, settlement) {
|
|
|
4976
5052
|
const child = invocation.state.lastChild;
|
|
4977
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`);
|
|
4978
5054
|
const exitCode = childExitCode(child);
|
|
5055
|
+
const nextActions = nextActionsWithBinName(settlement.nextActions, invocation.cliName);
|
|
4979
5056
|
if (invocation.state.format === "json") {
|
|
4980
|
-
settleStructuredChildStatus(invocation,
|
|
5057
|
+
settleStructuredChildStatus(invocation, nextActions, child, exitCode);
|
|
4981
5058
|
return;
|
|
4982
5059
|
}
|
|
4983
|
-
if (child.signal === null) renderChildNextActions(invocation,
|
|
5060
|
+
if (child.signal === null) renderChildNextActions(invocation, nextActions);
|
|
4984
5061
|
settleVerbatimExitCode(invocation, exitCode);
|
|
4985
5062
|
}
|
|
4986
5063
|
function renderChildNextActions(invocation, actions) {
|
|
@@ -4991,9 +5068,9 @@ function renderChildNextActions(invocation, actions) {
|
|
|
4991
5068
|
const paint = makePaint(invocation.state.colorEnabled);
|
|
4992
5069
|
for (const action of actions) invocation.runtime.stderr.write(`${renderNextAction(action, paint)}\n`);
|
|
4993
5070
|
}
|
|
4994
|
-
function settleStructuredChildStatus(invocation,
|
|
5071
|
+
function settleStructuredChildStatus(invocation, actions, child, exitCode) {
|
|
4995
5072
|
settleVerbatimExitCode(invocation, exitCode);
|
|
4996
|
-
const nextActions = child.signal === null ?
|
|
5073
|
+
const nextActions = child.signal === null ? actions : [];
|
|
4997
5074
|
if (exitCode === 0) {
|
|
4998
5075
|
emitFrame(invocation, {
|
|
4999
5076
|
kind: "result",
|
|
@@ -5228,6 +5305,16 @@ function unknownCommandActions(spec, state) {
|
|
|
5228
5305
|
function buildEngine(spec, options) {
|
|
5229
5306
|
return new EngineImpl(spec, options?.now, options?.delay);
|
|
5230
5307
|
}
|
|
5308
|
+
/** Returning the iterator is how the engine tells the host it has
|
|
5309
|
+
* stopped reading. On a real terminal the host's iterator may be
|
|
5310
|
+
* awaiting a keystroke that never comes, and its return cannot settle
|
|
5311
|
+
* before the host stops reading, so the run does not wait for it. */
|
|
5312
|
+
function releaseStdin(state) {
|
|
5313
|
+
const iterator = state.stdinIterator;
|
|
5314
|
+
if (iterator === void 0) return;
|
|
5315
|
+
state.stdinIterator = void 0;
|
|
5316
|
+
iterator.return?.()?.catch(() => {});
|
|
5317
|
+
}
|
|
5231
5318
|
/** Resolves on the timer OR on the signal, whichever comes first — the
|
|
5232
5319
|
* caller decides what an abort means, and no timer outlives the run. */
|
|
5233
5320
|
function waitFor(ms, signal) {
|
|
@@ -5311,6 +5398,7 @@ var EngineImpl = class {
|
|
|
5311
5398
|
};
|
|
5312
5399
|
const unsubscribe = runtime.onSignal(deliverSignal);
|
|
5313
5400
|
const invocation = {
|
|
5401
|
+
cliName: this.spec.name,
|
|
5314
5402
|
runtime,
|
|
5315
5403
|
hooks: { ...hooks },
|
|
5316
5404
|
now: this.now,
|
|
@@ -5375,7 +5463,7 @@ var EngineImpl = class {
|
|
|
5375
5463
|
});
|
|
5376
5464
|
} finally {
|
|
5377
5465
|
unsubscribe();
|
|
5378
|
-
|
|
5466
|
+
releaseStdin(state);
|
|
5379
5467
|
}
|
|
5380
5468
|
const exitCode = state.settledExitCode !== void 0 ? state.settledExitCode : this.settleRouting(invocation, stricliProcess.exitCode);
|
|
5381
5469
|
this.fireOnSettled(invocation, exitCode, startedAtMs);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as ResolvedSection, A as Format, At as CommandArgs, B as Ui, Bt as CredentialOrigin, C as defineSessionCommand, Ct as PackageManagerRunRequest, D as OpenUrlRequest, Dt as Args, E as OpenUrlOutcome, Et as PackageOperations, F as Span, Ft as ActiveAccessTokenOptions, G as ConfigSection, Gt as CredentialRefresher, H as Severity, Ht as Session, I as Status, It as ActiveCredential, J as ConfigSchema, Jt as TokenStorage, K as SectionValidation, Kt as ManagementApiClient, L as Text, Lt as Credential, M as PRESENTED, Mt as PositionalSpec, N as Presentations, Nt as flag, O as PromptSurface, Ot as ArgsSpec, P as PresentedResult, Pt as positional, Q as validateSectionWithSchema, R as Tone, Rt as CredentialIdentity, S as defineServerCommand, St as PackageManagerId, T as CommandContext, Tt as PackageManagerRunner, U as StreamEvent, Ut as StoredSessions, V as EngineEvent, Vt as SERVICE_TOKEN_ENV_VAR, W as StreamMeta, Wt as CredentialRefreshResult, X as configSchema, Y as ConfigSchemaValue, Z as reference, _ as ServerCommandDefinition, _t as SpawnChild, a as RedirectSpec, at as InputStream, b as WorkflowStep, bt as SpawnedChild, c as CommandDefinition, ct as OutputStream, d as CommandNeeds, dt as TelemetryPayload, et as SectionProvenance, f as CompletedEnvelope, ft as EngineCommandSnapshot, g as NeedsSpec, gt as ExitWithChildStatusOptions, h as HelpSpec, ht as ChildStatusSettlement, i as MountedTree, it as HostProcess, j as Outcome, jt as FlagSpec, k as Block, kt as Char, l as CommandHandler, lt as PRISMA_CONFIG_VERSION, m as Handler, mt as ChildResult, n as CommandFamily, nt as resolveSectionPath, o as defineCommandFamily, ot as LoadedConfig, p as ErroredEnvelope, pt as RunSummary, q as defineConfigSection, qt as ManagementApiClientConfig, r as CommandRedirect, rt as Host, s as AnyCommand, st as LoadedConfigFile, t as TelemetryDeclaration, tt as resolveSectionOverChain, u as CommandHelp, ut as Runtime, v as SessionCommandDefinition, vt as SpawnOptions, w as BrowserWaitRequest, wt as PackageManagerRunResult, x as defineCommand, xt as exitWithChildStatus, y as SpawnDeclarations, yt as SpawnRequest, z as TreeNode, zt as CredentialManager } from "./report-B_8n69OY.js";
|
|
2
2
|
import { n as CliStructuredError } from "./protocol-YjqPCCOG.js";
|
|
3
3
|
|
|
4
4
|
//#region src/active-access-token.d.ts
|
|
@@ -225,4 +225,4 @@ declare function claimedExpiresAt(token: string): Date | undefined;
|
|
|
225
225
|
*/
|
|
226
226
|
declare function claimedIdentity(token: string): CredentialIdentity | undefined;
|
|
227
227
|
//#endregion
|
|
228
|
-
export { type ActiveAccessTokenOptions, type ActiveCredential, type AnyCommand, type Args, type ArgsSpec, type Block, type BrowserWaitRequest, type Char, type ChildResult, type ChildStatusSettlement, type Cli, type CliRunHooks, type CommandArgs, type CommandContext, type CommandDefinition, type CommandFamily, type CommandHandler, type CommandHelp, type CommandNeeds, type CommandRedirect, type CompletedEnvelope, type ConfigSchema, type ConfigSchemaValue, type ConfigSection, type Credential, type CredentialIdentity, type CredentialManager, type CredentialOrigin, type CredentialRefreshResult, type CredentialRefresher, type CredentialsRequiredReason, type EngineCommandSnapshot, type EngineEvent, EnvironmentCredentialManager, type ErroredEnvelope, type ExitWithChildStatusOptions, type FlagSpec, type Format, type Handler, type HelpSpec, type Host, type HostProcess, type InputStream, type LoadedConfig, type LoadedConfigFile, type ManagementApiClient, type ManagementApiClientConfig, type MountedTree, type NeedsSpec, type OpenUrlOutcome, type OpenUrlRequest, type Outcome, type OutputStream, PRESENTED, PRISMA_CONFIG_VERSION, type PackageManagerId, type PackageManagerRunRequest, type PackageManagerRunResult, type PackageManagerRunner, type PackageOperations, type PositionalSpec, type Presentations, type PresentedResult, type PromptSurface, type RedirectSpec, type ResolvedSection, type RunSummary, type Runtime, SERVICE_TOKEN_ENV_VAR, type SectionProvenance, type SectionValidation, type ServerCommandDefinition, type Session, type SessionCommandDefinition, type Severity, type Span, type SpawnChild, type SpawnDeclarations, type SpawnOptions, type SpawnRequest, type SpawnedChild, type Status, type StoredSessions, type StreamEvent, type StreamMeta, type TelemetryDeclaration, type TelemetryPayload, type TelemetryStatus, type TelemetryStatusReason, type Text, type TokenStorage, type Tone, type TreeNode, type Ui, type WorkflowStep, authServiceError, claimedExpiresAt, claimedIdentity, configSchema, createCli, credentialRejectedError, credentialWorkspaceId, credentialWorkspaceMismatchError, credentialsRequiredError, defineCommand, defineCommandFamily, defineConfigSection, definePrismaConfig, defineServerCommand, defineSessionCommand, detectCI, emptyServiceTokenError, exitWithChildStatus, flag, loadConfig, noSessionForWorkspaceError, positional, readActiveAccessToken, realpathOr, resolveSectionOverChain, resolveSectionPath, telemetryCommandGroup, validateSectionWithSchema };
|
|
228
|
+
export { type ActiveAccessTokenOptions, type ActiveCredential, type AnyCommand, type Args, type ArgsSpec, type Block, type BrowserWaitRequest, type Char, type ChildResult, type ChildStatusSettlement, type Cli, type CliRunHooks, type CommandArgs, type CommandContext, type CommandDefinition, type CommandFamily, type CommandHandler, type CommandHelp, type CommandNeeds, type CommandRedirect, type CompletedEnvelope, type ConfigSchema, type ConfigSchemaValue, type ConfigSection, type Credential, type CredentialIdentity, type CredentialManager, type CredentialOrigin, type CredentialRefreshResult, type CredentialRefresher, type CredentialsRequiredReason, type EngineCommandSnapshot, type EngineEvent, EnvironmentCredentialManager, type ErroredEnvelope, type ExitWithChildStatusOptions, type FlagSpec, type Format, type Handler, type HelpSpec, type Host, type HostProcess, type InputStream, type LoadedConfig, type LoadedConfigFile, type ManagementApiClient, type ManagementApiClientConfig, type MountedTree, type NeedsSpec, type OpenUrlOutcome, type OpenUrlRequest, type Outcome, type OutputStream, PRESENTED, PRISMA_CONFIG_VERSION, type PackageManagerId, type PackageManagerRunRequest, type PackageManagerRunResult, type PackageManagerRunner, type PackageOperations, type PositionalSpec, type Presentations, type PresentedResult, type PromptSurface, type RedirectSpec, type ResolvedSection, type RunSummary, type Runtime, SERVICE_TOKEN_ENV_VAR, type SectionProvenance, type SectionValidation, type ServerCommandDefinition, type Session, type SessionCommandDefinition, type Severity, type Span, type SpawnChild, type SpawnDeclarations, type SpawnOptions, type SpawnRequest, type SpawnedChild, type Status, type StoredSessions, type StreamEvent, type StreamMeta, type TelemetryDeclaration, type TelemetryPayload, type TelemetryStatus, type TelemetryStatusReason, type Text, type TokenStorage, type Tone, type TreeNode, type Ui, type WorkflowStep, authServiceError, claimedExpiresAt, claimedIdentity, configSchema, createCli, credentialRejectedError, credentialWorkspaceId, credentialWorkspaceMismatchError, credentialsRequiredError, defineCommand, defineCommandFamily, defineConfigSection, definePrismaConfig, defineServerCommand, defineSessionCommand, detectCI, emptyServiceTokenError, exitWithChildStatus, flag, loadConfig, noSessionForWorkspaceError, positional, readActiveAccessToken, realpathOr, reference, resolveSectionOverChain, resolveSectionPath, telemetryCommandGroup, validateSectionWithSchema };
|
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
|
|
@@ -95,9 +95,10 @@ function defineServerCommand(def) {
|
|
|
95
95
|
//#endregion
|
|
96
96
|
//#region src/config-schema.ts
|
|
97
97
|
/**
|
|
98
|
-
* The
|
|
99
|
-
*
|
|
100
|
-
*
|
|
98
|
+
* The section being validated, published for the duration of one
|
|
99
|
+
* synchronous schema run: its provenance, so the `path` keyword can resolve
|
|
100
|
+
* each value against the file that declared its top-level key, and the
|
|
101
|
+
* values the schema declared references, so the clone keeps them.
|
|
101
102
|
*/
|
|
102
103
|
let current;
|
|
103
104
|
/** The file that declared the top-level key a value sits under, else the nearest file. */
|
|
@@ -147,17 +148,57 @@ const configSchema = scope({
|
|
|
147
148
|
* into an absolute path against that file's directory; an absolute value
|
|
148
149
|
* passes through unchanged.
|
|
149
150
|
*/
|
|
150
|
-
path: type("string").pipe((value, ctx) => resolvePathValue(value, ctx.path)) }).type;
|
|
151
|
+
path: type("string").pipe((value, ctx) => resolvePathValue(value, ctx.path)) }, { clone: (original) => copyExceptReferences(original, current?.references, /* @__PURE__ */ new Map()) }).type;
|
|
151
152
|
function isPlainObject(value) {
|
|
152
153
|
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
153
154
|
const prototype = Object.getPrototypeOf(value);
|
|
154
155
|
return prototype === Object.prototype || prototype === null;
|
|
155
156
|
}
|
|
156
|
-
/**
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
157
|
+
/**
|
|
158
|
+
* Before arktype applies a morph it clones the value, so resolving a path or
|
|
159
|
+
* applying a default never writes into what the caller passed in. The scope
|
|
160
|
+
* above supplies the clone through arktype's `clone` option: it copies every
|
|
161
|
+
* value except the ones the schema declared with {@link reference}, which
|
|
162
|
+
* reach the command as the config file built them. `seen` carries the copies
|
|
163
|
+
* made so far, so a value that refers back to itself is copied once.
|
|
164
|
+
*/
|
|
165
|
+
function copyExceptReferences(value, references, seen) {
|
|
166
|
+
if (typeof value !== "object" || value === null || references?.has(value)) return value;
|
|
167
|
+
const copied = seen.get(value);
|
|
168
|
+
if (copied !== void 0) return copied;
|
|
169
|
+
if (Array.isArray(value)) {
|
|
170
|
+
const elements = [];
|
|
171
|
+
seen.set(value, elements);
|
|
172
|
+
for (const element of value) elements.push(copyExceptReferences(element, references, seen));
|
|
173
|
+
return elements;
|
|
174
|
+
}
|
|
175
|
+
const copy = Object.create(Object.getPrototypeOf(value));
|
|
176
|
+
seen.set(value, copy);
|
|
177
|
+
for (const key of Reflect.ownKeys(value)) copy[key] = copyExceptReferences(value[key], references, seen);
|
|
178
|
+
return copy;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Declares a value the config file constructs, such as a descriptor, a
|
|
182
|
+
* client or any class instance: validation checks it against `schema`, and
|
|
183
|
+
* the command receives the file's own object, never a copy. Every value not
|
|
184
|
+
* declared this way is copied before arktype writes into the section.
|
|
185
|
+
*
|
|
186
|
+
* ```ts
|
|
187
|
+
* const toySchema = configSchema({
|
|
188
|
+
* target: reference(configSchema({ kind: "'target'", id: "string" })),
|
|
189
|
+
* "out?": "path",
|
|
190
|
+
* });
|
|
191
|
+
* ```
|
|
192
|
+
*
|
|
193
|
+
* `schema` cannot contain a `path` or a default: resolving one would write
|
|
194
|
+
* into the config file's own object, so such a schema is refused here.
|
|
195
|
+
*/
|
|
196
|
+
function reference(schema) {
|
|
197
|
+
if (schema.in.expression !== schema.expression) throw new Error(`@prisma/cli-engine: a reference cannot contain a path or a default, because resolving it would write into the config file's own object: ${schema.expression}`);
|
|
198
|
+
return schema.narrow((value) => {
|
|
199
|
+
if (typeof value === "object" && value !== null || typeof value === "function") current?.references.add(value);
|
|
200
|
+
return true;
|
|
201
|
+
});
|
|
161
202
|
}
|
|
162
203
|
function fieldDiagnostic(name, error, provenance) {
|
|
163
204
|
const field = error.path.map(String).join(".");
|
|
@@ -182,7 +223,9 @@ function fieldDiagnostic(name, error, provenance) {
|
|
|
182
223
|
* section is validated as an empty object, so a schema whose fields are
|
|
183
224
|
* all optional accepts it and a required field is reported by name. A
|
|
184
225
|
* plain-object value comes back frozen and carrying `baseDir`, the
|
|
185
|
-
* directory of the nearest file declaring the section
|
|
226
|
+
* directory of the nearest file declaring the section, unless the whole
|
|
227
|
+
* section is a reference, which comes back as the file's own object. Never
|
|
228
|
+
* throws for
|
|
186
229
|
* any input: arktype reports problems as errors, and a `path` value is
|
|
187
230
|
* only ever resolved here.
|
|
188
231
|
*/
|
|
@@ -192,12 +235,14 @@ function validateSectionWithSchema(name, schema, raw, provenance) {
|
|
|
192
235
|
diagnostics: [reservedKeyDiagnostic(name, "baseDir", provenance)]
|
|
193
236
|
};
|
|
194
237
|
const previous = current;
|
|
238
|
+
const references = /* @__PURE__ */ new WeakSet();
|
|
195
239
|
current = {
|
|
196
240
|
name,
|
|
197
|
-
provenance
|
|
241
|
+
provenance,
|
|
242
|
+
references
|
|
198
243
|
};
|
|
199
244
|
try {
|
|
200
|
-
const out = schema(raw === void 0 ? {} :
|
|
245
|
+
const out = schema(raw === void 0 ? {} : raw);
|
|
201
246
|
if (out instanceof type.errors) return {
|
|
202
247
|
ok: false,
|
|
203
248
|
diagnostics: [...out].map((error) => fieldDiagnostic(name, error, provenance))
|
|
@@ -205,7 +250,7 @@ function validateSectionWithSchema(name, schema, raw, provenance) {
|
|
|
205
250
|
const nearest = provenance.files[0];
|
|
206
251
|
return {
|
|
207
252
|
ok: true,
|
|
208
|
-
value: isPlainObject(out) && nearest !== void 0 ? Object.freeze({
|
|
253
|
+
value: isPlainObject(out) && nearest !== void 0 && !references.has(out) ? Object.freeze({
|
|
209
254
|
...out,
|
|
210
255
|
baseDir: dirname(nearest)
|
|
211
256
|
}) : out,
|
|
@@ -547,4 +592,4 @@ Telemetry is on by default (opt-out); see ${options.docsUrl}\nfor what is collec
|
|
|
547
592
|
};
|
|
548
593
|
}
|
|
549
594
|
//#endregion
|
|
550
|
-
export { EnvironmentCredentialManager, PRESENTED, PRISMA_CONFIG_VERSION, SERVICE_TOKEN_ENV_VAR, authServiceError, claimedExpiresAt, claimedIdentity, configSchema, createCli, credentialRejectedError, credentialWorkspaceId, credentialWorkspaceMismatchError, credentialsRequiredError, defineCommand, defineCommandFamily, defineConfigSection, definePrismaConfig, defineServerCommand, defineSessionCommand, detectCI, emptyServiceTokenError, exitWithChildStatus, flag, loadConfig, noSessionForWorkspaceError, positional, readActiveAccessToken, realpathOr, resolveSectionOverChain, resolveSectionPath, telemetryCommandGroup, validateSectionWithSchema };
|
|
595
|
+
export { EnvironmentCredentialManager, PRESENTED, PRISMA_CONFIG_VERSION, SERVICE_TOKEN_ENV_VAR, authServiceError, claimedExpiresAt, claimedIdentity, configSchema, createCli, credentialRejectedError, credentialWorkspaceId, credentialWorkspaceMismatchError, credentialsRequiredError, defineCommand, defineCommandFamily, defineConfigSection, definePrismaConfig, defineServerCommand, defineSessionCommand, detectCI, emptyServiceTokenError, exitWithChildStatus, flag, loadConfig, noSessionForWorkspaceError, positional, readActiveAccessToken, realpathOr, reference, resolveSectionOverChain, resolveSectionPath, telemetryCommandGroup, validateSectionWithSchema };
|
|
@@ -702,6 +702,12 @@ interface HostProcess {
|
|
|
702
702
|
readonly stdin: {
|
|
703
703
|
isTTY?: boolean;
|
|
704
704
|
setRawMode?(enabled: boolean): unknown;
|
|
705
|
+
/** Whether a stdin still being read keeps the process alive. The
|
|
706
|
+
* engine reads through the bin's adapter, which unrefs stdin once
|
|
707
|
+
* a run has finished prompting so an idle process can exit, and
|
|
708
|
+
* refs it again when the next run starts reading. */
|
|
709
|
+
ref?(): unknown;
|
|
710
|
+
unref?(): unknown;
|
|
705
711
|
[Symbol.asyncIterator](): AsyncIterator<Uint8Array>;
|
|
706
712
|
};
|
|
707
713
|
on(event: "SIGINT" | "SIGTERM", listener: () => void): unknown;
|
|
@@ -826,18 +832,38 @@ type ConfigSchema<T = unknown> = Type<T, typeof configScope.t>;
|
|
|
826
832
|
/**
|
|
827
833
|
* The validated value a schema produces: its output type plus `baseDir`,
|
|
828
834
|
* the directory of the nearest file declaring the section, which the engine
|
|
829
|
-
* adds to a plain-object value
|
|
830
|
-
* declare it and a config file may not write
|
|
835
|
+
* adds to a plain-object value that is not a {@link reference}. `baseDir`
|
|
836
|
+
* is reserved: a schema may not declare it and a config file may not write
|
|
837
|
+
* it.
|
|
831
838
|
*/
|
|
832
839
|
type ConfigSchemaValue<S extends ConfigSchema> = S["infer"] & {
|
|
833
840
|
readonly baseDir?: string;
|
|
834
841
|
};
|
|
842
|
+
/**
|
|
843
|
+
* Declares a value the config file constructs, such as a descriptor, a
|
|
844
|
+
* client or any class instance: validation checks it against `schema`, and
|
|
845
|
+
* the command receives the file's own object, never a copy. Every value not
|
|
846
|
+
* declared this way is copied before arktype writes into the section.
|
|
847
|
+
*
|
|
848
|
+
* ```ts
|
|
849
|
+
* const toySchema = configSchema({
|
|
850
|
+
* target: reference(configSchema({ kind: "'target'", id: "string" })),
|
|
851
|
+
* "out?": "path",
|
|
852
|
+
* });
|
|
853
|
+
* ```
|
|
854
|
+
*
|
|
855
|
+
* `schema` cannot contain a `path` or a default: resolving one would write
|
|
856
|
+
* into the config file's own object, so such a schema is refused here.
|
|
857
|
+
*/
|
|
858
|
+
declare function reference<S extends ConfigSchema>(schema: S): S;
|
|
835
859
|
/**
|
|
836
860
|
* Validates one section's resolved value against its schema. An absent
|
|
837
861
|
* section is validated as an empty object, so a schema whose fields are
|
|
838
862
|
* all optional accepts it and a required field is reported by name. A
|
|
839
863
|
* plain-object value comes back frozen and carrying `baseDir`, the
|
|
840
|
-
* directory of the nearest file declaring the section
|
|
864
|
+
* directory of the nearest file declaring the section, unless the whole
|
|
865
|
+
* section is a reference, which comes back as the file's own object. Never
|
|
866
|
+
* throws for
|
|
841
867
|
* any input: arktype reports problems as errors, and a `path` value is
|
|
842
868
|
* only ever resolved here.
|
|
843
869
|
*/
|
|
@@ -1333,10 +1359,10 @@ interface PromptSurface {
|
|
|
1333
1359
|
* `token` is the natural noun of what is being consented to — an app
|
|
1334
1360
|
* name, a hostname. Supplying one changes both halves of the prompt:
|
|
1335
1361
|
* interactively the user must type the token exactly instead of
|
|
1336
|
-
* answering yes/no, and
|
|
1337
|
-
*
|
|
1338
|
-
* consent). Without a token there is no
|
|
1339
|
-
* consent at all.
|
|
1362
|
+
* answering yes/no, and `--confirm <token>` on the command line grants
|
|
1363
|
+
* the consent up front in any session, so no prompt is shown (one
|
|
1364
|
+
* `--confirm` value per consent). Without a token there is no
|
|
1365
|
+
* non-interactive way to consent at all.
|
|
1340
1366
|
*/
|
|
1341
1367
|
readonly consent: (question: string, opts?: {
|
|
1342
1368
|
readonly token?: string;
|
|
@@ -1703,4 +1729,4 @@ interface TelemetryDeclaration {
|
|
|
1703
1729
|
readonly docsUrl: string;
|
|
1704
1730
|
}
|
|
1705
1731
|
//#endregion
|
|
1706
|
-
export {
|
|
1732
|
+
export { ResolvedSection as $, Format as A, CommandArgs as At, Ui as B, CredentialOrigin as Bt, defineSessionCommand as C, PackageManagerRunRequest as Ct, OpenUrlRequest as D, Args as Dt, OpenUrlOutcome as E, PackageOperations as Et, Span as F, ActiveAccessTokenOptions as Ft, ConfigSection as G, CredentialRefresher as Gt, Severity as H, Session as Ht, Status as I, ActiveCredential as It, ConfigSchema as J, TokenStorage$1 as Jt, SectionValidation as K, ManagementApiClient$1 as Kt, Text as L, Credential as Lt, PRESENTED as M, PositionalSpec as Mt, Presentations as N, flag as Nt, PromptSurface as O, ArgsSpec as Ot, PresentedResult as P, positional as Pt, validateSectionWithSchema as Q, Tone as R, CredentialIdentity as Rt, defineServerCommand as S, PackageManagerId as St, CommandContext as T, PackageManagerRunner as Tt, StreamEvent as U, StoredSessions as Ut, EngineEvent as V, SERVICE_TOKEN_ENV_VAR as Vt, StreamMeta as W, CredentialRefreshResult as Wt, configSchema as X, ConfigSchemaValue as Y, reference as Z, ServerCommandDefinition as _, SpawnChild as _t, RedirectSpec as a, InputStream as at, WorkflowStep as b, SpawnedChild as bt, CommandDefinition as c, OutputStream as ct, CommandNeeds as d, TelemetryPayload as dt, SectionProvenance as et, CompletedEnvelope as f, EngineCommandSnapshot as ft, NeedsSpec as g, ExitWithChildStatusOptions as gt, HelpSpec as h, ChildStatusSettlement as ht, MountedTree as i, HostProcess as it, Outcome as j, FlagSpec as jt, Block as k, Char as kt, CommandHandler as l, PRISMA_CONFIG_VERSION as lt, Handler as m, ChildResult as mt, CommandFamily as n, resolveSectionPath as nt, defineCommandFamily as o, LoadedConfig as ot, ErroredEnvelope as p, RunSummary as pt, defineConfigSection as q, ManagementApiClientConfig as qt, CommandRedirect as r, Host as rt, AnyCommand as s, LoadedConfigFile as st, TelemetryDeclaration as t, resolveSectionOverChain as tt, CommandHelp as u, Runtime as ut, SessionCommandDefinition as v, SpawnOptions as vt, BrowserWaitRequest as w, PackageManagerRunResult as wt, defineCommand as x, exitWithChildStatus as xt, SpawnDeclarations as y, SpawnRequest as yt, TreeNode as z, CredentialManager as zt };
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Ft as
|
|
1
|
+
import { Ft as ActiveAccessTokenOptions, Gt as CredentialRefresher, Ht as Session, It as ActiveCredential, Jt as TokenStorage, Kt as ManagementApiClient, Lt as Credential, P as PresentedResult, St as PackageManagerId, Tt as PackageManagerRunner, U as StreamEvent, Ut as StoredSessions, V as EngineEvent, _t as SpawnChild, b as WorkflowStep, dt as TelemetryPayload, i as MountedTree, mt as ChildResult, n as CommandFamily, pt as RunSummary, qt as ManagementApiClientConfig, rt as Host, t as TelemetryDeclaration, ut as Runtime, yt as SpawnRequest, zt as CredentialManager } from "./report-B_8n69OY.js";
|
|
2
2
|
|
|
3
3
|
//#region src/in-memory-credential-manager.d.ts
|
|
4
4
|
/** A stored session with its credential material — what the manager
|
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.2",
|
|
4
4
|
"description": "The execution engine of the unified Prisma CLI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -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.18-dev.134",
|
|
57
|
+
"@repo/tsconfig": "8.0.0-rc.18-dev.134",
|
|
58
58
|
"@types/node": "^22.19.19",
|
|
59
59
|
"ci-info": "^4.3.1",
|
|
60
60
|
"tsdown": "^0.21.10",
|