@kubb/cli 5.0.0-beta.9 → 5.0.0-beta.91
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 +48 -79
- package/bin/kubb.js +9 -3
- package/dist/Telemetry-7z2tIqPm.js +282 -0
- package/dist/Telemetry-7z2tIqPm.js.map +1 -0
- package/dist/{telemetry-B2iWkY5e.cjs → Telemetry-xcWb-UWT.cjs} +167 -116
- package/dist/Telemetry-xcWb-UWT.cjs.map +1 -0
- package/dist/{errors-CINO1EIv.js → errors-CMvLO2NE.js} +3 -15
- package/dist/{errors-CINO1EIv.js.map → errors-CMvLO2NE.js.map} +1 -1
- package/dist/{errors-CLCjoSg0.cjs → errors-DNxBUo3k.cjs} +2 -20
- package/dist/{errors-CLCjoSg0.cjs.map → errors-DNxBUo3k.cjs.map} +1 -1
- package/dist/generate-C9fJvlhv.js +87 -0
- package/dist/generate-C9fJvlhv.js.map +1 -0
- package/dist/generate-CIVRaeeA.cjs +87 -0
- package/dist/generate-CIVRaeeA.cjs.map +1 -0
- package/dist/index.cjs +33 -261
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +34 -262
- package/dist/index.js.map +1 -1
- package/dist/{init-bKtEOvhK.cjs → init-BBmle7Oc.cjs} +12 -13
- package/dist/init-BBmle7Oc.cjs.map +1 -0
- package/dist/{init-DOSXtcyb.js → init-DXjubhO6.js} +13 -13
- package/dist/init-DXjubhO6.js.map +1 -0
- package/dist/mcp-DLKKD_8s.js +21 -0
- package/dist/mcp-DLKKD_8s.js.map +1 -0
- package/dist/mcp-Dzgpeor_.cjs +20 -0
- package/dist/mcp-Dzgpeor_.cjs.map +1 -0
- package/dist/{package-DHGhrRW-.cjs → package-Bsc6NeTU.cjs} +2 -2
- package/dist/package-Bsc6NeTU.cjs.map +1 -0
- package/dist/package-CaBsNdoM.js +6 -0
- package/dist/package-CaBsNdoM.js.map +1 -0
- package/dist/{chunk-BvFE5Tac.js → rolldown-runtime-C0LytTxp.js} +0 -1
- package/dist/run-BBS4Sc38.js +1256 -0
- package/dist/run-BBS4Sc38.js.map +1 -0
- package/dist/{run-YsoCk5we.cjs → run-BNOCBw2y.cjs} +152 -98
- package/dist/run-BNOCBw2y.cjs.map +1 -0
- package/dist/{run-CQbj3ley.cjs → run-BdtVrLKu.cjs} +9 -15
- package/dist/run-BdtVrLKu.cjs.map +1 -0
- package/dist/run-Bgn3IPJt.cjs +1259 -0
- package/dist/run-Bgn3IPJt.cjs.map +1 -0
- package/dist/{run-CF97BWVa.js → run-CINOocLR.js} +138 -84
- package/dist/run-CINOocLR.js.map +1 -0
- package/dist/{run-CCZ24VKk.js → run-CaOjZRiQ.js} +7 -13
- package/dist/run-CaOjZRiQ.js.map +1 -0
- package/dist/run-D2vd34xp.cjs +33 -0
- package/dist/run-D2vd34xp.cjs.map +1 -0
- package/dist/run-lgrTO14E.js +32 -0
- package/dist/run-lgrTO14E.js.map +1 -0
- package/dist/tools-B23ltmWP.js +152 -0
- package/dist/tools-B23ltmWP.js.map +1 -0
- package/dist/tools-CeIABV0T.cjs +175 -0
- package/dist/tools-CeIABV0T.cjs.map +1 -0
- package/dist/{validate-Bj8vbvPt.cjs → validate-DaxZu9c3.cjs} +9 -10
- package/dist/validate-DaxZu9c3.cjs.map +1 -0
- package/dist/{validate-bHUrnYBv.js → validate-ugxFStuH.js} +10 -10
- package/dist/validate-ugxFStuH.js.map +1 -0
- package/package.json +14 -28
- package/dist/agent-C5F4itrc.js +0 -68
- package/dist/agent-C5F4itrc.js.map +0 -1
- package/dist/agent-d-lmeOr1.cjs +0 -70
- package/dist/agent-d-lmeOr1.cjs.map +0 -1
- package/dist/constants-B2JTeRBb.js +0 -42
- package/dist/constants-B2JTeRBb.js.map +0 -1
- package/dist/constants-BINTA5VZ.cjs +0 -77
- package/dist/constants-BINTA5VZ.cjs.map +0 -1
- package/dist/constants-BYGmiFs0.cjs +0 -139
- package/dist/constants-BYGmiFs0.cjs.map +0 -1
- package/dist/constants-DSJ-Xrbv.js +0 -116
- package/dist/constants-DSJ-Xrbv.js.map +0 -1
- package/dist/define-Bdn8j5VM.cjs +0 -54
- package/dist/define-Bdn8j5VM.cjs.map +0 -1
- package/dist/define-m_fp-Aqm.js +0 -43
- package/dist/define-m_fp-Aqm.js.map +0 -1
- package/dist/generate-BhfRufgh.js +0 -72
- package/dist/generate-BhfRufgh.js.map +0 -1
- package/dist/generate-BvuSxNYj.cjs +0 -71
- package/dist/generate-BvuSxNYj.cjs.map +0 -1
- package/dist/init-DOSXtcyb.js.map +0 -1
- package/dist/init-bKtEOvhK.cjs.map +0 -1
- package/dist/mcp-CKkbG0kp.cjs +0 -39
- package/dist/mcp-CKkbG0kp.cjs.map +0 -1
- package/dist/mcp-DzOfqX_j.js +0 -39
- package/dist/mcp-DzOfqX_j.js.map +0 -1
- package/dist/package-BgAYWN7y.js +0 -6
- package/dist/package-BgAYWN7y.js.map +0 -1
- package/dist/package-DHGhrRW-.cjs.map +0 -1
- package/dist/run-BObDb2qe.cjs +0 -1741
- package/dist/run-BObDb2qe.cjs.map +0 -1
- package/dist/run-BzpYYOQs.js +0 -121
- package/dist/run-BzpYYOQs.js.map +0 -1
- package/dist/run-CCZ24VKk.js.map +0 -1
- package/dist/run-CF97BWVa.js.map +0 -1
- package/dist/run-CQbj3ley.cjs.map +0 -1
- package/dist/run-D0hmRpHy.js +0 -49
- package/dist/run-D0hmRpHy.js.map +0 -1
- package/dist/run-DwdAwnLG.cjs +0 -125
- package/dist/run-DwdAwnLG.cjs.map +0 -1
- package/dist/run-Lr0Ctnu0.cjs +0 -50
- package/dist/run-Lr0Ctnu0.cjs.map +0 -1
- package/dist/run-P6D8TnXf.js +0 -1738
- package/dist/run-P6D8TnXf.js.map +0 -1
- package/dist/run-YsoCk5we.cjs.map +0 -1
- package/dist/shell-475fQKaX.cjs +0 -62
- package/dist/shell-475fQKaX.cjs.map +0 -1
- package/dist/shell-CN6DNqeC.js +0 -51
- package/dist/shell-CN6DNqeC.js.map +0 -1
- package/dist/telemetry-B2iWkY5e.cjs.map +0 -1
- package/dist/telemetry-BkektVz6.js +0 -243
- package/dist/telemetry-BkektVz6.js.map +0 -1
- package/dist/validate-Bj8vbvPt.cjs.map +0 -1
- package/dist/validate-bHUrnYBv.js.map +0 -1
- package/src/commands/agent/start.ts +0 -50
- package/src/commands/agent.ts +0 -10
- package/src/commands/generate.ts +0 -59
- package/src/commands/init.ts +0 -51
- package/src/commands/mcp.ts +0 -36
- package/src/commands/validate.ts +0 -22
- package/src/constants.ts +0 -48
- package/src/index.ts +0 -45
- package/src/loggers/clackLogger.ts +0 -460
- package/src/loggers/fileSystemLogger.ts +0 -151
- package/src/loggers/githubActionsLogger.ts +0 -367
- package/src/loggers/plainLogger.ts +0 -243
- package/src/loggers/types.ts +0 -7
- package/src/loggers/utils.ts +0 -252
- package/src/runners/agent/run.ts +0 -113
- package/src/runners/agent/utils.ts +0 -98
- package/src/runners/generate/run.ts +0 -276
- package/src/runners/generate/utils.ts +0 -209
- package/src/runners/init/run.ts +0 -211
- package/src/runners/init/utils.ts +0 -33
- package/src/runners/mcp/run.ts +0 -55
- package/src/runners/validate/run.ts +0 -63
- package/src/telemetry.ts +0 -280
- /package/dist/{chunk-ByKO4r7w.cjs → rolldown-runtime-Bx3C2hgW.cjs} +0 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
require("./rolldown-runtime-Bx3C2hgW.cjs");
|
|
2
|
+
let gunshi = require("gunshi");
|
|
3
|
+
//#region src/commands/generate.ts
|
|
4
|
+
const REPORTER_NAMES = [
|
|
5
|
+
"cli",
|
|
6
|
+
"json",
|
|
7
|
+
"file"
|
|
8
|
+
];
|
|
9
|
+
/**
|
|
10
|
+
* Splits and validates the comma-separated `--reporter` value against the known reporter names.
|
|
11
|
+
*/
|
|
12
|
+
function parseReporters(value) {
|
|
13
|
+
const names = value.split(",").map((name) => name.trim()).filter(Boolean);
|
|
14
|
+
for (const name of names) if (!REPORTER_NAMES.includes(name)) throw new Error(`must be one of cli, json, file (got "${name}")`);
|
|
15
|
+
return names;
|
|
16
|
+
}
|
|
17
|
+
const command = (0, gunshi.define)({
|
|
18
|
+
name: "generate",
|
|
19
|
+
description: "Generate TypeScript types, API clients, React Query hooks, Zod schemas, and more from an OpenAPI specification. Reads kubb.config.ts by default. Pass an OpenAPI file path as the first argument to override the input without editing the config.",
|
|
20
|
+
examples: [
|
|
21
|
+
"kubb generate",
|
|
22
|
+
"kubb generate ./openapi.yaml",
|
|
23
|
+
"kubb generate --config kubb.config.ts",
|
|
24
|
+
"kubb generate --watch"
|
|
25
|
+
].join("\n"),
|
|
26
|
+
args: {
|
|
27
|
+
input: {
|
|
28
|
+
type: "positional",
|
|
29
|
+
required: false,
|
|
30
|
+
description: "Path to the OpenAPI specification, overriding the config"
|
|
31
|
+
},
|
|
32
|
+
config: {
|
|
33
|
+
type: "string",
|
|
34
|
+
description: "Path to the Kubb config",
|
|
35
|
+
short: "c"
|
|
36
|
+
},
|
|
37
|
+
logLevel: {
|
|
38
|
+
type: "enum",
|
|
39
|
+
choices: [
|
|
40
|
+
"silent",
|
|
41
|
+
"info",
|
|
42
|
+
"verbose"
|
|
43
|
+
],
|
|
44
|
+
description: "Info, silent or verbose",
|
|
45
|
+
short: "l",
|
|
46
|
+
default: "info"
|
|
47
|
+
},
|
|
48
|
+
watch: {
|
|
49
|
+
type: "boolean",
|
|
50
|
+
description: "Watch mode based on the input file",
|
|
51
|
+
short: "w",
|
|
52
|
+
default: false
|
|
53
|
+
},
|
|
54
|
+
verbose: {
|
|
55
|
+
type: "boolean",
|
|
56
|
+
description: "Override logLevel to verbose",
|
|
57
|
+
default: false
|
|
58
|
+
},
|
|
59
|
+
silent: {
|
|
60
|
+
type: "boolean",
|
|
61
|
+
description: "Override logLevel to silent",
|
|
62
|
+
short: "s",
|
|
63
|
+
default: false
|
|
64
|
+
},
|
|
65
|
+
reporter: {
|
|
66
|
+
type: "custom",
|
|
67
|
+
description: "Reporters that render the run, comma-separated. Overrides config.reporters",
|
|
68
|
+
metavar: "cli|json|file",
|
|
69
|
+
parse: parseReporters
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
async run({ values }) {
|
|
73
|
+
const logLevel = values.verbose ? "verbose" : values.silent ? "silent" : values.logLevel;
|
|
74
|
+
const { run } = await Promise.resolve().then(() => require("./run-Bgn3IPJt.cjs"));
|
|
75
|
+
await run({
|
|
76
|
+
input: values.input,
|
|
77
|
+
configPath: values.config,
|
|
78
|
+
logLevel,
|
|
79
|
+
watch: values.watch,
|
|
80
|
+
reporters: values.reporter
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
//#endregion
|
|
85
|
+
exports.command = command;
|
|
86
|
+
|
|
87
|
+
//# sourceMappingURL=generate-CIVRaeeA.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-CIVRaeeA.cjs","names":[],"sources":["../src/commands/generate.ts"],"sourcesContent":["import { define } from 'gunshi'\nimport type { ReporterName } from '@kubb/core'\n\nconst REPORTER_NAMES: Array<ReporterName> = ['cli', 'json', 'file']\n\n/**\n * Splits and validates the comma-separated `--reporter` value against the known reporter names.\n */\nfunction parseReporters(value: string): Array<ReporterName> {\n const names = value\n .split(',')\n .map((name) => name.trim())\n .filter(Boolean)\n\n for (const name of names) {\n if (!REPORTER_NAMES.includes(name as ReporterName)) {\n throw new Error(`must be one of cli, json, file (got \"${name}\")`)\n }\n }\n\n return names as Array<ReporterName>\n}\n\nexport const command = define({\n name: 'generate',\n description:\n 'Generate TypeScript types, API clients, React Query hooks, Zod schemas, and more from an OpenAPI specification. Reads kubb.config.ts by default. Pass an OpenAPI file path as the first argument to override the input without editing the config.',\n examples: ['kubb generate', 'kubb generate ./openapi.yaml', 'kubb generate --config kubb.config.ts', 'kubb generate --watch'].join('\\n'),\n args: {\n input: {\n type: 'positional',\n required: false,\n description: 'Path to the OpenAPI specification, overriding the config',\n },\n config: {\n type: 'string',\n description: 'Path to the Kubb config',\n short: 'c',\n },\n logLevel: {\n type: 'enum',\n choices: ['silent', 'info', 'verbose'] as const,\n description: 'Info, silent or verbose',\n short: 'l',\n default: 'info',\n },\n watch: {\n type: 'boolean',\n description: 'Watch mode based on the input file',\n short: 'w',\n default: false,\n },\n verbose: {\n type: 'boolean',\n description: 'Override logLevel to verbose',\n default: false,\n },\n silent: {\n type: 'boolean',\n description: 'Override logLevel to silent',\n short: 's',\n default: false,\n },\n reporter: {\n type: 'custom',\n description: 'Reporters that render the run, comma-separated. Overrides config.reporters',\n metavar: 'cli|json|file',\n parse: parseReporters,\n },\n },\n async run({ values }) {\n const logLevel = values.verbose ? 'verbose' : values.silent ? 'silent' : values.logLevel\n const { run } = await import('../runners/generate/run.ts')\n\n await run({\n input: values.input,\n configPath: values.config,\n logLevel,\n watch: values.watch,\n reporters: values.reporter,\n })\n },\n})\n"],"mappings":";;;AAGA,MAAM,iBAAsC;CAAC;CAAO;CAAQ;AAAM;;;;AAKlE,SAAS,eAAe,OAAoC;CAC1D,MAAM,QAAQ,MACX,MAAM,GAAG,CAAC,CACV,KAAK,SAAS,KAAK,KAAK,CAAC,CAAC,CAC1B,OAAO,OAAO;CAEjB,KAAK,MAAM,QAAQ,OACjB,IAAI,CAAC,eAAe,SAAS,IAAoB,GAC/C,MAAM,IAAI,MAAM,wCAAwC,KAAK,GAAG;CAIpE,OAAO;AACT;AAEA,MAAa,WAAA,GAAA,OAAA,OAAA,CAAiB;CAC5B,MAAM;CACN,aACE;CACF,UAAU;EAAC;EAAiB;EAAgC;EAAyC;CAAuB,CAAC,CAAC,KAAK,IAAI;CACvI,MAAM;EACJ,OAAO;GACL,MAAM;GACN,UAAU;GACV,aAAa;EACf;EACA,QAAQ;GACN,MAAM;GACN,aAAa;GACb,OAAO;EACT;EACA,UAAU;GACR,MAAM;GACN,SAAS;IAAC;IAAU;IAAQ;GAAS;GACrC,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,OAAO;GACL,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,SAAS;GACP,MAAM;GACN,aAAa;GACb,SAAS;EACX;EACA,QAAQ;GACN,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,UAAU;GACR,MAAM;GACN,aAAa;GACb,SAAS;GACT,OAAO;EACT;CACF;CACA,MAAM,IAAI,EAAE,UAAU;EACpB,MAAM,WAAW,OAAO,UAAU,YAAY,OAAO,SAAS,WAAW,OAAO;EAChF,MAAM,EAAE,QAAQ,MAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAM,oBAAA,CAAA;EAEtB,MAAM,IAAI;GACR,OAAO,OAAO;GACd,YAAY,OAAO;GACnB;GACA,OAAO,OAAO;GACd,WAAW,OAAO;EACpB,CAAC;CACH;AACF,CAAC"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,276 +1,48 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
require("./
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const require_package = require("./package-DHGhrRW-.cjs");
|
|
6
|
-
const require_constants = require("./constants-BINTA5VZ.cjs");
|
|
2
|
+
require("./rolldown-runtime-Bx3C2hgW.cjs");
|
|
3
|
+
const require_Telemetry = require("./Telemetry-xcWb-UWT.cjs");
|
|
4
|
+
const require_package = require("./package-Bsc6NeTU.cjs");
|
|
7
5
|
let node_util = require("node:util");
|
|
8
|
-
|
|
6
|
+
let gunshi = require("gunshi");
|
|
7
|
+
//#region src/index.ts
|
|
9
8
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```ts
|
|
15
|
-
* getCommandSchema([generateCommand, agentCommand])
|
|
16
|
-
* // [{ name: 'generate', options: [...], subCommands: [] }, ...]
|
|
17
|
-
* ```
|
|
9
|
+
* Strips the leading executable + script entries when `process.argv` is passed directly.
|
|
10
|
+
* Handles Node.js (`/usr/bin/node`), Bun (`/usr/local/bin/bun`), Deno, tsx, etc. All runtime
|
|
11
|
+
* executable paths contain a path separator; bare command names do not.
|
|
18
12
|
*/
|
|
19
|
-
function
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
function serializeCommand(def) {
|
|
23
|
-
return {
|
|
24
|
-
name: def.name,
|
|
25
|
-
description: def.description,
|
|
26
|
-
arguments: def.arguments,
|
|
27
|
-
...def.examples?.length ? { examples: def.examples } : {},
|
|
28
|
-
options: serializeOptions(def.options ?? {}),
|
|
29
|
-
subCommands: def.subCommands ? def.subCommands.map(serializeCommand) : []
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
function serializeOptions(options) {
|
|
33
|
-
return Object.entries(options).map(([name, opt]) => {
|
|
34
|
-
return {
|
|
35
|
-
name,
|
|
36
|
-
flags: `${opt.short ? `-${opt.short}, ` : ""}--${name}${opt.type === "string" ? ` <${opt.hint ?? name}>` : ""}`,
|
|
37
|
-
type: opt.type,
|
|
38
|
-
description: opt.description,
|
|
39
|
-
...opt.default !== void 0 ? { default: opt.default } : {},
|
|
40
|
-
...opt.hint ? { hint: opt.hint } : {},
|
|
41
|
-
...opt.enum ? { enum: opt.enum } : {},
|
|
42
|
-
...opt.required ? { required: opt.required } : {}
|
|
43
|
-
};
|
|
44
|
-
});
|
|
13
|
+
function stripExecArgs(argv) {
|
|
14
|
+
const firstArgIsExecutablePath = (argv[0]?.includes("/") || argv[0]?.includes("\\")) ?? false;
|
|
15
|
+
return argv.length >= 2 && firstArgIsExecutablePath ? argv.slice(2) : argv;
|
|
45
16
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
*
|
|
50
|
-
* @example
|
|
51
|
-
* ```ts
|
|
52
|
-
* renderHelp({ name: 'generate', description: 'Generate client code' })
|
|
53
|
-
* // prints Usage: generate [options] ...
|
|
54
|
-
* ```
|
|
17
|
+
/**
|
|
18
|
+
* Entry point for the `kubb` CLI. Prints the telemetry notice unless telemetry is disabled or a
|
|
19
|
+
* quiet flag is passed, then runs the generate, validate, mcp, and init commands. Defaults to
|
|
20
|
+
* `generate` when no command is given.
|
|
55
21
|
*/
|
|
56
|
-
function
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
const
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
if (schema.subCommands.length) {
|
|
64
|
-
console.log((0, node_util.styleText)("bold", "Commands:"));
|
|
65
|
-
for (const sub of schema.subCommands) console.log(` ${(0, node_util.styleText)("cyan", sub.name.padEnd(16))}${sub.description}`);
|
|
66
|
-
console.log();
|
|
67
|
-
}
|
|
68
|
-
const options = [...schema.options, {
|
|
69
|
-
name: "help",
|
|
70
|
-
flags: "-h, --help",
|
|
71
|
-
type: "boolean",
|
|
72
|
-
description: "Show help"
|
|
73
|
-
}];
|
|
74
|
-
console.log((0, node_util.styleText)("bold", "Options:"));
|
|
75
|
-
for (const opt of options) {
|
|
76
|
-
const flags = (0, node_util.styleText)("cyan", opt.flags.padEnd(30));
|
|
77
|
-
const defaultPart = opt.default !== void 0 ? (0, node_util.styleText)("dim", ` (default: ${opt.default})`) : "";
|
|
78
|
-
console.log(` ${flags}${opt.description}${defaultPart}`);
|
|
79
|
-
}
|
|
80
|
-
console.log();
|
|
81
|
-
if (schema.examples?.length) {
|
|
82
|
-
console.log((0, node_util.styleText)("bold", "Examples:"));
|
|
83
|
-
for (const ex of schema.examples) console.log(` ${(0, node_util.styleText)("dim", ex)}`);
|
|
84
|
-
console.log();
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
//#endregion
|
|
88
|
-
//#region ../../internals/utils/src/cli/adapters/nodeAdapter.ts
|
|
89
|
-
function buildParseOptions(def) {
|
|
90
|
-
const result = { help: {
|
|
91
|
-
type: "boolean",
|
|
92
|
-
short: "h"
|
|
93
|
-
} };
|
|
94
|
-
for (const [name, opt] of Object.entries(def.options ?? {})) result[name] = {
|
|
95
|
-
type: opt.type,
|
|
96
|
-
...opt.short ? { short: opt.short } : {},
|
|
97
|
-
...opt.default !== void 0 ? { default: opt.default } : {}
|
|
98
|
-
};
|
|
99
|
-
return result;
|
|
100
|
-
}
|
|
101
|
-
async function runCommand(def, argv, parentName) {
|
|
102
|
-
const parseOptions = buildParseOptions(def);
|
|
103
|
-
let parsed;
|
|
22
|
+
async function run(argv = process.argv) {
|
|
23
|
+
const isQuietFlag = argv.some((arg) => require_Telemetry.QUIET_FLAGS.has(arg));
|
|
24
|
+
if (!require_Telemetry.isDisabled() && !isQuietFlag) console.log(`${(0, node_util.styleText)("yellow", "Notice:")} Kubb collects anonymous telemetry data to help improve the tool. No personal data or file contents are collected. \nTo disable, set ${(0, node_util.styleText)("cyan", "KUBB_DISABLE_TELEMETRY=1")}.\n`);
|
|
25
|
+
const { command: generateCommand } = await Promise.resolve().then(() => require("./generate-CIVRaeeA.cjs"));
|
|
26
|
+
const { command: validateCommand } = await Promise.resolve().then(() => require("./validate-DaxZu9c3.cjs"));
|
|
27
|
+
const { command: mcpCommand } = await Promise.resolve().then(() => require("./mcp-Dzgpeor_.cjs"));
|
|
28
|
+
const { command: initCommand } = await Promise.resolve().then(() => require("./init-BBmle7Oc.cjs"));
|
|
104
29
|
try {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
30
|
+
await (0, gunshi.cli)(stripExecArgs(argv), generateCommand, {
|
|
31
|
+
name: "kubb",
|
|
32
|
+
version: require_package.version,
|
|
33
|
+
description: generateCommand.description,
|
|
34
|
+
subCommands: {
|
|
35
|
+
generate: generateCommand,
|
|
36
|
+
init: initCommand,
|
|
37
|
+
validate: validateCommand,
|
|
38
|
+
mcp: mcpCommand
|
|
39
|
+
},
|
|
40
|
+
fallbackToEntry: true
|
|
110
41
|
});
|
|
111
|
-
parsed = {
|
|
112
|
-
values: result.values,
|
|
113
|
-
positionals: result.positionals
|
|
114
|
-
};
|
|
115
42
|
} catch {
|
|
116
|
-
renderHelp(def, parentName);
|
|
117
|
-
process.exit(1);
|
|
118
|
-
}
|
|
119
|
-
if (parsed.values["help"]) {
|
|
120
|
-
renderHelp(def, parentName);
|
|
121
|
-
process.exit(0);
|
|
122
|
-
}
|
|
123
|
-
for (const [name, opt] of Object.entries(def.options ?? {})) if (opt.required && parsed.values[name] === void 0) {
|
|
124
|
-
console.error((0, node_util.styleText)("red", `Error: --${name} is required`));
|
|
125
|
-
renderHelp(def, parentName);
|
|
126
|
-
process.exit(1);
|
|
127
|
-
}
|
|
128
|
-
if (!def.run) {
|
|
129
|
-
renderHelp(def, parentName);
|
|
130
|
-
process.exit(0);
|
|
131
|
-
}
|
|
132
|
-
try {
|
|
133
|
-
await def.run(parsed);
|
|
134
|
-
} catch (err) {
|
|
135
|
-
console.error((0, node_util.styleText)("red", `Error: ${err instanceof Error ? err.message : String(err)}`));
|
|
136
|
-
renderHelp(def, parentName);
|
|
137
43
|
process.exit(1);
|
|
138
44
|
}
|
|
139
45
|
}
|
|
140
|
-
function printRootHelp(programName, version, defs) {
|
|
141
|
-
console.log(`\n${(0, node_util.styleText)("bold", "Usage:")} ${programName} <command> [options]\n`);
|
|
142
|
-
console.log(` Kubb v${version} — Generate TypeScript types, API clients, React Query hooks,`);
|
|
143
|
-
console.log(` Zod schemas, and more from an OpenAPI specification.\n`);
|
|
144
|
-
console.log(` Quick start: ${(0, node_util.styleText)("cyan", `${programName} init`)} to scaffold a config, then ${(0, node_util.styleText)("cyan", `${programName} generate`)} to run.\n`);
|
|
145
|
-
console.log((0, node_util.styleText)("bold", "Commands:"));
|
|
146
|
-
for (const def of defs) console.log(` ${(0, node_util.styleText)("cyan", def.name.padEnd(16))}${def.description}`);
|
|
147
|
-
console.log();
|
|
148
|
-
console.log((0, node_util.styleText)("bold", "Options:"));
|
|
149
|
-
console.log(` ${(0, node_util.styleText)("cyan", "-v, --version".padEnd(30))}Show version number`);
|
|
150
|
-
console.log(` ${(0, node_util.styleText)("cyan", "-h, --help".padEnd(30))}Show help`);
|
|
151
|
-
console.log();
|
|
152
|
-
console.log(`Run ${(0, node_util.styleText)("cyan", `${programName} <command> --help`)} for command-specific help.\n`);
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* CLI adapter using `node:util parseArgs`. No external dependencies.
|
|
156
|
-
*/
|
|
157
|
-
const nodeAdapter = require_define.defineCLIAdapter({
|
|
158
|
-
renderHelp(def, parentName) {
|
|
159
|
-
renderHelp(def, parentName);
|
|
160
|
-
},
|
|
161
|
-
async run(defs, argv, opts) {
|
|
162
|
-
const { programName, defaultCommandName, version } = opts;
|
|
163
|
-
const firstArgIsExecutablePath = (argv[0]?.includes("/") || argv[0]?.includes("\\")) ?? false;
|
|
164
|
-
const args = argv.length >= 2 && firstArgIsExecutablePath ? argv.slice(2) : argv;
|
|
165
|
-
if (args[0] === "--version" || args[0] === "-v") {
|
|
166
|
-
console.log(version);
|
|
167
|
-
process.exit(0);
|
|
168
|
-
}
|
|
169
|
-
if (args[0] === "--help" || args[0] === "-h") {
|
|
170
|
-
printRootHelp(programName, version, defs);
|
|
171
|
-
process.exit(0);
|
|
172
|
-
}
|
|
173
|
-
if (args.length === 0) {
|
|
174
|
-
const defaultDef = defs.find((d) => d.name === defaultCommandName);
|
|
175
|
-
if (defaultDef?.run) await runCommand(defaultDef, [], programName);
|
|
176
|
-
else printRootHelp(programName, version, defs);
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
const [first, ...rest] = args;
|
|
180
|
-
const isKnownSubcommand = defs.some((d) => d.name === first);
|
|
181
|
-
let def;
|
|
182
|
-
let commandArgv;
|
|
183
|
-
let parentName;
|
|
184
|
-
if (isKnownSubcommand) {
|
|
185
|
-
def = defs.find((d) => d.name === first);
|
|
186
|
-
commandArgv = rest;
|
|
187
|
-
parentName = programName;
|
|
188
|
-
} else {
|
|
189
|
-
def = defs.find((d) => d.name === defaultCommandName);
|
|
190
|
-
commandArgv = args;
|
|
191
|
-
parentName = programName;
|
|
192
|
-
}
|
|
193
|
-
if (!def) {
|
|
194
|
-
console.error(`Unknown command: ${first}`);
|
|
195
|
-
printRootHelp(programName, version, defs);
|
|
196
|
-
process.exit(1);
|
|
197
|
-
}
|
|
198
|
-
if (def.subCommands?.length) {
|
|
199
|
-
const [subName, ...subRest] = commandArgv;
|
|
200
|
-
const subDef = def.subCommands.find((s) => s.name === subName);
|
|
201
|
-
if (subName === "--help" || subName === "-h") {
|
|
202
|
-
renderHelp(def, parentName);
|
|
203
|
-
process.exit(0);
|
|
204
|
-
}
|
|
205
|
-
if (!subDef) {
|
|
206
|
-
renderHelp(def, parentName);
|
|
207
|
-
process.exit(subName ? 1 : 0);
|
|
208
|
-
}
|
|
209
|
-
await runCommand(subDef, subRest, `${parentName} ${def.name}`);
|
|
210
|
-
return;
|
|
211
|
-
}
|
|
212
|
-
await runCommand(def, commandArgv, parentName);
|
|
213
|
-
}
|
|
214
|
-
});
|
|
215
|
-
//#endregion
|
|
216
|
-
//#region ../../internals/utils/src/cli/parse.ts
|
|
217
|
-
/**
|
|
218
|
-
* Creates a CLI runner bound to a specific adapter.
|
|
219
|
-
*
|
|
220
|
-
* @default nodeAdapter (Node.js `node:util parseArgs`)
|
|
221
|
-
*
|
|
222
|
-
* @example
|
|
223
|
-
* ```ts
|
|
224
|
-
* await createCLI().run(commands, process.argv.slice(2), {
|
|
225
|
-
* programName: 'kubb',
|
|
226
|
-
* defaultCommandName: 'generate',
|
|
227
|
-
* version: '5.0.0',
|
|
228
|
-
* })
|
|
229
|
-
* ```
|
|
230
|
-
*/
|
|
231
|
-
function createCLI(options) {
|
|
232
|
-
const adapter = options?.adapter ?? nodeAdapter;
|
|
233
|
-
return { run(commands, argv, opts) {
|
|
234
|
-
return adapter.run(commands, argv, opts);
|
|
235
|
-
} };
|
|
236
|
-
}
|
|
237
|
-
//#endregion
|
|
238
|
-
//#region ../../internals/utils/src/isFlag.ts
|
|
239
|
-
/**
|
|
240
|
-
* Type guard that confirms `value` is a member of `set`. Avoids type assertions with `Set<T extends string>`.
|
|
241
|
-
*/
|
|
242
|
-
function isFlag(set, value) {
|
|
243
|
-
for (const flag of set) if (flag === value) return true;
|
|
244
|
-
return false;
|
|
245
|
-
}
|
|
246
|
-
//#endregion
|
|
247
|
-
//#region src/index.ts
|
|
248
|
-
const cli = createCLI();
|
|
249
|
-
function shouldShowTelemetryNotice(argv) {
|
|
250
|
-
if (require_telemetry.isTelemetryDisabled()) return false;
|
|
251
|
-
if (argv.some((arg) => isFlag(require_constants.QUIET_FLAGS, arg))) return false;
|
|
252
|
-
if (!process.stdout.isTTY) return false;
|
|
253
|
-
return true;
|
|
254
|
-
}
|
|
255
|
-
async function run(argv = process.argv) {
|
|
256
|
-
if (shouldShowTelemetryNotice(argv)) console.log(`${(0, node_util.styleText)("yellow", "Notice:")} Kubb collects anonymous telemetry data to help improve the tool. No personal data or file contents are collected. \nTo disable, set ${(0, node_util.styleText)("cyan", "KUBB_DISABLE_TELEMETRY=1")}.\n`);
|
|
257
|
-
const { command: generateCommand } = await Promise.resolve().then(() => require("./generate-BvuSxNYj.cjs"));
|
|
258
|
-
const { command: validateCommand } = await Promise.resolve().then(() => require("./validate-Bj8vbvPt.cjs"));
|
|
259
|
-
const { command: mcpCommand } = await Promise.resolve().then(() => require("./mcp-CKkbG0kp.cjs"));
|
|
260
|
-
const { command: agentCommand } = await Promise.resolve().then(() => require("./agent-d-lmeOr1.cjs"));
|
|
261
|
-
const { command: initCommand } = await Promise.resolve().then(() => require("./init-bKtEOvhK.cjs"));
|
|
262
|
-
await cli.run([
|
|
263
|
-
generateCommand,
|
|
264
|
-
validateCommand,
|
|
265
|
-
mcpCommand,
|
|
266
|
-
agentCommand,
|
|
267
|
-
initCommand
|
|
268
|
-
], argv, {
|
|
269
|
-
programName: "kubb",
|
|
270
|
-
defaultCommandName: "generate",
|
|
271
|
-
version: require_package.version
|
|
272
|
-
});
|
|
273
|
-
}
|
|
274
46
|
//#endregion
|
|
275
47
|
exports.run = run;
|
|
276
48
|
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["defineCLIAdapter","isTelemetryDisabled","QUIET_FLAGS"],"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","../../../internals/utils/src/isFlag.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 ...(def.examples?.length ? { examples: def.examples } : {}),\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 if (schema.examples?.length) {\n console.log(styleText('bold', 'Examples:'))\n for (const ex of schema.examples) {\n console.log(` ${styleText('dim', ex)}`)\n }\n console.log()\n }\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 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 * 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 // 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: 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, isFlag } from '@internals/utils'\nimport { version } from '../package.json'\nimport { QUIET_FLAGS } from './constants.ts'\nimport { isTelemetryDisabled } from './telemetry.ts'\n\nconst cli = createCLI()\n\nfunction shouldShowTelemetryNotice(argv: Array<string>): boolean {\n if (isTelemetryDisabled()) {\n return false\n }\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\n // Skip in non-interactive / scripting contexts\n if (!process.stdout.isTTY) {\n return false\n }\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;CAC3E,OAAO,KAAK,IAAI,iBAAiB;;AAGnC,SAAS,iBAAiB,KAAuC;CAC/D,OAAO;EACL,MAAM,IAAI;EACV,aAAa,IAAI;EACjB,WAAW,IAAI;EACf,GAAI,IAAI,UAAU,SAAS,EAAE,UAAU,IAAI,UAAU,GAAG,EAAE;EAC1D,SAAS,iBAAiB,IAAI,WAAW,EAAE,CAAC;EAC5C,aAAa,IAAI,cAAc,IAAI,YAAY,IAAI,iBAAiB,GAAG,EAAE;EAC1E;;AAGH,SAAS,iBAAiB,SAA2D;CACnF,OAAO,OAAO,QAAQ,QAAQ,CAAC,KAAK,CAAC,MAAM,SAAS;EAKlD,OAAO;GACL;GACA,OAAA,GANgB,IAAI,QAAQ,IAAI,IAAI,MAAM,MAAM,GAEvB,IAAI,OADb,IAAI,SAAS,WAAW,KAAK,IAAI,QAAQ,KAAK,KAAK;GAMnE,MAAM,IAAI;GACV,aAAa,IAAI;GACjB,GAAI,IAAI,YAAY,KAAA,IAAY,EAAE,SAAS,IAAI,SAAS,GAAG,EAAE;GAC7D,GAAI,IAAI,OAAO,EAAE,MAAM,IAAI,MAAM,GAAG,EAAE;GACtC,GAAI,IAAI,OAAO,EAAE,MAAM,IAAI,MAAM,GAAG,EAAE;GACtC,GAAI,IAAI,WAAW,EAAE,UAAU,IAAI,UAAU,GAAG,EAAE;GACnD;GACD;;;;;;;;;;;;AC/BJ,SAAgB,WAAW,KAAwB,YAA2B;CAC5E,MAAM,SAAS,iBAAiB,CAAC,IAAI,CAAC,CAAC;CAEvC,MAAM,cAAc,aAAa,GAAG,WAAW,GAAG,OAAO,SAAS,OAAO;CAEzE,MAAM,WAAW,OAAO,WAAW,SAAS,IAAI,OAAO,UAAU,KAAK,IAAI,KAAK;CAC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li } from 'gunshi'\nimport { isDisabled as isTelemetryDisabled } 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 (!isTelemetryDisabled() && !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 generate: generateCommand,\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,QAAQA,kBAAAA,YAAY,IAAI,GAAG,CAAC;CAE3D,IAAI,CAACC,kBAAAA,WAAoB,KAAK,CAAC,aAC7B,QAAQ,IACN,IAAA,GAAA,UAAA,UAAA,CAAa,UAAU,SAAS,EAAE,wIAAA,GAAA,UAAA,UAAA,CAAiJ,QAAQ,0BAA0B,EAAE,IACzN;CAGF,MAAM,EAAE,SAAS,oBAAoB,MAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAM,yBAAA,CAAA;CAC3C,MAAM,EAAE,SAAS,oBAAoB,MAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAM,yBAAA,CAAA;CAC3C,MAAM,EAAE,SAAS,eAAe,MAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAM,oBAAA,CAAA;CACtC,MAAM,EAAE,SAAS,gBAAgB,MAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAM,qBAAA,CAAA;CAEvC,IAAI;EACF,OAAA,GAAA,OAAA,IAAA,CAAU,cAAc,IAAI,GAAG,iBAAiB;GAC9C,MAAM;GACN,SAAA,gBAAA;GACA,aAAa,gBAAgB;GAC7B,aAAa;IACX,UAAU;IACV,MAAM;IACN,UAAU;IACV,KAAK;GACP;GACA,iBAAiB;EACnB,CAAC;CACH,QAAQ;EACN,QAAQ,KAAK,CAAC;CAChB;AACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import { t as __name } from "./
|
|
1
|
+
import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
|
|
2
2
|
|
|
3
3
|
//#region src/index.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Entry point for the `kubb` CLI. Prints the telemetry notice unless telemetry is disabled or a
|
|
6
|
+
* quiet flag is passed, then runs the generate, validate, mcp, and init commands. Defaults to
|
|
7
|
+
* `generate` when no command is given.
|
|
8
|
+
*/
|
|
4
9
|
declare function run(argv?: Array<string>): Promise<void>;
|
|
5
10
|
//#endregion
|
|
6
11
|
export { run };
|