@kubb/cli 5.0.0-beta.1 → 5.0.0-beta.100

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.
Files changed (148) hide show
  1. package/LICENSE +17 -10
  2. package/README.md +171 -51
  3. package/bin/kubb.js +9 -3
  4. package/dist/Telemetry-7z2tIqPm.js +282 -0
  5. package/dist/Telemetry-7z2tIqPm.js.map +1 -0
  6. package/dist/Telemetry-xcWb-UWT.cjs +331 -0
  7. package/dist/Telemetry-xcWb-UWT.cjs.map +1 -0
  8. package/dist/{errors-CjPmyZHy.js → errors-CMvLO2NE.js} +3 -15
  9. package/dist/{errors-CjPmyZHy.js.map → errors-CMvLO2NE.js.map} +1 -1
  10. package/dist/{errors-CLCjoSg0.cjs → errors-DNxBUo3k.cjs} +2 -20
  11. package/dist/{errors-CLCjoSg0.cjs.map → errors-DNxBUo3k.cjs.map} +1 -1
  12. package/dist/generate-dIcWEfOA.cjs +95 -0
  13. package/dist/generate-dIcWEfOA.cjs.map +1 -0
  14. package/dist/generate-nPLBd69v.js +95 -0
  15. package/dist/generate-nPLBd69v.js.map +1 -0
  16. package/dist/index.cjs +33 -252
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.d.ts +6 -2
  19. package/dist/index.js +34 -253
  20. package/dist/index.js.map +1 -1
  21. package/dist/init-6h3K2syO.cjs +52 -0
  22. package/dist/init-6h3K2syO.cjs.map +1 -0
  23. package/dist/init-CNV6OC7m.js +53 -0
  24. package/dist/init-CNV6OC7m.js.map +1 -0
  25. package/dist/mcp-BzPiZA36.js +21 -0
  26. package/dist/mcp-BzPiZA36.js.map +1 -0
  27. package/dist/mcp-CmxnIZku.cjs +20 -0
  28. package/dist/mcp-CmxnIZku.cjs.map +1 -0
  29. package/dist/package-By3tigpl.js +6 -0
  30. package/dist/package-By3tigpl.js.map +1 -0
  31. package/dist/{package-Cdo6lNjF.cjs → package-CImfPtTH.cjs} +2 -2
  32. package/dist/package-CImfPtTH.cjs.map +1 -0
  33. package/dist/run-BJhB7Qer.js +306 -0
  34. package/dist/run-BJhB7Qer.js.map +1 -0
  35. package/dist/run-BdtVrLKu.cjs +46 -0
  36. package/dist/run-BdtVrLKu.cjs.map +1 -0
  37. package/dist/run-CaOjZRiQ.js +45 -0
  38. package/dist/run-CaOjZRiQ.js.map +1 -0
  39. package/dist/run-D-gAS1Vq.js +1264 -0
  40. package/dist/run-D-gAS1Vq.js.map +1 -0
  41. package/dist/run-DAHp52w3.js +33 -0
  42. package/dist/run-DAHp52w3.js.map +1 -0
  43. package/dist/run-DaVewTtW.cjs +310 -0
  44. package/dist/run-DaVewTtW.cjs.map +1 -0
  45. package/dist/run-HUVxfpGj.cjs +1267 -0
  46. package/dist/run-HUVxfpGj.cjs.map +1 -0
  47. package/dist/run-iidDikJH.cjs +34 -0
  48. package/dist/run-iidDikJH.cjs.map +1 -0
  49. package/dist/tools-CzgGQa64.cjs +175 -0
  50. package/dist/tools-CzgGQa64.cjs.map +1 -0
  51. package/dist/tools-DH1a7ZJH.js +152 -0
  52. package/dist/tools-DH1a7ZJH.js.map +1 -0
  53. package/dist/validate-BUw6PkPp.js +25 -0
  54. package/dist/validate-BUw6PkPp.js.map +1 -0
  55. package/dist/validate-DMfyLIta.cjs +24 -0
  56. package/dist/validate-DMfyLIta.cjs.map +1 -0
  57. package/package.json +24 -30
  58. package/dist/agent-B_pirbeB.cjs +0 -116
  59. package/dist/agent-B_pirbeB.cjs.map +0 -1
  60. package/dist/agent-CUmEyiqY.cjs +0 -58
  61. package/dist/agent-CUmEyiqY.cjs.map +0 -1
  62. package/dist/agent-Ev5hU5hH.js +0 -112
  63. package/dist/agent-Ev5hU5hH.js.map +0 -1
  64. package/dist/agent-v_2S-bnN.js +0 -56
  65. package/dist/agent-v_2S-bnN.js.map +0 -1
  66. package/dist/constants-CnDXa1R6.cjs +0 -148
  67. package/dist/constants-CnDXa1R6.cjs.map +0 -1
  68. package/dist/constants-aL3CP_Wq.js +0 -95
  69. package/dist/constants-aL3CP_Wq.js.map +0 -1
  70. package/dist/define-Bdn8j5VM.cjs +0 -54
  71. package/dist/define-Bdn8j5VM.cjs.map +0 -1
  72. package/dist/define-Ctii4bel.js +0 -43
  73. package/dist/define-Ctii4bel.js.map +0 -1
  74. package/dist/generate-BaJRhbCS.js +0 -66
  75. package/dist/generate-BaJRhbCS.js.map +0 -1
  76. package/dist/generate-CuxArvEk.js +0 -1753
  77. package/dist/generate-CuxArvEk.js.map +0 -1
  78. package/dist/generate-TL8zY_IT.cjs +0 -65
  79. package/dist/generate-TL8zY_IT.cjs.map +0 -1
  80. package/dist/generate-UCP0qpDp.cjs +0 -1756
  81. package/dist/generate-UCP0qpDp.cjs.map +0 -1
  82. package/dist/init-CZ5Xq2Hd.cjs +0 -293
  83. package/dist/init-CZ5Xq2Hd.cjs.map +0 -1
  84. package/dist/init-DRR_YWIq.cjs +0 -25
  85. package/dist/init-DRR_YWIq.cjs.map +0 -1
  86. package/dist/init-DSnRd1RJ.js +0 -25
  87. package/dist/init-DSnRd1RJ.js.map +0 -1
  88. package/dist/init-eNRlotJK.js +0 -289
  89. package/dist/init-eNRlotJK.js.map +0 -1
  90. package/dist/mcp-CLcDV4Jm.cjs +0 -41
  91. package/dist/mcp-CLcDV4Jm.cjs.map +0 -1
  92. package/dist/mcp-D7EIR9fR.js +0 -40
  93. package/dist/mcp-D7EIR9fR.js.map +0 -1
  94. package/dist/mcp-Dakxi9CL.js +0 -16
  95. package/dist/mcp-Dakxi9CL.js.map +0 -1
  96. package/dist/mcp-Dr_RY-hd.cjs +0 -16
  97. package/dist/mcp-Dr_RY-hd.cjs.map +0 -1
  98. package/dist/package-Cdo6lNjF.cjs.map +0 -1
  99. package/dist/package-DPooAj2l.js +0 -6
  100. package/dist/package-DPooAj2l.js.map +0 -1
  101. package/dist/shell-475fQKaX.cjs +0 -62
  102. package/dist/shell-475fQKaX.cjs.map +0 -1
  103. package/dist/shell-DLzN4fRo.js +0 -51
  104. package/dist/shell-DLzN4fRo.js.map +0 -1
  105. package/dist/telemetry-DN95_2pF.cjs +0 -282
  106. package/dist/telemetry-DN95_2pF.cjs.map +0 -1
  107. package/dist/telemetry-LgT_sdPe.js +0 -245
  108. package/dist/telemetry-LgT_sdPe.js.map +0 -1
  109. package/dist/validate-B1o-rY9o.js +0 -25
  110. package/dist/validate-B1o-rY9o.js.map +0 -1
  111. package/dist/validate-CXFY-mHL.cjs +0 -25
  112. package/dist/validate-CXFY-mHL.cjs.map +0 -1
  113. package/dist/validate-kLJoT_hi.js +0 -33
  114. package/dist/validate-kLJoT_hi.js.map +0 -1
  115. package/dist/validate-yKKzqEZ5.cjs +0 -34
  116. package/dist/validate-yKKzqEZ5.cjs.map +0 -1
  117. package/src/commands/agent/start.ts +0 -47
  118. package/src/commands/agent.ts +0 -8
  119. package/src/commands/generate.ts +0 -57
  120. package/src/commands/init.ts +0 -20
  121. package/src/commands/mcp.ts +0 -12
  122. package/src/commands/validate.ts +0 -20
  123. package/src/constants.ts +0 -104
  124. package/src/index.ts +0 -43
  125. package/src/loggers/clackLogger.ts +0 -458
  126. package/src/loggers/fileSystemLogger.ts +0 -138
  127. package/src/loggers/githubActionsLogger.ts +0 -379
  128. package/src/loggers/plainLogger.ts +0 -254
  129. package/src/loggers/types.ts +0 -1
  130. package/src/loggers/utils.ts +0 -106
  131. package/src/runners/agent.ts +0 -149
  132. package/src/runners/generate.ts +0 -333
  133. package/src/runners/init.ts +0 -296
  134. package/src/runners/mcp.ts +0 -45
  135. package/src/runners/validate.ts +0 -39
  136. package/src/types.ts +0 -11
  137. package/src/utils/Writables.ts +0 -17
  138. package/src/utils/executeHooks.ts +0 -45
  139. package/src/utils/flags.ts +0 -9
  140. package/src/utils/getConfig.ts +0 -10
  141. package/src/utils/getCosmiConfig.ts +0 -80
  142. package/src/utils/getSummary.ts +0 -68
  143. package/src/utils/packageManager.ts +0 -23
  144. package/src/utils/runHook.ts +0 -91
  145. package/src/utils/telemetry.ts +0 -273
  146. package/src/utils/watcher.ts +0 -19
  147. /package/dist/{chunk-ByKO4r7w.cjs → rolldown-runtime-Bx3C2hgW.cjs} +0 -0
  148. /package/dist/{chunk--u3MIqq1.js → rolldown-runtime-C0LytTxp.js} +0 -0
