@kubb/cli 5.0.0-alpha.1 → 5.0.0-alpha.11
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-C6o_6GSJ.cjs → agent-BapvKB4r.cjs} +3 -3
- package/dist/{agent-C6o_6GSJ.cjs.map → agent-BapvKB4r.cjs.map} +1 -1
- package/dist/{agent-L50VNhXv.js → agent-CBrpIMMU.js} +3 -3
- package/dist/{agent-L50VNhXv.js.map → agent-CBrpIMMU.js.map} +1 -1
- package/dist/{agent-79E3-u7O.cjs → agent-CWjx99b7.cjs} +4 -4
- package/dist/{agent-79E3-u7O.cjs.map → agent-CWjx99b7.cjs.map} +1 -1
- package/dist/{agent-Cp04hn9e.js → agent-Cj8-zyUG.js} +4 -4
- package/dist/{agent-Cp04hn9e.js.map → agent-Cj8-zyUG.js.map} +1 -1
- package/dist/{constants-BTUap0zs.cjs → constants-D0XHAHeZ.cjs} +78 -8
- package/dist/constants-D0XHAHeZ.cjs.map +1 -0
- package/dist/{constants-CM3dJzjK.js → constants-DJM9zCXm.js} +73 -9
- package/dist/constants-DJM9zCXm.js.map +1 -0
- package/dist/{generate--bVppR6p.cjs → generate-BGSP-yWr.cjs} +2 -2
- package/dist/{generate--bVppR6p.cjs.map → generate-BGSP-yWr.cjs.map} +1 -1
- package/dist/{generate-0eqtALtg.js → generate-CEdqAJKY.js} +24 -33
- package/dist/generate-CEdqAJKY.js.map +1 -0
- package/dist/{generate-CY3dN5fP.cjs → generate-CHXYcc6u.cjs} +23 -32
- package/dist/generate-CHXYcc6u.cjs.map +1 -0
- package/dist/{generate-B7E6fotL.js → generate-pRDRKUm-.js} +2 -2
- package/dist/{generate-B7E6fotL.js.map → generate-pRDRKUm-.js.map} +1 -1
- package/dist/index.cjs +19 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +19 -14
- package/dist/index.js.map +1 -1
- package/dist/{init-hmolV6B4.cjs → init-BK6inBTR.cjs} +2 -2
- package/dist/{init-hmolV6B4.cjs.map → init-BK6inBTR.cjs.map} +1 -1
- package/dist/{init-C-InrmSY.js → init-BQ6zfsnw.js} +2 -2
- package/dist/{init-C-InrmSY.js.map → init-BQ6zfsnw.js.map} +1 -1
- package/dist/{init-DxULcUVZ.js → init-DTf3Icbd.js} +3 -3
- package/dist/{init-DxULcUVZ.js.map → init-DTf3Icbd.js.map} +1 -1
- package/dist/{init-D9PIcHv5.cjs → init-Difgj4DR.cjs} +3 -3
- package/dist/{init-D9PIcHv5.cjs.map → init-Difgj4DR.cjs.map} +1 -1
- package/dist/{mcp-CmdDQe1I.cjs → mcp-B0nE_DlL.cjs} +3 -3
- package/dist/{mcp-CmdDQe1I.cjs.map → mcp-B0nE_DlL.cjs.map} +1 -1
- package/dist/{mcp-D2SHEg_d.js → mcp-BiGUvbWP.js} +2 -2
- package/dist/{mcp-D2SHEg_d.js.map → mcp-BiGUvbWP.js.map} +1 -1
- package/dist/{mcp-ChHFPRzD.cjs → mcp-CONmm_xT.cjs} +2 -2
- package/dist/{mcp-ChHFPRzD.cjs.map → mcp-CONmm_xT.cjs.map} +1 -1
- package/dist/{mcp-C0nP6f7U.js → mcp-DgcnQRu7.js} +3 -3
- package/dist/{mcp-C0nP6f7U.js.map → mcp-DgcnQRu7.js.map} +1 -1
- package/dist/{package-Dj3K_LEj.cjs → package-BMz8d3aM.cjs} +2 -2
- package/dist/package-BMz8d3aM.cjs.map +1 -0
- package/dist/package-BPoYTLqk.js +6 -0
- package/dist/package-BPoYTLqk.js.map +1 -0
- package/dist/{telemetry-DxiR7clS.js → telemetry-BF3SMlH6.js} +2 -2
- package/dist/{telemetry-DxiR7clS.js.map → telemetry-BF3SMlH6.js.map} +1 -1
- package/dist/{telemetry-Cn9X1I5B.cjs → telemetry-DZ7IrLAU.cjs} +2 -2
- package/dist/{telemetry-Cn9X1I5B.cjs.map → telemetry-DZ7IrLAU.cjs.map} +1 -1
- package/dist/{validate-l8vLmwKA.js → validate-BImbbx1t.js} +2 -2
- package/dist/{validate-l8vLmwKA.js.map → validate-BImbbx1t.js.map} +1 -1
- package/dist/{validate-tj-fCEwB.js → validate-DTllDsSn.js} +3 -3
- package/dist/{validate-tj-fCEwB.js.map → validate-DTllDsSn.js.map} +1 -1
- package/dist/{validate-BugLA3jw.cjs → validate-P6Zttj3f.cjs} +3 -3
- package/dist/{validate-BugLA3jw.cjs.map → validate-P6Zttj3f.cjs.map} +1 -1
- package/dist/{validate-Bbrn3Q-A.cjs → validate-ujLCYSWU.cjs} +2 -2
- package/dist/{validate-Bbrn3Q-A.cjs.map → validate-ujLCYSWU.cjs.map} +1 -1
- package/package.json +5 -5
- package/src/constants.ts +57 -10
- package/src/index.ts +5 -4
- package/src/loggers/clackLogger.ts +1 -2
- package/src/runners/generate.ts +14 -22
- package/src/types.ts +11 -0
- package/src/utils/flags.ts +10 -0
- package/dist/constants-BTUap0zs.cjs.map +0 -1
- package/dist/constants-CM3dJzjK.js.map +0 -1
- package/dist/generate-0eqtALtg.js.map +0 -1
- package/dist/generate-CY3dN5fP.cjs.map +0 -1
- package/dist/package-Dj3K_LEj.cjs.map +0 -1
- package/dist/package-fz4uup_a.js +0 -6
- package/dist/package-fz4uup_a.js.map +0 -1
- package/src/utils/getIntro.ts +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-
|
|
1
|
+
{"version":3,"file":"validate-BImbbx1t.js","names":[],"sources":["../src/runners/validate.ts"],"sourcesContent":["import process from 'node:process'\nimport { getErrorMessage } from '@internals/utils'\nimport type * as OasModule from '@kubb/oas'\nimport { jiti } from '../utils/jiti.ts'\nimport { buildTelemetryEvent, sendTelemetry } from '../utils/telemetry.ts'\n\ntype ValidateOptions = {\n input: string\n version: string\n}\n\nexport async function runValidate({ input, version }: ValidateOptions): Promise<void> {\n let mod: typeof OasModule\n try {\n mod = (await jiti.import('@kubb/oas', { default: true })) as typeof OasModule\n } catch (_e) {\n console.error(`Import of '@kubb/oas' is required to do validation`)\n process.exit(1)\n }\n\n const { parse } = mod\n const hrStart = process.hrtime()\n try {\n const oas = await parse(input)\n await oas.validate()\n\n await sendTelemetry(buildTelemetryEvent({ command: 'validate', kubbVersion: version, hrStart, status: 'success' }))\n console.log('✅ Validation success')\n } catch (error) {\n await sendTelemetry(buildTelemetryEvent({ command: 'validate', kubbVersion: version, hrStart, status: 'failed' }))\n console.error('❌ Validation failed')\n console.error(getErrorMessage(error))\n process.exit(1)\n }\n}\n"],"mappings":";;;;;;AAWA,eAAsB,YAAY,EAAE,OAAO,WAA2C;CACpF,IAAI;AACJ,KAAI;AACF,QAAO,MAAM,KAAK,OAAO,aAAa,EAAE,SAAS,MAAM,CAAC;UACjD,IAAI;AACX,UAAQ,MAAM,qDAAqD;AACnE,UAAQ,KAAK,EAAE;;CAGjB,MAAM,EAAE,UAAU;CAClB,MAAM,UAAU,QAAQ,QAAQ;AAChC,KAAI;AAEF,SADY,MAAM,MAAM,MAAM,EACpB,UAAU;AAEpB,QAAM,cAAc,oBAAoB;GAAE,SAAS;GAAY,aAAa;GAAS;GAAS,QAAQ;GAAW,CAAC,CAAC;AACnH,UAAQ,IAAI,uBAAuB;UAC5B,OAAO;AACd,QAAM,cAAc,oBAAoB;GAAE,SAAS;GAAY,aAAa;GAAS;GAAS,QAAQ;GAAU,CAAC,CAAC;AAClH,UAAQ,MAAM,sBAAsB;AACpC,UAAQ,MAAM,gBAAgB,MAAM,CAAC;AACrC,UAAQ,KAAK,EAAE"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./chunk--u3MIqq1.js";
|
|
2
2
|
import { n as defineCommand } from "./define--M_JMcDC.js";
|
|
3
|
-
import { t as version } from "./package-
|
|
3
|
+
import { t as version } from "./package-BPoYTLqk.js";
|
|
4
4
|
//#region src/commands/validate.ts
|
|
5
5
|
const command = defineCommand({
|
|
6
6
|
name: "validate",
|
|
@@ -12,7 +12,7 @@ const command = defineCommand({
|
|
|
12
12
|
required: true
|
|
13
13
|
} },
|
|
14
14
|
async run({ values }) {
|
|
15
|
-
const { runValidate } = await import("./validate-
|
|
15
|
+
const { runValidate } = await import("./validate-BImbbx1t.js");
|
|
16
16
|
await runValidate({
|
|
17
17
|
input: values.input,
|
|
18
18
|
version
|
|
@@ -22,4 +22,4 @@ const command = defineCommand({
|
|
|
22
22
|
//#endregion
|
|
23
23
|
export { command };
|
|
24
24
|
|
|
25
|
-
//# sourceMappingURL=validate-
|
|
25
|
+
//# sourceMappingURL=validate-DTllDsSn.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-
|
|
1
|
+
{"version":3,"file":"validate-DTllDsSn.js","names":[],"sources":["../src/commands/validate.ts"],"sourcesContent":["import { defineCommand } from '@internals/utils'\nimport { version } from '../../package.json'\n\nexport const command = defineCommand({\n name: 'validate',\n description: 'Validate a Swagger/OpenAPI file',\n options: {\n input: { type: 'string', description: 'Path to Swagger/OpenAPI file', short: 'i', required: true },\n },\n async run({ values }) {\n const { runValidate } = await import('../runners/validate.ts')\n\n await runValidate({ input: values.input, version })\n },\n})\n"],"mappings":";;;;AAGA,MAAa,UAAU,cAAc;CACnC,MAAM;CACN,aAAa;CACb,SAAS,EACP,OAAO;EAAE,MAAM;EAAU,aAAa;EAAgC,OAAO;EAAK,UAAU;EAAM,EACnG;CACD,MAAM,IAAI,EAAE,UAAU;EACpB,MAAM,EAAE,gBAAgB,MAAM,OAAO;AAErC,QAAM,YAAY;GAAE,OAAO,OAAO;GAAO;GAAS,CAAC;;CAEtD,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require("./chunk-ByKO4r7w.cjs");
|
|
2
2
|
const require_define = require("./define-D6Kfm7-Z.cjs");
|
|
3
|
-
const require_package = require("./package-
|
|
3
|
+
const require_package = require("./package-BMz8d3aM.cjs");
|
|
4
4
|
//#region src/commands/validate.ts
|
|
5
5
|
const command = require_define.defineCommand({
|
|
6
6
|
name: "validate",
|
|
@@ -12,7 +12,7 @@ const command = require_define.defineCommand({
|
|
|
12
12
|
required: true
|
|
13
13
|
} },
|
|
14
14
|
async run({ values }) {
|
|
15
|
-
const { runValidate } = await Promise.resolve().then(() => require("./validate-
|
|
15
|
+
const { runValidate } = await Promise.resolve().then(() => require("./validate-ujLCYSWU.cjs"));
|
|
16
16
|
await runValidate({
|
|
17
17
|
input: values.input,
|
|
18
18
|
version: require_package.version
|
|
@@ -22,4 +22,4 @@ const command = require_define.defineCommand({
|
|
|
22
22
|
//#endregion
|
|
23
23
|
exports.command = command;
|
|
24
24
|
|
|
25
|
-
//# sourceMappingURL=validate-
|
|
25
|
+
//# sourceMappingURL=validate-P6Zttj3f.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-
|
|
1
|
+
{"version":3,"file":"validate-P6Zttj3f.cjs","names":["defineCommand"],"sources":["../src/commands/validate.ts"],"sourcesContent":["import { defineCommand } from '@internals/utils'\nimport { version } from '../../package.json'\n\nexport const command = defineCommand({\n name: 'validate',\n description: 'Validate a Swagger/OpenAPI file',\n options: {\n input: { type: 'string', description: 'Path to Swagger/OpenAPI file', short: 'i', required: true },\n },\n async run({ values }) {\n const { runValidate } = await import('../runners/validate.ts')\n\n await runValidate({ input: values.input, version })\n },\n})\n"],"mappings":";;;;AAGA,MAAa,UAAUA,eAAAA,cAAc;CACnC,MAAM;CACN,aAAa;CACb,SAAS,EACP,OAAO;EAAE,MAAM;EAAU,aAAa;EAAgC,OAAO;EAAK,UAAU;EAAM,EACnG;CACD,MAAM,IAAI,EAAE,UAAU;EACpB,MAAM,EAAE,gBAAgB,MAAA,QAAA,SAAA,CAAA,WAAA,QAAM,0BAAA,CAAA;AAE9B,QAAM,YAAY;GAAE,OAAO,OAAO;GAAO,SAAA,gBAAA;GAAS,CAAC;;CAEtD,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-ByKO4r7w.cjs");
|
|
2
2
|
const require_errors = require("./errors-DBW0N9w4.cjs");
|
|
3
|
-
const require_telemetry = require("./telemetry-
|
|
3
|
+
const require_telemetry = require("./telemetry-DZ7IrLAU.cjs");
|
|
4
4
|
const require_jiti = require("./jiti-Cd3S0xwr.cjs");
|
|
5
5
|
let node_process = require("node:process");
|
|
6
6
|
node_process = require_chunk.__toESM(node_process);
|
|
@@ -39,4 +39,4 @@ async function runValidate({ input, version }) {
|
|
|
39
39
|
//#endregion
|
|
40
40
|
exports.runValidate = runValidate;
|
|
41
41
|
|
|
42
|
-
//# sourceMappingURL=validate-
|
|
42
|
+
//# sourceMappingURL=validate-ujLCYSWU.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-
|
|
1
|
+
{"version":3,"file":"validate-ujLCYSWU.cjs","names":["jiti","process","sendTelemetry","buildTelemetryEvent","getErrorMessage"],"sources":["../src/runners/validate.ts"],"sourcesContent":["import process from 'node:process'\nimport { getErrorMessage } from '@internals/utils'\nimport type * as OasModule from '@kubb/oas'\nimport { jiti } from '../utils/jiti.ts'\nimport { buildTelemetryEvent, sendTelemetry } from '../utils/telemetry.ts'\n\ntype ValidateOptions = {\n input: string\n version: string\n}\n\nexport async function runValidate({ input, version }: ValidateOptions): Promise<void> {\n let mod: typeof OasModule\n try {\n mod = (await jiti.import('@kubb/oas', { default: true })) as typeof OasModule\n } catch (_e) {\n console.error(`Import of '@kubb/oas' is required to do validation`)\n process.exit(1)\n }\n\n const { parse } = mod\n const hrStart = process.hrtime()\n try {\n const oas = await parse(input)\n await oas.validate()\n\n await sendTelemetry(buildTelemetryEvent({ command: 'validate', kubbVersion: version, hrStart, status: 'success' }))\n console.log('✅ Validation success')\n } catch (error) {\n await sendTelemetry(buildTelemetryEvent({ command: 'validate', kubbVersion: version, hrStart, status: 'failed' }))\n console.error('❌ Validation failed')\n console.error(getErrorMessage(error))\n process.exit(1)\n }\n}\n"],"mappings":";;;;;;;AAWA,eAAsB,YAAY,EAAE,OAAO,WAA2C;CACpF,IAAI;AACJ,KAAI;AACF,QAAO,MAAMA,aAAAA,KAAK,OAAO,aAAa,EAAE,SAAS,MAAM,CAAC;UACjD,IAAI;AACX,UAAQ,MAAM,qDAAqD;AACnE,eAAA,QAAQ,KAAK,EAAE;;CAGjB,MAAM,EAAE,UAAU;CAClB,MAAM,UAAUC,aAAAA,QAAQ,QAAQ;AAChC,KAAI;AAEF,SADY,MAAM,MAAM,MAAM,EACpB,UAAU;AAEpB,QAAMC,kBAAAA,cAAcC,kBAAAA,oBAAoB;GAAE,SAAS;GAAY,aAAa;GAAS;GAAS,QAAQ;GAAW,CAAC,CAAC;AACnH,UAAQ,IAAI,uBAAuB;UAC5B,OAAO;AACd,QAAMD,kBAAAA,cAAcC,kBAAAA,oBAAoB;GAAE,SAAS;GAAY,aAAa;GAAS;GAAS,QAAQ;GAAU,CAAC,CAAC;AAClH,UAAQ,MAAM,sBAAsB;AACpC,UAAQ,MAAMC,eAAAA,gBAAgB,MAAM,CAAC;AACrC,eAAA,QAAQ,KAAK,EAAE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/cli",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.11",
|
|
4
4
|
"description": "Command-line interface for Kubb, enabling easy generation of TypeScript, React-Query, Zod, and other code from OpenAPI specifications.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -58,14 +58,14 @@
|
|
|
58
58
|
"cosmiconfig": "^9.0.1",
|
|
59
59
|
"jiti": "2.5.1",
|
|
60
60
|
"tinyexec": "^1.0.4",
|
|
61
|
-
"@kubb/core": "5.0.0-alpha.
|
|
61
|
+
"@kubb/core": "5.0.0-alpha.11"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"source-map-support": "^0.5.21",
|
|
65
65
|
"@internals/utils": "0.0.0",
|
|
66
|
-
"@kubb/agent": "5.0.0-alpha.
|
|
67
|
-
"@kubb/mcp": "5.0.0-alpha.
|
|
68
|
-
"@kubb/oas": "5.0.0-alpha.
|
|
66
|
+
"@kubb/agent": "5.0.0-alpha.11",
|
|
67
|
+
"@kubb/mcp": "5.0.0-alpha.11",
|
|
68
|
+
"@kubb/oas": "5.0.0-alpha.11"
|
|
69
69
|
},
|
|
70
70
|
"engines": {
|
|
71
71
|
"node": ">=22"
|
package/src/constants.ts
CHANGED
|
@@ -1,33 +1,78 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* NPM registry endpoint used to check for @kubb/cli updates.
|
|
3
|
+
*/
|
|
2
4
|
export const KUBB_NPM_PACKAGE_URL = 'https://registry.npmjs.org/@kubb/cli/latest' as const
|
|
3
5
|
|
|
4
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* OpenTelemetry ingestion endpoint for anonymous usage telemetry.
|
|
8
|
+
*/
|
|
5
9
|
export const OTLP_ENDPOINT = 'https://otlp.kubb.dev' as const
|
|
6
10
|
|
|
7
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* Horizontal rule rendered above/below the plain-logger generation summary.
|
|
13
|
+
*/
|
|
8
14
|
export const SUMMARY_SEPARATOR = '─'.repeat(27)
|
|
9
15
|
|
|
10
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* Maximum number of █ characters in a plugin timing bar.
|
|
18
|
+
*/
|
|
11
19
|
export const SUMMARY_MAX_BAR_LENGTH = 10 as const
|
|
12
20
|
|
|
13
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* Divides elapsed milliseconds into bar-length units (1 block per 100 ms).
|
|
23
|
+
*/
|
|
14
24
|
export const SUMMARY_TIME_SCALE_DIVISOR = 100 as const
|
|
15
25
|
|
|
16
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* Glob pattern for paths the file watcher ignores.
|
|
28
|
+
*/
|
|
17
29
|
export const WATCHER_IGNORED_PATHS = '**/{.git,node_modules}/**' as const
|
|
18
30
|
|
|
19
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* Flags that short-circuit execution (help/version) — no telemetry notice is shown.
|
|
33
|
+
*/
|
|
34
|
+
export const QUITE_FLAGS = new Set(['--help', '-h', '--version', '-v'] as const)
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Flags accepted by the `generate` command.
|
|
38
|
+
*/
|
|
39
|
+
export const GENERATE_FLAGS = new Set(['--config', '-c', '--log-level', '-l', '--watch', '-w', '--debug', '-d', '--verbose', '-v', '--silent', '-s'] as const)
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Flags accepted by the `validate` command.
|
|
43
|
+
*/
|
|
44
|
+
export const VALIDATE_FLAGS = new Set(['--input', '-i'] as const)
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Flags accepted by the `init` command.
|
|
48
|
+
*/
|
|
49
|
+
export const INIT_FLAGS = new Set(['--yes', '-y'] as const)
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Flags accepted by the `agent start` command.
|
|
53
|
+
*/
|
|
54
|
+
export const AGENT_START_FLAGS = new Set(['--config', '-c', '--port', '-p', '--host', '--allow-write', '--allow-all'] as const)
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* All known CLI flags across every command.
|
|
58
|
+
*/
|
|
59
|
+
export const ARGS = new Set([...QUITE_FLAGS, ...GENERATE_FLAGS, ...VALIDATE_FLAGS, ...INIT_FLAGS, ...AGENT_START_FLAGS] as const)
|
|
60
|
+
|
|
20
61
|
export const agentDefaults = {
|
|
21
62
|
port: '3000',
|
|
22
63
|
host: 'localhost',
|
|
23
64
|
configFile: 'kubb.config.ts',
|
|
24
65
|
retryTimeout: '30000',
|
|
25
66
|
studioUrl: 'https://studio.kubb.dev',
|
|
26
|
-
/**
|
|
67
|
+
/**
|
|
68
|
+
* Relative path from the @kubb/agent package root to the server entry.
|
|
69
|
+
*/
|
|
27
70
|
serverEntryPath: '.output/server/index.mjs',
|
|
28
71
|
} as const
|
|
29
72
|
|
|
30
|
-
/**
|
|
73
|
+
/**
|
|
74
|
+
* Default values used during interactive `init` scaffolding.
|
|
75
|
+
*/
|
|
31
76
|
export const initDefaults = {
|
|
32
77
|
inputPath: './openapi.yaml',
|
|
33
78
|
outputPath: './src/gen',
|
|
@@ -73,4 +118,6 @@ export const pluginDefaultConfigs = {
|
|
|
73
118
|
})`,
|
|
74
119
|
} as const satisfies Record<string, string>
|
|
75
120
|
|
|
76
|
-
/**
|
|
121
|
+
/**
|
|
122
|
+
* Color palette used by randomCliColor() for deterministic plugin name coloring.
|
|
123
|
+
*/
|
package/src/index.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { styleText } from 'node:util'
|
|
2
2
|
import { createCLI } from '@internals/utils'
|
|
3
3
|
import { version } from '../package.json'
|
|
4
|
+
import { QUITE_FLAGS } from './constants.ts'
|
|
5
|
+
import { isFlag } from './utils/flags.ts'
|
|
4
6
|
import { isTelemetryDisabled } from './utils/telemetry.ts'
|
|
5
7
|
|
|
6
8
|
const cli = createCLI()
|
|
7
9
|
|
|
8
|
-
function shouldShowTelemetryNotice(argv: string
|
|
10
|
+
function shouldShowTelemetryNotice(argv: Array<string>): boolean {
|
|
9
11
|
if (isTelemetryDisabled()) {
|
|
10
12
|
return false
|
|
11
13
|
}
|
|
12
14
|
// Skip when the user is just asking for help or version info
|
|
13
|
-
|
|
14
|
-
if (argv.some((arg) => quietFlags.has(arg))) {
|
|
15
|
+
if (argv.some((arg) => isFlag(QUITE_FLAGS, arg))) {
|
|
15
16
|
return false
|
|
16
17
|
}
|
|
17
18
|
// Skip in non-interactive / scripting contexts
|
|
@@ -21,7 +22,7 @@ function shouldShowTelemetryNotice(argv: string[]): boolean {
|
|
|
21
22
|
return true
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
export async function run(argv: string
|
|
25
|
+
export async function run(argv: Array<string> = process.argv): Promise<void> {
|
|
25
26
|
if (shouldShowTelemetryNotice(argv)) {
|
|
26
27
|
console.log(
|
|
27
28
|
`${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`,
|
|
@@ -2,9 +2,8 @@ import { relative } from 'node:path'
|
|
|
2
2
|
import process from 'node:process'
|
|
3
3
|
import { styleText } from 'node:util'
|
|
4
4
|
import * as clack from '@clack/prompts'
|
|
5
|
-
import { formatMs, formatMsWithColor, toCause } from '@internals/utils'
|
|
5
|
+
import { formatMs, formatMsWithColor, getIntro, toCause } from '@internals/utils'
|
|
6
6
|
import { defineLogger, logLevel as logLevelMap } from '@kubb/core'
|
|
7
|
-
import { getIntro } from '../utils/getIntro.ts'
|
|
8
7
|
import { getSummary } from '../utils/getSummary.ts'
|
|
9
8
|
import { runHook } from '../utils/runHook.ts'
|
|
10
9
|
import { ClackWritable } from '../utils/Writables.ts'
|
package/src/runners/generate.ts
CHANGED
|
@@ -16,7 +16,6 @@ import {
|
|
|
16
16
|
type KubbEvents,
|
|
17
17
|
linters,
|
|
18
18
|
logLevel as logLevelMap,
|
|
19
|
-
PromiseManager,
|
|
20
19
|
safeBuild,
|
|
21
20
|
setup,
|
|
22
21
|
} from '@kubb/core'
|
|
@@ -159,7 +158,7 @@ async function generate({ input, config: userConfig, events, logLevel }: Generat
|
|
|
159
158
|
|
|
160
159
|
await events.emit('info', config.name ? `Setup generation ${styleText('bold', config.name)}` : 'Setup generation', inputPath)
|
|
161
160
|
|
|
162
|
-
const { sources, fabric,
|
|
161
|
+
const { sources, fabric, driver } = await setup({
|
|
163
162
|
config,
|
|
164
163
|
events,
|
|
165
164
|
})
|
|
@@ -171,7 +170,7 @@ async function generate({ input, config: userConfig, events, logLevel }: Generat
|
|
|
171
170
|
config,
|
|
172
171
|
events,
|
|
173
172
|
},
|
|
174
|
-
{
|
|
173
|
+
{ driver, fabric, events, sources },
|
|
175
174
|
)
|
|
176
175
|
|
|
177
176
|
await events.emit('info', 'Load summary')
|
|
@@ -206,7 +205,7 @@ async function generate({ input, config: userConfig, events, logLevel }: Generat
|
|
|
206
205
|
buildTelemetryEvent({
|
|
207
206
|
command: 'generate',
|
|
208
207
|
kubbVersion: version,
|
|
209
|
-
plugins:
|
|
208
|
+
plugins: driver.plugins.map((p) => ({ name: p.name, options: p.options as Record<string, unknown> })),
|
|
210
209
|
hrStart,
|
|
211
210
|
filesCreated: files.length,
|
|
212
211
|
status: 'failed',
|
|
@@ -274,7 +273,7 @@ async function generate({ input, config: userConfig, events, logLevel }: Generat
|
|
|
274
273
|
const telemetryEvent = buildTelemetryEvent({
|
|
275
274
|
command: 'generate',
|
|
276
275
|
kubbVersion: version,
|
|
277
|
-
plugins:
|
|
276
|
+
plugins: driver.plugins.map((p) => ({ name: p.name, options: p.options as Record<string, unknown> })),
|
|
278
277
|
hrStart,
|
|
279
278
|
filesCreated: files.length,
|
|
280
279
|
status: 'success',
|
|
@@ -293,7 +292,6 @@ type GenerateCommandOptions = {
|
|
|
293
292
|
export async function runGenerateCommand({ input, configPath, logLevel: logLevelKey, watch }: GenerateCommandOptions): Promise<void> {
|
|
294
293
|
const logLevel = logLevelMap[logLevelKey as keyof typeof logLevelMap] ?? logLevelMap.info
|
|
295
294
|
const events = new AsyncEventEmitterClass<KubbEvents>()
|
|
296
|
-
const promiseManager = new PromiseManager()
|
|
297
295
|
|
|
298
296
|
await setupLogger(events, { logLevel })
|
|
299
297
|
|
|
@@ -322,26 +320,20 @@ export async function runGenerateCommand({ input, configPath, logLevel: logLevel
|
|
|
322
320
|
|
|
323
321
|
await events.emit('lifecycle:start', version)
|
|
324
322
|
|
|
325
|
-
const
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
events.removeAll()
|
|
323
|
+
for (const config of configs) {
|
|
324
|
+
if (isInputPath(config) && watch) {
|
|
325
|
+
await startWatcher([input || config.input.path], async (paths) => {
|
|
326
|
+
// remove to avoid duplicate listeners after each change
|
|
327
|
+
events.removeAll()
|
|
331
328
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
clack.log.step(styleText('yellow', `Watching for changes in ${paths.join(' and ')}`))
|
|
335
|
-
})
|
|
336
|
-
|
|
337
|
-
return
|
|
338
|
-
}
|
|
329
|
+
await generate({ input, config, logLevel, events })
|
|
339
330
|
|
|
331
|
+
clack.log.step(styleText('yellow', `Watching for changes in ${paths.join(' and ')}`))
|
|
332
|
+
})
|
|
333
|
+
} else {
|
|
340
334
|
await generate({ input, config, logLevel, events })
|
|
341
335
|
}
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
await promiseManager.run('seq', promises)
|
|
336
|
+
}
|
|
345
337
|
|
|
346
338
|
await events.emit('lifecycle:end')
|
|
347
339
|
} catch (error) {
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type QuiteFlag = '--help' | '-h' | '--version' | '-v'
|
|
2
|
+
|
|
3
|
+
export type GenerateFlag = '--config' | '-c' | '--log-level' | '-l' | '--watch' | '-w' | '--debug' | '-d' | '--verbose' | '-v' | '--silent' | '-s'
|
|
4
|
+
|
|
5
|
+
export type ValidateFlag = '--input' | '-i'
|
|
6
|
+
|
|
7
|
+
export type InitFlag = '--yes' | '-y'
|
|
8
|
+
|
|
9
|
+
export type AgentStartFlag = '--config' | '-c' | '--port' | '-p' | '--host' | '--allow-write' | '--allow-all'
|
|
10
|
+
|
|
11
|
+
export type Arg = QuiteFlag | GenerateFlag | ValidateFlag | InitFlag | AgentStartFlag
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type guard that checks whether a raw string is a member of a typed flag set.
|
|
3
|
+
* Avoids the need for type assertions when working with `Set<T extends string>`.
|
|
4
|
+
*/
|
|
5
|
+
export function isFlag<T extends string>(set: ReadonlySet<T>, value: string): value is T {
|
|
6
|
+
for (const flag of set) {
|
|
7
|
+
if (flag === value) return true
|
|
8
|
+
}
|
|
9
|
+
return false
|
|
10
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants-BTUap0zs.cjs","names":[],"sources":["../src/constants.ts"],"sourcesContent":["/** NPM registry endpoint used to check for @kubb/cli updates. */\nexport const KUBB_NPM_PACKAGE_URL = 'https://registry.npmjs.org/@kubb/cli/latest' as const\n\n/** OpenTelemetry ingestion endpoint for anonymous usage telemetry. */\nexport const OTLP_ENDPOINT = 'https://otlp.kubb.dev' as const\n\n/** Horizontal rule rendered above/below the plain-logger generation summary. */\nexport const SUMMARY_SEPARATOR = '─'.repeat(27)\n\n/** Maximum number of █ characters in a plugin timing bar. */\nexport const SUMMARY_MAX_BAR_LENGTH = 10 as const\n\n/** Divides elapsed milliseconds into bar-length units (1 block per 100 ms). */\nexport const SUMMARY_TIME_SCALE_DIVISOR = 100 as const\n\n/** Glob pattern for paths the file watcher ignores. */\nexport const WATCHER_IGNORED_PATHS = '**/{.git,node_modules}/**' as const\n\n/** Default runtime values for the `agent start` command. */\nexport const agentDefaults = {\n port: '3000',\n host: 'localhost',\n configFile: 'kubb.config.ts',\n retryTimeout: '30000',\n studioUrl: 'https://studio.kubb.dev',\n /** Relative path from the @kubb/agent package root to the server entry. */\n serverEntryPath: '.output/server/index.mjs',\n} as const\n\n/** Default values used during interactive `init` scaffolding. */\nexport const initDefaults = {\n inputPath: './openapi.yaml',\n outputPath: './src/gen',\n plugins: ['plugin-oas', 'plugin-ts'],\n} as const\n\n/**\n * Maps each plugin value to the default config snippet inserted by `init`.\n * The `satisfies` constraint ensures all values remain plain strings while\n * `as const` keeps the object deeply immutable.\n */\nexport const pluginDefaultConfigs = {\n 'plugin-oas': 'pluginOas()',\n 'plugin-ts': `pluginTs({\n output: { path: 'models' },\n })`,\n 'plugin-client': `pluginClient({\n output: { path: 'clients' },\n })`,\n 'plugin-react-query': `pluginReactQuery({\n output: { path: 'hooks' },\n })`,\n 'plugin-solid-query': `pluginSolidQuery({\n output: { path: 'hooks' },\n })`,\n 'plugin-svelte-query': `pluginSvelteQuery({\n output: { path: 'hooks' },\n })`,\n 'plugin-vue-query': `pluginVueQuery({\n output: { path: 'hooks' },\n })`,\n 'plugin-swr': `pluginSwr({\n output: { path: 'hooks' },\n })`,\n 'plugin-zod': `pluginZod({\n output: { path: 'zod' },\n })`,\n 'plugin-faker': `pluginFaker({\n output: { path: 'mocks' },\n })`,\n 'plugin-msw': `pluginMsw({\n output: { path: 'msw' },\n })`,\n} as const satisfies Record<string, string>\n\n/** Color palette used by randomCliColor() for deterministic plugin name coloring. */\n"],"mappings":";;AACA,MAAa,uBAAuB;;AAGpC,MAAa,gBAAgB;;AAG7B,MAAa,oBAAoB,IAAI,OAAO,GAAG;;AAS/C,MAAa,wBAAwB;;AAGrC,MAAa,gBAAgB;CAC3B,MAAM;CACN,MAAM;CACN,YAAY;CACZ,cAAc;CACd,WAAW;CAEX,iBAAiB;CAClB;;AAGD,MAAa,eAAe;CAC1B,WAAW;CACX,YAAY;CACZ,SAAS,CAAC,cAAc,YAAY;CACrC;;;;;;AAOD,MAAa,uBAAuB;CAClC,cAAc;CACd,aAAa;;;CAGb,iBAAiB;;;CAGjB,sBAAsB;;;CAGtB,sBAAsB;;;CAGtB,uBAAuB;;;CAGvB,oBAAoB;;;CAGpB,cAAc;;;CAGd,cAAc;;;CAGd,gBAAgB;;;CAGhB,cAAc;;;CAGf"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants-CM3dJzjK.js","names":[],"sources":["../src/constants.ts"],"sourcesContent":["/** NPM registry endpoint used to check for @kubb/cli updates. */\nexport const KUBB_NPM_PACKAGE_URL = 'https://registry.npmjs.org/@kubb/cli/latest' as const\n\n/** OpenTelemetry ingestion endpoint for anonymous usage telemetry. */\nexport const OTLP_ENDPOINT = 'https://otlp.kubb.dev' as const\n\n/** Horizontal rule rendered above/below the plain-logger generation summary. */\nexport const SUMMARY_SEPARATOR = '─'.repeat(27)\n\n/** Maximum number of █ characters in a plugin timing bar. */\nexport const SUMMARY_MAX_BAR_LENGTH = 10 as const\n\n/** Divides elapsed milliseconds into bar-length units (1 block per 100 ms). */\nexport const SUMMARY_TIME_SCALE_DIVISOR = 100 as const\n\n/** Glob pattern for paths the file watcher ignores. */\nexport const WATCHER_IGNORED_PATHS = '**/{.git,node_modules}/**' as const\n\n/** Default runtime values for the `agent start` command. */\nexport const agentDefaults = {\n port: '3000',\n host: 'localhost',\n configFile: 'kubb.config.ts',\n retryTimeout: '30000',\n studioUrl: 'https://studio.kubb.dev',\n /** Relative path from the @kubb/agent package root to the server entry. */\n serverEntryPath: '.output/server/index.mjs',\n} as const\n\n/** Default values used during interactive `init` scaffolding. */\nexport const initDefaults = {\n inputPath: './openapi.yaml',\n outputPath: './src/gen',\n plugins: ['plugin-oas', 'plugin-ts'],\n} as const\n\n/**\n * Maps each plugin value to the default config snippet inserted by `init`.\n * The `satisfies` constraint ensures all values remain plain strings while\n * `as const` keeps the object deeply immutable.\n */\nexport const pluginDefaultConfigs = {\n 'plugin-oas': 'pluginOas()',\n 'plugin-ts': `pluginTs({\n output: { path: 'models' },\n })`,\n 'plugin-client': `pluginClient({\n output: { path: 'clients' },\n })`,\n 'plugin-react-query': `pluginReactQuery({\n output: { path: 'hooks' },\n })`,\n 'plugin-solid-query': `pluginSolidQuery({\n output: { path: 'hooks' },\n })`,\n 'plugin-svelte-query': `pluginSvelteQuery({\n output: { path: 'hooks' },\n })`,\n 'plugin-vue-query': `pluginVueQuery({\n output: { path: 'hooks' },\n })`,\n 'plugin-swr': `pluginSwr({\n output: { path: 'hooks' },\n })`,\n 'plugin-zod': `pluginZod({\n output: { path: 'zod' },\n })`,\n 'plugin-faker': `pluginFaker({\n output: { path: 'mocks' },\n })`,\n 'plugin-msw': `pluginMsw({\n output: { path: 'msw' },\n })`,\n} as const satisfies Record<string, string>\n\n/** Color palette used by randomCliColor() for deterministic plugin name coloring. */\n"],"mappings":";;AACA,MAAa,uBAAuB;;AAGpC,MAAa,gBAAgB;;AAG7B,MAAa,oBAAoB,IAAI,OAAO,GAAG;;AAS/C,MAAa,wBAAwB;;AAGrC,MAAa,gBAAgB;CAC3B,MAAM;CACN,MAAM;CACN,YAAY;CACZ,cAAc;CACd,WAAW;CAEX,iBAAiB;CAClB;;AAGD,MAAa,eAAe;CAC1B,WAAW;CACX,YAAY;CACZ,SAAS,CAAC,cAAc,YAAY;CACrC;;;;;;AAOD,MAAa,uBAAuB;CAClC,cAAc;CACd,aAAa;;;CAGb,iBAAiB;;;CAGjB,sBAAsB;;;CAGtB,sBAAsB;;;CAGtB,uBAAuB;;;CAGvB,oBAAoB;;;CAGpB,cAAc;;;CAGd,cAAc;;;CAGd,gBAAgB;;;CAGhB,cAAc;;;CAGf"}
|