@kubb/cli 4.32.4 → 4.33.1

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 (133) hide show
  1. package/dist/agent-Bd1QdPVV.cjs +91 -0
  2. package/dist/agent-Bd1QdPVV.cjs.map +1 -0
  3. package/dist/agent-D83d9Pud.cjs +60 -0
  4. package/dist/agent-D83d9Pud.cjs.map +1 -0
  5. package/dist/agent-DgKQXSmR.js +57 -0
  6. package/dist/agent-DgKQXSmR.js.map +1 -0
  7. package/dist/agent-u_Ehwz6r.js +87 -0
  8. package/dist/agent-u_Ehwz6r.js.map +1 -0
  9. package/dist/constants-BTUap0zs.cjs +108 -0
  10. package/dist/constants-BTUap0zs.cjs.map +1 -0
  11. package/dist/constants-CM3dJzjK.js +67 -0
  12. package/dist/constants-CM3dJzjK.js.map +1 -0
  13. package/dist/define--M_JMcDC.js +25 -0
  14. package/dist/define--M_JMcDC.js.map +1 -0
  15. package/dist/define-D6Kfm7-Z.cjs +36 -0
  16. package/dist/define-D6Kfm7-Z.cjs.map +1 -0
  17. package/dist/errors-6mF_WKxg.js +27 -0
  18. package/dist/errors-6mF_WKxg.js.map +1 -0
  19. package/dist/errors-DBW0N9w4.cjs +44 -0
  20. package/dist/errors-DBW0N9w4.cjs.map +1 -0
  21. package/dist/generate-Bn8n4w1O.cjs +65 -0
  22. package/dist/generate-Bn8n4w1O.cjs.map +1 -0
  23. package/dist/{generate-CpWtSc45.js → generate-CAsV9wSx.js} +656 -689
  24. package/dist/generate-CAsV9wSx.js.map +1 -0
  25. package/dist/generate-D-59YK0L.js +66 -0
  26. package/dist/generate-D-59YK0L.js.map +1 -0
  27. package/dist/{generate-COj0aMS6.cjs → generate-JC65igQh.cjs} +662 -694
  28. package/dist/generate-JC65igQh.cjs.map +1 -0
  29. package/dist/index.cjs +226 -35
  30. package/dist/index.cjs.map +1 -1
  31. package/dist/index.d.ts +1 -1
  32. package/dist/index.js +226 -35
  33. package/dist/index.js.map +1 -1
  34. package/dist/init-C-InrmSY.js +302 -0
  35. package/dist/init-C-InrmSY.js.map +1 -0
  36. package/dist/init-CXP8OfMe.js +25 -0
  37. package/dist/init-CXP8OfMe.js.map +1 -0
  38. package/dist/init-CbeE-L-0.cjs +25 -0
  39. package/dist/init-CbeE-L-0.cjs.map +1 -0
  40. package/dist/init-hmolV6B4.cjs +306 -0
  41. package/dist/init-hmolV6B4.cjs.map +1 -0
  42. package/dist/jiti-Cd3S0xwr.cjs +16 -0
  43. package/dist/jiti-Cd3S0xwr.cjs.map +1 -0
  44. package/dist/jiti-e08mD2Ph.js +11 -0
  45. package/dist/jiti-e08mD2Ph.js.map +1 -0
  46. package/dist/mcp-BDxg2oJm.cjs +16 -0
  47. package/dist/mcp-BDxg2oJm.cjs.map +1 -0
  48. package/dist/mcp-ChHFPRzD.cjs +42 -0
  49. package/dist/mcp-ChHFPRzD.cjs.map +1 -0
  50. package/dist/mcp-D2SHEg_d.js +41 -0
  51. package/dist/mcp-D2SHEg_d.js.map +1 -0
  52. package/dist/mcp-MSoE4vNA.js +16 -0
  53. package/dist/mcp-MSoE4vNA.js.map +1 -0
  54. package/dist/{package-aNQWvWbS.cjs → package-CUVyeIbt.cjs} +2 -2
  55. package/dist/package-CUVyeIbt.cjs.map +1 -0
  56. package/dist/package-Cbd8OC6q.js +6 -0
  57. package/dist/package-Cbd8OC6q.js.map +1 -0
  58. package/dist/shell-7HPrTCJ5.cjs +57 -0
  59. package/dist/shell-7HPrTCJ5.cjs.map +1 -0
  60. package/dist/shell-DqqWsHCD.js +46 -0
  61. package/dist/shell-DqqWsHCD.js.map +1 -0
  62. package/dist/{telemetry-BDSSqUiG.cjs → telemetry-Cn9X1I5B.cjs} +79 -9
  63. package/dist/telemetry-Cn9X1I5B.cjs.map +1 -0
  64. package/dist/{telemetry-DYWvlxqs.js → telemetry-DxiR7clS.js} +63 -11
  65. package/dist/telemetry-DxiR7clS.js.map +1 -0
  66. package/dist/validate-BG8A3aQS.cjs +25 -0
  67. package/dist/validate-BG8A3aQS.cjs.map +1 -0
  68. package/dist/validate-BZ1UFkwA.js +25 -0
  69. package/dist/validate-BZ1UFkwA.js.map +1 -0
  70. package/dist/validate-Bbrn3Q-A.cjs +42 -0
  71. package/dist/validate-Bbrn3Q-A.cjs.map +1 -0
  72. package/dist/validate-l8vLmwKA.js +41 -0
  73. package/dist/validate-l8vLmwKA.js.map +1 -0
  74. package/package.json +6 -6
  75. package/src/commands/agent/start.ts +27 -136
  76. package/src/commands/agent.ts +6 -25
  77. package/src/commands/generate.ts +26 -158
  78. package/src/commands/init.ts +9 -360
  79. package/src/commands/mcp.ts +7 -52
  80. package/src/commands/validate.ts +9 -60
  81. package/src/constants.ts +76 -0
  82. package/src/index.ts +36 -42
  83. package/src/loggers/clackLogger.ts +65 -165
  84. package/src/loggers/fileSystemLogger.ts +2 -14
  85. package/src/loggers/githubActionsLogger.ts +58 -125
  86. package/src/loggers/plainLogger.ts +44 -92
  87. package/src/loggers/utils.ts +67 -4
  88. package/src/runners/agent.ts +100 -0
  89. package/src/runners/generate.ts +223 -102
  90. package/src/runners/init.ts +323 -0
  91. package/src/runners/mcp.ts +32 -0
  92. package/src/runners/validate.ts +35 -0
  93. package/src/utils/Writables.ts +2 -2
  94. package/src/utils/executeHooks.ts +20 -8
  95. package/src/utils/getCosmiConfig.ts +10 -11
  96. package/src/utils/getIntro.ts +1 -81
  97. package/src/utils/getSummary.ts +12 -17
  98. package/src/utils/jiti.ts +9 -0
  99. package/src/utils/packageManager.ts +4 -4
  100. package/src/utils/runHook.ts +75 -0
  101. package/src/utils/telemetry.ts +8 -26
  102. package/src/utils/watcher.ts +2 -4
  103. package/dist/agent-6COck3B9.cjs +0 -20
  104. package/dist/agent-6COck3B9.cjs.map +0 -1
  105. package/dist/agent-DMm6c5Vg.js +0 -20
  106. package/dist/agent-DMm6c5Vg.js.map +0 -1
  107. package/dist/generate-COj0aMS6.cjs.map +0 -1
  108. package/dist/generate-CpWtSc45.js.map +0 -1
  109. package/dist/init-Bdn3_qir.js +0 -304
  110. package/dist/init-Bdn3_qir.js.map +0 -1
  111. package/dist/init-CFW2kWY8.cjs +0 -308
  112. package/dist/init-CFW2kWY8.cjs.map +0 -1
  113. package/dist/mcp-DkwtARfo.cjs +0 -57
  114. package/dist/mcp-DkwtARfo.cjs.map +0 -1
  115. package/dist/mcp-DrH93Vq4.js +0 -57
  116. package/dist/mcp-DrH93Vq4.js.map +0 -1
  117. package/dist/package-BnJbGmLm.js +0 -6
  118. package/dist/package-BnJbGmLm.js.map +0 -1
  119. package/dist/package-aNQWvWbS.cjs.map +0 -1
  120. package/dist/start-CqTUu14n.js +0 -131
  121. package/dist/start-CqTUu14n.js.map +0 -1
  122. package/dist/start-D-rsIJGo.cjs +0 -134
  123. package/dist/start-D-rsIJGo.cjs.map +0 -1
  124. package/dist/telemetry-BDSSqUiG.cjs.map +0 -1
  125. package/dist/telemetry-DYWvlxqs.js.map +0 -1
  126. package/dist/validate-BlV8L8gC.js +0 -66
  127. package/dist/validate-BlV8L8gC.js.map +0 -1
  128. package/dist/validate-COhZUXF8.cjs +0 -66
  129. package/dist/validate-COhZUXF8.cjs.map +0 -1
  130. package/src/loggers/envDetection.ts +0 -28
  131. package/src/loggers/index.ts +0 -5
  132. package/src/utils/formatMsWithColor.ts +0 -22
  133. package/src/utils/randomColor.ts +0 -23
