@kubb/cli 5.18.0 → 5.18.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Telemetry-B53gR0bc.js → Telemetry-0sUi82eD.js} +2 -2
- package/dist/{Telemetry-B53gR0bc.js.map → Telemetry-0sUi82eD.js.map} +1 -1
- package/dist/{Telemetry-CEZZ5IZu.cjs → Telemetry-D5VaUfKh.cjs} +2 -2
- package/dist/{Telemetry-CEZZ5IZu.cjs.map → Telemetry-D5VaUfKh.cjs.map} +1 -1
- package/dist/{background-CLQbyB3a.cjs → background-B3iKu3Xn.cjs} +2 -2
- package/dist/{background-CLQbyB3a.cjs.map → background-B3iKu3Xn.cjs.map} +1 -1
- package/dist/{background-ZOt9iygO.js → background-BNvM2_Dq.js} +2 -2
- package/dist/{background-ZOt9iygO.js.map → background-BNvM2_Dq.js.map} +1 -1
- package/dist/{background-C0z3j90s.js → background-DxzftIAz.js} +1 -1
- package/dist/{configFile-CVfWdtKh.cjs → configFile-BPHxtrEM.cjs} +2 -2
- package/dist/{configFile-CVfWdtKh.cjs.map → configFile-BPHxtrEM.cjs.map} +1 -1
- package/dist/{configFile-IHj8fRIw.js → configFile-L5i7gGUc.js} +2 -2
- package/dist/{configFile-IHj8fRIw.js.map → configFile-L5i7gGUc.js.map} +1 -1
- package/dist/index.cjs +11 -11
- package/dist/index.js +11 -11
- package/dist/{installWithSpinner-BAlTSQlE.js → installWithSpinner-CNDzLZw-.js} +2 -2
- package/dist/{installWithSpinner-BAlTSQlE.js.map → installWithSpinner-CNDzLZw-.js.map} +1 -1
- package/dist/{installWithSpinner-X9J7yxiR.cjs → installWithSpinner-CnE4dIza.cjs} +2 -2
- package/dist/{installWithSpinner-X9J7yxiR.cjs.map → installWithSpinner-CnE4dIza.cjs.map} +1 -1
- package/dist/{mcp-Dq3uJ97p.js → mcp-BqRGshGX.js} +2 -2
- package/dist/{mcp-Dq3uJ97p.js.map → mcp-BqRGshGX.js.map} +1 -1
- package/dist/{mcp-BkXSM9Fj.cjs → mcp-DcCwGJ3W.cjs} +2 -2
- package/dist/{mcp-BkXSM9Fj.cjs.map → mcp-DcCwGJ3W.cjs.map} +1 -1
- package/dist/package-BMabm3m4.js +5 -0
- package/dist/package-BMabm3m4.js.map +1 -0
- package/dist/{package-CHCCjtOD.cjs → package-Q8Q8RNv3.cjs} +2 -2
- package/dist/package-Q8Q8RNv3.cjs.map +1 -0
- package/dist/{run-Cgy4_JPy.js → run-5u7cHD85.js} +4 -4
- package/dist/{run-Cgy4_JPy.js.map → run-5u7cHD85.js.map} +1 -1
- package/dist/{run-CehHtecn.js → run-6G7UXKWu.js} +2 -2
- package/dist/{run-CehHtecn.js.map → run-6G7UXKWu.js.map} +1 -1
- package/dist/{run-DyF7mcCI.cjs → run-B3Be7mYI.cjs} +4 -4
- package/dist/{run-DyF7mcCI.cjs.map → run-B3Be7mYI.cjs.map} +1 -1
- package/dist/{run-BZa2J0G_.js → run-BBxFyD5y.js} +3 -3
- package/dist/{run-BZa2J0G_.js.map → run-BBxFyD5y.js.map} +1 -1
- package/dist/{run-B-fiM91f.js → run-BQbhIlHi.js} +2 -2
- package/dist/{run-B-fiM91f.js.map → run-BQbhIlHi.js.map} +1 -1
- package/dist/{run-CGb2TsqT.cjs → run-BUljCBLA.cjs} +5 -5
- package/dist/{run-CGb2TsqT.cjs.map → run-BUljCBLA.cjs.map} +1 -1
- package/dist/{run-CCcxqBn-.js → run-BWNlU77w.js} +1 -1
- package/dist/{run-qtDg9hZk.cjs → run-Ba-2JjgV.cjs} +5 -5
- package/dist/{run-qtDg9hZk.cjs.map → run-Ba-2JjgV.cjs.map} +1 -1
- package/dist/{run-P42MCJh7.js → run-BcenqAJQ.js} +5 -5
- package/dist/{run-P42MCJh7.js.map → run-BcenqAJQ.js.map} +1 -1
- package/dist/{run-fS5N3YT4.cjs → run-Bo6jUq0B.cjs} +2 -2
- package/dist/{run-fS5N3YT4.cjs.map → run-Bo6jUq0B.cjs.map} +1 -1
- package/dist/{run-DT4hTOR2.cjs → run-BxNbFsmc.cjs} +3 -3
- package/dist/{run-DT4hTOR2.cjs.map → run-BxNbFsmc.cjs.map} +1 -1
- package/dist/{run-DNWkBPyg.js → run-CPZtTfD9.js} +4 -4
- package/dist/{run-DNWkBPyg.js.map → run-CPZtTfD9.js.map} +1 -1
- package/dist/{run-PqKD04Dm.cjs → run-CVzNjqIF.cjs} +3 -3
- package/dist/{run-PqKD04Dm.cjs.map → run-CVzNjqIF.cjs.map} +1 -1
- package/dist/{run-Djq5PZCq.js → run-C_-U6tYc.js} +5 -5
- package/dist/{run-Djq5PZCq.js.map → run-C_-U6tYc.js.map} +1 -1
- package/dist/{run-Nh2f1Sw4.cjs → run-CqgCtKvI.cjs} +2 -2
- package/dist/{run-Nh2f1Sw4.cjs.map → run-CqgCtKvI.cjs.map} +1 -1
- package/dist/{run-DCggecSY.cjs → run-D-FHx4uQ.cjs} +4 -4
- package/dist/{run-DCggecSY.cjs.map → run-D-FHx4uQ.cjs.map} +1 -1
- package/dist/{run-DHfFHNfG.js → run-Dx8QpT_k.js} +3 -3
- package/dist/{run-DHfFHNfG.js.map → run-Dx8QpT_k.js.map} +1 -1
- package/dist/{snapshot-Dhh62LA9.cjs → snapshot-B0_6m8wO.cjs} +2 -2
- package/dist/{snapshot-Dhh62LA9.cjs.map → snapshot-B0_6m8wO.cjs.map} +1 -1
- package/dist/{snapshot-C0WMz4h6.js → snapshot-DOX7ORHz.js} +2 -2
- package/dist/{snapshot-C0WMz4h6.js.map → snapshot-DOX7ORHz.js.map} +1 -1
- package/dist/{status-DGUZGoOW.js → status-B0aaHq9Q.js} +2 -2
- package/dist/{status-DGUZGoOW.js.map → status-B0aaHq9Q.js.map} +1 -1
- package/dist/{status-Boyu19J6.cjs → status-Ibg3Xm0V.cjs} +2 -2
- package/dist/{status-Boyu19J6.cjs.map → status-Ibg3Xm0V.cjs.map} +1 -1
- package/dist/{studio-DO_ZVow1.js → studio-C3PJ3iNG.js} +11 -11
- package/dist/{studio-DO_ZVow1.js.map → studio-C3PJ3iNG.js.map} +1 -1
- package/dist/{studio-B9S_cGKE.cjs → studio-GT1ShMXA.cjs} +11 -11
- package/dist/{studio-B9S_cGKE.cjs.map → studio-GT1ShMXA.cjs.map} +1 -1
- package/dist/studioWorker.js +2 -2
- package/dist/{utils-uSJAZuvP.cjs → utils-DeXBGzGJ.cjs} +2 -2
- package/dist/utils-DeXBGzGJ.cjs.map +1 -0
- package/dist/{utils-CeMUE4P0.js → utils-f1C7RiEI.js} +2 -2
- package/dist/utils-f1C7RiEI.js.map +1 -0
- package/dist/{validate-W_4MBwS4.js → validate-BLeyRtbt.js} +2 -2
- package/dist/{validate-W_4MBwS4.js.map → validate-BLeyRtbt.js.map} +1 -1
- package/dist/{validate-CU54Odyp.cjs → validate-CuYIwX1m.cjs} +2 -2
- package/dist/{validate-CU54Odyp.cjs.map → validate-CuYIwX1m.cjs.map} +1 -1
- package/package.json +7 -7
- package/dist/package-BKe7tRfp.js +0 -5
- package/dist/package-BKe7tRfp.js.map +0 -1
- package/dist/package-CHCCjtOD.cjs.map +0 -1
- package/dist/utils-CeMUE4P0.js.map +0 -1
- package/dist/utils-uSJAZuvP.cjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-
|
|
1
|
+
{"version":3,"file":"mcp-BqRGshGX.js","names":[],"sources":["../src/commands/mcp.ts"],"sourcesContent":["import { define } from 'gunshi'\n\n/** The runner is imported when the command runs, so listing `kubb --help` never loads `@kubb/mcp`. */\nexport const command = define({\n name: 'mcp',\n description: 'Start an MCP server for code generation from an AI assistant.',\n examples: ['kubb mcp', '# Then add to your MCP client config:', '# { \"mcpServers\": { \"kubb\": { \"command\": \"npx\", \"args\": [\"kubb\", \"mcp\"] } } }'].join('\\n'),\n // gunshi prints the header to stdout, which the MCP stdio transport owns.\n rendering: { header: null },\n async run() {\n const { run } = await import('../runners/mcp/run.ts')\n await run()\n },\n})\n"],"mappings":";;;;AAGA,MAAa,UAAU,OAAO;CAC5B,MAAM;CACN,aAAa;CACb,UAAU;EAAC;EAAY;EAAyC;CAA+E,CAAC,CAAC,KAAK,IAAI;CAE1J,WAAW,EAAE,QAAQ,KAAK;CAC1B,MAAM,MAAM;EACV,MAAM,EAAE,QAAQ,MAAM,OAAO;EAC7B,MAAM,IAAI;CACZ;AACF,CAAC"}
|
|
@@ -11,10 +11,10 @@ const command = (0, require("gunshi").define)({
|
|
|
11
11
|
].join("\n"),
|
|
12
12
|
rendering: { header: null },
|
|
13
13
|
async run() {
|
|
14
|
-
const { run } = await Promise.resolve().then(() => require("./run-
|
|
14
|
+
const { run } = await Promise.resolve().then(() => require("./run-CqgCtKvI.cjs"));
|
|
15
15
|
await run();
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
18
|
exports.command = command;
|
|
19
19
|
|
|
20
|
-
//# sourceMappingURL=mcp-
|
|
20
|
+
//# sourceMappingURL=mcp-DcCwGJ3W.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-
|
|
1
|
+
{"version":3,"file":"mcp-DcCwGJ3W.cjs","names":["define"],"sources":["../src/commands/mcp.ts"],"sourcesContent":["import { define } from 'gunshi'\n\n/** The runner is imported when the command runs, so listing `kubb --help` never loads `@kubb/mcp`. */\nexport const command = define({\n name: 'mcp',\n description: 'Start an MCP server for code generation from an AI assistant.',\n examples: ['kubb mcp', '# Then add to your MCP client config:', '# { \"mcpServers\": { \"kubb\": { \"command\": \"npx\", \"args\": [\"kubb\", \"mcp\"] } } }'].join('\\n'),\n // gunshi prints the header to stdout, which the MCP stdio transport owns.\n rendering: { header: null },\n async run() {\n const { run } = await import('../runners/mcp/run.ts')\n await run()\n },\n})\n"],"mappings":";;;AAGA,MAAa,WAAA,G,gBAAUA,CAAAA,CAAAA,OAAAA,CAAO;CAC5B,MAAM;CACN,aAAa;CACb,UAAU;EAAC;EAAY;EAAyC;CAA+E,CAAC,CAAC,KAAK,IAAI;CAE1J,WAAW,EAAE,QAAQ,KAAK;CAC1B,MAAM,MAAM;EACV,MAAM,EAAE,QAAQ,MAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAM,oBAAA,CAAA;EACtB,MAAM,IAAI;CACZ;AACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-BMabm3m4.js","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// package.json
|
|
2
|
-
var version = "5.18.
|
|
2
|
+
var version = "5.18.2";
|
|
3
3
|
Object.defineProperty(exports, "version", {
|
|
4
4
|
enumerable: true,
|
|
5
5
|
get: function() {
|
|
@@ -7,4 +7,4 @@ Object.defineProperty(exports, "version", {
|
|
|
7
7
|
}
|
|
8
8
|
});
|
|
9
9
|
|
|
10
|
-
//# sourceMappingURL=package-
|
|
10
|
+
//# sourceMappingURL=package-Q8Q8RNv3.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-Q8Q8RNv3.cjs","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import "./rolldown-runtime-xo6NMXYd.js";
|
|
2
|
-
import { n as detectPackageManager, p as pascalCase } from "./utils-
|
|
2
|
+
import { n as detectPackageManager, p as pascalCase } from "./utils-f1C7RiEI.js";
|
|
3
3
|
import { t as getErrorMessage } from "./errors-wzqmMpMo.js";
|
|
4
4
|
import { i as read } from "./fs-Cf1FSRh9.js";
|
|
5
5
|
import { a as logWarn, i as logStep, n as logError, t as logBlock } from "./log-B-1vLxF1.js";
|
|
6
6
|
import { n as logIntro, t as isInteractiveRun } from "./intro-DRl-pwVs.js";
|
|
7
7
|
import { o as yesArg, t as configArg } from "./shared-DcDHRtZx.js";
|
|
8
8
|
import { r as BUNDLED_PACKAGES, t as findConfigFile } from "./config-CQTxXvIG.js";
|
|
9
|
-
import { a as ConfigEditOperation, i as readImports, n as editConfigFile, o as extensionKinds, t as editConfig } from "./configFile-
|
|
9
|
+
import { a as ConfigEditOperation, i as readImports, n as editConfigFile, o as extensionKinds, t as editConfig } from "./configFile-L5i7gGUc.js";
|
|
10
10
|
import { n as withSpinner } from "./spinner-DxsAllRI.js";
|
|
11
11
|
import { t as createSummary } from "./summary-BQWHL_Ca.js";
|
|
12
12
|
import { a as installSpec, c as toRegistryId, i as incompatibility, l as toShortId, n as closestIds, r as fetchRegistryIndex, s as registryUrl } from "./registry-Cy48PGdh.js";
|
|
13
|
-
import { t as installWithSpinner } from "./installWithSpinner-
|
|
13
|
+
import { t as installWithSpinner } from "./installWithSpinner-CNDzLZw-.js";
|
|
14
14
|
import { styleText } from "node:util";
|
|
15
15
|
import { define } from "gunshi";
|
|
16
16
|
import process from "node:process";
|
|
@@ -312,4 +312,4 @@ const command = define({
|
|
|
312
312
|
});
|
|
313
313
|
export { command, run, summarize };
|
|
314
314
|
|
|
315
|
-
//# sourceMappingURL=run-
|
|
315
|
+
//# sourceMappingURL=run-5u7cHD85.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-Cgy4_JPy.js","names":[],"sources":["../src/runners/add/run.ts"],"sourcesContent":["import path from 'node:path'\nimport process from 'node:process'\nimport { styleText } from 'node:util'\nimport * as clack from '@clack/prompts'\nimport { define } from 'gunshi'\nimport { BUNDLED_PACKAGES, ConfigEditOperation, extensionKinds, editConfig, editConfigFile, findConfigFile, readImports } from '@internals/shared'\nimport { getErrorMessage, pascalCase, read } from '@internals/utils'\nimport { Diagnostics, type ExtensionManifest, readInstalledPackages, type RegistryDetail, type RegistryEntry } from '@kubb/core'\nimport { configArg, yesArg } from '../../commands/shared.ts'\nimport { isInteractiveRun, logIntro } from '../../ui/intro.ts'\nimport { logBlock, logError, logStep, logWarn } from '../../ui/log.ts'\nimport { withSpinner } from '../../ui/spinner.ts'\nimport { createSummary } from '../../ui/summary.ts'\nimport { closestIds, fetchRegistryIndex, incompatibility, installSpec, registryUrl, toRegistryId, toShortId } from '../../utils/registry.ts'\nimport { detectPackageManager } from '../init/utils.ts'\nimport { installWithSpinner } from '../installWithSpinner.ts'\n\nexport type AddOptions = {\n /**\n * `owner/slug`, or a bare `slug` for an official extension. Asked for when omitted.\n */\n id?: string\n configPath?: string\n yes: boolean\n install: boolean\n}\n\ntype ConfigTarget = Pick<RegistryDetail, 'artifact' | 'manifest'>\n\n/** The import and the `defineConfig` property to merge into `kubb.config.ts` by hand. */\nfunction toSnippet({ artifact, manifest }: ConfigTarget): string {\n const call = `${manifest.export}()`\n const property: Record<ExtensionManifest['kind'], string> = {\n plugin: `plugins: [..., ${call}],`,\n adapter: `adapter: ${call},`,\n parser: `parsers: [..., ${call}],`,\n }\n return [`import { ${manifest.export} } from '${artifact.package}'`, '', property[manifest.kind]].join('\\n')\n}\n\n/** The `add-plugin` edits for `details`, and the manifests the edits read their export names from. */\nfunction toConfigEdits(details: Array<ConfigTarget>) {\n return {\n edits: details.map(({ artifact, manifest }) => ({\n operation: ConfigEditOperation.ADD_PLUGIN,\n ...(manifest.kind === extensionKinds.parser ? { kind: extensionKinds.parser } : {}),\n plugin: artifact.package,\n })),\n extensions: new Map(details.map(({ artifact, manifest }) => [artifact.package, { package: artifact.package, version: artifact.version, manifest }])),\n }\n}\n\n/** The lines adding `details` would put in the config `source`, trimmed, or why it could not add them. */\nfunction previewConfig({ details, source }: { details: Array<ConfigTarget>; source: string }): { lines: Array<string>; source: string } | { reason: string } {\n const result = editConfig({ source, ...toConfigEdits(details) })\n const failed = result.outcomes.find((outcome) => !outcome.applied)\n if (failed) return { reason: failed.reason ?? 'the config file was not changed' }\n const remaining = source.split('\\n')\n const lines = result.source.split('\\n').filter((line) => {\n const index = remaining.indexOf(line)\n if (index !== -1) remaining.splice(index, 1)\n return index === -1\n })\n return { lines: lines.map((line) => line.trim()), source: result.source }\n}\n\nasync function selectExtension({\n entries,\n versions,\n registry,\n}: {\n entries: Array<RegistryEntry>\n versions: Map<string, unknown>\n registry: string\n}): Promise<string | undefined> {\n if (!entries.length)\n throw new Diagnostics.Error({\n code: Diagnostics.code.unknown,\n severity: 'error',\n message: `The registry at ${registry} lists no extensions.`,\n help: 'Check that `KUBB_REGISTRY` points at a Kubb registry, or unset it to use https://kubb.dev/registry.',\n })\n\n // Filters in memory, so typing never waits on the network.\n const searchText = new Map(entries.map((entry) => [entry.id, `${entry.id} ${entry.manifest.displayName} ${entry.manifest.description}`.toLowerCase()]))\n const options = entries\n .toSorted((a, b) => a.id.localeCompare(b.id))\n .map((entry) => {\n const installed = versions.has(entry.artifact.package)\n return { value: entry.id, label: toShortId(entry.id), hint: installed ? 'installed' : summarize(entry.manifest.description), disabled: installed }\n })\n\n const id = await clack.autocomplete({\n message: `Add an extension · ${entries.length} in the registry`,\n placeholder: 'Search',\n options,\n filter: (search, option) => searchText.get(option.value)?.includes(search.toLowerCase()) ?? false,\n })\n return clack.isCancel(id) ? undefined : id\n}\n\n/** Asks whether to also add the required plugins the config lacks. `--yes` adds them. */\nasync function confirmDependencies({\n entry,\n missing,\n yes,\n}: {\n entry: RegistryEntry\n missing: Array<RegistryEntry>\n yes: boolean\n}): Promise<boolean | undefined> {\n if (!missing.length || yes) return true\n const names = missing.map((dependency) => dependency.manifest.name).join(', ')\n const answer = await clack.select({\n message: `${entry.manifest.name} needs ${names}. Add ${names} as well?`,\n options: [\n { value: true, label: `Yes, add ${missing.length === 1 ? 'both' : 'all'}`, hint: 'recommended' },\n { value: false, label: `Only ${entry.manifest.name}`, hint: 'generate fails until you add it' },\n ],\n initialValue: true,\n })\n return clack.isCancel(answer) ? undefined : answer\n}\n\n/** The first sentence of a registry description, cut to one terminal line. */\nexport function summarize(description: string, max = 64): string {\n const sentence = description.split(/\\.\\s/)[0]!.replace(/\\.$/, '')\n return sentence.length > max ? `${sentence.slice(0, max - 1).trimEnd()}…` : sentence\n}\n\n/**\n * Installs an extension from the Kubb registry at its reviewed version and, for a plugin or a parser,\n * adds it to `kubb.config.ts`, offering to add the plugins it needs as well. An adapter is never\n * written: the command prints the snippet to swap it in by hand. Without an id, asks which one.\n * Previews the packages and config lines before asking. Refuses when the running Kubb or Node.js\n * version is outside its compatibility.\n */\nexport async function run({ id: input, configPath, yes, install }: AddOptions): Promise<void> {\n const cwd = process.cwd()\n const hrStart = process.hrtime()\n const summary = createSummary(hrStart)\n const installedPackages: Array<string> = []\n const configured: Array<RegistryEntry> = []\n logIntro({ title: isInteractiveRun({ yes }) ? undefined : styleText('bgCyan', styleText('black', ' Kubb Add ')) })\n\n try {\n const registry = registryUrl()\n if (!input && yes)\n throw new Diagnostics.Error({\n code: Diagnostics.code.unknown,\n severity: 'error',\n message: 'Pass a registry id, such as plugin-zod, when using --yes.',\n help: 'Run `kubb add plugin-zod --yes`, or drop `--yes` to pick from a list.',\n })\n const inputId = input ? toRegistryId(input) : undefined\n const foundConfig = configPath ? path.resolve(configPath) : findConfigFile(cwd)\n const [entries, installed, configSource] = await withSpinner({\n message: 'Reading the registry',\n promise: Promise.all([\n fetchRegistryIndex({ registry }),\n readInstalledPackages({ root: cwd }),\n foundConfig ? read(foundConfig).catch(() => undefined) : undefined,\n ]),\n })\n const versions = new Map(installed.map((item) => [item.package, item.version]))\n\n const id = inputId ?? (await selectExtension({ entries, versions, registry }))\n if (!id) {\n summary('Add canceled', 'canceled', [' No changes made'])\n return\n }\n const entry = entries.find((candidate) => candidate.id === id)\n if (!entry) {\n const suggestions = closestIds({ input: id, ids: entries.map((entry) => entry.id) }).map(toShortId)\n summary(`No extension named ${input ?? id}`, 'failed', [\n ...suggestions.map((suggestion) => ` kubb add ${suggestion}`),\n ' Browse all kubb.dev/extensions',\n ])\n process.exitCode = 1\n return\n }\n const { artifact, manifest } = entry\n const kind = pascalCase(manifest.kind)\n\n const problem = incompatibility(manifest)\n if (problem)\n throw new Diagnostics.Error({\n code: Diagnostics.code.incompatibleExtension,\n severity: 'error',\n message: problem,\n help: 'Upgrade Kubb or Node.js to a version the extension supports.',\n })\n\n const configFile = manifest.kind === extensionKinds.adapter ? undefined : foundConfig\n if (manifest.kind !== extensionKinds.adapter && !configFile)\n throw new Diagnostics.Error({\n code: Diagnostics.code.unknown,\n severity: 'error',\n message: 'No kubb.config.ts found. Run `kubb init` first, or pass --config.',\n help: 'Run `kubb init` to create a config, or pass its path with `--config`.',\n })\n const configName = configFile ? path.relative(cwd, configFile) || configFile : undefined\n\n const byName = new Map(entries.map((candidate) => [candidate.manifest.name, candidate]))\n const inConfig = (name: string) => {\n const dependency = byName.get(name)\n return dependency ? !!configSource?.includes(`${dependency.manifest.export}(`) : installed.some((item) => item.manifest?.name === name)\n }\n const dependencies = manifest.dependencies ?? []\n const missing = configFile ? dependencies.filter((name) => !inConfig(name)).flatMap((name) => byName.get(name) ?? []) : []\n const withDependencies = await confirmDependencies({ entry, missing, yes })\n if (withDependencies === undefined) {\n summary('Add canceled', 'canceled', [` ${kind} ${manifest.name}`, ' No changes made'])\n return\n }\n const targets = [...(withDependencies ? missing : []), entry]\n\n const dependencyStatus = (name: string) => {\n if (inConfig(name)) return `${name} ${styleText('green', '✓ installed')}`\n return targets.some((target) => target.manifest.name === name) ? `${name} ${styleText('cyan', '+ adding')}` : `${name} ${styleText('yellow', 'missing')}`\n }\n const preview = configFile && configSource !== undefined ? previewConfig({ details: targets, source: configSource }) : undefined\n // The default parsers written next to a new parser come with `kubb`. A strict node_modules layout\n // only lets the config import direct dependencies, so they are installed at the project's `kubb` version.\n const before = readImports(configSource ?? '')\n const added = preview && 'lines' in preview ? readImports(preview.source).filter((name) => !before.includes(name)) : []\n const bundled = BUNDLED_PACKAGES.filter(\n (name) => added.includes(name) && !versions.has(name) && !targets.some((target) => target.artifact.package === name),\n )\n const kubbVersion = versions.get('kubb')\n const specs = [\n ...targets.filter((target) => target === entry || !versions.has(target.artifact.package)).map((target) => installSpec(target.artifact)),\n ...bundled.map((name) => (kubbVersion ? `${name}@${kubbVersion}` : name)),\n ]\n logStep(`${kind} ${styleText('cyan', manifest.name)} v${artifact.version} · ${summarize(manifest.description)}`)\n logBlock([\n ...(dependencies.length ? [`Needs ${dependencies.map(dependencyStatus).join(' ')}`] : []),\n install ? `Installs ${specs.join(' ')}` : 'Installs nothing (--no-install)',\n ...(configName ? [`Config ${configName}`] : [`Config prints the ${manifest.kind} snippet to add`]),\n ...(preview && 'lines' in preview ? preview.lines.map((line) => styleText('green', ` + ${line}`)) : []),\n ...(preview && 'reason' in preview ? [styleText('yellow', ` cannot edit it: ${preview.reason}`)] : []),\n ])\n\n const confirmed = yes || (await clack.confirm({ message: 'Add it?', initialValue: true }))\n if (clack.isCancel(confirmed) || !confirmed) {\n summary('Add canceled', 'canceled', [` ${kind} ${manifest.name}`, ' No changes made'])\n return\n }\n\n const packageManager = await detectPackageManager(cwd)\n const packages = () => (install ? `${installedPackages.length} installed with ${packageManager.name}` : 'installation skipped (--no-install)')\n if (install) {\n const names = [...targets.filter((target) => specs.includes(installSpec(target.artifact))).map((target) => target.artifact.package), ...bundled]\n await installWithSpinner({ packages: specs, names: names.join(', '), packageManager, cwd })\n installedPackages.push(...names)\n }\n\n const unconfigured: Array<RegistryEntry> = configFile ? [] : [entry]\n if (configFile) {\n for (const target of targets) {\n try {\n const { outcomes, changed } = await editConfigFile({ filePath: configFile, ...toConfigEdits([target]) })\n if (!outcomes[0]?.applied) throw new Error(outcomes[0]?.reason ?? 'the config file was not changed')\n if (changed) configured.push(target)\n logStep(`${target.manifest.export}() configured in ${configName}`)\n } catch (error) {\n logWarn(`Could not edit ${configName}: ${getErrorMessage(error)}`)\n unconfigured.push(target)\n }\n }\n }\n\n const manual = unconfigured.length > 0\n // A plugin or parser the command could not write into the config is a failure a caller can act on; an adapter never gets written.\n if (manual && manifest.kind !== extensionKinds.adapter) process.exitCode = 1\n if (manual)\n logBlock([\n 'Add the import to your Kubb config and merge the property into its defineConfig call:',\n '',\n ...unconfigured.map((target) => toSnippet(target)),\n ])\n const dependenciesMissing = !withDependencies && missing.length > 0\n const title = manual\n ? `${kind} needs configuration`\n : dependenciesMissing\n ? 'Plugin configured; dependencies missing'\n : configured.length\n ? install\n ? `${kind} ready`\n : `${kind} configured`\n : `${kind} already configured`\n summary(title, manual || dependenciesMissing ? 'warning' : 'success', [\n ` Packages ${packages()}`,\n ...configured.map((target) => styleText('green', ` + ${target.manifest.export}()`)),\n '',\n ...(!install ? [`Install ${specs.join(' ')} to use it.`] : []),\n ...(dependenciesMissing ? [`Missing plugins ${missing.map((target) => target.manifest.name).join(', ')}`] : []),\n manual ? 'Add the snippet above, then run kubb generate.' : 'Next kubb generate',\n `Options kubb.dev/extensions/${entry.id}`,\n ])\n } catch (error) {\n logError(getErrorMessage(error))\n summary('Add failed', 'failed', installedPackages.length ? [` Packages ${installedPackages.join(', ')} installed`] : [' No changes made'])\n process.exitCode = 1\n }\n}\n\nexport const command = define({\n name: 'add',\n description: 'Find and install plugins, adapters, and parsers from the Kubb registry.',\n examples: [\n 'kubb add',\n 'kubb add plugin-zod',\n 'kubb add kubb-labs/plugin-react-query',\n 'kubb add acme/plugin-x --yes',\n 'kubb add plugin-zod --no-install',\n ].join('\\n'),\n toKebab: true,\n args: {\n id: {\n type: 'positional',\n description: 'Registry id: owner/slug, or a slug for an official extension. Asked for when omitted',\n required: false,\n },\n ...configArg,\n ...yesArg,\n install: {\n type: 'boolean',\n description: 'Install the package. Pass --no-install to only edit the config',\n negatable: true,\n default: true,\n },\n },\n run: ({ values }) => run({ id: values.id, configPath: values.config, yes: values.yes, install: values.install }),\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA8BA,SAAS,UAAU,EAAE,UAAU,YAAkC;CAC/D,MAAM,OAAO,GAAG,SAAS,OAAO;CAChC,MAAM,WAAsD;EAC1D,QAAQ,kBAAkB,KAAK;EAC/B,SAAS,YAAY,KAAK;EAC1B,QAAQ,kBAAkB,KAAK;CACjC;CACA,OAAO;EAAC,YAAY,SAAS,OAAO,WAAW,SAAS,QAAQ;EAAI;EAAI,SAAS,SAAS;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ACrB;AACF;AAEA,MAAa,UAAU,OAAO;CAC5B,MAAM;CACN,aAAa;CACb,UAAU;EACR;EACA;EACA;EACA;EACA;CACF,CAAC,CAAC,KAAK,IAAI;CACX,SAAS;CACT,MAAM;EACJ,IAAI;GACF,MAAM;GACN,aAAa;GACb,UAAU;EACZ;EACA,GAAG;EACH,GAAG;EACH,SAAS;GACP,MAAM;GACN,aAAa;GACb,WAAW;GACX,SAAS;EACX;CACF;CACA,MAAM,EAAE,aAAa,IAAI;EAAE,IAAI,OAAO;EAAI,YAAY,OAAO;EAAQ,KAAK,OAAO;EAAK,SAAS,OAAO;CAAQ,CAAC;AACjH,CAAC"}
|
|
1
|
+
{"version":3,"file":"run-5u7cHD85.js","names":[],"sources":["../src/runners/add/run.ts"],"sourcesContent":["import path from 'node:path'\nimport process from 'node:process'\nimport { styleText } from 'node:util'\nimport * as clack from '@clack/prompts'\nimport { define } from 'gunshi'\nimport { BUNDLED_PACKAGES, ConfigEditOperation, extensionKinds, editConfig, editConfigFile, findConfigFile, readImports } from '@internals/shared'\nimport { getErrorMessage, pascalCase, read } from '@internals/utils'\nimport { Diagnostics, type ExtensionManifest, readInstalledPackages, type RegistryDetail, type RegistryEntry } from '@kubb/core'\nimport { configArg, yesArg } from '../../commands/shared.ts'\nimport { isInteractiveRun, logIntro } from '../../ui/intro.ts'\nimport { logBlock, logError, logStep, logWarn } from '../../ui/log.ts'\nimport { withSpinner } from '../../ui/spinner.ts'\nimport { createSummary } from '../../ui/summary.ts'\nimport { closestIds, fetchRegistryIndex, incompatibility, installSpec, registryUrl, toRegistryId, toShortId } from '../../utils/registry.ts'\nimport { detectPackageManager } from '../init/utils.ts'\nimport { installWithSpinner } from '../installWithSpinner.ts'\n\nexport type AddOptions = {\n /**\n * `owner/slug`, or a bare `slug` for an official extension. Asked for when omitted.\n */\n id?: string\n configPath?: string\n yes: boolean\n install: boolean\n}\n\ntype ConfigTarget = Pick<RegistryDetail, 'artifact' | 'manifest'>\n\n/** The import and the `defineConfig` property to merge into `kubb.config.ts` by hand. */\nfunction toSnippet({ artifact, manifest }: ConfigTarget): string {\n const call = `${manifest.export}()`\n const property: Record<ExtensionManifest['kind'], string> = {\n plugin: `plugins: [..., ${call}],`,\n adapter: `adapter: ${call},`,\n parser: `parsers: [..., ${call}],`,\n }\n return [`import { ${manifest.export} } from '${artifact.package}'`, '', property[manifest.kind]].join('\\n')\n}\n\n/** The `add-plugin` edits for `details`, and the manifests the edits read their export names from. */\nfunction toConfigEdits(details: Array<ConfigTarget>) {\n return {\n edits: details.map(({ artifact, manifest }) => ({\n operation: ConfigEditOperation.ADD_PLUGIN,\n ...(manifest.kind === extensionKinds.parser ? { kind: extensionKinds.parser } : {}),\n plugin: artifact.package,\n })),\n extensions: new Map(details.map(({ artifact, manifest }) => [artifact.package, { package: artifact.package, version: artifact.version, manifest }])),\n }\n}\n\n/** The lines adding `details` would put in the config `source`, trimmed, or why it could not add them. */\nfunction previewConfig({ details, source }: { details: Array<ConfigTarget>; source: string }): { lines: Array<string>; source: string } | { reason: string } {\n const result = editConfig({ source, ...toConfigEdits(details) })\n const failed = result.outcomes.find((outcome) => !outcome.applied)\n if (failed) return { reason: failed.reason ?? 'the config file was not changed' }\n const remaining = source.split('\\n')\n const lines = result.source.split('\\n').filter((line) => {\n const index = remaining.indexOf(line)\n if (index !== -1) remaining.splice(index, 1)\n return index === -1\n })\n return { lines: lines.map((line) => line.trim()), source: result.source }\n}\n\nasync function selectExtension({\n entries,\n versions,\n registry,\n}: {\n entries: Array<RegistryEntry>\n versions: Map<string, unknown>\n registry: string\n}): Promise<string | undefined> {\n if (!entries.length)\n throw new Diagnostics.Error({\n code: Diagnostics.code.unknown,\n severity: 'error',\n message: `The registry at ${registry} lists no extensions.`,\n help: 'Check that `KUBB_REGISTRY` points at a Kubb registry, or unset it to use https://kubb.dev/registry.',\n })\n\n // Filters in memory, so typing never waits on the network.\n const searchText = new Map(entries.map((entry) => [entry.id, `${entry.id} ${entry.manifest.displayName} ${entry.manifest.description}`.toLowerCase()]))\n const options = entries\n .toSorted((a, b) => a.id.localeCompare(b.id))\n .map((entry) => {\n const installed = versions.has(entry.artifact.package)\n return { value: entry.id, label: toShortId(entry.id), hint: installed ? 'installed' : summarize(entry.manifest.description), disabled: installed }\n })\n\n const id = await clack.autocomplete({\n message: `Add an extension · ${entries.length} in the registry`,\n placeholder: 'Search',\n options,\n filter: (search, option) => searchText.get(option.value)?.includes(search.toLowerCase()) ?? false,\n })\n return clack.isCancel(id) ? undefined : id\n}\n\n/** Asks whether to also add the required plugins the config lacks. `--yes` adds them. */\nasync function confirmDependencies({\n entry,\n missing,\n yes,\n}: {\n entry: RegistryEntry\n missing: Array<RegistryEntry>\n yes: boolean\n}): Promise<boolean | undefined> {\n if (!missing.length || yes) return true\n const names = missing.map((dependency) => dependency.manifest.name).join(', ')\n const answer = await clack.select({\n message: `${entry.manifest.name} needs ${names}. Add ${names} as well?`,\n options: [\n { value: true, label: `Yes, add ${missing.length === 1 ? 'both' : 'all'}`, hint: 'recommended' },\n { value: false, label: `Only ${entry.manifest.name}`, hint: 'generate fails until you add it' },\n ],\n initialValue: true,\n })\n return clack.isCancel(answer) ? undefined : answer\n}\n\n/** The first sentence of a registry description, cut to one terminal line. */\nexport function summarize(description: string, max = 64): string {\n const sentence = description.split(/\\.\\s/)[0]!.replace(/\\.$/, '')\n return sentence.length > max ? `${sentence.slice(0, max - 1).trimEnd()}…` : sentence\n}\n\n/**\n * Installs an extension from the Kubb registry at its reviewed version and, for a plugin or a parser,\n * adds it to `kubb.config.ts`, offering to add the plugins it needs as well. An adapter is never\n * written: the command prints the snippet to swap it in by hand. Without an id, asks which one.\n * Previews the packages and config lines before asking. Refuses when the running Kubb or Node.js\n * version is outside its compatibility.\n */\nexport async function run({ id: input, configPath, yes, install }: AddOptions): Promise<void> {\n const cwd = process.cwd()\n const hrStart = process.hrtime()\n const summary = createSummary(hrStart)\n const installedPackages: Array<string> = []\n const configured: Array<RegistryEntry> = []\n logIntro({ title: isInteractiveRun({ yes }) ? undefined : styleText('bgCyan', styleText('black', ' Kubb Add ')) })\n\n try {\n const registry = registryUrl()\n if (!input && yes)\n throw new Diagnostics.Error({\n code: Diagnostics.code.unknown,\n severity: 'error',\n message: 'Pass a registry id, such as plugin-zod, when using --yes.',\n help: 'Run `kubb add plugin-zod --yes`, or drop `--yes` to pick from a list.',\n })\n const inputId = input ? toRegistryId(input) : undefined\n const foundConfig = configPath ? path.resolve(configPath) : findConfigFile(cwd)\n const [entries, installed, configSource] = await withSpinner({\n message: 'Reading the registry',\n promise: Promise.all([\n fetchRegistryIndex({ registry }),\n readInstalledPackages({ root: cwd }),\n foundConfig ? read(foundConfig).catch(() => undefined) : undefined,\n ]),\n })\n const versions = new Map(installed.map((item) => [item.package, item.version]))\n\n const id = inputId ?? (await selectExtension({ entries, versions, registry }))\n if (!id) {\n summary('Add canceled', 'canceled', [' No changes made'])\n return\n }\n const entry = entries.find((candidate) => candidate.id === id)\n if (!entry) {\n const suggestions = closestIds({ input: id, ids: entries.map((entry) => entry.id) }).map(toShortId)\n summary(`No extension named ${input ?? id}`, 'failed', [\n ...suggestions.map((suggestion) => ` kubb add ${suggestion}`),\n ' Browse all kubb.dev/extensions',\n ])\n process.exitCode = 1\n return\n }\n const { artifact, manifest } = entry\n const kind = pascalCase(manifest.kind)\n\n const problem = incompatibility(manifest)\n if (problem)\n throw new Diagnostics.Error({\n code: Diagnostics.code.incompatibleExtension,\n severity: 'error',\n message: problem,\n help: 'Upgrade Kubb or Node.js to a version the extension supports.',\n })\n\n const configFile = manifest.kind === extensionKinds.adapter ? undefined : foundConfig\n if (manifest.kind !== extensionKinds.adapter && !configFile)\n throw new Diagnostics.Error({\n code: Diagnostics.code.unknown,\n severity: 'error',\n message: 'No kubb.config.ts found. Run `kubb init` first, or pass --config.',\n help: 'Run `kubb init` to create a config, or pass its path with `--config`.',\n })\n const configName = configFile ? path.relative(cwd, configFile) || configFile : undefined\n\n const byName = new Map(entries.map((candidate) => [candidate.manifest.name, candidate]))\n const inConfig = (name: string) => {\n const dependency = byName.get(name)\n return dependency ? !!configSource?.includes(`${dependency.manifest.export}(`) : installed.some((item) => item.manifest?.name === name)\n }\n const dependencies = manifest.dependencies ?? []\n const missing = configFile ? dependencies.filter((name) => !inConfig(name)).flatMap((name) => byName.get(name) ?? []) : []\n const withDependencies = await confirmDependencies({ entry, missing, yes })\n if (withDependencies === undefined) {\n summary('Add canceled', 'canceled', [` ${kind} ${manifest.name}`, ' No changes made'])\n return\n }\n const targets = [...(withDependencies ? missing : []), entry]\n\n const dependencyStatus = (name: string) => {\n if (inConfig(name)) return `${name} ${styleText('green', '✓ installed')}`\n return targets.some((target) => target.manifest.name === name) ? `${name} ${styleText('cyan', '+ adding')}` : `${name} ${styleText('yellow', 'missing')}`\n }\n const preview = configFile && configSource !== undefined ? previewConfig({ details: targets, source: configSource }) : undefined\n // The default parsers written next to a new parser come with `kubb`. A strict node_modules layout\n // only lets the config import direct dependencies, so they are installed at the project's `kubb` version.\n const before = readImports(configSource ?? '')\n const added = preview && 'lines' in preview ? readImports(preview.source).filter((name) => !before.includes(name)) : []\n const bundled = BUNDLED_PACKAGES.filter(\n (name) => added.includes(name) && !versions.has(name) && !targets.some((target) => target.artifact.package === name),\n )\n const kubbVersion = versions.get('kubb')\n const specs = [\n ...targets.filter((target) => target === entry || !versions.has(target.artifact.package)).map((target) => installSpec(target.artifact)),\n ...bundled.map((name) => (kubbVersion ? `${name}@${kubbVersion}` : name)),\n ]\n logStep(`${kind} ${styleText('cyan', manifest.name)} v${artifact.version} · ${summarize(manifest.description)}`)\n logBlock([\n ...(dependencies.length ? [`Needs ${dependencies.map(dependencyStatus).join(' ')}`] : []),\n install ? `Installs ${specs.join(' ')}` : 'Installs nothing (--no-install)',\n ...(configName ? [`Config ${configName}`] : [`Config prints the ${manifest.kind} snippet to add`]),\n ...(preview && 'lines' in preview ? preview.lines.map((line) => styleText('green', ` + ${line}`)) : []),\n ...(preview && 'reason' in preview ? [styleText('yellow', ` cannot edit it: ${preview.reason}`)] : []),\n ])\n\n const confirmed = yes || (await clack.confirm({ message: 'Add it?', initialValue: true }))\n if (clack.isCancel(confirmed) || !confirmed) {\n summary('Add canceled', 'canceled', [` ${kind} ${manifest.name}`, ' No changes made'])\n return\n }\n\n const packageManager = await detectPackageManager(cwd)\n const packages = () => (install ? `${installedPackages.length} installed with ${packageManager.name}` : 'installation skipped (--no-install)')\n if (install) {\n const names = [...targets.filter((target) => specs.includes(installSpec(target.artifact))).map((target) => target.artifact.package), ...bundled]\n await installWithSpinner({ packages: specs, names: names.join(', '), packageManager, cwd })\n installedPackages.push(...names)\n }\n\n const unconfigured: Array<RegistryEntry> = configFile ? [] : [entry]\n if (configFile) {\n for (const target of targets) {\n try {\n const { outcomes, changed } = await editConfigFile({ filePath: configFile, ...toConfigEdits([target]) })\n if (!outcomes[0]?.applied) throw new Error(outcomes[0]?.reason ?? 'the config file was not changed')\n if (changed) configured.push(target)\n logStep(`${target.manifest.export}() configured in ${configName}`)\n } catch (error) {\n logWarn(`Could not edit ${configName}: ${getErrorMessage(error)}`)\n unconfigured.push(target)\n }\n }\n }\n\n const manual = unconfigured.length > 0\n // A plugin or parser the command could not write into the config is a failure a caller can act on; an adapter never gets written.\n if (manual && manifest.kind !== extensionKinds.adapter) process.exitCode = 1\n if (manual)\n logBlock([\n 'Add the import to your Kubb config and merge the property into its defineConfig call:',\n '',\n ...unconfigured.map((target) => toSnippet(target)),\n ])\n const dependenciesMissing = !withDependencies && missing.length > 0\n const title = manual\n ? `${kind} needs configuration`\n : dependenciesMissing\n ? 'Plugin configured; dependencies missing'\n : configured.length\n ? install\n ? `${kind} ready`\n : `${kind} configured`\n : `${kind} already configured`\n summary(title, manual || dependenciesMissing ? 'warning' : 'success', [\n ` Packages ${packages()}`,\n ...configured.map((target) => styleText('green', ` + ${target.manifest.export}()`)),\n '',\n ...(!install ? [`Install ${specs.join(' ')} to use it.`] : []),\n ...(dependenciesMissing ? [`Missing plugins ${missing.map((target) => target.manifest.name).join(', ')}`] : []),\n manual ? 'Add the snippet above, then run kubb generate.' : 'Next kubb generate',\n `Options kubb.dev/extensions/${entry.id}`,\n ])\n } catch (error) {\n logError(getErrorMessage(error))\n summary('Add failed', 'failed', installedPackages.length ? [` Packages ${installedPackages.join(', ')} installed`] : [' No changes made'])\n process.exitCode = 1\n }\n}\n\nexport const command = define({\n name: 'add',\n description: 'Find and install plugins, adapters, and parsers from the Kubb registry.',\n examples: [\n 'kubb add',\n 'kubb add plugin-zod',\n 'kubb add kubb-labs/plugin-react-query',\n 'kubb add acme/plugin-x --yes',\n 'kubb add plugin-zod --no-install',\n ].join('\\n'),\n toKebab: true,\n args: {\n id: {\n type: 'positional',\n description: 'Registry id: owner/slug, or a slug for an official extension. Asked for when omitted',\n required: false,\n },\n ...configArg,\n ...yesArg,\n install: {\n type: 'boolean',\n description: 'Install the package. Pass --no-install to only edit the config',\n negatable: true,\n default: true,\n },\n },\n run: ({ values }) => run({ id: values.id, configPath: values.config, yes: values.yes, install: values.install }),\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA8BA,SAAS,UAAU,EAAE,UAAU,YAAkC;CAC/D,MAAM,OAAO,GAAG,SAAS,OAAO;CAChC,MAAM,WAAsD;EAC1D,QAAQ,kBAAkB,KAAK;EAC/B,SAAS,YAAY,KAAK;EAC1B,QAAQ,kBAAkB,KAAK;CACjC;CACA,OAAO;EAAC,YAAY,SAAS,OAAO,WAAW,SAAS,QAAQ;EAAI;EAAI,SAAS,SAAS;CAAK,CAAC,CAAC,KAAK,IAAI;AAC5G;;AAGA,SAAS,cAAc,SAA8B;CACnD,OAAO;EACL,OAAO,QAAQ,KAAK,EAAE,UAAU,gBAAgB;GAC9C,WAAW,oBAAoB;GAC/B,GAAI,SAAS,SAAS,eAAe,SAAS,EAAE,MAAM,eAAe,OAAO,IAAI,CAAC;GACjF,QAAQ,SAAS;EACnB,EAAE;EACF,YAAY,IAAI,IAAI,QAAQ,KAAK,EAAE,UAAU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E,aAAa,IAAI;EAAE,IAAI,OAAO;EAAI,YAAY,OAAO;EAAQ,KAAK,OAAO;EAAK,SAAS,OAAO;CAAQ,CAAC;AACjH,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./rolldown-runtime-xo6NMXYd.js";
|
|
2
2
|
import { n as toError } from "./errors-wzqmMpMo.js";
|
|
3
|
-
import { n as trackRun } from "./Telemetry-
|
|
3
|
+
import { n as trackRun } from "./Telemetry-0sUi82eD.js";
|
|
4
4
|
import { styleText } from "node:util";
|
|
5
5
|
import process from "node:process";
|
|
6
6
|
// src/runners/mcp/run.ts
|
|
@@ -28,4 +28,4 @@ async function run() {
|
|
|
28
28
|
}
|
|
29
29
|
export { run };
|
|
30
30
|
|
|
31
|
-
//# sourceMappingURL=run-
|
|
31
|
+
//# sourceMappingURL=run-6G7UXKWu.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-
|
|
1
|
+
{"version":3,"file":"run-6G7UXKWu.js","names":[],"sources":["../src/runners/mcp/run.ts"],"sourcesContent":["import process from 'node:process'\nimport { styleText } from 'node:util'\nimport { toError } from '@internals/utils'\nimport type * as McpModule from '@kubb/mcp'\nimport { trackRun } from '../../Telemetry.ts'\n\n/**\n * Starts the `@kubb/mcp` server over stdio and reports the outcome to telemetry.\n */\nexport async function run(): Promise<void> {\n const { run: startMcpServer } = (await import('@kubb/mcp')) as typeof McpModule\n\n const report = trackRun({ command: 'mcp', hrStart: process.hrtime() })\n\n try {\n // The MCP stdio transport owns stdout: anything else written there corrupts the JSON-RPC stream.\n console.error(styleText('cyan', '⏳ Starting MCP server...'))\n console.warn(styleText('yellow', 'This feature is still under development, use with caution'))\n const server = startMcpServer()\n // Report once the client introduces itself, so the event names the client (e.g. `claude-code`, `cursor-vscode`).\n server.on('initialize', ({ clientInfo }) => void report({ status: 'success', mcpClient: clientInfo.name }), { once: true })\n } catch (error) {\n await report({ status: 'failed' })\n console.error(toError(error).message)\n process.exitCode = 1\n }\n}\n"],"mappings":";;;;;;;;;AASA,eAAsB,MAAqB;CACzC,MAAM,EAAE,KAAK,mBAAoB,MAAM,OAAO;CAE9C,MAAM,SAAS,SAAS;EAAE,SAAS;EAAO,SAAS,QAAQ,OAAO;CAAE,CAAC;CAErE,IAAI;EAEF,QAAQ,MAAM,UAAU,QAAQ,0BAA0B,CAAC;EAC3D,QAAQ,KAAK,UAAU,UAAU,2DAA2D,CAAC;EAG7F,eAAK,CAAC,CAAC,GAAG,eAAe,EAAE,iBAAiB,KAAK,OAAO;GAAE,QAAQ;GAAW,WAAW,WAAW;EAAK,CAAC,GAAG,EAAE,MAAM,KAAK,CAAC;CAC5H,SAAS,OAAO;EACd,MAAM,OAAO,EAAE,QAAQ,SAAS,CAAC;EACjC,QAAQ,MAAM,QAAQ,KAAK,CAAC,CAAC,OAAO;EACpC,QAAQ,WAAW;CACrB;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-C3-Zg-KD.cjs");
|
|
2
|
-
const require_utils = require("./utils-
|
|
2
|
+
const require_utils = require("./utils-DeXBGzGJ.cjs");
|
|
3
3
|
const require_errors = require("./errors-BponpdjN.cjs");
|
|
4
4
|
const require_spinner = require("./spinner-RfMb7fd6.cjs");
|
|
5
5
|
const require_log = require("./log-wv1OxLiq.cjs");
|
|
@@ -9,7 +9,7 @@ const require_config = require("./config-CRrmj88c.cjs");
|
|
|
9
9
|
const require_text = require("./text-DMiX2dcG.cjs");
|
|
10
10
|
const require_summary = require("./summary-B2Apv5KO.cjs");
|
|
11
11
|
const require_registry = require("./registry-Q77p5TZp.cjs");
|
|
12
|
-
const require_installWithSpinner = require("./installWithSpinner-
|
|
12
|
+
const require_installWithSpinner = require("./installWithSpinner-CnE4dIza.cjs");
|
|
13
13
|
const require_table = require("./table-BlRe9YTZ.cjs");
|
|
14
14
|
let node_util = require("node:util");
|
|
15
15
|
let gunshi = require("gunshi");
|
|
@@ -33,7 +33,7 @@ async function regenerate({ cwd, configPath }) {
|
|
|
33
33
|
try {
|
|
34
34
|
const [{ getConfigs }, { generate }, { default: setupReporters }] = await Promise.all([
|
|
35
35
|
Promise.resolve().then(() => require("./config-BWj9jBVj.cjs")).then((n) => n.config_exports),
|
|
36
|
-
Promise.resolve().then(() => require("./run-
|
|
36
|
+
Promise.resolve().then(() => require("./run-CVzNjqIF.cjs")),
|
|
37
37
|
Promise.resolve().then(() => require("./reporters-DyjE3BzZ.cjs")).then((n) => n.reporters_exports)
|
|
38
38
|
]);
|
|
39
39
|
const { configs } = await getConfigs({ configPath });
|
|
@@ -236,4 +236,4 @@ const command = (0, gunshi.defineWithTypes)()({
|
|
|
236
236
|
exports.command = command;
|
|
237
237
|
exports.run = run;
|
|
238
238
|
|
|
239
|
-
//# sourceMappingURL=run-
|
|
239
|
+
//# sourceMappingURL=run-B3Be7mYI.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-DyF7mcCI.cjs","names":["createSpinner","Hookable","logLevelMap","pluralize","path","getErrorMessage","process","createSummary","isInteractiveRun","styleText","toRegistryId","withSpinner","fetchRegistryIndex","registryUrl","readInstalledPackages","bumpOf","isOutdated","incompatibility","formatTable","clack","pascalCase","toShortId","detectPackageManager","installWithSpinner","installSpec","findConfigFile","defineWithTypes","yesArg","dryRunId"],"sources":["../src/runners/update/run.ts"],"sourcesContent":["import path from 'node:path'\nimport process from 'node:process'\nimport { styleText } from 'node:util'\nimport * as clack from '@clack/prompts'\nimport { defineWithTypes } from 'gunshi'\nimport { findConfigFile } from '@internals/shared'\nimport { getErrorMessage, pascalCase } from '@internals/utils'\nimport { type GenerationResult, Hookable, type KubbHooks, logLevel as logLevelMap, readInstalledPackages, type RegistryEntry, type Reporter } from '@kubb/core'\nimport { pluralize } from '../../ui/text.ts'\nimport { dryRunId, type DryRunExtensions, yesArg } from '../../commands/shared.ts'\nimport { isInteractiveRun, logIntro } from '../../ui/intro.ts'\nimport { logBlock, logError, logStep, logWarn } from '../../ui/log.ts'\nimport { createSpinner, withSpinner } from '../../ui/spinner.ts'\nimport { createSummary } from '../../ui/summary.ts'\nimport { formatTable } from '../../ui/table.ts'\nimport { bumpOf, fetchRegistryIndex, incompatibility, installSpec, isOutdated, registryUrl, toRegistryId, toShortId } from '../../utils/registry.ts'\nimport { detectPackageManager } from '../init/utils.ts'\nimport { installWithSpinner } from '../installWithSpinner.ts'\n\nexport type UpdateOptions = {\n /**\n * Registry ids to update. Empty updates every installed extension the registry lists.\n */\n ids: Array<string>\n /**\n * List the updates without installing anything.\n */\n dryRun: boolean\n yes: boolean\n}\n\ntype FileChanges = NonNullable<GenerationResult['fileChanges']>\n\n/**\n * Generates every config in this process, the way `kubb generate` does, and returns the counts of\n * output files it changed. Runs after the install, so the config loads the new versions.\n * `undefined` when the config fails to load or a build fails.\n */\nasync function regenerate({ cwd, configPath }: { cwd: string; configPath: string }): Promise<{ changes: FileChanges; output: string } | undefined> {\n const spinner = createSpinner()\n spinner.start('Generating with the new versions')\n try {\n // Imported here, so the config loader and the generate path never slow down `kubb --help`.\n const [{ getConfigs }, { generate }, { default: setupReporters }] = await Promise.all([\n import('../../config.ts'),\n import('../generate/run.ts'),\n import('../../loggers/reporters.ts'),\n ])\n const { configs } = await getConfigs({ configPath })\n const hooks = new Hookable<KubbHooks>()\n const changes: FileChanges = { added: 0, modified: 0, deleted: 0, linesAdded: 0, linesRemoved: 0 }\n const collect: Reporter = {\n name: 'update',\n report: ({ fileChanges }) => {\n for (const key of Object.keys(changes) as Array<keyof FileChanges>) changes[key] += fileChanges?.[key] ?? 0\n },\n }\n setupReporters(hooks, { logLevel: logLevelMap.info, reporters: [collect], fileChanges: true })\n for (const config of configs) {\n if (!(await generate({ config, hooks }))) throw new Error('Generation failed')\n }\n const changed = changes.added + changes.modified + changes.deleted\n spinner.stop(changed ? `Generated: ${pluralize(changed, 'file')} changed` : 'Generated: no files changed')\n return { changes, output: configs.map((config) => path.relative(cwd, path.resolve(config.root ?? cwd, config.output.path)) || '.').join(', ') }\n } catch (error) {\n spinner.error(`Generation failed: ${getErrorMessage(error)}`)\n return undefined\n }\n}\n\n/**\n * Moves installed extensions to the version the registry pins. Shows each version change with its\n * bump, asks which to install with majors left out, installs them, and regenerates to show which\n * files changed. With `dryRun`, only lists the updates and installs nothing.\n */\nexport async function run({ ids, dryRun, yes }: UpdateOptions): Promise<void> {\n const cwd = process.cwd()\n const hrStart = process.hrtime()\n const installedPackages: Array<string> = []\n const summary = createSummary(hrStart)\n logIntro({ title: isInteractiveRun({ yes, dryRun }) ? undefined : styleText('bgCyan', styleText('black', ' Kubb Update ')) })\n\n try {\n const wanted = new Set(ids.map(toRegistryId))\n const [entries, installed] = await withSpinner({\n message: 'Checking the registry',\n promise: Promise.all([fetchRegistryIndex({ registry: registryUrl() }), readInstalledPackages({ root: cwd })]),\n })\n const versions = new Map(installed.map((item) => [item.package, item.version]))\n\n const tracked = entries.filter((entry) => versions.has(entry.artifact.package) && (!wanted.size || wanted.has(entry.id)))\n for (const id of wanted) {\n if (tracked.some((entry) => entry.id === id)) continue\n logWarn(`${id} is not installed, or not in the registry.`)\n // A caller that named it, such as Studio, must not read the run as a successful update.\n process.exitCode = 1\n }\n\n const current = ({ artifact }: RegistryEntry) => versions.get(artifact.package)\n const isMajor = (entry: RegistryEntry) => bumpOf({ installed: current(entry), latest: entry.artifact.version }) === 'major'\n const outdated = tracked.filter((entry) => isOutdated({ installed: current(entry), latest: entry.artifact.version }))\n const proposals = outdated.filter((entry) => {\n const problem = incompatibility(entry.manifest)\n if (problem) {\n logWarn(`Skipped ${entry.id}: ${problem}`)\n // Same as a missing id: Studio would report an update that installed nothing.\n if (wanted.has(entry.id)) process.exitCode = 1\n }\n return !problem\n })\n\n if (!proposals.length) {\n const title = outdated.length ? 'No compatible updates available' : 'Already up to date'\n summary(tracked.length ? title : 'No installed extensions to update', outdated.length ? 'warning' : 'success', [\n ` ${tracked.length - outdated.length} of ${tracked.length} up to date`,\n ...(ids.length ? ['', `No updates for ${ids.join(', ')}.`] : []),\n ])\n return\n }\n\n if (tracked.length) {\n const header = ['Extension', 'Current', 'Latest', '']\n const rows = tracked.map((entry) => {\n if (!outdated.includes(entry)) return [entry.artifact.package, current(entry) ?? '-', 'up to date', '']\n const bump = bumpOf({ installed: current(entry), latest: entry.artifact.version }) ?? ''\n return [entry.artifact.package, current(entry) ?? 'not installed', entry.artifact.version, bump === 'major' ? 'major · breaking' : bump]\n })\n const lines = formatTable([header, ...rows])\n logStep(`Checked ${pluralize(tracked.length, 'extension')} against the registry`)\n logBlock([\n styleText('dim', lines[0]!),\n ...lines.slice(1).map((line, index) => {\n if (!outdated.includes(tracked[index]!)) return styleText('dim', line)\n return line.endsWith('major · breaking') ? styleText('yellow', line) : line\n }),\n ])\n }\n\n if (dryRun) {\n summary('Updates available', 'planned', [`Dry run: nothing was installed. Run kubb update to install ${proposals.length === 1 ? 'it' : 'them'}.`])\n return\n }\n\n // A major can break the generated code, so it is only picked for you when you named it.\n const defaults = proposals.filter((entry) => wanted.has(entry.id) || !isMajor(entry))\n const chosen = yes\n ? defaults.map((entry) => entry.id)\n : await clack.multiselect({\n message: 'Select the updates to install',\n options: proposals.map((entry) => ({\n value: entry.id,\n label: entry.artifact.package,\n hint: `${current(entry) ?? 'not installed'} → ${entry.artifact.version}`,\n })),\n initialValues: defaults.map((entry) => entry.id),\n required: false,\n })\n if (clack.isCancel(chosen)) {\n summary('Update canceled', 'canceled', [' No changes made'])\n return\n }\n const selected = proposals.filter((entry) => chosen.includes(entry.id))\n\n const skipped = proposals\n .filter((entry) => !selected.includes(entry))\n .map((entry) => {\n const kind = pascalCase(entry.manifest.kind)\n return ` ${styleText('dim', 'Skipped')} ${kind} ${entry.artifact.package} ${entry.artifact.version} ${styleText('dim', `run kubb update ${toShortId(entry.id)} later`)}`\n })\n if (!selected.length) {\n summary('No updates installed', 'canceled', [' No updates selected.', ...skipped])\n return\n }\n\n const packageManager = await detectPackageManager(cwd)\n const names = selected.map(({ artifact }) => artifact.package).join(', ')\n await installWithSpinner({\n packages: selected.map(({ artifact }) => installSpec(artifact)),\n names,\n packageManager,\n cwd,\n })\n installedPackages.push(...selected.map((entry) => entry.artifact.package))\n\n // Regenerating rewrites output files, so it is asked for. `--yes` only accepts the install.\n const foundConfig = findConfigFile(cwd)\n const regenerateNow =\n foundConfig && !yes && (await clack.confirm({ message: 'Regenerate now? This rewrites the generated files.', initialValue: true })) === true\n const configPath = regenerateNow ? foundConfig : undefined\n const changed = configPath ? await regenerate({ cwd, configPath }) : undefined\n\n const generationFailed = Boolean(configPath && !changed)\n summary(generationFailed ? 'Extensions updated; generation failed' : 'Update complete', generationFailed ? 'warning' : 'success', [\n ` Packages ${selected.length} installed with ${packageManager.name}${skipped.length ? ` · ${skipped.length} skipped` : ''}`,\n ...skipped,\n ...(changed ? [` Files ${changed.changes.added} added · ${changed.changes.modified} modified · ${changed.changes.deleted} deleted`] : []),\n ...(!configPath ? [' Regeneration not run'] : []),\n ...(generationFailed ? ['', 'Fix the generation error, then run kubb generate.'] : []),\n ])\n } catch (error) {\n logError(getErrorMessage(error))\n summary('Update failed', 'failed', installedPackages.length ? [` Packages ${installedPackages.join(', ')} installed`] : [' No changes made'])\n process.exitCode = 1\n }\n}\n\nexport const command = defineWithTypes<{ extensions: DryRunExtensions }>()({\n name: 'update',\n description: 'Update installed extensions, regenerate, and summarize file changes.',\n examples: ['kubb update', 'kubb update --dry-run', 'kubb update plugin-zod plugin-ts --yes'].join('\\n'),\n args: {\n ids: {\n type: 'positional',\n description: 'Registry ids to update, all installed extensions when omitted',\n multiple: true,\n },\n ...yesArg,\n },\n run: ({ values, extensions }) => run({ ids: values.ids ?? [], dryRun: extensions[dryRunId].enabled, yes: values.yes }),\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,eAAe,WAAW,EAAE,KAAK,cAAkH;CACjJ,MAAM,UAAUA,gBAAAA,cAAc;CAC9B,QAAQ,MAAM,kCAAkC;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IAAI,CAAC;GAChD,GAAI,mBAAmB,CAAC,IAAI,mDAAmD,IAAI,CAAC;EACtF,CAAC;CACH,SAAS,OAAO;EACd,YAAA,SAASd,eAAAA,gBAAgB,KAAK,CAAC;EAC/B,QAAQ,iBAAiB,UAAU,kBAAkB,SAAS,CAAC,eAAe,kBAAkB,KAAK,IAAI,EAAE,WAAW,IAAI,CAAC,mBAAmB,CAAC;EAC/I,aAAA,QAAA,WAAmB;CACrB;AACF;AAEA,MAAa,WAAA,GAAUqB,OAAAA,gBAAAA,CAAkD,CAAC,CAAC;CACzE,MAAM;CACN,aAAa;CACb,UAAU;EAAC;EAAe;EAAyB;CAAwC,CAAC,CAAC,KAAK,IAAI;CACtG,MAAM;EACJ,KAAK;GACH,MAAM;GACN,aAAa;GACb,UAAU;EACZ;EACA,GAAGC,eAAAA;CACL;CACA,MAAM,EAAE,QAAQ,iBAAiB,IAAI;EAAE,KAAK,OAAO,OAAO,CAAC;EAAG,QAAQ,WAAWC,sBAAAA,SAAS,CAAC;EAAS,KAAK,OAAO;CAAI,CAAC;AACvH,CAAC"}
|
|
1
|
+
{"version":3,"file":"run-B3Be7mYI.cjs","names":["createSpinner","Hookable","logLevelMap","pluralize","path","getErrorMessage","process","createSummary","isInteractiveRun","styleText","toRegistryId","withSpinner","fetchRegistryIndex","registryUrl","readInstalledPackages","bumpOf","isOutdated","incompatibility","formatTable","clack","pascalCase","toShortId","detectPackageManager","installWithSpinner","installSpec","findConfigFile","defineWithTypes","yesArg","dryRunId"],"sources":["../src/runners/update/run.ts"],"sourcesContent":["import path from 'node:path'\nimport process from 'node:process'\nimport { styleText } from 'node:util'\nimport * as clack from '@clack/prompts'\nimport { defineWithTypes } from 'gunshi'\nimport { findConfigFile } from '@internals/shared'\nimport { getErrorMessage, pascalCase } from '@internals/utils'\nimport { type GenerationResult, Hookable, type KubbHooks, logLevel as logLevelMap, readInstalledPackages, type RegistryEntry, type Reporter } from '@kubb/core'\nimport { pluralize } from '../../ui/text.ts'\nimport { dryRunId, type DryRunExtensions, yesArg } from '../../commands/shared.ts'\nimport { isInteractiveRun, logIntro } from '../../ui/intro.ts'\nimport { logBlock, logError, logStep, logWarn } from '../../ui/log.ts'\nimport { createSpinner, withSpinner } from '../../ui/spinner.ts'\nimport { createSummary } from '../../ui/summary.ts'\nimport { formatTable } from '../../ui/table.ts'\nimport { bumpOf, fetchRegistryIndex, incompatibility, installSpec, isOutdated, registryUrl, toRegistryId, toShortId } from '../../utils/registry.ts'\nimport { detectPackageManager } from '../init/utils.ts'\nimport { installWithSpinner } from '../installWithSpinner.ts'\n\nexport type UpdateOptions = {\n /**\n * Registry ids to update. Empty updates every installed extension the registry lists.\n */\n ids: Array<string>\n /**\n * List the updates without installing anything.\n */\n dryRun: boolean\n yes: boolean\n}\n\ntype FileChanges = NonNullable<GenerationResult['fileChanges']>\n\n/**\n * Generates every config in this process, the way `kubb generate` does, and returns the counts of\n * output files it changed. Runs after the install, so the config loads the new versions.\n * `undefined` when the config fails to load or a build fails.\n */\nasync function regenerate({ cwd, configPath }: { cwd: string; configPath: string }): Promise<{ changes: FileChanges; output: string } | undefined> {\n const spinner = createSpinner()\n spinner.start('Generating with the new versions')\n try {\n // Imported here, so the config loader and the generate path never slow down `kubb --help`.\n const [{ getConfigs }, { generate }, { default: setupReporters }] = await Promise.all([\n import('../../config.ts'),\n import('../generate/run.ts'),\n import('../../loggers/reporters.ts'),\n ])\n const { configs } = await getConfigs({ configPath })\n const hooks = new Hookable<KubbHooks>()\n const changes: FileChanges = { added: 0, modified: 0, deleted: 0, linesAdded: 0, linesRemoved: 0 }\n const collect: Reporter = {\n name: 'update',\n report: ({ fileChanges }) => {\n for (const key of Object.keys(changes) as Array<keyof FileChanges>) changes[key] += fileChanges?.[key] ?? 0\n },\n }\n setupReporters(hooks, { logLevel: logLevelMap.info, reporters: [collect], fileChanges: true })\n for (const config of configs) {\n if (!(await generate({ config, hooks }))) throw new Error('Generation failed')\n }\n const changed = changes.added + changes.modified + changes.deleted\n spinner.stop(changed ? `Generated: ${pluralize(changed, 'file')} changed` : 'Generated: no files changed')\n return { changes, output: configs.map((config) => path.relative(cwd, path.resolve(config.root ?? cwd, config.output.path)) || '.').join(', ') }\n } catch (error) {\n spinner.error(`Generation failed: ${getErrorMessage(error)}`)\n return undefined\n }\n}\n\n/**\n * Moves installed extensions to the version the registry pins. Shows each version change with its\n * bump, asks which to install with majors left out, installs them, and regenerates to show which\n * files changed. With `dryRun`, only lists the updates and installs nothing.\n */\nexport async function run({ ids, dryRun, yes }: UpdateOptions): Promise<void> {\n const cwd = process.cwd()\n const hrStart = process.hrtime()\n const installedPackages: Array<string> = []\n const summary = createSummary(hrStart)\n logIntro({ title: isInteractiveRun({ yes, dryRun }) ? undefined : styleText('bgCyan', styleText('black', ' Kubb Update ')) })\n\n try {\n const wanted = new Set(ids.map(toRegistryId))\n const [entries, installed] = await withSpinner({\n message: 'Checking the registry',\n promise: Promise.all([fetchRegistryIndex({ registry: registryUrl() }), readInstalledPackages({ root: cwd })]),\n })\n const versions = new Map(installed.map((item) => [item.package, item.version]))\n\n const tracked = entries.filter((entry) => versions.has(entry.artifact.package) && (!wanted.size || wanted.has(entry.id)))\n for (const id of wanted) {\n if (tracked.some((entry) => entry.id === id)) continue\n logWarn(`${id} is not installed, or not in the registry.`)\n // A caller that named it, such as Studio, must not read the run as a successful update.\n process.exitCode = 1\n }\n\n const current = ({ artifact }: RegistryEntry) => versions.get(artifact.package)\n const isMajor = (entry: RegistryEntry) => bumpOf({ installed: current(entry), latest: entry.artifact.version }) === 'major'\n const outdated = tracked.filter((entry) => isOutdated({ installed: current(entry), latest: entry.artifact.version }))\n const proposals = outdated.filter((entry) => {\n const problem = incompatibility(entry.manifest)\n if (problem) {\n logWarn(`Skipped ${entry.id}: ${problem}`)\n // Same as a missing id: Studio would report an update that installed nothing.\n if (wanted.has(entry.id)) process.exitCode = 1\n }\n return !problem\n })\n\n if (!proposals.length) {\n const title = outdated.length ? 'No compatible updates available' : 'Already up to date'\n summary(tracked.length ? title : 'No installed extensions to update', outdated.length ? 'warning' : 'success', [\n ` ${tracked.length - outdated.length} of ${tracked.length} up to date`,\n ...(ids.length ? ['', `No updates for ${ids.join(', ')}.`] : []),\n ])\n return\n }\n\n if (tracked.length) {\n const header = ['Extension', 'Current', 'Latest', '']\n const rows = tracked.map((entry) => {\n if (!outdated.includes(entry)) return [entry.artifact.package, current(entry) ?? '-', 'up to date', '']\n const bump = bumpOf({ installed: current(entry), latest: entry.artifact.version }) ?? ''\n return [entry.artifact.package, current(entry) ?? 'not installed', entry.artifact.version, bump === 'major' ? 'major · breaking' : bump]\n })\n const lines = formatTable([header, ...rows])\n logStep(`Checked ${pluralize(tracked.length, 'extension')} against the registry`)\n logBlock([\n styleText('dim', lines[0]!),\n ...lines.slice(1).map((line, index) => {\n if (!outdated.includes(tracked[index]!)) return styleText('dim', line)\n return line.endsWith('major · breaking') ? styleText('yellow', line) : line\n }),\n ])\n }\n\n if (dryRun) {\n summary('Updates available', 'planned', [`Dry run: nothing was installed. Run kubb update to install ${proposals.length === 1 ? 'it' : 'them'}.`])\n return\n }\n\n // A major can break the generated code, so it is only picked for you when you named it.\n const defaults = proposals.filter((entry) => wanted.has(entry.id) || !isMajor(entry))\n const chosen = yes\n ? defaults.map((entry) => entry.id)\n : await clack.multiselect({\n message: 'Select the updates to install',\n options: proposals.map((entry) => ({\n value: entry.id,\n label: entry.artifact.package,\n hint: `${current(entry) ?? 'not installed'} → ${entry.artifact.version}`,\n })),\n initialValues: defaults.map((entry) => entry.id),\n required: false,\n })\n if (clack.isCancel(chosen)) {\n summary('Update canceled', 'canceled', [' No changes made'])\n return\n }\n const selected = proposals.filter((entry) => chosen.includes(entry.id))\n\n const skipped = proposals\n .filter((entry) => !selected.includes(entry))\n .map((entry) => {\n const kind = pascalCase(entry.manifest.kind)\n return ` ${styleText('dim', 'Skipped')} ${kind} ${entry.artifact.package} ${entry.artifact.version} ${styleText('dim', `run kubb update ${toShortId(entry.id)} later`)}`\n })\n if (!selected.length) {\n summary('No updates installed', 'canceled', [' No updates selected.', ...skipped])\n return\n }\n\n const packageManager = await detectPackageManager(cwd)\n const names = selected.map(({ artifact }) => artifact.package).join(', ')\n await installWithSpinner({\n packages: selected.map(({ artifact }) => installSpec(artifact)),\n names,\n packageManager,\n cwd,\n })\n installedPackages.push(...selected.map((entry) => entry.artifact.package))\n\n // Regenerating rewrites output files, so it is asked for. `--yes` only accepts the install.\n const foundConfig = findConfigFile(cwd)\n const regenerateNow =\n foundConfig && !yes && (await clack.confirm({ message: 'Regenerate now? This rewrites the generated files.', initialValue: true })) === true\n const configPath = regenerateNow ? foundConfig : undefined\n const changed = configPath ? await regenerate({ cwd, configPath }) : undefined\n\n const generationFailed = Boolean(configPath && !changed)\n summary(generationFailed ? 'Extensions updated; generation failed' : 'Update complete', generationFailed ? 'warning' : 'success', [\n ` Packages ${selected.length} installed with ${packageManager.name}${skipped.length ? ` · ${skipped.length} skipped` : ''}`,\n ...skipped,\n ...(changed ? [` Files ${changed.changes.added} added · ${changed.changes.modified} modified · ${changed.changes.deleted} deleted`] : []),\n ...(!configPath ? [' Regeneration not run'] : []),\n ...(generationFailed ? ['', 'Fix the generation error, then run kubb generate.'] : []),\n ])\n } catch (error) {\n logError(getErrorMessage(error))\n summary('Update failed', 'failed', installedPackages.length ? [` Packages ${installedPackages.join(', ')} installed`] : [' No changes made'])\n process.exitCode = 1\n }\n}\n\nexport const command = defineWithTypes<{ extensions: DryRunExtensions }>()({\n name: 'update',\n description: 'Update installed extensions, regenerate, and summarize file changes.',\n examples: ['kubb update', 'kubb update --dry-run', 'kubb update plugin-zod plugin-ts --yes'].join('\\n'),\n args: {\n ids: {\n type: 'positional',\n description: 'Registry ids to update, all installed extensions when omitted',\n multiple: true,\n },\n ...yesArg,\n },\n run: ({ values, extensions }) => run({ ids: values.ids ?? [], dryRun: extensions[dryRunId].enabled, yes: values.yes }),\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA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AQ,SAAS,cAAc,QAAQ,QAAQ,QAAQ,SAAS,IAAI,CAAC;GAC5I,GAAI,CAAC,aAAa,CAAC,wBAAwB,IAAI,CAAC;GAChD,GAAI,mBAAmB,CAAC,IAAI,mDAAmD,IAAI,CAAC;EACtF,CAAC;CACH,SAAS,OAAO;EACd,YAAA,SAASd,eAAAA,gBAAgB,KAAK,CAAC;EAC/B,QAAQ,iBAAiB,UAAU,kBAAkB,SAAS,CAAC,eAAe,kBAAkB,KAAK,IAAI,EAAE,WAAW,IAAI,CAAC,mBAAmB,CAAC;EAC/I,aAAA,QAAA,WAAmB;CACrB;AACF;AAEA,MAAa,WAAA,GAAUqB,OAAAA,gBAAAA,CAAkD,CAAC,CAAC;CACzE,MAAM;CACN,aAAa;CACb,UAAU;EAAC;EAAe;EAAyB;CAAwC,CAAC,CAAC,KAAK,IAAI;CACtG,MAAM;EACJ,KAAK;GACH,MAAM;GACN,aAAa;GACb,UAAU;EACZ;EACA,GAAGC,eAAAA;CACL;CACA,MAAM,EAAE,QAAQ,iBAAiB,IAAI;EAAE,KAAK,OAAO,OAAO,CAAC;EAAG,QAAQ,WAAWC,sBAAAA,SAAS,CAAC;EAAS,KAAK,OAAO;CAAI,CAAC;AACvH,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "./rolldown-runtime-xo6NMXYd.js";
|
|
2
2
|
import { n as getElapsedMs, t as formatMs } from "./time-C-wU7VhC.js";
|
|
3
3
|
import { a as startWatcher, i as listenForKeys, n as setupReporters, o as trackBuild, r as diffBuilds, t as selectReporters } from "./reporters-B_USHwD6.js";
|
|
4
|
-
import { t as version } from "./package-
|
|
5
|
-
import { n as trackRun } from "./Telemetry-
|
|
4
|
+
import { t as version } from "./package-BMabm3m4.js";
|
|
5
|
+
import { n as trackRun } from "./Telemetry-0sUi82eD.js";
|
|
6
6
|
import { a as logWarn, i as logStep, n as logError, r as logInfo, s as createPlainWriter } from "./log-B-1vLxF1.js";
|
|
7
7
|
import { a as logTip, i as logSpacer, n as logIntro, r as logOutro } from "./intro-DRl-pwVs.js";
|
|
8
8
|
import { n as logBanner } from "./mascot-CmUUHLlx.js";
|
|
@@ -223,4 +223,4 @@ async function run({ input, configPath, logLevel: logLevelKey, watch, reporters:
|
|
|
223
223
|
}
|
|
224
224
|
export { generate, run };
|
|
225
225
|
|
|
226
|
-
//# sourceMappingURL=run-
|
|
226
|
+
//# sourceMappingURL=run-BBxFyD5y.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-BZa2J0G_.js","names":["logLevel","logLevelMap"],"sources":["../src/runners/generate/run.ts"],"sourcesContent":["import path from 'node:path'\nimport process from 'node:process'\nimport { styleText } from 'node:util'\nimport { formatMs, formatters, getElapsedMs, linters } from '@internals/utils'\nimport {\n Hookable,\n type CLIOptions,\n cliReporter,\n type Config,\n createKubb,\n Diagnostics,\n fileReporter,\n getInputKind,\n htmlReporter,\n jsonReporter,\n type KubbHooks,\n logLevel as logLevelMap,\n memoryStorage,\n type ReporterName,\n} from '@kubb/core'\nimport { version } from '../../../package.json'\nimport { trackRun } from '../../Telemetry.ts'\nimport { pluralize } from '../../ui/text.ts'\nimport setupReporters, { selectReporters } from '../../loggers/reporters.ts'\nimport { createPlainWriter } from '../../loggers/plainWriter.ts'\nimport { logIntro, logOutro, logSpacer, logTip } from '../../ui/intro.ts'\nimport { logError, logInfo, logStep, logWarn } from '../../ui/log.ts'\nimport { logBanner } from '../../ui/mascot.ts'\nimport { createSpinner } from '../../ui/spinner.ts'\nimport { getConfigs } from '../../config.ts'\nimport { isOutdated } from '../../utils/registry.ts'\nimport { type BuildDiff, type BuildSnapshot, diffBuilds, listenForKeys, startWatcher, trackBuild } from './utils.ts'\n\n/** NPM registry endpoint used to check for @kubb/cli updates. */\nconst KUBB_NPM_PACKAGE_URL = 'https://registry.npmjs.org/@kubb/cli/latest' as const\n\n/** Upper bound in milliseconds for the npm update check, so a slow registry never stalls a run. */\nconst UPDATE_CHECK_TIMEOUT_MS = 3_000\n\n/** The formatter names from `Config['output'].format`, without `'auto'` (detection, not a tool) and `false` (skip). */\ntype FormatterName = Exclude<NonNullable<Config['output']['format']>, 'auto' | false>\ntype LinterName = Exclude<NonNullable<Config['output']['lint']>, 'auto' | false>\n\n// Pinned here, not in `@internals/utils` (which must not import `@kubb/core`): a tool added to the union without a descriptor fails to compile.\nformatters satisfies Record<FormatterName, unknown>\nlinters satisfies Record<LinterName, unknown>\n\ntype GenerateProps = {\n input?: string\n config: Config\n hooks: Hookable<KubbHooks>\n /**\n * When `true`, generates in memory instead of writing to disk, skips formatting, linting, and\n * post-generate commands, and prints what would change on disk.\n */\n dryRun?: boolean\n}\n\nexport async function generate(options: GenerateProps): Promise<boolean> {\n const { input, hooks, dryRun = false } = options\n\n const report = trackRun({ command: 'generate', hrStart: process.hrtime() })\n\n const config: Config = {\n ...options.config,\n input: input ?? options.config.input,\n // Dry-run never touches disk, regardless of the config's own storage driver.\n storage: dryRun ? memoryStorage() : options.config.storage,\n // Also keeps core's `hasOutputPasses` false, so dry-run skips the output manifest write too.\n output: dryRun ? { ...options.config.output, format: false, lint: false, postGenerate: [] } : options.config.output,\n }\n\n // Core formats, lints and runs `output.postGenerate` after an error-free build, and reports\n // their failures as coded diagnostics that reach the summary, the json report and the exit code.\n const kubb = createKubb(config, { hooks })\n const result = await kubb.generate()\n\n // Not awaited: the request finishes in the background, capped by its timeout, so it never delays the summary.\n void report({\n // A setup that threw leaves no driver, so read the configured plugins instead.\n plugins: kubb.config.plugins.flatMap((p) =>\n p && typeof p === 'object' ? [{ name: p.meta?.name ?? p.name ?? '', options: (p.options ?? {}) as Record<string, unknown> }] : [],\n ),\n filesCreated: result.files.length,\n status: result.success ? 'success' : 'failed',\n })\n\n return result.success\n}\n\ntype GenerateCommandOptions = {\n input?: string\n configPath?: string\n logLevel: string\n watch: boolean\n reporters?: Array<ReporterName>\n dryRun?: boolean\n}\n\n/** The latest published version, `undefined` when the registry does not answer in time or `signal` aborts. Never rejects. */\nasync function fetchLatestVersion(signal: AbortSignal): Promise<string | undefined> {\n try {\n const res = await fetch(KUBB_NPM_PACKAGE_URL, { signal: AbortSignal.any([signal, AbortSignal.timeout(UPDATE_CHECK_TIMEOUT_MS)]) })\n const data = (await res.json()) as { version: string }\n return data.version\n } catch {\n // Ignore network errors\n return undefined\n }\n}\n\nasync function checkForUpdate({ hooks, latestVersion }: { hooks: Hookable<KubbHooks>; latestVersion: string | undefined }): Promise<void> {\n if (latestVersion && isOutdated({ installed: version, latest: latestVersion })) {\n await Diagnostics.emit(hooks, Diagnostics.update({ currentVersion: version, latestVersion }))\n }\n}\n\n/** Prints `Rebuilt in 1.2s · +1 schema -2 operations`, without the names part when the spec kept the same names. */\nfunction logRebuild({ diff: { schemas, operations }, durationMs }: { diff: BuildDiff; durationMs: number }): void {\n const specChange = [\n schemas.added && styleText('green', `+${pluralize(schemas.added, 'schema')}`),\n schemas.removed && styleText('red', `-${pluralize(schemas.removed, 'schema')}`),\n operations.added && styleText('green', `+${pluralize(operations.added, 'operation')}`),\n operations.removed && styleText('red', `-${pluralize(operations.removed, 'operation')}`),\n ]\n .filter(Boolean)\n .join(' ')\n logStep([`Rebuilt in ${formatMs(durationMs)}`, specChange].filter(Boolean).join(styleText('dim', ' · ')))\n}\n\n/**\n * Runs the full Kubb generation lifecycle for the given CLI options.\n * Loads configs, sets up the reporters (CLI `--reporter` picks which of `config.reporters` to trigger),\n * calls `generate` for each config entry, and prints an update notice when the registry answered in time.\n */\nexport async function run({ input, configPath, logLevel: logLevelKey, watch, reporters: cliReporters, dryRun }: GenerateCommandOptions): Promise<void> {\n // Started first and never awaited: the notice prints at the end only when the registry has answered by then.\n const updateCheck = new AbortController()\n let latestVersion: string | undefined\n void fetchLatestVersion(updateCheck.signal).then((value) => {\n latestVersion = value\n })\n const logLevel = logLevelMap[logLevelKey as keyof typeof logLevelMap] ?? logLevelMap.info\n const hooks = new Hookable<KubbHooks>()\n\n // CLI `--reporter` selects which reporters to trigger by name, defaulting to `cli`. `defineConfig`\n // registers the built-in reporters on the config; a config exported without it falls back to them below.\n const requestedNames: Array<ReporterName> = cliReporters?.length ? cliReporters : ['cli']\n\n // The `json` reporter owns stdout, so the command writes nothing of its own around it.\n const json = requestedNames.includes('json')\n const quiet = logLevel <= logLevelMap.silent || json\n\n // Errors raised outside a build have no report entry. In `json` mode they go to a stderr logger,\n // so they are never silent and stdout stays one JSON document.\n const errorHooks = json ? new Hookable<KubbHooks>() : hooks\n if (json) setupReporters(errorHooks, { logLevel, reporters: [cliReporter], writer: createPlainWriter(console.error) })\n\n // The config loads while the banner plays; the output still prints in order once the banner is done.\n const banner = quiet ? undefined : logBanner(version)\n const loading = getConfigs({\n configPath,\n input,\n watch,\n logLevel: logLevelKey as CLIOptions['logLevel'],\n })\n // Handled below; this keeps a rejection during the banner from counting as unhandled.\n loading.catch(() => undefined)\n await banner\n\n if (!quiet) {\n logIntro({ title: 'Configuration' })\n }\n\n // Load the config first so `config.reporters` can pick the reporters. A failure here has no\n // reporter installed yet, so fall back to the default `cli` reporter to surface it.\n const configSpinner = createSpinner()\n let configs: Array<Config>\n let resolvedConfigPath: string\n try {\n if (!quiet) configSpinner.start('Loading config')\n\n const loaded = await loading\n configs = loaded.configs\n resolvedConfigPath = loaded.configPath\n\n if (!quiet) configSpinner.stop(`Loaded ${styleText('dim', path.relative(process.cwd(), resolvedConfigPath))}`)\n } catch (error) {\n if (!quiet) configSpinner.error('Config failed loading')\n\n if (!json) setupReporters(hooks, { logLevel, reporters: [cliReporter] })\n // A diagnostic thrown while the config file runs, such as invalid extension options, sits in the cause chain.\n await Diagnostics.emit(errorHooks, error)\n\n if (!quiet) logOutro(styleText('red', '✗ Configuration failed'))\n process.exit(1)\n }\n\n // Without a reporter nothing is printed, not even an error, so a config written without\n // `defineConfig` gets the same built-ins it would have registered.\n const available = configs[0]?.reporters?.length ? configs[0].reporters : [cliReporter, jsonReporter, fileReporter, htmlReporter]\n const reporters = selectReporters(available, requestedNames)\n setupReporters(hooks, { logLevel, reporters, dryRun })\n\n await hooks.callHook('kubb:lifecycle:start', { version })\n\n if (!quiet) logOutro(`${pluralize(configs.length, 'config')} ready`)\n\n try {\n let anyFailed = false\n // One tracker, one key listener and one build queue serve every watched config, so several configs never mix diffs or answer `r` twice.\n const tracker = watch ? trackBuild(hooks) : undefined\n const rebuilds: Array<() => Promise<void>> = []\n let armKeys: (() => void) | undefined\n // Configs share the hooks emitter, so every build, from any watcher or the `r` key, waits for the one before it.\n let queue = Promise.resolve()\n for (const config of configs) {\n const effectiveInput = input ?? config.input\n const inputKind = typeof effectiveInput === 'string' ? getInputKind(effectiveInput) : undefined\n const watchPath = inputKind === 'file' ? (effectiveInput as string) : undefined\n if (watchPath && tracker) {\n const label = styleText('yellow', `Watching ${path.relative(process.cwd(), watchPath)}`)\n let previous: BuildSnapshot | undefined\n // Don't removeAll() between builds, that would also drop logger and lifecycle\n // listeners. Plugin listeners are already disposed by safeBuild's dispose()\n // in its finally block, so re-running generate() on the same hooks emitter is safe.\n const build = async () => {\n const hrStart = process.hrtime()\n const succeeded = await generate({ input, config, hooks, dryRun })\n const snapshot = tracker.take()\n if (previous) logRebuild({ diff: diffBuilds(previous, snapshot), durationMs: getElapsedMs(hrStart) })\n previous = snapshot\n\n logStep(armKeys ? `${label} ${styleText('dim', 'r rebuild · q quit')}` : label)\n armKeys?.()\n if (succeeded) {\n logSpacer()\n logTip()\n }\n }\n // A trigger that lands while this config's build is queued joins it; one that lands during the build queues one more. Never rejects.\n let pending = false\n const rebuild = (): Promise<void> => {\n if (pending) return queue\n pending = true\n queue = queue\n .then(() => {\n pending = false\n return build()\n })\n .catch((error) => void Diagnostics.emit(errorHooks, error))\n return queue\n }\n rebuilds.push(rebuild)\n if (!quiet) {\n armKeys ??= listenForKeys({\n rebuild: () => rebuilds.forEach((trigger) => void trigger()),\n quit: (code) => void Promise.resolve(hooks.callHook('kubb:lifecycle:end')).finally(() => process.exit(code)),\n })\n }\n\n // The watcher ignores its startup state, so run the first build here; a failing one keeps watching so the user can fix the input.\n await rebuild()\n\n await startWatcher([watchPath], rebuild, { info: logInfo, error: logError })\n } else {\n if (tracker && !quiet) logWarn('Watch mode only follows a local `input` file, so this config is generated once.')\n try {\n const succeeded = await generate({ input, config, hooks, dryRun })\n if (!succeeded) anyFailed = true\n } catch (configError) {\n await Diagnostics.emit(errorHooks, configError)\n anyFailed = true\n }\n }\n }\n\n // A request still in flight would keep the process alive until its timeout.\n updateCheck.abort()\n await checkForUpdate({ hooks, latestVersion })\n\n await hooks.callHook('kubb:lifecycle:end')\n\n // Watch mode prints a tip after each successful build. Regular generate commands need to\n // print one explicitly after the lifecycle group has closed so it stays outside the group.\n if (!quiet && !watch && !anyFailed) {\n logTip()\n }\n\n // `exitCode`, not `exit()`, so a telemetry request still in flight can finish within its timeout.\n if (anyFailed) {\n process.exitCode = 1\n }\n } catch (error) {\n await Diagnostics.emit(errorHooks, error)\n process.exit(1)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAkCA,MAAM,uBAAuB;;AAG7B,MAAM,0BAA0B;AAqBhC,eAAsB,SAAS,SAA0C;CACvE,MAAM,EAAE,OAAO,OAAO,SAAS,UAAU;CAEzC,MAAM,SAAS,SAAS;EAAE,SAAS;EAAY,SAAS,QAAQ,OAAO;CAAE,CAAC;CAE1E,MAAM,SAAiB;EACrB,GAAG,QAAQ;EACX,OAAO,SAAS,QAAQ,OAAO;EAE/B,SAAS,SAAS,cAAc,IAAI,QAAQ,OAAO;EAEnD,QAAQ,SAAS;GAAE,GAAG,QAAQ,OAAO;GAAQ,QAAQ;GAAO,MAAM;GAAO,cAAc,CAAC;EAAE,IAAI,QAAQ,OAAO;CAC/G;CAIA,MAAM,OAAO,WAAW,QAAQ,EAAE,MAAM,CAAC;CACzC,MAAM,SAAS,MAAM,KAAK,SAAS;CAGnC,OAAY;EAEV,SAAS,KAAK,OAAO,QAAQ,SAAS,MACpC,KAAK,OAAO,MAAM,WAAW,CAAC;GAAE,MAA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ACV,UAAU;MACV,OAAO,MAAM;KACf,CAAC,CAAC,CACD,OAAO,UAAU,KAAK,YAAY,KAAK,YAAY,KAAK,CAAC;KAC5D,OAAO;IACT;IACA,SAAS,KAAK,OAAO;IACrB,IAAI,CAAC,OACH,YAAY,cAAc;KACxB,eAAe,SAAS,SAAS,YAAY,KAAK,QAAQ,CAAC;KAC3D,OAAO,SAAS,KAAK,QAAQ,QAAQ,MAAM,SAAS,oBAAoB,CAAC,CAAC,CAAC,cAAc,QAAQ,KAAK,IAAI,CAAC;IAC7G,CAAC;IAIH,MAAM,QAAQ;IAEd,MAAM,aAAa,CAAC,SAAS,GAAG,SAAS;KAAE,MAAM;KAAS,OAAO;IAAS,CAAC;GAC7E,OAAO;IACL,IAAI,WAAW,CAAC,OAAO,QAAQ,iFAAiF;IAChH,IAAI;KAEF,IAAI,CAAC,MADmB,SAAS;MAAE;MAAO;MAAQ;MAAO;KAAO,CAAC,GACjD,YAAY;IAC9B,SAAS,aAAa;KACpB,MAAM,YAAY,KAAK,YAAY,WAAW;KAC9C,YAAY;IACd;GACF;EACF;EAGA,YAAY,MAAM;EAClB,MAAM,eAAe;GAAE;GAAO;EAAc,CAAC;EAE7C,MAAM,MAAM,SAAS,oBAAoB;EAIzC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,WACvB,OAAO;EAIT,IAAI,WACF,QAAQ,WAAW;CAEvB,SAAS,OAAO;EACd,MAAM,YAAY,KAAK,YAAY,KAAK;EACxC,QAAQ,KAAK,CAAC;CAChB;AACF"}
|
|
1
|
+
{"version":3,"file":"run-BBxFyD5y.js","names":["logLevel","logLevelMap"],"sources":["../src/runners/generate/run.ts"],"sourcesContent":["import path from 'node:path'\nimport process from 'node:process'\nimport { styleText } from 'node:util'\nimport { formatMs, formatters, getElapsedMs, linters } from '@internals/utils'\nimport {\n Hookable,\n type CLIOptions,\n cliReporter,\n type Config,\n createKubb,\n Diagnostics,\n fileReporter,\n getInputKind,\n htmlReporter,\n jsonReporter,\n type KubbHooks,\n logLevel as logLevelMap,\n memoryStorage,\n type ReporterName,\n} from '@kubb/core'\nimport { version } from '../../../package.json'\nimport { trackRun } from '../../Telemetry.ts'\nimport { pluralize } from '../../ui/text.ts'\nimport setupReporters, { selectReporters } from '../../loggers/reporters.ts'\nimport { createPlainWriter } from '../../loggers/plainWriter.ts'\nimport { logIntro, logOutro, logSpacer, logTip } from '../../ui/intro.ts'\nimport { logError, logInfo, logStep, logWarn } from '../../ui/log.ts'\nimport { logBanner } from '../../ui/mascot.ts'\nimport { createSpinner } from '../../ui/spinner.ts'\nimport { getConfigs } from '../../config.ts'\nimport { isOutdated } from '../../utils/registry.ts'\nimport { type BuildDiff, type BuildSnapshot, diffBuilds, listenForKeys, startWatcher, trackBuild } from './utils.ts'\n\n/** NPM registry endpoint used to check for @kubb/cli updates. */\nconst KUBB_NPM_PACKAGE_URL = 'https://registry.npmjs.org/@kubb/cli/latest' as const\n\n/** Upper bound in milliseconds for the npm update check, so a slow registry never stalls a run. */\nconst UPDATE_CHECK_TIMEOUT_MS = 3_000\n\n/** The formatter names from `Config['output'].format`, without `'auto'` (detection, not a tool) and `false` (skip). */\ntype FormatterName = Exclude<NonNullable<Config['output']['format']>, 'auto' | false>\ntype LinterName = Exclude<NonNullable<Config['output']['lint']>, 'auto' | false>\n\n// Pinned here, not in `@internals/utils` (which must not import `@kubb/core`): a tool added to the union without a descriptor fails to compile.\nformatters satisfies Record<FormatterName, unknown>\nlinters satisfies Record<LinterName, unknown>\n\ntype GenerateProps = {\n input?: string\n config: Config\n hooks: Hookable<KubbHooks>\n /**\n * When `true`, generates in memory instead of writing to disk, skips formatting, linting, and\n * post-generate commands, and prints what would change on disk.\n */\n dryRun?: boolean\n}\n\nexport async function generate(options: GenerateProps): Promise<boolean> {\n const { input, hooks, dryRun = false } = options\n\n const report = trackRun({ command: 'generate', hrStart: process.hrtime() })\n\n const config: Config = {\n ...options.config,\n input: input ?? options.config.input,\n // Dry-run never touches disk, regardless of the config's own storage driver.\n storage: dryRun ? memoryStorage() : options.config.storage,\n // Also keeps core's `hasOutputPasses` false, so dry-run skips the output manifest write too.\n output: dryRun ? { ...options.config.output, format: false, lint: false, postGenerate: [] } : options.config.output,\n }\n\n // Core formats, lints and runs `output.postGenerate` after an error-free build, and reports\n // their failures as coded diagnostics that reach the summary, the json report and the exit code.\n const kubb = createKubb(config, { hooks })\n const result = await kubb.generate()\n\n // Not awaited: the request finishes in the background, capped by its timeout, so it never delays the summary.\n void report({\n // A setup that threw leaves no driver, so read the configured plugins instead.\n plugins: kubb.config.plugins.flatMap((p) =>\n p && typeof p === 'object' ? [{ name: p.meta?.name ?? p.name ?? '', options: (p.options ?? {}) as Record<string, unknown> }] : [],\n ),\n filesCreated: result.files.length,\n status: result.success ? 'success' : 'failed',\n })\n\n return result.success\n}\n\ntype GenerateCommandOptions = {\n input?: string\n configPath?: string\n logLevel: string\n watch: boolean\n reporters?: Array<ReporterName>\n dryRun?: boolean\n}\n\n/** The latest published version, `undefined` when the registry does not answer in time or `signal` aborts. Never rejects. */\nasync function fetchLatestVersion(signal: AbortSignal): Promise<string | undefined> {\n try {\n const res = await fetch(KUBB_NPM_PACKAGE_URL, { signal: AbortSignal.any([signal, AbortSignal.timeout(UPDATE_CHECK_TIMEOUT_MS)]) })\n const data = (await res.json()) as { version: string }\n return data.version\n } catch {\n // Ignore network errors\n return undefined\n }\n}\n\nasync function checkForUpdate({ hooks, latestVersion }: { hooks: Hookable<KubbHooks>; latestVersion: string | undefined }): Promise<void> {\n if (latestVersion && isOutdated({ installed: version, latest: latestVersion })) {\n await Diagnostics.emit(hooks, Diagnostics.update({ currentVersion: version, latestVersion }))\n }\n}\n\n/** Prints `Rebuilt in 1.2s · +1 schema -2 operations`, without the names part when the spec kept the same names. */\nfunction logRebuild({ diff: { schemas, operations }, durationMs }: { diff: BuildDiff; durationMs: number }): void {\n const specChange = [\n schemas.added && styleText('green', `+${pluralize(schemas.added, 'schema')}`),\n schemas.removed && styleText('red', `-${pluralize(schemas.removed, 'schema')}`),\n operations.added && styleText('green', `+${pluralize(operations.added, 'operation')}`),\n operations.removed && styleText('red', `-${pluralize(operations.removed, 'operation')}`),\n ]\n .filter(Boolean)\n .join(' ')\n logStep([`Rebuilt in ${formatMs(durationMs)}`, specChange].filter(Boolean).join(styleText('dim', ' · ')))\n}\n\n/**\n * Runs the full Kubb generation lifecycle for the given CLI options.\n * Loads configs, sets up the reporters (CLI `--reporter` picks which of `config.reporters` to trigger),\n * calls `generate` for each config entry, and prints an update notice when the registry answered in time.\n */\nexport async function run({ input, configPath, logLevel: logLevelKey, watch, reporters: cliReporters, dryRun }: GenerateCommandOptions): Promise<void> {\n // Started first and never awaited: the notice prints at the end only when the registry has answered by then.\n const updateCheck = new AbortController()\n let latestVersion: string | undefined\n void fetchLatestVersion(updateCheck.signal).then((value) => {\n latestVersion = value\n })\n const logLevel = logLevelMap[logLevelKey as keyof typeof logLevelMap] ?? logLevelMap.info\n const hooks = new Hookable<KubbHooks>()\n\n // CLI `--reporter` selects which reporters to trigger by name, defaulting to `cli`. `defineConfig`\n // registers the built-in reporters on the config; a config exported without it falls back to them below.\n const requestedNames: Array<ReporterName> = cliReporters?.length ? cliReporters : ['cli']\n\n // The `json` reporter owns stdout, so the command writes nothing of its own around it.\n const json = requestedNames.includes('json')\n const quiet = logLevel <= logLevelMap.silent || json\n\n // Errors raised outside a build have no report entry. In `json` mode they go to a stderr logger,\n // so they are never silent and stdout stays one JSON document.\n const errorHooks = json ? new Hookable<KubbHooks>() : hooks\n if (json) setupReporters(errorHooks, { logLevel, reporters: [cliReporter], writer: createPlainWriter(console.error) })\n\n // The config loads while the banner plays; the output still prints in order once the banner is done.\n const banner = quiet ? undefined : logBanner(version)\n const loading = getConfigs({\n configPath,\n input,\n watch,\n logLevel: logLevelKey as CLIOptions['logLevel'],\n })\n // Handled below; this keeps a rejection during the banner from counting as unhandled.\n loading.catch(() => undefined)\n await banner\n\n if (!quiet) {\n logIntro({ title: 'Configuration' })\n }\n\n // Load the config first so `config.reporters` can pick the reporters. A failure here has no\n // reporter installed yet, so fall back to the default `cli` reporter to surface it.\n const configSpinner = createSpinner()\n let configs: Array<Config>\n let resolvedConfigPath: string\n try {\n if (!quiet) configSpinner.start('Loading config')\n\n const loaded = await loading\n configs = loaded.configs\n resolvedConfigPath = loaded.configPath\n\n if (!quiet) configSpinner.stop(`Loaded ${styleText('dim', path.relative(process.cwd(), resolvedConfigPath))}`)\n } catch (error) {\n if (!quiet) configSpinner.error('Config failed loading')\n\n if (!json) setupReporters(hooks, { logLevel, reporters: [cliReporter] })\n // A diagnostic thrown while the config file runs, such as invalid extension options, sits in the cause chain.\n await Diagnostics.emit(errorHooks, error)\n\n if (!quiet) logOutro(styleText('red', '✗ Configuration failed'))\n process.exit(1)\n }\n\n // Without a reporter nothing is printed, not even an error, so a config written without\n // `defineConfig` gets the same built-ins it would have registered.\n const available = configs[0]?.reporters?.length ? configs[0].reporters : [cliReporter, jsonReporter, fileReporter, htmlReporter]\n const reporters = selectReporters(available, requestedNames)\n setupReporters(hooks, { logLevel, reporters, dryRun })\n\n await hooks.callHook('kubb:lifecycle:start', { version })\n\n if (!quiet) logOutro(`${pluralize(configs.length, 'config')} ready`)\n\n try {\n let anyFailed = false\n // One tracker, one key listener and one build queue serve every watched config, so several configs never mix diffs or answer `r` twice.\n const tracker = watch ? trackBuild(hooks) : undefined\n const rebuilds: Array<() => Promise<void>> = []\n let armKeys: (() => void) | undefined\n // Configs share the hooks emitter, so every build, from any watcher or the `r` key, waits for the one before it.\n let queue = Promise.resolve()\n for (const config of configs) {\n const effectiveInput = input ?? config.input\n const inputKind = typeof effectiveInput === 'string' ? getInputKind(effectiveInput) : undefined\n const watchPath = inputKind === 'file' ? (effectiveInput as string) : undefined\n if (watchPath && tracker) {\n const label = styleText('yellow', `Watching ${path.relative(process.cwd(), watchPath)}`)\n let previous: BuildSnapshot | undefined\n // Don't removeAll() between builds, that would also drop logger and lifecycle\n // listeners. Plugin listeners are already disposed by safeBuild's dispose()\n // in its finally block, so re-running generate() on the same hooks emitter is safe.\n const build = async () => {\n const hrStart = process.hrtime()\n const succeeded = await generate({ input, config, hooks, dryRun })\n const snapshot = tracker.take()\n if (previous) logRebuild({ diff: diffBuilds(previous, snapshot), durationMs: getElapsedMs(hrStart) })\n previous = snapshot\n\n logStep(armKeys ? `${label} ${styleText('dim', 'r rebuild · q quit')}` : label)\n armKeys?.()\n if (succeeded) {\n logSpacer()\n logTip()\n }\n }\n // A trigger that lands while this config's build is queued joins it; one that lands during the build queues one more. Never rejects.\n let pending = false\n const rebuild = (): Promise<void> => {\n if (pending) return queue\n pending = true\n queue = queue\n .then(() => {\n pending = false\n return build()\n })\n .catch((error) => void Diagnostics.emit(errorHooks, error))\n return queue\n }\n rebuilds.push(rebuild)\n if (!quiet) {\n armKeys ??= listenForKeys({\n rebuild: () => rebuilds.forEach((trigger) => void trigger()),\n quit: (code) => void Promise.resolve(hooks.callHook('kubb:lifecycle:end')).finally(() => process.exit(code)),\n })\n }\n\n // The watcher ignores its startup state, so run the first build here; a failing one keeps watching so the user can fix the input.\n await rebuild()\n\n await startWatcher([watchPath], rebuild, { info: logInfo, error: logError })\n } else {\n if (tracker && !quiet) logWarn('Watch mode only follows a local `input` file, so this config is generated once.')\n try {\n const succeeded = await generate({ input, config, hooks, dryRun })\n if (!succeeded) anyFailed = true\n } catch (configError) {\n await Diagnostics.emit(errorHooks, configError)\n anyFailed = true\n }\n }\n }\n\n // A request still in flight would keep the process alive until its timeout.\n updateCheck.abort()\n await checkForUpdate({ hooks, latestVersion })\n\n await hooks.callHook('kubb:lifecycle:end')\n\n // Watch mode prints a tip after each successful build. Regular generate commands need to\n // print one explicitly after the lifecycle group has closed so it stays outside the group.\n if (!quiet && !watch && !anyFailed) {\n logTip()\n }\n\n // `exitCode`, not `exit()`, so a telemetry request still in flight can finish within its timeout.\n if (anyFailed) {\n process.exitCode = 1\n }\n } catch (error) {\n await Diagnostics.emit(errorHooks, error)\n process.exit(1)\n }\n}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IAC9B,SAAS,aAAa;KACpB,MAAM,YAAY,KAAK,YAAY,WAAW;KAC9C,YAAY;IACd;GACF;EACF;EAGA,YAAY,MAAM;EAClB,MAAM,eAAe;GAAE;GAAO;EAAc,CAAC;EAE7C,MAAM,MAAM,SAAS,oBAAoB;EAIzC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,WACvB,OAAO;EAIT,IAAI,WACF,QAAQ,WAAW;CAEvB,SAAS,OAAO;EACd,MAAM,YAAY,KAAK,YAAY,KAAK;EACxC,QAAQ,KAAK,CAAC;CAChB;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./rolldown-runtime-xo6NMXYd.js";
|
|
2
2
|
import { n as toError } from "./errors-wzqmMpMo.js";
|
|
3
|
-
import { n as trackRun } from "./Telemetry-
|
|
3
|
+
import { n as trackRun } from "./Telemetry-0sUi82eD.js";
|
|
4
4
|
import { n as pluralize } from "./text-EoYn04SX.js";
|
|
5
5
|
import { t as findConfigFile } from "./config-CQTxXvIG.js";
|
|
6
6
|
import { t as getConfigs } from "./config-Uk3rbZfb.js";
|
|
@@ -96,4 +96,4 @@ async function run({ input, configPath }) {
|
|
|
96
96
|
}
|
|
97
97
|
export { run };
|
|
98
98
|
|
|
99
|
-
//# sourceMappingURL=run-
|
|
99
|
+
//# sourceMappingURL=run-BQbhIlHi.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-
|
|
1
|
+
{"version":3,"file":"run-BQbhIlHi.js","names":[],"sources":["../src/runners/validate/run.ts"],"sourcesContent":["import process from 'node:process'\nimport { resolve } from 'node:path'\nimport { styleText } from 'node:util'\nimport { findConfigFile } from '@internals/shared'\nimport { toError } from '@internals/utils'\nimport { type Config, checkoutGitInput, getInputKind } from '@kubb/core'\nimport { trackRun } from '../../Telemetry.ts'\nimport { getConfigs } from '../../config.ts'\nimport { pluralize } from '../../ui/text.ts'\nimport { logCommandSummary } from '../../ui/summary.ts'\n\ntype ValidateOptions = {\n /**\n * Path, URL, or git input (`git+<repo>#<ref>:<path>`) of the specification to validate.\n */\n input: string\n configPath?: string\n}\n\n/**\n * Validates `input` with the configured adapters, falling back to OpenAPI when no config exists.\n * Exits the process with code 1 on validation failure or missing dependency.\n */\nexport async function run({ input, configPath }: ValidateOptions): Promise<void> {\n const hrStart = process.hrtime()\n const report = trackRun({ command: 'validate', hrStart })\n let adapterName: string | undefined\n\n try {\n const configFile = configPath ?? findConfigFile()\n // A config found by search that does not load must not block validating a file; an explicit `--config` still fails.\n const loaded = configFile\n ? await getConfigs({ configPath: configFile, input }).catch((error) => {\n if (configPath) throw error\n })\n : undefined\n const fallback = async () => {\n adapterName = '@kubb/adapter-oas'\n const { adapterOas } = await import('@kubb/adapter-oas')\n return [{ adapter: adapterOas(), input }]\n }\n // An array config often repeats one adapter, so each adapter and input pair is validated once.\n const unique = new Map(\n (loaded?.configs ?? []).map((config) => {\n const resolved = getInputKind(input) === 'file' ? resolve(config.root || process.cwd(), input) : input\n return [`${config.adapter?.name}\\0${resolved}`, { adapter: config.adapter, input: resolved }] as const\n }),\n )\n const targets: Array<{ adapter: Config['adapter']; input: string }> = loaded ? [...unique.values()] : await fallback()\n if (!targets.length) throw new Error('The Kubb config contains no configurations to validate.')\n for (const target of targets) {\n adapterName = target.adapter?.name\n if (!target.adapter) throw new Error('No adapter is configured. Set adapter in your Kubb config to validate this specification.')\n const checkout = getInputKind(target.input) === 'git' ? await checkoutGitInput(target.input) : undefined\n try {\n await target.adapter.validate(checkout?.path ?? target.input, { throwOnError: true })\n } finally {\n await checkout?.dispose()\n }\n }\n const specifications = new Set(targets.map((target) => target.input)).size\n const adapterNames = [...new Set(targets.flatMap((target) => target.adapter?.name ?? []))]\n await report({ status: 'success' })\n\n logCommandSummary({\n title: 'Validation passed',\n status: 'success',\n hrStart,\n lines: [\n ` ${styleText('bold', `${pluralize(specifications, 'specification')} validated`)}`,\n ` ${styleText('dim', 'Input')} ${styleText('cyan', input)}`,\n ` ${styleText('dim', adapterNames.length === 1 ? 'Adapter' : 'Adapters')} ${adapterNames.join(', ')}`,\n ],\n })\n } catch (error) {\n await report({ status: 'failed' })\n const message = toError(error).message\n const missingAdapter = adapterName === '@kubb/adapter-oas' && /(?:Cannot find|Cannot resolve|not found)[\\s\\S]*@kubb\\/adapter-oas/.test(message)\n logCommandSummary({\n title: missingAdapter ? 'Could not validate' : 'Validation failed',\n status: 'failed',\n hrStart,\n lines: [\n ` ${styleText('dim', 'Input')} ${styleText('cyan', input)}`,\n ` ${styleText('dim', 'Adapter')} ${adapterName ?? 'not configured'}${missingAdapter ? ' · not installed' : ''}`,\n '',\n styleText('bold', missingAdapter ? 'Required package' : 'Validation error'),\n ` ${styleText('red', message)}`,\n ...(missingAdapter\n ? ['', 'Install it with:', styleText('cyan', ' npm install @kubb/adapter-oas'), styleText('cyan', ' pnpm add @kubb/adapter-oas')]\n : []),\n ],\n })\n\n process.exit(1)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAuBA,eAAsB,IAAI,EAAE,OAAO,cAA8C;CAC/E,MAAM,UAAU,QAAQ,OAAO;CAC/B,MAAM,SAAS,SAAS;EAAE,SAAS;EAAY;CAAQ,CAAC;CACxD,IAAI;CAEJ,IAAI;EACF,MAAM,aAAa,cAAc,eAAe;EAEhD,MAAM,SAAS,aACX,MAAM,WAAW;GAAE,YAAY;GAAY;EAAM,CAAC,CAAC,CAAC,OAAO,UAAU;GACnE,IAAI,YAAY,MAAM;EACxB,CAAC,IACD,KAAA;EACJ,MAAM,WAAW,YAAY;GAC3B,cAAc;GACd,MAAM,EAAE,eAAe,MAAM,OAAO;GACpC,OAAO,CAAC;IAAE,SAAS,WAAW;IAAG;GAAM,CAAC;EAC1C;EAEA,MAAM,SAAS,IAAI,KAChB,QAAQ,WAAW,CAAC,EAAA,CAAG,KAAK,WAAW;GACtC,MAAM,WAAW,aAAa,KAAK,MAAM,SAAS,QAAQ,OAAO,QAAQ,QAAQ,IAAI,GAAG,KAAK,IAAI;GACj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B,oEAAoE,KAAK,OAAO;EAC9I,kBAAkB;GAChB,OAAO,iBAAiB,uBAAuB;GAC/C,QAAQ;GACR;GACA,OAAO;IACL,KAAK,UAAU,OAAO,OAAO,EAAE,MAAM,UAAU,QAAQ,KAAK;IAC5D,KAAK,UAAU,OAAO,SAAS,EAAE,IAAI,eAAe,mBAAmB,iBAAiB,qBAAqB;IAC7G;IACA,UAAU,QAAQ,iBAAiB,qBAAqB,kBAAkB;IAC1E,KAAK,UAAU,OAAO,OAAO;IAC7B,GAAI,iBACA;KAAC;KAAI;KAAoB,UAAU,QAAQ,iCAAiC;KAAG,UAAU,QAAQ,8BAA8B;IAAC,IAChI,CAAC;GACP;EACF,CAAC;EAED,QAAQ,KAAK,CAAC;CAChB;AACF"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-C3-Zg-KD.cjs");
|
|
2
|
-
const require_utils = require("./utils-
|
|
2
|
+
const require_utils = require("./utils-DeXBGzGJ.cjs");
|
|
3
3
|
const require_time = require("./time-3BKoci3G.cjs");
|
|
4
4
|
const require_spinner = require("./spinner-RfMb7fd6.cjs");
|
|
5
|
-
const require_package = require("./package-
|
|
5
|
+
const require_package = require("./package-Q8Q8RNv3.cjs");
|
|
6
6
|
const require_log = require("./log-wv1OxLiq.cjs");
|
|
7
7
|
const require_intro = require("./intro-DuyzJ3Rb.cjs");
|
|
8
8
|
const require_config = require("./config-CRrmj88c.cjs");
|
|
9
|
-
const require_configFile = require("./configFile-
|
|
9
|
+
const require_configFile = require("./configFile-BPHxtrEM.cjs");
|
|
10
10
|
const require_config$1 = require("./config-BWj9jBVj.cjs");
|
|
11
11
|
const require_text = require("./text-DMiX2dcG.cjs");
|
|
12
12
|
const require_registry = require("./registry-Q77p5TZp.cjs");
|
|
13
|
-
const require_installWithSpinner = require("./installWithSpinner-
|
|
13
|
+
const require_installWithSpinner = require("./installWithSpinner-CnE4dIza.cjs");
|
|
14
14
|
let node_util = require("node:util");
|
|
15
15
|
let gunshi = require("gunshi");
|
|
16
16
|
let node_process = require("node:process");
|
|
@@ -372,4 +372,4 @@ const command = (0, gunshi.defineWithTypes)()({
|
|
|
372
372
|
exports.command = command;
|
|
373
373
|
exports.run = run;
|
|
374
374
|
|
|
375
|
-
//# sourceMappingURL=run-
|
|
375
|
+
//# sourceMappingURL=run-BUljCBLA.cjs.map
|