@kubb/cli 5.0.0-beta.84 → 5.0.0-beta.85
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-ugO-B77y.js → Telemetry-Cuzoes9Y.js} +6 -2
- package/dist/Telemetry-Cuzoes9Y.js.map +1 -0
- package/dist/{Telemetry-jtbchpQE.cjs → Telemetry-CwQYBgsg.cjs} +11 -1
- package/dist/Telemetry-CwQYBgsg.cjs.map +1 -0
- package/dist/{generate-DDgZnlMs.js → generate-C1bIl1nH.js} +34 -24
- package/dist/generate-C1bIl1nH.js.map +1 -0
- package/dist/{generate-Diob_zqj.cjs → generate-Cgmty90l.cjs} +34 -23
- package/dist/generate-Cgmty90l.cjs.map +1 -0
- package/dist/index.cjs +28 -192
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +29 -193
- package/dist/index.js.map +1 -1
- package/dist/{init-uOQx7jSE.cjs → init-DqgB69HY.cjs} +9 -10
- package/dist/init-DqgB69HY.cjs.map +1 -0
- package/dist/{init-Cn3jZVkf.js → init-EnhDxlBB.js} +10 -10
- package/dist/init-EnhDxlBB.js.map +1 -0
- package/dist/{mcp-n-IOoFZL.js → mcp-5DDTiwIA.js} +6 -6
- package/dist/mcp-5DDTiwIA.js.map +1 -0
- package/dist/{mcp-BxhOXHGD.cjs → mcp-DYmjmXQb.cjs} +5 -6
- package/dist/mcp-DYmjmXQb.cjs.map +1 -0
- package/dist/{package-BBBOfxZz.cjs → package-B57sF1X0.cjs} +2 -2
- package/dist/package-B57sF1X0.cjs.map +1 -0
- package/dist/package-CQbxcw7I.js +6 -0
- package/dist/package-CQbxcw7I.js.map +1 -0
- package/dist/{run-DXEMoDFa.cjs → run-3qq_Q4Tg.cjs} +4 -4
- package/dist/run-3qq_Q4Tg.cjs.map +1 -0
- package/dist/{run-Bz6ZUrhp.cjs → run-B9FN0sHW.cjs} +2 -2
- package/dist/run-B9FN0sHW.cjs.map +1 -0
- package/dist/{run-CPBFfbI7.js → run-BFhNcn8b.js} +4 -10
- package/dist/run-BFhNcn8b.js.map +1 -0
- package/dist/{run-D8TRnpBB.js → run-CCsw-Y-v.js} +226 -268
- package/dist/run-CCsw-Y-v.js.map +1 -0
- package/dist/{run-BBLhhWZu.js → run-D0Gs_UzJ.js} +2 -2
- package/dist/run-D0Gs_UzJ.js.map +1 -0
- package/dist/{run-ChSqYuc1.cjs → run-DT9pRBLX.cjs} +228 -269
- package/dist/run-DT9pRBLX.cjs.map +1 -0
- package/dist/{run-DYkciQ4u.cjs → run-DYzUPE7Z.cjs} +4 -10
- package/dist/run-DYzUPE7Z.cjs.map +1 -0
- package/dist/{run-44Zxh8Ec.js → run-yMRylOST.js} +3 -3
- package/dist/run-yMRylOST.js.map +1 -0
- package/dist/{tools-D0UogMU3.js → tools-B23ltmWP.js} +3 -3
- package/dist/tools-B23ltmWP.js.map +1 -0
- package/dist/{tools-CZT9wSA6.cjs → tools-CeIABV0T.cjs} +3 -3
- package/dist/tools-CeIABV0T.cjs.map +1 -0
- package/dist/{validate-CYIieoc4.cjs → validate-BTVjxR4L.cjs} +8 -9
- package/dist/validate-BTVjxR4L.cjs.map +1 -0
- package/dist/{validate-BoG8ZZgE.js → validate-CZFmahWd.js} +9 -9
- package/dist/validate-CZFmahWd.js.map +1 -0
- package/package.json +8 -7
- package/dist/Telemetry-jtbchpQE.cjs.map +0 -1
- package/dist/Telemetry-ugO-B77y.js.map +0 -1
- package/dist/defineCommand-Bo3yZTWI.cjs +0 -36
- package/dist/defineCommand-Bo3yZTWI.cjs.map +0 -1
- package/dist/defineCommand-DMEeqliP.js +0 -31
- package/dist/defineCommand-DMEeqliP.js.map +0 -1
- package/dist/generate-DDgZnlMs.js.map +0 -1
- package/dist/generate-Diob_zqj.cjs.map +0 -1
- package/dist/init-Cn3jZVkf.js.map +0 -1
- package/dist/init-uOQx7jSE.cjs.map +0 -1
- package/dist/mcp-BxhOXHGD.cjs.map +0 -1
- package/dist/mcp-n-IOoFZL.js.map +0 -1
- package/dist/package-BBBOfxZz.cjs.map +0 -1
- package/dist/package-DKwwXnAz.js +0 -6
- package/dist/package-DKwwXnAz.js.map +0 -1
- package/dist/run-44Zxh8Ec.js.map +0 -1
- package/dist/run-BBLhhWZu.js.map +0 -1
- package/dist/run-Bz6ZUrhp.cjs.map +0 -1
- package/dist/run-CPBFfbI7.js.map +0 -1
- package/dist/run-ChSqYuc1.cjs.map +0 -1
- package/dist/run-D8TRnpBB.js.map +0 -1
- package/dist/run-DXEMoDFa.cjs.map +0 -1
- package/dist/run-DYkciQ4u.cjs.map +0 -1
- package/dist/tools-CZT9wSA6.cjs.map +0 -1
- package/dist/tools-D0UogMU3.js.map +0 -1
- package/dist/validate-BoG8ZZgE.js.map +0 -1
- package/dist/validate-CYIieoc4.cjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,187 +1,18 @@
|
|
|
1
1
|
import "./rolldown-runtime-C0LytTxp.js";
|
|
2
|
-
import { r as QUIET_FLAGS, t as Telemetry } from "./Telemetry-
|
|
3
|
-
import { t as version } from "./package-
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return `${opt.short ? `-${opt.short}, ` : ""}--${name}${opt.type === "string" ? ` <${opt.hint ?? name}>` : ""}`;
|
|
8
|
-
}
|
|
9
|
-
/** Prints formatted help output for `def` using its `CommandDefinition`.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```ts
|
|
13
|
-
* renderHelp({ name: 'generate', description: 'Generate client code' })
|
|
14
|
-
* // prints Usage: generate [options] ...
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
function renderHelp(def, parentName) {
|
|
18
|
-
const programName = parentName ? `${parentName} ${def.name}` : def.name;
|
|
19
|
-
const subCommands = def.subCommands ?? [];
|
|
20
|
-
const argsPart = def.arguments?.length ? ` ${def.arguments.join(" ")}` : "";
|
|
21
|
-
const subCmdPart = subCommands.length ? " <command>" : "";
|
|
22
|
-
console.log(`\n${styleText("bold", "Usage:")} ${programName}${argsPart}${subCmdPart} [options]\n`);
|
|
23
|
-
if (def.description) console.log(` ${def.description}\n`);
|
|
24
|
-
if (subCommands.length) {
|
|
25
|
-
console.log(styleText("bold", "Commands:"));
|
|
26
|
-
for (const sub of subCommands) console.log(` ${styleText("cyan", sub.name.padEnd(16))}${sub.description}`);
|
|
27
|
-
console.log();
|
|
28
|
-
}
|
|
29
|
-
const options = [...Object.entries(def.options ?? {}).map(([name, opt]) => ({
|
|
30
|
-
flags: formatFlags(name, opt),
|
|
31
|
-
description: opt.description,
|
|
32
|
-
default: opt.default
|
|
33
|
-
})), {
|
|
34
|
-
flags: "-h, --help",
|
|
35
|
-
description: "Show help"
|
|
36
|
-
}];
|
|
37
|
-
console.log(styleText("bold", "Options:"));
|
|
38
|
-
for (const opt of options) {
|
|
39
|
-
const flags = styleText("cyan", opt.flags.padEnd(30));
|
|
40
|
-
const defaultPart = opt.default !== void 0 ? styleText("dim", ` (default: ${opt.default})`) : "";
|
|
41
|
-
console.log(` ${flags}${opt.description}${defaultPart}`);
|
|
42
|
-
}
|
|
43
|
-
console.log();
|
|
44
|
-
if (def.examples?.length) {
|
|
45
|
-
console.log(styleText("bold", "Examples:"));
|
|
46
|
-
for (const ex of def.examples) console.log(` ${styleText("dim", ex)}`);
|
|
47
|
-
console.log();
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
//#endregion
|
|
51
|
-
//#region ../../internals/utils/src/cli/runCLI.ts
|
|
52
|
-
function buildParseOptions(def) {
|
|
53
|
-
const result = { help: {
|
|
54
|
-
type: "boolean",
|
|
55
|
-
short: "h"
|
|
56
|
-
} };
|
|
57
|
-
for (const [name, opt] of Object.entries(def.options ?? {})) result[name] = {
|
|
58
|
-
type: opt.type,
|
|
59
|
-
...opt.short ? { short: opt.short } : {},
|
|
60
|
-
...opt.default !== void 0 ? { default: opt.default } : {}
|
|
61
|
-
};
|
|
62
|
-
return result;
|
|
63
|
-
}
|
|
64
|
-
async function runCommand(def, argv, parentName) {
|
|
65
|
-
const parseOptions = buildParseOptions(def);
|
|
66
|
-
let parsed;
|
|
67
|
-
try {
|
|
68
|
-
const result = parseArgs({
|
|
69
|
-
args: argv,
|
|
70
|
-
options: parseOptions,
|
|
71
|
-
allowPositionals: true,
|
|
72
|
-
strict: false
|
|
73
|
-
});
|
|
74
|
-
parsed = {
|
|
75
|
-
values: result.values,
|
|
76
|
-
positionals: result.positionals
|
|
77
|
-
};
|
|
78
|
-
} catch {
|
|
79
|
-
renderHelp(def, parentName);
|
|
80
|
-
process.exit(1);
|
|
81
|
-
}
|
|
82
|
-
if (parsed.values["help"]) {
|
|
83
|
-
renderHelp(def, parentName);
|
|
84
|
-
process.exit(0);
|
|
85
|
-
}
|
|
86
|
-
for (const [name, opt] of Object.entries(def.options ?? {})) if (opt.required && parsed.values[name] === void 0) {
|
|
87
|
-
console.error(styleText("red", `Error: --${name} is required`));
|
|
88
|
-
renderHelp(def, parentName);
|
|
89
|
-
process.exit(1);
|
|
90
|
-
}
|
|
91
|
-
if (!def.run) {
|
|
92
|
-
renderHelp(def, parentName);
|
|
93
|
-
process.exit(0);
|
|
94
|
-
}
|
|
95
|
-
try {
|
|
96
|
-
await def.run(parsed);
|
|
97
|
-
} catch (err) {
|
|
98
|
-
console.error(styleText("red", `Error: ${err instanceof Error ? err.message : String(err)}`));
|
|
99
|
-
renderHelp(def, parentName);
|
|
100
|
-
process.exit(1);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
function printRootHelp(programName, version, defs) {
|
|
104
|
-
console.log(`\n${styleText("bold", "Usage:")} ${programName} <command> [options]\n`);
|
|
105
|
-
console.log(` Kubb v${version} — Generate TypeScript types, API clients, React Query hooks,`);
|
|
106
|
-
console.log(` Zod schemas, and more from an OpenAPI specification.\n`);
|
|
107
|
-
console.log(` Quick start: ${styleText("cyan", `${programName} init`)} to scaffold a config, then ${styleText("cyan", `${programName} generate`)} to run.\n`);
|
|
108
|
-
console.log(styleText("bold", "Commands:"));
|
|
109
|
-
for (const def of defs) console.log(` ${styleText("cyan", def.name.padEnd(16))}${def.description}`);
|
|
110
|
-
console.log();
|
|
111
|
-
console.log(styleText("bold", "Options:"));
|
|
112
|
-
console.log(` ${styleText("cyan", "-v, --version".padEnd(30))}Show version number`);
|
|
113
|
-
console.log(` ${styleText("cyan", "-h, --help".padEnd(30))}Show help`);
|
|
114
|
-
console.log();
|
|
115
|
-
console.log(`Run ${styleText("cyan", `${programName} <command> --help`)} for command-specific help.\n`);
|
|
116
|
-
}
|
|
2
|
+
import { r as QUIET_FLAGS, t as Telemetry } from "./Telemetry-Cuzoes9Y.js";
|
|
3
|
+
import { t as version } from "./package-CQbxcw7I.js";
|
|
4
|
+
import { styleText } from "node:util";
|
|
5
|
+
import { cli } from "gunshi";
|
|
6
|
+
//#region src/index.ts
|
|
117
7
|
/**
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
* @example
|
|
122
|
-
* ```ts
|
|
123
|
-
* await runCLI(commands, process.argv, {
|
|
124
|
-
* programName: 'kubb',
|
|
125
|
-
* defaultCommandName: 'generate',
|
|
126
|
-
* version: '5.0.0',
|
|
127
|
-
* })
|
|
128
|
-
* ```
|
|
8
|
+
* Strips the leading executable + script entries when `process.argv` is passed directly.
|
|
9
|
+
* Handles Node.js (`/usr/bin/node`), Bun (`/usr/local/bin/bun`), Deno, tsx, etc. All runtime
|
|
10
|
+
* executable paths contain a path separator; bare command names do not.
|
|
129
11
|
*/
|
|
130
|
-
|
|
131
|
-
const { programName, defaultCommandName, version } = opts;
|
|
12
|
+
function stripExecArgs(argv) {
|
|
132
13
|
const firstArgIsExecutablePath = (argv[0]?.includes("/") || argv[0]?.includes("\\")) ?? false;
|
|
133
|
-
|
|
134
|
-
if (args[0] === "--version" || args[0] === "-v") {
|
|
135
|
-
console.log(version);
|
|
136
|
-
process.exit(0);
|
|
137
|
-
}
|
|
138
|
-
if (args[0] === "--help" || args[0] === "-h") {
|
|
139
|
-
printRootHelp(programName, version, defs);
|
|
140
|
-
process.exit(0);
|
|
141
|
-
}
|
|
142
|
-
if (args.length === 0) {
|
|
143
|
-
const defaultDef = defs.find((d) => d.name === defaultCommandName);
|
|
144
|
-
if (defaultDef?.run) await runCommand(defaultDef, [], programName);
|
|
145
|
-
else printRootHelp(programName, version, defs);
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
const [first, ...rest] = args;
|
|
149
|
-
const isKnownSubcommand = defs.some((d) => d.name === first);
|
|
150
|
-
let def;
|
|
151
|
-
let commandArgv;
|
|
152
|
-
let parentName;
|
|
153
|
-
if (isKnownSubcommand) {
|
|
154
|
-
def = defs.find((d) => d.name === first);
|
|
155
|
-
commandArgv = rest;
|
|
156
|
-
parentName = programName;
|
|
157
|
-
} else {
|
|
158
|
-
def = defs.find((d) => d.name === defaultCommandName);
|
|
159
|
-
commandArgv = args;
|
|
160
|
-
parentName = programName;
|
|
161
|
-
}
|
|
162
|
-
if (!def) {
|
|
163
|
-
console.error(`Unknown command: ${first}`);
|
|
164
|
-
printRootHelp(programName, version, defs);
|
|
165
|
-
process.exit(1);
|
|
166
|
-
}
|
|
167
|
-
if (def.subCommands?.length) {
|
|
168
|
-
const [subName, ...subRest] = commandArgv;
|
|
169
|
-
const subDef = def.subCommands.find((s) => s.name === subName);
|
|
170
|
-
if (subName === "--help" || subName === "-h") {
|
|
171
|
-
renderHelp(def, parentName);
|
|
172
|
-
process.exit(0);
|
|
173
|
-
}
|
|
174
|
-
if (!subDef) {
|
|
175
|
-
renderHelp(def, parentName);
|
|
176
|
-
process.exit(subName ? 1 : 0);
|
|
177
|
-
}
|
|
178
|
-
await runCommand(subDef, subRest, `${parentName} ${def.name}`);
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
await runCommand(def, commandArgv, parentName);
|
|
14
|
+
return argv.length >= 2 && firstArgIsExecutablePath ? argv.slice(2) : argv;
|
|
182
15
|
}
|
|
183
|
-
//#endregion
|
|
184
|
-
//#region src/index.ts
|
|
185
16
|
/**
|
|
186
17
|
* Entry point for the `kubb` CLI. Prints the telemetry notice unless telemetry is disabled or a
|
|
187
18
|
* quiet flag is passed, then runs the generate, validate, mcp, and init commands. Defaults to
|
|
@@ -190,20 +21,25 @@ async function runCLI(defs, argv, opts) {
|
|
|
190
21
|
async function run(argv = process.argv) {
|
|
191
22
|
const isQuietFlag = argv.some((arg) => QUIET_FLAGS.has(arg));
|
|
192
23
|
if (!Telemetry.isDisabled && !isQuietFlag) console.log(`${styleText("yellow", "Notice:")} Kubb collects anonymous telemetry data to help improve the tool. No personal data or file contents are collected. \nTo disable, set ${styleText("cyan", "KUBB_DISABLE_TELEMETRY=1")}.\n`);
|
|
193
|
-
const { command: generateCommand } = await import("./generate-
|
|
194
|
-
const { command: validateCommand } = await import("./validate-
|
|
195
|
-
const { command: mcpCommand } = await import("./mcp-
|
|
196
|
-
const { command: initCommand } = await import("./init-
|
|
197
|
-
|
|
198
|
-
generateCommand,
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
24
|
+
const { command: generateCommand } = await import("./generate-C1bIl1nH.js");
|
|
25
|
+
const { command: validateCommand } = await import("./validate-CZFmahWd.js");
|
|
26
|
+
const { command: mcpCommand } = await import("./mcp-5DDTiwIA.js");
|
|
27
|
+
const { command: initCommand } = await import("./init-EnhDxlBB.js");
|
|
28
|
+
try {
|
|
29
|
+
await cli(stripExecArgs(argv), generateCommand, {
|
|
30
|
+
name: "kubb",
|
|
31
|
+
version,
|
|
32
|
+
description: generateCommand.description,
|
|
33
|
+
subCommands: {
|
|
34
|
+
init: initCommand,
|
|
35
|
+
validate: validateCommand,
|
|
36
|
+
mcp: mcpCommand
|
|
37
|
+
},
|
|
38
|
+
fallbackToEntry: true
|
|
39
|
+
});
|
|
40
|
+
} catch {
|
|
41
|
+
process.exit(1);
|
|
42
|
+
}
|
|
207
43
|
}
|
|
208
44
|
//#endregion
|
|
209
45
|
export { run };
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../internals/utils/src/cli/renderHelp.ts","../../../internals/utils/src/cli/runCLI.ts","../src/index.ts"],"sourcesContent":["import { styleText } from 'node:util'\nimport type { CommandDefinition, OptionDefinition } from './defineCommand.ts'\n\nfunction formatFlags(name: string, opt: OptionDefinition): string {\n const short = opt.short ? `-${opt.short}, ` : ''\n const value = opt.type === 'string' ? ` <${opt.hint ?? name}>` : ''\n return `${short}--${name}${value}`\n}\n\n/** Prints formatted help output for `def` using its `CommandDefinition`.\n *\n * @example\n * ```ts\n * renderHelp({ name: 'generate', description: 'Generate client code' })\n * // prints Usage: generate [options] ...\n * ```\n */\nexport function renderHelp(def: CommandDefinition, parentName?: string): void {\n const programName = parentName ? `${parentName} ${def.name}` : def.name\n const subCommands = def.subCommands ?? []\n\n const argsPart = def.arguments?.length ? ` ${def.arguments.join(' ')}` : ''\n const subCmdPart = subCommands.length ? ' <command>' : ''\n console.log(`\\n${styleText('bold', 'Usage:')} ${programName}${argsPart}${subCmdPart} [options]\\n`)\n\n if (def.description) {\n console.log(` ${def.description}\\n`)\n }\n\n if (subCommands.length) {\n console.log(styleText('bold', 'Commands:'))\n for (const sub of subCommands) {\n console.log(` ${styleText('cyan', sub.name.padEnd(16))}${sub.description}`)\n }\n console.log()\n }\n\n const options: Array<{ flags: string; description: string; default?: string | boolean }> = [\n ...Object.entries(def.options ?? {}).map(([name, opt]) => ({ flags: formatFlags(name, opt), description: opt.description, default: opt.default })),\n { flags: '-h, --help', description: 'Show help' },\n ]\n\n console.log(styleText('bold', 'Options:'))\n for (const opt of options) {\n const flags = styleText('cyan', opt.flags.padEnd(30))\n const defaultPart = opt.default !== undefined ? styleText('dim', ` (default: ${opt.default})`) : ''\n console.log(` ${flags}${opt.description}${defaultPart}`)\n }\n console.log()\n\n if (def.examples?.length) {\n console.log(styleText('bold', 'Examples:'))\n for (const ex of def.examples) {\n console.log(` ${styleText('dim', ex)}`)\n }\n console.log()\n }\n}\n","import { parseArgs, styleText } from 'node:util'\nimport type { CommandDefinition, OptionType, ParsedArgs } from './defineCommand.ts'\nimport { renderHelp } from './renderHelp.ts'\n\n/**\n * Options passed to every `runCLI` invocation.\n */\nexport type RunOptions = {\n programName: string\n defaultCommandName: string\n version: string\n}\n\ntype ParseOption = {\n type: OptionType\n short?: string\n default?: string | boolean\n}\ntype ParseOptions = Record<string, ParseOption>\n\nfunction buildParseOptions(def: CommandDefinition): ParseOptions {\n const result: ParseOptions = {\n help: { type: 'boolean', short: 'h' },\n }\n\n for (const [name, opt] of Object.entries(def.options ?? {})) {\n result[name] = {\n type: opt.type,\n ...(opt.short ? { short: opt.short } : {}),\n ...(opt.default !== undefined ? { default: opt.default } : {}),\n }\n }\n\n return result\n}\n\nasync function runCommand(def: CommandDefinition, argv: Array<string>, parentName?: string): Promise<void> {\n const parseOptions = buildParseOptions(def)\n\n let parsed: ParsedArgs\n try {\n const result = parseArgs({\n args: argv,\n options: parseOptions,\n allowPositionals: true,\n strict: false,\n })\n parsed = {\n values: result.values as ParsedArgs['values'],\n positionals: result.positionals,\n }\n } catch {\n renderHelp(def, parentName)\n process.exit(1)\n }\n\n if (parsed.values['help']) {\n renderHelp(def, parentName)\n process.exit(0)\n }\n\n // Validate required options before running the command\n for (const [name, opt] of Object.entries(def.options ?? {})) {\n if (opt.required && parsed.values[name] === undefined) {\n console.error(styleText('red', `Error: --${name} is required`))\n renderHelp(def, parentName)\n process.exit(1)\n }\n }\n\n if (!def.run) {\n renderHelp(def, parentName)\n process.exit(0)\n }\n\n try {\n await def.run(parsed)\n } catch (err) {\n console.error(styleText('red', `Error: ${err instanceof Error ? err.message : String(err)}`))\n renderHelp(def, parentName)\n process.exit(1)\n }\n}\n\nfunction printRootHelp(programName: string, version: string, defs: Array<CommandDefinition>): void {\n console.log(`\\n${styleText('bold', 'Usage:')} ${programName} <command> [options]\\n`)\n console.log(` Kubb v${version} — Generate TypeScript types, API clients, React Query hooks,`)\n console.log(` Zod schemas, and more from an OpenAPI specification.\\n`)\n console.log(` Quick start: ${styleText('cyan', `${programName} init`)} to scaffold a config, then ${styleText('cyan', `${programName} generate`)} to run.\\n`)\n console.log(styleText('bold', 'Commands:'))\n for (const def of defs) {\n console.log(` ${styleText('cyan', def.name.padEnd(16))}${def.description}`)\n }\n console.log()\n console.log(styleText('bold', 'Options:'))\n console.log(` ${styleText('cyan', '-v, --version'.padEnd(30))}Show version number`)\n console.log(` ${styleText('cyan', '-h, --help'.padEnd(30))}Show help`)\n console.log()\n console.log(`Run ${styleText('cyan', `${programName} <command> --help`)} for command-specific help.\\n`)\n}\n\n/**\n * Parses `argv` and runs the matching command using `node:util parseArgs`. No external dependencies.\n * Falls back to `defaultCommandName` when no command is given.\n *\n * @example\n * ```ts\n * await runCLI(commands, process.argv, {\n * programName: 'kubb',\n * defaultCommandName: 'generate',\n * version: '5.0.0',\n * })\n * ```\n */\nexport async function runCLI(defs: Array<CommandDefinition>, argv: Array<string>, opts: RunOptions): Promise<void> {\n const { programName, defaultCommandName, version } = opts\n\n // Strip the leading executable + script entries when process.argv is passed directly.\n // Handles Node.js (/usr/bin/node), Bun (/usr/local/bin/bun), Deno, tsx, etc.\n // All runtime executable paths contain a path separator; bare command names do not.\n const firstArgIsExecutablePath = (argv[0]?.includes('/') || argv[0]?.includes('\\\\')) ?? false\n const args = argv.length >= 2 && firstArgIsExecutablePath ? argv.slice(2) : argv\n\n if (args[0] === '--version' || args[0] === '-v') {\n console.log(version)\n process.exit(0)\n }\n\n if (args[0] === '--help' || args[0] === '-h') {\n printRootHelp(programName, version, defs)\n process.exit(0)\n }\n\n if (args.length === 0) {\n const defaultDef = defs.find((d) => d.name === defaultCommandName)\n if (defaultDef?.run) {\n await runCommand(defaultDef, [], programName)\n } else {\n printRootHelp(programName, version, defs)\n }\n return\n }\n\n const [first, ...rest] = args\n const isKnownSubcommand = defs.some((d) => d.name === first)\n\n let def: CommandDefinition | undefined\n let commandArgv: Array<string>\n let parentName: string | undefined\n\n if (isKnownSubcommand) {\n def = defs.find((d) => d.name === first)\n commandArgv = rest\n parentName = programName\n } else {\n def = defs.find((d) => d.name === defaultCommandName)\n commandArgv = args\n parentName = programName\n }\n\n if (!def) {\n console.error(`Unknown command: ${first}`)\n printRootHelp(programName, version, defs)\n process.exit(1)\n }\n\n if (def.subCommands?.length) {\n const [subName, ...subRest] = commandArgv\n const subDef = def.subCommands.find((s) => s.name === subName)\n\n if (subName === '--help' || subName === '-h') {\n renderHelp(def, parentName)\n process.exit(0)\n }\n\n if (!subDef) {\n renderHelp(def, parentName)\n process.exit(subName ? 1 : 0)\n }\n\n await runCommand(subDef, subRest, `${parentName} ${def.name}`)\n return\n }\n\n await runCommand(def, commandArgv, parentName)\n}\n","import { styleText } from 'node:util'\nimport { runCLI } from '@internals/utils'\nimport { Telemetry } from './Telemetry.ts'\nimport { version } from '../package.json'\nimport { QUIET_FLAGS } from './constants.ts'\n\n/**\n * Entry point for the `kubb` CLI. Prints the telemetry notice unless telemetry is disabled or a\n * quiet flag is passed, then runs the generate, validate, mcp, and init commands. Defaults to\n * `generate` when no command is given.\n */\nexport async function run(argv: Array<string> = process.argv): Promise<void> {\n const isQuietFlag = argv.some((arg) => QUIET_FLAGS.has(arg))\n\n if (!Telemetry.isDisabled && !isQuietFlag) {\n console.log(\n `${styleText('yellow', 'Notice:')} Kubb collects anonymous telemetry data to help improve the tool. No personal data or file contents are collected. \\nTo disable, set ${styleText('cyan', 'KUBB_DISABLE_TELEMETRY=1')}.\\n`,\n )\n }\n\n const { command: generateCommand } = await import('./commands/generate.ts')\n const { command: validateCommand } = await import('./commands/validate.ts')\n const { command: mcpCommand } = await import('./commands/mcp.ts')\n const { command: initCommand } = await import('./commands/init.ts')\n\n await runCLI([generateCommand, validateCommand, mcpCommand, initCommand], argv, {\n programName: 'kubb',\n defaultCommandName: 'generate',\n version,\n })\n}\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1B,QAAQ,KAAK,UAAU,IAAI,CAAC;EAC9B;EAEA,MAAM,WAAW,QAAQ,SAAS,GAAG,WAAW,GAAG,IAAI,MAAM;EAC7D;CACF;CAEA,MAAM,WAAW,KAAK,aAAa,UAAU;AAC/C;;;;;;;;AC9KA,eAAsB,IAAI,OAAsB,QAAQ,MAAqB;CAC3E,MAAM,cAAc,KAAK,MAAM,QAAQ,YAAY,IAAI,GAAG,CAAC;CAE3D,IAAI,CAAC,UAAU,cAAc,CAAC,aAC5B,QAAQ,IACN,GAAG,UAAU,UAAU,SAAS,EAAE,uIAAuI,UAAU,QAAQ,0BAA0B,EAAE,IACzN;CAGF,MAAM,EAAE,SAAS,oBAAoB,MAAM,OAAO;CAClD,MAAM,EAAE,SAAS,oBAAoB,MAAM,OAAO;CAClD,MAAM,EAAE,SAAS,eAAe,MAAM,OAAO;CAC7C,MAAM,EAAE,SAAS,gBAAgB,MAAM,OAAO;CAE9C,MAAM,OAAO;EAAC;EAAiB;EAAiB;EAAY;CAAW,GAAG,MAAM;EAC9E,aAAa;EACb,oBAAoB;EACpB;CACF,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { styleText } from 'node:util'\nimport { cli } from 'gunshi'\nimport { Telemetry } from './Telemetry.ts'\nimport { version } from '../package.json'\nimport { QUIET_FLAGS } from './constants.ts'\n\n/**\n * Strips the leading executable + script entries when `process.argv` is passed directly.\n * Handles Node.js (`/usr/bin/node`), Bun (`/usr/local/bin/bun`), Deno, tsx, etc. All runtime\n * executable paths contain a path separator; bare command names do not.\n */\nfunction stripExecArgs(argv: Array<string>): Array<string> {\n const firstArgIsExecutablePath = (argv[0]?.includes('/') || argv[0]?.includes('\\\\')) ?? false\n return argv.length >= 2 && firstArgIsExecutablePath ? argv.slice(2) : argv\n}\n\n/**\n * Entry point for the `kubb` CLI. Prints the telemetry notice unless telemetry is disabled or a\n * quiet flag is passed, then runs the generate, validate, mcp, and init commands. Defaults to\n * `generate` when no command is given.\n */\nexport async function run(argv: Array<string> = process.argv): Promise<void> {\n const isQuietFlag = argv.some((arg) => QUIET_FLAGS.has(arg))\n\n if (!Telemetry.isDisabled && !isQuietFlag) {\n console.log(\n `${styleText('yellow', 'Notice:')} Kubb collects anonymous telemetry data to help improve the tool. No personal data or file contents are collected. \\nTo disable, set ${styleText('cyan', 'KUBB_DISABLE_TELEMETRY=1')}.\\n`,\n )\n }\n\n const { command: generateCommand } = await import('./commands/generate.ts')\n const { command: validateCommand } = await import('./commands/validate.ts')\n const { command: mcpCommand } = await import('./commands/mcp.ts')\n const { command: initCommand } = await import('./commands/init.ts')\n\n try {\n await cli(stripExecArgs(argv), generateCommand, {\n name: 'kubb',\n version,\n description: generateCommand.description,\n subCommands: {\n init: initCommand,\n validate: validateCommand,\n mcp: mcpCommand,\n },\n fallbackToEntry: true,\n })\n } catch {\n process.exit(1)\n }\n}\n"],"mappings":";;;;;;;;;;;AAWA,SAAS,cAAc,MAAoC;CACzD,MAAM,4BAA4B,KAAK,EAAE,EAAE,SAAS,GAAG,KAAK,KAAK,EAAE,EAAE,SAAS,IAAI,MAAM;CACxF,OAAO,KAAK,UAAU,KAAK,2BAA2B,KAAK,MAAM,CAAC,IAAI;AACxE;;;;;;AAOA,eAAsB,IAAI,OAAsB,QAAQ,MAAqB;CAC3E,MAAM,cAAc,KAAK,MAAM,QAAQ,YAAY,IAAI,GAAG,CAAC;CAE3D,IAAI,CAAC,UAAU,cAAc,CAAC,aAC5B,QAAQ,IACN,GAAG,UAAU,UAAU,SAAS,EAAE,uIAAuI,UAAU,QAAQ,0BAA0B,EAAE,IACzN;CAGF,MAAM,EAAE,SAAS,oBAAoB,MAAM,OAAO;CAClD,MAAM,EAAE,SAAS,oBAAoB,MAAM,OAAO;CAClD,MAAM,EAAE,SAAS,eAAe,MAAM,OAAO;CAC7C,MAAM,EAAE,SAAS,gBAAgB,MAAM,OAAO;CAE9C,IAAI;EACF,MAAM,IAAI,cAAc,IAAI,GAAG,iBAAiB;GAC9C,MAAM;GACN;GACA,aAAa,gBAAgB;GAC7B,aAAa;IACX,MAAM;IACN,UAAU;IACV,KAAK;GACP;GACA,iBAAiB;EACnB,CAAC;CACH,QAAQ;EACN,QAAQ,KAAK,CAAC;CAChB;AACF"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
require("./rolldown-runtime-Bx3C2hgW.cjs");
|
|
2
|
-
const
|
|
3
|
-
const require_package = require("./package-BBBOfxZz.cjs");
|
|
2
|
+
const require_package = require("./package-B57sF1X0.cjs");
|
|
4
3
|
//#region src/commands/init.ts
|
|
5
|
-
const command =
|
|
4
|
+
const command = (0, require("gunshi").define)({
|
|
6
5
|
name: "init",
|
|
7
6
|
description: "Scaffold a kubb.config.ts and install plugins for code generation from an OpenAPI spec. Run without flags for interactive setup, or pass --input, --output, and --plugins to skip the prompts.",
|
|
8
7
|
examples: [
|
|
@@ -10,8 +9,8 @@ const command = require_defineCommand.defineCommand({
|
|
|
10
9
|
"kubb init --yes",
|
|
11
10
|
"kubb init --input ./openapi.yaml --output ./src/gen --plugins plugin-ts,plugin-zod",
|
|
12
11
|
"kubb init --plugins plugin-ts,plugin-axios,plugin-react-query"
|
|
13
|
-
],
|
|
14
|
-
|
|
12
|
+
].join("\n"),
|
|
13
|
+
args: {
|
|
15
14
|
yes: {
|
|
16
15
|
type: "boolean",
|
|
17
16
|
description: "Skip prompts and use default options",
|
|
@@ -22,22 +21,22 @@ const command = require_defineCommand.defineCommand({
|
|
|
22
21
|
type: "string",
|
|
23
22
|
description: "Path to the OpenAPI specification",
|
|
24
23
|
short: "i",
|
|
25
|
-
|
|
24
|
+
metavar: "path"
|
|
26
25
|
},
|
|
27
26
|
output: {
|
|
28
27
|
type: "string",
|
|
29
28
|
description: "Output directory for generated files",
|
|
30
29
|
short: "o",
|
|
31
|
-
|
|
30
|
+
metavar: "path"
|
|
32
31
|
},
|
|
33
32
|
plugins: {
|
|
34
33
|
type: "string",
|
|
35
34
|
description: "Comma-separated list of plugins to use (plugin-ts, plugin-axios, plugin-fetch, plugin-react-query, plugin-vue-query, plugin-zod, plugin-faker, plugin-msw, plugin-cypress, plugin-mcp, plugin-redoc)",
|
|
36
|
-
|
|
35
|
+
metavar: "plugin-ts,plugin-zod,..."
|
|
37
36
|
}
|
|
38
37
|
},
|
|
39
38
|
async run({ values }) {
|
|
40
|
-
const { run } = await Promise.resolve().then(() => require("./run-
|
|
39
|
+
const { run } = await Promise.resolve().then(() => require("./run-3qq_Q4Tg.cjs"));
|
|
41
40
|
await run({
|
|
42
41
|
yes: values.yes,
|
|
43
42
|
version: require_package.version,
|
|
@@ -50,4 +49,4 @@ const command = require_defineCommand.defineCommand({
|
|
|
50
49
|
//#endregion
|
|
51
50
|
exports.command = command;
|
|
52
51
|
|
|
53
|
-
//# sourceMappingURL=init-
|
|
52
|
+
//# sourceMappingURL=init-DqgB69HY.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init-DqgB69HY.cjs","names":[],"sources":["../src/commands/init.ts"],"sourcesContent":["import { define } from 'gunshi'\nimport { version } from '../../package.json'\n\nexport const command = define({\n name: 'init',\n description:\n 'Scaffold a kubb.config.ts and install plugins for code generation from an OpenAPI spec. Run without flags for interactive setup, or pass --input, --output, and --plugins to skip the prompts.',\n examples: [\n 'kubb init',\n 'kubb init --yes',\n 'kubb init --input ./openapi.yaml --output ./src/gen --plugins plugin-ts,plugin-zod',\n 'kubb init --plugins plugin-ts,plugin-axios,plugin-react-query',\n ].join('\\n'),\n args: {\n yes: {\n type: 'boolean',\n description: 'Skip prompts and use default options',\n short: 'y',\n default: false,\n },\n input: {\n type: 'string',\n description: 'Path to the OpenAPI specification',\n short: 'i',\n metavar: 'path',\n },\n output: {\n type: 'string',\n description: 'Output directory for generated files',\n short: 'o',\n metavar: 'path',\n },\n plugins: {\n type: 'string',\n description:\n 'Comma-separated list of plugins to use (plugin-ts, plugin-axios, plugin-fetch, plugin-react-query, plugin-vue-query, plugin-zod, plugin-faker, plugin-msw, plugin-cypress, plugin-mcp, plugin-redoc)',\n metavar: 'plugin-ts,plugin-zod,...',\n },\n },\n async run({ values }) {\n const { run } = await import('../runners/init/run.ts')\n\n await run({\n yes: values.yes,\n version,\n input: values.input,\n output: values.output,\n plugins: values.plugins,\n })\n },\n})\n"],"mappings":";;;AAGA,MAAa,WAAA,mBAAA,CAAA,CAAA,OAAA,CAAiB;CAC5B,MAAM;CACN,aACE;CACF,UAAU;EACR;EACA;EACA;EACA;CACF,CAAC,CAAC,KAAK,IAAI;CACX,MAAM;EACJ,KAAK;GACH,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,OAAO;GACL,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,QAAQ;GACN,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,SAAS;GACP,MAAM;GACN,aACE;GACF,SAAS;EACX;CACF;CACA,MAAM,IAAI,EAAE,UAAU;EACpB,MAAM,EAAE,QAAQ,MAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAM,oBAAA,CAAA;EAEtB,MAAM,IAAI;GACR,KAAK,OAAO;GACZ,SAAA,gBAAA;GACA,OAAO,OAAO;GACd,QAAQ,OAAO;GACf,SAAS,OAAO;EAClB,CAAC;CACH;AACF,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "./rolldown-runtime-C0LytTxp.js";
|
|
2
|
-
import { t as
|
|
3
|
-
import {
|
|
2
|
+
import { t as version } from "./package-CQbxcw7I.js";
|
|
3
|
+
import { define } from "gunshi";
|
|
4
4
|
//#region src/commands/init.ts
|
|
5
|
-
const command =
|
|
5
|
+
const command = define({
|
|
6
6
|
name: "init",
|
|
7
7
|
description: "Scaffold a kubb.config.ts and install plugins for code generation from an OpenAPI spec. Run without flags for interactive setup, or pass --input, --output, and --plugins to skip the prompts.",
|
|
8
8
|
examples: [
|
|
@@ -10,8 +10,8 @@ const command = defineCommand({
|
|
|
10
10
|
"kubb init --yes",
|
|
11
11
|
"kubb init --input ./openapi.yaml --output ./src/gen --plugins plugin-ts,plugin-zod",
|
|
12
12
|
"kubb init --plugins plugin-ts,plugin-axios,plugin-react-query"
|
|
13
|
-
],
|
|
14
|
-
|
|
13
|
+
].join("\n"),
|
|
14
|
+
args: {
|
|
15
15
|
yes: {
|
|
16
16
|
type: "boolean",
|
|
17
17
|
description: "Skip prompts and use default options",
|
|
@@ -22,22 +22,22 @@ const command = defineCommand({
|
|
|
22
22
|
type: "string",
|
|
23
23
|
description: "Path to the OpenAPI specification",
|
|
24
24
|
short: "i",
|
|
25
|
-
|
|
25
|
+
metavar: "path"
|
|
26
26
|
},
|
|
27
27
|
output: {
|
|
28
28
|
type: "string",
|
|
29
29
|
description: "Output directory for generated files",
|
|
30
30
|
short: "o",
|
|
31
|
-
|
|
31
|
+
metavar: "path"
|
|
32
32
|
},
|
|
33
33
|
plugins: {
|
|
34
34
|
type: "string",
|
|
35
35
|
description: "Comma-separated list of plugins to use (plugin-ts, plugin-axios, plugin-fetch, plugin-react-query, plugin-vue-query, plugin-zod, plugin-faker, plugin-msw, plugin-cypress, plugin-mcp, plugin-redoc)",
|
|
36
|
-
|
|
36
|
+
metavar: "plugin-ts,plugin-zod,..."
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
39
|
async run({ values }) {
|
|
40
|
-
const { run } = await import("./run-
|
|
40
|
+
const { run } = await import("./run-yMRylOST.js");
|
|
41
41
|
await run({
|
|
42
42
|
yes: values.yes,
|
|
43
43
|
version,
|
|
@@ -50,4 +50,4 @@ const command = defineCommand({
|
|
|
50
50
|
//#endregion
|
|
51
51
|
export { command };
|
|
52
52
|
|
|
53
|
-
//# sourceMappingURL=init-
|
|
53
|
+
//# sourceMappingURL=init-EnhDxlBB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init-EnhDxlBB.js","names":[],"sources":["../src/commands/init.ts"],"sourcesContent":["import { define } from 'gunshi'\nimport { version } from '../../package.json'\n\nexport const command = define({\n name: 'init',\n description:\n 'Scaffold a kubb.config.ts and install plugins for code generation from an OpenAPI spec. Run without flags for interactive setup, or pass --input, --output, and --plugins to skip the prompts.',\n examples: [\n 'kubb init',\n 'kubb init --yes',\n 'kubb init --input ./openapi.yaml --output ./src/gen --plugins plugin-ts,plugin-zod',\n 'kubb init --plugins plugin-ts,plugin-axios,plugin-react-query',\n ].join('\\n'),\n args: {\n yes: {\n type: 'boolean',\n description: 'Skip prompts and use default options',\n short: 'y',\n default: false,\n },\n input: {\n type: 'string',\n description: 'Path to the OpenAPI specification',\n short: 'i',\n metavar: 'path',\n },\n output: {\n type: 'string',\n description: 'Output directory for generated files',\n short: 'o',\n metavar: 'path',\n },\n plugins: {\n type: 'string',\n description:\n 'Comma-separated list of plugins to use (plugin-ts, plugin-axios, plugin-fetch, plugin-react-query, plugin-vue-query, plugin-zod, plugin-faker, plugin-msw, plugin-cypress, plugin-mcp, plugin-redoc)',\n metavar: 'plugin-ts,plugin-zod,...',\n },\n },\n async run({ values }) {\n const { run } = await import('../runners/init/run.ts')\n\n await run({\n yes: values.yes,\n version,\n input: values.input,\n output: values.output,\n plugins: values.plugins,\n })\n },\n})\n"],"mappings":";;;;AAGA,MAAa,UAAU,OAAO;CAC5B,MAAM;CACN,aACE;CACF,UAAU;EACR;EACA;EACA;EACA;CACF,CAAC,CAAC,KAAK,IAAI;CACX,MAAM;EACJ,KAAK;GACH,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,OAAO;GACL,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,QAAQ;GACN,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,SAAS;GACP,MAAM;GACN,aACE;GACF,SAAS;EACX;CACF;CACA,MAAM,IAAI,EAAE,UAAU;EACpB,MAAM,EAAE,QAAQ,MAAM,OAAO;EAE7B,MAAM,IAAI;GACR,KAAK,OAAO;GACZ;GACA,OAAO,OAAO;GACd,QAAQ,OAAO;GACf,SAAS,OAAO;EAClB,CAAC;CACH;AACF,CAAC"}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import "./rolldown-runtime-C0LytTxp.js";
|
|
2
|
-
import { t as
|
|
3
|
-
import {
|
|
2
|
+
import { t as version } from "./package-CQbxcw7I.js";
|
|
3
|
+
import { define } from "gunshi";
|
|
4
4
|
//#region src/commands/mcp.ts
|
|
5
|
-
const command =
|
|
5
|
+
const command = define({
|
|
6
6
|
name: "mcp",
|
|
7
7
|
description: "Start a Model Context Protocol (MCP) server that exposes Kubb code generation as tools for AI assistants. Once running, configure your AI client (Claude, Cursor, Windsurf, etc.) to connect to it — the assistant can then call kubb generate directly without leaving the chat.",
|
|
8
8
|
examples: [
|
|
9
9
|
"kubb mcp",
|
|
10
10
|
"# Then add to your MCP client config:",
|
|
11
11
|
"# { \"mcpServers\": { \"kubb\": { \"command\": \"npx\", \"args\": [\"kubb\", \"mcp\"] } } }"
|
|
12
|
-
],
|
|
12
|
+
].join("\n"),
|
|
13
13
|
async run() {
|
|
14
|
-
const { run } = await import("./run-
|
|
14
|
+
const { run } = await import("./run-D0Gs_UzJ.js");
|
|
15
15
|
await run({ version });
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
18
|
//#endregion
|
|
19
19
|
export { command };
|
|
20
20
|
|
|
21
|
-
//# sourceMappingURL=mcp-
|
|
21
|
+
//# sourceMappingURL=mcp-5DDTiwIA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-5DDTiwIA.js","names":[],"sources":["../src/commands/mcp.ts"],"sourcesContent":["import { define } from 'gunshi'\nimport { version } from '../../package.json'\n\nexport const command = define({\n name: 'mcp',\n description:\n 'Start a Model Context Protocol (MCP) server that exposes Kubb code generation as tools for AI assistants. Once running, configure your AI client (Claude, Cursor, Windsurf, etc.) to connect to it — the assistant can then call kubb generate directly without leaving the chat.',\n examples: ['kubb mcp', '# Then add to your MCP client config:', '# { \"mcpServers\": { \"kubb\": { \"command\": \"npx\", \"args\": [\"kubb\", \"mcp\"] } } }'].join('\\n'),\n async run() {\n const { run } = await import('../runners/mcp/run.ts')\n\n await run({ version })\n },\n})\n"],"mappings":";;;;AAGA,MAAa,UAAU,OAAO;CAC5B,MAAM;CACN,aACE;CACF,UAAU;EAAC;EAAY;EAAyC;CAA+E,CAAC,CAAC,KAAK,IAAI;CAC1J,MAAM,MAAM;EACV,MAAM,EAAE,QAAQ,MAAM,OAAO;EAE7B,MAAM,IAAI,EAAE,QAAQ,CAAC;CACvB;AACF,CAAC"}
|
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
require("./rolldown-runtime-Bx3C2hgW.cjs");
|
|
2
|
-
const
|
|
3
|
-
const require_package = require("./package-BBBOfxZz.cjs");
|
|
2
|
+
const require_package = require("./package-B57sF1X0.cjs");
|
|
4
3
|
//#region src/commands/mcp.ts
|
|
5
|
-
const command =
|
|
4
|
+
const command = (0, require("gunshi").define)({
|
|
6
5
|
name: "mcp",
|
|
7
6
|
description: "Start a Model Context Protocol (MCP) server that exposes Kubb code generation as tools for AI assistants. Once running, configure your AI client (Claude, Cursor, Windsurf, etc.) to connect to it — the assistant can then call kubb generate directly without leaving the chat.",
|
|
8
7
|
examples: [
|
|
9
8
|
"kubb mcp",
|
|
10
9
|
"# Then add to your MCP client config:",
|
|
11
10
|
"# { \"mcpServers\": { \"kubb\": { \"command\": \"npx\", \"args\": [\"kubb\", \"mcp\"] } } }"
|
|
12
|
-
],
|
|
11
|
+
].join("\n"),
|
|
13
12
|
async run() {
|
|
14
|
-
const { run } = await Promise.resolve().then(() => require("./run-
|
|
13
|
+
const { run } = await Promise.resolve().then(() => require("./run-B9FN0sHW.cjs"));
|
|
15
14
|
await run({ version: require_package.version });
|
|
16
15
|
}
|
|
17
16
|
});
|
|
18
17
|
//#endregion
|
|
19
18
|
exports.command = command;
|
|
20
19
|
|
|
21
|
-
//# sourceMappingURL=mcp-
|
|
20
|
+
//# sourceMappingURL=mcp-DYmjmXQb.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-DYmjmXQb.cjs","names":[],"sources":["../src/commands/mcp.ts"],"sourcesContent":["import { define } from 'gunshi'\nimport { version } from '../../package.json'\n\nexport const command = define({\n name: 'mcp',\n description:\n 'Start a Model Context Protocol (MCP) server that exposes Kubb code generation as tools for AI assistants. Once running, configure your AI client (Claude, Cursor, Windsurf, etc.) to connect to it — the assistant can then call kubb generate directly without leaving the chat.',\n examples: ['kubb mcp', '# Then add to your MCP client config:', '# { \"mcpServers\": { \"kubb\": { \"command\": \"npx\", \"args\": [\"kubb\", \"mcp\"] } } }'].join('\\n'),\n async run() {\n const { run } = await import('../runners/mcp/run.ts')\n\n await run({ version })\n },\n})\n"],"mappings":";;;AAGA,MAAa,WAAA,mBAAA,CAAA,CAAA,OAAA,CAAiB;CAC5B,MAAM;CACN,aACE;CACF,UAAU;EAAC;EAAY;EAAyC;CAA+E,CAAC,CAAC,KAAK,IAAI;CAC1J,MAAM,MAAM;EACV,MAAM,EAAE,QAAQ,MAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAM,oBAAA,CAAA;EAEtB,MAAM,IAAI,EAAE,SAAA,gBAAA,QAAQ,CAAC;CACvB;AACF,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region package.json
|
|
2
|
-
var version = "5.0.0-beta.
|
|
2
|
+
var version = "5.0.0-beta.85";
|
|
3
3
|
//#endregion
|
|
4
4
|
Object.defineProperty(exports, "version", {
|
|
5
5
|
enumerable: true,
|
|
@@ -8,4 +8,4 @@ Object.defineProperty(exports, "version", {
|
|
|
8
8
|
}
|
|
9
9
|
});
|
|
10
10
|
|
|
11
|
-
//# sourceMappingURL=package-
|
|
11
|
+
//# sourceMappingURL=package-B57sF1X0.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-B57sF1X0.cjs","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-CQbxcw7I.js","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-Bx3C2hgW.cjs");
|
|
2
|
-
const require_tools = require("./tools-
|
|
2
|
+
const require_tools = require("./tools-CeIABV0T.cjs");
|
|
3
3
|
let node_util = require("node:util");
|
|
4
|
+
let node_process = require("node:process");
|
|
5
|
+
node_process = require_rolldown_runtime.__toESM(node_process, 1);
|
|
4
6
|
let node_fs = require("node:fs");
|
|
5
7
|
node_fs = require_rolldown_runtime.__toESM(node_fs, 1);
|
|
6
8
|
let node_path = require("node:path");
|
|
7
9
|
node_path = require_rolldown_runtime.__toESM(node_path, 1);
|
|
8
|
-
let node_process = require("node:process");
|
|
9
|
-
node_process = require_rolldown_runtime.__toESM(node_process, 1);
|
|
10
10
|
let _clack_prompts = require("@clack/prompts");
|
|
11
11
|
_clack_prompts = require_rolldown_runtime.__toESM(_clack_prompts, 1);
|
|
12
12
|
let tinyexec = require("tinyexec");
|
|
@@ -290,4 +290,4 @@ async function run({ yes, version, input: inputFlag, output: outputFlag, plugins
|
|
|
290
290
|
//#endregion
|
|
291
291
|
exports.run = run;
|
|
292
292
|
|
|
293
|
-
//# sourceMappingURL=run-
|
|
293
|
+
//# sourceMappingURL=run-3qq_Q4Tg.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-3qq_Q4Tg.cjs","names":["process","fs","path","process","clack","detectPackageManager","path","fs"],"sources":["../../../internals/shared/src/constants.ts","../../../internals/shared/src/init.ts","../src/runners/init/utils.ts","../src/runners/init/run.ts"],"sourcesContent":["import type { PluginOption } from './types.ts'\n\nexport const KUBB_CONFIG_FILENAME = 'kubb.config.ts' as const\n\nexport const initDefaults = {\n inputPath: './openapi.yaml',\n outputPath: './src/gen',\n plugins: ['plugin-ts'],\n} as const\n\nexport const availablePlugins: Array<PluginOption> = [\n {\n value: 'plugin-ts',\n label: 'TypeScript',\n hint: 'Recommended',\n packageName: '@kubb/plugin-ts',\n importName: 'pluginTs',\n category: 'types',\n },\n {\n value: 'plugin-axios',\n label: 'Axios Client',\n packageName: '@kubb/plugin-axios',\n importName: 'pluginAxios',\n category: 'client',\n },\n {\n value: 'plugin-fetch',\n label: 'Fetch Client',\n packageName: '@kubb/plugin-fetch',\n importName: 'pluginFetch',\n category: 'client',\n },\n {\n value: 'plugin-react-query',\n label: 'React Query / TanStack Query',\n packageName: '@kubb/plugin-react-query',\n importName: 'pluginReactQuery',\n category: 'framework',\n },\n {\n value: 'plugin-vue-query',\n label: 'Vue Query',\n packageName: '@kubb/plugin-vue-query',\n importName: 'pluginVueQuery',\n category: 'framework',\n },\n {\n value: 'plugin-zod',\n label: 'Zod Schemas',\n packageName: '@kubb/plugin-zod',\n importName: 'pluginZod',\n category: 'validation',\n },\n {\n value: 'plugin-faker',\n label: 'Faker.js Mocks',\n packageName: '@kubb/plugin-faker',\n importName: 'pluginFaker',\n category: 'mocks',\n },\n {\n value: 'plugin-msw',\n label: 'MSW Handlers',\n packageName: '@kubb/plugin-msw',\n importName: 'pluginMsw',\n category: 'mocks',\n },\n {\n value: 'plugin-cypress',\n label: 'Cypress Tests',\n packageName: '@kubb/plugin-cypress',\n importName: 'pluginCypress',\n category: 'testing',\n },\n {\n value: 'plugin-mcp',\n label: 'MCP Server (AI / Model Context Protocol)',\n packageName: '@kubb/plugin-mcp',\n importName: 'pluginMcp',\n category: 'ai',\n },\n {\n value: 'plugin-redoc',\n label: 'ReDoc Documentation',\n packageName: '@kubb/plugin-redoc',\n importName: 'pluginRedoc',\n category: 'documentation',\n },\n]\n","import type { PluginOption } from './types.ts'\n\nexport function generateConfigFile({\n selectedPlugins,\n inputPath,\n outputPath,\n}: {\n selectedPlugins: Array<PluginOption>\n inputPath: string\n outputPath: string\n}): string {\n const imports = selectedPlugins.map((plugin) => `import { ${plugin.importName} } from '${plugin.packageName}'`).join('\\n')\n\n const pluginConfigs = selectedPlugins.map((plugin) => ` ${plugin.importName}(),`).join('\\n')\n\n return `import { defineConfig } from 'kubb'\n${imports}\n\nexport default defineConfig({\n root: '.',\n input: {\n path: '${inputPath}',\n },\n output: {\n path: '${outputPath}',\n clean: true,\n },\n plugins: [\n${pluginConfigs}\n ],\n})\n`\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\nimport process from 'node:process'\nimport { x } from 'tinyexec'\nimport type { PackageManagerInfo, PackageManagerName } from '../../tools.ts'\n\n/**\n * Returns `true` when a `package.json` exists at `cwd`.\n */\nexport function hasPackageJson(cwd: string = process.cwd()): boolean {\n return fs.existsSync(path.join(cwd, 'package.json'))\n}\n\n/**\n * Initializes a new `package.json` at `cwd` using the detected package manager.\n */\nexport async function initPackageJson(cwd: string, packageManager: PackageManagerInfo): Promise<void> {\n const commands: Record<PackageManagerName, Array<string>> = {\n npm: ['init', '-y'],\n pnpm: ['init'],\n yarn: ['init', '-y'],\n bun: ['init', '-y'],\n }\n\n await x(packageManager.name, commands[packageManager.name], {\n nodeOptions: { cwd, stdio: 'inherit' },\n throwOnError: true,\n })\n}\n\n/**\n * Installs the given packages at `cwd` using the detected package manager.\n */\nexport async function installPackages(packages: Array<string>, packageManager: PackageManagerInfo, cwd: string = process.cwd()): Promise<void> {\n await x(packageManager.name, [...packageManager.installCommand, ...packages], {\n nodeOptions: { cwd, stdio: 'inherit' },\n throwOnError: true,\n })\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\nimport process from 'node:process'\nimport { styleText } from 'node:util'\nimport * as clack from '@clack/prompts'\nimport { availablePlugins, generateConfigFile, initDefaults, KUBB_CONFIG_FILENAME, type PluginOption } from '@internals/shared'\nimport { hasPackageJson, initPackageJson, installPackages } from './utils.ts'\nimport { detectPackageManager } from '../../tools.ts'\n\nfunction cancelAndExit(message = 'Operation canceled.'): never {\n clack.cancel(message)\n process.exit(0)\n}\n\ntype InitOptions = {\n /**\n * When `true`, skips all interactive prompts and uses default values.\n */\n yes: boolean\n /**\n * Current `@kubb/cli` version string, shown in the closing outro.\n */\n version: string\n /**\n * Input path flag value from `--input`. When provided, skips the input prompt.\n */\n input?: string\n /**\n * Output directory flag value from `--output`. When provided, skips the output prompt.\n */\n output?: string\n /**\n * Comma-separated plugin list from `--plugins`, e.g. `'plugin-ts,plugin-zod'`. When provided, skips the plugin selection prompt.\n */\n plugins?: string\n}\n\n/**\n * Runs the interactive Kubb scaffolding wizard.\n * Detects the package manager, prompts for input/output paths and plugins, installs packages, and writes `kubb.config.ts`.\n * Pass `yes: true` to skip all prompts and use defaults.\n */\nexport async function run({ yes, version, input: inputFlag, output: outputFlag, plugins: pluginsFlag }: InitOptions): Promise<void> {\n const cwd = process.cwd()\n\n clack.intro(styleText('bgCyan', styleText('black', ' Kubb Init ')))\n\n /**\n * Returns `flag` when provided, the `defaultValue` when `yes` is set,\n * or calls `prompt()` for interactive input. Exits on cancellation.\n */\n async function resolveOrPrompt<T>(flag: T | undefined, defaultValue: T, logLabel: string, prompt: () => Promise<T | symbol>): Promise<T> {\n if (flag !== undefined) {\n clack.log.info(`${logLabel}: ${styleText('cyan', String(flag))}`)\n return flag\n }\n if (yes) {\n clack.log.info(`${logLabel}: ${styleText('cyan', String(defaultValue))}`)\n return defaultValue\n }\n const result = await prompt()\n if (clack.isCancel(result)) cancelAndExit()\n return result as T\n }\n\n try {\n // Check/create package.json, detect package manager once after the block\n if (!hasPackageJson(cwd)) {\n if (!yes) {\n const shouldInit = await clack.confirm({\n message: 'No package.json found. Would you like to create one?',\n initialValue: true,\n })\n\n if (clack.isCancel(shouldInit) || !shouldInit) {\n cancelAndExit()\n }\n }\n\n const packageManager = detectPackageManager(cwd)\n const spinner = clack.spinner()\n spinner.start(`Initializing package.json with ${packageManager.name}`)\n await initPackageJson(cwd, packageManager)\n spinner.stop(`Created package.json with ${packageManager.name}`)\n }\n\n const packageManager = detectPackageManager(cwd)\n if (hasPackageJson(cwd)) {\n clack.log.info(`Detected package manager: ${styleText('cyan', packageManager.name)}`)\n }\n\n // Prompt for OpenAPI spec path\n const inputPath = await resolveOrPrompt(inputFlag, initDefaults.inputPath, 'Using input path', () =>\n clack.text({\n message: 'Where is your OpenAPI specification located?',\n placeholder: initDefaults.inputPath,\n defaultValue: initDefaults.inputPath,\n validate: (value) => {\n if (!value) return 'Input path is required'\n },\n }),\n )\n\n // Prompt for output directory\n const outputPath = await resolveOrPrompt(outputFlag, initDefaults.outputPath, 'Using output path', () =>\n clack.text({\n message: 'Where should the generated files be output?',\n placeholder: initDefaults.outputPath,\n defaultValue: initDefaults.outputPath,\n validate: (value) => {\n if (!value) return 'Output path is required'\n },\n }),\n )\n\n // Plugin selection\n const defaultPlugins = availablePlugins.filter((p) => (initDefaults.plugins as ReadonlyArray<string>).includes(p.value))\n const pluginLabel = (plugins: Array<PluginOption>) => styleText('cyan', plugins.map((p) => p.label).join(', '))\n\n const selectedPlugins: Array<PluginOption> = await (async () => {\n if (pluginsFlag) {\n const requested = pluginsFlag\n .split(',')\n .map((v) => v.trim())\n .filter(Boolean)\n const plugins = availablePlugins.filter((p) => requested.includes(p.value))\n if (plugins.length === 0) {\n clack.log.warn(`No valid plugins found in --plugins value; falling back to default: ${pluginLabel(defaultPlugins)}`)\n return defaultPlugins\n }\n clack.log.info(`Using plugins: ${pluginLabel(plugins)}`)\n return plugins\n }\n if (yes) {\n clack.log.info(`Using plugins: ${pluginLabel(defaultPlugins)}`)\n return defaultPlugins\n }\n const values = await clack.multiselect({\n message: 'Select plugins to use:',\n options: availablePlugins.map(({ value, label, hint }) => ({ value, label, hint })),\n initialValues: [...initDefaults.plugins],\n required: true,\n })\n if (clack.isCancel(values)) cancelAndExit()\n return availablePlugins.filter((p) => (values as Array<string>).includes(p.value))\n })()\n\n // Install packages\n const packagesToInstall = ['kubb', ...selectedPlugins.map((p) => p.packageName)]\n\n const spinner = clack.spinner()\n spinner.start(`Installing ${packagesToInstall.length} packages with ${packageManager.name}`)\n\n try {\n await installPackages(packagesToInstall, packageManager, cwd)\n spinner.stop(`Installed ${packagesToInstall.length} packages`)\n } catch (error) {\n spinner.stop('Installation failed')\n throw error\n }\n\n // Generate config file\n const configSpinner = clack.spinner()\n configSpinner.start(`Creating ${KUBB_CONFIG_FILENAME}`)\n\n const configContent = generateConfigFile({ selectedPlugins, inputPath, outputPath })\n const configPath = path.join(cwd, KUBB_CONFIG_FILENAME)\n\n if (fs.existsSync(configPath)) {\n configSpinner.stop(`${KUBB_CONFIG_FILENAME} already exists`)\n\n if (!yes) {\n const shouldOverwrite = await clack.confirm({\n message: `${KUBB_CONFIG_FILENAME} already exists. Overwrite?`,\n initialValue: false,\n })\n\n if (clack.isCancel(shouldOverwrite) || !shouldOverwrite) {\n cancelAndExit('Keeping existing configuration. Packages have been installed.')\n }\n }\n\n configSpinner.start(`Overwriting ${KUBB_CONFIG_FILENAME}`)\n }\n\n await fs.promises.writeFile(configPath, configContent, 'utf-8')\n\n configSpinner.stop(`Created ${KUBB_CONFIG_FILENAME}`)\n\n clack.outro(\n styleText('green', '✓ All set!') +\n '\\n\\n' +\n styleText('dim', 'Next steps:') +\n '\\n' +\n styleText('cyan', ` 1. Make sure your OpenAPI spec is at: ${inputPath}`) +\n '\\n' +\n styleText('cyan', ' 2. Generate code with: npx kubb generate') +\n '\\n' +\n styleText('cyan', ` 3. Find generated files in: ${outputPath}`) +\n '\\n\\n' +\n styleText('dim', `Using ${packageManager.name} • Kubb v${version}`),\n )\n } catch (error) {\n clack.log.error(styleText('red', 'An error occurred during initialization'))\n if (error instanceof Error) {\n clack.log.error(error.message)\n }\n process.exit(1)\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAEA,MAAa,uBAAuB;AAEpC,MAAa,eAAe;CAC1B,WAAW;CACX,YAAY;CACZ,SAAS,CAAC,WAAW;AACvB;AAEA,MAAa,mBAAwC;CACnD;EACE,OAAO;EACP,OAAO;EACP,MAAM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B;GAE3D,IAAI,CAAC,KAAK;IACR,MAAM,kBAAkB,MAAMH,eAAM,QAAQ;KAC1C,SAAS,GAAG,qBAAqB;KACjC,cAAc;IAChB,CAAC;IAED,IAAIA,eAAM,SAAS,eAAe,KAAK,CAAC,iBACtC,cAAc,+DAA+D;GAEjF;GAEA,cAAc,MAAM,eAAe,sBAAsB;EAC3D;EAEA,MAAMG,QAAAA,QAAG,SAAS,UAAU,YAAY,eAAe,OAAO;EAE9D,cAAc,KAAK,WAAW,sBAAsB;EAEpD,eAAM,OAAA,GAAA,UAAA,UAAA,CACM,SAAS,YAAY,IAC7B,UAAA,GAAA,UAAA,UAAA,CACU,OAAO,aAAa,IAC9B,QAAA,GAAA,UAAA,UAAA,CACU,QAAQ,2CAA2C,WAAW,IACxE,QAAA,GAAA,UAAA,UAAA,CACU,QAAQ,4CAA4C,IAC9D,QAAA,GAAA,UAAA,UAAA,CACU,QAAQ,iCAAiC,YAAY,IAC/D,UAAA,GAAA,UAAA,UAAA,CACU,OAAO,SAAS,eAAe,KAAK,WAAW,SAAS,CACtE;CACF,SAAS,OAAO;EACd,eAAM,IAAI,OAAA,GAAA,UAAA,UAAA,CAAgB,OAAO,yCAAyC,CAAC;EAC3E,IAAI,iBAAiB,OACnB,eAAM,IAAI,MAAM,MAAM,OAAO;EAE/B,aAAA,QAAQ,KAAK,CAAC;CAChB;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-Bx3C2hgW.cjs");
|
|
2
|
+
const require_Telemetry = require("./Telemetry-CwQYBgsg.cjs");
|
|
2
3
|
const require_errors = require("./errors-gxFK0vrp.cjs");
|
|
3
|
-
const require_Telemetry = require("./Telemetry-jtbchpQE.cjs");
|
|
4
4
|
let node_util = require("node:util");
|
|
5
5
|
let node_process = require("node:process");
|
|
6
6
|
node_process = require_rolldown_runtime.__toESM(node_process, 1);
|
|
@@ -30,4 +30,4 @@ async function run({ version }) {
|
|
|
30
30
|
//#endregion
|
|
31
31
|
exports.run = run;
|
|
32
32
|
|
|
33
|
-
//# sourceMappingURL=run-
|
|
33
|
+
//# sourceMappingURL=run-B9FN0sHW.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-B9FN0sHW.cjs","names":["process","Telemetry","getErrorMessage"],"sources":["../src/runners/mcp/run.ts"],"sourcesContent":["import process from 'node:process'\nimport { styleText } from 'node:util'\nimport { getErrorMessage } from '@internals/utils'\nimport { Telemetry } from '../../Telemetry.ts'\nimport type * as McpModule from '@kubb/mcp'\n\ntype McpOptions = {\n /**\n * Current `@kubb/cli` version string, used for the telemetry payload.\n */\n version: string\n}\n\n/**\n * Starts the `@kubb/mcp` server over stdio and reports the outcome to telemetry.\n */\nexport async function run({ version }: McpOptions): Promise<void> {\n const { run: startMcpServer } = (await import('@kubb/mcp')) as typeof McpModule\n\n const hrStart = process.hrtime()\n const report = (status: 'success' | 'failed') => Telemetry.send(Telemetry.build({ command: 'mcp', kubbVersion: version, hrStart, status }))\n\n try {\n console.log(styleText('cyan', '⏳ Starting MCP server...'))\n console.warn(styleText('yellow', 'This feature is still under development, use with caution'))\n\n await startMcpServer()\n await report('success')\n } catch (error) {\n await report('failed')\n console.error(getErrorMessage(error))\n }\n}\n"],"mappings":";;;;;;;;;;AAgBA,eAAsB,IAAI,EAAE,WAAsC;CAChE,MAAM,EAAE,KAAK,mBAAoB,MAAM,OAAO;CAE9C,MAAM,UAAUA,aAAAA,QAAQ,OAAO;CAC/B,MAAM,UAAU,WAAiCC,kBAAAA,UAAU,KAAKA,kBAAAA,UAAU,MAAM;EAAE,SAAS;EAAO,aAAa;EAAS;EAAS;CAAO,CAAC,CAAC;CAE1I,IAAI;EACF,QAAQ,KAAA,GAAA,UAAA,UAAA,CAAc,QAAQ,0BAA0B,CAAC;EACzD,QAAQ,MAAA,GAAA,UAAA,UAAA,CAAe,UAAU,2DAA2D,CAAC;EAE7F,MAAM,eAAe;EACrB,MAAM,OAAO,SAAS;CACxB,SAAS,OAAO;EACd,MAAM,OAAO,QAAQ;EACrB,QAAQ,MAAMC,eAAAA,gBAAgB,KAAK,CAAC;CACtC;AACF"}
|
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
import "./rolldown-runtime-C0LytTxp.js";
|
|
2
|
+
import { t as Telemetry } from "./Telemetry-Cuzoes9Y.js";
|
|
2
3
|
import { t as getErrorMessage } from "./errors-Dc_d7BfX.js";
|
|
3
|
-
import { t as Telemetry } from "./Telemetry-ugO-B77y.js";
|
|
4
4
|
import { styleText } from "node:util";
|
|
5
5
|
import process from "node:process";
|
|
6
6
|
//#region src/runners/validate/run.ts
|
|
7
7
|
/**
|
|
8
|
-
* Dynamically loads `@kubb/adapter-oas` for OpenAPI validation.
|
|
9
|
-
*/
|
|
10
|
-
function loadValidateModule() {
|
|
11
|
-
return import("@kubb/adapter-oas");
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
8
|
* Validates an OpenAPI/Swagger file at `input` using `@kubb/adapter-oas`.
|
|
15
9
|
* Exits the process with code 1 on validation failure or missing dependency.
|
|
16
10
|
*/
|
|
17
|
-
async function run({ input, version }
|
|
11
|
+
async function run({ input, version }) {
|
|
18
12
|
const hrStart = process.hrtime();
|
|
19
13
|
const report = (status) => Telemetry.send(Telemetry.build({
|
|
20
14
|
command: "validate",
|
|
@@ -23,7 +17,7 @@ async function run({ input, version }, dependencies = { loadValidateModule }) {
|
|
|
23
17
|
status
|
|
24
18
|
}));
|
|
25
19
|
try {
|
|
26
|
-
const { adapterOas } = await
|
|
20
|
+
const { adapterOas } = await import("@kubb/adapter-oas");
|
|
27
21
|
const adapter = adapterOas();
|
|
28
22
|
if (!adapter.validate) throw new Error("The loaded adapter does not support validation.");
|
|
29
23
|
await adapter.validate(input, { throwOnError: true });
|
|
@@ -48,4 +42,4 @@ async function run({ input, version }, dependencies = { loadValidateModule }) {
|
|
|
48
42
|
//#endregion
|
|
49
43
|
export { run };
|
|
50
44
|
|
|
51
|
-
//# sourceMappingURL=run-
|
|
45
|
+
//# sourceMappingURL=run-BFhNcn8b.js.map
|