@kubb/cli 5.0.0-beta.75 → 5.0.0-beta.76
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/LICENSE +17 -10
- package/README.md +171 -51
- package/bin/kubb.js +9 -3
- package/dist/Telemetry-CxzkLSdD.js +284 -0
- package/dist/Telemetry-CxzkLSdD.js.map +1 -0
- package/dist/Telemetry-D8jhC5Bc.cjs +315 -0
- package/dist/Telemetry-D8jhC5Bc.cjs.map +1 -0
- package/dist/{define-Bdn8j5VM.cjs → defineCommand-Bo3yZTWI.cjs} +3 -21
- package/dist/defineCommand-Bo3yZTWI.cjs.map +1 -0
- package/dist/{define-Ctii4bel.js → defineCommand-DMEeqliP.js} +4 -16
- package/dist/defineCommand-DMEeqliP.js.map +1 -0
- package/dist/{errors-CjPmyZHy.js → errors-Dc_d7BfX.js} +2 -2
- package/dist/{errors-CjPmyZHy.js.map → errors-Dc_d7BfX.js.map} +1 -1
- package/dist/{errors-CLCjoSg0.cjs → errors-gxFK0vrp.cjs} +2 -2
- package/dist/{errors-CLCjoSg0.cjs.map → errors-gxFK0vrp.cjs.map} +1 -1
- package/dist/generate-DD2TMRmo.js +77 -0
- package/dist/generate-DD2TMRmo.js.map +1 -0
- package/dist/generate-DJUcRnD9.cjs +76 -0
- package/dist/generate-DJUcRnD9.cjs.map +1 -0
- package/dist/index.cjs +93 -149
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +93 -149
- package/dist/index.js.map +1 -1
- package/dist/init-BYgTbDpy.cjs +53 -0
- package/dist/init-BYgTbDpy.cjs.map +1 -0
- package/dist/init-CONuOE9n.js +53 -0
- package/dist/init-CONuOE9n.js.map +1 -0
- package/dist/mcp---VI5xTX.js +21 -0
- package/dist/mcp---VI5xTX.js.map +1 -0
- package/dist/mcp-CbM2iAFq.cjs +21 -0
- package/dist/mcp-CbM2iAFq.cjs.map +1 -0
- package/dist/package-6guIlMlB.js +6 -0
- package/dist/package-6guIlMlB.js.map +1 -0
- package/dist/{package-D5arPDnh.cjs → package-DnvclOkv.cjs} +2 -2
- package/dist/package-DnvclOkv.cjs.map +1 -0
- package/dist/run-44Zxh8Ec.js +289 -0
- package/dist/run-44Zxh8Ec.js.map +1 -0
- package/dist/run-BPLW8mrc.cjs +52 -0
- package/dist/run-BPLW8mrc.cjs.map +1 -0
- package/dist/run-D1rr0epF.js +1327 -0
- package/dist/run-D1rr0epF.js.map +1 -0
- package/dist/run-DXEMoDFa.cjs +293 -0
- package/dist/run-DXEMoDFa.cjs.map +1 -0
- package/dist/run-Dq0CXCqU.cjs +1330 -0
- package/dist/run-Dq0CXCqU.cjs.map +1 -0
- package/dist/run-Dv-1NGl-.js +32 -0
- package/dist/run-Dv-1NGl-.js.map +1 -0
- package/dist/run-GFI-E4ua.cjs +33 -0
- package/dist/run-GFI-E4ua.cjs.map +1 -0
- package/dist/run-WfvBLKQY.js +51 -0
- package/dist/run-WfvBLKQY.js.map +1 -0
- package/dist/tools-CZT9wSA6.cjs +175 -0
- package/dist/tools-CZT9wSA6.cjs.map +1 -0
- package/dist/tools-D0UogMU3.js +152 -0
- package/dist/tools-D0UogMU3.js.map +1 -0
- package/dist/validate-CNvR28KI.cjs +26 -0
- package/dist/validate-CNvR28KI.cjs.map +1 -0
- package/dist/validate-ClAyEQgx.js +26 -0
- package/dist/validate-ClAyEQgx.js.map +1 -0
- package/package.json +24 -28
- package/dist/agent-BEgI2HXH.cjs +0 -58
- package/dist/agent-BEgI2HXH.cjs.map +0 -1
- package/dist/agent-B_pirbeB.cjs +0 -116
- package/dist/agent-B_pirbeB.cjs.map +0 -1
- package/dist/agent-CTdJEHEs.js +0 -56
- package/dist/agent-CTdJEHEs.js.map +0 -1
- package/dist/agent-Ev5hU5hH.js +0 -112
- package/dist/agent-Ev5hU5hH.js.map +0 -1
- package/dist/constants-CnDXa1R6.cjs +0 -148
- package/dist/constants-CnDXa1R6.cjs.map +0 -1
- package/dist/constants-aL3CP_Wq.js +0 -95
- package/dist/constants-aL3CP_Wq.js.map +0 -1
- package/dist/define-Bdn8j5VM.cjs.map +0 -1
- package/dist/define-Ctii4bel.js.map +0 -1
- package/dist/generate-Cg8yufrw.js +0 -1753
- package/dist/generate-Cg8yufrw.js.map +0 -1
- package/dist/generate-DDCwNQNo.cjs +0 -65
- package/dist/generate-DDCwNQNo.cjs.map +0 -1
- package/dist/generate-K8MJ9aQF.cjs +0 -1756
- package/dist/generate-K8MJ9aQF.cjs.map +0 -1
- package/dist/generate-YPtfjsg4.js +0 -66
- package/dist/generate-YPtfjsg4.js.map +0 -1
- package/dist/init-Bu95ML_u.cjs +0 -25
- package/dist/init-Bu95ML_u.cjs.map +0 -1
- package/dist/init-CZ5Xq2Hd.cjs +0 -293
- package/dist/init-CZ5Xq2Hd.cjs.map +0 -1
- package/dist/init-eNRlotJK.js +0 -289
- package/dist/init-eNRlotJK.js.map +0 -1
- package/dist/init-ooJeOBGt.js +0 -25
- package/dist/init-ooJeOBGt.js.map +0 -1
- package/dist/mcp-C-d5N1wZ.js +0 -16
- package/dist/mcp-C-d5N1wZ.js.map +0 -1
- package/dist/mcp-CLcDV4Jm.cjs +0 -41
- package/dist/mcp-CLcDV4Jm.cjs.map +0 -1
- package/dist/mcp-D7EIR9fR.js +0 -40
- package/dist/mcp-D7EIR9fR.js.map +0 -1
- package/dist/mcp-Dpu8vzzj.cjs +0 -16
- package/dist/mcp-Dpu8vzzj.cjs.map +0 -1
- package/dist/package-D5arPDnh.cjs.map +0 -1
- package/dist/package-DqZsMLZ9.js +0 -6
- package/dist/package-DqZsMLZ9.js.map +0 -1
- package/dist/shell-475fQKaX.cjs +0 -62
- package/dist/shell-475fQKaX.cjs.map +0 -1
- package/dist/shell-DLzN4fRo.js +0 -51
- package/dist/shell-DLzN4fRo.js.map +0 -1
- package/dist/telemetry-DN95_2pF.cjs +0 -282
- package/dist/telemetry-DN95_2pF.cjs.map +0 -1
- package/dist/telemetry-LgT_sdPe.js +0 -245
- package/dist/telemetry-LgT_sdPe.js.map +0 -1
- package/dist/validate-CIR3_lZI.js +0 -25
- package/dist/validate-CIR3_lZI.js.map +0 -1
- package/dist/validate-DcqUb4DM.cjs +0 -25
- package/dist/validate-DcqUb4DM.cjs.map +0 -1
- package/dist/validate-kLJoT_hi.js +0 -33
- package/dist/validate-kLJoT_hi.js.map +0 -1
- package/dist/validate-yKKzqEZ5.cjs +0 -34
- package/dist/validate-yKKzqEZ5.cjs.map +0 -1
- package/src/commands/agent/start.ts +0 -47
- package/src/commands/agent.ts +0 -8
- package/src/commands/generate.ts +0 -57
- package/src/commands/init.ts +0 -20
- package/src/commands/mcp.ts +0 -12
- package/src/commands/validate.ts +0 -20
- package/src/constants.ts +0 -104
- package/src/index.ts +0 -43
- package/src/loggers/clackLogger.ts +0 -458
- package/src/loggers/fileSystemLogger.ts +0 -138
- package/src/loggers/githubActionsLogger.ts +0 -379
- package/src/loggers/plainLogger.ts +0 -254
- package/src/loggers/types.ts +0 -1
- package/src/loggers/utils.ts +0 -106
- package/src/runners/agent.ts +0 -149
- package/src/runners/generate.ts +0 -333
- package/src/runners/init.ts +0 -296
- package/src/runners/mcp.ts +0 -45
- package/src/runners/validate.ts +0 -39
- package/src/types.ts +0 -11
- package/src/utils/Writables.ts +0 -17
- package/src/utils/executeHooks.ts +0 -45
- package/src/utils/flags.ts +0 -9
- package/src/utils/getConfig.ts +0 -10
- package/src/utils/getCosmiConfig.ts +0 -80
- package/src/utils/getSummary.ts +0 -68
- package/src/utils/packageManager.ts +0 -23
- package/src/utils/runHook.ts +0 -91
- package/src/utils/telemetry.ts +0 -273
- package/src/utils/watcher.ts +0 -19
- /package/dist/{chunk-ByKO4r7w.cjs → rolldown-runtime-Bx3C2hgW.cjs} +0 -0
- /package/dist/{chunk--u3MIqq1.js → rolldown-runtime-C0LytTxp.js} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,48 +1,11 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import { t as
|
|
3
|
-
import {
|
|
4
|
-
import { t as version } from "./package-DqZsMLZ9.js";
|
|
5
|
-
import { i as QUIET_FLAGS } from "./constants-aL3CP_Wq.js";
|
|
1
|
+
import "./rolldown-runtime-C0LytTxp.js";
|
|
2
|
+
import { r as QUIET_FLAGS, t as Telemetry } from "./Telemetry-CxzkLSdD.js";
|
|
3
|
+
import { t as version } from "./package-6guIlMlB.js";
|
|
6
4
|
import { parseArgs, styleText } from "node:util";
|
|
7
|
-
//#region ../../internals/utils/src/cli/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* Use to expose CLI capabilities to AI agents or MCP tools.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```ts
|
|
14
|
-
* getCommandSchema([generateCommand, agentCommand])
|
|
15
|
-
* // [{ name: 'generate', options: [...], subCommands: [] }, ...]
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
function getCommandSchema(defs) {
|
|
19
|
-
return defs.map(serializeCommand);
|
|
5
|
+
//#region ../../internals/utils/src/cli/renderHelp.ts
|
|
6
|
+
function formatFlags(name, opt) {
|
|
7
|
+
return `${opt.short ? `-${opt.short}, ` : ""}--${name}${opt.type === "string" ? ` <${opt.hint ?? name}>` : ""}`;
|
|
20
8
|
}
|
|
21
|
-
function serializeCommand(def) {
|
|
22
|
-
return {
|
|
23
|
-
name: def.name,
|
|
24
|
-
description: def.description,
|
|
25
|
-
arguments: def.arguments,
|
|
26
|
-
options: serializeOptions(def.options ?? {}),
|
|
27
|
-
subCommands: def.subCommands ? def.subCommands.map(serializeCommand) : []
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
function serializeOptions(options) {
|
|
31
|
-
return Object.entries(options).map(([name, opt]) => {
|
|
32
|
-
return {
|
|
33
|
-
name,
|
|
34
|
-
flags: `${opt.short ? `-${opt.short}, ` : ""}--${name}${opt.type === "string" ? ` <${opt.hint ?? name}>` : ""}`,
|
|
35
|
-
type: opt.type,
|
|
36
|
-
description: opt.description,
|
|
37
|
-
...opt.default !== void 0 ? { default: opt.default } : {},
|
|
38
|
-
...opt.hint ? { hint: opt.hint } : {},
|
|
39
|
-
...opt.enum ? { enum: opt.enum } : {},
|
|
40
|
-
...opt.required ? { required: opt.required } : {}
|
|
41
|
-
};
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
//#endregion
|
|
45
|
-
//#region ../../internals/utils/src/cli/help.ts
|
|
46
9
|
/** Prints formatted help output for `def` using its `CommandDefinition`.
|
|
47
10
|
*
|
|
48
11
|
* @example
|
|
@@ -52,21 +15,23 @@ function serializeOptions(options) {
|
|
|
52
15
|
* ```
|
|
53
16
|
*/
|
|
54
17
|
function renderHelp(def, parentName) {
|
|
55
|
-
const
|
|
56
|
-
const
|
|
57
|
-
const argsPart =
|
|
58
|
-
const subCmdPart =
|
|
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>" : "";
|
|
59
22
|
console.log(`\n${styleText("bold", "Usage:")} ${programName}${argsPart}${subCmdPart} [options]\n`);
|
|
60
|
-
if (
|
|
61
|
-
if (
|
|
23
|
+
if (def.description) console.log(` ${def.description}\n`);
|
|
24
|
+
if (subCommands.length) {
|
|
62
25
|
console.log(styleText("bold", "Commands:"));
|
|
63
|
-
for (const sub of
|
|
26
|
+
for (const sub of subCommands) console.log(` ${styleText("cyan", sub.name.padEnd(16))}${sub.description}`);
|
|
64
27
|
console.log();
|
|
65
28
|
}
|
|
66
|
-
const options = [...
|
|
67
|
-
|
|
29
|
+
const options = [...Object.entries(def.options ?? {}).map(([name, opt]) => ({
|
|
30
|
+
flags: formatFlags(name, opt),
|
|
31
|
+
description: opt.description,
|
|
32
|
+
default: opt.default
|
|
33
|
+
})), {
|
|
68
34
|
flags: "-h, --help",
|
|
69
|
-
type: "boolean",
|
|
70
35
|
description: "Show help"
|
|
71
36
|
}];
|
|
72
37
|
console.log(styleText("bold", "Options:"));
|
|
@@ -76,9 +41,14 @@ function renderHelp(def, parentName) {
|
|
|
76
41
|
console.log(` ${flags}${opt.description}${defaultPart}`);
|
|
77
42
|
}
|
|
78
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
|
+
}
|
|
79
49
|
}
|
|
80
50
|
//#endregion
|
|
81
|
-
//#region ../../internals/utils/src/cli/
|
|
51
|
+
//#region ../../internals/utils/src/cli/runCLI.ts
|
|
82
52
|
function buildParseOptions(def) {
|
|
83
53
|
const result = { help: {
|
|
84
54
|
type: "boolean",
|
|
@@ -132,7 +102,9 @@ async function runCommand(def, argv, parentName) {
|
|
|
132
102
|
}
|
|
133
103
|
function printRootHelp(programName, version, defs) {
|
|
134
104
|
console.log(`\n${styleText("bold", "Usage:")} ${programName} <command> [options]\n`);
|
|
135
|
-
console.log(` Kubb
|
|
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`);
|
|
136
108
|
console.log(styleText("bold", "Commands:"));
|
|
137
109
|
for (const def of defs) console.log(` ${styleText("cyan", def.name.padEnd(16))}${def.description}`);
|
|
138
110
|
console.log();
|
|
@@ -143,117 +115,89 @@ function printRootHelp(programName, version, defs) {
|
|
|
143
115
|
console.log(`Run ${styleText("cyan", `${programName} <command> --help`)} for command-specific help.\n`);
|
|
144
116
|
}
|
|
145
117
|
/**
|
|
146
|
-
*
|
|
147
|
-
|
|
148
|
-
const nodeAdapter = defineCLIAdapter({
|
|
149
|
-
renderHelp(def, parentName) {
|
|
150
|
-
renderHelp(def, parentName);
|
|
151
|
-
},
|
|
152
|
-
async run(defs, argv, opts) {
|
|
153
|
-
const { programName, defaultCommandName, version } = opts;
|
|
154
|
-
const args = argv.length >= 2 && argv[0]?.includes("node") ? argv.slice(2) : argv;
|
|
155
|
-
if (args[0] === "--version" || args[0] === "-v") {
|
|
156
|
-
console.log(version);
|
|
157
|
-
process.exit(0);
|
|
158
|
-
}
|
|
159
|
-
if (args[0] === "--help" || args[0] === "-h") {
|
|
160
|
-
printRootHelp(programName, version, defs);
|
|
161
|
-
process.exit(0);
|
|
162
|
-
}
|
|
163
|
-
if (args.length === 0) {
|
|
164
|
-
const defaultDef = defs.find((d) => d.name === defaultCommandName);
|
|
165
|
-
if (defaultDef?.run) await runCommand(defaultDef, [], programName);
|
|
166
|
-
else printRootHelp(programName, version, defs);
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
const [first, ...rest] = args;
|
|
170
|
-
const isKnownSubcommand = defs.some((d) => d.name === first);
|
|
171
|
-
let def;
|
|
172
|
-
let commandArgv;
|
|
173
|
-
let parentName;
|
|
174
|
-
if (isKnownSubcommand) {
|
|
175
|
-
def = defs.find((d) => d.name === first);
|
|
176
|
-
commandArgv = rest;
|
|
177
|
-
parentName = programName;
|
|
178
|
-
} else {
|
|
179
|
-
def = defs.find((d) => d.name === defaultCommandName);
|
|
180
|
-
commandArgv = args;
|
|
181
|
-
parentName = programName;
|
|
182
|
-
}
|
|
183
|
-
if (!def) {
|
|
184
|
-
console.error(`Unknown command: ${first}`);
|
|
185
|
-
printRootHelp(programName, version, defs);
|
|
186
|
-
process.exit(1);
|
|
187
|
-
}
|
|
188
|
-
if (def.subCommands?.length) {
|
|
189
|
-
const [subName, ...subRest] = commandArgv;
|
|
190
|
-
const subDef = def.subCommands.find((s) => s.name === subName);
|
|
191
|
-
if (subName === "--help" || subName === "-h") {
|
|
192
|
-
renderHelp(def, parentName);
|
|
193
|
-
process.exit(0);
|
|
194
|
-
}
|
|
195
|
-
if (!subDef) {
|
|
196
|
-
renderHelp(def, parentName);
|
|
197
|
-
process.exit(subName ? 1 : 0);
|
|
198
|
-
}
|
|
199
|
-
await runCommand(subDef, subRest, `${parentName} ${def.name}`);
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
await runCommand(def, commandArgv, parentName);
|
|
203
|
-
}
|
|
204
|
-
});
|
|
205
|
-
//#endregion
|
|
206
|
-
//#region ../../internals/utils/src/cli/parse.ts
|
|
207
|
-
/**
|
|
208
|
-
* Creates a CLI runner bound to a specific adapter.
|
|
209
|
-
*
|
|
210
|
-
* @default nodeAdapter (Node.js `node:util parseArgs`)
|
|
118
|
+
* Parses `argv` and runs the matching command using `node:util parseArgs`. No external dependencies.
|
|
119
|
+
* Falls back to `defaultCommandName` when no command is given.
|
|
211
120
|
*
|
|
212
121
|
* @example
|
|
213
122
|
* ```ts
|
|
214
|
-
* await
|
|
123
|
+
* await runCLI(commands, process.argv, {
|
|
215
124
|
* programName: 'kubb',
|
|
216
125
|
* defaultCommandName: 'generate',
|
|
217
126
|
* version: '5.0.0',
|
|
218
127
|
* })
|
|
219
128
|
* ```
|
|
220
129
|
*/
|
|
221
|
-
function
|
|
222
|
-
const
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
130
|
+
async function runCLI(defs, argv, opts) {
|
|
131
|
+
const { programName, defaultCommandName, version } = opts;
|
|
132
|
+
const firstArgIsExecutablePath = (argv[0]?.includes("/") || argv[0]?.includes("\\")) ?? false;
|
|
133
|
+
const args = argv.length >= 2 && firstArgIsExecutablePath ? argv.slice(2) : argv;
|
|
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);
|
|
226
182
|
}
|
|
227
183
|
//#endregion
|
|
228
|
-
//#region src/
|
|
184
|
+
//#region src/index.ts
|
|
229
185
|
/**
|
|
230
|
-
*
|
|
186
|
+
* Entry point for the `kubb` CLI. Prints the telemetry notice unless telemetry is disabled or a
|
|
187
|
+
* quiet flag is passed, then runs the generate, validate, mcp, and init commands. Defaults to
|
|
188
|
+
* `generate` when no command is given.
|
|
231
189
|
*/
|
|
232
|
-
function isFlag(set, value) {
|
|
233
|
-
for (const flag of set) if (flag === value) return true;
|
|
234
|
-
return false;
|
|
235
|
-
}
|
|
236
|
-
//#endregion
|
|
237
|
-
//#region src/index.ts
|
|
238
|
-
const cli = createCLI();
|
|
239
|
-
function shouldShowTelemetryNotice(argv) {
|
|
240
|
-
if (isTelemetryDisabled()) return false;
|
|
241
|
-
if (argv.some((arg) => isFlag(QUIET_FLAGS, arg))) return false;
|
|
242
|
-
if (!process.stdout.isTTY) return false;
|
|
243
|
-
return true;
|
|
244
|
-
}
|
|
245
190
|
async function run(argv = process.argv) {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
const { command:
|
|
249
|
-
const { command:
|
|
250
|
-
const { command:
|
|
251
|
-
const { command: initCommand } = await import("./init-
|
|
252
|
-
await
|
|
191
|
+
const isQuietFlag = argv.some((arg) => QUIET_FLAGS.has(arg));
|
|
192
|
+
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-DD2TMRmo.js");
|
|
194
|
+
const { command: validateCommand } = await import("./validate-ClAyEQgx.js");
|
|
195
|
+
const { command: mcpCommand } = await import("./mcp---VI5xTX.js");
|
|
196
|
+
const { command: initCommand } = await import("./init-CONuOE9n.js");
|
|
197
|
+
await runCLI([
|
|
253
198
|
generateCommand,
|
|
254
199
|
validateCommand,
|
|
255
200
|
mcpCommand,
|
|
256
|
-
agentCommand,
|
|
257
201
|
initCommand
|
|
258
202
|
], argv, {
|
|
259
203
|
programName: "kubb",
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../internals/utils/src/cli/schema.ts","../../../internals/utils/src/cli/help.ts","../../../internals/utils/src/cli/adapters/nodeAdapter.ts","../../../internals/utils/src/cli/parse.ts","../src/utils/flags.ts","../src/index.ts"],"sourcesContent":["import type { CommandDefinition, CommandSchema, OptionDefinition, OptionSchema } from './types.ts'\n\n/**\n * Serializes `CommandDefinition[]` to a plain, JSON-serializable structure.\n * Use to expose CLI capabilities to AI agents or MCP tools.\n *\n * @example\n * ```ts\n * getCommandSchema([generateCommand, agentCommand])\n * // [{ name: 'generate', options: [...], subCommands: [] }, ...]\n * ```\n */\nexport function getCommandSchema(defs: CommandDefinition[]): CommandSchema[] {\n return defs.map(serializeCommand)\n}\n\nfunction serializeCommand(def: CommandDefinition): CommandSchema {\n return {\n name: def.name,\n description: def.description,\n arguments: def.arguments,\n options: serializeOptions(def.options ?? {}),\n subCommands: def.subCommands ? def.subCommands.map(serializeCommand) : [],\n }\n}\n\nfunction serializeOptions(options: Record<string, OptionDefinition>): OptionSchema[] {\n return Object.entries(options).map(([name, opt]) => {\n const shortPart = opt.short ? `-${opt.short}, ` : ''\n const valuePart = opt.type === 'string' ? ` <${opt.hint ?? name}>` : ''\n const flags = `${shortPart}--${name}${valuePart}`\n\n return {\n name,\n flags,\n type: opt.type,\n description: opt.description,\n ...(opt.default !== undefined ? { default: opt.default } : {}),\n ...(opt.hint ? { hint: opt.hint } : {}),\n ...(opt.enum ? { enum: opt.enum } : {}),\n ...(opt.required ? { required: opt.required } : {}),\n }\n })\n}\n","import { styleText } from 'node:util'\nimport { getCommandSchema } from './schema.ts'\nimport type { CommandDefinition, OptionSchema } from './types.ts'\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 schema = getCommandSchema([def])[0]!\n\n const programName = parentName ? `${parentName} ${schema.name}` : schema.name\n\n const argsPart = schema.arguments?.length ? ` ${schema.arguments.join(' ')}` : ''\n const subCmdPart = schema.subCommands.length ? ' <command>' : ''\n console.log(`\\n${styleText('bold', 'Usage:')} ${programName}${argsPart}${subCmdPart} [options]\\n`)\n\n if (schema.description) {\n console.log(` ${schema.description}\\n`)\n }\n\n if (schema.subCommands.length) {\n console.log(styleText('bold', 'Commands:'))\n for (const sub of schema.subCommands) {\n console.log(` ${styleText('cyan', sub.name.padEnd(16))}${sub.description}`)\n }\n console.log()\n }\n\n const options: OptionSchema[] = [\n ...schema.options,\n {\n name: 'help',\n flags: '-h, --help',\n type: 'boolean' as const,\n description: 'Show help',\n },\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","import { parseArgs, styleText } from 'node:util'\nimport { defineCLIAdapter } from '../define.ts'\nimport { renderHelp } from '../help.ts'\nimport type { CommandDefinition, OptionType, ParsedArgs, RunOptions } from '../types.ts'\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: 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: CommandDefinition[]): void {\n console.log(`\\n${styleText('bold', 'Usage:')} ${programName} <command> [options]\\n`)\n console.log(` Kubb generation — v${version}\\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 * CLI adapter using `node:util parseArgs`. No external dependencies.\n */\nexport const nodeAdapter = defineCLIAdapter({\n renderHelp(def: CommandDefinition, parentName?: string): void {\n renderHelp(def, parentName)\n },\n\n async run(defs: CommandDefinition[], argv: string[], opts: RunOptions): Promise<void> {\n const { programName, defaultCommandName, version } = opts\n\n const args = argv.length >= 2 && argv[0]?.includes('node') ? 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: 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})\n","import { nodeAdapter } from './adapters/nodeAdapter.ts'\nimport type { CLIAdapter, CommandDefinition, RunOptions } from './types.ts'\n\n/**\n * Creates a CLI runner bound to a specific adapter.\n *\n * @default nodeAdapter (Node.js `node:util parseArgs`)\n *\n * @example\n * ```ts\n * await createCLI().run(commands, process.argv.slice(2), {\n * programName: 'kubb',\n * defaultCommandName: 'generate',\n * version: '5.0.0',\n * })\n * ```\n */\nexport function createCLI(options?: { adapter?: CLIAdapter }): {\n run(commands: CommandDefinition[], argv: string[], opts: RunOptions): Promise<void>\n} {\n const adapter = options?.adapter ?? nodeAdapter\n\n return {\n run(commands, argv, opts) {\n return adapter.run(commands, argv, opts)\n },\n }\n}\n","/**\n * Type guard that confirms `value` is a member of `set`. Avoids type assertions with `Set<T extends string>`.\n */\nexport function isFlag<T extends string>(set: ReadonlySet<T>, value: string): value is T {\n for (const flag of set) {\n if (flag === value) return true\n }\n return false\n}\n","import { styleText } from 'node:util'\nimport { createCLI } from '@internals/utils'\nimport { version } from '../package.json'\nimport { QUIET_FLAGS } from './constants.ts'\nimport { isFlag } from './utils/flags.ts'\nimport { isTelemetryDisabled } from './utils/telemetry.ts'\n\nconst cli = createCLI()\n\nfunction shouldShowTelemetryNotice(argv: Array<string>): boolean {\n if (isTelemetryDisabled()) {\n return false\n }\n // Skip when the user is just asking for help or version info\n if (argv.some((arg) => isFlag(QUIET_FLAGS, arg))) {\n return false\n }\n // Skip in non-interactive / scripting contexts\n if (!process.stdout.isTTY) {\n return false\n }\n return true\n}\n\nexport async function run(argv: Array<string> = process.argv): Promise<void> {\n if (shouldShowTelemetryNotice(argv)) {\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: agentCommand } = await import('./commands/agent.ts')\n const { command: initCommand } = await import('./commands/init.ts')\n\n await cli.run([generateCommand, validateCommand, mcpCommand, agentCommand, initCommand], argv, {\n programName: 'kubb',\n defaultCommandName: 'generate',\n version,\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAYA,SAAgB,iBAAiB,MAA4C;AAC3E,QAAO,KAAK,IAAI,iBAAiB;;AAGnC,SAAS,iBAAiB,KAAuC;AAC/D,QAAO;EACL,MAAM,IAAI;EACV,aAAa,IAAI;EACjB,WAAW,IAAI;EACf,SAAS,iBAAiB,IAAI,WAAW,EAAE,CAAC;EAC5C,aAAa,IAAI,cAAc,IAAI,YAAY,IAAI,iBAAiB,GAAG,EAAE;EAC1E;;AAGH,SAAS,iBAAiB,SAA2D;AACnF,QAAO,OAAO,QAAQ,QAAQ,CAAC,KAAK,CAAC,MAAM,SAAS;AAKlD,SAAO;GACL;GACA,OAAA,GANgB,IAAI,QAAQ,IAAI,IAAI,MAAM,MAAM,GAEvB,IAAI,OADb,IAAI,SA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vBH,SAAgB,OAAyB,KAAqB,OAA2B;AACvF,MAAK,MAAM,QAAQ,IACjB,KAAI,SAAS,MAAO,QAAO;AAE7B,QAAO;;;;ACAT,MAAM,MAAM,WAAW;AAEvB,SAAS,0BAA0B,MAA8B;AAC/D,KAAI,qBAAqB,CACvB,QAAO;AAGT,KAAI,KAAK,MAAM,QAAQ,OAAO,aAAa,IAAI,CAAC,CAC9C,QAAO;AAGT,KAAI,CAAC,QAAQ,OAAO,MAClB,QAAO;AAET,QAAO;;AAGT,eAAsB,IAAI,OAAsB,QAAQ,MAAqB;AAC3E,KAAI,0BAA0B,KAAK,CACjC,SAAQ,IACN,GAAG,UAAU,UAAU,UAAU,CAAC,uIAAuI,UAAU,QAAQ,2BAA2B,CAAC,KACxN;CAGH,MAAM,EAAE,SAAS,oBAAoB,MAAM,OAAO;CAClD,MAAM,EAAE,SAAS,oBAAoB,MAAM,OAAO;CAClD,MAAM,EAAE,SAAS,eAAe,MAAM,OAAO;CAC7C,MAAM,EAAE,SAAS,iBAAiB,MAAM,OAAO;CAC/C,MAAM,EAAE,SAAS,gBAAgB,MAAM,OAAO;AAE9C,OAAM,IAAI,IAAI;EAAC;EAAiB;EAAiB;EAAY;EAAc;EAAY,EAAE,MAAM;EAC7F,aAAa;EACb,oBAAoB;EACpB;EACD,CAAC"}
|
|
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}\n"],"mappings":";;;;;AAGA,SAAS,YAAY,MAAc,KAA+B;CAGhE,OAAO,GAFO,IAAI,QAAQ,IAAI,IAAI,MAAM,MAAM,GAE9B,IAAI,OADN,IAAI,SAAS,WAAW,KAAK,IAAI,QAAQ,KAAK,KAAK;AAEnE;;;;;;;;;AAUA,SAAgB,WAAW,KAAwB,YAA2B;CAC5E,MAAM,cAAc,aAAa,GAAG,WAAW,GAAG,IAAI,SAAS,IAAI;CACnE,MAAM,cAAc,IAAI,eAAe,CAAC;CAExC,MAAM,WAAW,IAAI,WAAW,SAAS,IAAI,IAAI,UAAU,KAAK,GAAG,MAAM;CACzE,MAAM,aAAa,YAAY,SAAS,eAAe;CACvD,QAAQ,IAAI,KAAK,UAAU,QAAQ,QAAQ,EAAE,GAAG,cAAc,WAAW,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AAM,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"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
require("./rolldown-runtime-Bx3C2hgW.cjs");
|
|
2
|
+
const require_defineCommand = require("./defineCommand-Bo3yZTWI.cjs");
|
|
3
|
+
const require_package = require("./package-DnvclOkv.cjs");
|
|
4
|
+
//#region src/commands/init.ts
|
|
5
|
+
const command = require_defineCommand.defineCommand({
|
|
6
|
+
name: "init",
|
|
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
|
+
examples: [
|
|
9
|
+
"kubb init",
|
|
10
|
+
"kubb init --yes",
|
|
11
|
+
"kubb init --input ./openapi.yaml --output ./src/gen --plugins plugin-ts,plugin-zod",
|
|
12
|
+
"kubb init --plugins plugin-ts,plugin-axios,plugin-react-query"
|
|
13
|
+
],
|
|
14
|
+
options: {
|
|
15
|
+
yes: {
|
|
16
|
+
type: "boolean",
|
|
17
|
+
description: "Skip prompts and use default options",
|
|
18
|
+
short: "y",
|
|
19
|
+
default: false
|
|
20
|
+
},
|
|
21
|
+
input: {
|
|
22
|
+
type: "string",
|
|
23
|
+
description: "Path to the OpenAPI specification",
|
|
24
|
+
short: "i",
|
|
25
|
+
hint: "path"
|
|
26
|
+
},
|
|
27
|
+
output: {
|
|
28
|
+
type: "string",
|
|
29
|
+
description: "Output directory for generated files",
|
|
30
|
+
short: "o",
|
|
31
|
+
hint: "path"
|
|
32
|
+
},
|
|
33
|
+
plugins: {
|
|
34
|
+
type: "string",
|
|
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
|
+
hint: "plugin-ts,plugin-zod,..."
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
async run({ values }) {
|
|
40
|
+
const { run } = await Promise.resolve().then(() => require("./run-DXEMoDFa.cjs"));
|
|
41
|
+
await run({
|
|
42
|
+
yes: values.yes,
|
|
43
|
+
version: require_package.version,
|
|
44
|
+
input: values.input,
|
|
45
|
+
output: values.output,
|
|
46
|
+
plugins: values.plugins
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
//#endregion
|
|
51
|
+
exports.command = command;
|
|
52
|
+
|
|
53
|
+
//# sourceMappingURL=init-BYgTbDpy.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init-BYgTbDpy.cjs","names":["defineCommand"],"sources":["../src/commands/init.ts"],"sourcesContent":["import { defineCommand } from '@internals/utils'\nimport { version } from '../../package.json'\n\nexport const command = defineCommand({\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 ],\n options: {\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 hint: 'path',\n },\n output: {\n type: 'string',\n description: 'Output directory for generated files',\n short: 'o',\n hint: '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 hint: '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,UAAUA,sBAAAA,cAAc;CACnC,MAAM;CACN,aACE;CACF,UAAU;EACR;EACA;EACA;EACA;CACF;CACA,SAAS;EACP,KAAK;GACH,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,OAAO;GACL,MAAM;GACN,aAAa;GACb,OAAO;GACP,MAAM;EACR;EACA,QAAQ;GACN,MAAM;GACN,aAAa;GACb,OAAO;GACP,MAAM;EACR;EACA,SAAS;GACP,MAAM;GACN,aACE;GACF,MAAM;EACR;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"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import "./rolldown-runtime-C0LytTxp.js";
|
|
2
|
+
import { t as defineCommand } from "./defineCommand-DMEeqliP.js";
|
|
3
|
+
import { t as version } from "./package-6guIlMlB.js";
|
|
4
|
+
//#region src/commands/init.ts
|
|
5
|
+
const command = defineCommand({
|
|
6
|
+
name: "init",
|
|
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
|
+
examples: [
|
|
9
|
+
"kubb init",
|
|
10
|
+
"kubb init --yes",
|
|
11
|
+
"kubb init --input ./openapi.yaml --output ./src/gen --plugins plugin-ts,plugin-zod",
|
|
12
|
+
"kubb init --plugins plugin-ts,plugin-axios,plugin-react-query"
|
|
13
|
+
],
|
|
14
|
+
options: {
|
|
15
|
+
yes: {
|
|
16
|
+
type: "boolean",
|
|
17
|
+
description: "Skip prompts and use default options",
|
|
18
|
+
short: "y",
|
|
19
|
+
default: false
|
|
20
|
+
},
|
|
21
|
+
input: {
|
|
22
|
+
type: "string",
|
|
23
|
+
description: "Path to the OpenAPI specification",
|
|
24
|
+
short: "i",
|
|
25
|
+
hint: "path"
|
|
26
|
+
},
|
|
27
|
+
output: {
|
|
28
|
+
type: "string",
|
|
29
|
+
description: "Output directory for generated files",
|
|
30
|
+
short: "o",
|
|
31
|
+
hint: "path"
|
|
32
|
+
},
|
|
33
|
+
plugins: {
|
|
34
|
+
type: "string",
|
|
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
|
+
hint: "plugin-ts,plugin-zod,..."
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
async run({ values }) {
|
|
40
|
+
const { run } = await import("./run-44Zxh8Ec.js");
|
|
41
|
+
await run({
|
|
42
|
+
yes: values.yes,
|
|
43
|
+
version,
|
|
44
|
+
input: values.input,
|
|
45
|
+
output: values.output,
|
|
46
|
+
plugins: values.plugins
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
//#endregion
|
|
51
|
+
export { command };
|
|
52
|
+
|
|
53
|
+
//# sourceMappingURL=init-CONuOE9n.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init-CONuOE9n.js","names":[],"sources":["../src/commands/init.ts"],"sourcesContent":["import { defineCommand } from '@internals/utils'\nimport { version } from '../../package.json'\n\nexport const command = defineCommand({\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 ],\n options: {\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 hint: 'path',\n },\n output: {\n type: 'string',\n description: 'Output directory for generated files',\n short: 'o',\n hint: '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 hint: '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,cAAc;CACnC,MAAM;CACN,aACE;CACF,UAAU;EACR;EACA;EACA;EACA;CACF;CACA,SAAS;EACP,KAAK;GACH,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,OAAO;GACL,MAAM;GACN,aAAa;GACb,OAAO;GACP,MAAM;EACR;EACA,QAAQ;GACN,MAAM;GACN,aAAa;GACb,OAAO;GACP,MAAM;EACR;EACA,SAAS;GACP,MAAM;GACN,aACE;GACF,MAAM;EACR;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"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import "./rolldown-runtime-C0LytTxp.js";
|
|
2
|
+
import { t as defineCommand } from "./defineCommand-DMEeqliP.js";
|
|
3
|
+
import { t as version } from "./package-6guIlMlB.js";
|
|
4
|
+
//#region src/commands/mcp.ts
|
|
5
|
+
const command = defineCommand({
|
|
6
|
+
name: "mcp",
|
|
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
|
+
examples: [
|
|
9
|
+
"kubb mcp",
|
|
10
|
+
"# Then add to your MCP client config:",
|
|
11
|
+
"# { \"mcpServers\": { \"kubb\": { \"command\": \"npx\", \"args\": [\"kubb\", \"mcp\"] } } }"
|
|
12
|
+
],
|
|
13
|
+
async run() {
|
|
14
|
+
const { run } = await import("./run-Dv-1NGl-.js");
|
|
15
|
+
await run({ version });
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
//#endregion
|
|
19
|
+
export { command };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=mcp---VI5xTX.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp---VI5xTX.js","names":[],"sources":["../src/commands/mcp.ts"],"sourcesContent":["import { defineCommand } from '@internals/utils'\nimport { version } from '../../package.json'\n\nexport const command = defineCommand({\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\"] } } }'],\n async run() {\n const { run } = await import('../runners/mcp/run.ts')\n\n await run({ version })\n },\n})\n"],"mappings":";;;;AAGA,MAAa,UAAU,cAAc;CACnC,MAAM;CACN,aACE;CACF,UAAU;EAAC;EAAY;EAAyC;CAA+E;CAC/I,MAAM,MAAM;EACV,MAAM,EAAE,QAAQ,MAAM,OAAO;EAE7B,MAAM,IAAI,EAAE,QAAQ,CAAC;CACvB;AACF,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
require("./rolldown-runtime-Bx3C2hgW.cjs");
|
|
2
|
+
const require_defineCommand = require("./defineCommand-Bo3yZTWI.cjs");
|
|
3
|
+
const require_package = require("./package-DnvclOkv.cjs");
|
|
4
|
+
//#region src/commands/mcp.ts
|
|
5
|
+
const command = require_defineCommand.defineCommand({
|
|
6
|
+
name: "mcp",
|
|
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
|
+
examples: [
|
|
9
|
+
"kubb mcp",
|
|
10
|
+
"# Then add to your MCP client config:",
|
|
11
|
+
"# { \"mcpServers\": { \"kubb\": { \"command\": \"npx\", \"args\": [\"kubb\", \"mcp\"] } } }"
|
|
12
|
+
],
|
|
13
|
+
async run() {
|
|
14
|
+
const { run } = await Promise.resolve().then(() => require("./run-GFI-E4ua.cjs"));
|
|
15
|
+
await run({ version: require_package.version });
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
//#endregion
|
|
19
|
+
exports.command = command;
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=mcp-CbM2iAFq.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-CbM2iAFq.cjs","names":["defineCommand"],"sources":["../src/commands/mcp.ts"],"sourcesContent":["import { defineCommand } from '@internals/utils'\nimport { version } from '../../package.json'\n\nexport const command = defineCommand({\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\"] } } }'],\n async run() {\n const { run } = await import('../runners/mcp/run.ts')\n\n await run({ version })\n },\n})\n"],"mappings":";;;;AAGA,MAAa,UAAUA,sBAAAA,cAAc;CACnC,MAAM;CACN,aACE;CACF,UAAU;EAAC;EAAY;EAAyC;CAA+E;CAC/I,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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-6guIlMlB.js","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region package.json
|
|
2
|
-
var version = "5.0.0-beta.
|
|
2
|
+
var version = "5.0.0-beta.76";
|
|
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-DnvclOkv.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-DnvclOkv.cjs","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}
|