@@ -0,0 +1,331 @@
1
+ const require_rolldown_runtime = require("./rolldown-runtime-Bx3C2hgW.cjs");
2
+ let node_crypto = require("node:crypto");
3
+ let node_os = require("node:os");
4
+ node_os = require_rolldown_runtime.__toESM(node_os, 1);
5
+ let node_process = require("node:process");
6
+ node_process = require_rolldown_runtime.__toESM(node_process, 1);
7
+ //#region ../../internals/utils/src/env.ts
8
+ /**
9
+ * Returns `true` when the process is running in a CI environment.
10
+ * Covers GitHub Actions, GitLab CI, CircleCI, Travis CI, Jenkins, Bitbucket,
11
+ * TeamCity, Buildkite, and Azure Pipelines.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * if (isCIEnvironment()) {
16
+ * logger.level = 'error'
17
+ * }
18
+ * ```
19
+ */
20
+ function isCIEnvironment() {
21
+ return !!(process.env.CI || process.env.GITHUB_ACTIONS || process.env.GITLAB_CI || process.env.BITBUCKET_BUILD_NUMBER || process.env.JENKINS_URL || process.env.CIRCLECI || process.env.TRAVIS || process.env.TEAMCITY_VERSION || process.env.BUILDKITE || process.env.TF_BUILD);
22
+ }
23
+ /**
24
+ * Returns `true` when the process has an interactive TTY with a valid terminal
25
+ * width and is not running in CI.
26
+ *
27
+ * Some IDE-embedded terminals report `isTTY = true` but set `columns` to `0`,
28
+ * which breaks clack's box-drawing helpers (they call `String.prototype.repeat`
29
+ * with a negative count and throw a `RangeError`). We therefore require a
30
+ * positive column count before declaring the TTY usable.
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * if (canUseTTY()) {
35
+ * renderProgressBar()
36
+ * }
37
+ * ```
38
+ */
39
+ function canUseTTY() {
40
+ return process.stdout.isTTY && (process.stdout.columns ?? 0) > 0 && !isCIEnvironment();
41
+ }
42
+ //#endregion
43
+ //#region ../../internals/utils/src/runtime.ts
44
+ /**
45
+ * Detects the JavaScript runtime executing the current process and exposes its name and version.
46
+ *
47
+ * Prefer the shared {@link runtime} instance over constructing your own.
48
+ */
49
+ var Runtime = class {
50
+ /**
51
+ * `true` when the current process is running under Bun.
52
+ *
53
+ * Detection keys off the global `Bun` object rather than `process.versions`,
54
+ * because Bun polyfills `process.versions.node` for Node compatibility and would
55
+ * otherwise look like Node.
56
+ *
57
+ * @example
58
+ * ```ts
59
+ * if (runtime.isBun) {
60
+ * await Bun.write(path, data)
61
+ * }
62
+ * ```
63
+ */
64
+ get isBun() {
65
+ return typeof Bun !== "undefined";
66
+ }
67
+ /**
68
+ * `true` when the current process is running under Deno.
69
+ */
70
+ get isDeno() {
71
+ return typeof globalThis.Deno !== "undefined";
72
+ }
73
+ /**
74
+ * `true` when the current process is running under Node.
75
+ *
76
+ * Bun and Deno are excluded first so a polyfilled `process` does not register as Node.
77
+ */
78
+ get isNode() {
79
+ return !this.isBun && !this.isDeno && typeof process !== "undefined" && process.versions?.node != null;
80
+ }
81
+ /**
82
+ * Name of the runtime executing the current process.
83
+ *
84
+ * @example
85
+ * ```ts
86
+ * runtime.name // 'bun' when run with `bun kubb`, 'node' otherwise
87
+ * ```
88
+ */
89
+ get name() {
90
+ if (this.isBun) return "bun";
91
+ if (this.isDeno) return "deno";
92
+ return "node";
93
+ }
94
+ /**
95
+ * Version of the active runtime, or an empty string when it cannot be read.
96
+ *
97
+ * @example
98
+ * ```ts
99
+ * runtime.version // '1.3.11' under Bun, '22.22.2' under Node
100
+ * ```
101
+ */
102
+ get version() {
103
+ if (this.isBun) return process.versions.bun ?? "";
104
+ if (this.isDeno) return globalThis.Deno?.version?.deno ?? "";
105
+ return process.versions?.node ?? "";
106
+ }
107
+ };
108
+ /**
109
+ * Shared {@link Runtime} instance describing the JavaScript runtime executing the current process.
110
+ */
111
+ const runtime = new Runtime();
112
+ //#endregion
113
+ //#region src/constants.ts
114
+ /**
115
+ * NPM registry endpoint used to check for @kubb/cli updates.
116
+ */
117
+ const KUBB_NPM_PACKAGE_URL = "https://registry.npmjs.org/@kubb/cli/latest";
118
+ /**
119
+ * OpenTelemetry ingestion endpoint for anonymous usage telemetry.
120
+ */
121
+ const OTLP_ENDPOINT = "https://otlp.kubb.dev";
122
+ /**
123
+ * Glob pattern for paths the file watcher ignores.
124
+ */
125
+ const WATCHER_IGNORED_PATHS = "**/{.git,node_modules}/**";
126
+ /**
127
+ * Upper bound in milliseconds for the npm update check, so a slow registry never stalls a run.
128
+ */
129
+ const UPDATE_CHECK_TIMEOUT_MS = 3e3;
130
+ /**
131
+ * Flags that short-circuit execution (help and version). The telemetry notice is suppressed for these.
132
+ */
133
+ const QUIET_FLAGS = /* @__PURE__ */ new Set([
134
+ "--help",
135
+ "-h",
136
+ "--version",
137
+ "-v"
138
+ ]);
139
+ //#endregion
140
+ //#region src/Telemetry.ts
141
+ /**
142
+ * Returns `true` when telemetry is disabled via `DO_NOT_TRACK` or `KUBB_DISABLE_TELEMETRY`.
143
+ */
144
+ function isDisabled() {
145
+ return node_process.default.env["DO_NOT_TRACK"] === "1" || node_process.default.env["DO_NOT_TRACK"] === "true" || node_process.default.env["KUBB_DISABLE_TELEMETRY"] === "1" || node_process.default.env["KUBB_DISABLE_TELEMETRY"] === "true";
146
+ }
147
+ /**
148
+ * Build an anonymous telemetry payload from a completed generation run.
149
+ */
150
+ function buildTelemetryEvent(options) {
151
+ const [seconds, nanoseconds] = node_process.default.hrtime(options.hrStart);
152
+ const duration = Math.round(seconds * 1e3 + nanoseconds / 1e6);
153
+ return {
154
+ command: options.command,
155
+ kubbVersion: options.kubbVersion,
156
+ nodeVersion: node_process.default.versions.node.split(".")[0],
157
+ runtime: runtime.name,
158
+ runtimeVersion: runtime.version.split(".")[0],
159
+ platform: node_os.default.platform(),
160
+ ci: isCIEnvironment(),
161
+ plugins: options.plugins ?? [],
162
+ duration,
163
+ filesCreated: options.filesCreated ?? 0,
164
+ status: options.status
165
+ };
166
+ }
167
+ /**
168
+ * Convert a {@link TelemetryEvent} into an OTLP-compatible JSON trace payload.
169
+ *
170
+ * @see https://opentelemetry.io/docs/languages/sdk-configuration/otlp-exporter/
171
+ */
172
+ function buildOtlpPayload(event) {
173
+ const traceId = (0, node_crypto.randomBytes)(16).toString("hex");
174
+ const spanId = (0, node_crypto.randomBytes)(8).toString("hex");
175
+ const endTimeNs = BigInt(Date.now()) * 1000000n;
176
+ const startTimeNs = endTimeNs - BigInt(event.duration) * 1000000n;
177
+ const attributes = [
178
+ {
179
+ key: "kubb.command",
180
+ value: { stringValue: event.command }
181
+ },
182
+ {
183
+ key: "kubb.version",
184
+ value: { stringValue: event.kubbVersion }
185
+ },
186
+ {
187
+ key: "kubb.node_version",
188
+ value: { stringValue: event.nodeVersion }
189
+ },
190
+ {
191
+ key: "kubb.runtime",
192
+ value: { stringValue: event.runtime }
193
+ },
194
+ {
195
+ key: "kubb.runtime_version",
196
+ value: { stringValue: event.runtimeVersion }
197
+ },
198
+ {
199
+ key: "kubb.platform",
200
+ value: { stringValue: event.platform }
201
+ },
202
+ {
203
+ key: "kubb.ci",
204
+ value: { boolValue: event.ci }
205
+ },
206
+ {
207
+ key: "kubb.files_created",
208
+ value: { intValue: event.filesCreated }
209
+ },
210
+ {
211
+ key: "kubb.status",
212
+ value: { stringValue: event.status }
213
+ },
214
+ {
215
+ key: "kubb.plugins",
216
+ value: { arrayValue: { values: event.plugins.map((p) => ({ kvlistValue: { values: [{
217
+ key: "name",
218
+ value: { stringValue: p.name }
219
+ }, {
220
+ key: "options",
221
+ value: { stringValue: JSON.stringify({
222
+ ...p.options,
223
+ usedEnumNames: void 0
224
+ }) }
225
+ }] } })) } }
226
+ }
227
+ ];
228
+ return { resourceSpans: [{
229
+ resource: { attributes: [
230
+ {
231
+ key: "service.name",
232
+ value: { stringValue: "kubb-core" }
233
+ },
234
+ {
235
+ key: "service.version",
236
+ value: { stringValue: event.kubbVersion }
237
+ },
238
+ {
239
+ key: "telemetry.sdk.language",
240
+ value: { stringValue: "nodejs" }
241
+ }
242
+ ] },
243
+ scopeSpans: [{
244
+ scope: {
245
+ name: "kubb-core",
246
+ version: event.kubbVersion
247
+ },
248
+ spans: [{
249
+ traceId,
250
+ spanId,
251
+ name: event.command,
252
+ kind: 1,
253
+ startTimeUnixNano: String(startTimeNs),
254
+ endTimeUnixNano: String(endTimeNs),
255
+ attributes,
256
+ status: { code: event.status === "success" ? 1 : 2 }
257
+ }]
258
+ }]
259
+ }] };
260
+ }
261
+ /**
262
+ * Send an anonymous telemetry event to the Kubb OTLP endpoint. Respects `DO_NOT_TRACK` and
263
+ * `KUBB_DISABLE_TELEMETRY`, and fails silently so telemetry never interrupts a run. No file
264
+ * paths, OpenAPI specs, or secrets are sent.
265
+ */
266
+ async function sendTelemetry(event) {
267
+ if (isDisabled()) return;
268
+ try {
269
+ await fetch(`${OTLP_ENDPOINT}/v1/traces`, {
270
+ method: "POST",
271
+ headers: {
272
+ "Content-Type": "application/json",
273
+ "Kubb-Telemetry-Version": "1",
274
+ "Kubb-Telemetry-Source": "kubb-core"
275
+ },
276
+ body: JSON.stringify(buildOtlpPayload(event)),
277
+ signal: AbortSignal.timeout(5e3)
278
+ });
279
+ } catch (_e) {}
280
+ }
281
+ //#endregion
282
+ Object.defineProperty(exports, "KUBB_NPM_PACKAGE_URL", {
283
+ enumerable: true,
284
+ get: function() {
285
+ return KUBB_NPM_PACKAGE_URL;
286
+ }
287
+ });
288
+ Object.defineProperty(exports, "QUIET_FLAGS", {
289
+ enumerable: true,
290
+ get: function() {
291
+ return QUIET_FLAGS;
292
+ }
293
+ });
294
+ Object.defineProperty(exports, "UPDATE_CHECK_TIMEOUT_MS", {
295
+ enumerable: true,
296
+ get: function() {
297
+ return UPDATE_CHECK_TIMEOUT_MS;
298
+ }
299
+ });
300
+ Object.defineProperty(exports, "WATCHER_IGNORED_PATHS", {
301
+ enumerable: true,
302
+ get: function() {
303
+ return WATCHER_IGNORED_PATHS;
304
+ }
305
+ });
306
+ Object.defineProperty(exports, "buildTelemetryEvent", {
307
+ enumerable: true,
308
+ get: function() {
309
+ return buildTelemetryEvent;
310
+ }
311
+ });
312
+ Object.defineProperty(exports, "canUseTTY", {
313
+ enumerable: true,
314
+ get: function() {
315
+ return canUseTTY;
316
+ }
317
+ });
318
+ Object.defineProperty(exports, "isDisabled", {
319
+ enumerable: true,
320
+ get: function() {
321
+ return isDisabled;
322
+ }
323
+ });
324
+ Object.defineProperty(exports, "sendTelemetry", {
325
+ enumerable: true,
326
+ get: function() {
327
+ return sendTelemetry;
328
+ }
329
+ });
330
+
331
+ //# sourceMappingURL=Telemetry-xcWb-UWT.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Telemetry-xcWb-UWT.cjs","names":["process","os"],"sources":["../../../internals/utils/src/env.ts","../../../internals/utils/src/runtime.ts","../src/constants.ts","../src/Telemetry.ts"],"sourcesContent":["/**\n * Returns `true` when the process is running in a CI environment.\n * Covers GitHub Actions, GitLab CI, CircleCI, Travis CI, Jenkins, Bitbucket,\n * TeamCity, Buildkite, and Azure Pipelines.\n *\n * @example\n * ```ts\n * if (isCIEnvironment()) {\n * logger.level = 'error'\n * }\n * ```\n */\nexport function isCIEnvironment(): boolean {\n return !!(\n process.env.CI ||\n process.env.GITHUB_ACTIONS ||\n process.env.GITLAB_CI ||\n process.env.BITBUCKET_BUILD_NUMBER ||\n process.env.JENKINS_URL ||\n process.env.CIRCLECI ||\n process.env.TRAVIS ||\n process.env.TEAMCITY_VERSION ||\n process.env.BUILDKITE ||\n process.env.TF_BUILD\n )\n}\n\n/**\n * Returns `true` when the process has an interactive TTY with a valid terminal\n * width and is not running in CI.\n *\n * Some IDE-embedded terminals report `isTTY = true` but set `columns` to `0`,\n * which breaks clack's box-drawing helpers (they call `String.prototype.repeat`\n * with a negative count and throw a `RangeError`). We therefore require a\n * positive column count before declaring the TTY usable.\n *\n * @example\n * ```ts\n * if (canUseTTY()) {\n * renderProgressBar()\n * }\n * ```\n */\nexport function canUseTTY(): boolean {\n return process.stdout.isTTY && (process.stdout.columns ?? 0) > 0 && !isCIEnvironment()\n}\n","/**\n * Name of the JavaScript runtime executing the current process.\n */\ntype RuntimeName = 'bun' | 'deno' | 'node'\n\n/**\n * Detects the JavaScript runtime executing the current process and exposes its name and version.\n *\n * Prefer the shared {@link runtime} instance over constructing your own.\n */\nclass Runtime {\n /**\n * `true` when the current process is running under Bun.\n *\n * Detection keys off the global `Bun` object rather than `process.versions`,\n * because Bun polyfills `process.versions.node` for Node compatibility and would\n * otherwise look like Node.\n *\n * @example\n * ```ts\n * if (runtime.isBun) {\n * await Bun.write(path, data)\n * }\n * ```\n */\n get isBun(): boolean {\n return typeof Bun !== 'undefined'\n }\n\n /**\n * `true` when the current process is running under Deno.\n */\n get isDeno(): boolean {\n return typeof (globalThis as { Deno?: unknown }).Deno !== 'undefined'\n }\n\n /**\n * `true` when the current process is running under Node.\n *\n * Bun and Deno are excluded first so a polyfilled `process` does not register as Node.\n */\n get isNode(): boolean {\n return !this.isBun && !this.isDeno && typeof process !== 'undefined' && process.versions?.node != null\n }\n\n /**\n * Name of the runtime executing the current process.\n *\n * @example\n * ```ts\n * runtime.name // 'bun' when run with `bun kubb`, 'node' otherwise\n * ```\n */\n get name(): RuntimeName {\n if (this.isBun) return 'bun'\n if (this.isDeno) return 'deno'\n\n return 'node'\n }\n\n /**\n * Version of the active runtime, or an empty string when it cannot be read.\n *\n * @example\n * ```ts\n * runtime.version // '1.3.11' under Bun, '22.22.2' under Node\n * ```\n */\n get version(): string {\n if (this.isBun) return process.versions.bun ?? ''\n if (this.isDeno) return (globalThis as { Deno?: { version?: { deno?: string } } }).Deno?.version?.deno ?? ''\n\n return process.versions?.node ?? ''\n }\n}\n\n/**\n * Shared {@link Runtime} instance describing the JavaScript runtime executing the current process.\n */\nexport const runtime = new Runtime()\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 * OpenTelemetry ingestion endpoint for anonymous usage telemetry.\n */\nexport const OTLP_ENDPOINT = 'https://otlp.kubb.dev' as const\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 * Quiet window in milliseconds that collapses a burst of watcher events (an editor save emits\n * several) into a single rebuild.\n */\nexport const WATCHER_DEBOUNCE_MS = 100\n\n/**\n * Upper bound in milliseconds for the npm update check, so a slow registry never stalls a run.\n */\nexport const UPDATE_CHECK_TIMEOUT_MS = 3_000\n\n/**\n * Flags that short-circuit execution (help and version). The telemetry notice is suppressed for these.\n */\nexport const QUIET_FLAGS = new Set<string>(['--help', '-h', '--version', '-v'])\n","import { randomBytes } from 'node:crypto'\nimport os from 'node:os'\nimport process from 'node:process'\nimport { isCIEnvironment, runtime } from '@internals/utils'\nimport { OTLP_ENDPOINT } from './constants.ts'\n\ntype OtlpKeyValue = {\n key: string\n value:\n | { stringValue: string }\n | { boolValue: boolean }\n | { intValue: number }\n | { arrayValue: { values: Array<{ kvlistValue: { values: Array<OtlpKeyValue> } }> } }\n | { kvlistValue: { values: Array<OtlpKeyValue> } }\n}\n\ntype OtlpSpan = {\n traceId: string\n spanId: string\n name: string\n kind: 1\n startTimeUnixNano: string\n endTimeUnixNano: string\n attributes: Array<OtlpKeyValue>\n status: { code: 1 | 2 }\n}\n\ntype OtlpExportTraceServiceRequest = {\n resourceSpans: Array<{\n resource: { attributes: Array<OtlpKeyValue> }\n scopeSpans: Array<{\n scope: { name: string; version: string }\n spans: Array<OtlpSpan>\n }>\n }>\n}\n\n/**\n * Anonymous plugin name and options snapshot sent with each telemetry event.\n */\nexport type TelemetryPlugin = {\n /**\n * Plugin name as registered in the Kubb config, e.g. `'@kubb/plugin-ts'`.\n */\n name: string\n /**\n * Anonymized snapshot of the plugin options. Values are included but cannot be traced back to a user.\n */\n options: Record<string, unknown>\n}\n\n/**\n * Anonymous snapshot of a single Kubb run, built by {@link buildTelemetryEvent} and sent by {@link sendTelemetry}.\n */\nexport type TelemetryEvent = {\n command: string\n kubbVersion: string\n /**\n * Major version of Node that executed the run, e.g. `'22'`.\n */\n nodeVersion: string\n /**\n * Name of the JavaScript runtime that executed the run, `'bun'`, `'deno'`, or `'node'`.\n */\n runtime: string\n /**\n * Major version of the active runtime, e.g. `'1'` under Bun or `'22'` under Node.\n */\n runtimeVersion: string\n platform: string\n ci: boolean\n plugins: Array<TelemetryPlugin>\n duration: number\n filesCreated: number\n status: 'success' | 'failed'\n}\n\n/**\n * Returns `true` when telemetry is disabled via `DO_NOT_TRACK` or `KUBB_DISABLE_TELEMETRY`.\n */\nexport function isDisabled(): boolean {\n return (\n process.env['DO_NOT_TRACK'] === '1' ||\n process.env['DO_NOT_TRACK'] === 'true' ||\n process.env['KUBB_DISABLE_TELEMETRY'] === '1' ||\n process.env['KUBB_DISABLE_TELEMETRY'] === 'true'\n )\n}\n\n/**\n * Build an anonymous telemetry payload from a completed generation run.\n */\nexport function buildTelemetryEvent(options: {\n command: 'generate' | 'mcp' | 'validate'\n kubbVersion: string\n plugins?: Array<TelemetryPlugin>\n hrStart: [number, number]\n filesCreated?: number\n status: 'success' | 'failed'\n}): TelemetryEvent {\n const [seconds, nanoseconds] = process.hrtime(options.hrStart)\n const duration = Math.round(seconds * 1000 + nanoseconds / 1e6)\n\n return {\n command: options.command,\n kubbVersion: options.kubbVersion,\n nodeVersion: process.versions.node.split('.')[0] as string,\n runtime: runtime.name,\n runtimeVersion: runtime.version.split('.')[0] as string,\n platform: os.platform(),\n ci: isCIEnvironment(),\n plugins: options.plugins ?? [],\n duration,\n filesCreated: options.filesCreated ?? 0,\n status: options.status,\n }\n}\n\n/**\n * Convert a {@link TelemetryEvent} into an OTLP-compatible JSON trace payload.\n *\n * @see https://opentelemetry.io/docs/languages/sdk-configuration/otlp-exporter/\n */\nexport function buildOtlpPayload(event: TelemetryEvent): OtlpExportTraceServiceRequest {\n const traceId = randomBytes(16).toString('hex')\n const spanId = randomBytes(8).toString('hex')\n const endTimeNs = BigInt(Date.now()) * 1_000_000n\n const startTimeNs = endTimeNs - BigInt(event.duration) * 1_000_000n\n\n const attributes: Array<OtlpKeyValue> = [\n { key: 'kubb.command', value: { stringValue: event.command } },\n { key: 'kubb.version', value: { stringValue: event.kubbVersion } },\n { key: 'kubb.node_version', value: { stringValue: event.nodeVersion } },\n { key: 'kubb.runtime', value: { stringValue: event.runtime } },\n { key: 'kubb.runtime_version', value: { stringValue: event.runtimeVersion } },\n { key: 'kubb.platform', value: { stringValue: event.platform } },\n { key: 'kubb.ci', value: { boolValue: event.ci } },\n { key: 'kubb.files_created', value: { intValue: event.filesCreated } },\n { key: 'kubb.status', value: { stringValue: event.status } },\n {\n key: 'kubb.plugins',\n value: {\n arrayValue: {\n values: event.plugins.map((p) => ({\n kvlistValue: {\n values: [\n { key: 'name', value: { stringValue: p.name } },\n {\n key: 'options',\n value: {\n stringValue: JSON.stringify({\n ...p.options,\n usedEnumNames: undefined,\n }),\n },\n },\n ],\n },\n })),\n },\n },\n },\n ]\n\n return {\n resourceSpans: [\n {\n resource: {\n attributes: [\n { key: 'service.name', value: { stringValue: 'kubb-core' } },\n {\n key: 'service.version',\n value: { stringValue: event.kubbVersion },\n },\n { key: 'telemetry.sdk.language', value: { stringValue: 'nodejs' } },\n ],\n },\n scopeSpans: [\n {\n scope: { name: 'kubb-core', version: event.kubbVersion },\n spans: [\n {\n traceId,\n spanId,\n name: event.command,\n kind: 1,\n startTimeUnixNano: String(startTimeNs),\n endTimeUnixNano: String(endTimeNs),\n attributes,\n status: {\n code: event.status === 'success' ? 1 : 2,\n },\n },\n ],\n },\n ],\n },\n ],\n }\n}\n\n/**\n * Send an anonymous telemetry event to the Kubb OTLP endpoint. Respects `DO_NOT_TRACK` and\n * `KUBB_DISABLE_TELEMETRY`, and fails silently so telemetry never interrupts a run. No file\n * paths, OpenAPI specs, or secrets are sent.\n */\nexport async function sendTelemetry(event: TelemetryEvent): Promise<void> {\n if (isDisabled()) {\n return\n }\n\n try {\n await fetch(`${OTLP_ENDPOINT}/v1/traces`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Kubb-Telemetry-Version': '1',\n 'Kubb-Telemetry-Source': 'kubb-core',\n },\n body: JSON.stringify(buildOtlpPayload(event)),\n signal: AbortSignal.timeout(5_000),\n })\n } catch (_e) {\n // Fail silently, telemetry must never break the run\n }\n}\n"],"mappings":"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"}
@@ -1,4 +1,4 @@
1
- import "./chunk--u3MIqq1.js";
1
+ import "./rolldown-runtime-C0LytTxp.js";
2
2
  //#region ../../internals/utils/src/errors.ts
