@kubb/cli 5.7.0 → 5.8.1
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-BMOPPGHO.js → Telemetry-C3raFshE.js} +2 -2
- package/dist/{Telemetry-BMOPPGHO.js.map → Telemetry-C3raFshE.js.map} +1 -1
- package/dist/{Telemetry-DYBLbGUo.cjs → Telemetry-DVdoZ5i3.cjs} +2 -2
- package/dist/{Telemetry-DYBLbGUo.cjs.map → Telemetry-DVdoZ5i3.cjs.map} +1 -1
- package/dist/{background-CY8X3xrg.cjs → background-BXczDhV0.cjs} +2 -2
- package/dist/{background-CY8X3xrg.cjs.map → background-BXczDhV0.cjs.map} +1 -1
- package/dist/background-DHfGpbjE.js +1 -0
- package/dist/{background-vORfkoMw.js → background-KPjyLyLs.js} +2 -2
- package/dist/{background-vORfkoMw.js.map → background-KPjyLyLs.js.map} +1 -1
- package/dist/{commands-eTkrUsmn.js → commands-DAb8WcSg.js} +3 -3
- package/dist/{commands-eTkrUsmn.js.map → commands-DAb8WcSg.js.map} +1 -1
- package/dist/{commands-B3w7oC6w.cjs → commands-Dves_8Dw.cjs} +3 -3
- package/dist/{commands-B3w7oC6w.cjs.map → commands-Dves_8Dw.cjs.map} +1 -1
- package/dist/{config-DX176_YM.cjs → config-CRBZcWwg.cjs} +16 -61
- package/dist/config-CRBZcWwg.cjs.map +1 -0
- package/dist/{config-Czvfdmb6.js → config-DAdYwK_D.js} +14 -53
- package/dist/config-DAdYwK_D.js.map +1 -0
- package/dist/{errors-CMbMAwyW.cjs → errors-BdA8M78q.cjs} +19 -1
- package/dist/{errors-CMbMAwyW.cjs.map → errors-BdA8M78q.cjs.map} +1 -1
- package/dist/{errors-BQJzaUwP.js → errors-DmC83ALX.js} +14 -2
- package/dist/{errors-BQJzaUwP.js.map → errors-DmC83ALX.js.map} +1 -1
- package/dist/index.cjs +128 -40
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.js +128 -40
- package/dist/index.js.map +1 -1
- package/dist/{output-DekB5lg3.cjs → output-CWupdozw.cjs} +31 -31
- package/dist/output-CWupdozw.cjs.map +1 -0
- package/dist/registry-CCKUL3ps.cjs +113 -0
- package/dist/registry-CCKUL3ps.cjs.map +1 -0
- package/dist/registry-DjGepXb0.js +77 -0
- package/dist/registry-DjGepXb0.js.map +1 -0
- package/dist/reporters-C5HAypFq.cjs +67 -0
- package/dist/reporters-C5HAypFq.cjs.map +1 -0
- package/dist/reporters-CNZQUlXY.js +55 -0
- package/dist/reporters-CNZQUlXY.js.map +1 -0
- package/dist/{run-q7t1opzc.cjs → run-33URIiPM.cjs} +9 -8
- package/dist/{run-q7t1opzc.cjs.map → run-33URIiPM.cjs.map} +1 -1
- package/dist/run-B9wWJSSx.js +65 -0
- package/dist/run-B9wWJSSx.js.map +1 -0
- package/dist/{run-C0-6Jt5R.js → run-BMHEBZbR.js} +6 -5
- package/dist/{run-C0-6Jt5R.js.map → run-BMHEBZbR.js.map} +1 -1
- package/dist/run-BURZ4hDs.js +106 -0
- package/dist/run-BURZ4hDs.js.map +1 -0
- package/dist/run-BaFyksnF.cjs +72 -0
- package/dist/run-BaFyksnF.cjs.map +1 -0
- package/dist/{run-ChNfjD8e.js → run-Bl8Evvbv.js} +3 -3
- package/dist/{run-ChNfjD8e.js.map → run-Bl8Evvbv.js.map} +1 -1
- package/dist/run-C4IHvWT_.cjs +109 -0
- package/dist/run-C4IHvWT_.cjs.map +1 -0
- package/dist/run-CDS3EWEN.js +71 -0
- package/dist/run-CDS3EWEN.js.map +1 -0
- package/dist/{run-gZj9QLbh.cjs → run-CYlBM95X.cjs} +3 -3
- package/dist/{run-gZj9QLbh.cjs.map → run-CYlBM95X.cjs.map} +1 -1
- package/dist/{run-BofroBgd.cjs → run-CZ26dcKd.cjs} +3 -3
- package/dist/{run-BofroBgd.cjs.map → run-CZ26dcKd.cjs.map} +1 -1
- package/dist/run-DVIqUt1x.cjs +67 -0
- package/dist/run-DVIqUt1x.cjs.map +1 -0
- package/dist/{run-DAvPwUw8.js → run-DkuGqsyU.js} +3 -3
- package/dist/{run-DAvPwUw8.js.map → run-DkuGqsyU.js.map} +1 -1
- package/dist/{run-BVMDJFOI.cjs → run-DnnQQi1q.cjs} +11 -9
- package/dist/{run-BVMDJFOI.cjs.map → run-DnnQQi1q.cjs.map} +1 -1
- package/dist/{run-s3XYpkCe.cjs → run-E11sqsk0.cjs} +9 -81
- package/dist/run-E11sqsk0.cjs.map +1 -0
- package/dist/{run-DS4T5yWG.js → run-FH6VbxNn.js} +7 -5
- package/dist/{run-DS4T5yWG.js.map → run-FH6VbxNn.js.map} +1 -1
- package/dist/{run-BTU318R1.js → run-USNnlQcA.js} +2 -74
- package/dist/run-USNnlQcA.js.map +1 -0
- package/dist/{snapshot-BIHvFhoD.js → snapshot-CVc0EW6M.js} +4 -4
- package/dist/{snapshot-BIHvFhoD.js.map → snapshot-CVc0EW6M.js.map} +1 -1
- package/dist/{snapshot-8My94tFp.cjs → snapshot-RIdF2azE.cjs} +7 -7
- package/dist/{snapshot-8My94tFp.cjs.map → snapshot-RIdF2azE.cjs.map} +1 -1
- package/dist/studioWorker.js +2 -2
- package/dist/utils-Dhx5PMpD.js +80 -0
- package/dist/utils-Dhx5PMpD.js.map +1 -0
- package/dist/utils-ZcCFqERz.cjs +106 -0
- package/dist/utils-ZcCFqERz.cjs.map +1 -0
- package/package.json +7 -7
- package/dist/background-C9hewu3p.js +0 -2
- package/dist/config-Czvfdmb6.js.map +0 -1
- package/dist/config-DX176_YM.cjs.map +0 -1
- package/dist/output-DekB5lg3.cjs.map +0 -1
- package/dist/run-BTU318R1.js.map +0 -1
- package/dist/run-s3XYpkCe.cjs.map +0 -1
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import "./rolldown-runtime-CRm0XQPb.js";
|
|
2
|
+
import { t as getErrorMessage } from "./errors-DmC83ALX.js";
|
|
3
|
+
import { t as findConfigFile } from "./config-DAdYwK_D.js";
|
|
4
|
+
import { a as logInfo, d as logWarn, i as logError, l as logStep, o as logIntro, r as logBlock, s as logOutro } from "./output-B9Yw7vL0.js";
|
|
5
|
+
import { a as registryUrl, o as toRegistryId, r as incompatibility, t as fetchRegistryDetail } from "./registry-DjGepXb0.js";
|
|
6
|
+
import { i as installPackages, t as detectPackageManager } from "./utils-Dhx5PMpD.js";
|
|
7
|
+
import { styleText } from "node:util";
|
|
8
|
+
import process from "node:process";
|
|
9
|
+
import path from "node:path";
|
|
10
|
+
import * as clack from "@clack/prompts";
|
|
11
|
+
//#region src/runners/add/run.ts
|
|
12
|
+
/** The import and the `defineConfig` property to merge into `kubb.config.ts` by hand. */
|
|
13
|
+
function toSnippet({ artifact, manifest }) {
|
|
14
|
+
const call = `${manifest.export}()`;
|
|
15
|
+
const property = {
|
|
16
|
+
plugin: `plugins: [..., ${call}],`,
|
|
17
|
+
adapter: `adapter: ${call},`,
|
|
18
|
+
parser: `parsers: [..., ${call}],`
|
|
19
|
+
};
|
|
20
|
+
return [
|
|
21
|
+
`import { ${manifest.export} } from '${artifact.package}'`,
|
|
22
|
+
"",
|
|
23
|
+
property[manifest.kind]
|
|
24
|
+
].join("\n");
|
|
25
|
+
}
|
|
26
|
+
/** Adds the plugin call and its import to the config file. Returns why it could not, or `undefined`. */
|
|
27
|
+
async function addToConfig({ detail, configFile }) {
|
|
28
|
+
const { artifact, manifest } = detail;
|
|
29
|
+
try {
|
|
30
|
+
const { writeConfigEdits } = await import("@kubb/studio");
|
|
31
|
+
const { outcomes } = await writeConfigEdits({
|
|
32
|
+
filePath: configFile,
|
|
33
|
+
edits: [{
|
|
34
|
+
operation: "add-plugin",
|
|
35
|
+
plugin: artifact.package,
|
|
36
|
+
importName: manifest.export
|
|
37
|
+
}],
|
|
38
|
+
extensions: /* @__PURE__ */ new Map([[artifact.package, {
|
|
39
|
+
package: artifact.package,
|
|
40
|
+
version: artifact.version,
|
|
41
|
+
manifest
|
|
42
|
+
}]])
|
|
43
|
+
});
|
|
44
|
+
return outcomes[0]?.applied ? void 0 : outcomes[0]?.reason ?? "the config file was not changed";
|
|
45
|
+
} catch (error) {
|
|
46
|
+
return getErrorMessage(error);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Installs an extension from the Kubb registry at its reviewed version and, for a plugin, adds it to
|
|
51
|
+
* `kubb.config.ts`. Refuses when the running Kubb or Node.js version is outside its compatibility.
|
|
52
|
+
*/
|
|
53
|
+
async function run({ id: input, configPath, yes, install }) {
|
|
54
|
+
const cwd = process.cwd();
|
|
55
|
+
logIntro({ title: styleText("bgCyan", styleText("black", " Kubb Add ")) });
|
|
56
|
+
try {
|
|
57
|
+
const registry = registryUrl();
|
|
58
|
+
const detail = await fetchRegistryDetail({
|
|
59
|
+
id: toRegistryId(input),
|
|
60
|
+
registry
|
|
61
|
+
});
|
|
62
|
+
const { artifact, manifest } = detail;
|
|
63
|
+
const problem = incompatibility(manifest);
|
|
64
|
+
if (problem) throw new Error(problem);
|
|
65
|
+
const spec = `${artifact.package}@${artifact.version}`;
|
|
66
|
+
const configFile = manifest.kind === "plugin" ? configPath ? path.resolve(configPath) : findConfigFile(cwd) : void 0;
|
|
67
|
+
if (manifest.kind === "plugin" && !configFile) throw new Error("No kubb.config.ts found. Run `kubb init` first, or pass --config.");
|
|
68
|
+
logInfo(`${styleText("cyan", manifest.displayName)} (${manifest.kind}): ${manifest.description}`);
|
|
69
|
+
logBlock([install ? `Install ${styleText("cyan", spec)} as a dev dependency` : `Skip installing ${spec}`, configFile ? `Add ${styleText("cyan", `${manifest.export}()`)} to ${path.relative(cwd, configFile) || configFile}` : `Print the ${manifest.kind} snippet to add`]);
|
|
70
|
+
const confirmed = yes || await clack.confirm({
|
|
71
|
+
message: "Continue?",
|
|
72
|
+
initialValue: true
|
|
73
|
+
});
|
|
74
|
+
if (clack.isCancel(confirmed) || !confirmed) {
|
|
75
|
+
clack.cancel("Operation canceled.");
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
if (install) {
|
|
79
|
+
const packageManager = detectPackageManager(cwd);
|
|
80
|
+
logStep(`Installing ${spec} with ${packageManager.name}`);
|
|
81
|
+
await installPackages([spec], packageManager, cwd);
|
|
82
|
+
}
|
|
83
|
+
const reason = configFile ? await addToConfig({
|
|
84
|
+
detail,
|
|
85
|
+
configFile
|
|
86
|
+
}) : `add the ${manifest.kind} to your config`;
|
|
87
|
+
if (!reason) {
|
|
88
|
+
logOutro(styleText("green", install ? `Added ${spec}` : `Added ${manifest.export}() to the config. Install ${spec} to use it.`));
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (configFile) logWarn(`Could not edit ${configFile}: ${reason}`);
|
|
92
|
+
logBlock([
|
|
93
|
+
"Add the import to your Kubb config and merge the property into its defineConfig call:",
|
|
94
|
+
"",
|
|
95
|
+
toSnippet(detail)
|
|
96
|
+
]);
|
|
97
|
+
logOutro(styleText("green", install ? `Installed ${spec}. Add it with the snippet above.` : `Install ${spec} and add the snippet above.`));
|
|
98
|
+
} catch (error) {
|
|
99
|
+
logError(getErrorMessage(error));
|
|
100
|
+
process.exitCode = 1;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
//#endregion
|
|
104
|
+
export { run };
|
|
105
|
+
|
|
106
|
+
//# sourceMappingURL=run-BURZ4hDs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-BURZ4hDs.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 { getErrorMessage } from '@internals/utils'\nimport type { ExtensionManifest, RegistryDetail } from '@kubb/core'\nimport { findConfigFile } from '../../config.ts'\nimport { logBlock, logError, logInfo, logIntro, logOutro, logStep, logWarn } from '../../loggers/output.ts'\nimport { fetchRegistryDetail, incompatibility, registryUrl, toRegistryId } from '../../utils/registry.ts'\nimport { detectPackageManager, installPackages } from '../init/utils.ts'\n\nexport type AddOptions = {\n /**\n * `owner/slug`, or a bare `slug` for an official extension.\n */\n id: string\n configPath?: string\n yes: boolean\n install: boolean\n}\n\n/** The import and the `defineConfig` property to merge into `kubb.config.ts` by hand. */\nexport function toSnippet({ artifact, manifest }: Pick<RegistryDetail, 'artifact' | 'manifest'>): 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/** Adds the plugin call and its import to the config file. Returns why it could not, or `undefined`. */\nasync function addToConfig({ detail, configFile }: { detail: RegistryDetail; configFile: string }): Promise<string | undefined> {\n const { artifact, manifest } = detail\n try {\n const { writeConfigEdits } = await import('@kubb/studio')\n const { outcomes } = await writeConfigEdits({\n filePath: configFile,\n edits: [{ operation: 'add-plugin', plugin: artifact.package, importName: manifest.export }],\n extensions: new Map([[artifact.package, { package: artifact.package, version: artifact.version, manifest }]]),\n })\n return outcomes[0]?.applied ? undefined : (outcomes[0]?.reason ?? 'the config file was not changed')\n } catch (error) {\n return getErrorMessage(error)\n }\n}\n\n/**\n * Installs an extension from the Kubb registry at its reviewed version and, for a plugin, adds it to\n * `kubb.config.ts`. Refuses when the running Kubb or Node.js version is outside its compatibility.\n */\nexport async function run({ id: input, configPath, yes, install }: AddOptions): Promise<void> {\n const cwd = process.cwd()\n logIntro({ title: styleText('bgCyan', styleText('black', ' Kubb Add ')) })\n\n try {\n const registry = registryUrl()\n const detail = await fetchRegistryDetail({ id: toRegistryId(input), registry })\n const { artifact, manifest } = detail\n\n const problem = incompatibility(manifest)\n if (problem) throw new Error(problem)\n\n const spec = `${artifact.package}@${artifact.version}`\n const configFile = manifest.kind === 'plugin' ? (configPath ? path.resolve(configPath) : findConfigFile(cwd)) : undefined\n if (manifest.kind === 'plugin' && !configFile) throw new Error('No kubb.config.ts found. Run `kubb init` first, or pass --config.')\n\n logInfo(`${styleText('cyan', manifest.displayName)} (${manifest.kind}): ${manifest.description}`)\n logBlock([\n install ? `Install ${styleText('cyan', spec)} as a dev dependency` : `Skip installing ${spec}`,\n configFile\n ? `Add ${styleText('cyan', `${manifest.export}()`)} to ${path.relative(cwd, configFile) || configFile}`\n : `Print the ${manifest.kind} snippet to add`,\n ])\n\n const confirmed = yes || (await clack.confirm({ message: 'Continue?', initialValue: true }))\n if (clack.isCancel(confirmed) || !confirmed) {\n clack.cancel('Operation canceled.')\n return\n }\n\n if (install) {\n const packageManager = detectPackageManager(cwd)\n logStep(`Installing ${spec} with ${packageManager.name}`)\n await installPackages([spec], packageManager, cwd)\n }\n\n const reason = configFile ? await addToConfig({ detail, configFile }) : `add the ${manifest.kind} to your config`\n if (!reason) {\n logOutro(styleText('green', install ? `Added ${spec}` : `Added ${manifest.export}() to the config. Install ${spec} to use it.`))\n return\n }\n\n if (configFile) logWarn(`Could not edit ${configFile}: ${reason}`)\n logBlock(['Add the import to your Kubb config and merge the property into its defineConfig call:', '', toSnippet(detail)])\n logOutro(styleText('green', install ? `Installed ${spec}. Add it with the snippet above.` : `Install ${spec} and add the snippet above.`))\n } catch (error) {\n logError(getErrorMessage(error))\n process.exitCode = 1\n }\n}\n"],"mappings":";;;;;;;;;;;;AAsBA,SAAgB,UAAU,EAAE,UAAU,YAAmE;CACvG,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,eAAe,YAAY,EAAE,QAAQ,cAA2F;CAC9H,MAAM,EAAE,UAAU,aAAa;CAC/B,IAAI;EACF,MAAM,EAA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KAAK,SAAS,KAAK,UAAU,KAAK,eACzF,aAAa,SAAS,KAAK,gBACjC,CAAC;EAED,MAAM,YAAY,OAAQ,MAAM,MAAM,QAAQ;GAAE,SAAS;GAAa,cAAc;EAAK,CAAC;EAC1F,IAAI,MAAM,SAAS,SAAS,KAAK,CAAC,WAAW;GAC3C,MAAM,OAAO,qBAAqB;GAClC;EACF;EAEA,IAAI,SAAS;GACX,MAAM,iBAAiB,qBAAqB,GAAG;GAC/C,QAAQ,cAAc,KAAK,QAAQ,eAAe,MAAM;GACxD,MAAM,gBAAgB,CAAC,IAAI,GAAG,gBAAgB,GAAG;EACnD;EAEA,MAAM,SAAS,aAAa,MAAM,YAAY;GAAE;GAAQ;EAAW,CAAC,IAAI,WAAW,SAAS,KAAK;EACjG,IAAI,CAAC,QAAQ;GACX,SAAS,UAAU,SAAS,UAAU,SAAS,SAAS,SAAS,SAAS,OAAO,4BAA4B,KAAK,YAAY,CAAC;GAC/H;EACF;EAEA,IAAI,YAAY,QAAQ,kBAAkB,WAAW,IAAI,QAAQ;EACjE,SAAS;GAAC;GAAyF;GAAI,UAAU,MAAM;EAAC,CAAC;EACzH,SAAS,UAAU,SAAS,UAAU,aAAa,KAAK,oCAAoC,WAAW,KAAK,4BAA4B,CAAC;CAC3I,SAAS,OAAO;EACd,SAAS,gBAAgB,KAAK,CAAC;EAC/B,QAAQ,WAAW;CACrB;AACF"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
const require_agent = require("./agent-DElUuYuy.cjs");
|
|
2
|
+
const require_errors = require("./errors-BdA8M78q.cjs");
|
|
3
|
+
const require_output = require("./output-CWupdozw.cjs");
|
|
4
|
+
const require_registry = require("./registry-CCKUL3ps.cjs");
|
|
5
|
+
let node_util = require("node:util");
|
|
6
|
+
let node_process = require("node:process");
|
|
7
|
+
node_process = require_agent.__toESM(node_process, 1);
|
|
8
|
+
let _kubb_core = require("@kubb/core");
|
|
9
|
+
//#region src/runners/list/run.ts
|
|
10
|
+
/**
|
|
11
|
+
* The installed packages that ship a `kubb-extension.json` or have a registry entry, with the
|
|
12
|
+
* version the registry pins.
|
|
13
|
+
*/
|
|
14
|
+
async function listExtensions({ cwd, registry }) {
|
|
15
|
+
const [installed, entries] = await Promise.all([(0, _kubb_core.readInstalledPackages)({ root: cwd }), require_registry.fetchRegistryIndex({ registry }).catch((error) => {
|
|
16
|
+
require_output.logWarn(`Showing installed extensions only: ${require_errors.getErrorMessage(error)}`);
|
|
17
|
+
return [];
|
|
18
|
+
})]);
|
|
19
|
+
const byPackage = new Map(entries.map((entry) => [entry.artifact.package, entry]));
|
|
20
|
+
return installed.flatMap(({ package: name, version, manifest }) => {
|
|
21
|
+
const entry = byPackage.get(name);
|
|
22
|
+
if (!entry && !manifest) return [];
|
|
23
|
+
const latest = entry?.artifact.version;
|
|
24
|
+
return [{
|
|
25
|
+
id: entry?.id,
|
|
26
|
+
package: name,
|
|
27
|
+
installed: version,
|
|
28
|
+
registry: latest,
|
|
29
|
+
update: !!latest && require_registry.isOutdated({
|
|
30
|
+
installed: version,
|
|
31
|
+
latest
|
|
32
|
+
})
|
|
33
|
+
}];
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
/** Prints the installed extensions as a table. */
|
|
37
|
+
async function run() {
|
|
38
|
+
try {
|
|
39
|
+
const rows = await listExtensions({
|
|
40
|
+
cwd: node_process.default.cwd(),
|
|
41
|
+
registry: require_registry.registryUrl()
|
|
42
|
+
});
|
|
43
|
+
if (!rows.length) {
|
|
44
|
+
require_output.logOutro("No installed extensions found.");
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const header = [
|
|
48
|
+
"ID",
|
|
49
|
+
"PACKAGE",
|
|
50
|
+
"INSTALLED",
|
|
51
|
+
"REGISTRY",
|
|
52
|
+
"UPDATE"
|
|
53
|
+
];
|
|
54
|
+
const cells = rows.map((row) => [
|
|
55
|
+
row.id ?? "-",
|
|
56
|
+
row.package,
|
|
57
|
+
row.installed ?? "-",
|
|
58
|
+
row.registry ?? "-",
|
|
59
|
+
row.update ? "yes" : "no"
|
|
60
|
+
]);
|
|
61
|
+
const widths = header.map((title, index) => Math.max(title.length, ...cells.map((cell) => cell[index].length)));
|
|
62
|
+
const line = (cell) => cell.map((value, index) => value.padEnd(widths[index])).join(" ").trimEnd();
|
|
63
|
+
require_output.logBlock([(0, node_util.styleText)("dim", line(header)), ...cells.map(line)]);
|
|
64
|
+
} catch (error) {
|
|
65
|
+
require_output.logError(require_errors.getErrorMessage(error));
|
|
66
|
+
node_process.default.exitCode = 1;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
//#endregion
|
|
70
|
+
exports.run = run;
|
|
71
|
+
|
|
72
|
+
//# sourceMappingURL=run-BaFyksnF.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-BaFyksnF.cjs","names":["readInstalledPackages","fetchRegistryIndex","getErrorMessage","isOutdated","process","registryUrl","styleText"],"sources":["../src/runners/list/run.ts"],"sourcesContent":["import process from 'node:process'\nimport { styleText } from 'node:util'\nimport { getErrorMessage } from '@internals/utils'\nimport { readInstalledPackages, type RegistryEntry } from '@kubb/core'\nimport { logBlock, logError, logOutro, logWarn } from '../../loggers/output.ts'\nimport { fetchRegistryIndex, isOutdated, registryUrl } from '../../utils/registry.ts'\n\nexport type ListRow = {\n id?: string\n package: string\n installed?: string\n registry?: string\n update: boolean\n}\n\n/**\n * The installed packages that ship a `kubb-extension.json` or have a registry entry, with the\n * version the registry pins.\n */\nexport async function listExtensions({ cwd, registry }: { cwd: string; registry: string }): Promise<Array<ListRow>> {\n const [installed, entries] = await Promise.all([\n readInstalledPackages({ root: cwd }),\n fetchRegistryIndex({ registry }).catch((error: unknown): Array<RegistryEntry> => {\n logWarn(`Showing installed extensions only: ${getErrorMessage(error)}`)\n return []\n }),\n ])\n const byPackage = new Map(entries.map((entry) => [entry.artifact.package, entry]))\n\n return installed.flatMap(({ package: name, version, manifest }): Array<ListRow> => {\n const entry = byPackage.get(name)\n if (!entry && !manifest) return []\n const latest = entry?.artifact.version\n return [{ id: entry?.id, package: name, installed: version, registry: latest, update: !!latest && isOutdated({ installed: version, latest }) }]\n })\n}\n\n/** Prints the installed extensions as a table. */\nexport async function run(): Promise<void> {\n try {\n const rows = await listExtensions({ cwd: process.cwd(), registry: registryUrl() })\n if (!rows.length) {\n logOutro('No installed extensions found.')\n return\n }\n\n const header = ['ID', 'PACKAGE', 'INSTALLED', 'REGISTRY', 'UPDATE']\n const cells = rows.map((row) => [row.id ?? '-', row.package, row.installed ?? '-', row.registry ?? '-', row.update ? 'yes' : 'no'])\n const widths = header.map((title, index) => Math.max(title.length, ...cells.map((cell) => cell[index]!.length)))\n const line = (cell: Array<string>) =>\n cell\n .map((value, index) => value.padEnd(widths[index]!))\n .join(' ')\n .trimEnd()\n\n logBlock([styleText('dim', line(header)), ...cells.map(line)])\n } catch (error) {\n logError(getErrorMessage(error))\n process.exitCode = 1\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAmBA,eAAsB,eAAe,EAAE,KAAK,YAAwE;CAClH,MAAM,CAAC,WAAW,WAAW,MAAM,QAAQ,IAAI,EAAA,GAC7CA,WAAAA,sBAAAA,CAAsB,EAAE,MAAM,IAAI,CAAC,GACnCC,iBAAAA,mBAAmB,EAAE,SAAS,CAAC,CAAC,CAAC,OAAO,UAAyC;EAC/E,eAAA,QAAQ,sCAAsCC,eAAAA,gBAAgB,KAAK,GAAG;EACtE,OAAO,CAAC;CACV,CAAC,CACH,CAAC;CACD,MAAM,YAAY,IAAI,IAAI,QAAQ,KAAK,UAAU,CAAC,MAAM,SAAS,SAAS,KAAK,CAAC,CAAC;CAEjF,OAAO,UAAU,SAAS,EAAE,SAAS,MAAM,SAAS,eAA+B;EACjF,MAAM,QAAQ,UAAU,IAAI,IAAI;EAChC,IAAI,CAAC,SAAS,CAAC,UAAU,OAAO,CAAC;EACjC,MAAM,SAAS,OAAO,SAAS;EAC/B,OAAO,CAAC;GAAE,IAAI,OAAO;GAAI,SAAS;GAAM,WAAW;GAAS,UAAU;GAAQ,QAAQ,CAAC,CAAC,UAAUC,iBAAAA,WAAW;IAAE,WAAW;IAAS;GAAO,CAAC;EAAE,CAAC;CAChJ,CAAC;AACH;;AAGA,eAAsB,MAAqB;CACzC,IAAI;EACF,MAAM,OAAO,MAAM,eAAe;GAAE,KAAKC,aAAAA,QAAQ,IAAI;GAAG,UAAUC,iBAAAA,YAAY;EAAE,CAAC;EACjF,IAAI,CAAC,KAAK,QAAQ;GAChB,eAAA,SAAS,gCAAgC;GACzC;EACF;EAEA,MAAM,SAAS;GAAC;GAAM;GAAW;GAAa;GAAY;EAAQ;EAClE,MAAM,QAAQ,KAAK,KAAK,QAAQ;GAAC,IAAI,MAAM;GAAK,IAAI;GAAS,IAAI,aAAa;GAAK,IAAI,YAAY;GAAK,IAAI,SAAS,QAAQ;EAAI,CAAC;EAClI,MAAM,SAAS,OAAO,KAAK,OAAO,UAAU,KAAK,IAAI,MAAM,QAAQ,GAAG,MAAM,KAAK,SAAS,KAAK,MAAM,CAAE,MAAM,CAAC,CAAC;EAC/G,MAAM,QAAQ,SACZ,KACG,KAAK,OAAO,UAAU,MAAM,OAAO,OAAO,MAAO,CAAC,CAAC,CACnD,KAAK,IAAI,CAAC,CACV,QAAQ;EAEb,eAAA,SAAS,EAAA,GAACC,UAAAA,UAAAA,CAAU,OAAO,KAAK,MAAM,CAAC,GAAG,GAAG,MAAM,IAAI,IAAI,CAAC,CAAC;CAC/D,SAAS,OAAO;EACd,eAAA,SAASJ,eAAAA,gBAAgB,KAAK,CAAC;EAC/B,aAAA,QAAA,WAAmB;CACrB;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./rolldown-runtime-CRm0XQPb.js";
|
|
2
|
-
import {
|
|
3
|
-
import { n as trackRun } from "./Telemetry-
|
|
2
|
+
import { n as toError } from "./errors-DmC83ALX.js";
|
|
3
|
+
import { n as trackRun } from "./Telemetry-C3raFshE.js";
|
|
4
4
|
import { styleText } from "node:util";
|
|
5
5
|
import process from "node:process";
|
|
6
6
|
//#region src/runners/validate/run.ts
|
|
@@ -39,4 +39,4 @@ async function run({ input }) {
|
|
|
39
39
|
//#endregion
|
|
40
40
|
export { run };
|
|
41
41
|
|
|
42
|
-
//# sourceMappingURL=run-
|
|
42
|
+
//# sourceMappingURL=run-Bl8Evvbv.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-
|
|
1
|
+
{"version":3,"file":"run-Bl8Evvbv.js","names":[],"sources":["../src/runners/validate/run.ts"],"sourcesContent":["import process from 'node:process'\nimport { styleText } from 'node:util'\nimport { toError } from '@internals/utils'\nimport { trackRun } from '../../Telemetry.ts'\n\ntype ValidateOptions = {\n /**\n * Path or URL to the OpenAPI/Swagger file to validate.\n */\n input: string\n}\n\n/**\n * Validates an OpenAPI/Swagger file at `input` using `@kubb/adapter-oas`.\n * Exits the process with code 1 on validation failure or missing dependency.\n */\nexport async function run({ input }: ValidateOptions): Promise<void> {\n const report = trackRun({ command: 'validate', hrStart: process.hrtime() })\n\n try {\n const { adapterOas } = await import('@kubb/adapter-oas')\n\n const adapter = adapterOas()\n if (!adapter.validate) {\n throw new Error('The loaded adapter does not support validation.')\n }\n\n await adapter.validate(input, { throwOnError: true })\n await report({ status: 'success' })\n\n console.log('✅ Validation success')\n } catch (error) {\n await report({ status: 'failed' })\n if (error instanceof Error && /@kubb\\/adapter-oas/.test(error.message)) {\n console.error(styleText('red', 'The @kubb/adapter-oas package is not installed.'))\n console.error('')\n console.error('Install it with:')\n console.error(styleText('cyan', ' npm install @kubb/adapter-oas'))\n console.error(styleText('cyan', ' # or'))\n console.error(styleText('cyan', ' pnpm install @kubb/adapter-oas'))\n console.error('')\n }\n console.error('❌ Validation failed')\n console.error(toError(error).message)\n\n process.exit(1)\n }\n}\n"],"mappings":";;;;;;;;;;AAgBA,eAAsB,IAAI,EAAE,SAAyC;CACnE,MAAM,SAAS,SAAS;EAAE,SAAS;EAAY,SAAS,QAAQ,OAAO;CAAE,CAAC;CAE1E,IAAI;EACF,MAAM,EAAE,eAAe,MAAM,OAAO;EAEpC,MAAM,UAAU,WAAW;EAC3B,IAAI,CAAC,QAAQ,UACX,MAAM,IAAI,MAAM,iDAAiD;EAGnE,MAAM,QAAQ,SAAS,OAAO,EAAE,cAAc,KAAK,CAAC;EACpD,MAAM,OAAO,EAAE,QAAQ,UAAU,CAAC;EAElC,QAAQ,IAAI,sBAAsB;CACpC,SAAS,OAAO;EACd,MAAM,OAAO,EAAE,QAAQ,SAAS,CAAC;EACjC,IAAI,iBAAiB,SAAS,qBAAqB,KAAK,MAAM,OAAO,GAAG;GACtE,QAAQ,MAAM,UAAU,OAAO,iDAAiD,CAAC;GACjF,QAAQ,MAAM,EAAE;GAChB,QAAQ,MAAM,kBAAkB;GAChC,QAAQ,MAAM,UAAU,QAAQ,iCAAiC,CAAC;GAClE,QAAQ,MAAM,UAAU,QAAQ,QAAQ,CAAC;GACzC,QAAQ,MAAM,UAAU,QAAQ,kCAAkC,CAAC;GACnE,QAAQ,MAAM,EAAE;EAClB;EACA,QAAQ,MAAM,qBAAqB;EACnC,QAAQ,MAAM,QAAQ,KAAK,CAAC,CAAC,OAAO;EAEpC,QAAQ,KAAK,CAAC;CAChB;AACF"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
const require_agent = require("./agent-DElUuYuy.cjs");
|
|
2
|
+
const require_errors = require("./errors-BdA8M78q.cjs");
|
|
3
|
+
const require_config = require("./config-CRBZcWwg.cjs");
|
|
4
|
+
const require_output = require("./output-CWupdozw.cjs");
|
|
5
|
+
const require_registry = require("./registry-CCKUL3ps.cjs");
|
|
6
|
+
const require_utils = require("./utils-ZcCFqERz.cjs");
|
|
7
|
+
let node_util = require("node:util");
|
|
8
|
+
let node_process = require("node:process");
|
|
9
|
+
node_process = require_agent.__toESM(node_process, 1);
|
|
10
|
+
let node_path = require("node:path");
|
|
11
|
+
node_path = require_agent.__toESM(node_path, 1);
|
|
12
|
+
let _clack_prompts = require("@clack/prompts");
|
|
13
|
+
_clack_prompts = require_agent.__toESM(_clack_prompts, 1);
|
|
14
|
+
//#region src/runners/add/run.ts
|
|
15
|
+
/** The import and the `defineConfig` property to merge into `kubb.config.ts` by hand. */
|
|
16
|
+
function toSnippet({ artifact, manifest }) {
|
|
17
|
+
const call = `${manifest.export}()`;
|
|
18
|
+
const property = {
|
|
19
|
+
plugin: `plugins: [..., ${call}],`,
|
|
20
|
+
adapter: `adapter: ${call},`,
|
|
21
|
+
parser: `parsers: [..., ${call}],`
|
|
22
|
+
};
|
|
23
|
+
return [
|
|
24
|
+
`import { ${manifest.export} } from '${artifact.package}'`,
|
|
25
|
+
"",
|
|
26
|
+
property[manifest.kind]
|
|
27
|
+
].join("\n");
|
|
28
|
+
}
|
|
29
|
+
/** Adds the plugin call and its import to the config file. Returns why it could not, or `undefined`. */
|
|
30
|
+
async function addToConfig({ detail, configFile }) {
|
|
31
|
+
const { artifact, manifest } = detail;
|
|
32
|
+
try {
|
|
33
|
+
const { writeConfigEdits } = await import("@kubb/studio");
|
|
34
|
+
const { outcomes } = await writeConfigEdits({
|
|
35
|
+
filePath: configFile,
|
|
36
|
+
edits: [{
|
|
37
|
+
operation: "add-plugin",
|
|
38
|
+
plugin: artifact.package,
|
|
39
|
+
importName: manifest.export
|
|
40
|
+
}],
|
|
41
|
+
extensions: /* @__PURE__ */ new Map([[artifact.package, {
|
|
42
|
+
package: artifact.package,
|
|
43
|
+
version: artifact.version,
|
|
44
|
+
manifest
|
|
45
|
+
}]])
|
|
46
|
+
});
|
|
47
|
+
return outcomes[0]?.applied ? void 0 : outcomes[0]?.reason ?? "the config file was not changed";
|
|
48
|
+
} catch (error) {
|
|
49
|
+
return require_errors.getErrorMessage(error);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Installs an extension from the Kubb registry at its reviewed version and, for a plugin, adds it to
|
|
54
|
+
* `kubb.config.ts`. Refuses when the running Kubb or Node.js version is outside its compatibility.
|
|
55
|
+
*/
|
|
56
|
+
async function run({ id: input, configPath, yes, install }) {
|
|
57
|
+
const cwd = node_process.default.cwd();
|
|
58
|
+
require_output.logIntro({ title: (0, node_util.styleText)("bgCyan", (0, node_util.styleText)("black", " Kubb Add ")) });
|
|
59
|
+
try {
|
|
60
|
+
const registry = require_registry.registryUrl();
|
|
61
|
+
const detail = await require_registry.fetchRegistryDetail({
|
|
62
|
+
id: require_registry.toRegistryId(input),
|
|
63
|
+
registry
|
|
64
|
+
});
|
|
65
|
+
const { artifact, manifest } = detail;
|
|
66
|
+
const problem = require_registry.incompatibility(manifest);
|
|
67
|
+
if (problem) throw new Error(problem);
|
|
68
|
+
const spec = `${artifact.package}@${artifact.version}`;
|
|
69
|
+
const configFile = manifest.kind === "plugin" ? configPath ? node_path.default.resolve(configPath) : require_config.findConfigFile(cwd) : void 0;
|
|
70
|
+
if (manifest.kind === "plugin" && !configFile) throw new Error("No kubb.config.ts found. Run `kubb init` first, or pass --config.");
|
|
71
|
+
require_output.logInfo(`${(0, node_util.styleText)("cyan", manifest.displayName)} (${manifest.kind}): ${manifest.description}`);
|
|
72
|
+
require_output.logBlock([install ? `Install ${(0, node_util.styleText)("cyan", spec)} as a dev dependency` : `Skip installing ${spec}`, configFile ? `Add ${(0, node_util.styleText)("cyan", `${manifest.export}()`)} to ${node_path.default.relative(cwd, configFile) || configFile}` : `Print the ${manifest.kind} snippet to add`]);
|
|
73
|
+
const confirmed = yes || await _clack_prompts.confirm({
|
|
74
|
+
message: "Continue?",
|
|
75
|
+
initialValue: true
|
|
76
|
+
});
|
|
77
|
+
if (_clack_prompts.isCancel(confirmed) || !confirmed) {
|
|
78
|
+
_clack_prompts.cancel("Operation canceled.");
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (install) {
|
|
82
|
+
const packageManager = require_utils.detectPackageManager(cwd);
|
|
83
|
+
require_output.logStep(`Installing ${spec} with ${packageManager.name}`);
|
|
84
|
+
await require_utils.installPackages([spec], packageManager, cwd);
|
|
85
|
+
}
|
|
86
|
+
const reason = configFile ? await addToConfig({
|
|
87
|
+
detail,
|
|
88
|
+
configFile
|
|
89
|
+
}) : `add the ${manifest.kind} to your config`;
|
|
90
|
+
if (!reason) {
|
|
91
|
+
require_output.logOutro((0, node_util.styleText)("green", install ? `Added ${spec}` : `Added ${manifest.export}() to the config. Install ${spec} to use it.`));
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
if (configFile) require_output.logWarn(`Could not edit ${configFile}: ${reason}`);
|
|
95
|
+
require_output.logBlock([
|
|
96
|
+
"Add the import to your Kubb config and merge the property into its defineConfig call:",
|
|
97
|
+
"",
|
|
98
|
+
toSnippet(detail)
|
|
99
|
+
]);
|
|
100
|
+
require_output.logOutro((0, node_util.styleText)("green", install ? `Installed ${spec}. Add it with the snippet above.` : `Install ${spec} and add the snippet above.`));
|
|
101
|
+
} catch (error) {
|
|
102
|
+
require_output.logError(require_errors.getErrorMessage(error));
|
|
103
|
+
node_process.default.exitCode = 1;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
//#endregion
|
|
107
|
+
exports.run = run;
|
|
108
|
+
|
|
109
|
+
//# sourceMappingURL=run-C4IHvWT_.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-C4IHvWT_.cjs","names":["getErrorMessage","process","styleText","registryUrl","fetchRegistryDetail","toRegistryId","incompatibility","path","findConfigFile","clack","detectPackageManager","installPackages"],"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 { getErrorMessage } from '@internals/utils'\nimport type { ExtensionManifest, RegistryDetail } from '@kubb/core'\nimport { findConfigFile } from '../../config.ts'\nimport { logBlock, logError, logInfo, logIntro, logOutro, logStep, logWarn } from '../../loggers/output.ts'\nimport { fetchRegistryDetail, incompatibility, registryUrl, toRegistryId } from '../../utils/registry.ts'\nimport { detectPackageManager, installPackages } from '../init/utils.ts'\n\nexport type AddOptions = {\n /**\n * `owner/slug`, or a bare `slug` for an official extension.\n */\n id: string\n configPath?: string\n yes: boolean\n install: boolean\n}\n\n/** The import and the `defineConfig` property to merge into `kubb.config.ts` by hand. */\nexport function toSnippet({ artifact, manifest }: Pick<RegistryDetail, 'artifact' | 'manifest'>): 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/** Adds the plugin call and its import to the config file. Returns why it could not, or `undefined`. */\nasync function addToConfig({ detail, configFile }: { detail: RegistryDetail; configFile: string }): Promise<string | undefined> {\n const { artifact, manifest } = detail\n try {\n const { writeConfigEdits } = await import('@kubb/studio')\n const { outcomes } = await writeConfigEdits({\n filePath: configFile,\n edits: [{ operation: 'add-plugin', plugin: artifact.package, importName: manifest.export }],\n extensions: new Map([[artifact.package, { package: artifact.package, version: artifact.version, manifest }]]),\n })\n return outcomes[0]?.applied ? undefined : (outcomes[0]?.reason ?? 'the config file was not changed')\n } catch (error) {\n return getErrorMessage(error)\n }\n}\n\n/**\n * Installs an extension from the Kubb registry at its reviewed version and, for a plugin, adds it to\n * `kubb.config.ts`. Refuses when the running Kubb or Node.js version is outside its compatibility.\n */\nexport async function run({ id: input, configPath, yes, install }: AddOptions): Promise<void> {\n const cwd = process.cwd()\n logIntro({ title: styleText('bgCyan', styleText('black', ' Kubb Add ')) })\n\n try {\n const registry = registryUrl()\n const detail = await fetchRegistryDetail({ id: toRegistryId(input), registry })\n const { artifact, manifest } = detail\n\n const problem = incompatibility(manifest)\n if (problem) throw new Error(problem)\n\n const spec = `${artifact.package}@${artifact.version}`\n const configFile = manifest.kind === 'plugin' ? (configPath ? path.resolve(configPath) : findConfigFile(cwd)) : undefined\n if (manifest.kind === 'plugin' && !configFile) throw new Error('No kubb.config.ts found. Run `kubb init` first, or pass --config.')\n\n logInfo(`${styleText('cyan', manifest.displayName)} (${manifest.kind}): ${manifest.description}`)\n logBlock([\n install ? `Install ${styleText('cyan', spec)} as a dev dependency` : `Skip installing ${spec}`,\n configFile\n ? `Add ${styleText('cyan', `${manifest.export}()`)} to ${path.relative(cwd, configFile) || configFile}`\n : `Print the ${manifest.kind} snippet to add`,\n ])\n\n const confirmed = yes || (await clack.confirm({ message: 'Continue?', initialValue: true }))\n if (clack.isCancel(confirmed) || !confirmed) {\n clack.cancel('Operation canceled.')\n return\n }\n\n if (install) {\n const packageManager = detectPackageManager(cwd)\n logStep(`Installing ${spec} with ${packageManager.name}`)\n await installPackages([spec], packageManager, cwd)\n }\n\n const reason = configFile ? await addToConfig({ detail, configFile }) : `add the ${manifest.kind} to your config`\n if (!reason) {\n logOutro(styleText('green', install ? `Added ${spec}` : `Added ${manifest.export}() to the config. Install ${spec} to use it.`))\n return\n }\n\n if (configFile) logWarn(`Could not edit ${configFile}: ${reason}`)\n logBlock(['Add the import to your Kubb config and merge the property into its defineConfig call:', '', toSnippet(detail)])\n logOutro(styleText('green', install ? `Installed ${spec}. Add it with the snippet above.` : `Install ${spec} and add the snippet above.`))\n } catch (error) {\n logError(getErrorMessage(error))\n process.exitCode = 1\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAsBA,SAAgB,UAAU,EAAE,UAAU,YAAmE;CACvG,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,eAAe,YAAY,EAAE,QAAQ,cAA2F;CAC9H,MAAM,EAAE,UAA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0 +1,71 @@
|
|
|
1
|
+
import "./rolldown-runtime-CRm0XQPb.js";
|
|
2
|
+
import { t as getErrorMessage } from "./errors-DmC83ALX.js";
|
|
3
|
+
import { d as logWarn, i as logError, r as logBlock, s as logOutro } from "./output-B9Yw7vL0.js";
|
|
4
|
+
import { a as registryUrl, i as isOutdated, n as fetchRegistryIndex } from "./registry-DjGepXb0.js";
|
|
5
|
+
import { styleText } from "node:util";
|
|
6
|
+
import process from "node:process";
|
|
7
|
+
import { readInstalledPackages } from "@kubb/core";
|
|
8
|
+
//#region src/runners/list/run.ts
|
|
9
|
+
/**
|
|
10
|
+
* The installed packages that ship a `kubb-extension.json` or have a registry entry, with the
|
|
11
|
+
* version the registry pins.
|
|
12
|
+
*/
|
|
13
|
+
async function listExtensions({ cwd, registry }) {
|
|
14
|
+
const [installed, entries] = await Promise.all([readInstalledPackages({ root: cwd }), fetchRegistryIndex({ registry }).catch((error) => {
|
|
15
|
+
logWarn(`Showing installed extensions only: ${getErrorMessage(error)}`);
|
|
16
|
+
return [];
|
|
17
|
+
})]);
|
|
18
|
+
const byPackage = new Map(entries.map((entry) => [entry.artifact.package, entry]));
|
|
19
|
+
return installed.flatMap(({ package: name, version, manifest }) => {
|
|
20
|
+
const entry = byPackage.get(name);
|
|
21
|
+
if (!entry && !manifest) return [];
|
|
22
|
+
const latest = entry?.artifact.version;
|
|
23
|
+
return [{
|
|
24
|
+
id: entry?.id,
|
|
25
|
+
package: name,
|
|
26
|
+
installed: version,
|
|
27
|
+
registry: latest,
|
|
28
|
+
update: !!latest && isOutdated({
|
|
29
|
+
installed: version,
|
|
30
|
+
latest
|
|
31
|
+
})
|
|
32
|
+
}];
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/** Prints the installed extensions as a table. */
|
|
36
|
+
async function run() {
|
|
37
|
+
try {
|
|
38
|
+
const rows = await listExtensions({
|
|
39
|
+
cwd: process.cwd(),
|
|
40
|
+
registry: registryUrl()
|
|
41
|
+
});
|
|
42
|
+
if (!rows.length) {
|
|
43
|
+
logOutro("No installed extensions found.");
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const header = [
|
|
47
|
+
"ID",
|
|
48
|
+
"PACKAGE",
|
|
49
|
+
"INSTALLED",
|
|
50
|
+
"REGISTRY",
|
|
51
|
+
"UPDATE"
|
|
52
|
+
];
|
|
53
|
+
const cells = rows.map((row) => [
|
|
54
|
+
row.id ?? "-",
|
|
55
|
+
row.package,
|
|
56
|
+
row.installed ?? "-",
|
|
57
|
+
row.registry ?? "-",
|
|
58
|
+
row.update ? "yes" : "no"
|
|
59
|
+
]);
|
|
60
|
+
const widths = header.map((title, index) => Math.max(title.length, ...cells.map((cell) => cell[index].length)));
|
|
61
|
+
const line = (cell) => cell.map((value, index) => value.padEnd(widths[index])).join(" ").trimEnd();
|
|
62
|
+
logBlock([styleText("dim", line(header)), ...cells.map(line)]);
|
|
63
|
+
} catch (error) {
|
|
64
|
+
logError(getErrorMessage(error));
|
|
65
|
+
process.exitCode = 1;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
export { run };
|
|
70
|
+
|
|
71
|
+
//# sourceMappingURL=run-CDS3EWEN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-CDS3EWEN.js","names":[],"sources":["../src/runners/list/run.ts"],"sourcesContent":["import process from 'node:process'\nimport { styleText } from 'node:util'\nimport { getErrorMessage } from '@internals/utils'\nimport { readInstalledPackages, type RegistryEntry } from '@kubb/core'\nimport { logBlock, logError, logOutro, logWarn } from '../../loggers/output.ts'\nimport { fetchRegistryIndex, isOutdated, registryUrl } from '../../utils/registry.ts'\n\nexport type ListRow = {\n id?: string\n package: string\n installed?: string\n registry?: string\n update: boolean\n}\n\n/**\n * The installed packages that ship a `kubb-extension.json` or have a registry entry, with the\n * version the registry pins.\n */\nexport async function listExtensions({ cwd, registry }: { cwd: string; registry: string }): Promise<Array<ListRow>> {\n const [installed, entries] = await Promise.all([\n readInstalledPackages({ root: cwd }),\n fetchRegistryIndex({ registry }).catch((error: unknown): Array<RegistryEntry> => {\n logWarn(`Showing installed extensions only: ${getErrorMessage(error)}`)\n return []\n }),\n ])\n const byPackage = new Map(entries.map((entry) => [entry.artifact.package, entry]))\n\n return installed.flatMap(({ package: name, version, manifest }): Array<ListRow> => {\n const entry = byPackage.get(name)\n if (!entry && !manifest) return []\n const latest = entry?.artifact.version\n return [{ id: entry?.id, package: name, installed: version, registry: latest, update: !!latest && isOutdated({ installed: version, latest }) }]\n })\n}\n\n/** Prints the installed extensions as a table. */\nexport async function run(): Promise<void> {\n try {\n const rows = await listExtensions({ cwd: process.cwd(), registry: registryUrl() })\n if (!rows.length) {\n logOutro('No installed extensions found.')\n return\n }\n\n const header = ['ID', 'PACKAGE', 'INSTALLED', 'REGISTRY', 'UPDATE']\n const cells = rows.map((row) => [row.id ?? '-', row.package, row.installed ?? '-', row.registry ?? '-', row.update ? 'yes' : 'no'])\n const widths = header.map((title, index) => Math.max(title.length, ...cells.map((cell) => cell[index]!.length)))\n const line = (cell: Array<string>) =>\n cell\n .map((value, index) => value.padEnd(widths[index]!))\n .join(' ')\n .trimEnd()\n\n logBlock([styleText('dim', line(header)), ...cells.map(line)])\n } catch (error) {\n logError(getErrorMessage(error))\n process.exitCode = 1\n }\n}\n"],"mappings":";;;;;;;;;;;;AAmBA,eAAsB,eAAe,EAAE,KAAK,YAAwE;CAClH,MAAM,CAAC,WAAW,WAAW,MAAM,QAAQ,IAAI,CAC7C,sBAAsB,EAAE,MAAM,IAAI,CAAC,GACnC,mBAAmB,EAAE,SAAS,CAAC,CAAC,CAAC,OAAO,UAAyC;EAC/E,QAAQ,sCAAsC,gBAAgB,KAAK,GAAG;EACtE,OAAO,CAAC;CACV,CAAC,CACH,CAAC;CACD,MAAM,YAAY,IAAI,IAAI,QAAQ,KAAK,UAAU,CAAC,MAAM,SAAS,SAAS,KAAK,CAAC,CAAC;CAEjF,OAAO,UAAU,SA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const require_Telemetry = require("./Telemetry-
|
|
2
|
+
const require_errors = require("./errors-BdA8M78q.cjs");
|
|
3
|
+
const require_Telemetry = require("./Telemetry-DVdoZ5i3.cjs");
|
|
4
4
|
let node_util = require("node:util");
|
|
5
5
|
let node_process = require("node:process");
|
|
6
6
|
node_process = require_agent.__toESM(node_process, 1);
|
|
@@ -40,4 +40,4 @@ async function run({ input }) {
|
|
|
40
40
|
//#endregion
|
|
41
41
|
exports.run = run;
|
|
42
42
|
|
|
43
|
-
//# sourceMappingURL=run-
|
|
43
|
+
//# sourceMappingURL=run-CYlBM95X.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-
|
|
1
|
+
{"version":3,"file":"run-CYlBM95X.cjs","names":["trackRun","process","styleText","toError"],"sources":["../src/runners/validate/run.ts"],"sourcesContent":["import process from 'node:process'\nimport { styleText } from 'node:util'\nimport { toError } from '@internals/utils'\nimport { trackRun } from '../../Telemetry.ts'\n\ntype ValidateOptions = {\n /**\n * Path or URL to the OpenAPI/Swagger file to validate.\n */\n input: string\n}\n\n/**\n * Validates an OpenAPI/Swagger file at `input` using `@kubb/adapter-oas`.\n * Exits the process with code 1 on validation failure or missing dependency.\n */\nexport async function run({ input }: ValidateOptions): Promise<void> {\n const report = trackRun({ command: 'validate', hrStart: process.hrtime() })\n\n try {\n const { adapterOas } = await import('@kubb/adapter-oas')\n\n const adapter = adapterOas()\n if (!adapter.validate) {\n throw new Error('The loaded adapter does not support validation.')\n }\n\n await adapter.validate(input, { throwOnError: true })\n await report({ status: 'success' })\n\n console.log('✅ Validation success')\n } catch (error) {\n await report({ status: 'failed' })\n if (error instanceof Error && /@kubb\\/adapter-oas/.test(error.message)) {\n console.error(styleText('red', 'The @kubb/adapter-oas package is not installed.'))\n console.error('')\n console.error('Install it with:')\n console.error(styleText('cyan', ' npm install @kubb/adapter-oas'))\n console.error(styleText('cyan', ' # or'))\n console.error(styleText('cyan', ' pnpm install @kubb/adapter-oas'))\n console.error('')\n }\n console.error('❌ Validation failed')\n console.error(toError(error).message)\n\n process.exit(1)\n }\n}\n"],"mappings":";;;;;;;;;;;AAgBA,eAAsB,IAAI,EAAE,SAAyC;CACnE,MAAM,SAASA,kBAAAA,SAAS;EAAE,SAAS;EAAY,SAASC,aAAAA,QAAQ,OAAO;CAAE,CAAC;CAE1E,IAAI;EACF,MAAM,EAAE,eAAe,MAAM,OAAO;EAEpC,MAAM,UAAU,WAAW;EAC3B,IAAI,CAAC,QAAQ,UACX,MAAM,IAAI,MAAM,iDAAiD;EAGnE,MAAM,QAAQ,SAAS,OAAO,EAAE,cAAc,KAAK,CAAC;EACpD,MAAM,OAAO,EAAE,QAAQ,UAAU,CAAC;EAElC,QAAQ,IAAI,sBAAsB;CACpC,SAAS,OAAO;EACd,MAAM,OAAO,EAAE,QAAQ,SAAS,CAAC;EACjC,IAAI,iBAAiB,SAAS,qBAAqB,KAAK,MAAM,OAAO,GAAG;GACtE,QAAQ,OAAA,GAAMC,UAAAA,UAAAA,CAAU,OAAO,iDAAiD,CAAC;GACjF,QAAQ,MAAM,EAAE;GAChB,QAAQ,MAAM,kBAAkB;GAChC,QAAQ,OAAA,GAAMA,UAAAA,UAAAA,CAAU,QAAQ,iCAAiC,CAAC;GAClE,QAAQ,OAAA,GAAMA,UAAAA,UAAAA,CAAU,QAAQ,QAAQ,CAAC;GACzC,QAAQ,OAAA,GAAMA,UAAAA,UAAAA,CAAU,QAAQ,kCAAkC,CAAC;GACnE,QAAQ,MAAM,EAAE;EAClB;EACA,QAAQ,MAAM,qBAAqB;EACnC,QAAQ,MAAMC,eAAAA,QAAQ,KAAK,CAAC,CAAC,OAAO;EAEpC,aAAA,QAAQ,KAAK,CAAC;CAChB;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_agent = require("./agent-DElUuYuy.cjs");
|
|
2
|
-
const require_errors = require("./errors-
|
|
3
|
-
const require_Telemetry = require("./Telemetry-
|
|
2
|
+
const require_errors = require("./errors-BdA8M78q.cjs");
|
|
3
|
+
const require_Telemetry = require("./Telemetry-DVdoZ5i3.cjs");
|
|
4
4
|
let node_util = require("node:util");
|
|
5
5
|
let node_process = require("node:process");
|
|
6
6
|
node_process = require_agent.__toESM(node_process, 1);
|
|
@@ -28,4 +28,4 @@ async function run() {
|
|
|
28
28
|
//#endregion
|
|
29
29
|
exports.run = run;
|
|
30
30
|
|
|
31
|
-
//# sourceMappingURL=run-
|
|
31
|
+
//# sourceMappingURL=run-CZ26dcKd.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-
|
|
1
|
+
{"version":3,"file":"run-CZ26dcKd.cjs","names":["trackRun","process","styleText","toError"],"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 await startMcpServer()\n await report({ status: 'success' })\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,SAASA,kBAAAA,SAAS;EAAE,SAAS;EAAO,SAASC,aAAAA,QAAQ,OAAO;CAAE,CAAC;CAErE,IAAI;EAEF,QAAQ,OAAA,GAAMC,UAAAA,UAAAA,CAAU,QAAQ,0BAA0B,CAAC;EAC3D,QAAQ,MAAA,GAAKA,UAAAA,UAAAA,CAAU,UAAU,2DAA2D,CAAC;EAC7F,MAAM,eAAe;EACrB,MAAM,OAAO,EAAE,QAAQ,UAAU,CAAC;CACpC,SAAS,OAAO;EACd,MAAM,OAAO,EAAE,QAAQ,SAAS,CAAC;EACjC,QAAQ,MAAMC,eAAAA,QAAQ,KAAK,CAAC,CAAC,OAAO;EACpC,aAAA,QAAA,WAAmB;CACrB;AACF"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
const require_agent = require("./agent-DElUuYuy.cjs");
|
|
2
|
+
const require_errors = require("./errors-BdA8M78q.cjs");
|
|
3
|
+
const require_output = require("./output-CWupdozw.cjs");
|
|
4
|
+
const require_registry = require("./registry-CCKUL3ps.cjs");
|
|
5
|
+
const require_utils = require("./utils-ZcCFqERz.cjs");
|
|
6
|
+
let node_util = require("node:util");
|
|
7
|
+
let node_process = require("node:process");
|
|
8
|
+
node_process = require_agent.__toESM(node_process, 1);
|
|
9
|
+
let _clack_prompts = require("@clack/prompts");
|
|
10
|
+
_clack_prompts = require_agent.__toESM(_clack_prompts, 1);
|
|
11
|
+
let _kubb_core = require("@kubb/core");
|
|
12
|
+
//#region src/runners/update/run.ts
|
|
13
|
+
/**
|
|
14
|
+
* Moves installed extensions to the version the registry pins. Lists the proposals, asks, then
|
|
15
|
+
* installs them. With `check`, only lists them.
|
|
16
|
+
*/
|
|
17
|
+
async function run({ ids, check, yes }) {
|
|
18
|
+
const cwd = node_process.default.cwd();
|
|
19
|
+
require_output.logIntro({ title: (0, node_util.styleText)("bgCyan", (0, node_util.styleText)("black", " Kubb Update ")) });
|
|
20
|
+
try {
|
|
21
|
+
const wanted = new Set(ids.map(require_registry.toRegistryId));
|
|
22
|
+
const [entries, installed] = await Promise.all([require_registry.fetchRegistryIndex({ registry: require_registry.registryUrl() }), (0, _kubb_core.readInstalledPackages)({ root: cwd })]);
|
|
23
|
+
const versions = new Map(installed.map((item) => [item.package, item.version]));
|
|
24
|
+
const tracked = entries.filter((entry) => versions.has(entry.artifact.package) && (!wanted.size || wanted.has(entry.id)));
|
|
25
|
+
for (const id of wanted) if (!tracked.some((entry) => entry.id === id)) require_output.logWarn(`${id} is not installed, or not in the registry.`);
|
|
26
|
+
const proposals = tracked.filter((entry) => {
|
|
27
|
+
if (!require_registry.isOutdated({
|
|
28
|
+
installed: versions.get(entry.artifact.package),
|
|
29
|
+
latest: entry.artifact.version
|
|
30
|
+
})) return false;
|
|
31
|
+
const problem = require_registry.incompatibility(entry.manifest);
|
|
32
|
+
if (problem) require_output.logWarn(`Skipped ${entry.id}: ${problem}`);
|
|
33
|
+
return !problem;
|
|
34
|
+
});
|
|
35
|
+
if (!proposals.length) {
|
|
36
|
+
require_output.logOutro(ids.length ? `No updates for ${ids.join(", ")}.` : "Every installed extension is up to date.");
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const plural = proposals.length === 1 ? "" : "s";
|
|
40
|
+
require_output.logBlock(proposals.map(({ artifact }) => `${artifact.package} ${versions.get(artifact.package) ?? "not installed"} -> ${(0, node_util.styleText)("green", artifact.version)}`));
|
|
41
|
+
if (check) {
|
|
42
|
+
require_output.logOutro(`${proposals.length} update${plural} available. Run \`kubb update\` to install.`);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const confirmed = yes || await _clack_prompts.confirm({
|
|
46
|
+
message: `Install ${proposals.length} update${plural}?`,
|
|
47
|
+
initialValue: true
|
|
48
|
+
});
|
|
49
|
+
if (_clack_prompts.isCancel(confirmed) || !confirmed) {
|
|
50
|
+
_clack_prompts.cancel("Operation canceled.");
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const packageManager = require_utils.detectPackageManager(cwd);
|
|
54
|
+
const specs = proposals.map(({ artifact }) => `${artifact.package}@${artifact.version}`);
|
|
55
|
+
require_output.logStep(`Installing ${specs.join(", ")} with ${packageManager.name}`);
|
|
56
|
+
await require_utils.installPackages(specs, packageManager, cwd);
|
|
57
|
+
require_output.logInfo(`Updated ${specs.length} extension${plural}`);
|
|
58
|
+
require_output.logOutro((0, node_util.styleText)("green", "Done"));
|
|
59
|
+
} catch (error) {
|
|
60
|
+
require_output.logError(require_errors.getErrorMessage(error));
|
|
61
|
+
node_process.default.exitCode = 1;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
//#endregion
|
|
65
|
+
exports.run = run;
|
|
66
|
+
|
|
67
|
+
//# sourceMappingURL=run-DVIqUt1x.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-DVIqUt1x.cjs","names":["process","styleText","toRegistryId","fetchRegistryIndex","registryUrl","readInstalledPackages","isOutdated","incompatibility","clack","detectPackageManager","installPackages","getErrorMessage"],"sources":["../src/runners/update/run.ts"],"sourcesContent":["import process from 'node:process'\nimport { styleText } from 'node:util'\nimport * as clack from '@clack/prompts'\nimport { getErrorMessage } from '@internals/utils'\nimport { readInstalledPackages } from '@kubb/core'\nimport { logBlock, logError, logInfo, logIntro, logOutro, logStep, logWarn } from '../../loggers/output.ts'\nimport { fetchRegistryIndex, incompatibility, isOutdated, registryUrl, toRegistryId } from '../../utils/registry.ts'\nimport { detectPackageManager, installPackages } from '../init/utils.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 check: boolean\n yes: boolean\n}\n\n/**\n * Moves installed extensions to the version the registry pins. Lists the proposals, asks, then\n * installs them. With `check`, only lists them.\n */\nexport async function run({ ids, check, yes }: UpdateOptions): Promise<void> {\n const cwd = process.cwd()\n logIntro({ title: styleText('bgCyan', styleText('black', ' Kubb Update ')) })\n\n try {\n const wanted = new Set(ids.map(toRegistryId))\n const [entries, installed] = await Promise.all([fetchRegistryIndex({ registry: registryUrl() }), readInstalledPackages({ root: cwd })])\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)) logWarn(`${id} is not installed, or not in the registry.`)\n }\n\n const proposals = tracked.filter((entry) => {\n if (!isOutdated({ installed: versions.get(entry.artifact.package), latest: entry.artifact.version })) return false\n const problem = incompatibility(entry.manifest)\n if (problem) logWarn(`Skipped ${entry.id}: ${problem}`)\n return !problem\n })\n\n if (!proposals.length) {\n logOutro(ids.length ? `No updates for ${ids.join(', ')}.` : 'Every installed extension is up to date.')\n return\n }\n\n const plural = proposals.length === 1 ? '' : 's'\n logBlock(\n proposals.map(({ artifact }) => `${artifact.package} ${versions.get(artifact.package) ?? 'not installed'} -> ${styleText('green', artifact.version)}`),\n )\n\n if (check) {\n logOutro(`${proposals.length} update${plural} available. Run \\`kubb update\\` to install.`)\n return\n }\n\n const confirmed = yes || (await clack.confirm({ message: `Install ${proposals.length} update${plural}?`, initialValue: true }))\n if (clack.isCancel(confirmed) || !confirmed) {\n clack.cancel('Operation canceled.')\n return\n }\n\n const packageManager = detectPackageManager(cwd)\n const specs = proposals.map(({ artifact }) => `${artifact.package}@${artifact.version}`)\n logStep(`Installing ${specs.join(', ')} with ${packageManager.name}`)\n await installPackages(specs, packageManager, cwd)\n\n logInfo(`Updated ${specs.length} extension${plural}`)\n logOutro(styleText('green', 'Done'))\n } catch (error) {\n logError(getErrorMessage(error))\n process.exitCode = 1\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAsBA,eAAsB,IAAI,EAAE,KAAK,OAAO,OAAqC;CAC3E,MAAM,MAAMA,aAAAA,QAAQ,IAAI;CACxB,eAAA,SAAS,EAAE,QAAA,GAAOC,UAAAA,UAAAA,CAAU,WAAA,GAAUA,UAAAA,UAAAA,CAAU,SAAS,eAAe,CAAC,EAAE,CAAC;CAE5E,IAAI;EACF,MAAM,SAAS,IAAI,IAAI,IAAI,IAAIC,iBAAAA,YAAY,CAAC;EAC5C,MAAM,CAAC,SAAS,aAAa,MAAM,QAAQ,IAAI,CAACC,iBAAAA,mBAAmB,EAAE,UAAUC,iBAAAA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AO;GAAI,cAAc;EAAK,CAAC;EAC7H,IAAIA,eAAM,SAAS,SAAS,KAAK,CAAC,WAAW;GAC3C,eAAM,OAAO,qBAAqB;GAClC;EACF;EAEA,MAAM,iBAAiBC,cAAAA,qBAAqB,GAAG;EAC/C,MAAM,QAAQ,UAAU,KAAK,EAAE,eAAe,GAAG,SAAS,QAAQ,GAAG,SAAS,SAAS;EACvF,eAAA,QAAQ,cAAc,MAAM,KAAK,IAAI,EAAE,QAAQ,eAAe,MAAM;EACpE,MAAMC,cAAAA,gBAAgB,OAAO,gBAAgB,GAAG;EAEhD,eAAA,QAAQ,WAAW,MAAM,OAAO,YAAY,QAAQ;EACpD,eAAA,UAAA,GAAST,UAAAA,UAAAA,CAAU,SAAS,MAAM,CAAC;CACrC,SAAS,OAAO;EACd,eAAA,SAASU,eAAAA,gBAAgB,KAAK,CAAC;EAC/B,aAAA,QAAA,WAAmB;CACrB;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./rolldown-runtime-CRm0XQPb.js";
|
|
2
|
-
import {
|
|
3
|
-
import { n as trackRun } from "./Telemetry-
|
|
2
|
+
import { n as toError } from "./errors-DmC83ALX.js";
|
|
3
|
+
import { n as trackRun } from "./Telemetry-C3raFshE.js";
|
|
4
4
|
import { styleText } from "node:util";
|
|
5
5
|
import process from "node:process";
|
|
6
6
|
//#region src/runners/mcp/run.ts
|
|
@@ -27,4 +27,4 @@ async function run() {
|
|
|
27
27
|
//#endregion
|
|
28
28
|
export { run };
|
|
29
29
|
|
|
30
|
-
//# sourceMappingURL=run-
|
|
30
|
+
//# sourceMappingURL=run-DkuGqsyU.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-
|
|
1
|
+
{"version":3,"file":"run-DkuGqsyU.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 await startMcpServer()\n await report({ status: 'success' })\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;EAC7F,MAAM,eAAe;EACrB,MAAM,OAAO,EAAE,QAAQ,UAAU,CAAC;CACpC,SAAS,OAAO;EACd,MAAM,OAAO,EAAE,QAAQ,SAAS,CAAC;EACjC,QAAQ,MAAM,QAAQ,KAAK,CAAC,CAAC,OAAO;EACpC,QAAQ,WAAW;CACrB;AACF"}
|