@kubb/cli 5.2.8 → 5.3.0

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 (68) hide show
  1. package/dist/{Telemetry-DIDDCARm.js → Telemetry-CJcQkQOT.js} +2 -2
  2. package/dist/Telemetry-CJcQkQOT.js.map +1 -0
  3. package/dist/{Telemetry-C-y1OMHs.cjs → Telemetry-CvHQevSK.cjs} +4 -4
  4. package/dist/Telemetry-CvHQevSK.cjs.map +1 -0
  5. package/dist/agent-3JmkMghp.js +24 -0
  6. package/dist/agent-3JmkMghp.js.map +1 -0
  7. package/dist/agent-BPqs9VRj.cjs +36 -0
  8. package/dist/agent-BPqs9VRj.cjs.map +1 -0
  9. package/dist/{generate-Bg8-2XSd.cjs → generate-CCjNi8-B.cjs} +6 -5
  10. package/dist/generate-CCjNi8-B.cjs.map +1 -0
  11. package/dist/{generate-CKsAI5H2.js → generate-DnOsvKdA.js} +6 -5
  12. package/dist/generate-DnOsvKdA.js.map +1 -0
  13. package/dist/index.cjs +7 -7
  14. package/dist/index.js +7 -7
  15. package/dist/{init-BPArhQCK.cjs → init-BEZE-TU-.cjs} +3 -3
  16. package/dist/{init-BPArhQCK.cjs.map → init-BEZE-TU-.cjs.map} +1 -1
  17. package/dist/{init-DroN6dri.js → init-DFBbp97w.js} +3 -3
  18. package/dist/{init-DroN6dri.js.map → init-DFBbp97w.js.map} +1 -1
  19. package/dist/{output-LZvrgF3z.js → output-DH2Uoy4x.js} +32 -3
  20. package/dist/output-DH2Uoy4x.js.map +1 -0
  21. package/dist/{output-B2V2MN_C.cjs → output-kmklyYIv.cjs} +42 -7
  22. package/dist/output-kmklyYIv.cjs.map +1 -0
  23. package/dist/package-DYdGw7-C.js +6 -0
  24. package/dist/package-DYdGw7-C.js.map +1 -0
  25. package/dist/{package-BMZZ3mUo.cjs → package-DgNWnCoo.cjs} +2 -2
  26. package/dist/package-DgNWnCoo.cjs.map +1 -0
  27. package/dist/{run-CphhWHm6.js → run-B1-xSKKe.js} +3 -3
  28. package/dist/{run-CphhWHm6.js.map → run-B1-xSKKe.js.map} +1 -1
  29. package/dist/{run-Cni7891O.cjs → run-BWahaRPU.cjs} +3 -3
  30. package/dist/{run-Cni7891O.cjs.map → run-BWahaRPU.cjs.map} +1 -1
  31. package/dist/{run-DL1wCsGn.cjs → run-Bh9GxeT8.cjs} +6 -7
  32. package/dist/{run-DL1wCsGn.cjs.map → run-Bh9GxeT8.cjs.map} +1 -1
  33. package/dist/{run-DoU73Qo5.cjs → run-BwMRCeWt.cjs} +3 -3
  34. package/dist/{run-DoU73Qo5.cjs.map → run-BwMRCeWt.cjs.map} +1 -1
  35. package/dist/{run-BHMES-2P.cjs → run-CDLUop5s.cjs} +51 -36
  36. package/dist/run-CDLUop5s.cjs.map +1 -0
  37. package/dist/{run-BcEQGlz_.js → run-CIkCVMy_.js} +3 -3
  38. package/dist/{run-BcEQGlz_.js.map → run-CIkCVMy_.js.map} +1 -1
  39. package/dist/{run-B6bZaLqK.js → run-CZaUf7i2.js} +48 -33
  40. package/dist/run-CZaUf7i2.js.map +1 -0
  41. package/dist/{run-SxqXLbrs.js → run-DiL672xB.js} +6 -7
  42. package/dist/{run-SxqXLbrs.js.map → run-DiL672xB.js.map} +1 -1
  43. package/dist/{run-DRBqVXX0.cjs → run-VK50TiB7.cjs} +2 -2
  44. package/dist/{run-DRBqVXX0.cjs.map → run-VK50TiB7.cjs.map} +1 -1
  45. package/dist/{run-BzvsJ0Ek.js → run-kdxqOL8u.js} +2 -2
  46. package/dist/{run-BzvsJ0Ek.js.map → run-kdxqOL8u.js.map} +1 -1
  47. package/dist/{utils-BgEQilnN.cjs → utils-CMU1rLfY.cjs} +22 -6
  48. package/dist/utils-CMU1rLfY.cjs.map +1 -0
  49. package/dist/{utils-VadUNZOm.js → utils-s6yetN6W.js} +21 -5
  50. package/dist/utils-s6yetN6W.js.map +1 -0
  51. package/package.json +7 -7
  52. package/dist/Telemetry-C-y1OMHs.cjs.map +0 -1
  53. package/dist/Telemetry-DIDDCARm.js.map +0 -1
  54. package/dist/env-DHaFBZTX.cjs +0 -82
  55. package/dist/env-DHaFBZTX.cjs.map +0 -1
  56. package/dist/env-DqPKEL59.js +0 -59
  57. package/dist/env-DqPKEL59.js.map +0 -1
  58. package/dist/generate-Bg8-2XSd.cjs.map +0 -1
  59. package/dist/generate-CKsAI5H2.js.map +0 -1
  60. package/dist/output-B2V2MN_C.cjs.map +0 -1
  61. package/dist/output-LZvrgF3z.js.map +0 -1
  62. package/dist/package-BMZZ3mUo.cjs.map +0 -1
  63. package/dist/package-BXaDNEkt.js +0 -6
  64. package/dist/package-BXaDNEkt.js.map +0 -1
  65. package/dist/run-B6bZaLqK.js.map +0 -1
  66. package/dist/run-BHMES-2P.cjs.map +0 -1
  67. package/dist/utils-BgEQilnN.cjs.map +0 -1
  68. package/dist/utils-VadUNZOm.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import "./rolldown-runtime-C0LytTxp.js";
2
- import { i as getAgentName, n as isCIEnvironment } from "./env-DqPKEL59.js";
2
+ import { n as isCIEnvironment, t as getAgentName } from "./agent-3JmkMghp.js";
3
3
  import { randomBytes } from "node:crypto";
4
4
  import os from "node:os";
5
5
  import process$1 from "node:process";
