@kubb/cli 5.0.0-beta.37 → 5.0.0-beta.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{agent-B8oJFhcN.js → agent-CLspGfSn.js} +4 -4
- package/dist/{agent-B8oJFhcN.js.map → agent-CLspGfSn.js.map} +1 -1
- package/dist/{agent-DtuTV_Qk.cjs → agent-RdNQgRXD.cjs} +4 -4
- package/dist/{agent-DtuTV_Qk.cjs.map → agent-RdNQgRXD.cjs.map} +1 -1
- package/dist/{constants-CYxk4aNm.js → constants-84a47qA-.js} +2 -6
- package/dist/constants-84a47qA-.js.map +1 -0
- package/dist/{constants-CAKUpLcQ.cjs → constants-BtmponZ3.cjs} +1 -11
- package/dist/constants-BtmponZ3.cjs.map +1 -0
- package/dist/{generate-BvaMqrBk.cjs → generate-DK1pLJMi.cjs} +3 -4
- package/dist/generate-DK1pLJMi.cjs.map +1 -0
- package/dist/{generate-CzTjeiji.js → generate-Db0pJmbG.js} +3 -4
- package/dist/{generate-CzTjeiji.js.map → generate-Db0pJmbG.js.map} +1 -1
- package/dist/index.cjs +9 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +9 -9
- package/dist/index.js.map +1 -1
- package/dist/{init-CaMeuE1-.js → init-DKMwmbmx.js} +2 -2
- package/dist/{init-CaMeuE1-.js.map → init-DKMwmbmx.js.map} +1 -1
- package/dist/{init-C59u3T68.cjs → init-D_MQBDVz.cjs} +2 -2
- package/dist/{init-C59u3T68.cjs.map → init-D_MQBDVz.cjs.map} +1 -1
- package/dist/{mcp-Ca3ZcpKB.js → mcp-DqNyN0cN.js} +3 -3
- package/dist/{mcp-Ca3ZcpKB.js.map → mcp-DqNyN0cN.js.map} +1 -1
- package/dist/{mcp-D4NMV9lk.cjs → mcp-DvEeDWlW.cjs} +3 -3
- package/dist/{mcp-D4NMV9lk.cjs.map → mcp-DvEeDWlW.cjs.map} +1 -1
- package/dist/package-C8u_WvqI.js +6 -0
- package/dist/package-C8u_WvqI.js.map +1 -0
- package/dist/{package-DQFf9DB2.cjs → package-CusjBrSS.cjs} +2 -2
- package/dist/package-CusjBrSS.cjs.map +1 -0
- package/dist/{run-DJxYClJV.js → run-BQ3Qj0xB.js} +4 -4
- package/dist/run-BQ3Qj0xB.js.map +1 -0
- package/dist/{run-BvXxelGR.js → run-BQzoaxjR.js} +3 -3
- package/dist/run-BQzoaxjR.js.map +1 -0
- package/dist/{run-Ca2h07rN.js → run-BabEDDqN.js} +130 -369
- package/dist/run-BabEDDqN.js.map +1 -0
- package/dist/{run-BFEK9md9.js → run-CGf0KEts.js} +3 -3
- package/dist/run-CGf0KEts.js.map +1 -0
- package/dist/{run-CK8Cvq6n.cjs → run-CJUmJcbC.cjs} +130 -369
- package/dist/run-CJUmJcbC.cjs.map +1 -0
- package/dist/{run-Bz9IFMWg.cjs → run-CkTpemme.cjs} +3 -3
- package/dist/run-CkTpemme.cjs.map +1 -0
- package/dist/{run-BQZyg7If.cjs → run-Cl4SrSob.cjs} +3 -3
- package/dist/run-Cl4SrSob.cjs.map +1 -0
- package/dist/{run-BFv6avA_.cjs → run-D-s2LdlW.cjs} +5 -5
- package/dist/run-D-s2LdlW.cjs.map +1 -0
- package/dist/{validate-B_wfDSHQ.cjs → validate-CkW_AKZp.cjs} +3 -3
- package/dist/{validate-B_wfDSHQ.cjs.map → validate-CkW_AKZp.cjs.map} +1 -1
- package/dist/{validate-BEEerg2-.js → validate-jRewvR0c.js} +3 -3
- package/dist/{validate-BEEerg2-.js.map → validate-jRewvR0c.js.map} +1 -1
- package/package.json +7 -7
- package/src/commands/generate.ts +2 -3
- package/src/constants.ts +0 -15
- package/src/index.ts +2 -2
- package/src/loggers/clackLogger.ts +4 -6
- package/src/loggers/githubActionsLogger.ts +3 -3
- package/src/loggers/plainLogger.ts +2 -3
- package/src/loggers/utils.ts +29 -28
- package/src/runners/agent/run.ts +2 -2
- package/src/runners/generate/run.ts +21 -17
- package/src/runners/generate/utils.ts +2 -2
- package/src/runners/mcp/run.ts +2 -2
- package/src/runners/validate/run.ts +2 -2
- package/dist/constants-CAKUpLcQ.cjs.map +0 -1
- package/dist/constants-CYxk4aNm.js.map +0 -1
- package/dist/generate-BvaMqrBk.cjs.map +0 -1
- package/dist/package-DQFf9DB2.cjs.map +0 -1
- package/dist/package-DUwUSFeL.js +0 -6
- package/dist/package-DUwUSFeL.js.map +0 -1
- package/dist/run-BFEK9md9.js.map +0 -1
- package/dist/run-BFv6avA_.cjs.map +0 -1
- package/dist/run-BQZyg7If.cjs.map +0 -1
- package/dist/run-BvXxelGR.js.map +0 -1
- package/dist/run-Bz9IFMWg.cjs.map +0 -1
- package/dist/run-CK8Cvq6n.cjs.map +0 -1
- package/dist/run-Ca2h07rN.js.map +0 -1
- package/dist/run-DJxYClJV.js.map +0 -1
- package/dist/telemetry-B80oJfxR.cjs +0 -280
- package/dist/telemetry-B80oJfxR.cjs.map +0 -1
- package/dist/telemetry-ueaMzs_c.js +0 -243
- package/dist/telemetry-ueaMzs_c.js.map +0 -1
- package/src/loggers/diagnostics.ts +0 -77
- package/src/reporters/cliReporter.ts +0 -89
- package/src/reporters/fileReporter.ts +0 -103
- package/src/reporters/jsonReporter.ts +0 -15
- package/src/reporters/report.ts +0 -84
- package/src/telemetry.ts +0 -280
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "./chunk-CRm0XQPb.js";
|
|
2
2
|
import { n as defineCommand } from "./define-DNG1U8ha.js";
|
|
3
|
-
import { t as version } from "./package-
|
|
4
|
-
import {
|
|
3
|
+
import { t as version } from "./package-C8u_WvqI.js";
|
|
4
|
+
import { i as agentDefaults } from "./constants-84a47qA-.js";
|
|
5
5
|
//#endregion
|
|
6
6
|
//#region src/commands/agent.ts
|
|
7
7
|
const command = defineCommand({
|
|
@@ -50,7 +50,7 @@ const command = defineCommand({
|
|
|
50
50
|
}
|
|
51
51
|
},
|
|
52
52
|
async run({ values }) {
|
|
53
|
-
const { run } = await import("./run-
|
|
53
|
+
const { run } = await import("./run-BQ3Qj0xB.js");
|
|
54
54
|
await run({
|
|
55
55
|
port: values.port !== void 0 ? values.port : void 0,
|
|
56
56
|
host: values.host,
|
|
@@ -65,4 +65,4 @@ const command = defineCommand({
|
|
|
65
65
|
//#endregion
|
|
66
66
|
export { command };
|
|
67
67
|
|
|
68
|
-
//# sourceMappingURL=agent-
|
|
68
|
+
//# sourceMappingURL=agent-CLspGfSn.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-
|
|
1
|
+
{"version":3,"file":"agent-CLspGfSn.js","names":["command","startCommand"],"sources":["../src/commands/agent/start.ts","../src/commands/agent.ts"],"sourcesContent":["import { defineCommand } from '@internals/utils'\nimport { version } from '../../../package.json'\nimport { agentDefaults } from '../../constants.ts'\n\nexport const command = defineCommand({\n name: 'start',\n description:\n 'Start the Kubb Agent HTTP server. Exposes a REST API that accepts a kubb.config.ts patch and returns generated code as a stream. Use --allow-write to also write files to disk.',\n examples: ['kubb agent start', 'kubb agent start --port 4000', 'kubb agent start --allow-write', 'kubb agent start --config ./kubb.config.ts --allow-all'],\n options: {\n config: {\n type: 'string',\n description: 'Path to the Kubb config file',\n short: 'c',\n },\n port: {\n type: 'string',\n description: 'Port the HTTP server listens on',\n short: 'p',\n default: agentDefaults.port,\n },\n host: {\n type: 'string',\n description: 'Hostname the HTTP server binds to',\n default: agentDefaults.host,\n },\n 'allow-write': {\n type: 'boolean',\n description: 'Write generated files to the filesystem. When omitted, output is streamed only and no files are written.',\n default: false,\n },\n 'allow-all': {\n type: 'boolean',\n description: 'Grant all permissions (implies --allow-write).',\n default: false,\n },\n },\n async run({ values }) {\n const { run } = await import('../../runners/agent/run.ts')\n\n await run({\n port: values.port !== undefined ? values.port : undefined,\n host: values.host,\n configPath: values.config,\n allowWrite: values['allow-write'],\n allowAll: values['allow-all'],\n version,\n })\n },\n})\n","import { defineCommand } from '@internals/utils'\nimport { command as startCommand } from './agent/start.ts'\n\nexport const command = defineCommand({\n name: 'agent',\n description:\n 'Manage the Kubb Agent — an HTTP server that lets AI agents trigger code generation programmatically via a REST API. Useful when an AI workflow needs to generate code without direct CLI access.',\n examples: ['kubb agent start', 'kubb agent start --port 4000 --allow-write', 'kubb agent start --config ./kubb.config.ts --allow-all'],\n subCommands: [startCommand],\n})\n"],"mappings":";;;;;;ACGA,MAAa,UAAU,cAAc;CACnC,MAAM;CACN,aACE;CACF,UAAU;EAAC;EAAoB;EAA8C;CAAwD;CACrI,aAAa,CDJQ,cAAc;EACnC,MAAM;EACN,aACE;EACF,UAAU;GAAC;GAAoB;GAAgC;GAAkC;EAAwD;EACzJ,SAAS;GACP,QAAQ;IACN,MAAM;IACN,aAAa;IACb,OAAO;GACT;GACA,MAAM;IACJ,MAAM;IACN,aAAa;IACb,OAAO;IACP,SAAS,cAAc;GACzB;GACA,MAAM;IACJ,MAAM;IACN,aAAa;IACb,SAAS,cAAc;GACzB;GACA,eAAe;IACb,MAAM;IACN,aAAa;IACb,SAAS;GACX;GACA,aAAa;IACX,MAAM;IACN,aAAa;IACb,SAAS;GACX;EACF;EACA,MAAM,IAAI,EAAE,UAAU;GACpB,MAAM,EAAE,QAAQ,MAAM,OAAO;GAE7B,MAAM,IAAI;IACR,MAAM,OAAO,SAAS,KAAA,IAAY,OAAO,OAAO,KAAA;IAChD,MAAM,OAAO;IACb,YAAY,OAAO;IACnB,YAAY,OAAO;IACnB,UAAU,OAAO;IACjB;GACF,CAAC;EACH;CACF,CCzCgBC,CAAY;AAC5B,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require("./chunk-Bx3C2hgW.cjs");
|
|
2
2
|
const require_define = require("./define-C4AB3POr.cjs");
|
|
3
|
-
const require_package = require("./package-
|
|
4
|
-
const require_constants = require("./constants-
|
|
3
|
+
const require_package = require("./package-CusjBrSS.cjs");
|
|
4
|
+
const require_constants = require("./constants-BtmponZ3.cjs");
|
|
5
5
|
//#region src/commands/agent/start.ts
|
|
6
6
|
const command$1 = require_define.defineCommand({
|
|
7
7
|
name: "start",
|
|
@@ -41,7 +41,7 @@ const command$1 = require_define.defineCommand({
|
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
43
|
async run({ values }) {
|
|
44
|
-
const { run } = await Promise.resolve().then(() => require("./run-
|
|
44
|
+
const { run } = await Promise.resolve().then(() => require("./run-D-s2LdlW.cjs"));
|
|
45
45
|
await run({
|
|
46
46
|
port: values.port !== void 0 ? values.port : void 0,
|
|
47
47
|
host: values.host,
|
|
@@ -67,4 +67,4 @@ const command = require_define.defineCommand({
|
|
|
67
67
|
//#endregion
|
|
68
68
|
exports.command = command;
|
|
69
69
|
|
|
70
|
-
//# sourceMappingURL=agent-
|
|
70
|
+
//# sourceMappingURL=agent-RdNQgRXD.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-
|
|
1
|
+
{"version":3,"file":"agent-RdNQgRXD.cjs","names":["command","defineCommand","agentDefaults","defineCommand","startCommand"],"sources":["../src/commands/agent/start.ts","../src/commands/agent.ts"],"sourcesContent":["import { defineCommand } from '@internals/utils'\nimport { version } from '../../../package.json'\nimport { agentDefaults } from '../../constants.ts'\n\nexport const command = defineCommand({\n name: 'start',\n description:\n 'Start the Kubb Agent HTTP server. Exposes a REST API that accepts a kubb.config.ts patch and returns generated code as a stream. Use --allow-write to also write files to disk.',\n examples: ['kubb agent start', 'kubb agent start --port 4000', 'kubb agent start --allow-write', 'kubb agent start --config ./kubb.config.ts --allow-all'],\n options: {\n config: {\n type: 'string',\n description: 'Path to the Kubb config file',\n short: 'c',\n },\n port: {\n type: 'string',\n description: 'Port the HTTP server listens on',\n short: 'p',\n default: agentDefaults.port,\n },\n host: {\n type: 'string',\n description: 'Hostname the HTTP server binds to',\n default: agentDefaults.host,\n },\n 'allow-write': {\n type: 'boolean',\n description: 'Write generated files to the filesystem. When omitted, output is streamed only and no files are written.',\n default: false,\n },\n 'allow-all': {\n type: 'boolean',\n description: 'Grant all permissions (implies --allow-write).',\n default: false,\n },\n },\n async run({ values }) {\n const { run } = await import('../../runners/agent/run.ts')\n\n await run({\n port: values.port !== undefined ? values.port : undefined,\n host: values.host,\n configPath: values.config,\n allowWrite: values['allow-write'],\n allowAll: values['allow-all'],\n version,\n })\n },\n})\n","import { defineCommand } from '@internals/utils'\nimport { command as startCommand } from './agent/start.ts'\n\nexport const command = defineCommand({\n name: 'agent',\n description:\n 'Manage the Kubb Agent — an HTTP server that lets AI agents trigger code generation programmatically via a REST API. Useful when an AI workflow needs to generate code without direct CLI access.',\n examples: ['kubb agent start', 'kubb agent start --port 4000 --allow-write', 'kubb agent start --config ./kubb.config.ts --allow-all'],\n subCommands: [startCommand],\n})\n"],"mappings":";;;;;AAIA,MAAaA,YAAUC,eAAAA,cAAc;CACnC,MAAM;CACN,aACE;CACF,UAAU;EAAC;EAAoB;EAAgC;EAAkC;CAAwD;CACzJ,SAAS;EACP,QAAQ;GACN,MAAM;GACN,aAAa;GACb,OAAO;EACT;EACA,MAAM;GACJ,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAASC,kBAAAA,cAAc;EACzB;EACA,MAAM;GACJ,MAAM;GACN,aAAa;GACb,SAASA,kBAAAA,cAAc;EACzB;EACA,eAAe;GACb,MAAM;GACN,aAAa;GACb,SAAS;EACX;EACA,aAAa;GACX,MAAM;GACN,aAAa;GACb,SAAS;EACX;CACF;CACA,MAAM,IAAI,EAAE,UAAU;EACpB,MAAM,EAAE,QAAQ,MAAA,QAAA,QAAA,EAAA,WAAA,QAAM,oBAAA,CAAA;EAEtB,MAAM,IAAI;GACR,MAAM,OAAO,SAAS,KAAA,IAAY,OAAO,OAAO,KAAA;GAChD,MAAM,OAAO;GACb,YAAY,OAAO;GACnB,YAAY,OAAO;GACnB,UAAU,OAAO;GACjB,SAAA,gBAAA;EACF,CAAC;CACH;AACF,CAAC;;;AC9CD,MAAa,UAAUC,eAAAA,cAAc;CACnC,MAAM;CACN,aACE;CACF,UAAU;EAAC;EAAoB;EAA8C;CAAwD;CACrI,aAAa,CAACC,SAAY;AAC5B,CAAC"}
|
|
@@ -4,10 +4,6 @@ import { t as KUBB_CONFIG_FILENAME } from "./constants-C94RKp3A.js";
|
|
|
4
4
|
* NPM registry endpoint used to check for @kubb/cli updates.
|
|
5
5
|
*/
|
|
6
6
|
const KUBB_NPM_PACKAGE_URL = "https://registry.npmjs.org/@kubb/cli/latest";
|
|
7
|
-
/**
|
|
8
|
-
* OpenTelemetry ingestion endpoint for anonymous usage telemetry.
|
|
9
|
-
*/
|
|
10
|
-
const OTLP_ENDPOINT = "https://otlp.kubb.dev";
|
|
11
7
|
"─".repeat(27);
|
|
12
8
|
/**
|
|
13
9
|
* Glob pattern for paths the file watcher ignores.
|
|
@@ -34,6 +30,6 @@ const agentDefaults = {
|
|
|
34
30
|
serverEntryPath: ".output/server/index.mjs"
|
|
35
31
|
};
|
|
36
32
|
//#endregion
|
|
37
|
-
export { agentDefaults as
|
|
33
|
+
export { agentDefaults as i, QUIET_FLAGS as n, WATCHER_IGNORED_PATHS as r, KUBB_NPM_PACKAGE_URL as t };
|
|
38
34
|
|
|
39
|
-
//# sourceMappingURL=constants-
|
|
35
|
+
//# sourceMappingURL=constants-84a47qA-.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants-84a47qA-.js","names":[],"sources":["../src/constants.ts"],"sourcesContent":["import { KUBB_CONFIG_FILENAME } from '@internals/shared'\n\n/**\n * NPM registry endpoint used to check for @kubb/cli updates.\n */\nexport const KUBB_NPM_PACKAGE_URL = 'https://registry.npmjs.org/@kubb/cli/latest' as const\n\n/**\n * Horizontal rule rendered above/below the plain-logger generation summary.\n */\nexport const SUMMARY_SEPARATOR = '─'.repeat(27)\n\n/**\n * Glob pattern for paths the file watcher ignores.\n */\nexport const WATCHER_IGNORED_PATHS = '**/{.git,node_modules}/**' as const\n\n/**\n * Flags that short-circuit execution (help/version), no telemetry notice is shown.\n */\nexport const QUIET_FLAGS = new Set(['--help', '-h', '--version', '-v'] as const)\n\nexport const agentDefaults = {\n port: '3000',\n host: 'localhost',\n configFile: KUBB_CONFIG_FILENAME,\n retryTimeout: '30000',\n studioUrl: 'https://kubb.studio',\n /**\n * Relative path from the @kubb/agent package root to the server entry.\n */\n serverEntryPath: '.output/server/index.mjs',\n} as const\n"],"mappings":";;;;;AAKA,MAAa,uBAAuB;AAKH,IAAI,OAAO,EAAE;;;;AAK9C,MAAa,wBAAwB;;;;AAKrC,MAAa,cAAc,IAAI,IAAI;CAAC;CAAU;CAAM;CAAa;AAAI,CAAU;AAE/E,MAAa,gBAAgB;CAC3B,MAAM;CACN,MAAM;CACN,YAAY;CACZ,cAAc;CACd,WAAW;;;;CAIX,iBAAiB;AACnB"}
|
|
@@ -4,10 +4,6 @@ const require_constants = require("./constants-AHhyFH15.cjs");
|
|
|
4
4
|
* NPM registry endpoint used to check for @kubb/cli updates.
|
|
5
5
|
*/
|
|
6
6
|
const KUBB_NPM_PACKAGE_URL = "https://registry.npmjs.org/@kubb/cli/latest";
|
|
7
|
-
/**
|
|
8
|
-
* OpenTelemetry ingestion endpoint for anonymous usage telemetry.
|
|
9
|
-
*/
|
|
10
|
-
const OTLP_ENDPOINT = "https://otlp.kubb.dev";
|
|
11
7
|
"─".repeat(27);
|
|
12
8
|
/**
|
|
13
9
|
* Glob pattern for paths the file watcher ignores.
|
|
@@ -40,12 +36,6 @@ Object.defineProperty(exports, "KUBB_NPM_PACKAGE_URL", {
|
|
|
40
36
|
return KUBB_NPM_PACKAGE_URL;
|
|
41
37
|
}
|
|
42
38
|
});
|
|
43
|
-
Object.defineProperty(exports, "OTLP_ENDPOINT", {
|
|
44
|
-
enumerable: true,
|
|
45
|
-
get: function() {
|
|
46
|
-
return OTLP_ENDPOINT;
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
39
|
Object.defineProperty(exports, "QUIET_FLAGS", {
|
|
50
40
|
enumerable: true,
|
|
51
41
|
get: function() {
|
|
@@ -65,4 +55,4 @@ Object.defineProperty(exports, "agentDefaults", {
|
|
|
65
55
|
}
|
|
66
56
|
});
|
|
67
57
|
|
|
68
|
-
//# sourceMappingURL=constants-
|
|
58
|
+
//# sourceMappingURL=constants-BtmponZ3.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants-BtmponZ3.cjs","names":["KUBB_CONFIG_FILENAME"],"sources":["../src/constants.ts"],"sourcesContent":["import { KUBB_CONFIG_FILENAME } from '@internals/shared'\n\n/**\n * NPM registry endpoint used to check for @kubb/cli updates.\n */\nexport const KUBB_NPM_PACKAGE_URL = 'https://registry.npmjs.org/@kubb/cli/latest' as const\n\n/**\n * Horizontal rule rendered above/below the plain-logger generation summary.\n */\nexport const SUMMARY_SEPARATOR = '─'.repeat(27)\n\n/**\n * Glob pattern for paths the file watcher ignores.\n */\nexport const WATCHER_IGNORED_PATHS = '**/{.git,node_modules}/**' as const\n\n/**\n * Flags that short-circuit execution (help/version), no telemetry notice is shown.\n */\nexport const QUIET_FLAGS = new Set(['--help', '-h', '--version', '-v'] as const)\n\nexport const agentDefaults = {\n port: '3000',\n host: 'localhost',\n configFile: KUBB_CONFIG_FILENAME,\n retryTimeout: '30000',\n studioUrl: 'https://kubb.studio',\n /**\n * Relative path from the @kubb/agent package root to the server entry.\n */\n serverEntryPath: '.output/server/index.mjs',\n} as const\n"],"mappings":";;;;;AAKA,MAAa,uBAAuB;AAKH,IAAI,OAAO,EAAE;;;;AAK9C,MAAa,wBAAwB;;;;AAKrC,MAAa,cAAc,IAAI,IAAI;CAAC;CAAU;CAAM;CAAa;AAAI,CAAU;AAE/E,MAAa,gBAAgB;CAC3B,MAAM;CACN,MAAM;CACN,YAAYA,kBAAAA;CACZ,cAAc;CACd,WAAW;;;;CAIX,iBAAiB;AACnB"}
|
|
@@ -49,7 +49,6 @@ const command = require("./define-C4AB3POr.cjs").defineCommand({
|
|
|
49
49
|
reporter: {
|
|
50
50
|
type: "string",
|
|
51
51
|
description: "Reporters that render the run, comma-separated. Overrides config.reporters",
|
|
52
|
-
default: "cli",
|
|
53
52
|
hint: "cli|json|file",
|
|
54
53
|
enum: [
|
|
55
54
|
"cli",
|
|
@@ -60,8 +59,8 @@ const command = require("./define-C4AB3POr.cjs").defineCommand({
|
|
|
60
59
|
},
|
|
61
60
|
async run({ values, positionals }) {
|
|
62
61
|
const logLevel = values.verbose ? "verbose" : values.silent ? "silent" : values.logLevel;
|
|
63
|
-
const reporters = values.reporter
|
|
64
|
-
const { run } = await Promise.resolve().then(() => require("./run-
|
|
62
|
+
const reporters = values.reporter?.split(",").map((name) => name.trim()).filter(Boolean);
|
|
63
|
+
const { run } = await Promise.resolve().then(() => require("./run-CJUmJcbC.cjs"));
|
|
65
64
|
await run({
|
|
66
65
|
input: positionals[0],
|
|
67
66
|
configPath: values.config,
|
|
@@ -74,4 +73,4 @@ const command = require("./define-C4AB3POr.cjs").defineCommand({
|
|
|
74
73
|
//#endregion
|
|
75
74
|
exports.command = command;
|
|
76
75
|
|
|
77
|
-
//# sourceMappingURL=generate-
|
|
76
|
+
//# sourceMappingURL=generate-DK1pLJMi.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-DK1pLJMi.cjs","names":["defineCommand"],"sources":["../src/commands/generate.ts"],"sourcesContent":["import { defineCommand } from '@internals/utils'\nimport type { ReporterName } from '@kubb/core'\n\nexport const command = defineCommand({\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 arguments: ['[input]'],\n examples: ['kubb generate', 'kubb generate ./openapi.yaml', 'kubb generate --config kubb.config.ts', 'kubb generate --watch'],\n options: {\n config: {\n type: 'string',\n description: 'Path to the Kubb config',\n short: 'c',\n },\n logLevel: {\n type: 'string',\n description: 'Info, silent or verbose',\n short: 'l',\n default: 'info',\n hint: 'silent|info|verbose',\n enum: ['silent', 'info', 'verbose'],\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 short: 'v',\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: 'string',\n description: 'Reporters that render the run, comma-separated. Overrides config.reporters',\n hint: 'cli|json|file',\n enum: ['cli', 'json', 'file'],\n },\n },\n async run({ values, positionals }) {\n const logLevel = values.verbose ? 'verbose' : values.silent ? 'silent' : values.logLevel\n const reporters = values.reporter\n ?.split(',')\n .map((name) => name.trim())\n .filter(Boolean) as Array<ReporterName> | undefined\n const { run } = await import('../runners/generate/run.ts')\n\n await run({\n input: positionals[0],\n configPath: values.config,\n logLevel,\n watch: values.watch,\n reporters,\n })\n },\n})\n"],"mappings":";;AAGA,MAAa,yCAAUA,EAAAA,cAAc;CACnC,MAAM;CACN,aACE;CACF,WAAW,CAAC,SAAS;CACrB,UAAU;EAAC;EAAiB;EAAgC;EAAyC;CAAuB;CAC5H,SAAS;EACP,QAAQ;GACN,MAAM;GACN,aAAa;GACb,OAAO;EACT;EACA,UAAU;GACR,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;GACT,MAAM;GACN,MAAM;IAAC;IAAU;IAAQ;GAAS;EACpC;EACA,OAAO;GACL,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,SAAS;GACP,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,QAAQ;GACN,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,UAAU;GACR,MAAM;GACN,aAAa;GACb,MAAM;GACN,MAAM;IAAC;IAAO;IAAQ;GAAM;EAC9B;CACF;CACA,MAAM,IAAI,EAAE,QAAQ,eAAe;EACjC,MAAM,WAAW,OAAO,UAAU,YAAY,OAAO,SAAS,WAAW,OAAO;EAChF,MAAM,YAAY,OAAO,UACrB,MAAM,GAAG,EACV,KAAK,SAAS,KAAK,KAAK,CAAC,EACzB,OAAO,OAAO;EACjB,MAAM,EAAE,QAAQ,MAAA,QAAA,QAAA,EAAA,WAAA,QAAM,oBAAA,CAAA;EAEtB,MAAM,IAAI;GACR,OAAO,YAAY;GACnB,YAAY,OAAO;GACnB;GACA,OAAO,OAAO;GACd;EACF,CAAC;CACH;AACF,CAAC"}
|
|
@@ -50,7 +50,6 @@ const command = defineCommand({
|
|
|
50
50
|
reporter: {
|
|
51
51
|
type: "string",
|
|
52
52
|
description: "Reporters that render the run, comma-separated. Overrides config.reporters",
|
|
53
|
-
default: "cli",
|
|
54
53
|
hint: "cli|json|file",
|
|
55
54
|
enum: [
|
|
56
55
|
"cli",
|
|
@@ -61,8 +60,8 @@ const command = defineCommand({
|
|
|
61
60
|
},
|
|
62
61
|
async run({ values, positionals }) {
|
|
63
62
|
const logLevel = values.verbose ? "verbose" : values.silent ? "silent" : values.logLevel;
|
|
64
|
-
const reporters = values.reporter
|
|
65
|
-
const { run } = await import("./run-
|
|
63
|
+
const reporters = values.reporter?.split(",").map((name) => name.trim()).filter(Boolean);
|
|
64
|
+
const { run } = await import("./run-BabEDDqN.js");
|
|
66
65
|
await run({
|
|
67
66
|
input: positionals[0],
|
|
68
67
|
configPath: values.config,
|
|
@@ -75,4 +74,4 @@ const command = defineCommand({
|
|
|
75
74
|
//#endregion
|
|
76
75
|
export { command };
|
|
77
76
|
|
|
78
|
-
//# sourceMappingURL=generate-
|
|
77
|
+
//# sourceMappingURL=generate-Db0pJmbG.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-
|
|
1
|
+
{"version":3,"file":"generate-Db0pJmbG.js","names":[],"sources":["../src/commands/generate.ts"],"sourcesContent":["import { defineCommand } from '@internals/utils'\nimport type { ReporterName } from '@kubb/core'\n\nexport const command = defineCommand({\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 arguments: ['[input]'],\n examples: ['kubb generate', 'kubb generate ./openapi.yaml', 'kubb generate --config kubb.config.ts', 'kubb generate --watch'],\n options: {\n config: {\n type: 'string',\n description: 'Path to the Kubb config',\n short: 'c',\n },\n logLevel: {\n type: 'string',\n description: 'Info, silent or verbose',\n short: 'l',\n default: 'info',\n hint: 'silent|info|verbose',\n enum: ['silent', 'info', 'verbose'],\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 short: 'v',\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: 'string',\n description: 'Reporters that render the run, comma-separated. Overrides config.reporters',\n hint: 'cli|json|file',\n enum: ['cli', 'json', 'file'],\n },\n },\n async run({ values, positionals }) {\n const logLevel = values.verbose ? 'verbose' : values.silent ? 'silent' : values.logLevel\n const reporters = values.reporter\n ?.split(',')\n .map((name) => name.trim())\n .filter(Boolean) as Array<ReporterName> | undefined\n const { run } = await import('../runners/generate/run.ts')\n\n await run({\n input: positionals[0],\n configPath: values.config,\n logLevel,\n watch: values.watch,\n reporters,\n })\n },\n})\n"],"mappings":";;;AAGA,MAAa,UAAU,cAAc;CACnC,MAAM;CACN,aACE;CACF,WAAW,CAAC,SAAS;CACrB,UAAU;EAAC;EAAiB;EAAgC;EAAyC;CAAuB;CAC5H,SAAS;EACP,QAAQ;GACN,MAAM;GACN,aAAa;GACb,OAAO;EACT;EACA,UAAU;GACR,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;GACT,MAAM;GACN,MAAM;IAAC;IAAU;IAAQ;GAAS;EACpC;EACA,OAAO;GACL,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,SAAS;GACP,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,QAAQ;GACN,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,UAAU;GACR,MAAM;GACN,aAAa;GACb,MAAM;GACN,MAAM;IAAC;IAAO;IAAQ;GAAM;EAC9B;CACF;CACA,MAAM,IAAI,EAAE,QAAQ,eAAe;EACjC,MAAM,WAAW,OAAO,UAAU,YAAY,OAAO,SAAS,WAAW,OAAO;EAChF,MAAM,YAAY,OAAO,UACrB,MAAM,GAAG,EACV,KAAK,SAAS,KAAK,KAAK,CAAC,EACzB,OAAO,OAAO;EACjB,MAAM,EAAE,QAAQ,MAAM,OAAO;EAE7B,MAAM,IAAI;GACR,OAAO,YAAY;GACnB,YAAY,OAAO;GACnB;GACA,OAAO,OAAO;GACd;EACF,CAAC;CACH;AACF,CAAC"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
require("./chunk-Bx3C2hgW.cjs");
|
|
3
3
|
const require_define = require("./define-C4AB3POr.cjs");
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const require_constants = require("./constants-CAKUpLcQ.cjs");
|
|
4
|
+
const require_package = require("./package-CusjBrSS.cjs");
|
|
5
|
+
const require_constants = require("./constants-BtmponZ3.cjs");
|
|
7
6
|
let node_util = require("node:util");
|
|
7
|
+
let _kubb_core = require("@kubb/core");
|
|
8
8
|
//#region ../../internals/utils/src/cli/schema.ts
|
|
9
9
|
/**
|
|
10
10
|
* Serializes `CommandDefinition[]` to a plain, JSON-serializable structure.
|
|
@@ -247,18 +247,18 @@ function isFlag(set, value) {
|
|
|
247
247
|
//#region src/index.ts
|
|
248
248
|
const cli = createCLI();
|
|
249
249
|
function shouldShowTelemetryNotice(argv) {
|
|
250
|
-
if (
|
|
250
|
+
if (_kubb_core.Telemetry.isDisabled()) return false;
|
|
251
251
|
if (argv.some((arg) => isFlag(require_constants.QUIET_FLAGS, arg))) return false;
|
|
252
252
|
if (!process.stdout.isTTY) return false;
|
|
253
253
|
return true;
|
|
254
254
|
}
|
|
255
255
|
async function run(argv = process.argv) {
|
|
256
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-
|
|
258
|
-
const { command: validateCommand } = await Promise.resolve().then(() => require("./validate-
|
|
259
|
-
const { command: mcpCommand } = await Promise.resolve().then(() => require("./mcp-
|
|
260
|
-
const { command: agentCommand } = await Promise.resolve().then(() => require("./agent-
|
|
261
|
-
const { command: initCommand } = await Promise.resolve().then(() => require("./init-
|
|
257
|
+
const { command: generateCommand } = await Promise.resolve().then(() => require("./generate-DK1pLJMi.cjs"));
|
|
258
|
+
const { command: validateCommand } = await Promise.resolve().then(() => require("./validate-CkW_AKZp.cjs"));
|
|
259
|
+
const { command: mcpCommand } = await Promise.resolve().then(() => require("./mcp-DvEeDWlW.cjs"));
|
|
260
|
+
const { command: agentCommand } = await Promise.resolve().then(() => require("./agent-RdNQgRXD.cjs"));
|
|
261
|
+
const { command: initCommand } = await Promise.resolve().then(() => require("./init-D_MQBDVz.cjs"));
|
|
262
262
|
await cli.run([
|
|
263
263
|
generateCommand,
|
|
264
264
|
validateCommand,
|
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,gBAAgB;AAClC;AAEA,SAAS,iBAAiB,KAAuC;CAC/D,OAAO;EACL,MAAM,IAAI;EACV,aAAa,IAAI;EACjB,WAAW,IAAI;EACf,GAAI,IAAI,UAAU,SAAS,EAAE,UAAU,IAAI,SAAS,IAAI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8B;CAC/D,IAAIC,kBAAAA,oBAAoB,GACtB,OAAO;CAIT,IAAI,KAAK,MAAM,QAAQ,OAAOC,kBAAAA,aAAa,GAAG,CAAC,GAC7C,OAAO;CAIT,IAAI,CAAC,QAAQ,OAAO,OAClB,OAAO;CAGT,OAAO;AACT;AAEA,eAAsB,IAAI,OAAsB,QAAQ,MAAqB;CAC3E,IAAI,0BAA0B,IAAI,GAChC,QAAQ,IACN,IAAA,GAAA,UAAA,WAAa,UAAU,SAAS,EAAE,wIAAA,GAAA,UAAA,WAAiJ,QAAQ,0BAA0B,EAAE,IACzN;CAGF,MAAM,EAAE,SAAS,oBAAoB,MAAA,QAAA,QAAA,EAAA,WAAA,QAAM,yBAAA,CAAA;CAC3C,MAAM,EAAE,SAAS,oBAAoB,MAAA,QAAA,QAAA,EAAA,WAAA,QAAM,yBAAA,CAAA;CAC3C,MAAM,EAAE,SAAS,eAAe,MAAA,QAAA,QAAA,EAAA,WAAA,QAAM,oBAAA,CAAA;CACtC,MAAM,EAAE,SAAS,iBAAiB,MAAA,QAAA,QAAA,EAAA,WAAA,QAAM,sBAAA,CAAA;CACxC,MAAM,EAAE,SAAS,gBAAgB,MAAA,QAAA,QAAA,EAAA,WAAA,QAAM,qBAAA,CAAA;CAEvC,MAAM,IAAI,IAAI;EAAC;EAAiB;EAAiB;EAAY;EAAc;CAAW,GAAG,MAAM;EAC7F,aAAa;EACb,oBAAoB;EACpB,SAAA,gBAAA;CACF,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["defineCLIAdapter","Telemetry","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 { Telemetry } from '@kubb/core'\nimport { version } from '../package.json'\nimport { QUIET_FLAGS } from './constants.ts'\n\nconst cli = createCLI()\n\nfunction shouldShowTelemetryNotice(argv: Array<string>): boolean {\n if (Telemetry.isDisabled()) {\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,gBAAgB;AAClC;AAEA,SAAS,iBAAiB,KAAuC;CAC/D,OAAO;EACL,MAAM,IAAI;EACV,aAAa,IAAI;EACjB,WAAW,IAAI;EACf,GAAI,IAAI,UAAU,SAAS,EAAE,UAAU,IAAI,SAAS,IAAI,CAAC;EACzD,SAAS,iBAAiB,IA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,WAAW,GACvB,OAAO;CAIT,IAAI,KAAK,MAAM,QAAQ,OAAOC,kBAAAA,aAAa,GAAG,CAAC,GAC7C,OAAO;CAIT,IAAI,CAAC,QAAQ,OAAO,OAClB,OAAO;CAGT,OAAO;AACT;AAEA,eAAsB,IAAI,OAAsB,QAAQ,MAAqB;CAC3E,IAAI,0BAA0B,IAAI,GAChC,QAAQ,IACN,IAAA,GAAA,UAAA,WAAa,UAAU,SAAS,EAAE,wIAAA,GAAA,UAAA,WAAiJ,QAAQ,0BAA0B,EAAE,IACzN;CAGF,MAAM,EAAE,SAAS,oBAAoB,MAAA,QAAA,QAAA,EAAA,WAAA,QAAM,yBAAA,CAAA;CAC3C,MAAM,EAAE,SAAS,oBAAoB,MAAA,QAAA,QAAA,EAAA,WAAA,QAAM,yBAAA,CAAA;CAC3C,MAAM,EAAE,SAAS,eAAe,MAAA,QAAA,QAAA,EAAA,WAAA,QAAM,oBAAA,CAAA;CACtC,MAAM,EAAE,SAAS,iBAAiB,MAAA,QAAA,QAAA,EAAA,WAAA,QAAM,sBAAA,CAAA;CACxC,MAAM,EAAE,SAAS,gBAAgB,MAAA,QAAA,QAAA,EAAA,WAAA,QAAM,qBAAA,CAAA;CAEvC,MAAM,IAAI,IAAI;EAAC;EAAiB;EAAiB;EAAY;EAAc;CAAW,GAAG,MAAM;EAC7F,aAAa;EACb,oBAAoB;EACpB,SAAA,gBAAA;CACF,CAAC;AACH"}
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import "./chunk-CRm0XQPb.js";
|
|
2
2
|
import { t as defineCLIAdapter } from "./define-DNG1U8ha.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { r as QUIET_FLAGS } from "./constants-CYxk4aNm.js";
|
|
3
|
+
import { t as version } from "./package-C8u_WvqI.js";
|
|
4
|
+
import { n as QUIET_FLAGS } from "./constants-84a47qA-.js";
|
|
6
5
|
import { parseArgs, styleText } from "node:util";
|
|
6
|
+
import { Telemetry } from "@kubb/core";
|
|
7
7
|
//#region ../../internals/utils/src/cli/schema.ts
|
|
8
8
|
/**
|
|
9
9
|
* Serializes `CommandDefinition[]` to a plain, JSON-serializable structure.
|
|
@@ -246,18 +246,18 @@ function isFlag(set, value) {
|
|
|
246
246
|
//#region src/index.ts
|
|
247
247
|
const cli = createCLI();
|
|
248
248
|
function shouldShowTelemetryNotice(argv) {
|
|
249
|
-
if (
|
|
249
|
+
if (Telemetry.isDisabled()) return false;
|
|
250
250
|
if (argv.some((arg) => isFlag(QUIET_FLAGS, arg))) return false;
|
|
251
251
|
if (!process.stdout.isTTY) return false;
|
|
252
252
|
return true;
|
|
253
253
|
}
|
|
254
254
|
async function run(argv = process.argv) {
|
|
255
255
|
if (shouldShowTelemetryNotice(argv)) 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`);
|
|
256
|
-
const { command: generateCommand } = await import("./generate-
|
|
257
|
-
const { command: validateCommand } = await import("./validate-
|
|
258
|
-
const { command: mcpCommand } = await import("./mcp-
|
|
259
|
-
const { command: agentCommand } = await import("./agent-
|
|
260
|
-
const { command: initCommand } = await import("./init-
|
|
256
|
+
const { command: generateCommand } = await import("./generate-Db0pJmbG.js");
|
|
257
|
+
const { command: validateCommand } = await import("./validate-jRewvR0c.js");
|
|
258
|
+
const { command: mcpCommand } = await import("./mcp-DqNyN0cN.js");
|
|
259
|
+
const { command: agentCommand } = await import("./agent-CLspGfSn.js");
|
|
260
|
+
const { command: initCommand } = await import("./init-DKMwmbmx.js");
|
|
261
261
|
await cli.run([
|
|
262
262
|
generateCommand,
|
|
263
263
|
validateCommand,
|
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","../../../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,gBAAgB;A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OAAO;CAIT,IAAI,CAAC,QAAQ,OAAO,OAClB,OAAO;CAGT,OAAO;AACT;AAEA,eAAsB,IAAI,OAAsB,QAAQ,MAAqB;CAC3E,IAAI,0BAA0B,IAAI,GAChC,QAAQ,IACN,GAAG,UAAU,UAAU,SAAS,EAAE,uIAAuI,UAAU,QAAQ,0BAA0B,EAAE,IACzN;CAGF,MAAM,EAAE,SAAS,oBAAoB,MAAM,OAAO;CAClD,MAAM,EAAE,SAAS,oBAAoB,MAAM,OAAO;CAClD,MAAM,EAAE,SAAS,eAAe,MAAM,OAAO;CAC7C,MAAM,EAAE,SAAS,iBAAiB,MAAM,OAAO;CAC/C,MAAM,EAAE,SAAS,gBAAgB,MAAM,OAAO;CAE9C,MAAM,IAAI,IAAI;EAAC;EAAiB;EAAiB;EAAY;EAAc;CAAW,GAAG,MAAM;EAC7F,aAAa;EACb,oBAAoB;EACpB;CACF,CAAC;AACH"}
|
|
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","../../../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 { Telemetry } from '@kubb/core'\nimport { version } from '../package.json'\nimport { QUIET_FLAGS } from './constants.ts'\n\nconst cli = createCLI()\n\nfunction shouldShowTelemetryNotice(argv: Array<string>): boolean {\n if (Telemetry.isDisabled()) {\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,gBAAgB;AAClC;AAEA,SAAS,iBAAiB,KAAuC;CAC/D,OAAO;EACL,MAAM,IAAI;EACV,aAAa,IAAI;EACjB,WAAW,IAAI;EACf,GAAI,IAAI,UAAU,SAAS,EAAE,UAAU,IAAI,SAAS,IAAI,CAAC;EACzD,SAAS,iBAAiB,IAAI,WAAW,CAAC,CAAC;EAC3C,aAAa,IAAI,cAAc,IAAI,YAAY,IAAI,gBAAgB,IAAI,CAAC;CAC1E;AACF;AAEA,SAAS,iBAAiB,SAA2D;CACnF,OAAO,OAAO,QAAQ,OAAO,EAAE,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,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AAC;AACH"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./chunk-CRm0XQPb.js";
|
|
2
2
|
import { n as defineCommand } from "./define-DNG1U8ha.js";
|
|
3
|
-
import { t as version } from "./package-
|
|
3
|
+
import { t as version } from "./package-C8u_WvqI.js";
|
|
4
4
|
//#region src/commands/init.ts
|
|
5
5
|
const command = defineCommand({
|
|
6
6
|
name: "init",
|
|
@@ -50,4 +50,4 @@ const command = defineCommand({
|
|
|
50
50
|
//#endregion
|
|
51
51
|
export { command };
|
|
52
52
|
|
|
53
|
-
//# sourceMappingURL=init-
|
|
53
|
+
//# sourceMappingURL=init-DKMwmbmx.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init-
|
|
1
|
+
{"version":3,"file":"init-DKMwmbmx.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-client,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-client, 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"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require("./chunk-Bx3C2hgW.cjs");
|
|
2
2
|
const require_define = require("./define-C4AB3POr.cjs");
|
|
3
|
-
const require_package = require("./package-
|
|
3
|
+
const require_package = require("./package-CusjBrSS.cjs");
|
|
4
4
|
//#region src/commands/init.ts
|
|
5
5
|
const command = require_define.defineCommand({
|
|
6
6
|
name: "init",
|
|
@@ -50,4 +50,4 @@ const command = require_define.defineCommand({
|
|
|
50
50
|
//#endregion
|
|
51
51
|
exports.command = command;
|
|
52
52
|
|
|
53
|
-
//# sourceMappingURL=init-
|
|
53
|
+
//# sourceMappingURL=init-D_MQBDVz.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init-
|
|
1
|
+
{"version":3,"file":"init-D_MQBDVz.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-client,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-client, 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,eAAAA,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,EAAA,WAAA,QAAM,oBAAA,CAAA;EAEtB,MAAM,IAAI;GACR,KAAK,OAAO;GACZ,SAAA,gBAAA;GACA,OAAO,OAAO;GACd,QAAQ,OAAO;GACf,SAAS,OAAO;EAClB,CAAC;CACH;AACF,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./chunk-CRm0XQPb.js";
|
|
2
2
|
import { n as defineCommand } from "./define-DNG1U8ha.js";
|
|
3
|
-
import { t as version } from "./package-
|
|
3
|
+
import { t as version } from "./package-C8u_WvqI.js";
|
|
4
4
|
//#region src/commands/mcp.ts
|
|
5
5
|
const command = defineCommand({
|
|
6
6
|
name: "mcp",
|
|
@@ -25,7 +25,7 @@ const command = defineCommand({
|
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
async run({ values }) {
|
|
28
|
-
const { run } = await import("./run-
|
|
28
|
+
const { run } = await import("./run-BQzoaxjR.js");
|
|
29
29
|
await run({
|
|
30
30
|
version,
|
|
31
31
|
port: values.port,
|
|
@@ -36,4 +36,4 @@ const command = defineCommand({
|
|
|
36
36
|
//#endregion
|
|
37
37
|
export { command };
|
|
38
38
|
|
|
39
|
-
//# sourceMappingURL=mcp-
|
|
39
|
+
//# sourceMappingURL=mcp-DqNyN0cN.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-
|
|
1
|
+
{"version":3,"file":"mcp-DqNyN0cN.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: [\n 'kubb mcp',\n 'kubb mcp --port 3001',\n '# Then add to your MCP client config:',\n '# { \"mcpServers\": { \"kubb\": { \"command\": \"npx\", \"args\": [\"kubb\", \"mcp\"] } } }',\n ],\n options: {\n port: {\n type: 'string',\n short: 'p',\n description: 'Port for HTTP MCP server (omit for stdio)',\n hint: 'number',\n },\n host: {\n type: 'string',\n description: 'Hostname to bind to (HTTP mode only)',\n default: 'localhost',\n },\n },\n async run({ values }) {\n const { run } = await import('../runners/mcp/run.ts')\n\n await run({\n version,\n port: values.port,\n host: values.host,\n })\n },\n})\n"],"mappings":";;;;AAGA,MAAa,UAAU,cAAc;CACnC,MAAM;CACN,aACE;CACF,UAAU;EACR;EACA;EACA;EACA;CACF;CACA,SAAS;EACP,MAAM;GACJ,MAAM;GACN,OAAO;GACP,aAAa;GACb,MAAM;EACR;EACA,MAAM;GACJ,MAAM;GACN,aAAa;GACb,SAAS;EACX;CACF;CACA,MAAM,IAAI,EAAE,UAAU;EACpB,MAAM,EAAE,QAAQ,MAAM,OAAO;EAE7B,MAAM,IAAI;GACR;GACA,MAAM,OAAO;GACb,MAAM,OAAO;EACf,CAAC;CACH;AACF,CAAC"}
|