@kubb/cli 5.0.0-beta.82 → 5.0.0-beta.85

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 (76) hide show
  1. package/dist/{Telemetry-ugO-B77y.js → Telemetry-Cuzoes9Y.js} +6 -2
  2. package/dist/Telemetry-Cuzoes9Y.js.map +1 -0
  3. package/dist/{Telemetry-jtbchpQE.cjs → Telemetry-CwQYBgsg.cjs} +11 -1
  4. package/dist/Telemetry-CwQYBgsg.cjs.map +1 -0
  5. package/dist/{generate-D5AWn6lH.js → generate-C1bIl1nH.js} +34 -24
  6. package/dist/generate-C1bIl1nH.js.map +1 -0
  7. package/dist/{generate-DfzX98Lx.cjs → generate-Cgmty90l.cjs} +34 -23
  8. package/dist/generate-Cgmty90l.cjs.map +1 -0
  9. package/dist/index.cjs +28 -192
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.js +29 -193
  12. package/dist/index.js.map +1 -1
  13. package/dist/{init-hKT7f8_b.cjs → init-DqgB69HY.cjs} +9 -10
  14. package/dist/init-DqgB69HY.cjs.map +1 -0
  15. package/dist/{init-GU5uRenE.js → init-EnhDxlBB.js} +10 -10
  16. package/dist/init-EnhDxlBB.js.map +1 -0
  17. package/dist/{mcp-B3TSdKiQ.js → mcp-5DDTiwIA.js} +6 -6
  18. package/dist/mcp-5DDTiwIA.js.map +1 -0
  19. package/dist/{mcp-B5ppXTnU.cjs → mcp-DYmjmXQb.cjs} +5 -6
  20. package/dist/mcp-DYmjmXQb.cjs.map +1 -0
  21. package/dist/{package-BBBrKion.cjs → package-B57sF1X0.cjs} +2 -2
  22. package/dist/package-B57sF1X0.cjs.map +1 -0
  23. package/dist/package-CQbxcw7I.js +6 -0
  24. package/dist/package-CQbxcw7I.js.map +1 -0
  25. package/dist/{run-DXEMoDFa.cjs → run-3qq_Q4Tg.cjs} +4 -4
  26. package/dist/run-3qq_Q4Tg.cjs.map +1 -0
  27. package/dist/{run-Bz6ZUrhp.cjs → run-B9FN0sHW.cjs} +2 -2
  28. package/dist/run-B9FN0sHW.cjs.map +1 -0
  29. package/dist/{run-CPBFfbI7.js → run-BFhNcn8b.js} +4 -10
  30. package/dist/run-BFhNcn8b.js.map +1 -0
  31. package/dist/{run-B0HOqTrU.js → run-CCsw-Y-v.js} +226 -268
  32. package/dist/run-CCsw-Y-v.js.map +1 -0
  33. package/dist/{run-BBLhhWZu.js → run-D0Gs_UzJ.js} +2 -2
  34. package/dist/run-D0Gs_UzJ.js.map +1 -0
  35. package/dist/{run-C4k6vPeY.cjs → run-DT9pRBLX.cjs} +228 -269
  36. package/dist/run-DT9pRBLX.cjs.map +1 -0
  37. package/dist/{run-DYkciQ4u.cjs → run-DYzUPE7Z.cjs} +4 -10
  38. package/dist/run-DYzUPE7Z.cjs.map +1 -0
  39. package/dist/{run-44Zxh8Ec.js → run-yMRylOST.js} +3 -3
  40. package/dist/run-yMRylOST.js.map +1 -0
  41. package/dist/{tools-D0UogMU3.js → tools-B23ltmWP.js} +3 -3
  42. package/dist/tools-B23ltmWP.js.map +1 -0
  43. package/dist/{tools-CZT9wSA6.cjs → tools-CeIABV0T.cjs} +3 -3
  44. package/dist/tools-CeIABV0T.cjs.map +1 -0
  45. package/dist/{validate-CbWRcTMP.cjs → validate-BTVjxR4L.cjs} +8 -9
  46. package/dist/validate-BTVjxR4L.cjs.map +1 -0
  47. package/dist/{validate-BMaesb7k.js → validate-CZFmahWd.js} +9 -9
  48. package/dist/validate-CZFmahWd.js.map +1 -0
  49. package/package.json +8 -7
  50. package/dist/Telemetry-jtbchpQE.cjs.map +0 -1
  51. package/dist/Telemetry-ugO-B77y.js.map +0 -1
  52. package/dist/defineCommand-Bo3yZTWI.cjs +0 -36
  53. package/dist/defineCommand-Bo3yZTWI.cjs.map +0 -1
  54. package/dist/defineCommand-DMEeqliP.js +0 -31
  55. package/dist/defineCommand-DMEeqliP.js.map +0 -1
  56. package/dist/generate-D5AWn6lH.js.map +0 -1
  57. package/dist/generate-DfzX98Lx.cjs.map +0 -1
  58. package/dist/init-GU5uRenE.js.map +0 -1
  59. package/dist/init-hKT7f8_b.cjs.map +0 -1
  60. package/dist/mcp-B3TSdKiQ.js.map +0 -1
  61. package/dist/mcp-B5ppXTnU.cjs.map +0 -1
  62. package/dist/package-BBBrKion.cjs.map +0 -1
  63. package/dist/package-DSkZlfZS.js +0 -6
  64. package/dist/package-DSkZlfZS.js.map +0 -1
  65. package/dist/run-44Zxh8Ec.js.map +0 -1
  66. package/dist/run-B0HOqTrU.js.map +0 -1
  67. package/dist/run-BBLhhWZu.js.map +0 -1
  68. package/dist/run-Bz6ZUrhp.cjs.map +0 -1
  69. package/dist/run-C4k6vPeY.cjs.map +0 -1
  70. package/dist/run-CPBFfbI7.js.map +0 -1
  71. package/dist/run-DXEMoDFa.cjs.map +0 -1
  72. package/dist/run-DYkciQ4u.cjs.map +0 -1
  73. package/dist/tools-CZT9wSA6.cjs.map +0 -1
  74. package/dist/tools-D0UogMU3.js.map +0 -1
  75. package/dist/validate-BMaesb7k.js.map +0 -1
  76. package/dist/validate-CbWRcTMP.cjs.map +0 -1
@@ -122,6 +122,10 @@ const OTLP_ENDPOINT = "https://otlp.kubb.dev";
122
122
  */
123
123
  const WATCHER_IGNORED_PATHS = "**/{.git,node_modules}/**";
124
124
  /**
125
+ * Upper bound in milliseconds for the npm update check, so a slow registry never stalls a run.
126
+ */
127
+ const UPDATE_CHECK_TIMEOUT_MS = 3e3;
128
+ /**
125
129
  * Flags that short-circuit execution (help and version). The telemetry notice is suppressed for these.
126
130
  */