@@ -259,4 +259,4 @@ async function sendTelemetry(event) {
259
259
  //#endregion
260
260
  export { QUIET_FLAGS as a, URL_WATCHER_TIMEOUT_MS as c, KUBB_NPM_PACKAGE_URL as i, WATCHER_IGNORED_PATHS as l, isDisabled as n, UPDATE_CHECK_TIMEOUT_MS as o, sendTelemetry as r, URL_WATCHER_INTERVAL_MS as s, buildTelemetryEvent as t, runtime as u };
261
261
 
262
- //# sourceMappingURL=Telemetry-DIDDCARm.js.map
262
+ //# sourceMappingURL=Telemetry-CJcQkQOT.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Telemetry-CJcQkQOT.js","names":["process"],"sources":["../../../internals/utils/src/runtime.ts","../src/constants.ts","../src/Telemetry.ts"],"sourcesContent":["/**\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 * Interval in milliseconds between polls of a remote `input` URL in watch mode. A remote document\n * emits no filesystem events, so watch mode falls back to fetching it and comparing bodies.\n */\nexport const URL_WATCHER_INTERVAL_MS = 2_000\n\n/**\n * Upper bound in milliseconds for a single URL watcher request, covering both the response headers\n * and the body read. A server that hangs mid-response would otherwise stall polling forever.\n */\nexport const URL_WATCHER_TIMEOUT_MS = 10_000\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 { getAgentName } from './agent.ts'\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 */\ntype 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 /**\n * Name of the detected AI coding agent (e.g. `'claude'`, `'cursor'`), when the CLI is invoked\n * by one. `undefined` when run by a human or an unrecognized caller.\n */\n agent?: string\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' | 'studio' | '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 agent: getAgentName(),\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 ...(event.agent ? [{ key: 'kubb.agent', value: { stringValue: event.agent } }] : []),\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":";;;;;;;;;;;AAUA,IAAM,UAAN,MAAc;;;;;;;;;;;;;;;CAeZ,IAAI,QAAiB;EACnB,OAAO,OAAO,QAAQ;CACxB;;;;CAKA,IAAI,SAAkB;EACpB,OAAO,OAAQ,WAAkC,SAAS;CAC5D;;;;;;CAOA,IAAI,SAAkB;EACpB,OAAO,CAAC,KAAK,SAAS,CAAC,KAAK,UAAU,OAAO,YAAY,eAAe,QAAQ,UAAU,QAAQ;CACpG;;;;;;;;;CAUA,IAAI,OAAoB;EACtB,IAAI,KAAK,OAAO,OAAO;EACvB,IAAI,KAAK,QAAQ,OAAO;EAExB,OAAO;CACT;;;;;;;;;CAUA,IAAI,UAAkB;EACpB,IAAI,KAAK,OAAO,OAAO,QAAQ,SAAS,OAAO;EAC/C,IAAI,KAAK,QAAQ,OAAQ,WAA0D,MAAM,SAAS,QAAQ;EAE1G,OAAO,QAAQ,UAAU,QAAQ;CACn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IACA;IACA,MAAM,MAAM;IACZ,MAAM;IACN,mBAAmB,OAAO,WAAW;IACrC,iBAAiB,OAAO,SAAS;IACjC;IACA,QAAQ,EACN,MAAM,MAAM,WAAW,YAAY,IAAI,EACzC;GACF,CACF;EACF,CACF;CACF,CACF,EACF;AACF;;;;;;AAOA,eAAsB,cAAc,OAAsC;CACxE,IAAI,WAAW,GACb;CAGF,IAAI;EACF,MAAM,MAAM,GAAG,cAAc,aAAa;GACxC,QAAQ;GACR,SAAS;IACP,gBAAgB;IAChB,0BAA0B;IAC1B,yBAAyB;GAC3B;GACA,MAAM,KAAK,UAAU,iBAAiB,KAAK,CAAC;GAC5C,QAAQ,YAAY,QAAQ,GAAK;EACnC,CAAC;CACH,SAAS,IAAI,CAEb;AACF"}
@@ -1,5 +1,5 @@
1
1
  const require_rolldown_runtime = require("./rolldown-runtime-qbf5tadS.cjs");
2
- const require_env = require("./env-DHaFBZTX.cjs");
2
+ const require_agent = require("./agent-BPqs9VRj.cjs");
3
3
  let node_crypto = require("node:crypto");
4
4
  let node_os = require("node:os");
5
5
  node_os = require_rolldown_runtime.__toESM(node_os, 1);
@@ -132,8 +132,8 @@ function buildTelemetryEvent(options) {
132
132
  runtime: runtime.name,
133
133
  runtimeVersion: runtime.version.split(".")[0],
134
134
  platform: node_os.default.platform(),
135
- ci: require_env.isCIEnvironment(),
136
- agent: require_env.getAgentName(),
135
+ ci: require_agent.isCIEnvironment(),
136
+ agent: require_agent.getAgentName(),
137
137
  plugins: options.plugins ?? [],
138
138
  duration,
139
139
  filesCreated: options.filesCreated ?? 0,
@@ -320,4 +320,4 @@ Object.defineProperty(exports, "sendTelemetry", {
320
320
  }
321
321
  });
322
322
 
323
- //# sourceMappingURL=Telemetry-C-y1OMHs.cjs.map
323
+ //# sourceMappingURL=Telemetry-CvHQevSK.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Telemetry-CvHQevSK.cjs","names":["process","os","isCIEnvironment","getAgentName","randomBytes"],"sources":["../../../internals/utils/src/runtime.ts","../src/constants.ts","../src/Telemetry.ts"],"sourcesContent":["/**\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 * Interval in milliseconds between polls of a remote `input` URL in watch mode. A remote document\n * emits no filesystem events, so watch mode falls back to fetching it and comparing bodies.\n */\nexport const URL_WATCHER_INTERVAL_MS = 2_000\n\n/**\n * Upper bound in milliseconds for a single URL watcher request, covering both the response headers\n * and the body read. A server that hangs mid-response would otherwise stall polling forever.\n */\nexport const URL_WATCHER_TIMEOUT_MS = 10_000\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 { getAgentName } from './agent.ts'\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 */\ntype 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 /**\n * Name of the detected AI coding agent (e.g. `'claude'`, `'cursor'`), when the CLI is invoked\n * by one. `undefined` when run by a human or an unrecognized caller.\n */\n agent?: string\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' | 'studio' | '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 agent: getAgentName(),\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 ...(event.agent ? [{ key: 'kubb.agent', value: { stringValue: event.agent } }] : []),\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":";;;;;;;;;;;;;AAUA,IAAM,UAAN,MAAc;;;;;;;;;;;;;;;CAeZ,IAAI,QAAiB;EACnB,OAAO,OAAO,QAAQ;CACxB;;;;CAKA,IAAI,SAAkB;EACpB,OAAO,OAAQ,WAAkC,SAAS;CAC5D;;;;;;CAOA,IAAI,SAAkB;EACpB,OAAO,CAAC,KAAK,SAAS,CAAC,KAAK,UAAU,OAAO,YAAY,eAAe,QAAQ,UAAU,QAAQ;CACpG;;;;;;;;;CAUA,IAAI,OAAoB;EACtB,IAAI,KAAK,OAAO,OAAO;EACvB,IAAI,KAAK,QAAQ,OAAO;EAExB,OAAO;CACT;;;;;;;;;CAUA,IAAI,UAAkB;EACpB,IAAI,KAAK,OAAO,OAAO,QAAQ,SAAS,OAAO;EAC/C,IAAI,KAAK,QAAQ,OAAQ,WAA0D,MAAM,SAA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;GAC1C;GACA;IAAE,KAAK;IAA0B,OAAO,EAAE,aAAa,SAAS;GAAE;EACpE,EACF;EACA,YAAY,CACV;GACE,OAAO;IAAE,MAAM;IAAa,SAAS,MAAM;GAAY;GACvD,OAAO,CACL;IACE;IACA;IACA,MAAM,MAAM;IACZ,MAAM;IACN,mBAAmB,OAAO,WAAW;IACrC,iBAAiB,OAAO,SAAS;IACjC;IACA,QAAQ,EACN,MAAM,MAAM,WAAW,YAAY,IAAI,EACzC;GACF,CACF;EACF,CACF;CACF,CACF,EACF;AACF;;;;;;AAOA,eAAsB,cAAc,OAAsC;CACxE,IAAI,WAAW,GACb;CAGF,IAAI;EACF,MAAM,MAAM,GAAG,cAAc,aAAa;GACxC,QAAQ;GACR,SAAS;IACP,gBAAgB;IAChB,0BAA0B;IAC1B,yBAAyB;GAC3B;GACA,MAAM,KAAK,UAAU,iBAAiB,KAAK,CAAC;GAC5C,QAAQ,YAAY,QAAQ,GAAK;EACnC,CAAC;CACH,SAAS,IAAI,CAEb;AACF"}
@@ -0,0 +1,24 @@
1
+ import "./rolldown-runtime-C0LytTxp.js";
2
+ import process from "node:process";
3
+ import { getAgentProfile } from "gunshi/agent";
4
+ //#region ../../internals/utils/src/isCIEnvironment.ts
5
+ /**
6
+ * Returns `true` when a known CI provider has set its environment variable.
7
+ */
8
+ function isCIEnvironment() {
9
+ 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);
10
+ }
11
+ //#endregion
12
+ //#region src/agent.ts
13
+ /**
14
+ * Name of the AI coding agent driving this process, when one is detected (e.g. `'claude'`,
15
+ * `'cursor'`). `undefined` when run by a human or an unrecognized caller.
16
+ */
17
+ function getAgentName() {
18
+ const profile = getAgentProfile();
19
+ return profile.isAgent ? profile.name : void 0;
20
+ }
21
+ //#endregion
22
+ export { isCIEnvironment as n, getAgentName as t };
23
+
24
+ //# sourceMappingURL=agent-3JmkMghp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-3JmkMghp.js","names":[],"sources":["../../../internals/utils/src/isCIEnvironment.ts","../src/agent.ts"],"sourcesContent":["import process from 'node:process'\n\n/**\n * Returns `true` when a known CI provider has set its environment variable.\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","import { getAgentProfile } from 'gunshi/agent'\n\n/**\n * Name of the AI coding agent driving this process, when one is detected (e.g. `'claude'`,\n * `'cursor'`). `undefined` when run by a human or an unrecognized caller.\n */\nexport function getAgentName(): string | undefined {\n const profile = getAgentProfile()\n return profile.isAgent ? profile.name : undefined\n}\n"],"mappings":";;;;;;;AAKA,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;;;;;;;ACZA,SAAgB,eAAmC;CACjD,MAAM,UAAU,gBAAgB;CAChC,OAAO,QAAQ,UAAU,QAAQ,OAAO,KAAA;AAC1C"}
@@ -0,0 +1,36 @@
1
+ const require_rolldown_runtime = require("./rolldown-runtime-qbf5tadS.cjs");
2
+ let node_process = require("node:process");
3
+ node_process = require_rolldown_runtime.__toESM(node_process, 1);
4
+ let gunshi_agent = require("gunshi/agent");
5
+ //#region ../../internals/utils/src/isCIEnvironment.ts
6
+ /**
7
+ * Returns `true` when a known CI provider has set its environment variable.
8
+ */
9
+ function isCIEnvironment() {
10
+ return !!(node_process.default.env.CI || node_process.default.env.GITHUB_ACTIONS || node_process.default.env.GITLAB_CI || node_process.default.env.BITBUCKET_BUILD_NUMBER || node_process.default.env.JENKINS_URL || node_process.default.env.CIRCLECI || node_process.default.env.TRAVIS || node_process.default.env.TEAMCITY_VERSION || node_process.default.env.BUILDKITE || node_process.default.env.TF_BUILD);
11
+ }
12
+ //#endregion
13
+ //#region src/agent.ts
14
+ /**
15
+ * Name of the AI coding agent driving this process, when one is detected (e.g. `'claude'`,
16
+ * `'cursor'`). `undefined` when run by a human or an unrecognized caller.
17
+ */
18
+ function getAgentName() {
19
+ const profile = (0, gunshi_agent.getAgentProfile)();
20
+ return profile.isAgent ? profile.name : void 0;
21
+ }
22
+ //#endregion
23
+ Object.defineProperty(exports, "getAgentName", {
24
+ enumerable: true,
25
+ get: function() {
26
+ return getAgentName;
27
+ }
28
+ });
29
+ Object.defineProperty(exports, "isCIEnvironment", {
30
+ enumerable: true,
31
+ get: function() {
32
+ return isCIEnvironment;
33
+ }
34
+ });
35
+
36
+ //# sourceMappingURL=agent-BPqs9VRj.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-BPqs9VRj.cjs","names":["process","getAgentProfile"],"sources":["../../../internals/utils/src/isCIEnvironment.ts","../src/agent.ts"],"sourcesContent":["import process from 'node:process'\n\n/**\n * Returns `true` when a known CI provider has set its environment variable.\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","import { getAgentProfile } from 'gunshi/agent'\n\n/**\n * Name of the AI coding agent driving this process, when one is detected (e.g. `'claude'`,\n * `'cursor'`). `undefined` when run by a human or an unrecognized caller.\n */\nexport function getAgentName(): string | undefined {\n const profile = getAgentProfile()\n return profile.isAgent ? profile.name : undefined\n}\n"],"mappings":";;;;;;;;AAKA,SAAgB,kBAA2B;CACzC,OAAO,CAAC,EACNA,aAAAA,QAAQ,IAAI,MACZA,aAAAA,QAAQ,IAAI,kBACZA,aAAAA,QAAQ,IAAI,aACZA,aAAAA,QAAQ,IAAI,0BACZA,aAAAA,QAAQ,IAAI,eACZA,aAAAA,QAAQ,IAAI,YACZA,aAAAA,QAAQ,IAAI,UACZA,aAAAA,QAAQ,IAAI,oBACZA,aAAAA,QAAQ,IAAI,aACZA,aAAAA,QAAQ,IAAI;AAEhB;;;;;;;ACZA,SAAgB,eAAmC;CACjD,MAAM,WAAA,GAAUC,aAAAA,gBAAAA,CAAgB;CAChC,OAAO,QAAQ,UAAU,QAAQ,OAAO,KAAA;AAC1C"}
@@ -5,14 +5,15 @@ let _gunshi_plugin_dryrun = require("@gunshi/plugin-dryrun");
5
5
  const REPORTER_NAMES = [
6
6
  "cli",
7
7
  "json",
8
- "file"
8
+ "file",
9
+ "html"
9
10
  ];
