@prisma/cli-engine 0.6.3 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +65 -0
- package/dist/{engine-BLU1DuVo.js → engine-BE7WKK2X.js} +561 -40
- package/dist/index.d.ts +6 -4
- package/dist/index.js +8 -3
- package/dist/{report-B_8n69OY.d.ts → report-CQ30sy_e.d.ts} +108 -2
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -10,4 +10,69 @@ Every command describes its output once, as blocks, and the engine renders it in
|
|
|
10
10
|
- `@prisma/cli-engine/protocol` — the wire types for machine-readable (JSON) output.
|
|
11
11
|
- `@prisma/cli-engine/testing` — the test harness for running commands in-process.
|
|
12
12
|
|
|
13
|
+
## Mounting commands
|
|
14
|
+
|
|
15
|
+
`createCli` takes commands by path. Every path with more than one word needs its group declared in `groups`, and the group's `brief` is its row on the parent's help card. A path can be a command and a group at once:
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
createCli({
|
|
19
|
+
groups: { dev: { brief: "Run the app locally. Start it, print URLs, stop it" } },
|
|
20
|
+
commands: { dev, "dev url": devUrl, "dev stop": devStop },
|
|
21
|
+
// ...
|
|
22
|
+
});
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
`dev module.ts` runs `dev` with the positional `module.ts`, and `dev url gateway` runs `dev url`. When the word after `dev` names a command beneath it, that command runs, so `dev url` never reaches `dev` as a positional. To pass such a word as the positional, put `--` before it: `dev -- url` runs `dev` with `url`. A retired path declared as a redirect, such as `dev up`, wins over the positional the same way. `dev --help` shows the `dev` command's help and lists `url` and `stop`.
|
|
26
|
+
|
|
27
|
+
## Statement prompts
|
|
28
|
+
|
|
29
|
+
A command asks what the user means to happen to something with `ctx.prompt.statement`. The answer is a verb and free text, and the command validates it.
|
|
30
|
+
|
|
31
|
+
The command declares the verbs it may ask with, each with its `arity` (how many values follow the flag) and a help `brief`:
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
defineCommand({
|
|
35
|
+
statements: {
|
|
36
|
+
rename: { arity: 1, brief: "Rename a table instead of dropping it: --rename Old:New" },
|
|
37
|
+
delete: { arity: 1, brief: "Drop a table and its rows: --delete Table" },
|
|
38
|
+
},
|
|
39
|
+
// ...
|
|
40
|
+
});
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Only that command accepts `--rename` and `--delete`; on any other command they are unknown flags. Their values stay out of the handler's flags, and help lists them on the command's own card. A verb is one lowercase word, and may not be a shared flag or one of the command's own flags. Asking with a verb the command did not declare is a construction error, and so is a question with an empty subject or a verb listed twice.
|
|
44
|
+
|
|
45
|
+
Then, in the handler:
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
const answer = await ctx.prompt.statement(
|
|
49
|
+
'Table "Legacy" would be dropped and its rows lost. What do you mean?',
|
|
50
|
+
{
|
|
51
|
+
subject: "Legacy",
|
|
52
|
+
verbs: ["rename", "delete"],
|
|
53
|
+
forms: { rename: "Legacy:<new name>" },
|
|
54
|
+
validate: (verb, text) =>
|
|
55
|
+
verb === "rename" && !text.startsWith("Legacy:")
|
|
56
|
+
? "Write the rename as Legacy:<new name>."
|
|
57
|
+
: undefined,
|
|
58
|
+
},
|
|
59
|
+
);
|
|
60
|
+
// { verb: "delete", text: "Legacy", values: ["Legacy"] }
|
|
61
|
+
// or { verb: "rename", text: "Legacy:Archive", values: ["Legacy:Archive"] }
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Each occurrence of `--<verb>` takes exactly `arity` values, in argv order across all the verbs. A wrong count or an empty value is `CLI.INVALID_ARGUMENTS`. A token that starts with `-` reads as a flag, so a first value that starts with `-` must be written `--<verb>=<value>`. `values` holds them; `text` is them joined by one space.
|
|
65
|
+
|
|
66
|
+
The engine answers the question in this order:
|
|
67
|
+
|
|
68
|
+
1. A verb flag whose first value names the subject: the value is the subject, or starts with `<subject>:`. `--delete Legacy` and `--rename Legacy:Archive` both name `Legacy`. Within one batch, a value equal to a subject answers that subject first, and any other value goes to the longest subject it names, so `--delete A:B` answers the question about `A:B`, not the one about `A`. Ask questions whose subjects are prefixes of one another in one batch. A value `validate` rejects fails the run with `CLI.PROMPT_INVALID`.
|
|
69
|
+
2. With no such value, a non-interactive run, or one under `--yes`, fails with `CLI.CONSENT_REQUIRED`. Its next actions give one flag to pass per verb, safe to paste into a shell: a value with anything but plain characters is single-quoted, and a value starting with `-` is written `--<verb>=<value>`, and its `meta` carries `subject`, `verbs` and `unanswered`.
|
|
70
|
+
3. Otherwise the user is asked, and answers `<verb> <text>`, or `<verb>` alone to mean the subject. A verb with an arity above 1 takes its values from the text, separated by whitespace, and `text` is them joined by one space, as for a flag. A rejected answer is asked again on a terminal; with scripted or piped input it fails with `CLI.PROMPT_INVALID`.
|
|
71
|
+
|
|
72
|
+
`ctx.prompt.statements([...])` asks several questions at once and returns the answers in order. Flags answer what they can, a refusal lists every question still unanswered, and an interactive run asks the rest one after another.
|
|
73
|
+
|
|
74
|
+
A statement is the command's own declared input, unlike a `--confirm` value, which a handler never sees. A command that needs some statements as input to its work, before it can know what to ask, takes them with `ctx.statements.take("rename")`: every unconsumed value of that verb, in argv order, as `{ verb, values, text }[]`. Taken values are consumed, and other verbs' values stay for the questions. A later question may still list a taken verb: no flag value of it is left to answer the question, so the verb serves the refusal's `--<verb>` form and what a user may type. `ctx.statements.values()` lists every unconsumed value of every verb in argv order without consuming any, for showing what a run was given, such as in a line that repeats the command. Take, and ask any consent with a token, before any `last: true` batch, which reports every value still unconsumed.
|
|
75
|
+
|
|
76
|
+
Each flag answers one question. A run that succeeds with a flag nothing consumed fails with `CLI.CONSENT_UNUSED`, so a mistyped subject or a second answer to one question is never ignored. The same holds for a `--confirm` token no consent asked for, on a command that declares statements (other commands still ignore a leftover `--confirm`; see [#339](https://github.com/prisma/prisma-cli/issues/339)). A refusal also names any given statement flag that matches none of its questions, and any `--confirm` token, so the user hears of it before answering a prompt. That check runs when the handler returns, after the command has acted. A command that asks everything in one batch passes `statements(questions, { last: true })` to get the same failure right after the questions are answered, before it does anything with them.
|
|
77
|
+
|
|
13
78
|
Part of [prisma/prisma-cli](https://github.com/prisma/prisma-cli).
|
|
@@ -1158,7 +1158,7 @@ const SHELL_SAFE = /^[A-Za-z0-9_@%+=:,./-]+$/;
|
|
|
1158
1158
|
* an ordinary character and reads `%` and `^` — so a line pasted into
|
|
1159
1159
|
* cmd.exe or PowerShell is not quoted for those shells.
|
|
1160
1160
|
*/
|
|
1161
|
-
function shellQuote(entry) {
|
|
1161
|
+
function shellQuote$1(entry) {
|
|
1162
1162
|
if (SHELL_SAFE.test(entry)) return entry;
|
|
1163
1163
|
return `'${entry.replaceAll("'", String.raw`'\''`)}'`;
|
|
1164
1164
|
}
|
|
@@ -1166,7 +1166,7 @@ function spell$1(file, args) {
|
|
|
1166
1166
|
return {
|
|
1167
1167
|
file,
|
|
1168
1168
|
args,
|
|
1169
|
-
line: [file, ...args].map(shellQuote).join(" ")
|
|
1169
|
+
line: [file, ...args].map(shellQuote$1).join(" ")
|
|
1170
1170
|
};
|
|
1171
1171
|
}
|
|
1172
1172
|
function addSpelling(file) {
|
|
@@ -2158,11 +2158,128 @@ function resolveLogLevel(shared) {
|
|
|
2158
2158
|
return shared.logLevel ?? "info";
|
|
2159
2159
|
}
|
|
2160
2160
|
//#endregion
|
|
2161
|
+
//#region src/execution/statement-flags.ts
|
|
2162
|
+
/**
|
|
2163
|
+
* Statement flags: `--<verb>` followed by the verb's `arity` values,
|
|
2164
|
+
* repeatable, accepted only by the command that declares the verb. The
|
|
2165
|
+
* engine takes them out of argv before the parser sees it, because the
|
|
2166
|
+
* parser gives a flag one value per occurrence and keeps no order
|
|
2167
|
+
* across flags. The values stay out of the handler's flags; the
|
|
2168
|
+
* handler reads them through ctx.prompt.statement or
|
|
2169
|
+
* ctx.statements.take.
|
|
2170
|
+
*/
|
|
2171
|
+
function statementsOf(def) {
|
|
2172
|
+
return def.kind === "result-command" ? def.statements ?? {} : {};
|
|
2173
|
+
}
|
|
2174
|
+
function declaredStatements(def) {
|
|
2175
|
+
return Object.keys(statementsOf(def));
|
|
2176
|
+
}
|
|
2177
|
+
/** How help shows the flag: `<subject>` for the first value, `<value>`
|
|
2178
|
+
* for each further one. */
|
|
2179
|
+
function statementPlaceholders(spec) {
|
|
2180
|
+
return ["<subject>", ...Array.from({ length: spec.arity - 1 }, () => "<value>")].join(" ");
|
|
2181
|
+
}
|
|
2182
|
+
function statementBrief(verb, spec) {
|
|
2183
|
+
return spec.brief ?? `Say what happens to <subject>: ${verb}, instead of being asked (repeatable)`;
|
|
2184
|
+
}
|
|
2185
|
+
/** The command argv routes to, found the way the parser routes: the
|
|
2186
|
+
* leading words, group by group, until one names a command. A group
|
|
2187
|
+
* with its own command routes to it at the first word that names no
|
|
2188
|
+
* child. Like the parser, a kebab-case word matches a camelCase name. */
|
|
2189
|
+
function routedCommand(tree, argv) {
|
|
2190
|
+
let node = tree;
|
|
2191
|
+
for (const token of argv) {
|
|
2192
|
+
const entry = node.commands.get(token) ?? node.commands.get(camelCase(token));
|
|
2193
|
+
if (entry !== void 0) return entry;
|
|
2194
|
+
const child = node.children.get(token) ?? node.children.get(camelCase(token));
|
|
2195
|
+
if (child === void 0) return node.ownCommand;
|
|
2196
|
+
node = child;
|
|
2197
|
+
}
|
|
2198
|
+
return node.ownCommand;
|
|
2199
|
+
}
|
|
2200
|
+
function statementFlagIn(token, statements) {
|
|
2201
|
+
if (!token.startsWith("--")) return;
|
|
2202
|
+
const equals = token.indexOf("=");
|
|
2203
|
+
const verb = token.slice(2, equals === -1 ? void 0 : equals);
|
|
2204
|
+
if (!Object.hasOwn(statements, verb)) return;
|
|
2205
|
+
return {
|
|
2206
|
+
verb,
|
|
2207
|
+
inline: equals === -1 ? void 0 : token.slice(equals + 1)
|
|
2208
|
+
};
|
|
2209
|
+
}
|
|
2210
|
+
/** A first value that starts with `-` reads as a flag, so it can only
|
|
2211
|
+
* be given inline; the error says so when that is what happened. */
|
|
2212
|
+
function wrongValueCount(verb, arity, given, next) {
|
|
2213
|
+
const wanted = arity === 1 ? "a value" : `${arity} values`;
|
|
2214
|
+
const summary = `--${verb} needs ${wanted}, and was given ${given}.`;
|
|
2215
|
+
if (given === 0 && next?.startsWith("-") === true) return new CliStructuredError("CLI.INVALID_ARGUMENTS", `${summary} A value that starts with '-' must be written --${verb}=<value>.`, { nextActions: [{
|
|
2216
|
+
kind: "user-choice",
|
|
2217
|
+
label: `Write --${verb}=<value>.`
|
|
2218
|
+
}] });
|
|
2219
|
+
return new CliStructuredError("CLI.INVALID_ARGUMENTS", summary, { nextActions: [{
|
|
2220
|
+
kind: "user-choice",
|
|
2221
|
+
label: `Pass --${verb} followed by ${wanted}.`
|
|
2222
|
+
}] });
|
|
2223
|
+
}
|
|
2224
|
+
function emptyValue(verb) {
|
|
2225
|
+
return new CliStructuredError("CLI.INVALID_ARGUMENTS", `--${verb} was given an empty value.`, { nextActions: [{
|
|
2226
|
+
kind: "user-choice",
|
|
2227
|
+
label: `Name what --${verb} is about.`
|
|
2228
|
+
}] });
|
|
2229
|
+
}
|
|
2230
|
+
/**
|
|
2231
|
+
* Takes the command's statement flags out of argv, keeping their
|
|
2232
|
+
* values in the order argv gave them. A value is any following token
|
|
2233
|
+
* that is not a flag; nothing after a bare `--` is a flag.
|
|
2234
|
+
*/
|
|
2235
|
+
function extractStatementFlags(argv, statements) {
|
|
2236
|
+
const terminator = argv.indexOf("--");
|
|
2237
|
+
const tokens = terminator === -1 ? argv : argv.slice(0, terminator);
|
|
2238
|
+
const rest = terminator === -1 ? [] : argv.slice(terminator);
|
|
2239
|
+
const kept = [];
|
|
2240
|
+
const values = [];
|
|
2241
|
+
let index = 0;
|
|
2242
|
+
while (index < tokens.length) {
|
|
2243
|
+
const token = tokens[index];
|
|
2244
|
+
index += 1;
|
|
2245
|
+
const flag = statementFlagIn(token, statements);
|
|
2246
|
+
if (flag === void 0) {
|
|
2247
|
+
kept.push(token);
|
|
2248
|
+
continue;
|
|
2249
|
+
}
|
|
2250
|
+
const { arity } = statements[flag.verb];
|
|
2251
|
+
const given = flag.inline === void 0 ? [] : [flag.inline];
|
|
2252
|
+
while (given.length < arity && index < tokens.length && !tokens[index].startsWith("-")) {
|
|
2253
|
+
given.push(tokens[index]);
|
|
2254
|
+
index += 1;
|
|
2255
|
+
}
|
|
2256
|
+
if (given.length !== arity) return {
|
|
2257
|
+
ok: false,
|
|
2258
|
+
error: wrongValueCount(flag.verb, arity, given.length, tokens[index])
|
|
2259
|
+
};
|
|
2260
|
+
if (given.some((value) => value.trim() === "")) return {
|
|
2261
|
+
ok: false,
|
|
2262
|
+
error: emptyValue(flag.verb)
|
|
2263
|
+
};
|
|
2264
|
+
values.push({
|
|
2265
|
+
verb: flag.verb,
|
|
2266
|
+
values: given,
|
|
2267
|
+
consumed: false
|
|
2268
|
+
});
|
|
2269
|
+
}
|
|
2270
|
+
return {
|
|
2271
|
+
ok: true,
|
|
2272
|
+
argv: [...kept, ...rest],
|
|
2273
|
+
values
|
|
2274
|
+
};
|
|
2275
|
+
}
|
|
2276
|
+
//#endregion
|
|
2161
2277
|
//#region src/execution/command-tree.ts
|
|
2162
2278
|
function constructionError(message) {
|
|
2163
2279
|
return /* @__PURE__ */ new Error(`@prisma/cli-engine: ${message}`);
|
|
2164
2280
|
}
|
|
2165
2281
|
const CAMEL_CASE = /^[a-z][a-zA-Z0-9]*$/;
|
|
2282
|
+
const ONE_LOWERCASE_WORD = /^[a-z]+$/;
|
|
2166
2283
|
const INTEGER_LIKE = /^\d+$/;
|
|
2167
2284
|
function validateFlags(path, def) {
|
|
2168
2285
|
const flags = def.args.flags;
|
|
@@ -2177,6 +2294,14 @@ function validateFlags(path, def) {
|
|
|
2177
2294
|
seenAliases.add(alias);
|
|
2178
2295
|
}
|
|
2179
2296
|
}
|
|
2297
|
+
function validateStatements(path, def) {
|
|
2298
|
+
for (const [verb, spec] of Object.entries(statementsOf(def))) {
|
|
2299
|
+
if (!ONE_LOWERCASE_WORD.test(verb)) throw constructionError(`command '${path}' statement '${verb}' must be one lowercase word (it is both the flag and the word typed at the prompt)`);
|
|
2300
|
+
if (RESERVED_FLAG_NAMES.has(verb)) throw constructionError(`command '${path}' declares statement '${verb}', which is a shared flag`);
|
|
2301
|
+
if (def.args.flags[verb] !== void 0) throw constructionError(`command '${path}' declares both a flag and a statement named '${verb}'`);
|
|
2302
|
+
if (!Number.isInteger(spec.arity) || spec.arity < 1) throw constructionError(`command '${path}' statement '${verb}' declares arity ${spec.arity}; arity is a whole number of values, at least 1`);
|
|
2303
|
+
}
|
|
2304
|
+
}
|
|
2180
2305
|
function validatePositionals(path, def) {
|
|
2181
2306
|
const entries = Object.entries(def.args.positionals);
|
|
2182
2307
|
let sawOptional = false;
|
|
@@ -2200,30 +2325,43 @@ function validateSpawnDeclarations(path, def) {
|
|
|
2200
2325
|
}
|
|
2201
2326
|
function emptyNode() {
|
|
2202
2327
|
return {
|
|
2328
|
+
ownCommand: void 0,
|
|
2203
2329
|
commands: /* @__PURE__ */ new Map(),
|
|
2204
2330
|
children: /* @__PURE__ */ new Map()
|
|
2205
2331
|
};
|
|
2206
2332
|
}
|
|
2207
|
-
function
|
|
2333
|
+
function childNode(node, segment) {
|
|
2334
|
+
let child = node.children.get(segment);
|
|
2335
|
+
if (child === void 0) {
|
|
2336
|
+
child = emptyNode();
|
|
2337
|
+
node.children.set(segment, child);
|
|
2338
|
+
}
|
|
2339
|
+
return child;
|
|
2340
|
+
}
|
|
2341
|
+
/** Every path some other mounted path extends: `dev` when `dev url` is
|
|
2342
|
+
* mounted. */
|
|
2343
|
+
function groupPathsOf(paths) {
|
|
2344
|
+
const groups = /* @__PURE__ */ new Set();
|
|
2345
|
+
for (const path of paths) {
|
|
2346
|
+
const segments = path.split(" ");
|
|
2347
|
+
for (let depth = 1; depth < segments.length; depth += 1) groups.add(segments.slice(0, depth).join(" "));
|
|
2348
|
+
}
|
|
2349
|
+
return groups;
|
|
2350
|
+
}
|
|
2351
|
+
/** A path that is also a group keeps its command on the group's node,
|
|
2352
|
+
* so the node's children and its own command meet in one place. */
|
|
2353
|
+
function insertCommand(root, path, def, docsBaseUrl, isGroup) {
|
|
2208
2354
|
const segments = path.split(" ");
|
|
2209
2355
|
if (segments.some((segment) => segment.length === 0)) throw constructionError(`invalid command path '${path}'`);
|
|
2210
|
-
|
|
2211
|
-
for (const segment of segments.slice(0, -1)) {
|
|
2212
|
-
if (node.commands.has(segment)) throw constructionError(`command path '${path}' collides with a command mounted at a prefix of it`);
|
|
2213
|
-
let child = node.children.get(segment);
|
|
2214
|
-
if (child === void 0) {
|
|
2215
|
-
child = emptyNode();
|
|
2216
|
-
node.children.set(segment, child);
|
|
2217
|
-
}
|
|
2218
|
-
node = child;
|
|
2219
|
-
}
|
|
2220
|
-
const leaf = segments[segments.length - 1];
|
|
2221
|
-
if (node.commands.has(leaf) || node.children.has(leaf)) throw constructionError(`command path '${path}' collides with another mounted command`);
|
|
2222
|
-
node.commands.set(leaf, {
|
|
2356
|
+
const entry = {
|
|
2223
2357
|
def,
|
|
2224
2358
|
id: segments.join("."),
|
|
2225
2359
|
docsBaseUrl
|
|
2226
|
-
}
|
|
2360
|
+
};
|
|
2361
|
+
const parent = segments.slice(0, -1).reduce((node, segment) => childNode(node, segment), root);
|
|
2362
|
+
const leaf = segments[segments.length - 1];
|
|
2363
|
+
if (isGroup) childNode(parent, leaf).ownCommand = entry;
|
|
2364
|
+
else parent.commands.set(leaf, entry);
|
|
2227
2365
|
}
|
|
2228
2366
|
/** A command belongs to the family whose commands record contains it
|
|
2229
2367
|
* (identity). Harness-mounted commands with no family are unowned. */
|
|
@@ -2266,10 +2404,12 @@ function buildCommandTree(spec) {
|
|
|
2266
2404
|
if (paths.length === 0) throw constructionError("createCli requires at least one mounted command");
|
|
2267
2405
|
validateDocsBaseUrls(spec);
|
|
2268
2406
|
validateConfigSectionNames(spec);
|
|
2407
|
+
const groupPaths = groupPathsOf(paths);
|
|
2269
2408
|
const root = emptyNode();
|
|
2270
2409
|
for (const path of paths) {
|
|
2271
2410
|
const def = spec.commands[path];
|
|
2272
2411
|
validateFlags(path, def);
|
|
2412
|
+
validateStatements(path, def);
|
|
2273
2413
|
validatePositionals(path, def);
|
|
2274
2414
|
validateExitCodes(path, def);
|
|
2275
2415
|
validateSpawnDeclarations(path, def);
|
|
@@ -2279,7 +2419,7 @@ function buildCommandTree(spec) {
|
|
|
2279
2419
|
const groupPath = segments.slice(0, depth).join(" ");
|
|
2280
2420
|
if (spec.groups[groupPath] === void 0) throw constructionError(`command path '${path}' references unknown group '${groupPath}' (declare it in createCli's groups)`);
|
|
2281
2421
|
}
|
|
2282
|
-
insertCommand(root, path, def, commandFamilyOf(spec, def)?.docsBaseUrl);
|
|
2422
|
+
insertCommand(root, path, def, commandFamilyOf(spec, def)?.docsBaseUrl, groupPaths.has(path));
|
|
2283
2423
|
}
|
|
2284
2424
|
return root;
|
|
2285
2425
|
}
|
|
@@ -2296,7 +2436,7 @@ function mountedAs(spec, path) {
|
|
|
2296
2436
|
/** Engine-injected shared flags count: a command answers them whether
|
|
2297
2437
|
* or not it declared them, so a redirect for one could never fire. */
|
|
2298
2438
|
function acceptsFlag(def, flag) {
|
|
2299
|
-
if (def.args.flags[flag] !== void 0) return true;
|
|
2439
|
+
if (def.args.flags[flag] !== void 0 || declaredStatements(def).includes(flag)) return true;
|
|
2300
2440
|
return def.kind !== "server-command" && RESERVED_FLAG_NAMES.has(flag);
|
|
2301
2441
|
}
|
|
2302
2442
|
function addVerbRedirect(spec, table, redirect) {
|
|
@@ -2608,15 +2748,30 @@ function toStricliCommand(entry, cliName, runEntry) {
|
|
|
2608
2748
|
docs: commandDocs(entry.def, cliName)
|
|
2609
2749
|
});
|
|
2610
2750
|
}
|
|
2751
|
+
/** The route a group's own command sits under, hidden from listings.
|
|
2752
|
+
* A child's name is one path segment and never contains a space, so no
|
|
2753
|
+
* child can take this name. A user can still type it, so it is dropped
|
|
2754
|
+
* from the path the parser reports. */
|
|
2755
|
+
const OWN_COMMAND_ROUTE = "<own command>";
|
|
2611
2756
|
function buildRoutes(spec, node, groupPath, runEntry) {
|
|
2612
2757
|
const routes = {};
|
|
2758
|
+
if (node.ownCommand !== void 0) routes[OWN_COMMAND_ROUTE] = toStricliCommand(node.ownCommand, spec.name, runEntry);
|
|
2613
2759
|
for (const [name, entry] of node.commands) routes[name] = toStricliCommand(entry, spec.name, runEntry);
|
|
2614
2760
|
for (const [name, child] of node.children) routes[name] = buildRoutes(spec, child, groupPath === "" ? name : `${groupPath} ${name}`, runEntry);
|
|
2761
|
+
const docs = groupPath === "" ? { brief: spec.name } : {
|
|
2762
|
+
brief: spec.groups[groupPath].brief,
|
|
2763
|
+
fullDescription: spec.groups[groupPath].description
|
|
2764
|
+
};
|
|
2765
|
+
if (node.ownCommand === void 0) return buildRouteMap({
|
|
2766
|
+
routes,
|
|
2767
|
+
docs
|
|
2768
|
+
});
|
|
2615
2769
|
return buildRouteMap({
|
|
2616
2770
|
routes,
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2771
|
+
defaultCommand: OWN_COMMAND_ROUTE,
|
|
2772
|
+
docs: {
|
|
2773
|
+
...docs,
|
|
2774
|
+
hideRoute: { [OWN_COMMAND_ROUTE]: true }
|
|
2620
2775
|
}
|
|
2621
2776
|
});
|
|
2622
2777
|
}
|
|
@@ -2973,7 +3128,11 @@ function writeDiagnostic(stream, diagnostic, paint = PLAIN) {
|
|
|
2973
3128
|
const glyph = paint(diagnostic.severity, DIAGNOSTIC_SYMBOL[diagnostic.severity]);
|
|
2974
3129
|
const code = paint("muted", `[${diagnostic.code}]`);
|
|
2975
3130
|
stream.write(`${glyph} ${code} ${diagnostic.summary}\n`);
|
|
2976
|
-
if (diagnostic.why !== void 0)
|
|
3131
|
+
if (diagnostic.why !== void 0) {
|
|
3132
|
+
const [first, ...rest] = String(diagnostic.why).split("\n");
|
|
3133
|
+
stream.write(` ${paint("muted", `why: ${first}`)}\n`);
|
|
3134
|
+
for (const line of rest) stream.write(` ${paint("muted", line)}\n`);
|
|
3135
|
+
}
|
|
2977
3136
|
for (const action of renderableNextActions(diagnostic.nextActions)) stream.write(`${renderNextAction(action, paint)}\n`);
|
|
2978
3137
|
if (diagnostic.docsUrl !== void 0) stream.write(` ${paint("muted", "docs:")} ${paint("link", diagnostic.docsUrl)}\n`);
|
|
2979
3138
|
}
|
|
@@ -3830,7 +3989,7 @@ function toWritable(out) {
|
|
|
3830
3989
|
callback();
|
|
3831
3990
|
} });
|
|
3832
3991
|
}
|
|
3833
|
-
async function makeClackRenderer(stdin, stderr) {
|
|
3992
|
+
async function makeClackRenderer(stdin, stderr, signal) {
|
|
3834
3993
|
const clack = await import("@clack/prompts");
|
|
3835
3994
|
const input = toReadable(stdin);
|
|
3836
3995
|
const output = toWritable(stderr);
|
|
@@ -3838,25 +3997,35 @@ async function makeClackRenderer(stdin, stderr) {
|
|
|
3838
3997
|
confirm: (question, initial) => clack.confirm({
|
|
3839
3998
|
input,
|
|
3840
3999
|
output,
|
|
4000
|
+
signal,
|
|
3841
4001
|
message: question,
|
|
3842
4002
|
initialValue: initial ?? false
|
|
3843
4003
|
}),
|
|
3844
4004
|
consent: (question) => clack.confirm({
|
|
3845
4005
|
input,
|
|
3846
4006
|
output,
|
|
4007
|
+
signal,
|
|
3847
4008
|
message: question,
|
|
3848
4009
|
initialValue: false
|
|
3849
4010
|
}),
|
|
3850
4011
|
confirmToken: (question, token) => clack.text({
|
|
3851
4012
|
input,
|
|
3852
4013
|
output,
|
|
4014
|
+
signal,
|
|
3853
4015
|
message: `${question} Type ${token} to confirm.`,
|
|
3854
4016
|
placeholder: token,
|
|
3855
4017
|
validate: (value) => value === token ? void 0 : `Type ${token} exactly, or press Ctrl-C.`
|
|
3856
4018
|
}),
|
|
4019
|
+
statement: (message) => clack.text({
|
|
4020
|
+
input,
|
|
4021
|
+
output,
|
|
4022
|
+
signal,
|
|
4023
|
+
message
|
|
4024
|
+
}),
|
|
3857
4025
|
select: (question, options, initial) => clack.select({
|
|
3858
4026
|
input,
|
|
3859
4027
|
output,
|
|
4028
|
+
signal,
|
|
3860
4029
|
message: question,
|
|
3861
4030
|
options: options.map((option) => ({
|
|
3862
4031
|
value: option.value,
|
|
@@ -3867,6 +4036,7 @@ async function makeClackRenderer(stdin, stderr) {
|
|
|
3867
4036
|
text: (question, placeholder, fallback) => clack.text({
|
|
3868
4037
|
input,
|
|
3869
4038
|
output,
|
|
4039
|
+
signal,
|
|
3870
4040
|
message: question,
|
|
3871
4041
|
placeholder,
|
|
3872
4042
|
defaultValue: fallback
|
|
@@ -3876,6 +4046,9 @@ async function makeClackRenderer(stdin, stderr) {
|
|
|
3876
4046
|
}
|
|
3877
4047
|
//#endregion
|
|
3878
4048
|
//#region src/execution/prompts.ts
|
|
4049
|
+
const WHITESPACE = /\s/;
|
|
4050
|
+
const SHELL_PLAIN = /^[A-Za-z0-9_.:@%+/,-][A-Za-z0-9_.:@%+/,=-]*$/;
|
|
4051
|
+
const WHITESPACES = /\s+/;
|
|
3879
4052
|
/** How often browserWait asks whether the user has finished. */
|
|
3880
4053
|
const BROWSER_WAIT_POLL_INTERVAL_MS = 1e3;
|
|
3881
4054
|
/** A `--confirm` value grants at most one consent: the matched value is
|
|
@@ -3886,6 +4059,174 @@ function consumeConfirmValue(state, token) {
|
|
|
3886
4059
|
state.confirmValues.splice(index, 1);
|
|
3887
4060
|
return true;
|
|
3888
4061
|
}
|
|
4062
|
+
/** A value as a POSIX shell reads it back: plain values as they are,
|
|
4063
|
+
* anything else in single quotes, an embedded quote written `'\''`. */
|
|
4064
|
+
function shellQuote(value) {
|
|
4065
|
+
return SHELL_PLAIN.test(value) ? value : `'${value.replaceAll("'", "'\\''")}'`;
|
|
4066
|
+
}
|
|
4067
|
+
/** The flag as a user would paste it. A first value starting with `-`
|
|
4068
|
+
* would read as a flag, so it is joined with `=`. */
|
|
4069
|
+
function flagForm(verb, values) {
|
|
4070
|
+
const [first, ...rest] = values.map(shellQuote);
|
|
4071
|
+
return [values[0].startsWith("-") ? `--${verb}=${first}` : `--${verb} ${first}`, ...rest].join(" ");
|
|
4072
|
+
}
|
|
4073
|
+
/** What a question accepts, as the prompt shows it: each verb with its
|
|
4074
|
+
* form when it has one. */
|
|
4075
|
+
function statementHint(question) {
|
|
4076
|
+
return question.verbs.map((verb) => {
|
|
4077
|
+
const form = question.forms?.[verb];
|
|
4078
|
+
return form === void 0 ? verb : `${verb} ${form}`;
|
|
4079
|
+
}).join(" or ");
|
|
4080
|
+
}
|
|
4081
|
+
function namesSubject(value, subject) {
|
|
4082
|
+
return value === subject || value.startsWith(`${subject}:`);
|
|
4083
|
+
}
|
|
4084
|
+
function subjectOf(value) {
|
|
4085
|
+
const colon = value.indexOf(":");
|
|
4086
|
+
return colon === -1 ? value : value.slice(0, colon);
|
|
4087
|
+
}
|
|
4088
|
+
/** The longest of `subjects` that `value` names: `A:B` names both `A`
|
|
4089
|
+
* and `A:B`, and belongs to `A:B`. */
|
|
4090
|
+
function longestSubjectNamed(value, subjects) {
|
|
4091
|
+
let longest;
|
|
4092
|
+
for (const subject of subjects) if (namesSubject(value, subject) && (longest === void 0 || subject.length > longest.length)) longest = subject;
|
|
4093
|
+
return longest;
|
|
4094
|
+
}
|
|
4095
|
+
/** The first unconsumed statement-flag value whose first value `fits`
|
|
4096
|
+
* the question, tried verb by verb. A value the command rejects fails
|
|
4097
|
+
* the run: a wrong flag cannot be corrected by asking again. */
|
|
4098
|
+
function answerFromFlags(state, question, fits) {
|
|
4099
|
+
for (const verb of question.verbs) {
|
|
4100
|
+
const value = state.statementValues.find((candidate) => !candidate.consumed && candidate.verb === verb && fits(candidate.values[0]));
|
|
4101
|
+
if (value === void 0) continue;
|
|
4102
|
+
const text = value.values.join(" ");
|
|
4103
|
+
const rejection = question.validate(verb, text);
|
|
4104
|
+
if (rejection !== void 0) throw new CliStructuredError("CLI.PROMPT_INVALID", `${flagForm(verb, value.values)} does not answer "${question.question}": ${rejection}`);
|
|
4105
|
+
value.consumed = true;
|
|
4106
|
+
return {
|
|
4107
|
+
verb,
|
|
4108
|
+
text,
|
|
4109
|
+
values: value.values
|
|
4110
|
+
};
|
|
4111
|
+
}
|
|
4112
|
+
}
|
|
4113
|
+
/** Why a refusal could not be answered from the command line: the
|
|
4114
|
+
* statement values that name none of the batch's subjects, and any
|
|
4115
|
+
* `--confirm` value, which answers no statement. */
|
|
4116
|
+
function strayFlagLines(state, subjects) {
|
|
4117
|
+
return [...state.statementValues.filter((value) => !value.consumed && longestSubjectNamed(value.values[0], subjects) === void 0).map((value) => `${flagForm(value.verb, value.values)} answers no question; the questions are about ${subjects.join(", ")}.`), ...state.confirmValues.map((token) => `${flagForm("confirm", [token])} answers no consent in this run; a statement flag is what answers these questions.`)];
|
|
4118
|
+
}
|
|
4119
|
+
function statementUnavailable(unanswered, subjects, state) {
|
|
4120
|
+
const quoted = unanswered.map((question) => `"${question.subject}"`);
|
|
4121
|
+
const situation = state.yes ? "which --yes cannot give" : "and the session is not interactive";
|
|
4122
|
+
const summary = unanswered.length === 1 ? `${quoted[0]} needs a statement, ${situation}.` : `${unanswered.length} subjects need a statement, ${situation}: ${quoted.join(", ")}.`;
|
|
4123
|
+
const listed = unanswered.map(({ subject, verbs }) => ({
|
|
4124
|
+
subject,
|
|
4125
|
+
verbs
|
|
4126
|
+
}));
|
|
4127
|
+
const unmatched = state.statementValues.filter((value) => !value.consumed && longestSubjectNamed(value.values[0], subjects) === void 0).map(({ verb, values }) => ({
|
|
4128
|
+
verb,
|
|
4129
|
+
values
|
|
4130
|
+
}));
|
|
4131
|
+
return new CliStructuredError("CLI.CONSENT_REQUIRED", summary, {
|
|
4132
|
+
why: [...unanswered.map((question) => question.question), ...strayFlagLines(state, subjects)].join("\n"),
|
|
4133
|
+
nextActions: unanswered.flatMap((question) => question.verbs.map((verb) => ({
|
|
4134
|
+
kind: "user-choice",
|
|
4135
|
+
label: `Run the command again with ${flagForm(verb, [question.forms?.[verb] ?? question.subject])}`
|
|
4136
|
+
}))),
|
|
4137
|
+
meta: {
|
|
4138
|
+
...listed.length === 1 ? listed[0] : {},
|
|
4139
|
+
unanswered: listed,
|
|
4140
|
+
...unmatched.length === 0 ? {} : { unmatched },
|
|
4141
|
+
...state.confirmValues.length === 0 ? {} : { confirm: [...state.confirmValues] }
|
|
4142
|
+
}
|
|
4143
|
+
});
|
|
4144
|
+
}
|
|
4145
|
+
/** An interactive answer: `<verb> <text>`, or `<verb>` alone to mean
|
|
4146
|
+
* the subject. A verb taking several values reads them from the text,
|
|
4147
|
+
* separated by whitespace. */
|
|
4148
|
+
function parseStatement(raw, question, state) {
|
|
4149
|
+
const trimmed = raw.trim();
|
|
4150
|
+
const space = trimmed.search(WHITESPACE);
|
|
4151
|
+
const typedVerb = space === -1 ? trimmed : trimmed.slice(0, space);
|
|
4152
|
+
const rest = space === -1 ? "" : trimmed.slice(space).trim();
|
|
4153
|
+
const verb = question.verbs.find((candidate) => candidate === typedVerb);
|
|
4154
|
+
if (verb === void 0) return { problem: `Start the answer with ${question.verbs.join(" or ")}.` };
|
|
4155
|
+
const typed = rest === "" ? question.subject : rest;
|
|
4156
|
+
const { arity } = state.statements[verb];
|
|
4157
|
+
const values = arity === 1 ? [typed] : typed.split(WHITESPACES);
|
|
4158
|
+
if (values.length !== arity) return { problem: `Give ${arity} values after ${verb}.` };
|
|
4159
|
+
const text = values.join(" ");
|
|
4160
|
+
const rejection = question.validate(verb, text);
|
|
4161
|
+
return rejection === void 0 ? { answer: {
|
|
4162
|
+
verb,
|
|
4163
|
+
text,
|
|
4164
|
+
values
|
|
4165
|
+
} } : { problem: rejection };
|
|
4166
|
+
}
|
|
4167
|
+
/** What makes a question one the command could never have meant to
|
|
4168
|
+
* ask, if anything. */
|
|
4169
|
+
function malformation(question, declared) {
|
|
4170
|
+
const about = `about '${question.subject}'`;
|
|
4171
|
+
if (question.subject === "") return `${about}: a subject must be non-empty`;
|
|
4172
|
+
if (question.verbs.length === 0) return `${about} with no verbs`;
|
|
4173
|
+
if (new Set(question.verbs).size !== question.verbs.length) return `${about} listing a verb twice`;
|
|
4174
|
+
const undeclared = question.verbs.find((verb) => !Object.hasOwn(declared, verb));
|
|
4175
|
+
return undeclared === void 0 ? void 0 : `with verb '${undeclared}', which it does not declare in statements`;
|
|
4176
|
+
}
|
|
4177
|
+
/** The asked subject a value names, if any. */
|
|
4178
|
+
function askedSubjectOf(state, value) {
|
|
4179
|
+
return longestSubjectNamed(value.values[0], state.askedSubjects);
|
|
4180
|
+
}
|
|
4181
|
+
function unusedSentence(state, value) {
|
|
4182
|
+
const given = flagForm(value.verb, value.values);
|
|
4183
|
+
const asked = askedSubjectOf(state, value);
|
|
4184
|
+
return asked === void 0 ? `${given} was given but nothing in this run asked about ${subjectOf(value.values[0])}.` : `${given} was given, but the question about ${asked} was already answered by another flag.`;
|
|
4185
|
+
}
|
|
4186
|
+
/** `--confirm` tokens no consent consumed, reported only on a command
|
|
4187
|
+
* that declares statements, where one is certainly a mistake. Other
|
|
4188
|
+
* commands still take `--confirm` on paths that ask nothing; making
|
|
4189
|
+
* their leftovers an error waits on prisma/prisma-cli#339. */
|
|
4190
|
+
function leftoverConfirmTokens(state) {
|
|
4191
|
+
return Object.keys(state.statements).length === 0 ? [] : state.confirmValues;
|
|
4192
|
+
}
|
|
4193
|
+
function unusedActions(unused, state) {
|
|
4194
|
+
const actions = [];
|
|
4195
|
+
if (unused.some((value) => askedSubjectOf(state, value) === void 0)) actions.push({
|
|
4196
|
+
kind: "user-choice",
|
|
4197
|
+
label: "Remove the flag, or spell the subject the way the command names it."
|
|
4198
|
+
});
|
|
4199
|
+
if (unused.some((value) => askedSubjectOf(state, value) !== void 0)) actions.push({
|
|
4200
|
+
kind: "user-choice",
|
|
4201
|
+
label: "Give one flag per question."
|
|
4202
|
+
});
|
|
4203
|
+
if (leftoverConfirmTokens(state).length > 0) actions.push({
|
|
4204
|
+
kind: "user-choice",
|
|
4205
|
+
label: "Remove the --confirm flag: nothing in this run asks for it."
|
|
4206
|
+
});
|
|
4207
|
+
return actions;
|
|
4208
|
+
}
|
|
4209
|
+
/** Fails a run when a consent flag answered nothing: a mistyped
|
|
4210
|
+
* subject or token, or a second answer to one question, must not
|
|
4211
|
+
* pass silently. Covers statement values and `--confirm` tokens. */
|
|
4212
|
+
function unusedConsentError(state) {
|
|
4213
|
+
const unused = state.statementValues.filter((value) => !value.consumed);
|
|
4214
|
+
if (unused.length === 0 && leftoverConfirmTokens(state).length === 0) return;
|
|
4215
|
+
const sentences = [...unused.map((value) => unusedSentence(state, value)), ...leftoverConfirmTokens(state).map((token) => `${flagForm("confirm", [token])} answers no consent in this run.`)];
|
|
4216
|
+
const asked = [...state.askedSubjects];
|
|
4217
|
+
return new CliStructuredError("CLI.CONSENT_UNUSED", sentences.join(" "), {
|
|
4218
|
+
...asked.length === 0 ? {} : { why: `The run asked about ${asked.join(", ")}.` },
|
|
4219
|
+
nextActions: unusedActions(unused, state),
|
|
4220
|
+
meta: {
|
|
4221
|
+
unused: unused.map(({ verb, values }) => ({
|
|
4222
|
+
verb,
|
|
4223
|
+
values
|
|
4224
|
+
})),
|
|
4225
|
+
...leftoverConfirmTokens(state).length === 0 ? {} : { confirm: [...leftoverConfirmTokens(state)] },
|
|
4226
|
+
...asked.length === 0 ? {} : { asked }
|
|
4227
|
+
}
|
|
4228
|
+
});
|
|
4229
|
+
}
|
|
3889
4230
|
function makeLineReader(stdin, invocation) {
|
|
3890
4231
|
const iterator = stdin[Symbol.asyncIterator]();
|
|
3891
4232
|
invocation.state.stdinIterator = iterator;
|
|
@@ -4005,12 +4346,57 @@ function parseBooleanAnswer(raw, fallback, question) {
|
|
|
4005
4346
|
].includes(normalized)) return false;
|
|
4006
4347
|
throw promptInvalid(question, raw);
|
|
4007
4348
|
}
|
|
4349
|
+
/** ctx.statements: the command's statement values read as its own
|
|
4350
|
+
* input. `values` only reads them; `take` consumes a verb's values so
|
|
4351
|
+
* the leftover check does not report them. */
|
|
4352
|
+
function makeStatementSurface(invocation) {
|
|
4353
|
+
const { state } = invocation;
|
|
4354
|
+
return {
|
|
4355
|
+
values: () => state.statementValues.filter((value) => !value.consumed).map((value) => ({
|
|
4356
|
+
verb: value.verb,
|
|
4357
|
+
text: value.values.join(" "),
|
|
4358
|
+
values: value.values
|
|
4359
|
+
})),
|
|
4360
|
+
take: (verb) => {
|
|
4361
|
+
if (!Object.hasOwn(state.statements, verb)) throw constructionError(`command '${state.commandId}' took verb '${verb}', which it does not declare in statements`);
|
|
4362
|
+
return state.statementValues.filter((value) => !value.consumed && value.verb === verb).map((value) => {
|
|
4363
|
+
value.consumed = true;
|
|
4364
|
+
return {
|
|
4365
|
+
verb,
|
|
4366
|
+
text: value.values.join(" "),
|
|
4367
|
+
values: value.values
|
|
4368
|
+
};
|
|
4369
|
+
});
|
|
4370
|
+
}
|
|
4371
|
+
};
|
|
4372
|
+
}
|
|
4008
4373
|
function makePromptSurface(invocation) {
|
|
4009
4374
|
const { runtime, hooks, state } = invocation;
|
|
4010
4375
|
let readLine;
|
|
4011
4376
|
let answerCursor = 0;
|
|
4012
4377
|
let renderer;
|
|
4013
4378
|
const useClack = () => hooks.answers === void 0 && clackCapable(runtime);
|
|
4379
|
+
/** Marks the prompt as waiting for input, so a signal cancels it. */
|
|
4380
|
+
const reading = async (wait) => {
|
|
4381
|
+
state.readingPrompt = true;
|
|
4382
|
+
try {
|
|
4383
|
+
return await wait();
|
|
4384
|
+
} finally {
|
|
4385
|
+
state.readingPrompt = false;
|
|
4386
|
+
}
|
|
4387
|
+
};
|
|
4388
|
+
/** A line read that a signal cancels: resolves undefined, which the
|
|
4389
|
+
* caller reports as a cancelled prompt. */
|
|
4390
|
+
const untilCancelled = (line) => {
|
|
4391
|
+
const signal = state.promptCancel.signal;
|
|
4392
|
+
if (signal.aborted) return Promise.resolve(void 0);
|
|
4393
|
+
let onAbort = () => {};
|
|
4394
|
+
const aborted = new Promise((resolve) => {
|
|
4395
|
+
onAbort = () => resolve(void 0);
|
|
4396
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
4397
|
+
});
|
|
4398
|
+
return Promise.race([line, aborted]).finally(() => signal.removeEventListener("abort", onAbort));
|
|
4399
|
+
};
|
|
4014
4400
|
const renderWithClack = async (question, run) => {
|
|
4015
4401
|
renderer ??= (() => {
|
|
4016
4402
|
const iterator = runtime.stdin[Symbol.asyncIterator]();
|
|
@@ -4018,10 +4404,10 @@ function makePromptSurface(invocation) {
|
|
|
4018
4404
|
return makeClackRenderer({
|
|
4019
4405
|
[Symbol.asyncIterator]: () => iterator,
|
|
4020
4406
|
setRawMode: (enabled) => runtime.stdin.setRawMode?.(enabled)
|
|
4021
|
-
}, runtime.stderr);
|
|
4407
|
+
}, runtime.stderr, state.promptCancel.signal);
|
|
4022
4408
|
})();
|
|
4023
4409
|
const r = await renderer;
|
|
4024
|
-
const value = await run(r);
|
|
4410
|
+
const value = await reading(() => run(r));
|
|
4025
4411
|
if (r.isCancel(value)) throw promptCancelled(question);
|
|
4026
4412
|
return value;
|
|
4027
4413
|
};
|
|
@@ -4035,7 +4421,8 @@ function makePromptSurface(invocation) {
|
|
|
4035
4421
|
}
|
|
4036
4422
|
runtime.stderr.write(rendered);
|
|
4037
4423
|
readLine ??= makeLineReader(runtime.stdin, invocation);
|
|
4038
|
-
const
|
|
4424
|
+
const readNext = readLine;
|
|
4425
|
+
const line = await reading(() => untilCancelled(readNext()));
|
|
4039
4426
|
if (line === void 0) throw promptCancelled(question);
|
|
4040
4427
|
return line;
|
|
4041
4428
|
};
|
|
@@ -4073,6 +4460,47 @@ function makePromptSurface(invocation) {
|
|
|
4073
4460
|
if (raw === "") return fallback ?? "";
|
|
4074
4461
|
return raw;
|
|
4075
4462
|
};
|
|
4463
|
+
const askStatement = async (question) => {
|
|
4464
|
+
const asked = `${question.question} (${statementHint(question)})`;
|
|
4465
|
+
if (useClack()) {
|
|
4466
|
+
const askWithClack = async (problem) => {
|
|
4467
|
+
const message = problem === void 0 ? asked : `${problem}\n${asked}`;
|
|
4468
|
+
const parsed = parseStatement(await renderWithClack(question.question, (r) => r.statement(message)), question, state);
|
|
4469
|
+
return "problem" in parsed ? askWithClack(parsed.problem) : parsed.answer;
|
|
4470
|
+
};
|
|
4471
|
+
return askWithClack(void 0);
|
|
4472
|
+
}
|
|
4473
|
+
const raw = await ask(question.question, `? ${asked} `);
|
|
4474
|
+
if (typeof raw !== "string") throw promptInvalid(question.question, String(raw));
|
|
4475
|
+
const parsed = parseStatement(raw, question, state);
|
|
4476
|
+
if ("problem" in parsed) throw new CliStructuredError("CLI.PROMPT_INVALID", `"${raw}" is not a valid answer to "${question.question}": ${parsed.problem}`);
|
|
4477
|
+
return parsed.answer;
|
|
4478
|
+
};
|
|
4479
|
+
const requireWellFormed = (questions) => {
|
|
4480
|
+
for (const question of questions) {
|
|
4481
|
+
const problem = malformation(question, state.statements);
|
|
4482
|
+
if (problem !== void 0) throw constructionError(`command '${state.commandId}' asked a statement ${problem}`);
|
|
4483
|
+
}
|
|
4484
|
+
};
|
|
4485
|
+
/** Flags answer first, so a refusal can name every question still
|
|
4486
|
+
* unanswered at once; the rest are asked one after another. */
|
|
4487
|
+
const statements = async (questions, opts) => {
|
|
4488
|
+
requireWellFormed(questions);
|
|
4489
|
+
for (const question of questions) state.askedSubjects.add(question.subject);
|
|
4490
|
+
const subjects = questions.map((question) => question.subject);
|
|
4491
|
+
const exact = questions.map((question) => answerFromFlags(state, question, (first) => first === question.subject));
|
|
4492
|
+
const fromFlags = questions.map((question, index) => exact[index] ?? answerFromFlags(state, question, (first) => longestSubjectNamed(first, subjects) === question.subject));
|
|
4493
|
+
const unanswered = questions.filter((_question, index) => fromFlags[index] === void 0);
|
|
4494
|
+
if (unanswered.length > 0 && (state.yes || !state.interactive)) throw statementUnavailable(unanswered, questions.map((question) => question.subject), state);
|
|
4495
|
+
const answerFrom = async (index) => {
|
|
4496
|
+
if (index === questions.length) return [];
|
|
4497
|
+
return [fromFlags[index] ?? await askStatement(questions[index]), ...await answerFrom(index + 1)];
|
|
4498
|
+
};
|
|
4499
|
+
const answers = await answerFrom(0);
|
|
4500
|
+
const unused = opts?.last === true ? unusedConsentError(state) : void 0;
|
|
4501
|
+
if (unused !== void 0) throw unused;
|
|
4502
|
+
return answers;
|
|
4503
|
+
};
|
|
4076
4504
|
/** A prompt writes to stderr and reads the engine's stdin — the same
|
|
4077
4505
|
* terminal a live child inherited. Like ctx.present, prompting while
|
|
4078
4506
|
* a child owns the terminal is a construction error. */
|
|
@@ -4143,6 +4571,14 @@ function makePromptSurface(invocation) {
|
|
|
4143
4571
|
consent: (question, opts) => claimTerminal(() => surface.consent(question, opts)),
|
|
4144
4572
|
select: (question, options, opts) => claimTerminal(() => surface.select(question, options, opts)),
|
|
4145
4573
|
text: (question, opts) => claimTerminal(() => surface.text(question, opts)),
|
|
4574
|
+
statement: async (question, opts) => {
|
|
4575
|
+
const [answer] = await claimTerminal(() => statements([{
|
|
4576
|
+
question,
|
|
4577
|
+
...opts
|
|
4578
|
+
}], void 0));
|
|
4579
|
+
return answer;
|
|
4580
|
+
},
|
|
4581
|
+
statements: (questions, opts) => claimTerminal(() => statements(questions, opts)),
|
|
4146
4582
|
browserWait: (request) => claimTerminal(() => surface.browserWait(request))
|
|
4147
4583
|
};
|
|
4148
4584
|
}
|
|
@@ -4440,6 +4876,7 @@ function makeContext(invocation, def, config, configFiles, capabilities) {
|
|
|
4440
4876
|
lastChild: () => state.lastChild,
|
|
4441
4877
|
report: (event) => reportEvent(invocation, event),
|
|
4442
4878
|
prompt: makePromptSurface(invocation),
|
|
4879
|
+
statements: makeStatementSurface(invocation),
|
|
4443
4880
|
openUrl: (request) => announceUrl(invocation, request),
|
|
4444
4881
|
signal: invocation.signal,
|
|
4445
4882
|
cwd: invocation.runtime.cwd,
|
|
@@ -4480,7 +4917,7 @@ function makeContext(invocation, def, config, configFiles, capabilities) {
|
|
|
4480
4917
|
* positional slots (reduced to a count on the spot).
|
|
4481
4918
|
*/
|
|
4482
4919
|
function declaredFlagKeys(def) {
|
|
4483
|
-
const own = Object.keys(def.args.flags);
|
|
4920
|
+
const own = [...Object.keys(def.args.flags), ...declaredStatements(def)];
|
|
4484
4921
|
if (def.kind === "server-command") return own;
|
|
4485
4922
|
return [...Object.keys(SHARED_FLAG_PARAMETERS), ...own];
|
|
4486
4923
|
}
|
|
@@ -4594,7 +5031,8 @@ function helpPath(argv) {
|
|
|
4594
5031
|
return segments;
|
|
4595
5032
|
}
|
|
4596
5033
|
/** Walks as far as the segments stay recognized; help for `project
|
|
4597
|
-
* frobnicate` is project's help, not a dead end.
|
|
5034
|
+
* frobnicate` is project's help, not a dead end. A group with its own
|
|
5035
|
+
* command answers with that command's help. */
|
|
4598
5036
|
function resolveTarget(root, segments) {
|
|
4599
5037
|
let node = root;
|
|
4600
5038
|
const path = [];
|
|
@@ -4602,8 +5040,9 @@ function resolveTarget(root, segments) {
|
|
|
4602
5040
|
const entry = node.commands.get(segment);
|
|
4603
5041
|
if (entry !== void 0) return {
|
|
4604
5042
|
target: {
|
|
4605
|
-
kind: "
|
|
4606
|
-
entry
|
|
5043
|
+
kind: "command",
|
|
5044
|
+
entry,
|
|
5045
|
+
subcommands: void 0
|
|
4607
5046
|
},
|
|
4608
5047
|
path: [...path, segment]
|
|
4609
5048
|
};
|
|
@@ -4612,6 +5051,14 @@ function resolveTarget(root, segments) {
|
|
|
4612
5051
|
node = child;
|
|
4613
5052
|
path.push(segment);
|
|
4614
5053
|
}
|
|
5054
|
+
if (node.ownCommand !== void 0) return {
|
|
5055
|
+
target: {
|
|
5056
|
+
kind: "command",
|
|
5057
|
+
entry: node.ownCommand,
|
|
5058
|
+
subcommands: node
|
|
5059
|
+
},
|
|
5060
|
+
path
|
|
5061
|
+
};
|
|
4615
5062
|
return {
|
|
4616
5063
|
target: {
|
|
4617
5064
|
kind: "node",
|
|
@@ -4623,8 +5070,9 @@ function resolveTarget(root, segments) {
|
|
|
4623
5070
|
/** A BARE group invocation (`prisma-cli project`, or no argv at all)
|
|
4624
5071
|
* is a help request; anything carrying flags or extra tokens is not —
|
|
4625
5072
|
* `cli --unknown` and `cli project --frobnicate` must reach routing
|
|
4626
|
-
* and usage validation, not exit 0 with a help card. A bare leaf
|
|
4627
|
-
*
|
|
5073
|
+
* and usage validation, not exit 0 with a help card. A bare leaf, or
|
|
5074
|
+
* a bare group with its own command, is a command run and is left
|
|
5075
|
+
* alone. The format-selection flags do not
|
|
4628
5076
|
* count: `cli project --format markdown` asks for the group's help in
|
|
4629
5077
|
* Markdown. */
|
|
4630
5078
|
function bareGroupInvocation(root, rawArgv) {
|
|
@@ -4645,7 +5093,7 @@ function renderHelp(spec, root, argv, options, out) {
|
|
|
4645
5093
|
}
|
|
4646
5094
|
function helpCard(spec, root, argv) {
|
|
4647
5095
|
const { target, path } = resolveTarget(root, helpPath(argv));
|
|
4648
|
-
return target.kind === "
|
|
5096
|
+
return target.kind === "command" ? leafCard(spec, target.entry, target.subcommands, path) : nodeCard(spec, target.node, path);
|
|
4649
5097
|
}
|
|
4650
5098
|
function nodeCard(spec, node, path) {
|
|
4651
5099
|
const atRoot = path.length === 0;
|
|
@@ -4667,7 +5115,7 @@ function nodeCard(spec, node, path) {
|
|
|
4667
5115
|
docsUrl: atRoot ? spec.help?.docsUrl : void 0
|
|
4668
5116
|
};
|
|
4669
5117
|
}
|
|
4670
|
-
function leafCard(spec, entry, path) {
|
|
5118
|
+
function leafCard(spec, entry, subcommands, path) {
|
|
4671
5119
|
const def = entry.def;
|
|
4672
5120
|
const usage = [
|
|
4673
5121
|
spec.name,
|
|
@@ -4683,7 +5131,7 @@ function leafCard(spec, entry, path) {
|
|
|
4683
5131
|
tagline: def.help.summary,
|
|
4684
5132
|
usage,
|
|
4685
5133
|
description: def.help.description,
|
|
4686
|
-
commands: [],
|
|
5134
|
+
commands: subcommands === void 0 ? [] : nodeRows(spec, subcommands, path),
|
|
4687
5135
|
workflow: [],
|
|
4688
5136
|
arguments: Object.values(def.args.positionals).map((spec) => positionalRuntime(spec)).map((runtime) => ({
|
|
4689
5137
|
name: runtime.placeholder,
|
|
@@ -4718,6 +5166,7 @@ function renderHelpTerminal(card, paint) {
|
|
|
4718
5166
|
lines.push(rail(paint));
|
|
4719
5167
|
proseLines(card.description, paint, lines);
|
|
4720
5168
|
}
|
|
5169
|
+
if (card.kind === "leaf") rowSection("Commands", card.commands, paint, lines);
|
|
4721
5170
|
workflowLines(card.workflow, paint, lines);
|
|
4722
5171
|
rowSection("Arguments", card.arguments, paint, lines);
|
|
4723
5172
|
rowSection("Options", card.options, paint, lines);
|
|
@@ -4835,7 +5284,16 @@ function sharedFlagRows() {
|
|
|
4835
5284
|
}
|
|
4836
5285
|
];
|
|
4837
5286
|
}
|
|
5287
|
+
function statementFlagRows(def) {
|
|
5288
|
+
return Object.entries(statementsOf(def)).map(([verb, spec]) => ({
|
|
5289
|
+
name: ` --${verb} ${statementPlaceholders(spec)}...`,
|
|
5290
|
+
brief: statementBrief(verb, spec)
|
|
5291
|
+
}));
|
|
5292
|
+
}
|
|
4838
5293
|
function declaredFlagRows(def) {
|
|
5294
|
+
return [...ownFlagRows(def), ...statementFlagRows(def)];
|
|
5295
|
+
}
|
|
5296
|
+
function ownFlagRows(def) {
|
|
4839
5297
|
return Object.entries(def.args.flags).map(([key, spec]) => {
|
|
4840
5298
|
const runtime = flagRuntime(spec);
|
|
4841
5299
|
return {
|
|
@@ -4964,7 +5422,7 @@ function accompanyingFindings(diagnostics) {
|
|
|
4964
5422
|
}
|
|
4965
5423
|
function settleErrored(invocation, error, diagnostics = []) {
|
|
4966
5424
|
const state = invocation.state;
|
|
4967
|
-
state.settledExitCode = error.code === "CLI.PROMPT_CANCELLED" ?
|
|
5425
|
+
state.settledExitCode = error.code === "CLI.PROMPT_CANCELLED" ? cancelledExitCode(state) : 2;
|
|
4968
5426
|
emitErrored(invocation, {
|
|
4969
5427
|
ok: false,
|
|
4970
5428
|
commandId: state.commandId,
|
|
@@ -4973,6 +5431,12 @@ function settleErrored(invocation, error, diagnostics = []) {
|
|
|
4973
5431
|
nextActions: nextActionsWithBinName(error.nextActions, invocation.cliName)
|
|
4974
5432
|
});
|
|
4975
5433
|
}
|
|
5434
|
+
/** A cancelled prompt exits 3, the user declining, unless a SIGTERM
|
|
5435
|
+
* cancelled it while it waited for input: that ends the run as the
|
|
5436
|
+
* signal it is. */
|
|
5437
|
+
function cancelledExitCode(state) {
|
|
5438
|
+
return state.promptCancel.signal.reason === "SIGTERM" ? signalExitCode("SIGTERM") : 3;
|
|
5439
|
+
}
|
|
4976
5440
|
/** The conventional code for a delivered signal: 128 + its number, so
|
|
4977
5441
|
* 130 for SIGINT and 143 for SIGTERM. */
|
|
4978
5442
|
function signalExitCode(signal) {
|
|
@@ -5226,7 +5690,7 @@ function settleCommandMoved(spec, invocation, redirect, commandId) {
|
|
|
5226
5690
|
}
|
|
5227
5691
|
/** The command path stricli resolved, without the binary name. */
|
|
5228
5692
|
function commandSegments(spec, prefix) {
|
|
5229
|
-
return prefix[0] === spec.name ? prefix.slice(1) : prefix;
|
|
5693
|
+
return (prefix[0] === spec.name ? prefix.slice(1) : prefix).filter((segment) => segment !== OWN_COMMAND_ROUTE);
|
|
5230
5694
|
}
|
|
5231
5695
|
/** Maps stricli's own settlement (parse/route failures, framework bugs)
|
|
5232
5696
|
* onto the engine protocol when the pipeline never settled. A failure
|
|
@@ -5356,6 +5820,9 @@ var EngineImpl = class {
|
|
|
5356
5820
|
logLevel: "info",
|
|
5357
5821
|
yes: false,
|
|
5358
5822
|
confirmValues: [],
|
|
5823
|
+
statements: {},
|
|
5824
|
+
askedSubjects: /* @__PURE__ */ new Set(),
|
|
5825
|
+
statementValues: [],
|
|
5359
5826
|
interactive: defaultInteractive(runtime),
|
|
5360
5827
|
/** Pre-parse resolution so a run that never mounts a command — an
|
|
5361
5828
|
* unknown command, a parse failure — still colours its
|
|
@@ -5374,6 +5841,8 @@ var EngineImpl = class {
|
|
|
5374
5841
|
delegatedTerminal: void 0,
|
|
5375
5842
|
lastChild: void 0,
|
|
5376
5843
|
activePrompts: 0,
|
|
5844
|
+
readingPrompt: false,
|
|
5845
|
+
promptCancel: new AbortController(),
|
|
5377
5846
|
packageOperationRunning: false,
|
|
5378
5847
|
deliveredSignal: void 0,
|
|
5379
5848
|
pendingForceExit: void 0,
|
|
@@ -5389,10 +5858,14 @@ var EngineImpl = class {
|
|
|
5389
5858
|
recordSignalDuringSpawn(state.delegatedTerminal, signal);
|
|
5390
5859
|
return;
|
|
5391
5860
|
}
|
|
5392
|
-
if (state.deliveredSignal !== void 0) {
|
|
5861
|
+
if (state.deliveredSignal !== void 0 || state.promptCancel.signal.aborted) {
|
|
5393
5862
|
runtime.exit(signal === "SIGTERM" ? 143 : 130);
|
|
5394
5863
|
return;
|
|
5395
5864
|
}
|
|
5865
|
+
if (state.readingPrompt) {
|
|
5866
|
+
state.promptCancel.abort(signal);
|
|
5867
|
+
if (signal === "SIGINT") return;
|
|
5868
|
+
}
|
|
5396
5869
|
state.deliveredSignal = signal;
|
|
5397
5870
|
controller.abort(signal);
|
|
5398
5871
|
};
|
|
@@ -5429,6 +5902,18 @@ var EngineImpl = class {
|
|
|
5429
5902
|
}, stream);
|
|
5430
5903
|
return 0;
|
|
5431
5904
|
}
|
|
5905
|
+
const retired = this.retiredPathBeneathCommand(argv);
|
|
5906
|
+
if (retired !== void 0) {
|
|
5907
|
+
unsubscribe();
|
|
5908
|
+
const exitCode = settleCommandMoved(this.spec, invocation, retired, retired.from.replaceAll(" ", "."));
|
|
5909
|
+
this.fireOnSettled(invocation, exitCode, startedAtMs);
|
|
5910
|
+
return exitCode;
|
|
5911
|
+
}
|
|
5912
|
+
const stricliArgv = this.takeStatementFlags(invocation, argv, startedAtMs);
|
|
5913
|
+
if (stricliArgv === void 0) {
|
|
5914
|
+
unsubscribe();
|
|
5915
|
+
return 2;
|
|
5916
|
+
}
|
|
5432
5917
|
const stricliProcess = {
|
|
5433
5918
|
/** stricli writes only help text here. In json mode stdout carries
|
|
5434
5919
|
* exactly the frame stream, so help prose goes to stderr instead. */
|
|
@@ -5451,7 +5936,7 @@ var EngineImpl = class {
|
|
|
5451
5936
|
localization: { text: capturingText(state) }
|
|
5452
5937
|
});
|
|
5453
5938
|
try {
|
|
5454
|
-
await run(app, [...
|
|
5939
|
+
await run(app, [...stricliArgv], {
|
|
5455
5940
|
process: stricliProcess,
|
|
5456
5941
|
forCommand: (info) => {
|
|
5457
5942
|
state.prefix = info.prefix;
|
|
@@ -5470,6 +5955,36 @@ var EngineImpl = class {
|
|
|
5470
5955
|
if (state.pendingForceExit !== void 0) runtime.exit(state.pendingForceExit === "SIGTERM" ? 143 : 130);
|
|
5471
5956
|
return exitCode;
|
|
5472
5957
|
}
|
|
5958
|
+
/** The routed command's statement flags come out of argv before the
|
|
5959
|
+
* parser sees it. Returns the argv left for the parser, or undefined
|
|
5960
|
+
* when a statement flag was malformed and the run has settled. */
|
|
5961
|
+
takeStatementFlags(invocation, argv, startedAtMs) {
|
|
5962
|
+
const state = invocation.state;
|
|
5963
|
+
const routed = routedCommand(this.tree, argv);
|
|
5964
|
+
if (routed === void 0) return argv;
|
|
5965
|
+
state.statements = statementsOf(routed.def);
|
|
5966
|
+
const extraction = extractStatementFlags(argv, state.statements);
|
|
5967
|
+
if (!extraction.ok) {
|
|
5968
|
+
state.commandId = routed.id;
|
|
5969
|
+
state.docsBaseUrl = routed.docsBaseUrl;
|
|
5970
|
+
state.snapshot = buildCommandSnapshot(routed.id, routed.def, argv, []);
|
|
5971
|
+
settleErrored(invocation, extraction.error);
|
|
5972
|
+
this.fireOnSettled(invocation, 2, startedAtMs);
|
|
5973
|
+
return;
|
|
5974
|
+
}
|
|
5975
|
+
state.statementValues = extraction.values;
|
|
5976
|
+
return extraction.argv;
|
|
5977
|
+
}
|
|
5978
|
+
/** A retired path beneath a mounted command, such as `dev up` beside
|
|
5979
|
+
* `dev`. The parser would hand `up` to `dev` as a positional, so the
|
|
5980
|
+
* redirect is matched first: a retired child's name wins over the
|
|
5981
|
+
* positional, as a live child's name does. */
|
|
5982
|
+
retiredPathBeneathCommand(argv) {
|
|
5983
|
+
const routed = routedCommand(this.tree, argv);
|
|
5984
|
+
if (routed === void 0) return;
|
|
5985
|
+
const redirect = matchVerbRedirect(this.redirects, attemptedPath(argv));
|
|
5986
|
+
return redirect !== void 0 && redirect.from.split(" ").length > routed.id.split(".").length ? redirect : void 0;
|
|
5987
|
+
}
|
|
5473
5988
|
/** stricli routed or parsed nothing runnable. When the redirect table
|
|
5474
5989
|
* claims the invocation the user typed, the run names its
|
|
5475
5990
|
* replacement; otherwise it settles as the usage error it is. */
|
|
@@ -5534,7 +6049,9 @@ var EngineImpl = class {
|
|
|
5534
6049
|
const result = await runHandler();
|
|
5535
6050
|
if (await this.settleAbandonedChild(invocation, false)) return;
|
|
5536
6051
|
state.resolved = true;
|
|
6052
|
+
const unused = unusedConsentError(state);
|
|
5537
6053
|
if (!result.ok) settleErrored(invocation, result.failure, result.failure.diagnostics);
|
|
6054
|
+
else if (unused !== void 0 && succeeded(state, result.value)) settleErrored(invocation, unused);
|
|
5538
6055
|
else if (isChildStatusSettlement(result.value)) settleChildStatus(invocation, entry.def, result.value);
|
|
5539
6056
|
else settleCompletion(result.value);
|
|
5540
6057
|
} catch (cause) {
|
|
@@ -5660,6 +6177,10 @@ var EngineImpl = class {
|
|
|
5660
6177
|
}
|
|
5661
6178
|
}
|
|
5662
6179
|
};
|
|
6180
|
+
function succeeded(state, value) {
|
|
6181
|
+
if (!isChildStatusSettlement(value)) return true;
|
|
6182
|
+
return state.lastChild !== void 0 && childExitCode(state.lastChild) === 0;
|
|
6183
|
+
}
|
|
5663
6184
|
/** The path the user typed, for argv that routed to no command: the
|
|
5664
6185
|
* leading tokens up to the first flag or argument escape. */
|
|
5665
6186
|
function attemptedPath(argv) {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as defineConfigSection, $t as ManagementApiClientConfig, A as StatementAnswer, At as PackageManagerRunResult, B as PresentedResult, Bt as positional, C as defineServerCommand, Ct as SpawnChild, D as OpenUrlOutcome, Dt as exitWithChildStatus, E as CommandContext, Et as SpawnedChild, F as Block, Ft as Char, G as TreeNode, Gt as CredentialManager, H as Status, Ht as ActiveCredential, I as Format, It as CommandArgs, J as Severity, Jt as Session, K as Ui, Kt as CredentialOrigin, L as Outcome, Lt as FlagSpec, M as StatementQuestion, Mt as PackageOperations, N as StatementSurface, Nt as Args, O as OpenUrlRequest, Ot as PackageManagerId, P as StatementsOptions, Pt as ArgsSpec, Q as SectionValidation, Qt as ManagementApiClient, R as PRESENTED, Rt as PositionalSpec, S as defineCommand, St as ExitWithChildStatusOptions, T as BrowserWaitRequest, Tt as SpawnRequest, U as Text, Ut as Credential, V as Span, Vt as ActiveAccessTokenOptions, W as Tone, Wt as CredentialIdentity, X as StreamMeta, Xt as CredentialRefreshResult, Y as StreamEvent, Yt as StoredSessions, Z as ConfigSection, Zt as CredentialRefresher, _ as ServerCommandDefinition, _t as TelemetryPayload, a as RedirectSpec, at as ResolvedSection, b as StatementSpec, bt as ChildResult, c as CommandDefinition, ct as resolveSectionPath, d as CommandNeeds, dt as InputStream, en as TokenStorage, et as ConfigSchema, f as CompletedEnvelope, ft as LoadedConfig, g as NeedsSpec, gt as Runtime, h as HelpSpec, ht as PRISMA_CONFIG_VERSION, i as MountedTree, it as validateSectionWithSchema, j as StatementOptions, jt as PackageManagerRunner, k as PromptSurface, kt as PackageManagerRunRequest, l as CommandHandler, lt as Host, m as Handler, mt as OutputStream, n as CommandFamily, nt as configSchema, o as defineCommandFamily, ot as SectionProvenance, p as ErroredEnvelope, pt as LoadedConfigFile, q as EngineEvent, qt as SERVICE_TOKEN_ENV_VAR, r as CommandRedirect, rt as reference, s as AnyCommand, st as resolveSectionOverChain, t as TelemetryDeclaration, tt as ConfigSchemaValue, u as CommandHelp, ut as HostProcess, v as SessionCommandDefinition, vt as EngineCommandSnapshot, w as defineSessionCommand, wt as SpawnOptions, x as WorkflowStep, xt as ChildStatusSettlement, y as SpawnDeclarations, yt as RunSummary, z as Presentations, zt as flag } from "./report-CQ30sy_e.js";
|
|
2
2
|
import { n as CliStructuredError } from "./protocol-YjqPCCOG.js";
|
|
3
3
|
|
|
4
4
|
//#region src/active-access-token.d.ts
|
|
@@ -37,8 +37,10 @@ interface Cli {
|
|
|
37
37
|
run(argv: readonly string[], runtime: Runtime, hooks?: CliRunHooks): Promise<number>;
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
|
-
* Shell-side construction. Group help is declared with the mount.
|
|
41
|
-
*
|
|
40
|
+
* Shell-side construction. Group help is declared with the mount. A
|
|
41
|
+
* path may be both a command and a group (`dev` beside `dev url`); a
|
|
42
|
+
* child's name wins over the command's positional. Redirects onto
|
|
43
|
+
* mounted paths, unknown groups, reserved-flag violations, grammar
|
|
42
44
|
* violations, and foreign-section references fail construction (build
|
|
43
45
|
* time, not run time).
|
|
44
46
|
*/
|
|
@@ -225,4 +227,4 @@ declare function claimedExpiresAt(token: string): Date | undefined;
|
|
|
225
227
|
*/
|
|
226
228
|
declare function claimedIdentity(token: string): CredentialIdentity | undefined;
|
|
227
229
|
//#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, reference, resolveSectionOverChain, resolveSectionPath, telemetryCommandGroup, validateSectionWithSchema };
|
|
230
|
+
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 StatementAnswer, type StatementOptions, type StatementQuestion, type StatementSpec, type StatementSurface, type StatementsOptions, 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,11 +1,13 @@
|
|
|
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-BE7WKK2X.js";
|
|
3
3
|
import { dirname, isAbsolute, resolve } from "node:path";
|
|
4
4
|
import { scope, type } from "arktype";
|
|
5
5
|
//#region src/cli.ts
|
|
6
6
|
/**
|
|
7
|
-
* Shell-side construction. Group help is declared with the mount.
|
|
8
|
-
*
|
|
7
|
+
* Shell-side construction. Group help is declared with the mount. A
|
|
8
|
+
* path may be both a command and a group (`dev` beside `dev url`); a
|
|
9
|
+
* child's name wins over the command's positional. Redirects onto
|
|
10
|
+
* mounted paths, unknown groups, reserved-flag violations, grammar
|
|
9
11
|
* violations, and foreign-section references fail construction (build
|
|
10
12
|
* time, not run time).
|
|
11
13
|
*/
|
|
@@ -69,10 +71,12 @@ function defineCommand(def) {
|
|
|
69
71
|
managesCredentials: def.managesCredentials ?? false,
|
|
70
72
|
maySpawn: def.maySpawn ?? false,
|
|
71
73
|
installsPackages: def.installsPackages ?? false,
|
|
74
|
+
statements: Object.freeze({ ...def.statements }),
|
|
72
75
|
handler: def.handler
|
|
73
76
|
});
|
|
74
77
|
}
|
|
75
78
|
function defineSessionCommand(def) {
|
|
79
|
+
if (Object.hasOwn(def, "statements")) throw new Error("@prisma/cli-engine: a session command cannot declare statements (only a result command asks them)");
|
|
76
80
|
return Object.freeze({
|
|
77
81
|
kind: "session-command",
|
|
78
82
|
help: normalizeHelp(def.help),
|
|
@@ -83,6 +87,7 @@ function defineSessionCommand(def) {
|
|
|
83
87
|
});
|
|
84
88
|
}
|
|
85
89
|
function defineServerCommand(def) {
|
|
90
|
+
if (Object.hasOwn(def, "statements")) throw new Error("@prisma/cli-engine: a server command cannot declare statements (it never prompts)");
|
|
86
91
|
return Object.freeze({
|
|
87
92
|
kind: "server-command",
|
|
88
93
|
help: normalizeHelp(def.help),
|
|
@@ -1254,6 +1254,8 @@ interface CommandContext<TConfig = undefined, TCode extends number = never> {
|
|
|
1254
1254
|
readonly report: (event: EngineEvent) => void;
|
|
1255
1255
|
/** Interactive input. */
|
|
1256
1256
|
readonly prompt: PromptSurface;
|
|
1257
|
+
/** The command's declared statement flags, read as its own input. */
|
|
1258
|
+
readonly statements: StatementSurface;
|
|
1257
1259
|
/**
|
|
1258
1260
|
* Shows the user a URL and, in an interactive session, opens it in
|
|
1259
1261
|
* their browser. Always announces the URL on the commentary channel
|
|
@@ -1332,6 +1334,62 @@ interface BrowserWaitRequest {
|
|
|
1332
1334
|
* interval; a command with its own configurable cadence passes it. */
|
|
1333
1335
|
readonly interval?: number;
|
|
1334
1336
|
}
|
|
1337
|
+
interface StatementOptions<V extends string> {
|
|
1338
|
+
/** What the answer is about, in the command's own vocabulary.
|
|
1339
|
+
* Non-empty; an empty subject is a construction error. A flag value
|
|
1340
|
+
* names it when it equals the subject or starts with `<subject>:`.
|
|
1341
|
+
* Within one batch a value equal to a subject answers that subject
|
|
1342
|
+
* first, and any other value goes to the longest subject it names,
|
|
1343
|
+
* so ask questions whose subjects are prefixes of one another (`A`
|
|
1344
|
+
* and `A:B`) in one `statements` call. */
|
|
1345
|
+
readonly subject: string;
|
|
1346
|
+
/** The verbs that may answer, in the order a refusal lists them. */
|
|
1347
|
+
readonly verbs: readonly V[];
|
|
1348
|
+
/** How a refusal writes a verb's flag value, such as
|
|
1349
|
+
* `Legacy:<new name>`. A verb without one is written with the
|
|
1350
|
+
* subject. */
|
|
1351
|
+
readonly forms?: Partial<Record<V, string>>;
|
|
1352
|
+
/** Returns undefined to accept the answer, or a message saying why it
|
|
1353
|
+
* is rejected. The engine never interprets the text. */
|
|
1354
|
+
readonly validate: (verb: V, text: string) => string | undefined;
|
|
1355
|
+
}
|
|
1356
|
+
interface StatementQuestion<V extends string> extends StatementOptions<V> {
|
|
1357
|
+
readonly question: string;
|
|
1358
|
+
}
|
|
1359
|
+
interface StatementAnswer<V extends string> {
|
|
1360
|
+
readonly verb: V;
|
|
1361
|
+
/** The values joined by one space. */
|
|
1362
|
+
readonly text: string;
|
|
1363
|
+
/** The verb's `arity` values: from the flag, or split from the
|
|
1364
|
+
* typed answer on whitespace. */
|
|
1365
|
+
readonly values: readonly string[];
|
|
1366
|
+
}
|
|
1367
|
+
interface StatementSurface {
|
|
1368
|
+
/**
|
|
1369
|
+
* Every unconsumed value of `verb`, in argv order, consumed so the
|
|
1370
|
+
* leftover check does not report them. For statements that are input
|
|
1371
|
+
* to the command's work rather than answers to a question; other
|
|
1372
|
+
* verbs' values stay for the questions. A verb the command did not
|
|
1373
|
+
* declare is a construction error. A later question may still list a
|
|
1374
|
+
* taken verb: no flag value of it is left to answer the question, so
|
|
1375
|
+
* the verb serves the refusal's flag form and the typed answer.
|
|
1376
|
+
*/
|
|
1377
|
+
readonly take: <V extends string>(verb: V) => StatementAnswer<V>[];
|
|
1378
|
+
/**
|
|
1379
|
+
* Every unconsumed value of every verb, in argv order, without
|
|
1380
|
+
* consuming any: for showing the statements a run was given, such as
|
|
1381
|
+
* in a line that repeats the command.
|
|
1382
|
+
*/
|
|
1383
|
+
readonly values: () => StatementAnswer<string>[];
|
|
1384
|
+
}
|
|
1385
|
+
interface StatementsOptions {
|
|
1386
|
+
/** This is the run's final ask: values still unconsumed once the
|
|
1387
|
+
* questions are answered fail with CLI.CONSENT_UNUSED here, before
|
|
1388
|
+
* the command acts on the answers. Take any verbs you take, and ask
|
|
1389
|
+
* any consent with a token, before the `last` batch: it reports
|
|
1390
|
+
* their flags as unused at once. */
|
|
1391
|
+
readonly last?: boolean;
|
|
1392
|
+
}
|
|
1335
1393
|
/**
|
|
1336
1394
|
* Prompts. Every prompt resolves to its answered value directly.
|
|
1337
1395
|
* Failures THROW engine-internal structured errors the engine catches
|
|
@@ -1340,12 +1398,17 @@ interface BrowserWaitRequest {
|
|
|
1340
1398
|
* 2. A handler that does not catch simply propagates; one that catches
|
|
1341
1399
|
* cannot swallow the settlement — rethrow or return notOk.
|
|
1342
1400
|
*
|
|
1343
|
-
* Every prompt except `consent` may carry a declared `default`. Under
|
|
1401
|
+
* Every prompt except `consent` and `statement` may carry a declared `default`. Under
|
|
1344
1402
|
* --yes and in non-interactive contexts (no TTY stdin, CI,
|
|
1345
1403
|
* --no-interactive — format never decides interactivity) a prompt with
|
|
1346
1404
|
* a default resolves to it; one without a default throws. The prompt UI
|
|
1347
1405
|
* writes to stderr, so an interactive json run prompts without touching
|
|
1348
1406
|
* the stdout stream.
|
|
1407
|
+
*
|
|
1408
|
+
* A SIGINT or SIGTERM delivered while a prompt waits cancels it with
|
|
1409
|
+
* CLI.PROMPT_CANCELLED (exit 3 for SIGINT, 143 for SIGTERM). The
|
|
1410
|
+
* cancellation holds for the rest of the run: every later prompt is
|
|
1411
|
+
* cancelled at once, and a further signal force-exits.
|
|
1349
1412
|
*/
|
|
1350
1413
|
interface PromptSurface {
|
|
1351
1414
|
readonly confirm: (question: string, opts?: {
|
|
@@ -1367,6 +1430,29 @@ interface PromptSurface {
|
|
|
1367
1430
|
readonly consent: (question: string, opts?: {
|
|
1368
1431
|
readonly token?: string;
|
|
1369
1432
|
}) => Promise<boolean>;
|
|
1433
|
+
/**
|
|
1434
|
+
* A consent answered with a verb and free text: what the user means
|
|
1435
|
+
* should happen to `subject`. Like `consent`, `--yes` and Enter never
|
|
1436
|
+
* answer it.
|
|
1437
|
+
*
|
|
1438
|
+
* A `--<verb>` flag whose value names the subject answers it first,
|
|
1439
|
+
* in any session, without rendering anything: the value names the
|
|
1440
|
+
* subject when it is the subject or starts with `<subject>:`. A
|
|
1441
|
+
* value `validate` rejects fails the run with `CLI.PROMPT_INVALID`.
|
|
1442
|
+
* Without such a flag a non-interactive run, or one under `--yes`,
|
|
1443
|
+
* fails with `CLI.CONSENT_REQUIRED`; an interactive run asks, and the
|
|
1444
|
+
* user answers `<verb> <text>`, or `<verb>` alone to mean the subject.
|
|
1445
|
+
* Each verb must be one the command declares in `statements`; the
|
|
1446
|
+
* flag takes that declaration's `arity` values per occurrence.
|
|
1447
|
+
*/
|
|
1448
|
+
readonly statement: <V extends string>(question: string, opts: StatementOptions<V>) => Promise<StatementAnswer<V>>;
|
|
1449
|
+
/**
|
|
1450
|
+
* Several statements asked together, answered in order. Flags answer
|
|
1451
|
+
* what they can; a refusal names every question still unanswered at
|
|
1452
|
+
* once, and an interactive run asks them one after another.
|
|
1453
|
+
* `statement(question, opts)` is `statements([{ question, ...opts }])`.
|
|
1454
|
+
*/
|
|
1455
|
+
readonly statements: <V extends string>(questions: readonly StatementQuestion<V>[], opts?: StatementsOptions) => Promise<StatementAnswer<V>[]>;
|
|
1370
1456
|
readonly select: <T extends string>(question: string, options: ReadonlyArray<{
|
|
1371
1457
|
value: T;
|
|
1372
1458
|
label: string;
|
|
@@ -1491,6 +1577,22 @@ interface CommandNeeds<TConfig> {
|
|
|
1491
1577
|
interface SpawnDeclarations {
|
|
1492
1578
|
readonly maySpawn?: boolean;
|
|
1493
1579
|
}
|
|
1580
|
+
/**
|
|
1581
|
+
* A statement the command may ask for with ctx.prompt.statement. Its
|
|
1582
|
+
* key is the verb, one lowercase word, and the command alone accepts
|
|
1583
|
+
* `--<verb>` followed by `arity` values, repeatable, to answer it. The
|
|
1584
|
+
* values stay out of the handler's flags; the handler reads them
|
|
1585
|
+
* through ctx.prompt.statement or ctx.statements.take.
|
|
1586
|
+
*/
|
|
1587
|
+
interface StatementSpec {
|
|
1588
|
+
/** How many argv values each occurrence of the flag takes. Giving
|
|
1589
|
+
* another number is CLI.INVALID_ARGUMENTS. Only the first value can
|
|
1590
|
+
* be written `--<verb>=<value>`, so with an arity above 1 a later
|
|
1591
|
+
* value starting with `-` cannot be passed. */
|
|
1592
|
+
readonly arity: number;
|
|
1593
|
+
/** The flag's help brief, held to the help standard like any flag's. */
|
|
1594
|
+
readonly brief?: string;
|
|
1595
|
+
}
|
|
1494
1596
|
interface CommandDefinition<TFlags extends Record<string, FlagSpec<unknown>> = Record<never, FlagSpec<unknown>>, TPositionals extends Record<string, PositionalSpec<unknown>> = Record<never, PositionalSpec<unknown>>, TConfig = undefined, TCode extends number = never, TManagesCredentials extends boolean = false, TInstallsPackages extends boolean = false> {
|
|
1495
1597
|
readonly kind: "result-command";
|
|
1496
1598
|
readonly help: CommandHelp;
|
|
@@ -1519,6 +1621,9 @@ interface CommandDefinition<TFlags extends Record<string, FlagSpec<unknown>> = R
|
|
|
1519
1621
|
* user's project. Declaring it never fails a run.
|
|
1520
1622
|
*/
|
|
1521
1623
|
readonly installsPackages: TInstallsPackages;
|
|
1624
|
+
/** The statements ctx.prompt.statement may ask, by verb. Optional
|
|
1625
|
+
* because a command built by an older engine has none. */
|
|
1626
|
+
readonly statements?: Readonly<Record<string, StatementSpec>>;
|
|
1522
1627
|
/**
|
|
1523
1628
|
* The handler function, referenced directly — never a dynamic import
|
|
1524
1629
|
* (operator ruling, 2026-08-09). A handler that needs heavy
|
|
@@ -1542,6 +1647,7 @@ declare function defineCommand<TFlags extends Record<string, FlagSpec<unknown>>
|
|
|
1542
1647
|
readonly exitCodes?: Readonly<Record<TCode, string>>;
|
|
1543
1648
|
readonly managesCredentials?: TManagesCredentials;
|
|
1544
1649
|
readonly installsPackages?: TInstallsPackages;
|
|
1650
|
+
readonly statements?: Readonly<Record<string, StatementSpec>>;
|
|
1545
1651
|
readonly handler: Handler<TFlags, TPositionals, TConfig, TCode, TManagesCredentials, TInstallsPackages>;
|
|
1546
1652
|
} & SpawnDeclarations): CommandDefinition<TFlags, TPositionals, TConfig, TCode, TManagesCredentials, TInstallsPackages>;
|
|
1547
1653
|
/**
|
|
@@ -1729,4 +1835,4 @@ interface TelemetryDeclaration {
|
|
|
1729
1835
|
readonly docsUrl: string;
|
|
1730
1836
|
}
|
|
1731
1837
|
//#endregion
|
|
1732
|
-
export {
|
|
1838
|
+
export { defineConfigSection as $, ManagementApiClientConfig as $t, StatementAnswer as A, PackageManagerRunResult as At, PresentedResult as B, positional as Bt, defineServerCommand as C, SpawnChild as Ct, OpenUrlOutcome as D, exitWithChildStatus as Dt, CommandContext as E, SpawnedChild as Et, Block as F, Char as Ft, TreeNode as G, CredentialManager as Gt, Status as H, ActiveCredential as Ht, Format as I, CommandArgs as It, Severity as J, Session as Jt, Ui as K, CredentialOrigin as Kt, Outcome as L, FlagSpec as Lt, StatementQuestion as M, PackageOperations as Mt, StatementSurface as N, Args as Nt, OpenUrlRequest as O, PackageManagerId as Ot, StatementsOptions as P, ArgsSpec as Pt, SectionValidation as Q, ManagementApiClient$1 as Qt, PRESENTED as R, PositionalSpec as Rt, defineCommand as S, ExitWithChildStatusOptions as St, BrowserWaitRequest as T, SpawnRequest as Tt, Text as U, Credential as Ut, Span as V, ActiveAccessTokenOptions as Vt, Tone as W, CredentialIdentity as Wt, StreamMeta as X, CredentialRefreshResult as Xt, StreamEvent as Y, StoredSessions as Yt, ConfigSection as Z, CredentialRefresher as Zt, ServerCommandDefinition as _, TelemetryPayload as _t, RedirectSpec as a, ResolvedSection as at, StatementSpec as b, ChildResult as bt, CommandDefinition as c, resolveSectionPath as ct, CommandNeeds as d, InputStream as dt, TokenStorage$1 as en, ConfigSchema as et, CompletedEnvelope as f, LoadedConfig as ft, NeedsSpec as g, Runtime as gt, HelpSpec as h, PRISMA_CONFIG_VERSION as ht, MountedTree as i, validateSectionWithSchema as it, StatementOptions as j, PackageManagerRunner as jt, PromptSurface as k, PackageManagerRunRequest as kt, CommandHandler as l, Host as lt, Handler as m, OutputStream as mt, CommandFamily as n, configSchema as nt, defineCommandFamily as o, SectionProvenance as ot, ErroredEnvelope as p, LoadedConfigFile as pt, EngineEvent as q, SERVICE_TOKEN_ENV_VAR as qt, CommandRedirect as r, reference as rt, AnyCommand as s, resolveSectionOverChain as st, TelemetryDeclaration as t, ConfigSchemaValue as tt, CommandHelp as u, HostProcess as ut, SessionCommandDefinition as v, EngineCommandSnapshot as vt, defineSessionCommand as w, SpawnOptions as wt, WorkflowStep as x, ChildStatusSettlement as xt, SpawnDeclarations as y, RunSummary as yt, Presentations as z, flag as zt };
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { $t as ManagementApiClientConfig, B as PresentedResult, Ct as SpawnChild, Gt as CredentialManager, Ht as ActiveCredential, Jt as Session, Ot as PackageManagerId, Qt as ManagementApiClient, Tt as SpawnRequest, Ut as Credential, Vt as ActiveAccessTokenOptions, Y as StreamEvent, Yt as StoredSessions, Zt as CredentialRefresher, _t as TelemetryPayload, bt as ChildResult, en as TokenStorage, gt as Runtime, i as MountedTree, jt as PackageManagerRunner, lt as Host, n as CommandFamily, q as EngineEvent, t as TelemetryDeclaration, x as WorkflowStep, yt as RunSummary } from "./report-CQ30sy_e.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-BE7WKK2X.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.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "The execution engine of the unified Prisma CLI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@prisma/management-api-sdk": "1.80.0",
|
|
56
|
-
"@repo/cli-conformance": "8.0.0-rc.
|
|
57
|
-
"@repo/tsconfig": "8.0.0-rc.
|
|
56
|
+
"@repo/cli-conformance": "8.0.0-rc.23-dev.152",
|
|
57
|
+
"@repo/tsconfig": "8.0.0-rc.23-dev.152",
|
|
58
58
|
"@types/node": "^22.19.19",
|
|
59
59
|
"ci-info": "^4.3.1",
|
|
60
60
|
"tsdown": "^0.21.10",
|