3
3
  /**
4
4
  * Coerces an unknown thrown value to an `Error` instance.
@@ -15,18 +15,6 @@ function toError(value) {
15
15
  return value instanceof Error ? value : new Error(String(value));
16
16
  }
17
17
  /**
18
- * Extracts a human-readable message from any thrown value.
19
- *
20
- * @example
21
- * ```ts
22
- * getErrorMessage(new Error('oops')) // 'oops'
23
- * getErrorMessage('plain string') // 'plain string'
24
- * ```
25
- */
26
- function getErrorMessage(value) {
27
- return value instanceof Error ? value.message : String(value);
28
- }
29
- /**
30
18
  * Extracts the `.cause` of an `Error` as an `Error`, or `undefined` when absent or not an `Error`.
31
19
  *
32
20
  * @example
@@ -38,6 +26,6 @@ function toCause(error) {
38
26
  return error.cause instanceof Error ? error.cause : void 0;
39
27
  }
40
28
  //#endregion
41
- export { toCause as n, toError as r, getErrorMessage as t };
29
+ export { toError as n, toCause as t };
42
30
 
43
- //# sourceMappingURL=errors-CjPmyZHy.js.map
31
+ //# sourceMappingURL=errors-CMvLO2NE.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors-CjPmyZHy.js","names":[],"sources":["../../../internals/utils/src/errors.ts"],"sourcesContent":["/**\n * Thrown when one or more errors occur during a Kubb build.\n * Carries the full list of underlying errors on `errors`.\n *\n * @example\n * ```ts\n * throw new BuildError('Build failed', { errors: [err1, err2] })\n * ```\n */\nexport class BuildError extends Error {\n errors: Array<Error>\n\n constructor(message: string, options: { cause?: Error; errors: Array<Error> }) {\n super(message, { cause: options.cause })\n this.name = 'BuildError'\n this.errors = options.errors\n }\n}\n\n/**\n * Coerces an unknown thrown value to an `Error` instance.\n * Returns the value as-is when it is already an `Error`; otherwise wraps it with `String(value)`.\n *\n * @example\n * ```ts\n * try { ... } catch(err) {\n * throw new BuildError('Build failed', { cause: toError(err), errors: [] })\n * }\n * ```\n */\nexport function toError(value: unknown): Error {\n return value instanceof Error ? value : new Error(String(value))\n}\n\n/**\n * Extracts a human-readable message from any thrown value.\n *\n * @example\n * ```ts\n * getErrorMessage(new Error('oops')) // 'oops'\n * getErrorMessage('plain string') // 'plain string'\n * ```\n */\nexport function getErrorMessage(value: unknown): string {\n return value instanceof Error ? value.message : String(value)\n}\n\n/**\n * Extracts the `.cause` of an `Error` as an `Error`, or `undefined` when absent or not an `Error`.\n *\n * @example\n * ```ts\n * const cause = toCause(buildError) // Error | undefined\n * ```\n */\nexport function toCause(error: Error): Error | undefined {\n return error.cause instanceof Error ? error.cause : undefined\n}\n"],"mappings":";;;;;;;;;;;;;AA8BA,SAAgB,QAAQ,OAAuB;AAC7C,QAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,MAAM,CAAC;;;;;;;;;;;AAYlE,SAAgB,gBAAgB,OAAwB;AACtD,QAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;;;;;;;;;;AAW/D,SAAgB,QAAQ,OAAiC;AACvD,QAAO,MAAM,iBAAiB,QAAQ,MAAM,QAAQ,KAAA"}
1
+ {"version":3,"file":"errors-CMvLO2NE.js","names":[],"sources":["../../../internals/utils/src/errors.ts"],"sourcesContent":["/**\n * Thrown when one or more errors occur during a Kubb build.\n * Carries the full list of underlying errors on `errors`.\n *\n * @example\n * ```ts\n * throw new BuildError('Build failed', { errors: [err1, err2] })\n * ```\n */\nexport class BuildError extends Error {\n errors: Array<Error>\n\n constructor(message: string, options: { cause?: Error; errors: Array<Error> }) {\n super(message, { cause: options.cause })\n this.name = 'BuildError'\n this.errors = options.errors\n }\n}\n\n/**\n * Coerces an unknown thrown value to an `Error` instance.\n * Returns the value as-is when it is already an `Error`; otherwise wraps it with `String(value)`.\n *\n * @example\n * ```ts\n * try { ... } catch(err) {\n * throw new BuildError('Build failed', { cause: toError(err), errors: [] })\n * }\n * ```\n */\nexport function toError(value: unknown): Error {\n return value instanceof Error ? value : new Error(String(value))\n}\n\n/**\n * Extracts a human-readable message from any thrown value.\n *\n * @example\n * ```ts\n * getErrorMessage(new Error('oops')) // 'oops'\n * getErrorMessage('plain string') // 'plain string'\n * ```\n */\nexport function getErrorMessage(value: unknown): string {\n return value instanceof Error ? value.message : String(value)\n}\n\n/**\n * Extracts the `.cause` of an `Error` as an `Error`, or `undefined` when absent or not an `Error`.\n *\n * @example\n * ```ts\n * const cause = toCause(buildError) // Error | undefined\n * ```\n */\nexport function toCause(error: Error): Error | undefined {\n return error.cause instanceof Error ? error.cause : undefined\n}\n"],"mappings":";;;;;;;;;;;;;AA8BA,SAAgB,QAAQ,OAAuB;CAC7C,OAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC;AACjE;;;;;;;;;AAuBA,SAAgB,QAAQ,OAAiC;CACvD,OAAO,MAAM,iBAAiB,QAAQ,MAAM,QAAQ,KAAA;AACtD"}
@@ -1,4 +1,4 @@
1
- require("./chunk-ByKO4r7w.cjs");
1
+ require("./rolldown-runtime-Bx3C2hgW.cjs");
2
2
  //#region ../../internals/utils/src/errors.ts