10
11
  /**
11
12
  * Splits and validates the comma-separated `--reporter` value against the known reporter names.
12
13
  */
13
14
  function parseReporters(value) {
14
15
  const names = value.split(",").map((name) => name.trim()).filter(Boolean);
15
- for (const name of names) if (!REPORTER_NAMES.includes(name)) throw new Error(`must be one of cli, json, file (got "${name}")`);
16
+ for (const name of names) if (!REPORTER_NAMES.includes(name)) throw new Error(`must be one of cli, json, file, html (got "${name}")`);
16
17
  return names;
17
18
  }
18
19
  /**
@@ -78,14 +79,14 @@ const command = (0, gunshi.defineWithTypes)()({
78
79
  reporter: {
79
80
  type: "custom",
80
81
  description: "Reporters that render the run, comma-separated. Overrides config.reporters",
81
- metavar: "cli|json|file",
82
+ metavar: "cli|json|file|html",
82
83
  parse: parseReporters
83
84
  }
84
85
  },
85
86
  async run(ctx) {
86
87
  const { values } = ctx;
87
88
  const logLevel = resolveLogLevel(values);
88
- const { run } = await Promise.resolve().then(() => require("./run-DL1wCsGn.cjs"));
89
+ const { run } = await Promise.resolve().then(() => require("./run-Bh9GxeT8.cjs"));
89
90
  await run({
90
91
  input: values.input,
91
92
  configPath: values.config,
@@ -99,4 +100,4 @@ const command = (0, gunshi.defineWithTypes)()({
99
100
  //#endregion
100
101
  exports.command = command;
101
102
 
102
- //# sourceMappingURL=generate-Bg8-2XSd.cjs.map
103
+ //# sourceMappingURL=generate-CCjNi8-B.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-CCjNi8-B.cjs","names":["defineWithTypes","dryRunId"],"sources":["../src/commands/generate.ts"],"sourcesContent":["import { defineWithTypes } from 'gunshi'\nimport type { ReporterName } from '@kubb/core'\nimport { dryRunId } from '../gunshiDryRun.ts'\nimport type { DryRunExtensions } from '../gunshiDryRun.ts'\n\nconst REPORTER_NAMES: Array<ReporterName> = ['cli', 'json', 'file', 'html']\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, html (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 = defineWithTypes<{ extensions: DryRunExtensions }>()({\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: [\n 'kubb generate # generate from kubb.config.ts',\n 'kubb generate ./openapi.yaml # generate from this spec instead of the config input',\n 'kubb generate --config kubb.config.ts',\n 'kubb generate --watch # regenerate whenever the spec changes',\n 'kubb generate --dryRun # preview the run without writing files',\n 'kubb studio # connect this project to Kubb Studio and generate from the browser',\n 'kubb studio --allowWrite # let Studio write the generated files to disk',\n 'kubb studio login # pair this machine with Studio without connecting',\n ].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: watches an input file for changes, or polls an input URL',\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|html',\n parse: parseReporters,\n },\n },\n async run(ctx) {\n const { values } = ctx\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 dryRun: ctx.extensions[dryRunId].enabled,\n })\n },\n})\n"],"mappings":";;;;AAKA,MAAM,iBAAsC;CAAC;CAAO;CAAQ;CAAQ;AAAM;;;;AAK1E,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,8CAA8C,KAAK,GAAG;CAI1E,OAAO;AACT;;;;AAKA,SAAS,gBAAgB,EAAE,SAAS,QAAQ,YAA6E;CACvH,IAAI,SAAS,OAAO;CACpB,IAAI,QAAQ,OAAO;CACnB,OAAO;AACT;AAEA,MAAa,WAAA,GAAUA,OAAAA,gBAAAA,CAAkD,CAAC,CAAC;CACzE,MAAM;CACN,aACE;CACF,UAAU;EACR;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC,CAAC,KAAK,IAAI;CACX,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,KAAK;EACb,MAAM,EAAE,WAAW;EACnB,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;GAClB,QAAQ,IAAI,WAAWC,sBAAAA,SAAS,CAAC;EACnC,CAAC;CACH;AACF,CAAC"}
@@ -5,14 +5,15 @@ import { defineWithTypes } from "gunshi";
5
5
  const REPORTER_NAMES = [
6
6
  "cli",
7
7
  "json",
8
- "file"
8
+ "file",
9
+ "html"
9
10
  ];
10
11
  /**
11
12
  * Splits and validates the comma-separated `--reporter` value against the known reporter names.
12
13
  */