@@ -0,0 +1,57 @@
1
+ require("./chunk-ByKO4r7w.cjs");
2
+ let node_child_process = require("node:child_process");
3
+ //#region ../../internals/utils/src/shell.ts
4
+ /**
5
+ * Tokenizes a shell command string, respecting single and double quotes.
6
+ *
7
+ * @example
8
+ * tokenize('git commit -m "initial commit"')
9
+ * // → ['git', 'commit', '-m', 'initial commit']
10
+ */
11
+ function tokenize(command) {
12
+ return (command.match(/[^\s"']+|"([^"]*)"|'([^']*)'/g) ?? []).map((token) => token.replace(/^["']|["']$/g, ""));
13
+ }
14
+ /**
15
+ * Spawns `cmd` with `args` and returns a promise that settles when the child process finishes.
16
+ *
17
+ * Foreground mode (default) inherits the parent's stdio and rejects on non-zero exit or signal.
18
+ * Detached mode spawns the child in its own process group, unref's it, and resolves immediately —
19
+ * the parent can exit without waiting for the child.
20
+ */
21
+ function spawnAsync(cmd, args, options = {}) {
22
+ const { cwd = process.cwd(), env, detached = false } = options;
23
+ return new Promise((resolve, reject) => {
24
+ const child = (0, node_child_process.spawn)(cmd, args, {
25
+ stdio: detached ? "ignore" : "inherit",
26
+ cwd,
27
+ env,
28
+ detached
29
+ });
30
+ if (detached) {
31
+ child.unref();
32
+ resolve();
33
+ return;
34
+ }
35
+ child.on("close", (code, signal) => {
36
+ if (code === 0) resolve();
37
+ else if (signal !== null) reject(/* @__PURE__ */ new Error(`"${cmd} ${args.join(" ")}" was terminated by signal ${signal}`));
38
+ else reject(/* @__PURE__ */ new Error(`"${cmd} ${args.join(" ")}" exited with code ${code}`));
39
+ });
40
+ child.on("error", reject);
41
+ });
42
+ }
43
+ //#endregion
44
+ Object.defineProperty(exports, "spawnAsync", {
45
+ enumerable: true,
46
+ get: function() {
47
+ return spawnAsync;
48
+ }
49
+ });
50
+ Object.defineProperty(exports, "tokenize", {
51
+ enumerable: true,
52
+ get: function() {
53
+ return tokenize;
54
+ }
55
+ });
56
+
57
+ //# sourceMappingURL=shell-7HPrTCJ5.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shell-7HPrTCJ5.cjs","names":[],"sources":["../../../internals/utils/src/shell.ts"],"sourcesContent":["import { spawn } from 'node:child_process'\n\n/**\n * Tokenizes a shell command string, respecting single and double quotes.\n *\n * @example\n * tokenize('git commit -m \"initial commit\"')\n * // → ['git', 'commit', '-m', 'initial commit']\n */\nexport function tokenize(command: string): string[] {\n return (command.match(/[^\\s\"']+|\"([^\"]*)\"|'([^']*)'/g) ?? []).map((token) => token.replace(/^[\"']|[\"']$/g, ''))\n}\n\ntype SpawnOptions = {\n /** Working directory for the child process. Defaults to `process.cwd()`. */\n cwd?: string\n /** Environment variables passed to the child process. Defaults to the parent's `process.env`. */\n env?: NodeJS.ProcessEnv\n /**\n * When `true`, spawns a detached background process and resolves immediately.\n * The child is unref'd so the parent process can exit independently.\n * Defaults to `false` (foreground — inherits stdio and waits for exit).\n */\n detached?: boolean\n}\n\n/**\n * Spawns `cmd` with `args` and returns a promise that settles when the child process finishes.\n *\n * Foreground mode (default) inherits the parent's stdio and rejects on non-zero exit or signal.\n * Detached mode spawns the child in its own process group, unref's it, and resolves immediately —\n * the parent can exit without waiting for the child.\n */\nexport function spawnAsync(cmd: string, args: string[], options: SpawnOptions = {}): Promise<void> {\n const { cwd = process.cwd(), env, detached = false } = options\n\n return new Promise((resolve, reject) => {\n const child = spawn(cmd, args, {\n stdio: detached ? 'ignore' : 'inherit',\n cwd,\n env,\n detached,\n })\n\n if (detached) {\n child.unref()\n resolve()\n return\n }\n\n child.on('close', (code, signal) => {\n if (code === 0) {\n resolve()\n } else if (signal !== null) {\n reject(new Error(`\"${cmd} ${args.join(' ')}\" was terminated by signal ${signal}`))\n } else {\n reject(new Error(`\"${cmd} ${args.join(' ')}\" exited with code ${code}`))\n }\n })\n child.on('error', reject)\n })\n}\n"],"mappings":";;;;;;;;;;AASA,SAAgB,SAAS,SAA2B;AAClD,SAAQ,QAAQ,MAAM,gCAAgC,IAAI,EAAE,EAAE,KAAK,UAAU,MAAM,QAAQ,gBAAgB,GAAG,CAAC;;;;;;;;;AAuBjH,SAAgB,WAAW,KAAa,MAAgB,UAAwB,EAAE,EAAiB;CACjG,MAAM,EAAE,MAAM,QAAQ,KAAK,EAAE,KAAK,WAAW,UAAU;AAEvD,QAAO,IAAI,SAAS,SAAS,WAAW;EACtC,MAAM,SAAA,GAAA,mBAAA,OAAc,KAAK,MAAM;GAC7B,OAAO,WAAW,WAAW;GAC7B;GACA;GACA;GACD,CAAC;AAEF,MAAI,UAAU;AACZ,SAAM,OAAO;AACb,YAAS;AACT;;AAGF,QAAM,GAAG,UAAU,MAAM,WAAW;AAClC,OAAI,SAAS,EACX,UAAS;YACA,WAAW,KACpB,wBAAO,IAAI,MAAM,IAAI,IAAI,GAAG,KAAK,KAAK,IAAI,CAAC,6BAA6B,SAAS,CAAC;OAElF,wBAAO,IAAI,MAAM,IAAI,IAAI,GAAG,KAAK,KAAK,IAAI,CAAC,qBAAqB,OAAO,CAAC;IAE1E;AACF,QAAM,GAAG,SAAS,OAAO;GACzB"}
@@ -0,0 +1,46 @@
1
+ import "./chunk--u3MIqq1.js";
2
+ import { spawn } from "node:child_process";
3
+ //#region ../../internals/utils/src/shell.ts
4
+ /**
5
+ * Tokenizes a shell command string, respecting single and double quotes.
6
+ *
7
+ * @example
8
+ * tokenize('git commit -m "initial commit"')
9
+ * // → ['git', 'commit', '-m', 'initial commit']
10
+ */
11
+ function tokenize(command) {
12
+ return (command.match(/[^\s"']+|"([^"]*)"|'([^']*)'/g) ?? []).map((token) => token.replace(/^["']|["']$/g, ""));
13
+ }
14
+ /**
15
+ * Spawns `cmd` with `args` and returns a promise that settles when the child process finishes.
16
+ *
17
+ * Foreground mode (default) inherits the parent's stdio and rejects on non-zero exit or signal.
18
+ * Detached mode spawns the child in its own process group, unref's it, and resolves immediately —
19
+ * the parent can exit without waiting for the child.
20
+ */
21
+ function spawnAsync(cmd, args, options = {}) {
22
+ const { cwd = process.cwd(), env, detached = false } = options;
23
+ return new Promise((resolve, reject) => {
24
+ const child = spawn(cmd, args, {
25
+ stdio: detached ? "ignore" : "inherit",
26
+ cwd,
27
+ env,
28
+ detached
29
+ });
30
+ if (detached) {
31
+ child.unref();
32
+ resolve();
33
+ return;
34
+ }
35
+ child.on("close", (code, signal) => {
36
+ if (code === 0) resolve();
37
+ else if (signal !== null) reject(/* @__PURE__ */ new Error(`"${cmd} ${args.join(" ")}" was terminated by signal ${signal}`));
38
+ else reject(/* @__PURE__ */ new Error(`"${cmd} ${args.join(" ")}" exited with code ${code}`));
39
+ });
40
+ child.on("error", reject);
41
+ });
42
+ }
43
+ //#endregion
44
+ export { tokenize as n, spawnAsync as t };
45
+
46
+ //# sourceMappingURL=shell-DqqWsHCD.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shell-DqqWsHCD.js","names":[],"sources":["../../../internals/utils/src/shell.ts"],"sourcesContent":["import { spawn } from 'node:child_process'\n\n/**\n * Tokenizes a shell command string, respecting single and double quotes.\n *\n * @example\n * tokenize('git commit -m \"initial commit\"')\n * // → ['git', 'commit', '-m', 'initial commit']\n */\nexport function tokenize(command: string): string[] {\n return (command.match(/[^\\s\"']+|\"([^\"]*)\"|'([^']*)'/g) ?? []).map((token) => token.replace(/^[\"']|[\"']$/g, ''))\n}\n\ntype SpawnOptions = {\n /** Working directory for the child process. Defaults to `process.cwd()`. */\n cwd?: string\n /** Environment variables passed to the child process. Defaults to the parent's `process.env`. */\n env?: NodeJS.ProcessEnv\n /**\n * When `true`, spawns a detached background process and resolves immediately.\n * The child is unref'd so the parent process can exit independently.\n * Defaults to `false` (foreground — inherits stdio and waits for exit).\n */\n detached?: boolean\n}\n\n/**\n * Spawns `cmd` with `args` and returns a promise that settles when the child process finishes.\n *\n * Foreground mode (default) inherits the parent's stdio and rejects on non-zero exit or signal.\n * Detached mode spawns the child in its own process group, unref's it, and resolves immediately —\n * the parent can exit without waiting for the child.\n */\nexport function spawnAsync(cmd: string, args: string[], options: SpawnOptions = {}): Promise<void> {\n const { cwd = process.cwd(), env, detached = false } = options\n\n return new Promise((resolve, reject) => {\n const child = spawn(cmd, args, {\n stdio: detached ? 'ignore' : 'inherit',\n cwd,\n env,\n detached,\n })\n\n if (detached) {\n child.unref()\n resolve()\n return\n }\n\n child.on('close', (code, signal) => {\n if (code === 0) {\n resolve()\n } else if (signal !== null) {\n reject(new Error(`\"${cmd} ${args.join(' ')}\" was terminated by signal ${signal}`))\n } else {\n reject(new Error(`\"${cmd} ${args.join(' ')}\" exited with code ${code}`))\n }\n })\n child.on('error', reject)\n })\n}\n"],"mappings":";;;;;;;;;;AASA,SAAgB,SAAS,SAA2B;AAClD,SAAQ,QAAQ,MAAM,gCAAgC,IAAI,EAAE,EAAE,KAAK,UAAU,MAAM,QAAQ,gBAAgB,GAAG,CAAC;;;;;;;;;AAuBjH,SAAgB,WAAW,KAAa,MAAgB,UAAwB,EAAE,EAAiB;CACjG,MAAM,EAAE,MAAM,QAAQ,KAAK,EAAE,KAAK,WAAW,UAAU;AAEvD,QAAO,IAAI,SAAS,SAAS,WAAW;EACtC,MAAM,QAAQ,MAAM,KAAK,MAAM;GAC7B,OAAO,WAAW,WAAW;GAC7B;GACA;GACA;GACD,CAAC;AAEF,MAAI,UAAU;AACZ,SAAM,OAAO;AACb,YAAS;AACT;;AAGF,QAAM,GAAG,UAAU,MAAM,WAAW;AAClC,OAAI,SAAS,EACX,UAAS;YACA,WAAW,KACpB,wBAAO,IAAI,MAAM,IAAI,IAAI,GAAG,KAAK,KAAK,IAAI,CAAC,6BAA6B,SAAS,CAAC;OAElF,wBAAO,IAAI,MAAM,IAAI,IAAI,GAAG,KAAK,KAAK,IAAI,CAAC,qBAAqB,OAAO,CAAC;IAE1E;AACF,QAAM,GAAG,SAAS,OAAO;GACzB"}
@@ -1,18 +1,70 @@
1
1
  const require_chunk = require("./chunk-ByKO4r7w.cjs");
2
+ const require_constants = require("./constants-BTUap0zs.cjs");
2
3
  let node_crypto = require("node:crypto");
4
+ let node_dns = require("node:dns");
3
5
  let node_os = require("node:os");
4
6
  node_os = require_chunk.__toESM(node_os);
5
7
  let node_process = require("node:process");
6
8
  node_process = require_chunk.__toESM(node_process);
7
- let _kubb_core_utils = require("@kubb/core/utils");
9
+ //#region ../../internals/utils/src/env.ts
10
+ /**
11
+ * Returns `true` when running inside a GitHub Actions workflow.
12
+ */
13
+ function isGitHubActions() {
14
+ return !!process.env.GITHUB_ACTIONS;
15
+ }
16
+ /**
17
+ * Returns `true` when the process is running in a CI environment.
18
+ * Covers GitHub Actions, GitLab CI, CircleCI, Travis CI, Jenkins, Bitbucket,
19
+ * TeamCity, Buildkite, and Azure Pipelines.
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 and is not running in CI.
26
+ */
27
+ function canUseTTY() {
28
+ return !!process.stdout.isTTY && !isCIEnvironment();
29
+ }
30
+ //#endregion
31
+ //#region ../../internals/utils/src/network.ts
32
+ /** Well-known stable domains used as DNS probes to check internet connectivity. */
33
+ const TEST_DOMAINS = [
34
+ "dns.google.com",
35
+ "cloudflare.com",
36
+ "one.one.one.one"
37
+ ];
38
+ /**
39
+ * Returns `true` when the system has internet connectivity.
40
+ * Uses DNS resolution against well-known stable domains as a lightweight probe.
41
+ */
42
+ async function isOnline() {
43
+ for (const domain of TEST_DOMAINS) try {
44
+ await node_dns.promises.resolve(domain);
45
+ return true;
46
+ } catch {}
47
+ return false;
48
+ }
49
+ /**
50
+ * Executes `fn` only when the system is online. Returns `null` when offline or on error.
51
+ */
52
+ async function executeIfOnline(fn) {
53
+ if (!await isOnline()) return null;
54
+ try {
55
+ return await fn();
56
+ } catch {
57
+ return null;
58
+ }
59
+ }
60
+ //#endregion
8
61
  //#region src/utils/telemetry.ts
9
- const OTLP_ENDPOINT = "https://otlp.kubb.dev";
10
62
  /**
11
- * Detect whether the current process is running inside a CI environment by
12
- * checking the well-known environment variables set by all major CI systems.
63
+ * Detect whether the current process is running inside a CI environment.
64
+ * Delegates to the canonical isCIEnvironment() from envDetection.
13
65
  */
14
66
  function isCi() {
15
- 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"]);
67
+ return isCIEnvironment();
16
68
  }
17
69
  /**
18
70
  * Check if telemetry is disabled via DO_NOT_TRACK or KUBB_DISABLE_TELEMETRY.
@@ -113,9 +165,9 @@ function buildOtlpPayload(event) {
113
165
  */
114
166
  async function sendTelemetry(event) {
115
167
  if (isTelemetryDisabled()) return;
116
- await (0, _kubb_core_utils.executeIfOnline)(async () => {
168
+ await executeIfOnline(async () => {
117
169
  try {
118
- await fetch(`${OTLP_ENDPOINT}/v1/traces`, {
170
+ await fetch(`${require_constants.OTLP_ENDPOINT}/v1/traces`, {
119
171
  method: "POST",
120
172
  headers: {
121
173
  "Content-Type": "application/json",
@@ -138,7 +190,7 @@ function buildTelemetryEvent(options) {
138
190
  return {
139
191
  command: options.command,
140
192
  kubbVersion: options.kubbVersion,
141
- nodeVersion: node_process.default.versions.node.split(".")[0] ?? "unknown",
193
+ nodeVersion: node_process.default.versions.node.split(".")[0],
142
194
  platform: node_os.default.platform(),
143
195
  ci: isCi(),
144
196
  plugins: options.plugins ?? [],
@@ -154,6 +206,24 @@ Object.defineProperty(exports, "buildTelemetryEvent", {
154
206
  return buildTelemetryEvent;
155
207
  }
156
208
  });
209
+ Object.defineProperty(exports, "canUseTTY", {
210
+ enumerable: true,
211
+ get: function() {
212
+ return canUseTTY;
213
+ }
214
+ });
215
+ Object.defineProperty(exports, "executeIfOnline", {
216
+ enumerable: true,
217
+ get: function() {
218
+ return executeIfOnline;
219
+ }
220
+ });
221
+ Object.defineProperty(exports, "isGitHubActions", {
222
+ enumerable: true,
223
+ get: function() {
224
+ return isGitHubActions;
225
+ }
226
+ });
157
227
  Object.defineProperty(exports, "isTelemetryDisabled", {
158
228
  enumerable: true,
159
229
  get: function() {
@@ -167,4 +237,4 @@ Object.defineProperty(exports, "sendTelemetry", {
167
237
  }
168
238
  });
169
239
 
170
- //# sourceMappingURL=telemetry-BDSSqUiG.cjs.map
240
+ //# sourceMappingURL=telemetry-Cn9X1I5B.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"telemetry-Cn9X1I5B.cjs","names":["dnsPromises","process","OTLP_ENDPOINT","os"],"sources":["../../../internals/utils/src/env.ts","../../../internals/utils/src/network.ts","../src/utils/telemetry.ts"],"sourcesContent":["/**\n * Returns `true` when running inside a GitHub Actions workflow.\n */\nexport function isGitHubActions(): boolean {\n return !!process.env.GITHUB_ACTIONS\n}\n\n/**\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 */\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 and is not running in CI.\n */\nexport function canUseTTY(): boolean {\n return !!process.stdout.isTTY && !isCIEnvironment()\n}\n","import { promises as dnsPromises } from 'node:dns'\n\n/** Well-known stable domains used as DNS probes to check internet connectivity. */\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 * Uses DNS resolution against well-known stable domains as a lightweight probe.\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 */\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","import { randomBytes } from 'node:crypto'\nimport os from 'node:os'\nimport process from 'node:process'\nimport { executeIfOnline, isCIEnvironment } 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: OtlpAnyValue[] } }\ntype OtlpKvListValue = { kvlistValue: { values: 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: OtlpKeyValue[]\n droppedAttributesCount?: number\n}\n\ntype OtlpInstrumentationScope = {\n name: string\n version?: string\n attributes?: 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?: OtlpKeyValue[]\n droppedAttributesCount?: number\n events?: OtlpSpanEvent[]\n droppedEventsCount?: number\n links?: OtlpSpanLink[]\n droppedLinksCount?: number\n status?: OtlpStatus\n}\n\ntype OtlpSpanEvent = {\n timeUnixNano: string\n name: string\n attributes?: OtlpKeyValue[]\n droppedAttributesCount?: number\n}\n\ntype OtlpSpanLink = {\n traceId: string\n spanId: string\n traceState?: string\n attributes?: OtlpKeyValue[]\n droppedAttributesCount?: number\n}\n\ntype OtlpScopeSpans = {\n scope: OtlpInstrumentationScope\n spans: OtlpSpan[]\n schemaUrl?: string\n}\n\ntype OtlpResourceSpans = {\n resource: OtlpResource\n scopeSpans: OtlpScopeSpans[]\n schemaUrl?: string\n}\n\n/** Root payload sent to POST /v1/traces */\ntype OtlpExportTraceServiceRequest = {\n resourceSpans: OtlpResourceSpans[]\n}\n\nexport type TelemetryPlugin = {\n name: string\n options: Record<string, unknown>\n}\n\ntype TelemetryEvent = {\n command: string\n kubbVersion: string\n nodeVersion: string\n platform: string\n ci: boolean\n plugins: TelemetryPlugin[]\n duration: number\n filesCreated: number\n status: 'success' | 'failed'\n}\n\n/**\n * Detect whether the current process is running inside a CI environment.\n * Delegates to the canonical isCIEnvironment() from envDetection.\n */\nexport function isCi(): boolean {\n return isCIEnvironment()\n}\n\n/**\n * Check if telemetry is disabled via DO_NOT_TRACK or KUBB_DISABLE_TELEMETRY.\n * Respects the standard DO_NOT_TRACK convention used across development tools.\n */\nexport function isTelemetryDisabled(): 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 * Convert a TelemetryEvent into an OTLP-compatible JSON trace payload.\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: 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.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 { key: 'options', value: { stringValue: JSON.stringify({ ...p.options, usedEnumNames: undefined }) } },\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-cli' } },\n { key: 'service.version', value: { stringValue: event.kubbVersion } },\n { key: 'telemetry.sdk.language', value: { stringValue: 'nodejs' } },\n ],\n },\n scopeSpans: [\n {\n scope: { name: 'kubb-cli', 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: { code: (event.status === 'success' ? 1 : 2) satisfies OtlpStatusCode },\n },\n ],\n },\n ],\n },\n ],\n }\n}\n\n/**\n * Send an anonymous telemetry event to the Kubb OTLP endpoint.\n * Respects DO_NOT_TRACK and KUBB_DISABLE_TELEMETRY environment variables.\n * Fails silently to never interrupt the generation process.\n */\nexport async function sendTelemetry(event: TelemetryEvent): Promise<void> {\n if (isTelemetryDisabled()) {\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-cli',\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 CLI\n }\n })\n}\n\n/**\n * Build an anonymous telemetry payload from a completed generation run.\n * No file paths, OpenAPI specs, or secrets are included.\n */\nexport function buildTelemetryEvent(options: {\n command: 'generate' | 'mcp' | 'validate' | 'agent'\n kubbVersion: string\n plugins?: 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 platform: os.platform(),\n ci: isCi(),\n plugins: options.plugins ?? [],\n duration,\n filesCreated: options.filesCreated ?? 0,\n status: options.status,\n }\n}\n"],"mappings":";;;;;;;;;;;;AAGA,SAAgB,kBAA2B;AACzC,QAAO,CAAC,CAAC,QAAQ,IAAI;;;;;;;AAQvB,SAAgB,kBAA2B;AACzC,QAAO,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;;;;;AAOhB,SAAgB,YAAqB;AACnC,QAAO,CAAC,CAAC,QAAQ,OAAO,SAAS,CAAC,iBAAiB;;;;;AC5BrD,MAAM,eAAe;CAAC;CAAkB;CAAkB;CAAkB;;;;;AAM5E,eAAsB,WAA6B;AACjD,MAAK,MAAM,UAAU,aACnB,KAAI;AACF,QAAMA,SAAAA,SAAY,QAAQ,OAAO;AACjC,SAAO;SACD;AAKV,QAAO;;;;;AAMT,eAAsB,gBAAmB,IAAyC;AAChF,KAAI,CAAE,MAAM,UAAU,CAAG,QAA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AAQ,WAAW,EAAE;EAC9B;EACA,cAAc,QAAQ,gBAAgB;EACtC,QAAQ,QAAQ;EACjB"}
@@ -1,23 +1,75 @@
1
1
  import "./chunk--u3MIqq1.js";
2
+ import { n as OTLP_ENDPOINT } from "./constants-CM3dJzjK.js";
2
3
  import { randomBytes } from "node:crypto";
4
+ import { promises } from "node:dns";
3
5
  import os from "node:os";
4
- import process from "node:process";
5
- import { executeIfOnline } from "@kubb/core/utils";
6
+ import process$1 from "node:process";
7
+ //#region ../../internals/utils/src/env.ts
8
+ /**
9
+ * Returns `true` when running inside a GitHub Actions workflow.
10
+ */
11
+ function isGitHubActions() {
12
+ return !!process.env.GITHUB_ACTIONS;
13
+ }
14
+ /**
15
+ * Returns `true` when the process is running in a CI environment.
16
+ * Covers GitHub Actions, GitLab CI, CircleCI, Travis CI, Jenkins, Bitbucket,
17
+ * TeamCity, Buildkite, and Azure Pipelines.
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 and is not running in CI.
24
+ */
25
+ function canUseTTY() {
26
+ return !!process.stdout.isTTY && !isCIEnvironment();
27
+ }
28
+ //#endregion
29
+ //#region ../../internals/utils/src/network.ts
30
+ /** Well-known stable domains used as DNS probes to check internet connectivity. */
31
+ const TEST_DOMAINS = [
32
+ "dns.google.com",
33
+ "cloudflare.com",
34
+ "one.one.one.one"
35
+ ];
36
+ /**
37
+ * Returns `true` when the system has internet connectivity.
38
+ * Uses DNS resolution against well-known stable domains as a lightweight probe.
39
+ */
40
+ async function isOnline() {
41
+ for (const domain of TEST_DOMAINS) try {
42
+ await promises.resolve(domain);
43
+ return true;
44
+ } catch {}
45
+ return false;
46
+ }
47
+ /**
48
+ * Executes `fn` only when the system is online. Returns `null` when offline or on error.
49
+ */
50
+ async function executeIfOnline(fn) {
51
+ if (!await isOnline()) return null;
52
+ try {
53
+ return await fn();
54
+ } catch {
55
+ return null;
56
+ }
57
+ }
58
+ //#endregion
6
59
  //#region src/utils/telemetry.ts
7
- const OTLP_ENDPOINT = "https://otlp.kubb.dev";
8
60
  /**
9
- * Detect whether the current process is running inside a CI environment by
10
- * checking the well-known environment variables set by all major CI systems.
61
+ * Detect whether the current process is running inside a CI environment.
62
+ * Delegates to the canonical isCIEnvironment() from envDetection.
11
63
  */
12
64
  function isCi() {
13
- 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"]);
65
+ return isCIEnvironment();
14
66
  }
15
67
  /**
16
68
  * Check if telemetry is disabled via DO_NOT_TRACK or KUBB_DISABLE_TELEMETRY.
17
69
  * Respects the standard DO_NOT_TRACK convention used across development tools.
18
70
  */
19
71
  function isTelemetryDisabled() {
20
- return process.env["DO_NOT_TRACK"] === "1" || process.env["DO_NOT_TRACK"] === "true" || process.env["KUBB_DISABLE_TELEMETRY"] === "1" || process.env["KUBB_DISABLE_TELEMETRY"] === "true";
72
+ 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";
21
73
  }
22
74
  /**
23
75
  * Convert a TelemetryEvent into an OTLP-compatible JSON trace payload.
@@ -131,12 +183,12 @@ async function sendTelemetry(event) {
131
183
  * No file paths, OpenAPI specs, or secrets are included.
132
184
  */
133
185
  function buildTelemetryEvent(options) {
134
- const [seconds, nanoseconds] = process.hrtime(options.hrStart);
186
+ const [seconds, nanoseconds] = process$1.hrtime(options.hrStart);
135
187
  const duration = Math.round(seconds * 1e3 + nanoseconds / 1e6);
136
188
  return {
137
189
  command: options.command,
138
190
  kubbVersion: options.kubbVersion,
139
- nodeVersion: process.versions.node.split(".")[0] ?? "unknown",
191
+ nodeVersion: process$1.versions.node.split(".")[0],
140
192
  platform: os.platform(),
141
193
  ci: isCi(),
142
194
  plugins: options.plugins ?? [],
@@ -146,6 +198,6 @@ function buildTelemetryEvent(options) {
146
198
  };
147
199
  }
148
200
  //#endregion
149
- export { isTelemetryDisabled as n, sendTelemetry as r, buildTelemetryEvent as t };
201
+ export { canUseTTY as a, executeIfOnline as i, isTelemetryDisabled as n, isGitHubActions as o, sendTelemetry as r, buildTelemetryEvent as t };
150
202
 
151
- //# sourceMappingURL=telemetry-DYWvlxqs.js.map
203
+ //# sourceMappingURL=telemetry-DxiR7clS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"telemetry-DxiR7clS.js","names":["dnsPromises","process"],"sources":["../../../internals/utils/src/env.ts","../../../internals/utils/src/network.ts","../src/utils/telemetry.ts"],"sourcesContent":["/**\n * Returns `true` when running inside a GitHub Actions workflow.\n */\nexport function isGitHubActions(): boolean {\n return !!process.env.GITHUB_ACTIONS\n}\n\n/**\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 */\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 and is not running in CI.\n */\nexport function canUseTTY(): boolean {\n return !!process.stdout.isTTY && !isCIEnvironment()\n}\n","import { promises as dnsPromises } from 'node:dns'\n\n/** Well-known stable domains used as DNS probes to check internet connectivity. */\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 * Uses DNS resolution against well-known stable domains as a lightweight probe.\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 */\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","import { randomBytes } from 'node:crypto'\nimport os from 'node:os'\nimport process from 'node:process'\nimport { executeIfOnline, isCIEnvironment } 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: OtlpAnyValue[] } }\ntype OtlpKvListValue = { kvlistValue: { values: 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: OtlpKeyValue[]\n droppedAttributesCount?: number\n}\n\ntype OtlpInstrumentationScope = {\n name: string\n version?: string\n attributes?: 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?: OtlpKeyValue[]\n droppedAttributesCount?: number\n events?: OtlpSpanEvent[]\n droppedEventsCount?: number\n links?: OtlpSpanLink[]\n droppedLinksCount?: number\n status?: OtlpStatus\n}\n\ntype OtlpSpanEvent = {\n timeUnixNano: string\n name: string\n attributes?: OtlpKeyValue[]\n droppedAttributesCount?: number\n}\n\ntype OtlpSpanLink = {\n traceId: string\n spanId: string\n traceState?: string\n attributes?: OtlpKeyValue[]\n droppedAttributesCount?: number\n}\n\ntype OtlpScopeSpans = {\n scope: OtlpInstrumentationScope\n spans: OtlpSpan[]\n schemaUrl?: string\n}\n\ntype OtlpResourceSpans = {\n resource: OtlpResource\n scopeSpans: OtlpScopeSpans[]\n schemaUrl?: string\n}\n\n/** Root payload sent to POST /v1/traces */\ntype OtlpExportTraceServiceRequest = {\n resourceSpans: OtlpResourceSpans[]\n}\n\nexport type TelemetryPlugin = {\n name: string\n options: Record<string, unknown>\n}\n\ntype TelemetryEvent = {\n command: string\n kubbVersion: string\n nodeVersion: string\n platform: string\n ci: boolean\n plugins: TelemetryPlugin[]\n duration: number\n filesCreated: number\n status: 'success' | 'failed'\n}\n\n/**\n * Detect whether the current process is running inside a CI environment.\n * Delegates to the canonical isCIEnvironment() from envDetection.\n */\nexport function isCi(): boolean {\n return isCIEnvironment()\n}\n\n/**\n * Check if telemetry is disabled via DO_NOT_TRACK or KUBB_DISABLE_TELEMETRY.\n * Respects the standard DO_NOT_TRACK convention used across development tools.\n */\nexport function isTelemetryDisabled(): 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 * Convert a TelemetryEvent into an OTLP-compatible JSON trace payload.\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: 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.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 { key: 'options', value: { stringValue: JSON.stringify({ ...p.options, usedEnumNames: undefined }) } },\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-cli' } },\n { key: 'service.version', value: { stringValue: event.kubbVersion } },\n { key: 'telemetry.sdk.language', value: { stringValue: 'nodejs' } },\n ],\n },\n scopeSpans: [\n {\n scope: { name: 'kubb-cli', 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: { code: (event.status === 'success' ? 1 : 2) satisfies OtlpStatusCode },\n },\n ],\n },\n ],\n },\n ],\n }\n}\n\n/**\n * Send an anonymous telemetry event to the Kubb OTLP endpoint.\n * Respects DO_NOT_TRACK and KUBB_DISABLE_TELEMETRY environment variables.\n * Fails silently to never interrupt the generation process.\n */\nexport async function sendTelemetry(event: TelemetryEvent): Promise<void> {\n if (isTelemetryDisabled()) {\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-cli',\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 CLI\n }\n })\n}\n\n/**\n * Build an anonymous telemetry payload from a completed generation run.\n * No file paths, OpenAPI specs, or secrets are included.\n */\nexport function buildTelemetryEvent(options: {\n command: 'generate' | 'mcp' | 'validate' | 'agent'\n kubbVersion: string\n plugins?: 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 platform: os.platform(),\n ci: isCi(),\n plugins: options.plugins ?? [],\n duration,\n filesCreated: options.filesCreated ?? 0,\n status: options.status,\n }\n}\n"],"mappings":";;;;;;;;;;AAGA,SAAgB,kBAA2B;AACzC,QAAO,CAAC,CAAC,QAAQ,IAAI;;;;;;;AAQvB,SAAgB,kBAA2B;AACzC,QAAO,CAAC,EACN,QAAQ,IAAI,MACZ,QAAQ,IAAI,kBACZ,QAAQ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iBAAiB,MAAM,CAAC;IAC7C,QAAQ,YAAY,QAAQ,IAAM;IACnC,CAAC;WACK,IAAI;GAGb;;;;;;AAOJ,SAAgB,oBAAoB,SAOjB;CACjB,MAAM,CAAC,SAAS,eAAeA,UAAQ,OAAO,QAAQ,QAAQ;CAC9D,MAAM,WAAW,KAAK,MAAM,UAAU,MAAO,cAAc,IAAI;AAE/D,QAAO;EACL,SAAS,QAAQ;EACjB,aAAa,QAAQ;EACrB,aAAaA,UAAQ,SAAS,KAAK,MAAM,IAAI,CAAC;EAC9C,UAAU,GAAG,UAAU;EACvB,IAAI,MAAM;EACV,SAAS,QAAQ,WAAW,EAAE;EAC9B;EACA,cAAc,QAAQ,gBAAgB;EACtC,QAAQ,QAAQ;EACjB"}
@@ -0,0 +1,25 @@
1
+ require("./chunk-ByKO4r7w.cjs");
2
+ const require_define = require("./define-D6Kfm7-Z.cjs");
3
+ const require_package = require("./package-CUVyeIbt.cjs");
4
+ //#region src/commands/validate.ts
5
+ const command = require_define.defineCommand({
6
+ name: "validate",
7
+ description: "Validate a Swagger/OpenAPI file",
8
+ options: { input: {
9
+ type: "string",
10
+ description: "Path to Swagger/OpenAPI file",
11
+ short: "i",
12
+ required: true
13
+ } },
14
+ async run({ values }) {
15
+ const { runValidate } = await Promise.resolve().then(() => require("./validate-Bbrn3Q-A.cjs"));
16
+ await runValidate({
17
+ input: values.input,
18
+ version: require_package.version
19
+ });
20
+ }
21
+ });
22
+ //#endregion
23
+ exports.command = command;
24
+
25
+ //# sourceMappingURL=validate-BG8A3aQS.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-BG8A3aQS.cjs","names":["defineCommand"],"sources":["../src/commands/validate.ts"],"sourcesContent":["import { defineCommand } from '@internals/utils'\nimport { version } from '../../package.json'\n\nexport const command = defineCommand({\n name: 'validate',\n description: 'Validate a Swagger/OpenAPI file',\n options: {\n input: { type: 'string', description: 'Path to Swagger/OpenAPI file', short: 'i', required: true },\n },\n async run({ values }) {\n const { runValidate } = await import('../runners/validate.ts')\n\n await runValidate({ input: values.input, version })\n },\n})\n"],"mappings":";;;;AAGA,MAAa,UAAUA,eAAAA,cAAc;CACnC,MAAM;CACN,aAAa;CACb,SAAS,EACP,OAAO;EAAE,MAAM;EAAU,aAAa;EAAgC,OAAO;EAAK,UAAU;EAAM,EACnG;CACD,MAAM,IAAI,EAAE,UAAU;EACpB,MAAM,EAAE,gBAAgB,MAAA,QAAA,SAAA,CAAA,WAAA,QAAM,0BAAA,CAAA;AAE9B,QAAM,YAAY;GAAE,OAAO,OAAO;GAAO,SAAA,gBAAA;GAAS,CAAC;;CAEtD,CAAC"}
@@ -0,0 +1,25 @@
1
+ import "./chunk--u3MIqq1.js";
2
+ import { n as defineCommand } from "./define--M_JMcDC.js";
3
+ import { t as version } from "./package-Cbd8OC6q.js";
4
+ //#region src/commands/validate.ts
5
+ const command = defineCommand({
6
+ name: "validate",
7
+ description: "Validate a Swagger/OpenAPI file",
8
+ options: { input: {
9
+ type: "string",
10
+ description: "Path to Swagger/OpenAPI file",
11
+ short: "i",
12
+ required: true
13
+ } },
14
+ async run({ values }) {
15
+ const { runValidate } = await import("./validate-l8vLmwKA.js");
16
+ await runValidate({
17
+ input: values.input,
18
+ version
19
+ });
20
+ }
21
+ });
22
+ //#endregion
23
+ export { command };
24
+
25
+ //# sourceMappingURL=validate-BZ1UFkwA.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-BZ1UFkwA.js","names":[],"sources":["../src/commands/validate.ts"],"sourcesContent":["import { defineCommand } from '@internals/utils'\nimport { version } from '../../package.json'\n\nexport const command = defineCommand({\n name: 'validate',\n description: 'Validate a Swagger/OpenAPI file',\n options: {\n input: { type: 'string', description: 'Path to Swagger/OpenAPI file', short: 'i', required: true },\n },\n async run({ values }) {\n const { runValidate } = await import('../runners/validate.ts')\n\n await runValidate({ input: values.input, version })\n },\n})\n"],"mappings":";;;;AAGA,MAAa,UAAU,cAAc;CACnC,MAAM;CACN,aAAa;CACb,SAAS,EACP,OAAO;EAAE,MAAM;EAAU,aAAa;EAAgC,OAAO;EAAK,UAAU;EAAM,EACnG;CACD,MAAM,IAAI,EAAE,UAAU;EACpB,MAAM,EAAE,gBAAgB,MAAM,OAAO;AAErC,QAAM,YAAY;GAAE,OAAO,OAAO;GAAO;GAAS,CAAC;;CAEtD,CAAC"}
@@ -0,0 +1,42 @@
1
+ const require_chunk = require("./chunk-ByKO4r7w.cjs");
2
+ const require_errors = require("./errors-DBW0N9w4.cjs");
3
+ const require_telemetry = require("./telemetry-Cn9X1I5B.cjs");
4
+ const require_jiti = require("./jiti-Cd3S0xwr.cjs");
5
+ let node_process = require("node:process");
6
+ node_process = require_chunk.__toESM(node_process);
7
+ //#region src/runners/validate.ts
8
+ async function runValidate({ input, version }) {
9
+ let mod;
10
+ try {
11
+ mod = await require_jiti.jiti.import("@kubb/oas", { default: true });
12
+ } catch (_e) {
13
+ console.error(`Import of '@kubb/oas' is required to do validation`);
14
+ node_process.default.exit(1);
15
+ }
16
+ const { parse } = mod;
17
+ const hrStart = node_process.default.hrtime();
18
+ try {
19
+ await (await parse(input)).validate();
20
+ await require_telemetry.sendTelemetry(require_telemetry.buildTelemetryEvent({
21
+ command: "validate",
22
+ kubbVersion: version,
23
+ hrStart,
24
+ status: "success"
25
+ }));
26
+ console.log("✅ Validation success");
27
+ } catch (error) {
28
+ await require_telemetry.sendTelemetry(require_telemetry.buildTelemetryEvent({
29
+ command: "validate",
30
+ kubbVersion: version,
31
+ hrStart,
32
+ status: "failed"
33
+ }));
34
+ console.error("❌ Validation failed");
35
+ console.error(require_errors.getErrorMessage(error));
36
+ node_process.default.exit(1);
37
+ }
38
+ }
39
+ //#endregion
40
+ exports.runValidate = runValidate;
41
+
42
+ //# sourceMappingURL=validate-Bbrn3Q-A.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-Bbrn3Q-A.cjs","names":["jiti","process","sendTelemetry","buildTelemetryEvent","getErrorMessage"],"sources":["../src/runners/validate.ts"],"sourcesContent":["import process from 'node:process'\nimport { getErrorMessage } from '@internals/utils'\nimport type * as OasModule from '@kubb/oas'\nimport { jiti } from '../utils/jiti.ts'\nimport { buildTelemetryEvent, sendTelemetry } from '../utils/telemetry.ts'\n\ntype ValidateOptions = {\n input: string\n version: string\n}\n\nexport async function runValidate({ input, version }: ValidateOptions): Promise<void> {\n let mod: typeof OasModule\n try {\n mod = (await jiti.import('@kubb/oas', { default: true })) as typeof OasModule\n } catch (_e) {\n console.error(`Import of '@kubb/oas' is required to do validation`)\n process.exit(1)\n }\n\n const { parse } = mod\n const hrStart = process.hrtime()\n try {\n const oas = await parse(input)\n await oas.validate()\n\n await sendTelemetry(buildTelemetryEvent({ command: 'validate', kubbVersion: version, hrStart, status: 'success' }))\n console.log('✅ Validation success')\n } catch (error) {\n await sendTelemetry(buildTelemetryEvent({ command: 'validate', kubbVersion: version, hrStart, status: 'failed' }))\n console.error('❌ Validation failed')\n console.error(getErrorMessage(error))\n process.exit(1)\n }\n}\n"],"mappings":";;;;;;;AAWA,eAAsB,YAAY,EAAE,OAAO,WAA2C;CACpF,IAAI;AACJ,KAAI;AACF,QAAO,MAAMA,aAAAA,KAAK,OAAO,aAAa,EAAE,SAAS,MAAM,CAAC;UACjD,IAAI;AACX,UAAQ,MAAM,qDAAqD;AACnE,eAAA,QAAQ,KAAK,EAAE;;CAGjB,MAAM,EAAE,UAAU;CAClB,MAAM,UAAUC,aAAAA,QAAQ,QAAQ;AAChC,KAAI;AAEF,SADY,MAAM,MAAM,MAAM,EACpB,UAAU;AAEpB,QAAMC,kBAAAA,cAAcC,kBAAAA,oBAAoB;GAAE,SAAS;GAAY,aAAa;GAAS;GAAS,QAAQ;GAAW,CAAC,CAAC;AACnH,UAAQ,IAAI,uBAAuB;UAC5B,OAAO;AACd,QAAMD,kBAAAA,cAAcC,kBAAAA,oBAAoB;GAAE,SAAS;GAAY,aAAa;GAAS;GAAS,QAAQ;GAAU,CAAC,CAAC;AAClH,UAAQ,MAAM,sBAAsB;AACpC,UAAQ,MAAMC,eAAAA,gBAAgB,MAAM,CAAC;AACrC,eAAA,QAAQ,KAAK,EAAE"}
@@ -0,0 +1,41 @@
1
+ import "./chunk--u3MIqq1.js";
2
+ import { t as getErrorMessage } from "./errors-6mF_WKxg.js";
3
+ import { r as sendTelemetry, t as buildTelemetryEvent } from "./telemetry-DxiR7clS.js";
4
+ import { t as jiti } from "./jiti-e08mD2Ph.js";
5
+ import process from "node:process";
6
+ //#region src/runners/validate.ts
7
+ async function runValidate({ input, version }) {
8
+ let mod;
9
+ try {
10
+ mod = await jiti.import("@kubb/oas", { default: true });
11
+ } catch (_e) {
12
+ console.error(`Import of '@kubb/oas' is required to do validation`);
13
+ process.exit(1);
14
+ }
15
+ const { parse } = mod;
16
+ const hrStart = process.hrtime();
17
+ try {
18
+ await (await parse(input)).validate();
19
+ await sendTelemetry(buildTelemetryEvent({
20
+ command: "validate",
21
+ kubbVersion: version,
22
+ hrStart,
23
+ status: "success"
24
+ }));
25
+ console.log("✅ Validation success");
26
+ } catch (error) {
27
+ await sendTelemetry(buildTelemetryEvent({
28
+ command: "validate",
29
+ kubbVersion: version,
30
+ hrStart,
31
+ status: "failed"
32
+ }));
33
+ console.error("❌ Validation failed");
34
+ console.error(getErrorMessage(error));
35
+ process.exit(1);
36
+ }
37
+ }
38
+ //#endregion
39
+ export { runValidate };
40
+
41
+ //# sourceMappingURL=validate-l8vLmwKA.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-l8vLmwKA.js","names":[],"sources":["../src/runners/validate.ts"],"sourcesContent":["import process from 'node:process'\nimport { getErrorMessage } from '@internals/utils'\nimport type * as OasModule from '@kubb/oas'\nimport { jiti } from '../utils/jiti.ts'\nimport { buildTelemetryEvent, sendTelemetry } from '../utils/telemetry.ts'\n\ntype ValidateOptions = {\n input: string\n version: string\n}\n\nexport async function runValidate({ input, version }: ValidateOptions): Promise<void> {\n let mod: typeof OasModule\n try {\n mod = (await jiti.import('@kubb/oas', { default: true })) as typeof OasModule\n } catch (_e) {\n console.error(`Import of '@kubb/oas' is required to do validation`)\n process.exit(1)\n }\n\n const { parse } = mod\n const hrStart = process.hrtime()\n try {\n const oas = await parse(input)\n await oas.validate()\n\n await sendTelemetry(buildTelemetryEvent({ command: 'validate', kubbVersion: version, hrStart, status: 'success' }))\n console.log('✅ Validation success')\n } catch (error) {\n await sendTelemetry(buildTelemetryEvent({ command: 'validate', kubbVersion: version, hrStart, status: 'failed' }))\n console.error('❌ Validation failed')\n console.error(getErrorMessage(error))\n process.exit(1)\n }\n}\n"],"mappings":";;;;;;AAWA,eAAsB,YAAY,EAAE,OAAO,WAA2C;CACpF,IAAI;AACJ,KAAI;AACF,QAAO,MAAM,KAAK,OAAO,aAAa,EAAE,SAAS,MAAM,CAAC;UACjD,IAAI;AACX,UAAQ,MAAM,qDAAqD;AACnE,UAAQ,KAAK,EAAE;;CAGjB,MAAM,EAAE,UAAU;CAClB,MAAM,UAAU,QAAQ,QAAQ;AAChC,KAAI;AAEF,SADY,MAAM,MAAM,MAAM,EACpB,UAAU;AAEpB,QAAM,cAAc,oBAAoB;GAAE,SAAS;GAAY,aAAa;GAAS;GAAS,QAAQ;GAAW,CAAC,CAAC;AACnH,UAAQ,IAAI,uBAAuB;UAC5B,OAAO;AACd,QAAM,cAAc,oBAAoB;GAAE,SAAS;GAAY,aAAa;GAAS;GAAS,QAAQ;GAAU,CAAC,CAAC;AAClH,UAAQ,MAAM,sBAAsB;AACpC,UAAQ,MAAM,gBAAgB,MAAM,CAAC;AACrC,UAAQ,KAAK,EAAE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/cli",
3
- "version": "4.32.4",
3
+ "version": "4.33.1",
4
4
  "description": "Command-line interface for Kubb, enabling easy generation of TypeScript, React-Query, Zod, and other code from OpenAPI specifications.",
5
5
  "keywords": [
6
6
  "cli",
@@ -55,17 +55,17 @@
55
55
  "dependencies": {
56
56
  "@clack/prompts": "^1.1.0",
57
57
  "chokidar": "^5.0.0",
58
- "citty": "^0.1.6",
59
58
  "cosmiconfig": "^9.0.1",
60
59
  "jiti": "2.5.1",
61
60
  "tinyexec": "^1.0.2",
62
- "@kubb/core": "4.32.4"
61
+ "@kubb/core": "4.33.1"
63
62
  },
64
63
  "devDependencies": {
65
64
  "source-map-support": "^0.5.21",
66
- "@kubb/agent": "4.32.4",
67
- "@kubb/mcp": "4.32.4",
68
- "@kubb/oas": "4.32.4"
65
+ "@internals/utils": "0.0.0",
66
+ "@kubb/agent": "4.33.1",
67
+ "@kubb/mcp": "4.33.1",
68
+ "@kubb/oas": "4.33.1"
69
69
  },
70
70
  "engines": {
71
71
  "node": ">=20"