@kubb/cli 5.0.0-beta.50 → 5.0.0-beta.52

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 (64) hide show
  1. package/dist/Telemetry-BZH4YIxq.js +312 -0
  2. package/dist/Telemetry-BZH4YIxq.js.map +1 -0
  3. package/dist/Telemetry-DC5WVMB9.cjs +349 -0
  4. package/dist/Telemetry-DC5WVMB9.cjs.map +1 -0
  5. package/dist/{generate-CKnn3tQa.js → generate-BYoW6Tbf.js} +2 -2
  6. package/dist/{generate-CKnn3tQa.js.map → generate-BYoW6Tbf.js.map} +1 -1
  7. package/dist/{generate-Q6GMu4L8.cjs → generate-BtVVpqYI.cjs} +2 -2
  8. package/dist/{generate-Q6GMu4L8.cjs.map → generate-BtVVpqYI.cjs.map} +1 -1
  9. package/dist/index.cjs +8 -9
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.js +6 -7
  12. package/dist/index.js.map +1 -1
  13. package/dist/{init-C5iCqBwA.cjs → init-C5MBsMV9.cjs} +2 -2
  14. package/dist/{init-C5iCqBwA.cjs.map → init-C5MBsMV9.cjs.map} +1 -1
  15. package/dist/{init-DyOF6CiQ.js → init-Dc5SDV9B.js} +2 -2
  16. package/dist/{init-DyOF6CiQ.js.map → init-Dc5SDV9B.js.map} +1 -1
  17. package/dist/{mcp-BN5HQYdK.cjs → mcp-B6ycoHpi.cjs} +3 -3
  18. package/dist/{mcp-BN5HQYdK.cjs.map → mcp-B6ycoHpi.cjs.map} +1 -1
  19. package/dist/{mcp-09FvxYWS.js → mcp-CuLcYL2g.js} +3 -3
  20. package/dist/{mcp-09FvxYWS.js.map → mcp-CuLcYL2g.js.map} +1 -1
  21. package/dist/{package-DOVOGEEY.cjs → package-CMoiVX61.cjs} +2 -2
  22. package/dist/package-CMoiVX61.cjs.map +1 -0
  23. package/dist/package-ChkqOLMB.js +6 -0
  24. package/dist/package-ChkqOLMB.js.map +1 -0
  25. package/dist/{run-CrvmI4G2.cjs → run-B2etCFG8.cjs} +42 -104
  26. package/dist/run-B2etCFG8.cjs.map +1 -0
  27. package/dist/{run-BO7phoNN.js → run-C7cr0qhi.js} +2 -2
  28. package/dist/run-C7cr0qhi.js.map +1 -0
  29. package/dist/{run-DvZ5i2lT.js → run-D2s4baOU.js} +34 -96
  30. package/dist/run-D2s4baOU.js.map +1 -0
  31. package/dist/{run-Cl4SrSob.cjs → run-DGMgkbD3.cjs} +3 -3
  32. package/dist/run-DGMgkbD3.cjs.map +1 -0
  33. package/dist/{run-BzaKz_nl.js → run-DLVIbuN0.js} +2 -2
  34. package/dist/run-DLVIbuN0.js.map +1 -0
  35. package/dist/{run-CkTpemme.cjs → run-DMWGLJUx.cjs} +3 -3
  36. package/dist/run-DMWGLJUx.cjs.map +1 -0
  37. package/dist/{validate-C6KPFEex.cjs → validate-B-8HQq1B.cjs} +3 -3
  38. package/dist/{validate-C6KPFEex.cjs.map → validate-B-8HQq1B.cjs.map} +1 -1
  39. package/dist/{validate-5atkOC73.js → validate-BWtbWM9F.js} +3 -3
  40. package/dist/{validate-5atkOC73.js.map → validate-BWtbWM9F.js.map} +1 -1
  41. package/package.json +6 -6
  42. package/src/Telemetry.ts +290 -0
  43. package/src/constants.ts +2 -2
  44. package/src/index.ts +1 -1
  45. package/src/loggers/clackLogger.ts +2 -27
  46. package/src/loggers/defineLogger.ts +59 -0
  47. package/src/loggers/plainLogger.ts +2 -4
  48. package/src/loggers/utils.ts +27 -1
  49. package/src/runners/generate/run.ts +3 -6
  50. package/src/runners/mcp/run.ts +1 -1
  51. package/src/runners/validate/run.ts +1 -1
  52. package/dist/constants-BQ8LZB1P.js +0 -23
  53. package/dist/constants-BQ8LZB1P.js.map +0 -1
  54. package/dist/constants-MzEjK668.cjs +0 -40
  55. package/dist/constants-MzEjK668.cjs.map +0 -1
  56. package/dist/package-Bm6VUbtL.js +0 -6
  57. package/dist/package-Bm6VUbtL.js.map +0 -1
  58. package/dist/package-DOVOGEEY.cjs.map +0 -1
  59. package/dist/run-BO7phoNN.js.map +0 -1
  60. package/dist/run-BzaKz_nl.js.map +0 -1
  61. package/dist/run-CkTpemme.cjs.map +0 -1
  62. package/dist/run-Cl4SrSob.cjs.map +0 -1
  63. package/dist/run-CrvmI4G2.cjs.map +0 -1
  64. package/dist/run-DvZ5i2lT.js.map +0 -1