13
14
  function parseReporters(value) {
14
15
  const names = value.split(",").map((name) => name.trim()).filter(Boolean);
15
- for (const name of names) if (!REPORTER_NAMES.includes(name)) throw new Error(`must be one of cli, json, file (got "${name}")`);
16
+ for (const name of names) if (!REPORTER_NAMES.includes(name)) throw new Error(`must be one of cli, json, file, html (got "${name}")`);
16
17
  return names;
17
18
  }
18
19
  /**
@@ -78,14 +79,14 @@ const command = defineWithTypes()({
78
79
  reporter: {
79
80
  type: "custom",
80
81
  description: "Reporters that render the run, comma-separated. Overrides config.reporters",
81
- metavar: "cli|json|file",
82
+ metavar: "cli|json|file|html",
82
83
  parse: parseReporters
83
84
  }
84
85
  },
85
86
  async run(ctx) {
86
87
  const { values } = ctx;
87
88
  const logLevel = resolveLogLevel(values);
88
- const { run } = await import("./run-SxqXLbrs.js");
89
+ const { run } = await import("./run-DiL672xB.js");
89
90
  await run({
90
91
  input: values.input,
91
92
  configPath: values.config,
@@ -99,4 +100,4 @@ const command = defineWithTypes()({
99
100
  //#endregion
100
101
  export { command };
101
102
 
102
- //# sourceMappingURL=generate-CKsAI5H2.js.map
103
+ //# sourceMappingURL=generate-DnOsvKdA.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-DnOsvKdA.js","names":[],"sources":["../src/commands/generate.ts"],"sourcesContent":["import { defineWithTypes } from 'gunshi'\nimport type { ReporterName } from '@kubb/core'\nimport { dryRunId } from '../gunshiDryRun.ts'\nimport type { DryRunExtensions } from '../gunshiDryRun.ts'\n\nconst REPORTER_NAMES: Array<ReporterName> = ['cli', 'json', 'file', 'html']\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, html (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 = defineWithTypes<{ extensions: DryRunExtensions }>()({\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: [\n 'kubb generate # generate from kubb.config.ts',\n 'kubb generate ./openapi.yaml # generate from this spec instead of the config input',\n 'kubb generate --config kubb.config.ts',\n 'kubb generate --watch # regenerate whenever the spec changes',\n 'kubb generate --dryRun # preview the run without writing files',\n 'kubb studio # connect this project to Kubb Studio and generate from the browser',\n 'kubb studio --allowWrite # let Studio write the generated files to disk',\n 'kubb studio login # pair this machine with Studio without connecting',\n ].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: watches an input file for changes, or polls an input URL',\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|html',\n parse: parseReporters,\n },\n },\n async run(ctx) {\n const { values } = ctx\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 dryRun: ctx.extensions[dryRunId].enabled,\n })\n },\n})\n"],"mappings":";;;;AAK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AW,SAAS,CAAC;EACnC,CAAC;CACH;AACF,CAAC"}
package/dist/index.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_rolldown_runtime = require("./rolldown-runtime-qbf5tadS.cjs");
3
- const require_Telemetry = require("./Telemetry-C-y1OMHs.cjs");
4
- const require_package = require("./package-BMZZ3mUo.cjs");
3
+ const require_Telemetry = require("./Telemetry-CvHQevSK.cjs");
4
+ const require_package = require("./package-DgNWnCoo.cjs");
5
5
  let node_util = require("node:util");
6
6
  let _gunshi_plugin_dryrun = require("@gunshi/plugin-dryrun");
7
7
  _gunshi_plugin_dryrun = require_rolldown_runtime.__toESM(_gunshi_plugin_dryrun, 1);
@@ -33,14 +33,14 @@ async function run(argv = process.argv) {
33
33
  const args = stripExecArgs(argv);
34
34
  const isQuietFlag = args.some((arg) => require_Telemetry.QUIET_FLAGS.has(arg)) || isSnapshotJson(args);
35
35
  if (!require_Telemetry.isDisabled() && !isQuietFlag) console.log(`${(0, node_util.styleText)("yellow", "Notice:")} Kubb collects anonymous telemetry data to help improve the tool. No personal data or file contents are collected. \nTo disable, set ${(0, node_util.styleText)("cyan", "KUBB_DISABLE_TELEMETRY=1")}.\n`);
36
- const { command: generateCommand } = await Promise.resolve().then(() => require("./generate-Bg8-2XSd.cjs"));
37
- const { command: initCommand } = await Promise.resolve().then(() => require("./init-BPArhQCK.cjs"));
36
+ const { command: generateCommand } = await Promise.resolve().then(() => require("./generate-CCjNi8-B.cjs"));
37
+ const { command: initCommand } = await Promise.resolve().then(() => require("./init-BEZE-TU-.cjs"));
38
38
  const { definition: validateDefinition } = await Promise.resolve().then(() => require("./validate-BcB0tFQ6.cjs"));
39
- const validateCommand = (0, gunshi.lazy)(async () => (await Promise.resolve().then(() => require("./run-DoU73Qo5.cjs"))).runner, validateDefinition);
39
+ const validateCommand = (0, gunshi.lazy)(async () => (await Promise.resolve().then(() => require("./run-BwMRCeWt.cjs"))).runner, validateDefinition);
40
40
  const { definition: mcpDefinition } = await Promise.resolve().then(() => require("./mcp-B3B-rE7W.cjs"));
41
- const mcpCommand = (0, gunshi.lazy)(async () => (await Promise.resolve().then(() => require("./run-Cni7891O.cjs"))).runner, mcpDefinition);
41
+ const mcpCommand = (0, gunshi.lazy)(async () => (await Promise.resolve().then(() => require("./run-BWahaRPU.cjs"))).runner, mcpDefinition);
42
42
  const { definition: studioDefinition } = await Promise.resolve().then(() => require("./studio-BQV9CeZK.cjs"));
43
- const studioCommand = (0, gunshi.lazy)(async () => (await Promise.resolve().then(() => require("./run-BHMES-2P.cjs"))).runner, studioDefinition);
43
+ const studioCommand = (0, gunshi.lazy)(async () => (await Promise.resolve().then(() => require("./run-CDLUop5s.cjs"))).runner, studioDefinition);
44
44
  await (0, gunshi.cli)(args, generateCommand, {
45
45
  name: "kubb",
46
46
  version: require_package.version,
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import "./rolldown-runtime-C0LytTxp.js";
2
- import { a as QUIET_FLAGS, n as isDisabled } from "./Telemetry-DIDDCARm.js";
3
- import { t as version } from "./package-BXaDNEkt.js";
2
+ import { a as QUIET_FLAGS, n as isDisabled } from "./Telemetry-CJcQkQOT.js";
3
+ import { t as version } from "./package-DYdGw7-C.js";
4
4
  import { styleText } from "node:util";
5
5
  import dryrun from "@gunshi/plugin-dryrun";
6
6
  import { cli, lazy } from "gunshi";
@@ -31,14 +31,14 @@ async function run(argv = process.argv) {
31
31
  const args = stripExecArgs(argv);
32
32
  const isQuietFlag = args.some((arg) => QUIET_FLAGS.has(arg)) || isSnapshotJson(args);
33
33
  if (!isDisabled() && !isQuietFlag) console.log(`${styleText("yellow", "Notice:")} Kubb collects anonymous telemetry data to help improve the tool. No personal data or file contents are collected. \nTo disable, set ${styleText("cyan", "KUBB_DISABLE_TELEMETRY=1")}.\n`);
34
- const { command: generateCommand } = await import("./generate-CKsAI5H2.js");
35
- const { command: initCommand } = await import("./init-DroN6dri.js");
34
+ const { command: generateCommand } = await import("./generate-DnOsvKdA.js");
35
+ const { command: initCommand } = await import("./init-DFBbp97w.js");
36
36
  const { definition: validateDefinition } = await import("./validate-QpkCbIFJ.js");
37
- const validateCommand = lazy(async () => (await import("./run-CphhWHm6.js")).runner, validateDefinition);
37
+ const validateCommand = lazy(async () => (await import("./run-B1-xSKKe.js")).runner, validateDefinition);
38
38
  const { definition: mcpDefinition } = await import("./mcp-B-GxGgVr.js");
39
- const mcpCommand = lazy(async () => (await import("./run-BcEQGlz_.js")).runner, mcpDefinition);
39
+ const mcpCommand = lazy(async () => (await import("./run-CIkCVMy_.js")).runner, mcpDefinition);
40
40
  const { definition: studioDefinition } = await import("./studio-DUNPmQ5V.js");
41
- const studioCommand = lazy(async () => (await import("./run-B6bZaLqK.js")).runner, studioDefinition);
41
+ const studioCommand = lazy(async () => (await import("./run-CZaUf7i2.js")).runner, studioDefinition);
42
42
  await cli(args, generateCommand, {
43
43
  name: "kubb",
44
44
  version,
@@ -1,5 +1,5 @@
1
1
  require("./rolldown-runtime-qbf5tadS.cjs");
2
- const require_package = require("./package-BMZZ3mUo.cjs");
2
+ const require_package = require("./package-DgNWnCoo.cjs");
3
3
  let gunshi = require("gunshi");
4
4
  let _gunshi_plugin_dryrun = require("@gunshi/plugin-dryrun");
5
5
  //#region src/commands/init.ts
@@ -40,7 +40,7 @@ const command = (0, gunshi.defineWithTypes)()({
40
40
  },
41
41
  async run(ctx) {
42
42
  const { values } = ctx;
43
- const { run } = await Promise.resolve().then(() => require("./run-DRBqVXX0.cjs"));
43
+ const { run } = await Promise.resolve().then(() => require("./run-VK50TiB7.cjs"));
44
44
  await run({
45
45
  yes: values.yes,
46
46
  version: require_package.version,
@@ -54,4 +54,4 @@ const command = (0, gunshi.defineWithTypes)()({
54
54
  //#endregion
55
55
  exports.command = command;
56
56
 
57
- //# sourceMappingURL=init-BPArhQCK.cjs.map
57
+ //# sourceMappingURL=init-BEZE-TU-.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"init-BPArhQCK.cjs","names":["defineWithTypes","dryRunId"],"sources":["../src/commands/init.ts"],"sourcesContent":["import { defineWithTypes } from 'gunshi'\nimport { dryRunId } from '../gunshiDryRun.ts'\nimport type { DryRunExtensions } from '../gunshiDryRun.ts'\nimport { version } from '../../package.json'\n\nexport const command = defineWithTypes<{ extensions: DryRunExtensions }>()({\n name: 'init',\n description:\n 'Scaffold a kubb.config.ts and install plugins for code generation from an OpenAPI spec. Run without flags for interactive setup, or pass --input, --output, and --plugins to skip the prompts.',\n examples: [\n 'kubb init',\n 'kubb init --yes',\n 'kubb init --input ./openapi.yaml --output ./src/gen --plugins plugin-ts,plugin-zod',\n 'kubb init --plugins plugin-ts,plugin-axios,plugin-react-query',\n 'kubb init --yes --dryRun',\n ].join('\\n'),\n args: {\n yes: {\n type: 'boolean',\n description: 'Skip prompts and use default options',\n short: 'y',\n default: false,\n },\n input: {\n type: 'string',\n description: 'Path to the OpenAPI specification',\n short: 'i',\n metavar: 'path',\n },\n output: {\n type: 'string',\n description: 'Output directory for generated files',\n short: 'o',\n metavar: 'path',\n },\n plugins: {\n type: 'string',\n description:\n 'Comma-separated list of plugins to use (plugin-ts, plugin-axios, plugin-fetch, plugin-react-query, plugin-vue-query, plugin-zod, plugin-faker, plugin-msw, plugin-cypress, plugin-mcp, plugin-redoc)',\n metavar: 'plugin-ts,plugin-zod,...',\n },\n },\n async run(ctx) {\n const { values } = ctx\n const { run } = await import('../runners/init/run.ts')\n\n await run({\n yes: values.yes,\n version,\n input: values.input,\n output: values.output,\n plugins: values.plugins,\n dryRun: ctx.extensions[dryRunId],\n })\n },\n})\n"],"mappings":";;;;;AAKA,MAAa,WAAA,GAAUA,OAAAA,gBAAAA,CAAkD,CAAC,CAAC;CACzE,MAAM;CACN,aACE;CACF,UAAU;EACR;EACA;EACA;EACA;EACA;CACF,CAAC,CAAC,KAAK,IAAI;CACX,MAAM;EACJ,KAAK;GACH,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,OAAO;GACL,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,QAAQ;GACN,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,SAAS;GACP,MAAM;GACN,aACE;GACF,SAAS;EACX;CACF;CACA,MAAM,IAAI,KAAK;EACb,MAAM,EAAE,WAAW;EACnB,MAAM,EAAE,QAAQ,MAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAM,oBAAA,CAAA;EAEtB,MAAM,IAAI;GACR,KAAK,OAAO;GACZ,SAAA,gBAAA;GACA,OAAO,OAAO;GACd,QAAQ,OAAO;GACf,SAAS,OAAO;GAChB,QAAQ,IAAI,WAAWC,sBAAAA;EACzB,CAAC;CACH;AACF,CAAC"}
1
+ {"version":3,"file":"init-BEZE-TU-.cjs","names":["defineWithTypes","dryRunId"],"sources":["../src/commands/init.ts"],"sourcesContent":["import { defineWithTypes } from 'gunshi'\nimport { dryRunId } from '../gunshiDryRun.ts'\nimport type { DryRunExtensions } from '../gunshiDryRun.ts'\nimport { version } from '../../package.json'\n\nexport const command = defineWithTypes<{ extensions: DryRunExtensions }>()({\n name: 'init',\n description:\n 'Scaffold a kubb.config.ts and install plugins for code generation from an OpenAPI spec. Run without flags for interactive setup, or pass --input, --output, and --plugins to skip the prompts.',\n examples: [\n 'kubb init',\n 'kubb init --yes',\n 'kubb init --input ./openapi.yaml --output ./src/gen --plugins plugin-ts,plugin-zod',\n 'kubb init --plugins plugin-ts,plugin-axios,plugin-react-query',\n 'kubb init --yes --dryRun',\n ].join('\\n'),\n args: {\n yes: {\n type: 'boolean',\n description: 'Skip prompts and use default options',\n short: 'y',\n default: false,\n },\n input: {\n type: 'string',\n description: 'Path to the OpenAPI specification',\n short: 'i',\n metavar: 'path',\n },\n output: {\n type: 'string',\n description: 'Output directory for generated files',\n short: 'o',\n metavar: 'path',\n },\n plugins: {\n type: 'string',\n description:\n 'Comma-separated list of plugins to use (plugin-ts, plugin-axios, plugin-fetch, plugin-react-query, plugin-vue-query, plugin-zod, plugin-faker, plugin-msw, plugin-cypress, plugin-mcp, plugin-redoc)',\n metavar: 'plugin-ts,plugin-zod,...',\n },\n },\n async run(ctx) {\n const { values } = ctx\n const { run } = await import('../runners/init/run.ts')\n\n await run({\n yes: values.yes,\n version,\n input: values.input,\n output: values.output,\n plugins: values.plugins,\n dryRun: ctx.extensions[dryRunId],\n })\n },\n})\n"],"mappings":";;;;;AAKA,MAAa,WAAA,GAAUA,OAAAA,gBAAAA,CAAkD,CAAC,CAAC;CACzE,MAAM;CACN,aACE;CACF,UAAU;EACR;EACA;EACA;EACA;EACA;CACF,CAAC,CAAC,KAAK,IAAI;CACX,MAAM;EACJ,KAAK;GACH,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,OAAO;GACL,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,QAAQ;GACN,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,SAAS;GACP,MAAM;GACN,aACE;GACF,SAAS;EACX;CACF;CACA,MAAM,IAAI,KAAK;EACb,MAAM,EAAE,WAAW;EACnB,MAAM,EAAE,QAAQ,MAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAM,oBAAA,CAAA;EAEtB,MAAM,IAAI;GACR,KAAK,OAAO;GACZ,SAAA,gBAAA;GACA,OAAO,OAAO;GACd,QAAQ,OAAO;GACf,SAAS,OAAO;GAChB,QAAQ,IAAI,WAAWC,sBAAAA;EACzB,CAAC;CACH;AACF,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import "./rolldown-runtime-C0LytTxp.js";
2
- import { t as version } from "./package-BXaDNEkt.js";
2
+ import { t as version } from "./package-DYdGw7-C.js";
3
3
  import { t as dryRunId } from "./gunshiDryRun-DdKJuVn1.js";
4
4
  import { defineWithTypes } from "gunshi";
5
5
  //#region src/commands/init.ts
@@ -40,7 +40,7 @@ const command = defineWithTypes()({
40
40
  },
41
41
  async run(ctx) {
42
42
  const { values } = ctx;
43
- const { run } = await import("./run-BzvsJ0Ek.js");
43
+ const { run } = await import("./run-kdxqOL8u.js");
44
44
  await run({
45
45
  yes: values.yes,
46
46
  version,
@@ -54,4 +54,4 @@ const command = defineWithTypes()({
54
54
  //#endregion
55
55
  export { command };
56
56
 
57
- //# sourceMappingURL=init-DroN6dri.js.map
57
+ //# sourceMappingURL=init-DFBbp97w.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"init-DroN6dri.js","names":[],"sources":["../src/commands/init.ts"],"sourcesContent":["import { defineWithTypes } from 'gunshi'\nimport { dryRunId } from '../gunshiDryRun.ts'\nimport type { DryRunExtensions } from '../gunshiDryRun.ts'\nimport { version } from '../../package.json'\n\nexport const command = defineWithTypes<{ extensions: DryRunExtensions }>()({\n name: 'init',\n description:\n 'Scaffold a kubb.config.ts and install plugins for code generation from an OpenAPI spec. Run without flags for interactive setup, or pass --input, --output, and --plugins to skip the prompts.',\n examples: [\n 'kubb init',\n 'kubb init --yes',\n 'kubb init --input ./openapi.yaml --output ./src/gen --plugins plugin-ts,plugin-zod',\n 'kubb init --plugins plugin-ts,plugin-axios,plugin-react-query',\n 'kubb init --yes --dryRun',\n ].join('\\n'),\n args: {\n yes: {\n type: 'boolean',\n description: 'Skip prompts and use default options',\n short: 'y',\n default: false,\n },\n input: {\n type: 'string',\n description: 'Path to the OpenAPI specification',\n short: 'i',\n metavar: 'path',\n },\n output: {\n type: 'string',\n description: 'Output directory for generated files',\n short: 'o',\n metavar: 'path',\n },\n plugins: {\n type: 'string',\n description:\n 'Comma-separated list of plugins to use (plugin-ts, plugin-axios, plugin-fetch, plugin-react-query, plugin-vue-query, plugin-zod, plugin-faker, plugin-msw, plugin-cypress, plugin-mcp, plugin-redoc)',\n metavar: 'plugin-ts,plugin-zod,...',\n },\n },\n async run(ctx) {\n const { values } = ctx\n const { run } = await import('../runners/init/run.ts')\n\n await run({\n yes: values.yes,\n version,\n input: values.input,\n output: values.output,\n plugins: values.plugins,\n dryRun: ctx.extensions[dryRunId],\n })\n },\n})\n"],"mappings":";;;;;AAKA,MAAa,UAAU,gBAAkD,CAAC,CAAC;CACzE,MAAM;CACN,aACE;CACF,UAAU;EACR;EACA;EACA;EACA;EACA;CACF,CAAC,CAAC,KAAK,IAAI;CACX,MAAM;EACJ,KAAK;GACH,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,OAAO;GACL,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,QAAQ;GACN,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,SAAS;GACP,MAAM;GACN,aACE;GACF,SAAS;EACX;CACF;CACA,MAAM,IAAI,KAAK;EACb,MAAM,EAAE,WAAW;EACnB,MAAM,EAAE,QAAQ,MAAM,OAAO;EAE7B,MAAM,IAAI;GACR,KAAK,OAAO;GACZ;GACA,OAAO,OAAO;GACd,QAAQ,OAAO;GACf,SAAS,OAAO;GAChB,QAAQ,IAAI,WAAW;EACzB,CAAC;CACH;AACF,CAAC"}
1
+ {"version":3,"file":"init-DFBbp97w.js","names":[],"sources":["../src/commands/init.ts"],"sourcesContent":["import { defineWithTypes } from 'gunshi'\nimport { dryRunId } from '../gunshiDryRun.ts'\nimport type { DryRunExtensions } from '../gunshiDryRun.ts'\nimport { version } from '../../package.json'\n\nexport const command = defineWithTypes<{ extensions: DryRunExtensions }>()({\n name: 'init',\n description:\n 'Scaffold a kubb.config.ts and install plugins for code generation from an OpenAPI spec. Run without flags for interactive setup, or pass --input, --output, and --plugins to skip the prompts.',\n examples: [\n 'kubb init',\n 'kubb init --yes',\n 'kubb init --input ./openapi.yaml --output ./src/gen --plugins plugin-ts,plugin-zod',\n 'kubb init --plugins plugin-ts,plugin-axios,plugin-react-query',\n 'kubb init --yes --dryRun',\n ].join('\\n'),\n args: {\n yes: {\n type: 'boolean',\n description: 'Skip prompts and use default options',\n short: 'y',\n default: false,\n },\n input: {\n type: 'string',\n description: 'Path to the OpenAPI specification',\n short: 'i',\n metavar: 'path',\n },\n output: {\n type: 'string',\n description: 'Output directory for generated files',\n short: 'o',\n metavar: 'path',\n },\n plugins: {\n type: 'string',\n description:\n 'Comma-separated list of plugins to use (plugin-ts, plugin-axios, plugin-fetch, plugin-react-query, plugin-vue-query, plugin-zod, plugin-faker, plugin-msw, plugin-cypress, plugin-mcp, plugin-redoc)',\n metavar: 'plugin-ts,plugin-zod,...',\n },\n },\n async run(ctx) {\n const { values } = ctx\n const { run } = await import('../runners/init/run.ts')\n\n await run({\n yes: values.yes,\n version,\n input: values.input,\n output: values.output,\n plugins: values.plugins,\n dryRun: ctx.extensions[dryRunId],\n })\n },\n})\n"],"mappings":";;;;;AAKA,MAAa,UAAU,gBAAkD,CAAC,CAAC;CACzE,MAAM;CACN,aACE;CACF,UAAU;EACR;EACA;EACA;EACA;EACA;CACF,CAAC,CAAC,KAAK,IAAI;CACX,MAAM;EACJ,KAAK;GACH,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,OAAO;GACL,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,QAAQ;GACN,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,SAAS;GACP,MAAM;GACN,aACE;GACF,SAAS;EACX;CACF;CACA,MAAM,IAAI,KAAK;EACb,MAAM,EAAE,WAAW;EACnB,MAAM,EAAE,QAAQ,MAAM,OAAO;EAE7B,MAAM,IAAI;GACR,KAAK,OAAO;GACZ;GACA,OAAO,OAAO;GACd,QAAQ,OAAO;GACf,SAAS,OAAO;GAChB,QAAQ,IAAI,WAAW;EACzB,CAAC;CACH;AACF,CAAC"}
@@ -1,6 +1,35 @@
1
1
  import "./rolldown-runtime-C0LytTxp.js";
2
- import { r as isRichOutput } from "./env-DqPKEL59.js";
2
+ import { n as isCIEnvironment, t as getAgentName } from "./agent-3JmkMghp.js";
3
3
  import * as prompts from "@clack/prompts";
4
+ //#region src/utils/env.ts
5
+ /**
6
+ * Returns `true` when the process has an interactive TTY with a valid terminal
7
+ * width and is not running in CI.
8
+ *
9
+ * Some IDE-embedded terminals report `isTTY = true` but set `columns` to `0`,
10
+ * which breaks clack's box-drawing helpers (they call `String.prototype.repeat`
11
+ * with a negative count and throw a `RangeError`). A positive column count is
12
+ * required before the TTY counts as usable.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * if (canUseTTY()) {
17
+ * renderProgressBar()
18
+ * }
19
+ * ```
20
+ */
21
+ function canUseTTY() {
22
+ return process.stdout.isTTY && (process.stdout.columns ?? 0) > 0 && !isCIEnvironment();
23
+ }
24
+ /**
25
+ * Returns `true` when output can carry spinners and clack's gutter: an interactive TTY that no AI
26
+ * coding agent is reading. Cursor-movement escapes are hard for an agent to parse even over a
27
+ * pseudo-TTY, so it gets the plain writer.
28
+ */
29
+ function isRichOutput() {
30
+ return canUseTTY() && !getAgentName();
31
+ }
32
+ //#endregion
4
33
  //#region src/loggers/output.ts
