@kubb/cli 5.10.1 → 5.10.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Telemetry-BfdvvZus.cjs → Telemetry-BV4GonCV.cjs} +2 -2
- package/dist/Telemetry-BV4GonCV.cjs.map +1 -0
- package/dist/Telemetry-CH2kkxWK.cjs +322 -0
- package/dist/Telemetry-CH2kkxWK.cjs.map +1 -0
- package/dist/{Telemetry-Bf6lUdai.js → Telemetry-Cz9QCzRo.js} +2 -2
- package/dist/Telemetry-Cz9QCzRo.js.map +1 -0
- package/dist/{background-D5K6ecEo.js → background-DFME5huR.js} +30 -7
- package/dist/background-DFME5huR.js.map +1 -0
- package/dist/{background-obsD4Gj2.cjs → background-DVZB1n4j.cjs} +25 -6
- package/dist/background-DVZB1n4j.cjs.map +1 -0
- package/dist/background-WaKtfQWr.cjs +192 -0
- package/dist/background-WaKtfQWr.cjs.map +1 -0
- package/dist/{background-C8doa9-4.js → background-_A5NwvYH.js} +1 -1
- package/dist/{config-CcqzzfB7.cjs → config-DKAqX5sW.cjs} +18 -4
- package/dist/config-DKAqX5sW.cjs.map +1 -0
- package/dist/{config-IMZ26zcb.js → config-DV_7s1m-.js} +19 -5
- package/dist/config-DV_7s1m-.js.map +1 -0
- package/dist/config-OL_izsmp.cjs +113 -0
- package/dist/config-OL_izsmp.cjs.map +1 -0
- package/dist/credentials-xOkTTDWj.cjs +113 -0
- package/dist/credentials-xOkTTDWj.cjs.map +1 -0
- package/dist/index.cjs +65 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.js +65 -24
- package/dist/index.js.map +1 -1
- package/dist/output-C5g7AtWH.cjs +1008 -0
- package/dist/output-C5g7AtWH.cjs.map +1 -0
- package/dist/{output-mwVt_Vj9.js → output-D_gc1nrM.js} +99 -44
- package/dist/output-D_gc1nrM.js.map +1 -0
- package/dist/{output-DLrxGtuN.cjs → output-nieBFDgM.cjs} +104 -43
- package/dist/output-nieBFDgM.cjs.map +1 -0
- package/dist/{registry-x-_nbYR6.cjs → registry-C8E_G7Xc.cjs} +49 -15
- package/dist/registry-C8E_G7Xc.cjs.map +1 -0
- package/dist/registry-CIpW2zQc.cjs +157 -0
- package/dist/registry-CIpW2zQc.cjs.map +1 -0
- package/dist/{registry-ChqX2AFQ.js → registry-De1vVn1d.js} +50 -16
- package/dist/registry-De1vVn1d.js.map +1 -0
- package/dist/rolldown-runtime-C0BPl7ul.cjs +43 -0
- package/dist/run-BbhrOuK6.cjs +40 -0
- package/dist/{run-1MJA0P5x.cjs.map → run-BbhrOuK6.cjs.map} +1 -1
- package/dist/{run-DHiVlG37.cjs → run-BnLba1gt.cjs} +27 -14
- package/dist/run-BnLba1gt.cjs.map +1 -0
- package/dist/{run-D4vOhfbJ.js → run-Bp47k1W1.js} +2 -2
- package/dist/{run-D4vOhfbJ.js.map → run-Bp47k1W1.js.map} +1 -1
- package/dist/run-BpdJ6X75.cjs +32 -0
- package/dist/{run-B13e9GQz.cjs.map → run-BpdJ6X75.cjs.map} +1 -1
- package/dist/{run-Cm0sJO0h.js → run-CCMlmk-z.js} +1 -1
- package/dist/{run-DTz7gAk1.js → run-CPYD1Lp0.js} +27 -14
- package/dist/run-CPYD1Lp0.js.map +1 -0
- package/dist/run-CSOEGpWZ.cjs +326 -0
- package/dist/run-CSOEGpWZ.cjs.map +1 -0
- package/dist/{run-B13e9GQz.cjs → run-CvE8ZdKG.cjs} +2 -2
- package/dist/run-CvE8ZdKG.cjs.map +1 -0
- package/dist/{run-Cu3pmezx.js → run-DaFK-Uy2.js} +2 -2
- package/dist/{run-Cu3pmezx.js.map → run-DaFK-Uy2.js.map} +1 -1
- package/dist/{run-BAlcXyYw.js → run-Ij84bqza.js} +22 -16
- package/dist/run-Ij84bqza.js.map +1 -0
- package/dist/{run-1MJA0P5x.cjs → run-MFjzBB_M.cjs} +2 -2
- package/dist/run-MFjzBB_M.cjs.map +1 -0
- package/dist/run-hgSZImuK.cjs +345 -0
- package/dist/run-hgSZImuK.cjs.map +1 -0
- package/dist/{run-CUyhuGlK.cjs → run-hyi91b22.cjs} +22 -16
- package/dist/run-hyi91b22.cjs.map +1 -0
- package/dist/{snapshot-DCG-Jf1A.js → snapshot-B6w3BLum.js} +22 -9
- package/dist/snapshot-B6w3BLum.js.map +1 -0
- package/dist/snapshot-DP9Pcnsg.cjs +264 -0
- package/dist/snapshot-DP9Pcnsg.cjs.map +1 -0
- package/dist/{snapshot-C5cthCuU.cjs → snapshot-D_F4XkYQ.cjs} +22 -9
- package/dist/snapshot-D_F4XkYQ.cjs.map +1 -0
- package/dist/studioWorker.js +2 -2
- package/package.json +15 -10
- package/dist/Telemetry-Bf6lUdai.js.map +0 -1
- package/dist/Telemetry-BfdvvZus.cjs.map +0 -1
- package/dist/background-D5K6ecEo.js.map +0 -1
- package/dist/background-obsD4Gj2.cjs.map +0 -1
- package/dist/config-CcqzzfB7.cjs.map +0 -1
- package/dist/config-IMZ26zcb.js.map +0 -1
- package/dist/output-DLrxGtuN.cjs.map +0 -1
- package/dist/output-mwVt_Vj9.js.map +0 -1
- package/dist/registry-ChqX2AFQ.js.map +0 -1
- package/dist/registry-x-_nbYR6.cjs.map +0 -1
- package/dist/run-BAlcXyYw.js.map +0 -1
- package/dist/run-CUyhuGlK.cjs.map +0 -1
- package/dist/run-DHiVlG37.cjs.map +0 -1
- package/dist/run-DTz7gAk1.js.map +0 -1
- package/dist/snapshot-C5cthCuU.cjs.map +0 -1
- package/dist/snapshot-DCG-Jf1A.js.map +0 -1
- package/dist/studioWorker.d.ts +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentials-xOkTTDWj.cjs","names":["process","path","hash","resolveKubbDir","kubbStorage","randomBytes"],"sources":["../src/runners/studio/credentials.ts"],"sourcesContent":["import { hash, randomBytes } from 'node:crypto'\nimport path from 'node:path'\nimport process from 'node:process'\nimport { kubbStorage, resolveKubbDir } from '@kubb/core'\n\nconst projectBase = (project = process.cwd()) => path.join('projects', hash('sha256', project))\n\n/**\n * Root for the credential and machine identity of the current project, inside `KUBB_HOME`.\n *\n * Studio agents are project connections, so two projects on one machine must not share the same\n * persisted token or machine secret.\n */\nexport function getProjectKubbHome(project = process.cwd()): string {\n return resolveKubbDir(projectBase(project))\n}\n\nconst projectStorage = () => kubbStorage({ base: projectBase() })\n\nconst CREDENTIALS_FILENAME = 'credentials.json'\n\n/**\n * Absolute path of the stored credential, so callers can name it in output without rebuilding it.\n */\nexport function getCredentialsPath(): string {\n return path.join(getProjectKubbHome(), CREDENTIALS_FILENAME)\n}\n\nexport type Credentials = {\n /**\n * The Studio instance this machine paired with. A different `--url` means re-pairing.\n */\n studioUrl: string\n /**\n * Bearer token for this machine. Never logged, never printed.\n */\n token: string\n agentId: string\n agentSlug: string\n /**\n * Permissions the user has already granted, keyed by absolute project path, so the CLI asks\n * once per project instead of on every run.\n */\n projects?: Record<string, { allowRead?: boolean; allowReadAst?: boolean; allowWrite?: boolean; allowConfigEdit?: boolean; allowExec?: boolean }>\n}\n\n/**\n * Reads the stored credential, or null when this machine has not paired yet or the file is\n * unreadable or corrupt. A bad file is treated as \"not paired\" so `kubb studio login` can\n * overwrite it rather than the CLI dying on it.\n */\nexport async function readCredentials(): Promise<Credentials | null> {\n const stored = await projectStorage()\n .getItem<Credentials>(CREDENTIALS_FILENAME)\n .catch(() => null)\n\n return typeof stored?.token === 'string' && stored.token !== '' ? stored : null\n}\n\n/**\n * Writes the credential into the project folder, which only its owner can open.\n */\nexport async function writeCredentials(credentials: Credentials): Promise<void> {\n await projectStorage().setItem(CREDENTIALS_FILENAME, credentials)\n}\n\n/**\n * Forgets the stored credential. Succeeds when there was nothing to forget.\n */\nexport async function clearCredentials(): Promise<void> {\n await projectStorage().removeItem(CREDENTIALS_FILENAME)\n}\n\n/**\n * Reads this project's machine secret, creating it on first use. Pairing sends its hash, so pairing\n * the same project again rotates one agent's token instead of creating a second agent. It lives\n * apart from the credential, which {@link clearCredentials} deletes.\n */\nexport async function getMachineId(): Promise<string> {\n const storage = projectStorage()\n const stored = await storage.getItem('machine-secret').catch(() => null)\n if (typeof stored === 'string' && stored.trim()) return stored.trim()\n\n const secret = randomBytes(32).toString('hex')\n await storage.setItem('machine-secret', secret)\n\n return secret\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAKA,MAAM,eAAe,UAAUA,aAAAA,QAAQ,IAAI,MAAMC,UAAAA,QAAK,KAAK,aAAA,GAAYC,YAAAA,KAAAA,CAAK,UAAU,OAAO,CAAC;;;;;;;AAQ9F,SAAgB,mBAAmB,UAAUF,aAAAA,QAAQ,IAAI,GAAW;CAClE,QAAA,GAAOG,WAAAA,eAAAA,CAAe,YAAY,OAAO,CAAC;AAC5C;AAEA,MAAM,wBAAA,GAAuBC,WAAAA,YAAAA,CAAY,EAAE,MAAM,YAAY,EAAE,CAAC;AAEhE,MAAM,uBAAuB;;;;AAK7B,SAAgB,qBAA6B;CAC3C,OAAOH,UAAAA,QAAK,KAAK,mBAAmB,GAAG,oBAAoB;AAC7D;;;;;;AAyBA,eAAsB,kBAA+C;CACnE,MAAM,SAAS,MAAM,eAAe,CAAC,CAClC,QAAqB,oBAAoB,CAAC,CAC1C,YAAY,IAAI;CAEnB,OAAO,OAAO,QAAQ,UAAU,YAAY,OAAO,UAAU,KAAK,SAAS;AAC7E;;;;AAKA,eAAsB,iBAAiB,aAAyC;CAC9E,MAAM,eAAe,CAAC,CAAC,QAAQ,sBAAsB,WAAW;AAClE;;;;AAKA,eAAsB,mBAAkC;CACtD,MAAM,eAAe,CAAC,CAAC,WAAW,oBAAoB;AACxD;;;;;;AAOA,eAAsB,eAAgC;CACpD,MAAM,UAAU,eAAe;CAC/B,MAAM,SAAS,MAAM,QAAQ,QAAQ,gBAAgB,CAAC,CAAC,YAAY,IAAI;CACvE,IAAI,OAAO,WAAW,YAAY,OAAO,KAAK,GAAG,OAAO,OAAO,KAAK;CAEpE,MAAM,UAAA,GAASI,YAAAA,YAAAA,CAAY,EAAE,CAAC,CAAC,SAAS,KAAK;CAC7C,MAAM,QAAQ,QAAQ,kBAAkB,MAAM;CAE9C,OAAO;AACT"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_rolldown_runtime = require("./rolldown-runtime-CPE0t6oh.cjs");
|
|
3
|
-
const require_Telemetry = require("./Telemetry-
|
|
4
|
-
const require_output = require("./output-
|
|
5
|
-
const require_registry = require("./registry-
|
|
3
|
+
const require_Telemetry = require("./Telemetry-BV4GonCV.cjs");
|
|
4
|
+
const require_output = require("./output-nieBFDgM.cjs");
|
|
5
|
+
const require_registry = require("./registry-C8E_G7Xc.cjs");
|
|
6
6
|
let node_util = require("node:util");
|
|
7
7
|
let _gunshi_plugin_dryrun = require("@gunshi/plugin-dryrun");
|
|
8
8
|
_gunshi_plugin_dryrun = require_rolldown_runtime.__toESM(_gunshi_plugin_dryrun, 1);
|
|
@@ -12,11 +12,11 @@ node_process = require_rolldown_runtime.__toESM(node_process, 1);
|
|
|
12
12
|
let tinyexec = require("tinyexec");
|
|
13
13
|
let node_path = require("node:path");
|
|
14
14
|
node_path = require_rolldown_runtime.__toESM(node_path, 1);
|
|
15
|
+
let _kubb_core = require("@kubb/core");
|
|
15
16
|
let _clack_prompts = require("@clack/prompts");
|
|
16
17
|
_clack_prompts = require_rolldown_runtime.__toESM(_clack_prompts, 1);
|
|
17
18
|
let node_fs = require("node:fs");
|
|
18
19
|
node_fs = require_rolldown_runtime.__toESM(node_fs, 1);
|
|
19
|
-
let _kubb_core = require("@kubb/core");
|
|
20
20
|
//#region src/commands/shared.ts
|
|
21
21
|
const configArg = { config: {
|
|
22
22
|
type: "string",
|
|
@@ -96,7 +96,12 @@ const REPORTER_NAMES = [
|
|
|
96
96
|
*/
|
|
97
97
|
function parseReporters(value) {
|
|
98
98
|
const names = value.split(",").map((name) => name.trim()).filter(Boolean);
|
|
99
|
-
for (const name of names) if (!REPORTER_NAMES.includes(name)) throw new Error(
|
|
99
|
+
for (const name of names) if (!REPORTER_NAMES.includes(name)) throw new _kubb_core.Diagnostics.Error({
|
|
100
|
+
code: _kubb_core.Diagnostics.code.unknown,
|
|
101
|
+
severity: "error",
|
|
102
|
+
message: `must be one of cli, json, file, html (got "${name}")`,
|
|
103
|
+
help: "Use one of cli, json, file, html."
|
|
104
|
+
});
|
|
100
105
|
return names;
|
|
101
106
|
}
|
|
102
107
|
/**
|
|
@@ -157,7 +162,7 @@ const command$13 = (0, gunshi.defineWithTypes)()({
|
|
|
157
162
|
async run(ctx) {
|
|
158
163
|
const { values } = ctx;
|
|
159
164
|
const logLevel = resolveLogLevel(values);
|
|
160
|
-
const { run } = await Promise.resolve().then(() => require("./run-
|
|
165
|
+
const { run } = await Promise.resolve().then(() => require("./run-hyi91b22.cjs"));
|
|
161
166
|
await run({
|
|
162
167
|
input: values.input,
|
|
163
168
|
configPath: values.config,
|
|
@@ -181,7 +186,7 @@ const command$12 = (0, gunshi.define)({
|
|
|
181
186
|
].join("\n"),
|
|
182
187
|
rendering: { header: null },
|
|
183
188
|
async run() {
|
|
184
|
-
const { run } = await Promise.resolve().then(() => require("./run-
|
|
189
|
+
const { run } = await Promise.resolve().then(() => require("./run-CvE8ZdKG.cjs"));
|
|
185
190
|
await run();
|
|
186
191
|
}
|
|
187
192
|
});
|
|
@@ -196,7 +201,7 @@ function studioCommand({ action, block, ...definition }) {
|
|
|
196
201
|
...definition,
|
|
197
202
|
toKebab: true,
|
|
198
203
|
async run({ values }) {
|
|
199
|
-
const { runStudio } = await Promise.resolve().then(() => require("./run-
|
|
204
|
+
const { runStudio } = await Promise.resolve().then(() => require("./run-BnLba1gt.cjs"));
|
|
200
205
|
await runStudio(values, action, { block });
|
|
201
206
|
}
|
|
202
207
|
});
|
|
@@ -226,7 +231,7 @@ const command$11 = studioCommand({
|
|
|
226
231
|
},
|
|
227
232
|
block: true,
|
|
228
233
|
async action(options) {
|
|
229
|
-
const { connect } = await Promise.resolve().then(() => require("./run-
|
|
234
|
+
const { connect } = await Promise.resolve().then(() => require("./run-BnLba1gt.cjs"));
|
|
230
235
|
await connect(options);
|
|
231
236
|
}
|
|
232
237
|
});
|
|
@@ -238,7 +243,7 @@ const command$10 = studioCommand({
|
|
|
238
243
|
examples: ["kubb studio login", "kubb studio login --url http://localhost:3000"].join("\n"),
|
|
239
244
|
args: command$11.args,
|
|
240
245
|
async action(options) {
|
|
241
|
-
const { login } = await Promise.resolve().then(() => require("./run-
|
|
246
|
+
const { login } = await Promise.resolve().then(() => require("./run-BnLba1gt.cjs"));
|
|
242
247
|
await login(options);
|
|
243
248
|
}
|
|
244
249
|
});
|
|
@@ -250,7 +255,7 @@ const command$9 = studioCommand({
|
|
|
250
255
|
examples: "kubb studio logout",
|
|
251
256
|
args: {},
|
|
252
257
|
async action() {
|
|
253
|
-
const { stopWorker } = await Promise.resolve().then(() => require("./background-
|
|
258
|
+
const { stopWorker } = await Promise.resolve().then(() => require("./background-DVZB1n4j.cjs"));
|
|
254
259
|
const { clearCredentials } = await Promise.resolve().then(() => require("./credentials-DDaKqtJn.cjs")).then((n) => n.credentials_exports);
|
|
255
260
|
await stopWorker();
|
|
256
261
|
await clearCredentials();
|
|
@@ -293,7 +298,7 @@ const command$8 = (0, gunshi.define)({
|
|
|
293
298
|
...logLevelArg
|
|
294
299
|
},
|
|
295
300
|
async run(ctx) {
|
|
296
|
-
const { runner } = await Promise.resolve().then(() => require("./snapshot-
|
|
301
|
+
const { runner } = await Promise.resolve().then(() => require("./snapshot-D_F4XkYQ.cjs"));
|
|
297
302
|
await runner(ctx);
|
|
298
303
|
}
|
|
299
304
|
});
|
|
@@ -304,7 +309,7 @@ const command$7 = studioCommand({
|
|
|
304
309
|
description: "Keep this project connected to Kubb Studio in the background.",
|
|
305
310
|
args: command$11.args,
|
|
306
311
|
async action(options) {
|
|
307
|
-
const { startWorker } = await Promise.resolve().then(() => require("./background-
|
|
312
|
+
const { startWorker } = await Promise.resolve().then(() => require("./background-DVZB1n4j.cjs"));
|
|
308
313
|
await startWorker(options);
|
|
309
314
|
}
|
|
310
315
|
});
|
|
@@ -312,7 +317,7 @@ const stopCommand = (0, gunshi.define)({
|
|
|
312
317
|
name: "stop",
|
|
313
318
|
description: "Stop this project's background connection and keep its pairing.",
|
|
314
319
|
async run() {
|
|
315
|
-
const { stopWorker } = await Promise.resolve().then(() => require("./background-
|
|
320
|
+
const { stopWorker } = await Promise.resolve().then(() => require("./background-DVZB1n4j.cjs"));
|
|
316
321
|
await stopWorker();
|
|
317
322
|
console.log("Background connection stopped.");
|
|
318
323
|
}
|
|
@@ -325,9 +330,9 @@ const command$6 = studioCommand({
|
|
|
325
330
|
examples: "kubb studio status",
|
|
326
331
|
args: { url: studioConnectionArgs.url },
|
|
327
332
|
async action(options) {
|
|
328
|
-
const { getWorkerLogPath, getWorkerStatus } = await Promise.resolve().then(() => require("./background-
|
|
333
|
+
const { getWorkerLogPath, getWorkerStatus } = await Promise.resolve().then(() => require("./background-DVZB1n4j.cjs"));
|
|
329
334
|
const { readCredentials } = await Promise.resolve().then(() => require("./credentials-DDaKqtJn.cjs")).then((n) => n.credentials_exports);
|
|
330
|
-
const { formatPermissionRows } = await Promise.resolve().then(() => require("./run-
|
|
335
|
+
const { formatPermissionRows } = await Promise.resolve().then(() => require("./run-BnLba1gt.cjs"));
|
|
331
336
|
const worker = await getWorkerStatus();
|
|
332
337
|
console.log(`Background connection: ${worker.state}${worker.running ? ` (PID ${worker.pid})` : ""}`);
|
|
333
338
|
console.log(`Logs: ${getWorkerLogPath()}`);
|
|
@@ -403,7 +408,7 @@ const command$4 = (0, gunshi.define)({
|
|
|
403
408
|
required: true
|
|
404
409
|
} },
|
|
405
410
|
async run({ values }) {
|
|
406
|
-
const { run } = await Promise.resolve().then(() => require("./run-
|
|
411
|
+
const { run } = await Promise.resolve().then(() => require("./run-MFjzBB_M.cjs"));
|
|
407
412
|
await run({ input: values.input });
|
|
408
413
|
}
|
|
409
414
|
});
|
|
@@ -572,7 +577,12 @@ async function selectExtension(registry) {
|
|
|
572
577
|
label: entry.manifest.displayName,
|
|
573
578
|
hint: `${entry.id} · ${entry.kind} ${entry.artifact.version} · ${entry.manifest.description}`
|
|
574
579
|
}));
|
|
575
|
-
if (!options.length) throw new Error(
|
|
580
|
+
if (!options.length) throw new _kubb_core.Diagnostics.Error({
|
|
581
|
+
code: _kubb_core.Diagnostics.code.unknown,
|
|
582
|
+
severity: "error",
|
|
583
|
+
message: `The registry at ${registry} lists no extensions.`,
|
|
584
|
+
help: "Check that `KUBB_REGISTRY` points at a Kubb registry, or unset it to use https://kubb.dev/registry."
|
|
585
|
+
});
|
|
576
586
|
const id = await _clack_prompts.autocomplete({
|
|
577
587
|
message: "Select an extension to add:",
|
|
578
588
|
options,
|
|
@@ -590,7 +600,12 @@ async function run$4({ id: input, configPath, yes, install }) {
|
|
|
590
600
|
require_output.logIntro({ title: (0, node_util.styleText)("bgCyan", (0, node_util.styleText)("black", " Kubb Add ")) });
|
|
591
601
|
try {
|
|
592
602
|
const registry = require_registry.registryUrl();
|
|
593
|
-
if (!input && yes) throw new Error(
|
|
603
|
+
if (!input && yes) throw new _kubb_core.Diagnostics.Error({
|
|
604
|
+
code: _kubb_core.Diagnostics.code.unknown,
|
|
605
|
+
severity: "error",
|
|
606
|
+
message: "Pass a registry id, such as plugin-zod, when using --yes.",
|
|
607
|
+
help: "Run `kubb add plugin-zod --yes`, or drop `--yes` to pick from a list."
|
|
608
|
+
});
|
|
594
609
|
const id = input ? require_registry.toRegistryId(input) : await selectExtension(registry);
|
|
595
610
|
if (!id) {
|
|
596
611
|
_clack_prompts.cancel("Operation canceled.");
|
|
@@ -602,10 +617,20 @@ async function run$4({ id: input, configPath, yes, install }) {
|
|
|
602
617
|
});
|
|
603
618
|
const { artifact, manifest } = detail;
|
|
604
619
|
const problem = require_registry.incompatibility(manifest);
|
|
605
|
-
if (problem) throw new Error(
|
|
620
|
+
if (problem) throw new _kubb_core.Diagnostics.Error({
|
|
621
|
+
code: _kubb_core.Diagnostics.code.incompatibleExtension,
|
|
622
|
+
severity: "error",
|
|
623
|
+
message: problem,
|
|
624
|
+
help: "Upgrade Kubb or Node.js to a version the extension supports."
|
|
625
|
+
});
|
|
606
626
|
const spec = require_registry.installSpec(artifact);
|
|
607
627
|
const configFile = manifest.kind === "plugin" ? configPath ? node_path.default.resolve(configPath) : require_output.findConfigFile(cwd) : void 0;
|
|
608
|
-
if (manifest.kind === "plugin" && !configFile) throw new Error(
|
|
628
|
+
if (manifest.kind === "plugin" && !configFile) throw new _kubb_core.Diagnostics.Error({
|
|
629
|
+
code: _kubb_core.Diagnostics.code.unknown,
|
|
630
|
+
severity: "error",
|
|
631
|
+
message: "No kubb.config.ts found. Run `kubb init` first, or pass --config.",
|
|
632
|
+
help: "Run `kubb init` to create a config, or pass its path with `--config`."
|
|
633
|
+
});
|
|
609
634
|
require_output.logInfo(`${(0, node_util.styleText)("cyan", manifest.displayName)} (${manifest.kind}): ${manifest.description}`);
|
|
610
635
|
require_output.logBlock([install ? `Install ${(0, node_util.styleText)("cyan", spec)} as a dev dependency` : `Skip installing ${spec}`, configFile ? `Add ${(0, node_util.styleText)("cyan", `${manifest.export}()`)} to ${node_path.default.relative(cwd, configFile) || configFile}` : `Print the ${manifest.kind} snippet to add`]);
|
|
611
636
|
const confirmed = yes || await _clack_prompts.confirm({
|
|
@@ -747,7 +772,12 @@ async function run$3({ yes, input: inputFlag, output: outputFlag, plugins: plugi
|
|
|
747
772
|
if (pluginsFlag) {
|
|
748
773
|
const ids = pluginsFlag.split(",").map((id) => id.trim()).filter(Boolean);
|
|
749
774
|
const unknown = ids.filter((id) => !byId.has(require_registry.toRegistryId(id)));
|
|
750
|
-
if (unknown.length) throw new Error(
|
|
775
|
+
if (unknown.length) throw new _kubb_core.Diagnostics.Error({
|
|
776
|
+
code: _kubb_core.Diagnostics.code.pluginNotFound,
|
|
777
|
+
severity: "error",
|
|
778
|
+
message: `Not in the Kubb registry: ${unknown.join(", ")}. Browse the plugins at https://kubb.dev/extensions.`,
|
|
779
|
+
help: "Use plugin ids from https://kubb.dev/extensions, such as plugin-ts."
|
|
780
|
+
});
|
|
751
781
|
const entries = ids.map((id) => byId.get(require_registry.toRegistryId(id)));
|
|
752
782
|
require_output.logInfo(`Using plugins: ${pluginLabel(entries)}`);
|
|
753
783
|
return entries;
|
|
@@ -773,7 +803,11 @@ async function run$3({ yes, input: inputFlag, output: outputFlag, plugins: plugi
|
|
|
773
803
|
selected: selectedPlugins.map((entry) => entry.manifest.name),
|
|
774
804
|
manifests: selectedPlugins.map((entry) => entry.manifest)
|
|
775
805
|
});
|
|
776
|
-
if (missing.length) throw new Error(
|
|
806
|
+
if (missing.length) throw new _kubb_core.Diagnostics.Error({
|
|
807
|
+
code: _kubb_core.Diagnostics.code.missingDependency,
|
|
808
|
+
severity: "error",
|
|
809
|
+
message: `${missing.join("\n")}\nAdd the missing plugins and run kubb init again.`
|
|
810
|
+
});
|
|
777
811
|
const packagesToInstall = [`${require_output.KUBB_PACKAGE_NAME}@${require_Telemetry.version}`, ...selectedPlugins.map((entry) => require_registry.installSpec(entry.artifact))];
|
|
778
812
|
const spinner = require_output.createSpinner();
|
|
779
813
|
spinner.start(`Installing ${packagesToInstall.length} packages with ${packageManager.name}`);
|
|
@@ -811,7 +845,12 @@ async function run$3({ yes, input: inputFlag, output: outputFlag, plugins: plugi
|
|
|
811
845
|
message: `add ${entry.manifest.export}() to ${require_output.KUBB_CONFIG_FILENAME}`,
|
|
812
846
|
resolve: () => void 0
|
|
813
847
|
});
|
|
814
|
-
if (reason) throw new
|
|
848
|
+
if (reason) throw new _kubb_core.Diagnostics.Error({
|
|
849
|
+
code: _kubb_core.Diagnostics.code.unknown,
|
|
850
|
+
severity: "error",
|
|
851
|
+
message: `Could not add ${entry.manifest.export}() to ${require_output.KUBB_CONFIG_FILENAME}: ${reason}`,
|
|
852
|
+
help: `Add ${entry.manifest.export}() to the plugins array in ${require_output.KUBB_CONFIG_FILENAME} by hand.`
|
|
853
|
+
});
|
|
815
854
|
}
|
|
816
855
|
configSpinner.stop(`Created ${require_output.KUBB_CONFIG_FILENAME}`);
|
|
817
856
|
require_output.logOutro((0, node_util.styleText)("green", "✓ All set!") + "\n\n" + (0, node_util.styleText)("dim", "Next steps:") + "\n" + (0, node_util.styleText)("cyan", ` 1. Make sure your OpenAPI spec is at: ${inputPath}`) + "\n" + (0, node_util.styleText)("cyan", " 2. Generate code with: npx kubb generate") + "\n" + (0, node_util.styleText)("cyan", ` 3. Find generated files in: ${outputPath}`) + "\n\n" + (0, node_util.styleText)("dim", `Using ${packageManager.name} • Kubb v${require_Telemetry.version}`));
|
|
@@ -1044,6 +1083,7 @@ const QUIET_FLAGS = /* @__PURE__ */ new Set([
|
|
|
1044
1083
|
async function run(argv = process.argv.slice(2)) {
|
|
1045
1084
|
const args = routeStudioFlags(resolveDeprecatedFlags(argv));
|
|
1046
1085
|
const isQuietFlag = args.some((arg) => QUIET_FLAGS.has(arg));
|
|
1086
|
+
const isJsonReporter = args.some((arg, index) => /^--reporter=.*\bjson\b/.test(arg) || arg === "--reporter" && /\bjson\b/.test(args[index + 1] ?? ""));
|
|
1047
1087
|
if (!require_Telemetry.isDisabled() && !isQuietFlag) console.error(`${(0, node_util.styleText)("yellow", "Notice:")} Kubb collects anonymous telemetry data to help improve the tool. No personal data or file contents are collected. \nTo disable, set ${(0, node_util.styleText)("cyan", "KUBB_DISABLE_TELEMETRY=1")}.\n`);
|
|
1048
1088
|
await (0, gunshi.cli)(args, command$13, {
|
|
1049
1089
|
name: "kubb",
|
|
@@ -1060,6 +1100,7 @@ async function run(argv = process.argv.slice(2)) {
|
|
|
1060
1100
|
list: command$1
|
|
1061
1101
|
},
|
|
1062
1102
|
fallbackToEntry: true,
|
|
1103
|
+
...isJsonReporter ? { renderHeader: null } : {},
|
|
1063
1104
|
strict: true,
|
|
1064
1105
|
plugins: [(0, _gunshi_plugin_dryrun.default)({ name: "dry-run" })],
|
|
1065
1106
|
onErrorCommand: async (_ctx, error) => {
|