@@ -0,0 +1,312 @@
1
+ import "./chunk-C0LytTxp.js";
2
+ import { randomBytes } from "node:crypto";
3
+ import { promises } from "node:dns";
4
+ import os from "node:os";
5
+ import process$1 from "node:process";
6
+ //#region ../../internals/utils/src/env.ts
7
+ /**
8
+ * Returns `true` when the process is running in a CI environment.
9
+ * Covers GitHub Actions, GitLab CI, CircleCI, Travis CI, Jenkins, Bitbucket,
10
+ * TeamCity, Buildkite, and Azure Pipelines.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * if (isCIEnvironment()) {
15
+ * logger.level = 'error'
16
+ * }
17
+ * ```
18
+ */
19
+ function isCIEnvironment() {
20
+ 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);
21
+ }
22
+ /**
23
+ * Returns `true` when the process has an interactive TTY with a valid terminal
24
+ * width and is not running in CI.
25
+ *
26
+ * Some IDE-embedded terminals report `isTTY = true` but set `columns` to `0`,
27
+ * which breaks clack's box-drawing helpers (they call `String.prototype.repeat`
28
+ * with a negative count and throw a `RangeError`). We therefore require a
29
+ * positive column count before declaring the TTY usable.
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * if (canUseTTY()) {
34
+ * renderProgressBar()
35
+ * }
36
+ * ```
37
+ */
38
+ function canUseTTY() {
39
+ return !!process.stdout.isTTY && (process.stdout.columns ?? 0) > 0 && !isCIEnvironment();
40
+ }
41
+ //#endregion
42
+ //#region ../../internals/utils/src/network.ts
43
+ /**
44
+ * Well-known stable domains used as DNS probes to check internet connectivity.
45
+ */
46
+ const TEST_DOMAINS = [
47
+ "dns.google.com",
48
+ "cloudflare.com",
49
+ "one.one.one.one"
50
+ ];
51
+ /**
52
+ * Returns `true` when the system has internet connectivity.
53
+ * Probes DNS resolution against well-known stable domains.
54
+ *
55
+ * @example
56
+ * ```ts
57
+ * if (await isOnline()) {
58
+ * await fetchLatestVersion()
59
+ * }
60
+ * ```
61
+ */
62
+ async function isOnline() {
63
+ for (const domain of TEST_DOMAINS) try {
64
+ await promises.resolve(domain);
65
+ return true;
66
+ } catch {}
67
+ return false;
68
+ }
69
+ /**
70
+ * Executes `fn` only when the system is online. Returns `null` when offline or on error.
71
+ *
72
+ * @example
73
+ * ```ts
74
+ * const version = await executeIfOnline(() => fetchLatestVersion('kubb'))
75
+ * // null when offline
76
+ * ```
77
+ */
78
+ async function executeIfOnline(fn) {
79
+ if (!await isOnline()) return null;
80
+ try {
81
+ return await fn();
82
+ } catch {
83
+ return null;
84
+ }
85
+ }
86
+ //#endregion
87
+ //#region ../../internals/utils/src/runtime.ts
88
+ /**
89
+ * Returns `true` when the current process is running under Bun.
90
+ *
91
+ * Detection keys off the global `Bun` object rather than `process.versions`,
92
+ * because Bun polyfills `process.versions.node` for Node compatibility and would
93
+ * otherwise look like Node.
94
+ *
95
+ * @example
96
+ * ```ts
97
+ * if (isBun()) {
98
+ * await Bun.write(path, data)
99
+ * }
100
+ * ```
101
+ */
102
+ function isBun() {
103
+ return typeof Bun !== "undefined";
104
+ }
105
+ /**
106
+ * Returns `true` when the current process is running under Deno.
107
+ */
108
+ function isDeno() {
109
+ return typeof globalThis.Deno !== "undefined";
110
+ }
111
+ /**
112
+ * Returns the name of the runtime executing the current process.
113
+ *
114
+ * @example
115
+ * ```ts
116
+ * getRuntimeName() // 'bun' when run with `bun kubb`, 'node' otherwise
117
+ * ```
118
+ */
119
+ function getRuntimeName() {
120
+ if (isBun()) return "bun";
121
+ if (isDeno()) return "deno";
122
+ return "node";
123
+ }
124
+ /**
125
+ * Returns the version of the active runtime, or an empty string when it cannot be read.
126
+ *
127
+ * @example
128
+ * ```ts
129
+ * getRuntimeVersion() // '1.3.11' under Bun, '22.22.2' under Node
130
+ * ```
131
+ */
132
+ function getRuntimeVersion() {
133
+ if (isBun()) return process.versions.bun ?? "";
134
+ if (isDeno()) return globalThis.Deno?.version?.deno ?? "";
135
+ return process.versions?.node ?? "";
136
+ }
137
+ //#endregion
138
+ //#region src/constants.ts
139
+ /**
140
+ * NPM registry endpoint used to check for @kubb/cli updates.
141
+ */
142
+ const KUBB_NPM_PACKAGE_URL = "https://registry.npmjs.org/@kubb/cli/latest";
143
+ /**
144
+ * OpenTelemetry ingestion endpoint for anonymous usage telemetry.
145
+ */
146
+ const OTLP_ENDPOINT = "https://otlp.kubb.dev";
147
+ /**
148
+ * Glob pattern for paths the file watcher ignores.
149
+ */
150
+ const WATCHER_IGNORED_PATHS = "**/{.git,node_modules}/**";
151
+ /**
152
+ * Flags that short-circuit execution (help/version), no telemetry notice is shown.
153
+ */
154
+ const QUIET_FLAGS = new Set([
155
+ "--help",
156
+ "-h",
157
+ "--version",
158
+ "-v"
159
+ ]);
160
+ //#endregion
161
+ //#region src/Telemetry.ts
162
+ /**
163
+ * Anonymous OTLP usage telemetry for the Kubb run. All methods are static, so call them as
164
+ * `Telemetry.build(...)`, `Telemetry.send(...)`, and `Telemetry.isDisabled()`. No file paths,
165
+ * OpenAPI specs, or secrets are ever included, and sending fails silently to never break a run.
166
+ */
167
+ var Telemetry = class Telemetry {
168
+ /**
169
+ * Returns `true` when telemetry is disabled via `DO_NOT_TRACK` or `KUBB_DISABLE_TELEMETRY`.
170
+ */
171
+ static isDisabled() {
172
+ return process$1.env["DO_NOT_TRACK"] === "1" || process$1.env["DO_NOT_TRACK"] === "true" || process$1.env["KUBB_DISABLE_TELEMETRY"] === "1" || process$1.env["KUBB_DISABLE_TELEMETRY"] === "true";
173
+ }
174
+ /**
175
+ * Build an anonymous telemetry payload from a completed generation run.
176
+ */
177
+ static build(options) {
178
+ const [seconds, nanoseconds] = process$1.hrtime(options.hrStart);
179
+ const duration = Math.round(seconds * 1e3 + nanoseconds / 1e6);
180
+ return {
181
+ command: options.command,
182
+ kubbVersion: options.kubbVersion,
183
+ nodeVersion: process$1.versions.node.split(".")[0],
184
+ runtime: getRuntimeName(),
185
+ runtimeVersion: getRuntimeVersion().split(".")[0],
186
+ platform: os.platform(),
187
+ ci: isCIEnvironment(),
188
+ plugins: options.plugins ?? [],
189
+ duration,
190
+ filesCreated: options.filesCreated ?? 0,
191
+ status: options.status
192
+ };
193
+ }
194
+ /**
195
+ * Convert a {@link TelemetryEvent} into an OTLP-compatible JSON trace payload.
196
+ * See https://opentelemetry.io/docs/languages/sdk-configuration/otlp-exporter/
197
+ */
198
+ static buildOtlpPayload(event) {
199
+ const traceId = randomBytes(16).toString("hex");
200
+ const spanId = randomBytes(8).toString("hex");
201
+ const endTimeNs = BigInt(Date.now()) * 1000000n;
202
+ const startTimeNs = endTimeNs - BigInt(event.duration) * 1000000n;
203
+ const attributes = [
204
+ {
205
+ key: "kubb.command",
206
+ value: { stringValue: event.command }
207
+ },
208
+ {
209
+ key: "kubb.version",
210
+ value: { stringValue: event.kubbVersion }
211
+ },
212
+ {
213
+ key: "kubb.node_version",
214
+ value: { stringValue: event.nodeVersion }
215
+ },
216
+ {
217
+ key: "kubb.runtime",
218
+ value: { stringValue: event.runtime }
219
+ },
220
+ {
221
+ key: "kubb.runtime_version",
222
+ value: { stringValue: event.runtimeVersion }
223
+ },
224
+ {
225
+ key: "kubb.platform",
226
+ value: { stringValue: event.platform }
227
+ },
228
+ {
229
+ key: "kubb.ci",
230
+ value: { boolValue: event.ci }
231
+ },
232
+ {
233
+ key: "kubb.files_created",
234
+ value: { intValue: event.filesCreated }
235
+ },
236
+ {
237
+ key: "kubb.status",
238
+ value: { stringValue: event.status }
239
+ },
240
+ {
241
+ key: "kubb.plugins",
242
+ value: { arrayValue: { values: event.plugins.map((p) => ({ kvlistValue: { values: [{
243
+ key: "name",
244
+ value: { stringValue: p.name }
245
+ }, {
246
+ key: "options",
247
+ value: { stringValue: JSON.stringify({
248
+ ...p.options,
249
+ usedEnumNames: void 0
250
+ }) }
251
+ }] } })) } }
252
+ }
253
+ ];
254
+ return { resourceSpans: [{
255
+ resource: { attributes: [
256
+ {
257
+ key: "service.name",
258
+ value: { stringValue: "kubb-core" }
259
+ },
260
+ {
261
+ key: "service.version",
262
+ value: { stringValue: event.kubbVersion }
263
+ },
264
+ {
265
+ key: "telemetry.sdk.language",
266
+ value: { stringValue: "nodejs" }
267
+ }
268
+ ] },
269
+ scopeSpans: [{
270
+ scope: {
271
+ name: "kubb-core",
272
+ version: event.kubbVersion
273
+ },
274
+ spans: [{
275
+ traceId,
276
+ spanId,
277
+ name: event.command,
278
+ kind: 1,
279
+ startTimeUnixNano: String(startTimeNs),
280
+ endTimeUnixNano: String(endTimeNs),
281
+ attributes,
282
+ status: { code: event.status === "success" ? 1 : 2 }
283
+ }]
284
+ }]
285
+ }] };
286
+ }
287
+ /**
288
+ * Send an anonymous telemetry event to the Kubb OTLP endpoint. Respects `DO_NOT_TRACK` and
289
+ * `KUBB_DISABLE_TELEMETRY`, and fails silently so telemetry never interrupts a run.
290
+ */
291
+ static async send(event) {
292
+ if (Telemetry.isDisabled()) return;
293
+ await executeIfOnline(async () => {
294
+ try {
295
+ await fetch(`${OTLP_ENDPOINT}/v1/traces`, {
296
+ method: "POST",
297
+ headers: {
298
+ "Content-Type": "application/json",
299
+ "Kubb-Telemetry-Version": "1",
300
+ "Kubb-Telemetry-Source": "kubb-core"
301
+ },
302
+ body: JSON.stringify(Telemetry.buildOtlpPayload(event)),
303
+ signal: AbortSignal.timeout(5e3)
304
+ });
305
+ } catch (_e) {}
306
+ });
307
+ }
308
+ };
309
+ //#endregion
310
+ export { executeIfOnline as a, WATCHER_IGNORED_PATHS as i, KUBB_NPM_PACKAGE_URL as n, canUseTTY as o, QUIET_FLAGS as r, Telemetry as t };
311
+
312
+ //# sourceMappingURL=Telemetry-BZH4YIxq.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Telemetry-BZH4YIxq.js","names":["dnsPromises","process"],"sources":["../../../internals/utils/src/env.ts","../../../internals/utils/src/network.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","import { promises as dnsPromises } from 'node:dns'\n\n/**\n * Well-known stable domains used as DNS probes to check internet connectivity.\n */\nconst TEST_DOMAINS = ['dns.google.com', 'cloudflare.com', 'one.one.one.one'] as const\n\n/**\n * Returns `true` when the system has internet connectivity.\n * Probes DNS resolution against well-known stable domains.\n *\n * @example\n * ```ts\n * if (await isOnline()) {\n * await fetchLatestVersion()\n * }\n * ```\n */\nexport async function isOnline(): Promise<boolean> {\n for (const domain of TEST_DOMAINS) {\n try {\n await dnsPromises.resolve(domain)\n return true\n } catch {\n // Try next domain\n }\n }\n\n return false\n}\n\n/**\n * Executes `fn` only when the system is online. Returns `null` when offline or on error.\n *\n * @example\n * ```ts\n * const version = await executeIfOnline(() => fetchLatestVersion('kubb'))\n * // null when offline\n * ```\n */\nexport async function executeIfOnline<T>(fn: () => Promise<T>): Promise<T | null> {\n if (!(await isOnline())) return null\n\n try {\n return await fn()\n } catch {\n return null\n }\n}\n","/**\n * Name of the JavaScript runtime executing the current process.\n */\nexport type RuntimeName = 'bun' | 'deno' | 'node'\n\n/**\n * Returns `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 (isBun()) {\n * await Bun.write(path, data)\n * }\n * ```\n */\nexport function isBun(): boolean {\n return typeof Bun !== 'undefined'\n}\n\n/**\n * Returns `true` when the current process is running under Deno.\n */\nexport function isDeno(): boolean {\n return typeof (globalThis as { Deno?: unknown }).Deno !== 'undefined'\n}\n\n/**\n * Returns `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 */\nexport function isNode(): boolean {\n return !isBun() && !isDeno() && typeof process !== 'undefined' && process.versions?.node != null\n}\n\n/**\n * Returns the name of the runtime executing the current process.\n *\n * @example\n * ```ts\n * getRuntimeName() // 'bun' when run with `bun kubb`, 'node' otherwise\n * ```\n */\nexport function getRuntimeName(): RuntimeName {\n if (isBun()) return 'bun'\n if (isDeno()) return 'deno'\n return 'node'\n}\n\n/**\n * Returns the version of the active runtime, or an empty string when it cannot be read.\n *\n * @example\n * ```ts\n * getRuntimeVersion() // '1.3.11' under Bun, '22.22.2' under Node\n * ```\n */\nexport function getRuntimeVersion(): string {\n if (isBun()) return process.versions.bun ?? ''\n if (isDeno()) return (globalThis as { Deno?: { version?: { deno?: string } } }).Deno?.version?.deno ?? ''\n return process.versions?.node ?? ''\n}\n","/**\n * NPM registry endpoint used to check for @kubb/cli updates.\n */\nexport const KUBB_NPM_PACKAGE_URL = 'https://registry.npmjs.org/@kubb/cli/latest' as const\n\n/**\n * 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 * Flags that short-circuit execution (help/version), no telemetry notice is shown.\n */\nexport const QUIET_FLAGS = new Set(['--help', '-h', '--version', '-v'] as const)\n","import { randomBytes } from 'node:crypto'\nimport os from 'node:os'\nimport process from 'node:process'\nimport { executeIfOnline, getRuntimeName, getRuntimeVersion, isCIEnvironment, type RuntimeName } from '@internals/utils'\nimport { OTLP_ENDPOINT } from './constants.ts'\n\n// OpenTelemetry OTLP JSON types\n// https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/trace/v1/trace.proto\n// https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/common/v1/common.proto\n\ntype OtlpStringValue = { stringValue: string }\ntype OtlpBoolValue = { boolValue: boolean }\ntype OtlpIntValue = { intValue: number }\ntype OtlpDoubleValue = { doubleValue: number }\ntype OtlpBytesValue = { bytesValue: string }\ntype OtlpArrayValue = { arrayValue: { values: Array<OtlpAnyValue> } }\ntype OtlpKvListValue = { kvlistValue: { values: Array<OtlpKeyValue> } }\n\ntype OtlpAnyValue = OtlpStringValue | OtlpBoolValue | OtlpIntValue | OtlpDoubleValue | OtlpBytesValue | OtlpArrayValue | OtlpKvListValue\n\ntype OtlpKeyValue = {\n key: string\n value: OtlpAnyValue\n}\n\ntype OtlpResource = {\n attributes: Array<OtlpKeyValue>\n droppedAttributesCount?: number\n}\n\ntype OtlpInstrumentationScope = {\n name: string\n version?: string\n attributes?: Array<OtlpKeyValue>\n droppedAttributesCount?: number\n}\n\n/** https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/trace/v1/trace.proto#L103 */\ntype OtlpSpanKind = 0 | 1 | 2 | 3 | 4 | 5\n\n/** 0 = STATUS_CODE_UNSET, 1 = STATUS_CODE_OK, 2 = STATUS_CODE_ERROR */\ntype OtlpStatusCode = 0 | 1 | 2\n\ntype OtlpStatus = {\n code: OtlpStatusCode\n message?: string\n}\n\ntype OtlpSpan = {\n traceId: string\n spanId: string\n traceState?: string\n parentSpanId?: string\n name: string\n kind: OtlpSpanKind\n startTimeUnixNano: string\n endTimeUnixNano: string\n attributes?: Array<OtlpKeyValue>\n droppedAttributesCount?: number\n events?: Array<OtlpSpanEvent>\n droppedEventsCount?: number\n links?: Array<OtlpSpanLink>\n droppedLinksCount?: number\n status?: OtlpStatus\n}\n\ntype OtlpSpanEvent = {\n timeUnixNano: string\n name: string\n attributes?: Array<OtlpKeyValue>\n droppedAttributesCount?: number\n}\n\ntype OtlpSpanLink = {\n traceId: string\n spanId: string\n traceState?: string\n attributes?: Array<OtlpKeyValue>\n droppedAttributesCount?: number\n}\n\ntype OtlpScopeSpans = {\n scope: OtlpInstrumentationScope\n spans: Array<OtlpSpan>\n schemaUrl?: string\n}\n\ntype OtlpResourceSpans = {\n resource: OtlpResource\n scopeSpans: Array<OtlpScopeSpans>\n schemaUrl?: string\n}\n\n/** Root payload sent to POST /v1/traces */\ntype OtlpExportTraceServiceRequest = {\n resourceSpans: Array<OtlpResourceSpans>\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 plugin options snapshot, values are included but cannot be traced back to the user.\n */\n options: Record<string, unknown>\n}\n\nexport type TelemetryEvent = {\n command: string\n kubbVersion: string\n nodeVersion: string\n /**\n * Name of the JavaScript runtime that executed the run, `'bun'`, `'deno'`, or `'node'`.\n */\n runtime: RuntimeName\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 the Kubb run. All methods are static, so call them as\n * `Telemetry.build(...)`, `Telemetry.send(...)`, and `Telemetry.isDisabled()`. No file paths,\n * OpenAPI specs, or secrets are ever included, and sending fails silently to never break a run.\n */\nexport class Telemetry {\n /**\n * Returns `true` when telemetry is disabled via `DO_NOT_TRACK` or `KUBB_DISABLE_TELEMETRY`.\n */\n static 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: getRuntimeName(),\n runtimeVersion: getRuntimeVersion().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 * 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(\n (p): OtlpKvListValue => ({\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\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 satisfies OtlpSpanKind,\n startTimeUnixNano: String(startTimeNs),\n endTimeUnixNano: String(endTimeNs),\n attributes,\n status: {\n code: (event.status === 'success' ? 1 : 2) satisfies OtlpStatusCode,\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 await executeIfOnline(async () => {\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}\n"],"mappings":"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"}
@@ -0,0 +1,349 @@
1
+ const require_chunk = require("./chunk-Bx3C2hgW.cjs");
2
+ let node_crypto = require("node:crypto");
3
+ let node_dns = require("node:dns");
4
+ let node_os = require("node:os");
5
+ node_os = require_chunk.__toESM(node_os, 1);
6
+ let node_process = require("node:process");
7
+ node_process = require_chunk.__toESM(node_process, 1);
8
+ //#region ../../internals/utils/src/env.ts
9
+ /**
10
+ * Returns `true` when the process is running in a CI environment.
11
+ * Covers GitHub Actions, GitLab CI, CircleCI, Travis CI, Jenkins, Bitbucket,
12
+ * TeamCity, Buildkite, and Azure Pipelines.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * if (isCIEnvironment()) {
17
+ * logger.level = 'error'
18
+ * }
19
+ * ```
20
+ */
21
+ function isCIEnvironment() {
22
+ 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);
23
+ }
24
+ /**
25
+ * Returns `true` when the process has an interactive TTY with a valid terminal
26
+ * width and is not running in CI.
27
+ *
28
+ * Some IDE-embedded terminals report `isTTY = true` but set `columns` to `0`,
29
+ * which breaks clack's box-drawing helpers (they call `String.prototype.repeat`
30
+ * with a negative count and throw a `RangeError`). We therefore require a
31
+ * positive column count before declaring the TTY usable.
32
+ *
33
+ * @example
34
+ * ```ts
35
+ * if (canUseTTY()) {
36
+ * renderProgressBar()
37
+ * }
38
+ * ```
39
+ */
40
+ function canUseTTY() {
41
+ return !!process.stdout.isTTY && (process.stdout.columns ?? 0) > 0 && !isCIEnvironment();
42
+ }
43
+ //#endregion
44
+ //#region ../../internals/utils/src/network.ts
45
+ /**
46
+ * Well-known stable domains used as DNS probes to check internet connectivity.
47
+ */
48
+ const TEST_DOMAINS = [
49
+ "dns.google.com",
50
+ "cloudflare.com",
51
+ "one.one.one.one"
52
+ ];
53
+ /**
54
+ * Returns `true` when the system has internet connectivity.
55
+ * Probes DNS resolution against well-known stable domains.
56
+ *
57
+ * @example
58
+ * ```ts
59
+ * if (await isOnline()) {
60
+ * await fetchLatestVersion()
61
+ * }
62
+ * ```
63
+ */
64
+ async function isOnline() {
65
+ for (const domain of TEST_DOMAINS) try {
66
+ await node_dns.promises.resolve(domain);
67
+ return true;
68
+ } catch {}
69
+ return false;
70
+ }
71
+ /**
72
+ * Executes `fn` only when the system is online. Returns `null` when offline or on error.
73
+ *
74
+ * @example
75
+ * ```ts
76
+ * const version = await executeIfOnline(() => fetchLatestVersion('kubb'))
77
+ * // null when offline
78
+ * ```
79
+ */
80
+ async function executeIfOnline(fn) {
81
+ if (!await isOnline()) return null;
82
+ try {
83
+ return await fn();
84
+ } catch {
85
+ return null;
86
+ }
87
+ }
88
+ //#endregion
89
+ //#region ../../internals/utils/src/runtime.ts
90
+ /**
91
+ * Returns `true` when the current process is running under Bun.
92
+ *
93
+ * Detection keys off the global `Bun` object rather than `process.versions`,
94
+ * because Bun polyfills `process.versions.node` for Node compatibility and would
95
+ * otherwise look like Node.
96
+ *
97
+ * @example
98
+ * ```ts
99
+ * if (isBun()) {
100
+ * await Bun.write(path, data)
101
+ * }
102
+ * ```
103
+ */
104
+ function isBun() {
105
+ return typeof Bun !== "undefined";
106
+ }
107
+ /**
108
+ * Returns `true` when the current process is running under Deno.
109
+ */
110
+ function isDeno() {
111
+ return typeof globalThis.Deno !== "undefined";
112
+ }
113
+ /**
114
+ * Returns the name of the runtime executing the current process.
115
+ *
116
+ * @example
117
+ * ```ts
118
+ * getRuntimeName() // 'bun' when run with `bun kubb`, 'node' otherwise
119
+ * ```
120
+ */
121
+ function getRuntimeName() {
122
+ if (isBun()) return "bun";
123
+ if (isDeno()) return "deno";
124
+ return "node";
125
+ }
126
+ /**
127
+ * Returns the version of the active runtime, or an empty string when it cannot be read.
128
+ *
129
+ * @example
130
+ * ```ts
131
+ * getRuntimeVersion() // '1.3.11' under Bun, '22.22.2' under Node
132
+ * ```
133
+ */
134
+ function getRuntimeVersion() {
135
+ if (isBun()) return process.versions.bun ?? "";
136
+ if (isDeno()) return globalThis.Deno?.version?.deno ?? "";
137
+ return process.versions?.node ?? "";
138
+ }
139
+ //#endregion
140
+ //#region src/constants.ts
141
+ /**
142
+ * NPM registry endpoint used to check for @kubb/cli updates.
143
+ */
144
+ const KUBB_NPM_PACKAGE_URL = "https://registry.npmjs.org/@kubb/cli/latest";
145
+ /**
146
+ * OpenTelemetry ingestion endpoint for anonymous usage telemetry.
147
+ */
148
+ const OTLP_ENDPOINT = "https://otlp.kubb.dev";
149
+ /**
150
+ * Glob pattern for paths the file watcher ignores.
151
+ */
152
+ const WATCHER_IGNORED_PATHS = "**/{.git,node_modules}/**";
153
+ /**
154
+ * Flags that short-circuit execution (help/version), no telemetry notice is shown.
155
+ */
156
+ const QUIET_FLAGS = new Set([
157
+ "--help",
158
+ "-h",
159
+ "--version",
160
+ "-v"
161
+ ]);
162
+ //#endregion
163
+ //#region src/Telemetry.ts
164
+ /**
165
+ * Anonymous OTLP usage telemetry for the Kubb run. All methods are static, so call them as
166
+ * `Telemetry.build(...)`, `Telemetry.send(...)`, and `Telemetry.isDisabled()`. No file paths,
167
+ * OpenAPI specs, or secrets are ever included, and sending fails silently to never break a run.
168
+ */
169
+ var Telemetry = class Telemetry {
170
+ /**
171
+ * Returns `true` when telemetry is disabled via `DO_NOT_TRACK` or `KUBB_DISABLE_TELEMETRY`.
172
+ */
173
+ static isDisabled() {
174
+ return node_process.default.env["DO_NOT_TRACK"] === "1" || node_process.default.env["DO_NOT_TRACK"] === "true" || node_process.default.env["KUBB_DISABLE_TELEMETRY"] === "1" || node_process.default.env["KUBB_DISABLE_TELEMETRY"] === "true";
175
+ }
176
+ /**
177
+ * Build an anonymous telemetry payload from a completed generation run.
178
+ */
179
+ static build(options) {
180
+ const [seconds, nanoseconds] = node_process.default.hrtime(options.hrStart);
181
+ const duration = Math.round(seconds * 1e3 + nanoseconds / 1e6);
182
+ return {
183
+ command: options.command,
184
+ kubbVersion: options.kubbVersion,
185
+ nodeVersion: node_process.default.versions.node.split(".")[0],
186
+ runtime: getRuntimeName(),
187
+ runtimeVersion: getRuntimeVersion().split(".")[0],
188
+ platform: node_os.default.platform(),
189
+ ci: isCIEnvironment(),
190
+ plugins: options.plugins ?? [],
191
+ duration,
192
+ filesCreated: options.filesCreated ?? 0,
193
+ status: options.status
194
+ };
195
+ }
196
+ /**
197
+ * Convert a {@link TelemetryEvent} into an OTLP-compatible JSON trace payload.
198
+ * See https://opentelemetry.io/docs/languages/sdk-configuration/otlp-exporter/
199
+ */
200
+ static buildOtlpPayload(event) {
201
+ const traceId = (0, node_crypto.randomBytes)(16).toString("hex");
202
+ const spanId = (0, node_crypto.randomBytes)(8).toString("hex");
203
+ const endTimeNs = BigInt(Date.now()) * 1000000n;
204
+ const startTimeNs = endTimeNs - BigInt(event.duration) * 1000000n;
205
+ const attributes = [
206
+ {
207
+ key: "kubb.command",
208
+ value: { stringValue: event.command }
209
+ },
210
+ {
211
+ key: "kubb.version",
212
+ value: { stringValue: event.kubbVersion }
213
+ },
214
+ {
215
+ key: "kubb.node_version",
216
+ value: { stringValue: event.nodeVersion }
217
+ },
218
+ {
219
+ key: "kubb.runtime",
220
+ value: { stringValue: event.runtime }
221
+ },
222
+ {
223
+ key: "kubb.runtime_version",
224
+ value: { stringValue: event.runtimeVersion }
225
+ },
226
+ {
227
+ key: "kubb.platform",
228
+ value: { stringValue: event.platform }
229
+ },
230
+ {
231
+ key: "kubb.ci",
232
+ value: { boolValue: event.ci }
233
+ },
234
+ {
235
+ key: "kubb.files_created",
236
+ value: { intValue: event.filesCreated }
237
+ },
238
+ {
239
+ key: "kubb.status",
240
+ value: { stringValue: event.status }
241
+ },
242
+ {
243
+ key: "kubb.plugins",
244
+ value: { arrayValue: { values: event.plugins.map((p) => ({ kvlistValue: { values: [{
245
+ key: "name",
246
+ value: { stringValue: p.name }
247
+ }, {
248
+ key: "options",
249
+ value: { stringValue: JSON.stringify({
250
+ ...p.options,
251
+ usedEnumNames: void 0
252
+ }) }
253
+ }] } })) } }
254
+ }
255
+ ];
256
+ return { resourceSpans: [{
257
+ resource: { attributes: [
258
+ {
259
+ key: "service.name",
260
+ value: { stringValue: "kubb-core" }
261
+ },
262
+ {
263
+ key: "service.version",
264
+ value: { stringValue: event.kubbVersion }
265
+ },
266
+ {
267
+ key: "telemetry.sdk.language",
268
+ value: { stringValue: "nodejs" }
269
+ }
270
+ ] },
271
+ scopeSpans: [{
272
+ scope: {
273
+ name: "kubb-core",
274
+ version: event.kubbVersion
275
+ },
276
+ spans: [{
277
+ traceId,
278
+ spanId,
279
+ name: event.command,
280
+ kind: 1,
281
+ startTimeUnixNano: String(startTimeNs),
282
+ endTimeUnixNano: String(endTimeNs),
283
+ attributes,
284
+ status: { code: event.status === "success" ? 1 : 2 }
285
+ }]
286
+ }]
287
+ }] };
288
+ }
289
+ /**
290
+ * Send an anonymous telemetry event to the Kubb OTLP endpoint. Respects `DO_NOT_TRACK` and
291
+ * `KUBB_DISABLE_TELEMETRY`, and fails silently so telemetry never interrupts a run.
292
+ */
293
+ static async send(event) {
294
+ if (Telemetry.isDisabled()) return;
295
+ await executeIfOnline(async () => {
296
+ try {
297
+ await fetch(`${OTLP_ENDPOINT}/v1/traces`, {
298
+ method: "POST",
299
+ headers: {
300
+ "Content-Type": "application/json",
301
+ "Kubb-Telemetry-Version": "1",
302
+ "Kubb-Telemetry-Source": "kubb-core"
303
+ },
304
+ body: JSON.stringify(Telemetry.buildOtlpPayload(event)),
305
+ signal: AbortSignal.timeout(5e3)
306
+ });
307
+ } catch (_e) {}
308
+ });
309
+ }
310
+ };
311
+ //#endregion
312
+ Object.defineProperty(exports, "KUBB_NPM_PACKAGE_URL", {
313
+ enumerable: true,
314
+ get: function() {
315
+ return KUBB_NPM_PACKAGE_URL;
316
+ }
317
+ });
318
+ Object.defineProperty(exports, "QUIET_FLAGS", {
319
+ enumerable: true,
320
+ get: function() {
321
+ return QUIET_FLAGS;
322
+ }
323
+ });
324
+ Object.defineProperty(exports, "Telemetry", {
325
+ enumerable: true,
326
+ get: function() {
327
+ return Telemetry;
328
+ }
329
+ });
330
+ Object.defineProperty(exports, "WATCHER_IGNORED_PATHS", {
331
+ enumerable: true,
332
+ get: function() {
333
+ return WATCHER_IGNORED_PATHS;
334
+ }
335
+ });
336
+ Object.defineProperty(exports, "canUseTTY", {
337
+ enumerable: true,
338
+ get: function() {
339
+ return canUseTTY;
340
+ }
341
+ });
342
+ Object.defineProperty(exports, "executeIfOnline", {
343
+ enumerable: true,
344
+ get: function() {
345
+ return executeIfOnline;
346
+ }
347
+ });
348
+
349
+ //# sourceMappingURL=Telemetry-DC5WVMB9.cjs.map