5
34
  /**
6
35
  * Prefixes the plain writers use, the same ones `plainLogger` prints, so a command's own output
@@ -84,6 +113,6 @@ function createSpinner() {
84
113
  };
85
114
  }
86
115
  //#endregion
87
- export { logIntro as a, logWarn as c, logInfo as i, logBlock as n, logOutro as o, logError as r, logStep as s, createSpinner as t };
116
+ export { logIntro as a, logWarn as c, logInfo as i, canUseTTY as l, logBlock as n, logOutro as o, logError as r, logStep as s, createSpinner as t };
88
117
 
89
- //# sourceMappingURL=output-LZvrgF3z.js.map
118
+ //# sourceMappingURL=output-DH2Uoy4x.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output-DH2Uoy4x.js","names":[],"sources":["../src/utils/env.ts","../src/loggers/output.ts"],"sourcesContent":["import { getAgentName } from '../agent.ts'\nimport { isCIEnvironment } from '@internals/utils'\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`). A positive column count is\n * required before the TTY counts as 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/**\n * Returns `true` when output can carry spinners and clack's gutter: an interactive TTY that no AI\n * coding agent is reading. Cursor-movement escapes are hard for an agent to parse even over a\n * pseudo-TTY, so it gets the plain writer.\n */\nexport function isRichOutput(): boolean {\n return canUseTTY() && !getAgentName()\n}\n","import * as prompts from '@clack/prompts'\nimport { isRichOutput } from '../utils/env.ts'\n\n/**\n * Prefixes the plain writers use, the same ones `plainLogger` prints, so a command's own output\n * and the hook output around it read as one stream.\n */\nconst SYMBOLS = { info: 'ℹ', warn: '⚠', error: '✗', step: '◇' } as const\n\ntype Level = keyof typeof SYMBOLS\n\nfunction write(level: Level, message: string): void {\n if (isRichOutput()) {\n prompts.log[level](message)\n\n return\n }\n\n console.log(`${SYMBOLS[level]} ${message}`)\n}\n\ntype IntroOptions = {\n title: string\n /**\n * Printed under the title, for a command that has a caveat to lead with.\n */\n warning?: string\n /**\n * Whether to open a block a later {@link logOutro} closes. Pass `false` for a command that\n * prints and exits, since nothing would ever close the block.\n *\n * @default true\n */\n block?: boolean\n}\n\n/**\n * Opens a command's output with its title.\n */\nexport function logIntro({ title, warning, block = true }: IntroOptions): void {\n if (block && isRichOutput()) {\n prompts.intro(title)\n\n if (warning) {\n prompts.log.warn(warning)\n }\n\n return\n }\n\n console.log(title)\n\n if (warning) {\n console.warn(warning)\n }\n\n console.log()\n}\n\n/**\n * Closes the block {@link logIntro} opened. The closing gutter is not a written line, so plain\n * output prints the text on its own.\n */\nexport function logOutro(text: string): void {\n if (isRichOutput()) {\n prompts.outro(text)\n\n return\n }\n\n console.log(text)\n}\n\n/**\n * Prints lines as one block, without a symbol in front of them.\n */\nexport function logBlock(lines: string | Array<string>): void {\n if (isRichOutput()) {\n prompts.log.message(lines)\n\n return\n }\n\n console.log([lines].flat().join('\\n'))\n}\n\nexport function logInfo(message: string): void {\n write('info', message)\n}\n\nexport function logWarn(message: string): void {\n write('warn', message)\n}\n\nexport function logError(message: string): void {\n write('error', message)\n}\n\n/**\n * Reports a step the command is taking, rather than something it found.\n */\nexport function logStep(message: string): void {\n write('step', message)\n}\n\ntype Spinner = {\n start: (message?: string) => void\n stop: (message?: string, code?: number) => void\n message: (message?: string) => void\n}\n\n/**\n * A progress spinner, or a writer that prints each message it is given when the terminal cannot\n * animate one. Callers drive both the same way.\n */\nexport function createSpinner(): Spinner {\n if (isRichOutput()) {\n return prompts.spinner()\n }\n\n const print = (message?: string) => {\n if (message) {\n console.log(message)\n }\n }\n\n return { start: print, stop: print, message: print }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAmBA,SAAgB,YAAqB;CACnC,OAAO,QAAQ,OAAO,UAAU,QAAQ,OAAO,WAAW,KAAK,KAAK,CAAC,gBAAgB;AACvF;;;;;;AAOA,SAAgB,eAAwB;CACtC,OAAO,UAAU,KAAK,CAAC,aAAa;AACtC;;;;;;;ACvBA,MAAM,UAAU;CAAE,MAAM;CAAK,MAAM;CAAK,OAAO;CAAK,MAAM;AAAI;AAI9D,SAAS,MAAM,OAAc,SAAuB;CAClD,IAAI,aAAa,GAAG;EAClB,QAAQ,IAAI,MAAM,CAAC,OAAO;EAE1B;CACF;CAEA,QAAQ,IAAI,GAAG,QAAQ,OAAO,GAAG,SAAS;AAC5C;;;;AAoBA,SAAgB,SAAS,EAAE,OAAO,SAAS,QAAQ,QAA4B;CAC7E,IAAI,SAAS,aAAa,GAAG;EAC3B,QAAQ,MAAM,KAAK;EAEnB,IAAI,SACF,QAAQ,IAAI,KAAK,OAAO;EAG1B;CACF;CAEA,QAAQ,IAAI,KAAK;CAEjB,IAAI,SACF,QAAQ,KAAK,OAAO;CAGtB,QAAQ,IAAI;AACd;;;;;AAMA,SAAgB,SAAS,MAAoB;CAC3C,IAAI,aAAa,GAAG;EAClB,QAAQ,MAAM,IAAI;EAElB;CACF;CAEA,QAAQ,IAAI,IAAI;AAClB;;;;AAKA,SAAgB,SAAS,OAAqC;CAC5D,IAAI,aAAa,GAAG;EAClB,QAAQ,IAAI,QAAQ,KAAK;EAEzB;CACF;CAEA,QAAQ,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,IAAI,CAAC;AACvC;AAEA,SAAgB,QAAQ,SAAuB;CAC7C,MAAM,QAAQ,OAAO;AACvB;AAEA,SAAgB,QAAQ,SAAuB;CAC7C,MAAM,QAAQ,OAAO;AACvB;AAEA,SAAgB,SAAS,SAAuB;CAC9C,MAAM,SAAS,OAAO;AACxB;;;;AAKA,SAAgB,QAAQ,SAAuB;CAC7C,MAAM,QAAQ,OAAO;AACvB;;;;;AAYA,SAAgB,gBAAyB;CACvC,IAAI,aAAa,GACf,OAAO,QAAQ,QAAQ;CAGzB,MAAM,SAAS,YAAqB;EAClC,IAAI,SACF,QAAQ,IAAI,OAAO;CAEvB;CAEA,OAAO;EAAE,OAAO;EAAO,MAAM;EAAO,SAAS;CAAM;AACrD"}
@@ -1,7 +1,36 @@
1
1
  const require_rolldown_runtime = require("./rolldown-runtime-qbf5tadS.cjs");
2
- const require_env = require("./env-DHaFBZTX.cjs");
2
+ const require_agent = require("./agent-BPqs9VRj.cjs");
3
3
  let _clack_prompts = require("@clack/prompts");
4
4
  _clack_prompts = require_rolldown_runtime.__toESM(_clack_prompts, 1);
5
+ //#region src/utils/env.ts
6
+ /**
7
+ * Returns `true` when the process has an interactive TTY with a valid terminal
8
+ * width and is not running in CI.
9
+ *
10
+ * Some IDE-embedded terminals report `isTTY = true` but set `columns` to `0`,
11
+ * which breaks clack's box-drawing helpers (they call `String.prototype.repeat`
12
+ * with a negative count and throw a `RangeError`). A positive column count is
13
+ * required before the TTY counts as usable.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * if (canUseTTY()) {
18
+ * renderProgressBar()
19
+ * }
20
+ * ```
21
+ */
22
+ function canUseTTY() {
23
+ return process.stdout.isTTY && (process.stdout.columns ?? 0) > 0 && !require_agent.isCIEnvironment();
24
+ }
25
+ /**
26
+ * Returns `true` when output can carry spinners and clack's gutter: an interactive TTY that no AI
27
+ * coding agent is reading. Cursor-movement escapes are hard for an agent to parse even over a
28
+ * pseudo-TTY, so it gets the plain writer.
29
+ */
30
+ function isRichOutput() {
31
+ return canUseTTY() && !require_agent.getAgentName();
32
+ }
33
+ //#endregion
5
34
  //#region src/loggers/output.ts
6
35
  /**
7
36
  * Prefixes the plain writers use, the same ones `plainLogger` prints, so a command's own output
@@ -14,7 +43,7 @@ const SYMBOLS = {
14
43
  step: "◇"
15
44
  };
16
45
  function write(level, message) {
17
- if (require_env.isRichOutput()) {
46
+ if (isRichOutput()) {
18
47
  _clack_prompts.log[level](message);
19
48
  return;
20
49
  }
@@ -24,7 +53,7 @@ function write(level, message) {
24
53
  * Opens a command's output with its title.
25
54
  */
26
55
  function logIntro({ title, warning, block = true }) {
27
- if (block && require_env.isRichOutput()) {
56
+ if (block && isRichOutput()) {
28
57
  _clack_prompts.intro(title);
29
58
  if (warning) _clack_prompts.log.warn(warning);
30
59
  return;
@@ -38,7 +67,7 @@ function logIntro({ title, warning, block = true }) {
38
67
  * output prints the text on its own.
39
68
  */
40
69
  function logOutro(text) {
41
- if (require_env.isRichOutput()) {
70
+ if (isRichOutput()) {
42
71
  _clack_prompts.outro(text);
43
72
  return;
44
73
  }
@@ -48,7 +77,7 @@ function logOutro(text) {
48
77
  * Prints lines as one block, without a symbol in front of them.
49
78
  */
50
79
  function logBlock(lines) {
51
- if (require_env.isRichOutput()) {
80
+ if (isRichOutput()) {
52
81
  _clack_prompts.log.message(lines);
53
82
  return;
54
83
  }
@@ -74,7 +103,7 @@ function logStep(message) {
74
103
  * animate one. Callers drive both the same way.
75
104
  */
76
105
  function createSpinner() {
77
- if (require_env.isRichOutput()) return _clack_prompts.spinner();
106
+ if (isRichOutput()) return _clack_prompts.spinner();
78
107
  const print = (message) => {
79
108
  if (message) console.log(message);
80
109
  };
@@ -85,6 +114,12 @@ function createSpinner() {
85
114
  };
86
115
  }
87
116
  //#endregion
117
+ Object.defineProperty(exports, "canUseTTY", {
118
+ enumerable: true,
119
+ get: function() {
120
+ return canUseTTY;
121
+ }
122
+ });
88
123
  Object.defineProperty(exports, "createSpinner", {
89
124
  enumerable: true,
90
125
  get: function() {
@@ -134,4 +169,4 @@ Object.defineProperty(exports, "logWarn", {
134
169
  }
135
170
  });
136
171
 
137
- //# sourceMappingURL=output-B2V2MN_C.cjs.map
172
+ //# sourceMappingURL=output-kmklyYIv.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output-kmklyYIv.cjs","names":["isCIEnvironment","getAgentName","prompts"],"sources":["../src/utils/env.ts","../src/loggers/output.ts"],"sourcesContent":["import { getAgentName } from '../agent.ts'\nimport { isCIEnvironment } from '@internals/utils'\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`). A positive column count is\n * required before the TTY counts as 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/**\n * Returns `true` when output can carry spinners and clack's gutter: an interactive TTY that no AI\n * coding agent is reading. Cursor-movement escapes are hard for an agent to parse even over a\n * pseudo-TTY, so it gets the plain writer.\n */\nexport function isRichOutput(): boolean {\n return canUseTTY() && !getAgentName()\n}\n","import * as prompts from '@clack/prompts'\nimport { isRichOutput } from '../utils/env.ts'\n\n/**\n * Prefixes the plain writers use, the same ones `plainLogger` prints, so a command's own output\n * and the hook output around it read as one stream.\n */\nconst SYMBOLS = { info: 'ℹ', warn: '⚠', error: '✗', step: '◇' } as const\n\ntype Level = keyof typeof SYMBOLS\n\nfunction write(level: Level, message: string): void {\n if (isRichOutput()) {\n prompts.log[level](message)\n\n return\n }\n\n console.log(`${SYMBOLS[level]} ${message}`)\n}\n\ntype IntroOptions = {\n title: string\n /**\n * Printed under the title, for a command that has a caveat to lead with.\n */\n warning?: string\n /**\n * Whether to open a block a later {@link logOutro} closes. Pass `false` for a command that\n * prints and exits, since nothing would ever close the block.\n *\n * @default true\n */\n block?: boolean\n}\n\n/**\n * Opens a command's output with its title.\n */\nexport function logIntro({ title, warning, block = true }: IntroOptions): void {\n if (block && isRichOutput()) {\n prompts.intro(title)\n\n if (warning) {\n prompts.log.warn(warning)\n }\n\n return\n }\n\n console.log(title)\n\n if (warning) {\n console.warn(warning)\n }\n\n console.log()\n}\n\n/**\n * Closes the block {@link logIntro} opened. The closing gutter is not a written line, so plain\n * output prints the text on its own.\n */\nexport function logOutro(text: string): void {\n if (isRichOutput()) {\n prompts.outro(text)\n\n return\n }\n\n console.log(text)\n}\n\n/**\n * Prints lines as one block, without a symbol in front of them.\n */\nexport function logBlock(lines: string | Array<string>): void {\n if (isRichOutput()) {\n prompts.log.message(lines)\n\n return\n }\n\n console.log([lines].flat().join('\\n'))\n}\n\nexport function logInfo(message: string): void {\n write('info', message)\n}\n\nexport function logWarn(message: string): void {\n write('warn', message)\n}\n\nexport function logError(message: string): void {\n write('error', message)\n}\n\n/**\n * Reports a step the command is taking, rather than something it found.\n */\nexport function logStep(message: string): void {\n write('step', message)\n}\n\ntype Spinner = {\n start: (message?: string) => void\n stop: (message?: string, code?: number) => void\n message: (message?: string) => void\n}\n\n/**\n * A progress spinner, or a writer that prints each message it is given when the terminal cannot\n * animate one. Callers drive both the same way.\n */\nexport function createSpinner(): Spinner {\n if (isRichOutput()) {\n return prompts.spinner()\n }\n\n const print = (message?: string) => {\n if (message) {\n console.log(message)\n }\n }\n\n return { start: print, stop: print, message: print }\n}\n"],"mappings":";;;;;;;;;;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