127
131
  const QUIET_FLAGS = /* @__PURE__ */ new Set([
@@ -279,6 +283,6 @@ var Telemetry = class Telemetry {
279
283
  }
280
284
  };
281
285
  //#endregion
282
- export { canUseTTY as a, WATCHER_IGNORED_PATHS as i, KUBB_NPM_PACKAGE_URL as n, QUIET_FLAGS as r, Telemetry as t };
286
+ export { WATCHER_IGNORED_PATHS as a, UPDATE_CHECK_TIMEOUT_MS as i, KUBB_NPM_PACKAGE_URL as n, canUseTTY as o, QUIET_FLAGS as r, Telemetry as t };
283
287
 
284
- //# sourceMappingURL=Telemetry-ugO-B77y.js.map
288
+ //# sourceMappingURL=Telemetry-Cuzoes9Y.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Telemetry-Cuzoes9Y.js","names":["process"],"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 Telemetry.build} and sent by {@link Telemetry.send}.\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 * Anonymous OTLP usage telemetry for a Kubb run. The API is static, so call it as `Telemetry.build(...)`\n * and `Telemetry.send(...)`. No file paths, OpenAPI specs, or secrets are sent, and sending fails\n * silently so a failed request never breaks the run.\n */\nexport class Telemetry {\n /**\n * Returns `true` when telemetry is disabled via `DO_NOT_TRACK` or `KUBB_DISABLE_TELEMETRY`.\n */\n static get 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 */\n static build(options: {\n command: 'generate' | 'mcp' | 'validate' | 'agent'\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 */\n static 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.\n */\n static async send(event: TelemetryEvent): Promise<void> {\n if (Telemetry.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':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,QAAQ;IACR,SAAS;KACP,gBAAgB;KAChB,0BAA0B;KAC1B,yBAAyB;IAC3B;IACA,MAAM,KAAK,UAAU,UAAU,iBAAiB,KAAK,CAAC;IACtD,QAAQ,YAAY,QAAQ,GAAK;GACnC,CAAC;EACH,SAAS,IAAI,CAEb;CACF;AACF"}
@@ -124,6 +124,10 @@ const OTLP_ENDPOINT = "https://otlp.kubb.dev";
124
124
  */
125
125
  const WATCHER_IGNORED_PATHS = "**/{.git,node_modules}/**";
126
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
+ /**
127
131
  * Flags that short-circuit execution (help and version). The telemetry notice is suppressed for these.
128
132
  */
129
133
  const QUIET_FLAGS = /* @__PURE__ */ new Set([
@@ -299,6 +303,12 @@ Object.defineProperty(exports, "Telemetry", {
299
303
  return Telemetry;
300
304
  }
301
305
  });
306
+ Object.defineProperty(exports, "UPDATE_CHECK_TIMEOUT_MS", {
307
+ enumerable: true,
308
+ get: function() {
309
+ return UPDATE_CHECK_TIMEOUT_MS;
310
+ }
311
+ });
302
312
  Object.defineProperty(exports, "WATCHER_IGNORED_PATHS", {
303
313
  enumerable: true,
304
314
  get: function() {
@@ -312,4 +322,4 @@ Object.defineProperty(exports, "canUseTTY", {
312
322
  }
313
323
  });
314
324
 
315
- //# sourceMappingURL=Telemetry-jtbchpQE.cjs.map
325
+ //# sourceMappingURL=Telemetry-CwQYBgsg.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Telemetry-CwQYBgsg.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 Telemetry.build} and sent by {@link Telemetry.send}.\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 * Anonymous OTLP usage telemetry for a Kubb run. The API is static, so call it as `Telemetry.build(...)`\n * and `Telemetry.send(...)`. No file paths, OpenAPI specs, or secrets are sent, and sending fails\n * silently so a failed request never breaks the run.\n */\nexport class Telemetry {\n /**\n * Returns `true` when telemetry is disabled via `DO_NOT_TRACK` or `KUBB_DISABLE_TELEMETRY`.\n */\n static get 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 */\n static build(options: {\n command: 'generate' | 'mcp' | 'validate' | 'agent'\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 */\n static 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.\n */\n static async send(event: TelemetryEvent): Promise<void> {\n if (Telemetry.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(Telemetry.buildOtlpPayload(event)),\n signal: AbortSignal.timeout(5_000),\n })\n } catch (_e) {\n // Fail silently, telemetry must never break the run\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAYA,SAAgB,kBAA2B;CACzC,OAAO,CAAC,EACN,QAAQ,IAAI,MACZ,QAAQ,IAAI,kBACZ,QAAQ,IAAI,aACZ,QAAQ,IAAI,0BACZ,QAAQ,IAAI,eACZ,QAAQ,IAAI,YACZ,QAAQ,IAAI,UACZ,QAAQ,IAAI,oBACZ,QAAQ,IAAI,aACZ,QAAQ,IAAI;AAEhB;;;;;;;;;;;;;;;;;AAkBA,SAAgB,YA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OAAO,EACL,YAAY,EACV,QAAQ,MAAM,QAAQ,KAAK,OAAO,EAChC,aAAa,EACX,QAAQ,CACN;KAAE,KAAK;KAAQ,OAAO,EAAE,aAAa,EAAE,KAAK;IAAE,GAC9C;KACE,KAAK;KACL,OAAO,EACL,aAAa,KAAK,UAAU;MAC1B,GAAG,EAAE;MACL,eAAe,KAAA;KACjB,CAAC,EACH;IACF,CACF,EACF,EACF,EAAE,EACJ,EACF;GACF;EACF;EAEA,OAAO,EACL,eAAe,CACb;GACE,UAAU,EACR,YAAY;IACV;KAAE,KAAK;KAAgB,OAAO,EAAE,aAAa,YAAY;IAAE;IAC3D;KACE,KAAK;KACL,OAAO,EAAE,aAAa,MAAM,YAAY;IAC1C;IACA;KAAE,KAAK;KAA0B,OAAO,EAAE,aAAa,SAAS;IAAE;GACpE,EACF;GACA,YAAY,CACV;IACE,OAAO;KAAE,MAAM;KAAa,SAAS,MAAM;IAAY;IACvD,OAAO,CACL;KACE;KACA;KACA,MAAM,MAAM;KACZ,MAAM;KACN,mBAAmB,OAAO,WAAW;KACrC,iBAAiB,OAAO,SAAS;KACjC;KACA,QAAQ,EACN,MAAM,MAAM,WAAW,YAAY,IAAI,EACzC;IACF,CACF;GACF,CACF;EACF,CACF,EACF;CACF;;;;;CAMA,aAAa,KAAK,OAAsC;EACtD,IAAI,UAAU,YACZ;EAGF,IAAI;GACF,MAAM,MAAM,GAAG,cAAc,aAAa;IACxC,QAAQ;IACR,SAAS;KACP,gBAAgB;KAChB,0BAA0B;KAC1B,yBAAyB;IAC3B;IACA,MAAM,KAAK,UAAU,UAAU,iBAAiB,KAAK,CAAC;IACtD,QAAQ,YAAY,QAAQ,GAAK;GACnC,CAAC;EACH,SAAS,IAAI,CAEb;CACF;AACF"}
@@ -1,33 +1,49 @@
1
1
  import "./rolldown-runtime-C0LytTxp.js";
2
- import { t as defineCommand } from "./defineCommand-DMEeqliP.js";
2
+ import { define } from "gunshi";
3
3
  //#region src/commands/generate.ts
4
- const command = defineCommand({
4
+ const REPORTER_NAMES = [
5
+ "cli",
6
+ "json",
7
+ "file"
8
+ ];
9
+ /**
10
+ * Splits and validates the comma-separated `--reporter` value against the known reporter names.
11
+ */
12
+ function parseReporters(value) {
13
+ const names = value.split(",").map((name) => name.trim()).filter(Boolean);
14
+ for (const name of names) if (!REPORTER_NAMES.includes(name)) throw new Error(`must be one of cli, json, file (got "${name}")`);
15
+ return names;
16
+ }
17
+ const command = define({
5
18
  name: "generate",
6
19
  description: "Generate TypeScript types, API clients, React Query hooks, Zod schemas, and more from an OpenAPI specification. Reads kubb.config.ts by default. Pass an OpenAPI file path as the first argument to override the input without editing the config.",
7
- arguments: ["[input]"],
8
20
  examples: [
9
21
  "kubb generate",
10
22
  "kubb generate ./openapi.yaml",
11
23
  "kubb generate --config kubb.config.ts",
12
24
  "kubb generate --watch"
13
- ],
14
- options: {
25
+ ].join("\n"),
26
+ args: {
27
+ input: {
28
+ type: "positional",
29
+ required: false,
30
+ description: "Path to the OpenAPI specification, overriding the config"
31
+ },
15
32
  config: {
16
33
  type: "string",
17
34
  description: "Path to the Kubb config",
18
35
  short: "c"
19
36
  },
20
37
  logLevel: {
21
- type: "string",
22
- description: "Info, silent or verbose",
23
- short: "l",
24
- default: "info",
25
- hint: "silent|info|verbose",
26
- enum: [
38
+ type: "enum",
39
+ choices: [
27
40
  "silent",
28
41
  "info",
29
42
  "verbose"
30
- ]
43
+ ],
44
+ description: "Info, silent or verbose",
45
+ short: "l",
46
+ default: "info"
31
47
  },
32
48
  watch: {
33
49
  type: "boolean",
@@ -38,7 +54,6 @@ const command = defineCommand({
38
54
  verbose: {
39
55
  type: "boolean",
40
56
  description: "Override logLevel to verbose",
41
- short: "v",
42
57
  default: false
43
58
  },
44
59
  silent: {
@@ -48,30 +63,25 @@ const command = defineCommand({
48
63
  default: false
49
64
  },
50
65
  reporter: {
51
- type: "string",
66
+ type: "custom",
52
67
  description: "Reporters that render the run, comma-separated. Overrides config.reporters",
53
- hint: "cli|json|file",
54
- enum: [
55
- "cli",
56
- "json",
57
- "file"
58
- ]
68
+ metavar: "cli|json|file",
69
+ parse: parseReporters
59
70
  }
60
71
  },
61
72
  async run({ values, positionals }) {
62
73
  const logLevel = values.verbose ? "verbose" : values.silent ? "silent" : values.logLevel;
63
- const reporters = values.reporter?.split(",").map((name) => name.trim()).filter(Boolean);
64
- const { run } = await import("./run-B0HOqTrU.js");
74
+ const { run } = await import("./run-CCsw-Y-v.js");
65
75
  await run({
66
76
  input: positionals[0],
67
77
  configPath: values.config,
68
78
  logLevel,
69
79
  watch: values.watch,
70
- reporters
80
+ reporters: values.reporter
71
81
  });
72
82
  }
73
83
  });
74
84
  //#endregion
75
85
  export { command };
76
86
 
77
- //# sourceMappingURL=generate-D5AWn6lH.js.map
87
+ //# sourceMappingURL=generate-C1bIl1nH.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-C1bIl1nH.js","names":[],"sources":["../src/commands/generate.ts"],"sourcesContent":["import { define } from 'gunshi'\nimport type { ReporterName } from '@kubb/core'\n\nconst REPORTER_NAMES: Array<ReporterName> = ['cli', 'json', 'file']\n\n/**\n * Splits and validates the comma-separated `--reporter` value against the known reporter names.\n */\nfunction parseReporters(value: string): Array<ReporterName> {\n const names = value\n .split(',')\n .map((name) => name.trim())\n .filter(Boolean)\n\n for (const name of names) {\n if (!REPORTER_NAMES.includes(name as ReporterName)) {\n throw new Error(`must be one of cli, json, file (got \"${name}\")`)\n }\n }\n\n return names as Array<ReporterName>\n}\n\nexport const command = define({\n name: 'generate',\n description:\n 'Generate TypeScript types, API clients, React Query hooks, Zod schemas, and more from an OpenAPI specification. Reads kubb.config.ts by default. Pass an OpenAPI file path as the first argument to override the input without editing the config.',\n examples: ['kubb generate', 'kubb generate ./openapi.yaml', 'kubb generate --config kubb.config.ts', 'kubb generate --watch'].join('\\n'),\n args: {\n input: {\n type: 'positional',\n required: false,\n description: 'Path to the OpenAPI specification, overriding the config',\n },\n config: {\n type: 'string',\n description: 'Path to the Kubb config',\n short: 'c',\n },\n logLevel: {\n type: 'enum',\n choices: ['silent', 'info', 'verbose'] as const,\n description: 'Info, silent or verbose',\n short: 'l',\n default: 'info',\n },\n watch: {\n type: 'boolean',\n description: 'Watch mode based on the input file',\n short: 'w',\n default: false,\n },\n verbose: {\n type: 'boolean',\n description: 'Override logLevel to verbose',\n default: false,\n },\n silent: {\n type: 'boolean',\n description: 'Override logLevel to silent',\n short: 's',\n default: false,\n },\n reporter: {\n type: 'custom',\n description: 'Reporters that render the run, comma-separated. Overrides config.reporters',\n metavar: 'cli|json|file',\n parse: parseReporters,\n },\n },\n async run({ values, positionals }) {\n const logLevel = values.verbose ? 'verbose' : values.silent ? 'silent' : values.logLevel\n const { run } = await import('../runners/generate/run.ts')\n\n await run({\n input: positionals[0],\n configPath: values.config,\n logLevel,\n watch: values.watch,\n reporters: values.reporter,\n })\n },\n})\n"],"mappings":";;;AAGA,MAAM,iBAAsC;CAAC;CAAO;CAAQ;AAAM;;;;AAKlE,SAAS,eAAe,OAAoC;CAC1D,MAAM,QAAQ,MACX,MAAM,GAAG,CAAC,CACV,KAAK,SAAS,KAAK,KAAK,CAAC,CAAC,CAC1B,OAAO,OAAO;CAEjB,KAAK,MAAM,QAAQ,OACjB,IAAI,CAAC,eAAe,SAAS,IAAoB,GAC/C,MAAM,IAAI,MAAM,wCAAwC,KAAK,GAAG;CAIpE,OAAO;AACT;AAEA,MAAa,UAAU,OAAO;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,QAAQ,eAAe;EACjC,MAAM,WAAW,OAAO,UAAU,YAAY,OAAO,SAAS,WAAW,OAAO;EAChF,MAAM,EAAE,QAAQ,MAAM,OAAO;EAE7B,MAAM,IAAI;GACR,OAAO,YAAY;GACnB,YAAY,OAAO;GACnB;GACA,OAAO,OAAO;GACd,WAAW,OAAO;EACpB,CAAC;CACH;AACF,CAAC"}
@@ -1,32 +1,49 @@
1
1
  require("./rolldown-runtime-Bx3C2hgW.cjs");
2
+ let gunshi = require("gunshi");
2
3
  //#region src/commands/generate.ts
3
- const command = require("./defineCommand-Bo3yZTWI.cjs").defineCommand({
4
+ const REPORTER_NAMES = [
5
+ "cli",
6
+ "json",
7
+ "file"
8
+ ];
9
+ /**
10
+ * Splits and validates the comma-separated `--reporter` value against the known reporter names.
11
+ */
12
+ function parseReporters(value) {
13
+ const names = value.split(",").map((name) => name.trim()).filter(Boolean);
14
+ for (const name of names) if (!REPORTER_NAMES.includes(name)) throw new Error(`must be one of cli, json, file (got "${name}")`);
15
+ return names;
16
+ }
17
+ const command = (0, gunshi.define)({
4
18
  name: "generate",
5
19
  description: "Generate TypeScript types, API clients, React Query hooks, Zod schemas, and more from an OpenAPI specification. Reads kubb.config.ts by default. Pass an OpenAPI file path as the first argument to override the input without editing the config.",
6
- arguments: ["[input]"],
7
20
  examples: [
8
21
  "kubb generate",
9
22
  "kubb generate ./openapi.yaml",
10
23
  "kubb generate --config kubb.config.ts",
11
24
  "kubb generate --watch"
12
- ],
13
- options: {
25
+ ].join("\n"),
26
+ args: {
27
+ input: {
28
+ type: "positional",
29
+ required: false,
30
+ description: "Path to the OpenAPI specification, overriding the config"
31
+ },
14
32
  config: {
15
33
  type: "string",
16
34
  description: "Path to the Kubb config",
17
35
  short: "c"
18
36
  },
19
37
  logLevel: {
20
- type: "string",
21
- description: "Info, silent or verbose",
22
- short: "l",
23
- default: "info",
24
- hint: "silent|info|verbose",
25
- enum: [
38
+ type: "enum",
39
+ choices: [
26
40
  "silent",
27
41
  "info",
28
42
  "verbose"
29
- ]
43
+ ],
44
+ description: "Info, silent or verbose",
45
+ short: "l",
46
+ default: "info"
30
47
  },
31
48
  watch: {
32
49
  type: "boolean",
@@ -37,7 +54,6 @@ const command = require("./defineCommand-Bo3yZTWI.cjs").defineCommand({
37
54
  verbose: {
38
55
  type: "boolean",
39
56
  description: "Override logLevel to verbose",
40
- short: "v",
41
57
  default: false
42
58
  },
43
59
  silent: {
@@ -47,30 +63,25 @@ const command = require("./defineCommand-Bo3yZTWI.cjs").defineCommand({
47
63
  default: false
48
64
  },
49
65
  reporter: {
50
- type: "string",
66
+ type: "custom",
51
67
  description: "Reporters that render the run, comma-separated. Overrides config.reporters",
52
- hint: "cli|json|file",
53
- enum: [
54
- "cli",
55
- "json",
56
- "file"
57
- ]
68
+ metavar: "cli|json|file",
69
+ parse: parseReporters
58
70
  }
59
71
  },
60
72
  async run({ values, positionals }) {
61
73
  const logLevel = values.verbose ? "verbose" : values.silent ? "silent" : values.logLevel;
62
- const reporters = values.reporter?.split(",").map((name) => name.trim()).filter(Boolean);
63
- const { run } = await Promise.resolve().then(() => require("./run-C4k6vPeY.cjs"));
74
+ const { run } = await Promise.resolve().then(() => require("./run-DT9pRBLX.cjs"));
64
75
  await run({
65
76
  input: positionals[0],
66
77
  configPath: values.config,
67
78
  logLevel,
68
79
  watch: values.watch,
69
- reporters
80
+ reporters: values.reporter
70
81
  });
71
82
  }
72
83
  });
73
84
  //#endregion
74
85
  exports.command = command;
75
86
 
76
- //# sourceMappingURL=generate-DfzX98Lx.cjs.map
87
+ //# sourceMappingURL=generate-Cgmty90l.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-Cgmty90l.cjs","names":[],"sources":["../src/commands/generate.ts"],"sourcesContent":["import { define } from 'gunshi'\nimport type { ReporterName } from '@kubb/core'\n\nconst REPORTER_NAMES: Array<ReporterName> = ['cli', 'json', 'file']\n\n/**\n * Splits and validates the comma-separated `--reporter` value against the known reporter names.\n */\nfunction parseReporters(value: string): Array<ReporterName> {\n const names = value\n .split(',')\n .map((name) => name.trim())\n .filter(Boolean)\n\n for (const name of names) {\n if (!REPORTER_NAMES.includes(name as ReporterName)) {\n throw new Error(`must be one of cli, json, file (got \"${name}\")`)\n }\n }\n\n return names as Array<ReporterName>\n}\n\nexport const command = define({\n name: 'generate',\n description:\n 'Generate TypeScript types, API clients, React Query hooks, Zod schemas, and more from an OpenAPI specification. Reads kubb.config.ts by default. Pass an OpenAPI file path as the first argument to override the input without editing the config.',\n examples: ['kubb generate', 'kubb generate ./openapi.yaml', 'kubb generate --config kubb.config.ts', 'kubb generate --watch'].join('\\n'),\n args: {\n input: {\n type: 'positional',\n required: false,\n description: 'Path to the OpenAPI specification, overriding the config',\n },\n config: {\n type: 'string',\n description: 'Path to the Kubb config',\n short: 'c',\n },\n logLevel: {\n type: 'enum',\n choices: ['silent', 'info', 'verbose'] as const,\n description: 'Info, silent or verbose',\n short: 'l',\n default: 'info',\n },\n watch: {\n type: 'boolean',\n description: 'Watch mode based on the input file',\n short: 'w',\n default: false,\n },\n verbose: {\n type: 'boolean',\n description: 'Override logLevel to verbose',\n default: false,\n },\n silent: {\n type: 'boolean',\n description: 'Override logLevel to silent',\n short: 's',\n default: false,\n },\n reporter: {\n type: 'custom',\n description: 'Reporters that render the run, comma-separated. Overrides config.reporters',\n metavar: 'cli|json|file',\n parse: parseReporters,\n },\n },\n async run({ values, positionals }) {\n const logLevel = values.verbose ? 'verbose' : values.silent ? 'silent' : values.logLevel\n const { run } = await import('../runners/generate/run.ts')\n\n await run({\n input: positionals[0],\n configPath: values.config,\n logLevel,\n watch: values.watch,\n reporters: values.reporter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1,188 +1,19 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  require("./rolldown-runtime-Bx3C2hgW.cjs");
3
- const require_Telemetry = require("./Telemetry-jtbchpQE.cjs");
4
- const require_package = require("./package-BBBrKion.cjs");
3
+ const require_Telemetry = require("./Telemetry-CwQYBgsg.cjs");
4
+ const require_package = require("./package-B57sF1X0.cjs");
5
5
  let node_util = require("node:util");
6
- //#region ../../internals/utils/src/cli/renderHelp.ts
7
- function formatFlags(name, opt) {
8
- return `${opt.short ? `-${opt.short}, ` : ""}--${name}${opt.type === "string" ? ` <${opt.hint ?? name}>` : ""}`;
9
- }
10
- /** Prints formatted help output for `def` using its `CommandDefinition`.
11
- *
12
- * @example
13
- * ```ts
14
- * renderHelp({ name: 'generate', description: 'Generate client code' })
15
- * // prints Usage: generate [options] ...
16
- * ```
17
- */
18
- function renderHelp(def, parentName) {
19
- const programName = parentName ? `${parentName} ${def.name}` : def.name;
20
- const subCommands = def.subCommands ?? [];
21
- const argsPart = def.arguments?.length ? ` ${def.arguments.join(" ")}` : "";
22
- const subCmdPart = subCommands.length ? " <command>" : "";
23
- console.log(`\n${(0, node_util.styleText)("bold", "Usage:")} ${programName}${argsPart}${subCmdPart} [options]\n`);
24
- if (def.description) console.log(` ${def.description}\n`);
25
- if (subCommands.length) {
26
- console.log((0, node_util.styleText)("bold", "Commands:"));
27
- for (const sub of subCommands) console.log(` ${(0, node_util.styleText)("cyan", sub.name.padEnd(16))}${sub.description}`);
28
- console.log();
29
- }
30
- const options = [...Object.entries(def.options ?? {}).map(([name, opt]) => ({
31
- flags: formatFlags(name, opt),
32
- description: opt.description,
33
- default: opt.default
34
- })), {
35
- flags: "-h, --help",
36
- description: "Show help"
37
- }];
38
- console.log((0, node_util.styleText)("bold", "Options:"));
39
- for (const opt of options) {
40
- const flags = (0, node_util.styleText)("cyan", opt.flags.padEnd(30));
41
- const defaultPart = opt.default !== void 0 ? (0, node_util.styleText)("dim", ` (default: ${opt.default})`) : "";
42
- console.log(` ${flags}${opt.description}${defaultPart}`);
43
- }
44
- console.log();
45
- if (def.examples?.length) {
46
- console.log((0, node_util.styleText)("bold", "Examples:"));
47
- for (const ex of def.examples) console.log(` ${(0, node_util.styleText)("dim", ex)}`);
48
- console.log();
49
- }
50
- }
51
- //#endregion
52
- //#region ../../internals/utils/src/cli/runCLI.ts
53
- function buildParseOptions(def) {
54
- const result = { help: {
55
- type: "boolean",
56
- short: "h"
57
- } };
58
- for (const [name, opt] of Object.entries(def.options ?? {})) result[name] = {
59
- type: opt.type,
60
- ...opt.short ? { short: opt.short } : {},
61
- ...opt.default !== void 0 ? { default: opt.default } : {}
62
- };
63
- return result;
64
- }
65
- async function runCommand(def, argv, parentName) {
66
- const parseOptions = buildParseOptions(def);
67
- let parsed;
68
- try {
69
- const result = (0, node_util.parseArgs)({
70
- args: argv,
71
- options: parseOptions,
72
- allowPositionals: true,
73
- strict: false
74
- });
75
- parsed = {
76
- values: result.values,
77
- positionals: result.positionals
78
- };
79
- } catch {
80
- renderHelp(def, parentName);
81
- process.exit(1);
82
- }
83
- if (parsed.values["help"]) {
84
- renderHelp(def, parentName);
85
- process.exit(0);
86
- }
87
- for (const [name, opt] of Object.entries(def.options ?? {})) if (opt.required && parsed.values[name] === void 0) {
88
- console.error((0, node_util.styleText)("red", `Error: --${name} is required`));
89
- renderHelp(def, parentName);
90
- process.exit(1);
91
- }
92
- if (!def.run) {
93
- renderHelp(def, parentName);
94
- process.exit(0);
95
- }
96
- try {
97
- await def.run(parsed);
98
- } catch (err) {
99
- console.error((0, node_util.styleText)("red", `Error: ${err instanceof Error ? err.message : String(err)}`));
100
- renderHelp(def, parentName);
101
- process.exit(1);
102
- }
103
- }
104
- function printRootHelp(programName, version, defs) {
105
- console.log(`\n${(0, node_util.styleText)("bold", "Usage:")} ${programName} <command> [options]\n`);
106
- console.log(` Kubb v${version} — Generate TypeScript types, API clients, React Query hooks,`);
107
- console.log(` Zod schemas, and more from an OpenAPI specification.\n`);
108
- console.log(` Quick start: ${(0, node_util.styleText)("cyan", `${programName} init`)} to scaffold a config, then ${(0, node_util.styleText)("cyan", `${programName} generate`)} to run.\n`);
109
- console.log((0, node_util.styleText)("bold", "Commands:"));
110
- for (const def of defs) console.log(` ${(0, node_util.styleText)("cyan", def.name.padEnd(16))}${def.description}`);
111
- console.log();
112
- console.log((0, node_util.styleText)("bold", "Options:"));
113
- console.log(` ${(0, node_util.styleText)("cyan", "-v, --version".padEnd(30))}Show version number`);
114
- console.log(` ${(0, node_util.styleText)("cyan", "-h, --help".padEnd(30))}Show help`);
115
- console.log();
116
- console.log(`Run ${(0, node_util.styleText)("cyan", `${programName} <command> --help`)} for command-specific help.\n`);
117
- }
6
+ let gunshi = require("gunshi");
7
+ //#region src/index.ts
118
8
  /**
119
- * Parses `argv` and runs the matching command using `node:util parseArgs`. No external dependencies.
120
- * Falls back to `defaultCommandName` when no command is given.
121
- *
122
- * @example
123
- * ```ts
124
- * await runCLI(commands, process.argv, {
125
- * programName: 'kubb',
126
- * defaultCommandName: 'generate',
127
- * version: '5.0.0',
128
- * })
129
- * ```
9
+ * Strips the leading executable + script entries when `process.argv` is passed directly.
10
+ * Handles Node.js (`/usr/bin/node`), Bun (`/usr/local/bin/bun`), Deno, tsx, etc. All runtime
11
+ * executable paths contain a path separator; bare command names do not.
130
12
  */
131
- async function runCLI(defs, argv, opts) {
132
- const { programName, defaultCommandName, version } = opts;
13
+ function stripExecArgs(argv) {
133
14
  const firstArgIsExecutablePath = (argv[0]?.includes("/") || argv[0]?.includes("\\")) ?? false;
134
- const args = argv.length >= 2 && firstArgIsExecutablePath ? argv.slice(2) : argv;
135
- if (args[0] === "--version" || args[0] === "-v") {
136
- console.log(version);
137
- process.exit(0);
138
- }
139
- if (args[0] === "--help" || args[0] === "-h") {
140
- printRootHelp(programName, version, defs);
141
- process.exit(0);
142
- }
143
- if (args.length === 0) {
144
- const defaultDef = defs.find((d) => d.name === defaultCommandName);
145
- if (defaultDef?.run) await runCommand(defaultDef, [], programName);
146
- else printRootHelp(programName, version, defs);
147
- return;
148
- }
149
- const [first, ...rest] = args;
150
- const isKnownSubcommand = defs.some((d) => d.name === first);
151
- let def;
152
- let commandArgv;
153
- let parentName;
154
- if (isKnownSubcommand) {
155
- def = defs.find((d) => d.name === first);
156
- commandArgv = rest;
157
- parentName = programName;
158
- } else {
159
- def = defs.find((d) => d.name === defaultCommandName);
160
- commandArgv = args;
161
- parentName = programName;
162
- }
163
- if (!def) {
164
- console.error(`Unknown command: ${first}`);
165
- printRootHelp(programName, version, defs);
166
- process.exit(1);
167
- }
168
- if (def.subCommands?.length) {
169
- const [subName, ...subRest] = commandArgv;
170
- const subDef = def.subCommands.find((s) => s.name === subName);
171
- if (subName === "--help" || subName === "-h") {
172
- renderHelp(def, parentName);
173
- process.exit(0);
174
- }
175
- if (!subDef) {
176
- renderHelp(def, parentName);
177
- process.exit(subName ? 1 : 0);
178
- }
179
- await runCommand(subDef, subRest, `${parentName} ${def.name}`);
180
- return;
181
- }
182
- await runCommand(def, commandArgv, parentName);
15
+ return argv.length >= 2 && firstArgIsExecutablePath ? argv.slice(2) : argv;
183
16
  }
184
- //#endregion
185
- //#region src/index.ts
186
17
  /**
187
18
  * Entry point for the `kubb` CLI. Prints the telemetry notice unless telemetry is disabled or a
188
19
  * quiet flag is passed, then runs the generate, validate, mcp, and init commands. Defaults to
@@ -191,20 +22,25 @@ async function runCLI(defs, argv, opts) {
191
22
  async function run(argv = process.argv) {
192
23
  const isQuietFlag = argv.some((arg) => require_Telemetry.QUIET_FLAGS.has(arg));
193
24
  if (!require_Telemetry.Telemetry.isDisabled && !isQuietFlag) console.log(`${(0, node_util.styleText)("yellow", "Notice:")} Kubb collects anonymous telemetry data to help improve the tool. No personal data or file contents are collected. \nTo disable, set ${(0, node_util.styleText)("cyan", "KUBB_DISABLE_TELEMETRY=1")}.\n`);
194
- const { command: generateCommand } = await Promise.resolve().then(() => require("./generate-DfzX98Lx.cjs"));
195
- const { command: validateCommand } = await Promise.resolve().then(() => require("./validate-CbWRcTMP.cjs"));
196
- const { command: mcpCommand } = await Promise.resolve().then(() => require("./mcp-B5ppXTnU.cjs"));
197
- const { command: initCommand } = await Promise.resolve().then(() => require("./init-hKT7f8_b.cjs"));
198
- await runCLI([
199
- generateCommand,
200
- validateCommand,
201
- mcpCommand,
202
- initCommand
203
- ], argv, {
204
- programName: "kubb",
205
- defaultCommandName: "generate",
206
- version: require_package.version
207
- });
25
+ const { command: generateCommand } = await Promise.resolve().then(() => require("./generate-Cgmty90l.cjs"));
26
+ const { command: validateCommand } = await Promise.resolve().then(() => require("./validate-BTVjxR4L.cjs"));
27
+ const { command: mcpCommand } = await Promise.resolve().then(() => require("./mcp-DYmjmXQb.cjs"));
28
+ const { command: initCommand } = await Promise.resolve().then(() => require("./init-DqgB69HY.cjs"));
29
+ try {
30
+ await (0, gunshi.cli)(stripExecArgs(argv), generateCommand, {
31
+ name: "kubb",
32
+ version: require_package.version,
33
+ description: generateCommand.description,
34
+ subCommands: {
35
+ init: initCommand,
36
+ validate: validateCommand,
37
+ mcp: mcpCommand
38
+ },
39
+ fallbackToEntry: true
40
+ });
41
+ } catch {
42
+ process.exit(1);
43
+ }
208
44
  }
209
45
  //#endregion
210
46
  exports.run = run;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["QUIET_FLAGS","Telemetry"],"sources":["../../../internals/utils/src/cli/renderHelp.ts","../../../internals/utils/src/cli/runCLI.ts","../src/index.ts"],"sourcesContent":["import { styleText } from 'node:util'\nimport type { CommandDefinition, OptionDefinition } from './defineCommand.ts'\n\nfunction formatFlags(name: string, opt: OptionDefinition): string {\n const short = opt.short ? `-${opt.short}, ` : ''\n const value = opt.type === 'string' ? ` <${opt.hint ?? name}>` : ''\n return `${short}--${name}${value}`\n}\n\n/** Prints formatted help output for `def` using its `CommandDefinition`.\n *\n * @example\n * ```ts\n * renderHelp({ name: 'generate', description: 'Generate client code' })\n * // prints Usage: generate [options] ...\n * ```\n */\nexport function renderHelp(def: CommandDefinition, parentName?: string): void {\n const programName = parentName ? `${parentName} ${def.name}` : def.name\n const subCommands = def.subCommands ?? []\n\n const argsPart = def.arguments?.length ? ` ${def.arguments.join(' ')}` : ''\n const subCmdPart = subCommands.length ? ' <command>' : ''\n console.log(`\\n${styleText('bold', 'Usage:')} ${programName}${argsPart}${subCmdPart} [options]\\n`)\n\n if (def.description) {\n console.log(` ${def.description}\\n`)\n }\n\n if (subCommands.length) {\n console.log(styleText('bold', 'Commands:'))\n for (const sub of subCommands) {\n console.log(` ${styleText('cyan', sub.name.padEnd(16))}${sub.description}`)\n }\n console.log()\n }\n\n const options: Array<{ flags: string; description: string; default?: string | boolean }> = [\n ...Object.entries(def.options ?? {}).map(([name, opt]) => ({ flags: formatFlags(name, opt), description: opt.description, default: opt.default })),\n { flags: '-h, --help', description: 'Show help' },\n ]\n\n console.log(styleText('bold', 'Options:'))\n for (const opt of options) {\n const flags = styleText('cyan', opt.flags.padEnd(30))\n const defaultPart = opt.default !== undefined ? styleText('dim', ` (default: ${opt.default})`) : ''\n console.log(` ${flags}${opt.description}${defaultPart}`)\n }\n console.log()\n\n if (def.examples?.length) {\n console.log(styleText('bold', 'Examples:'))\n for (const ex of def.examples) {\n console.log(` ${styleText('dim', ex)}`)\n }\n console.log()\n }\n}\n","import { parseArgs, styleText } from 'node:util'\nimport type { CommandDefinition, OptionType, ParsedArgs } from './defineCommand.ts'\nimport { renderHelp } from './renderHelp.ts'\n\n/**\n * Options passed to every `runCLI` invocation.\n */\nexport type RunOptions = {\n programName: string\n defaultCommandName: string\n version: string\n}\n\ntype ParseOption = {\n type: OptionType\n short?: string\n default?: string | boolean\n}\ntype ParseOptions = Record<string, ParseOption>\n\nfunction buildParseOptions(def: CommandDefinition): ParseOptions {\n const result: ParseOptions = {\n help: { type: 'boolean', short: 'h' },\n }\n\n for (const [name, opt] of Object.entries(def.options ?? {})) {\n result[name] = {\n type: opt.type,\n ...(opt.short ? { short: opt.short } : {}),\n ...(opt.default !== undefined ? { default: opt.default } : {}),\n }\n }\n\n return result\n}\n\nasync function runCommand(def: CommandDefinition, argv: Array<string>, parentName?: string): Promise<void> {\n const parseOptions = buildParseOptions(def)\n\n let parsed: ParsedArgs\n try {\n const result = parseArgs({\n args: argv,\n options: parseOptions,\n allowPositionals: true,\n strict: false,\n })\n parsed = {\n values: result.values as ParsedArgs['values'],\n positionals: result.positionals,\n }\n } catch {\n renderHelp(def, parentName)\n process.exit(1)\n }\n\n if (parsed.values['help']) {\n renderHelp(def, parentName)\n process.exit(0)\n }\n\n // Validate required options before running the command\n for (const [name, opt] of Object.entries(def.options ?? {})) {\n if (opt.required && parsed.values[name] === undefined) {\n console.error(styleText('red', `Error: --${name} is required`))\n renderHelp(def, parentName)\n process.exit(1)\n }\n }\n\n if (!def.run) {\n renderHelp(def, parentName)\n process.exit(0)\n }\n\n try {\n await def.run(parsed)\n } catch (err) {\n console.error(styleText('red', `Error: ${err instanceof Error ? err.message : String(err)}`))\n renderHelp(def, parentName)\n process.exit(1)\n }\n}\n\nfunction printRootHelp(programName: string, version: string, defs: Array<CommandDefinition>): void {\n console.log(`\\n${styleText('bold', 'Usage:')} ${programName} <command> [options]\\n`)\n console.log(` Kubb v${version} — Generate TypeScript types, API clients, React Query hooks,`)\n console.log(` Zod schemas, and more from an OpenAPI specification.\\n`)\n console.log(` Quick start: ${styleText('cyan', `${programName} init`)} to scaffold a config, then ${styleText('cyan', `${programName} generate`)} to run.\\n`)\n console.log(styleText('bold', 'Commands:'))\n for (const def of defs) {\n console.log(` ${styleText('cyan', def.name.padEnd(16))}${def.description}`)\n }\n console.log()\n console.log(styleText('bold', 'Options:'))\n console.log(` ${styleText('cyan', '-v, --version'.padEnd(30))}Show version number`)\n console.log(` ${styleText('cyan', '-h, --help'.padEnd(30))}Show help`)\n console.log()\n console.log(`Run ${styleText('cyan', `${programName} <command> --help`)} for command-specific help.\\n`)\n}\n\n/**\n * Parses `argv` and runs the matching command using `node:util parseArgs`. No external dependencies.\n * Falls back to `defaultCommandName` when no command is given.\n *\n * @example\n * ```ts\n * await runCLI(commands, process.argv, {\n * programName: 'kubb',\n * defaultCommandName: 'generate',\n * version: '5.0.0',\n * })\n * ```\n */\nexport async function runCLI(defs: Array<CommandDefinition>, argv: Array<string>, opts: RunOptions): Promise<void> {\n const { programName, defaultCommandName, version } = opts\n\n // Strip the leading executable + script entries when process.argv is passed directly.\n // Handles Node.js (/usr/bin/node), Bun (/usr/local/bin/bun), Deno, tsx, etc.\n // All runtime executable paths contain a path separator; bare command names do not.\n const firstArgIsExecutablePath = (argv[0]?.includes('/') || argv[0]?.includes('\\\\')) ?? false\n const args = argv.length >= 2 && firstArgIsExecutablePath ? argv.slice(2) : argv\n\n if (args[0] === '--version' || args[0] === '-v') {\n console.log(version)\n process.exit(0)\n }\n\n if (args[0] === '--help' || args[0] === '-h') {\n printRootHelp(programName, version, defs)\n process.exit(0)\n }\n\n if (args.length === 0) {\n const defaultDef = defs.find((d) => d.name === defaultCommandName)\n if (defaultDef?.run) {\n await runCommand(defaultDef, [], programName)\n } else {\n printRootHelp(programName, version, defs)\n }\n return\n }\n\n const [first, ...rest] = args\n const isKnownSubcommand = defs.some((d) => d.name === first)\n\n let def: CommandDefinition | undefined\n let commandArgv: Array<string>\n let parentName: string | undefined\n\n if (isKnownSubcommand) {\n def = defs.find((d) => d.name === first)\n commandArgv = rest\n parentName = programName\n } else {\n def = defs.find((d) => d.name === defaultCommandName)\n commandArgv = args\n parentName = programName\n }\n\n if (!def) {\n console.error(`Unknown command: ${first}`)\n printRootHelp(programName, version, defs)\n process.exit(1)\n }\n\n if (def.subCommands?.length) {\n const [subName, ...subRest] = commandArgv\n const subDef = def.subCommands.find((s) => s.name === subName)\n\n if (subName === '--help' || subName === '-h') {\n renderHelp(def, parentName)\n process.exit(0)\n }\n\n if (!subDef) {\n renderHelp(def, parentName)\n process.exit(subName ? 1 : 0)\n }\n\n await runCommand(subDef, subRest, `${parentName} ${def.name}`)\n return\n }\n\n await runCommand(def, commandArgv, parentName)\n}\n","import { styleText } from 'node:util'\nimport { runCLI } from '@internals/utils'\nimport { Telemetry } from './Telemetry.ts'\nimport { version } from '../package.json'\nimport { QUIET_FLAGS } from './constants.ts'\n\n/**\n * Entry point for the `kubb` CLI. Prints the telemetry notice unless telemetry is disabled or a\n * quiet flag is passed, then runs the generate, validate, mcp, and init commands. Defaults to\n * `generate` when no command is given.\n */\nexport async function run(argv: Array<string> = process.argv): Promise<void> {\n const isQuietFlag = argv.some((arg) => QUIET_FLAGS.has(arg))\n\n if (!Telemetry.isDisabled && !isQuietFlag) {\n console.log(\n `${styleText('yellow', 'Notice:')} Kubb collects anonymous telemetry data to help improve the tool. No personal data or file contents are collected. \\nTo disable, set ${styleText('cyan', 'KUBB_DISABLE_TELEMETRY=1')}.\\n`,\n )\n }\n\n const { command: generateCommand } = await import('./commands/generate.ts')\n const { command: validateCommand } = await import('./commands/validate.ts')\n const { command: mcpCommand } = await import('./commands/mcp.ts')\n const { command: initCommand } = await import('./commands/init.ts')\n\n await runCLI([generateCommand, validateCommand, mcpCommand, initCommand], argv, {\n programName: 'kubb',\n defaultCommandName: 'generate',\n version,\n })\n}\n"],"mappings":";;;;;;AAGA,SAAS,YAAY,MAAc,KAA+B;CAGhE,OAAO,GAFO,IAAI,QAAQ,IAAI,IAAI,MAAM,MAAM,GAE9B,IAAI,OADN,IAAI,SAAS,WAAW,KAAK,IAAI,QAAQ,KAAK,KAAK;AAEnE;;;;;;;;;AAUA,SAAgB,WAAW,KAAwB,YAA2B;CAC5E,MAAM,cAAc,aAAa,GAAG,WAAW,GAAG,IAAI,SAAS,IAAI;CACnE,MAAM,cAAc,IAAI,eAAe,CAAC;CAExC,MAAM,WAAW,IAAI,WAAW,SAAS,IAAI,IAAI,UAAU,KAAK,GAAG,MAAM;CACzE,MAAM,aAAa,YAAY,SAAS,eAAe;CACvD,QAAQ,IAAI,MAAA,GAAA,UAAA,UAAA,CAAe,QAAQ,QAAQ,EAAE,GAAG,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AK,aAAa,UAAU;AAC/C;;;;;;;;AC9KA,eAAsB,IAAI,OAAsB,QAAQ,MAAqB;CAC3E,MAAM,cAAc,KAAK,MAAM,QAAQA,kBAAAA,YAAY,IAAI,GAAG,CAAC;CAE3D,IAAI,CAACC,kBAAAA,UAAU,cAAc,CAAC,aAC5B,QAAQ,IACN,IAAA,GAAA,UAAA,UAAA,CAAa,UAAU,SAAS,EAAE,wIAAA,GAAA,UAAA,UAAA,CAAiJ,QAAQ,0BAA0B,EAAE,IACzN;CAGF,MAAM,EAAE,SAAS,oBAAoB,MAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAM,yBAAA,CAAA;CAC3C,MAAM,EAAE,SAAS,oBAAoB,MAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAM,yBAAA,CAAA;CAC3C,MAAM,EAAE,SAAS,eAAe,MAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAM,oBAAA,CAAA;CACtC,MAAM,EAAE,SAAS,gBAAgB,MAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAM,qBAAA,CAAA;CAEvC,MAAM,OAAO;EAAC;EAAiB;EAAiB;EAAY;CAAW,GAAG,MAAM;EAC9E,aAAa;EACb,oBAAoB;EACpB,SAAA,gBAAA;CACF,CAAC;AACH"}
1
+ {"version":3,"file":"index.cjs","names":["QUIET_FLAGS","Telemetry"],"sources":["../src/index.ts"],"sourcesContent":["import { styleText } from 'node:util'\nimport { cli } from 'gunshi'\nimport { Telemetry } from './Telemetry.ts'\nimport { version } from '../package.json'\nimport { QUIET_FLAGS } from './constants.ts'\n\n/**\n * Strips the leading executable + script entries when `process.argv` is passed directly.\n * Handles Node.js (`/usr/bin/node`), Bun (`/usr/local/bin/bun`), Deno, tsx, etc. All runtime\n * executable paths contain a path separator; bare command names do not.\n */\nfunction stripExecArgs(argv: Array<string>): Array<string> {\n const firstArgIsExecutablePath = (argv[0]?.includes('/') || argv[0]?.includes('\\\\')) ?? false\n return argv.length >= 2 && firstArgIsExecutablePath ? argv.slice(2) : argv\n}\n\n/**\n * Entry point for the `kubb` CLI. Prints the telemetry notice unless telemetry is disabled or a\n * quiet flag is passed, then runs the generate, validate, mcp, and init commands. Defaults to\n * `generate` when no command is given.\n */\nexport async function run(argv: Array<string> = process.argv): Promise<void> {\n const isQuietFlag = argv.some((arg) => QUIET_FLAGS.has(arg))\n\n if (!Telemetry.isDisabled && !isQuietFlag) {\n console.log(\n `${styleText('yellow', 'Notice:')} Kubb collects anonymous telemetry data to help improve the tool. No personal data or file contents are collected. \\nTo disable, set ${styleText('cyan', 'KUBB_DISABLE_TELEMETRY=1')}.\\n`,\n )\n }\n\n const { command: generateCommand } = await import('./commands/generate.ts')\n const { command: validateCommand } = await import('./commands/validate.ts')\n const { command: mcpCommand } = await import('./commands/mcp.ts')\n const { command: initCommand } = await import('./commands/init.ts')\n\n try {\n await cli(stripExecArgs(argv), generateCommand, {\n name: 'kubb',\n version,\n description: generateCommand.description,\n subCommands: {\n init: initCommand,\n validate: validateCommand,\n mcp: mcpCommand,\n },\n fallbackToEntry: true,\n })\n } catch {\n process.exit(1)\n }\n}\n"],"mappings":";;;;;;;;;;;;AAWA,SAAS,cAAc,MAAoC;CACzD,MAAM,4BAA4B,KAAK,EAAE,EAAE,SAAS,GAAG,KAAK,KAAK,EAAE,EAAE,SAAS,IAAI,MAAM;CACxF,OAAO,KAAK,UAAU,KAAK,2BAA2B,KAAK,MAAM,CAAC,IAAI;AACxE;;;;;;AAOA,eAAsB,IAAI,OAAsB,QAAQ,MAAqB;CAC3E,MAAM,cAAc,KAAK,MAAM,QAAQA,kBAAAA,YAAY,IAAI,GAAG,CAAC;CAE3D,IAAI,CAACC,kBAAAA,UAAU,cAAc,CAAC,aAC5B,QAAQ,IACN,IAAA,GAAA,UAAA,UAAA,CAAa,UAAU,SAAS,EAAE,wIAAA,GAAA,UAAA,UAAA,CAAiJ,QAAQ,0BAA0B,EAAE,IACzN;CAGF,MAAM,EAAE,SAAS,oBAAoB,MAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAM,yBAAA,CAAA;CAC3C,MAAM,EAAE,SAAS,oBAAoB,MAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAM,yBAAA,CAAA;CAC3C,MAAM,EAAE,SAAS,eAAe,MAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAM,oBAAA,CAAA;CACtC,MAAM,EAAE,SAAS,gBAAgB,MAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAM,qBAAA,CAAA;CAEvC,IAAI;EACF,OAAA,GAAA,OAAA,IAAA,CAAU,cAAc,IAAI,GAAG,iBAAiB;GAC9C,MAAM;GACN,SAAA,gBAAA;GACA,aAAa,gBAAgB;GAC7B,aAAa;IACX,MAAM;IACN,UAAU;IACV,KAAK;GACP;GACA,iBAAiB;EACnB,CAAC;CACH,QAAQ;EACN,QAAQ,KAAK,CAAC;CAChB;AACF"}