3
3
  /**
4
4
  * Coerces an unknown thrown value to an `Error` instance.
@@ -15,18 +15,6 @@ function toError(value) {
15
15
  return value instanceof Error ? value : new Error(String(value));
16
16
  }
17
17
  /**
18
- * Extracts a human-readable message from any thrown value.
19
- *
20
- * @example
21
- * ```ts
22
- * getErrorMessage(new Error('oops')) // 'oops'
23
- * getErrorMessage('plain string') // 'plain string'
24
- * ```
25
- */
26
- function getErrorMessage(value) {
27
- return value instanceof Error ? value.message : String(value);
28
- }
29
- /**
30
18
  * Extracts the `.cause` of an `Error` as an `Error`, or `undefined` when absent or not an `Error`.
31
19
  *
32
20
  * @example
@@ -38,12 +26,6 @@ function toCause(error) {
38
26
  return error.cause instanceof Error ? error.cause : void 0;
39
27
  }
40
28
  //#endregion
41
- Object.defineProperty(exports, "getErrorMessage", {
42
- enumerable: true,
43
- get: function() {
44
- return getErrorMessage;
45
- }
46
- });
47
29
  Object.defineProperty(exports, "toCause", {
48
30
  enumerable: true,
49
31
  get: function() {
@@ -57,4 +39,4 @@ Object.defineProperty(exports, "toError", {
57
39
  }
58
40
  });
59
41
 
60
- //# sourceMappingURL=errors-CLCjoSg0.cjs.map
42
+ //# sourceMappingURL=errors-DNxBUo3k.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors-CLCjoSg0.cjs","names":[],"sources":["../../../internals/utils/src/errors.ts"],"sourcesContent":["/**\n * Thrown when one or more errors occur during a Kubb build.\n * Carries the full list of underlying errors on `errors`.\n *\n * @example\n * ```ts\n * throw new BuildError('Build failed', { errors: [err1, err2] })\n * ```\n */\nexport class BuildError extends Error {\n errors: Array<Error>\n\n constructor(message: string, options: { cause?: Error; errors: Array<Error> }) {\n super(message, { cause: options.cause })\n this.name = 'BuildError'\n this.errors = options.errors\n }\n}\n\n/**\n * Coerces an unknown thrown value to an `Error` instance.\n * Returns the value as-is when it is already an `Error`; otherwise wraps it with `String(value)`.\n *\n * @example\n * ```ts\n * try { ... } catch(err) {\n * throw new BuildError('Build failed', { cause: toError(err), errors: [] })\n * }\n * ```\n */\nexport function toError(value: unknown): Error {\n return value instanceof Error ? value : new Error(String(value))\n}\n\n/**\n * Extracts a human-readable message from any thrown value.\n *\n * @example\n * ```ts\n * getErrorMessage(new Error('oops')) // 'oops'\n * getErrorMessage('plain string') // 'plain string'\n * ```\n */\nexport function getErrorMessage(value: unknown): string {\n return value instanceof Error ? value.message : String(value)\n}\n\n/**\n * Extracts the `.cause` of an `Error` as an `Error`, or `undefined` when absent or not an `Error`.\n *\n * @example\n * ```ts\n * const cause = toCause(buildError) // Error | undefined\n * ```\n */\nexport function toCause(error: Error): Error | undefined {\n return error.cause instanceof Error ? error.cause : undefined\n}\n"],"mappings":";;;;;;;;;;;;;AA8BA,SAAgB,QAAQ,OAAuB;AAC7C,QAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,MAAM,CAAC;;;;;;;;;;;AAYlE,SAAgB,gBAAgB,OAAwB;AACtD,QAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;;;;;;;;;;AAW/D,SAAgB,QAAQ,OAAiC;AACvD,QAAO,MAAM,iBAAiB,QAAQ,MAAM,QAAQ,KAAA"}
1
+ {"version":3,"file":"errors-DNxBUo3k.cjs","names":[],"sources":["../../../internals/utils/src/errors.ts"],"sourcesContent":["/**\n * Thrown when one or more errors occur during a Kubb build.\n * Carries the full list of underlying errors on `errors`.\n *\n * @example\n * ```ts\n * throw new BuildError('Build failed', { errors: [err1, err2] })\n * ```\n */\nexport class BuildError extends Error {\n errors: Array<Error>\n\n constructor(message: string, options: { cause?: Error; errors: Array<Error> }) {\n super(message, { cause: options.cause })\n this.name = 'BuildError'\n this.errors = options.errors\n }\n}\n\n/**\n * Coerces an unknown thrown value to an `Error` instance.\n * Returns the value as-is when it is already an `Error`; otherwise wraps it with `String(value)`.\n *\n * @example\n * ```ts\n * try { ... } catch(err) {\n * throw new BuildError('Build failed', { cause: toError(err), errors: [] })\n * }\n * ```\n */\nexport function toError(value: unknown): Error {\n return value instanceof Error ? value : new Error(String(value))\n}\n\n/**\n * Extracts a human-readable message from any thrown value.\n *\n * @example\n * ```ts\n * getErrorMessage(new Error('oops')) // 'oops'\n * getErrorMessage('plain string') // 'plain string'\n * ```\n */\nexport function getErrorMessage(value: unknown): string {\n return value instanceof Error ? value.message : String(value)\n}\n\n/**\n * Extracts the `.cause` of an `Error` as an `Error`, or `undefined` when absent or not an `Error`.\n *\n * @example\n * ```ts\n * const cause = toCause(buildError) // Error | undefined\n * ```\n */\nexport function toCause(error: Error): Error | undefined {\n return error.cause instanceof Error ? error.cause : undefined\n}\n"],"mappings":";;;;;;;;;;;;;AA8BA,SAAgB,QAAQ,OAAuB;CAC7C,OAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC;AACjE;;;;;;;;;AAuBA,SAAgB,QAAQ,OAAiC;CACvD,OAAO,MAAM,iBAAiB,QAAQ,MAAM,QAAQ,KAAA;AACtD"}
@@ -0,0 +1,95 @@
1
+ require("./rolldown-runtime-Bx3C2hgW.cjs");
2
+ let gunshi = require("gunshi");
3
+ //#region src/commands/generate.ts
4
+ const REPORTER_NAMES = [
5
+ "cli",
6
+ "json",
7
+ "file"
8
+ ];
9
+ /**
10
+ * Splits and validates the comma-separated `--reporter` value against the known reporter names.
11
+ */
12
+ function parseReporters(value) {
13
+ const names = value.split(",").map((name) => name.trim()).filter(Boolean);
14
+ for (const name of names) if (!REPORTER_NAMES.includes(name)) throw new Error(`must be one of cli, json, file (got "${name}")`);
15
+ return names;
16
+ }
17
+ /**
18
+ * Resolves the effective log level, letting the `--verbose` and `--silent` flags win over `--logLevel`.
19
+ */
20
+ function resolveLogLevel({ verbose, silent, logLevel }) {
21
+ if (verbose) return "verbose";
22
+ if (silent) return "silent";
23
+ return logLevel;
24
+ }
25
+ const command = (0, gunshi.define)({
26
+ name: "generate",
27
+ description: "Generate TypeScript types, API clients, React Query hooks, Zod schemas, and more from an OpenAPI specification. Reads kubb.config.ts by default. Pass an OpenAPI file path as the first argument to override the input without editing the config.",
28
+ examples: [
29
+ "kubb generate",
30
+ "kubb generate ./openapi.yaml",
31
+ "kubb generate --config kubb.config.ts",
32
+ "kubb generate --watch"
33
+ ].join("\n"),
34
+ args: {
35
+ input: {
36
+ type: "positional",
37
+ required: false,
38
+ description: "Path to the OpenAPI specification, overriding the config"
39
+ },
40
+ config: {
41
+ type: "string",
42
+ description: "Path to the Kubb config",
43
+ short: "c"
44
+ },
45
+ logLevel: {
46
+ type: "enum",
47
+ choices: [
48
+ "silent",
49
+ "info",
50
+ "verbose"
51
+ ],
52
+ description: "Info, silent or verbose",
53
+ short: "l",
54
+ default: "info"
55
+ },
56
+ watch: {
57
+ type: "boolean",
58
+ description: "Watch mode based on the input file",
59
+ short: "w",
60
+ default: false
61
+ },
62
+ verbose: {
63
+ type: "boolean",
64
+ description: "Override logLevel to verbose",
65
+ default: false
66
+ },
67
+ silent: {
68
+ type: "boolean",
69
+ description: "Override logLevel to silent",
70
+ short: "s",
71
+ default: false
72
+ },
73
+ reporter: {
74
+ type: "custom",
75
+ description: "Reporters that render the run, comma-separated. Overrides config.reporters",
76
+ metavar: "cli|json|file",
77
+ parse: parseReporters
78
+ }
79
+ },
80
+ async run({ values }) {
81
+ const logLevel = resolveLogLevel(values);
82
+ const { run } = await Promise.resolve().then(() => require("./run-HUVxfpGj.cjs"));
83
+ await run({
84
+ input: values.input,
85
+ configPath: values.config,
86
+ logLevel,
87
+ watch: values.watch,
88
+ reporters: values.reporter
89
+ });
90
+ }
91
+ });
92
+ //#endregion
93
+ exports.command = command;
94
+
95
+ //# sourceMappingURL=generate-dIcWEfOA.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-dIcWEfOA.cjs","names":[],"sources":["../src/commands/generate.ts"],"sourcesContent":["import { define } from 'gunshi'\nimport type { ReporterName } from '@kubb/core'\n\nconst REPORTER_NAMES: Array<ReporterName> = ['cli', 'json', 'file']\n\n/**\n * Splits and validates the comma-separated `--reporter` value against the known reporter names.\n */\nfunction parseReporters(value: string): Array<ReporterName> {\n const names = value\n .split(',')\n .map((name) => name.trim())\n .filter(Boolean)\n\n for (const name of names) {\n if (!REPORTER_NAMES.includes(name as ReporterName)) {\n throw new Error(`must be one of cli, json, file (got \"${name}\")`)\n }\n }\n\n return names as Array<ReporterName>\n}\n\n/**\n * Resolves the effective log level, letting the `--verbose` and `--silent` flags win over `--logLevel`.\n */\nfunction resolveLogLevel({ verbose, silent, logLevel }: { verbose: boolean; silent: boolean; logLevel: string }): string {\n if (verbose) return 'verbose'\n if (silent) return 'silent'\n return logLevel\n}\n\nexport const command = define({\n name: 'generate',\n description:\n 'Generate TypeScript types, API clients, React Query hooks, Zod schemas, and more from an OpenAPI specification. Reads kubb.config.ts by default. Pass an OpenAPI file path as the first argument to override the input without editing the config.',\n examples: ['kubb generate', 'kubb generate ./openapi.yaml', 'kubb generate --config kubb.config.ts', 'kubb generate --watch'].join('\\n'),\n args: {\n input: {\n type: 'positional',\n required: false,\n description: 'Path to the OpenAPI specification, overriding the config',\n },\n config: {\n type: 'string',\n description: 'Path to the Kubb config',\n short: 'c',\n },\n logLevel: {\n type: 'enum',\n choices: ['silent', 'info', 'verbose'] as const,\n description: 'Info, silent or verbose',\n short: 'l',\n default: 'info',\n },\n watch: {\n type: 'boolean',\n description: 'Watch mode based on the input file',\n short: 'w',\n default: false,\n },\n verbose: {\n type: 'boolean',\n description: 'Override logLevel to verbose',\n default: false,\n },\n silent: {\n type: 'boolean',\n description: 'Override logLevel to silent',\n short: 's',\n default: false,\n },\n reporter: {\n type: 'custom',\n description: 'Reporters that render the run, comma-separated. Overrides config.reporters',\n metavar: 'cli|json|file',\n parse: parseReporters,\n },\n },\n async run({ values }) {\n const logLevel = resolveLogLevel(values)\n const { run } = await import('../runners/generate/run.ts')\n\n await run({\n input: values.input,\n configPath: values.config,\n logLevel,\n watch: values.watch,\n reporters: values.reporter,\n })\n },\n})\n"],"mappings":";;;AAGA,MAAM,iBAAsC;CAAC;CAAO;CAAQ;AAAM;;;;AAKlE,SAAS,eAAe,OAAoC;CAC1D,MAAM,QAAQ,MACX,MAAM,GAAG,CAAC,CACV,KAAK,SAAS,KAAK,KAAK,CAAC,CAAC,CAC1B,OAAO,OAAO;CAEjB,KAAK,MAAM,QAAQ,OACjB,IAAI,CAAC,eAAe,SAAS,IAAoB,GAC/C,MAAM,IAAI,MAAM,wCAAwC,KAAK,GAAG;CAIpE,OAAO;AACT;;;;AAKA,SAAS,gBAAgB,EAAE,SAAS,QAAQ,YAA6E;CACvH,IAAI,SAAS,OAAO;CACpB,IAAI,QAAQ,OAAO;CACnB,OAAO;AACT;AAEA,MAAa,WAAA,GAAA,OAAA,OAAA,CAAiB;CAC5B,MAAM;CACN,aACE;CACF,UAAU;EAAC;EAAiB;EAAgC;EAAyC;CAAuB,CAAC,CAAC,KAAK,IAAI;CACvI,MAAM;EACJ,OAAO;GACL,MAAM;GACN,UAAU;GACV,aAAa;EACf;EACA,QAAQ;GACN,MAAM;GACN,aAAa;GACb,OAAO;EACT;EACA,UAAU;GACR,MAAM;GACN,SAAS;IAAC;IAAU;IAAQ;GAAS;GACrC,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,OAAO;GACL,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,SAAS;GACP,MAAM;GACN,aAAa;GACb,SAAS;EACX;EACA,QAAQ;GACN,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,UAAU;GACR,MAAM;GACN,aAAa;GACb,SAAS;GACT,OAAO;EACT;CACF;CACA,MAAM,IAAI,EAAE,UAAU;EACpB,MAAM,WAAW,gBAAgB,MAAM;EACvC,MAAM,EAAE,QAAQ,MAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAM,oBAAA,CAAA;EAEtB,MAAM,IAAI;GACR,OAAO,OAAO;GACd,YAAY,OAAO;GACnB;GACA,OAAO,OAAO;GACd,WAAW,OAAO;EACpB,CAAC;CACH;AACF,CAAC"}
@@ -0,0 +1,95 @@
1
+ import "./rolldown-runtime-C0LytTxp.js";
2
+ import { define } from "gunshi";
3
+ //#region src/commands/generate.ts
4
+ const REPORTER_NAMES = [
5
+ "cli",
6
+ "json",
7
+ "file"
8
+ ];
9
+ /**
10
+ * Splits and validates the comma-separated `--reporter` value against the known reporter names.
11
+ */
12
+ function parseReporters(value) {
13
+ const names = value.split(",").map((name) => name.trim()).filter(Boolean);
14
+ for (const name of names) if (!REPORTER_NAMES.includes(name)) throw new Error(`must be one of cli, json, file (got "${name}")`);
15
+ return names;
16
+ }
17
+ /**
18
+ * Resolves the effective log level, letting the `--verbose` and `--silent` flags win over `--logLevel`.
19
+ */
20
+ function resolveLogLevel({ verbose, silent, logLevel }) {
21
+ if (verbose) return "verbose";
22
+ if (silent) return "silent";
23
+ return logLevel;
24
+ }
25
+ const command = define({
26
+ name: "generate",
27
+ description: "Generate TypeScript types, API clients, React Query hooks, Zod schemas, and more from an OpenAPI specification. Reads kubb.config.ts by default. Pass an OpenAPI file path as the first argument to override the input without editing the config.",
28
+ examples: [
29
+ "kubb generate",
30
+ "kubb generate ./openapi.yaml",
31
+ "kubb generate --config kubb.config.ts",
32
+ "kubb generate --watch"
33
+ ].join("\n"),
34
+ args: {
35
+ input: {
36
+ type: "positional",
37
+ required: false,
38
+ description: "Path to the OpenAPI specification, overriding the config"
39
+ },
40
+ config: {
41
+ type: "string",
42
+ description: "Path to the Kubb config",
43
+ short: "c"
44
+ },
45
+ logLevel: {
46
+ type: "enum",
47
+ choices: [
48
+ "silent",
49
+ "info",
50
+ "verbose"
51
+ ],
52
+ description: "Info, silent or verbose",
53
+ short: "l",
54
+ default: "info"
55
+ },
56
+ watch: {
57
+ type: "boolean",
58
+ description: "Watch mode based on the input file",
59
+ short: "w",
60
+ default: false
61
+ },
62
+ verbose: {
63
+ type: "boolean",
64
+ description: "Override logLevel to verbose",
65
+ default: false
66
+ },
67
+ silent: {
68
+ type: "boolean",
69
+ description: "Override logLevel to silent",
70
+ short: "s",
71
+ default: false
72
+ },
73
+ reporter: {
74
+ type: "custom",
75
+ description: "Reporters that render the run, comma-separated. Overrides config.reporters",
76
+ metavar: "cli|json|file",
77
+ parse: parseReporters
78
+ }
79
+ },
80
+ async run({ values }) {
81
+ const logLevel = resolveLogLevel(values);
82
+ const { run } = await import("./run-D-gAS1Vq.js");
83
+ await run({
84
+ input: values.input,
85
+ configPath: values.config,
86
+ logLevel,
87
+ watch: values.watch,
88
+ reporters: values.reporter
89
+ });
90
+ }
91
+ });
92
+ //#endregion
93
+ export { command };
94
+
95
+ //# sourceMappingURL=generate-nPLBd69v.js.map