@kubb/cli 5.0.0-alpha.2 → 5.0.0-alpha.21
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.
- package/dist/{agent-L50VNhXv.js → agent-DTyw-mt7.js} +4 -4
- package/dist/{agent-L50VNhXv.js.map → agent-DTyw-mt7.js.map} +1 -1
- package/dist/{agent-B2TK-4x7.cjs → agent-Dd7uQlD3.cjs} +5 -5
- package/dist/{agent-B2TK-4x7.cjs.map → agent-Dd7uQlD3.cjs.map} +1 -1
- package/dist/{agent-C6o_6GSJ.cjs → agent-DpzeyN1s.cjs} +4 -4
- package/dist/{agent-C6o_6GSJ.cjs.map → agent-DpzeyN1s.cjs.map} +1 -1
- package/dist/{agent-CxaBPZgN.js → agent-TvIyrWHH.js} +5 -5
- package/dist/{agent-CxaBPZgN.js.map → agent-TvIyrWHH.js.map} +1 -1
- package/dist/{constants-BTUap0zs.cjs → constants-D0XHAHeZ.cjs} +78 -8
- package/dist/constants-D0XHAHeZ.cjs.map +1 -0
- package/dist/{constants-CM3dJzjK.js → constants-DJM9zCXm.js} +73 -9
- package/dist/constants-DJM9zCXm.js.map +1 -0
- package/dist/define-Bdn8j5VM.cjs +54 -0
- package/dist/define-Bdn8j5VM.cjs.map +1 -0
- package/dist/define-Ctii4bel.js +43 -0
- package/dist/define-Ctii4bel.js.map +1 -0
- package/dist/{errors-DBW0N9w4.cjs → errors-CLCjoSg0.cjs} +22 -6
- package/dist/errors-CLCjoSg0.cjs.map +1 -0
- package/dist/errors-CjPmyZHy.js +43 -0
- package/dist/errors-CjPmyZHy.js.map +1 -0
- package/dist/{generate-C52-Gwzu.cjs → generate-8gBYPkBI.cjs} +3 -3
- package/dist/{generate-C52-Gwzu.cjs.map → generate-8gBYPkBI.cjs.map} +1 -1
- package/dist/{generate-8xxZmvqZ.js → generate-BjYMvMXy.js} +178 -77
- package/dist/generate-BjYMvMXy.js.map +1 -0
- package/dist/{generate-D8p6X0le.cjs → generate-C1x42EUt.cjs} +177 -76
- package/dist/generate-C1x42EUt.cjs.map +1 -0
- package/dist/{generate-DYZYA7O1.js → generate-CCKyB7yS.js} +3 -3
- package/dist/{generate-DYZYA7O1.js.map → generate-CCKyB7yS.js.map} +1 -1
- package/dist/index.cjs +49 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +49 -19
- package/dist/index.js.map +1 -1
- package/dist/{init-hmolV6B4.cjs → init-BlriFVH6.cjs} +19 -4
- package/dist/init-BlriFVH6.cjs.map +1 -0
- package/dist/{init-BH6q17OX.js → init-C71oxvYR.js} +4 -4
- package/dist/{init-BH6q17OX.js.map → init-C71oxvYR.js.map} +1 -1
- package/dist/{init-BiutNzDD.cjs → init-DnUVdLjN.cjs} +4 -4
- package/dist/{init-BiutNzDD.cjs.map → init-DnUVdLjN.cjs.map} +1 -1
- package/dist/{init-C-InrmSY.js → init-Y1TNCdzh.js} +19 -4
- package/dist/init-Y1TNCdzh.js.map +1 -0
- package/dist/{mcp-Bc7xyp4a.js → mcp-9R8F1uQc.js} +4 -4
- package/dist/{mcp-Bc7xyp4a.js.map → mcp-9R8F1uQc.js.map} +1 -1
- package/dist/{mcp-D2SHEg_d.js → mcp-CxuctqmK.js} +3 -3
- package/dist/{mcp-D2SHEg_d.js.map → mcp-CxuctqmK.js.map} +1 -1
- package/dist/{mcp-B9iqBWaU.cjs → mcp-DDX2VL5b.cjs} +4 -4
- package/dist/{mcp-B9iqBWaU.cjs.map → mcp-DDX2VL5b.cjs.map} +1 -1
- package/dist/{mcp-ChHFPRzD.cjs → mcp-jMZ56bqT.cjs} +3 -3
- package/dist/{mcp-ChHFPRzD.cjs.map → mcp-jMZ56bqT.cjs.map} +1 -1
- package/dist/{package-lo3R7SUU.cjs → package-CH6AW-ko.cjs} +2 -2
- package/dist/package-CH6AW-ko.cjs.map +1 -0
- package/dist/package-DTEuw2ZR.js +6 -0
- package/dist/package-DTEuw2ZR.js.map +1 -0
- package/dist/{shell-7HPrTCJ5.cjs → shell-475fQKaX.cjs} +8 -3
- package/dist/shell-475fQKaX.cjs.map +1 -0
- package/dist/{shell-DqqWsHCD.js → shell-DLzN4fRo.js} +8 -3
- package/dist/shell-DLzN4fRo.js.map +1 -0
- package/dist/{telemetry-DxiR7clS.js → telemetry-CBISr5w4.js} +48 -6
- package/dist/telemetry-CBISr5w4.js.map +1 -0
- package/dist/{telemetry-Cn9X1I5B.cjs → telemetry-YO-uwAbf.cjs} +48 -6
- package/dist/telemetry-YO-uwAbf.cjs.map +1 -0
- package/dist/{validate-Bbrn3Q-A.cjs → validate-B-LfVNlS.cjs} +3 -3
- package/dist/{validate-Bbrn3Q-A.cjs.map → validate-B-LfVNlS.cjs.map} +1 -1
- package/dist/{validate-l8vLmwKA.js → validate-CIS8nJdd.js} +3 -3
- package/dist/{validate-l8vLmwKA.js.map → validate-CIS8nJdd.js.map} +1 -1
- package/dist/{validate-DCeW2b2k.js → validate-CT9EjxW0.js} +4 -4
- package/dist/{validate-DCeW2b2k.js.map → validate-CT9EjxW0.js.map} +1 -1
- package/dist/{validate-B_O2agAB.cjs → validate-D-Jv1vcb.cjs} +4 -4
- package/dist/{validate-B_O2agAB.cjs.map → validate-D-Jv1vcb.cjs.map} +1 -1
- package/package.json +5 -5
- package/src/constants.ts +57 -10
- package/src/index.ts +5 -4
- package/src/loggers/clackLogger.ts +30 -22
- package/src/runners/generate.ts +22 -23
- package/src/types.ts +11 -0
- package/src/utils/flags.ts +10 -0
- package/src/utils/getCosmiConfig.ts +6 -0
- package/dist/constants-BTUap0zs.cjs.map +0 -1
- package/dist/constants-CM3dJzjK.js.map +0 -1
- package/dist/define--M_JMcDC.js +0 -25
- package/dist/define--M_JMcDC.js.map +0 -1
- package/dist/define-D6Kfm7-Z.cjs +0 -36
- package/dist/define-D6Kfm7-Z.cjs.map +0 -1
- package/dist/errors-6mF_WKxg.js +0 -27
- package/dist/errors-6mF_WKxg.js.map +0 -1
- package/dist/errors-DBW0N9w4.cjs.map +0 -1
- package/dist/generate-8xxZmvqZ.js.map +0 -1
- package/dist/generate-D8p6X0le.cjs.map +0 -1
- package/dist/init-C-InrmSY.js.map +0 -1
- package/dist/init-hmolV6B4.cjs.map +0 -1
- package/dist/package-B4LgzOaR.js +0 -6
- package/dist/package-B4LgzOaR.js.map +0 -1
- package/dist/package-lo3R7SUU.cjs.map +0 -1
- package/dist/shell-7HPrTCJ5.cjs.map +0 -1
- package/dist/shell-DqqWsHCD.js.map +0 -1
- package/dist/telemetry-Cn9X1I5B.cjs.map +0 -1
- package/dist/telemetry-DxiR7clS.js.map +0 -1
- package/src/utils/getIntro.ts +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shell-475fQKaX.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 /**\n * Working directory for the child process.\n * @default process.cwd()\n */\n cwd?: string\n /**\n * Environment variables passed to the child process.\n * @default process.env\n */\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 * @default false\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 *\n * @example\n * ```ts\n * await spawnAsync('pnpm', ['install'])\n * await spawnAsync('node', ['server.js'], { detached: true }) // fire-and-forget\n * ```\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;;;;;;;;;;;;;;AAkCjH,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"}
|
|
@@ -15,8 +15,13 @@ function tokenize(command) {
|
|
|
15
15
|
* Spawns `cmd` with `args` and returns a promise that settles when the child process finishes.
|
|
16
16
|
*
|
|
17
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
|
-
*
|
|
18
|
+
* Detached mode spawns the child in its own process group, unref's it, and resolves immediately.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* await spawnAsync('pnpm', ['install'])
|
|
23
|
+
* await spawnAsync('node', ['server.js'], { detached: true }) // fire-and-forget
|
|
24
|
+
* ```
|
|
20
25
|
*/
|
|
21
26
|
function spawnAsync(cmd, args, options = {}) {
|
|
22
27
|
const { cwd = process.cwd(), env, detached = false } = options;
|
|
@@ -43,4 +48,4 @@ function spawnAsync(cmd, args, options = {}) {
|
|
|
43
48
|
//#endregion
|
|
44
49
|
export { tokenize as n, spawnAsync as t };
|
|
45
50
|
|
|
46
|
-
//# sourceMappingURL=shell-
|
|
51
|
+
//# sourceMappingURL=shell-DLzN4fRo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shell-DLzN4fRo.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 /**\n * Working directory for the child process.\n * @default process.cwd()\n */\n cwd?: string\n /**\n * Environment variables passed to the child process.\n * @default process.env\n */\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 * @default false\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 *\n * @example\n * ```ts\n * await spawnAsync('pnpm', ['install'])\n * await spawnAsync('node', ['server.js'], { detached: true }) // fire-and-forget\n * ```\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;;;;;;;;;;;;;;AAkCjH,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,5 +1,5 @@
|
|
|
1
1
|
import "./chunk--u3MIqq1.js";
|
|
2
|
-
import { n as OTLP_ENDPOINT } from "./constants-
|
|
2
|
+
import { n as OTLP_ENDPOINT } from "./constants-DJM9zCXm.js";
|
|
3
3
|
import { randomBytes } from "node:crypto";
|
|
4
4
|
import { promises } from "node:dns";
|
|
5
5
|
import os from "node:os";
|
|
@@ -7,6 +7,13 @@ import process$1 from "node:process";
|
|
|
7
7
|
//#region ../../internals/utils/src/env.ts
|
|
8
8
|
/**
|
|
9
9
|
* Returns `true` when running inside a GitHub Actions workflow.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* if (isGitHubActions()) {
|
|
14
|
+
* core.setOutput('result', 'ok')
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
10
17
|
*/
|
|
11
18
|
function isGitHubActions() {
|
|
12
19
|
return !!process.env.GITHUB_ACTIONS;
|
|
@@ -15,19 +22,41 @@ function isGitHubActions() {
|
|
|
15
22
|
* Returns `true` when the process is running in a CI environment.
|
|
16
23
|
* Covers GitHub Actions, GitLab CI, CircleCI, Travis CI, Jenkins, Bitbucket,
|
|
17
24
|
* TeamCity, Buildkite, and Azure Pipelines.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* if (isCIEnvironment()) {
|
|
29
|
+
* logger.level = 'error'
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
18
32
|
*/
|
|
19
33
|
function isCIEnvironment() {
|
|
20
34
|
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
35
|
}
|
|
22
36
|
/**
|
|
23
|
-
* Returns `true` when the process has an interactive TTY
|
|
37
|
+
* Returns `true` when the process has an interactive TTY with a valid terminal
|
|
38
|
+
* width and is not running in CI.
|
|
39
|
+
*
|
|
40
|
+
* Some IDE-embedded terminals report `isTTY = true` but set `columns` to `0`,
|
|
41
|
+
* which breaks clack's box-drawing helpers (they call `String.prototype.repeat`
|
|
42
|
+
* with a negative count and throw a `RangeError`). We therefore require a
|
|
43
|
+
* positive column count before declaring the TTY usable.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* if (canUseTTY()) {
|
|
48
|
+
* renderProgressBar()
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
24
51
|
*/
|
|
25
52
|
function canUseTTY() {
|
|
26
|
-
return !!process.stdout.isTTY && !isCIEnvironment();
|
|
53
|
+
return !!process.stdout.isTTY && (process.stdout.columns ?? 0) > 0 && !isCIEnvironment();
|
|
27
54
|
}
|
|
28
55
|
//#endregion
|
|
29
56
|
//#region ../../internals/utils/src/network.ts
|
|
30
|
-
/**
|
|
57
|
+
/**
|
|
58
|
+
* Well-known stable domains used as DNS probes to check internet connectivity.
|
|
59
|
+
*/
|
|
31
60
|
const TEST_DOMAINS = [
|
|
32
61
|
"dns.google.com",
|
|
33
62
|
"cloudflare.com",
|
|
@@ -35,7 +64,14 @@ const TEST_DOMAINS = [
|
|
|
35
64
|
];
|
|
36
65
|
/**
|
|
37
66
|
* Returns `true` when the system has internet connectivity.
|
|
38
|
-
*
|
|
67
|
+
* Probes DNS resolution against well-known stable domains.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```ts
|
|
71
|
+
* if (await isOnline()) {
|
|
72
|
+
* await fetchLatestVersion()
|
|
73
|
+
* }
|
|
74
|
+
* ```
|
|
39
75
|
*/
|
|
40
76
|
async function isOnline() {
|
|
41
77
|
for (const domain of TEST_DOMAINS) try {
|
|
@@ -46,6 +82,12 @@ async function isOnline() {
|
|
|
46
82
|
}
|
|
47
83
|
/**
|
|
48
84
|
* Executes `fn` only when the system is online. Returns `null` when offline or on error.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```ts
|
|
88
|
+
* const version = await executeIfOnline(() => fetchLatestVersion('kubb'))
|
|
89
|
+
* // null when offline
|
|
90
|
+
* ```
|
|
49
91
|
*/
|
|
50
92
|
async function executeIfOnline(fn) {
|
|
51
93
|
if (!await isOnline()) return null;
|
|
@@ -200,4 +242,4 @@ function buildTelemetryEvent(options) {
|
|
|
200
242
|
//#endregion
|
|
201
243
|
export { canUseTTY as a, executeIfOnline as i, isTelemetryDisabled as n, isGitHubActions as o, sendTelemetry as r, buildTelemetryEvent as t };
|
|
202
244
|
|
|
203
|
-
//# sourceMappingURL=telemetry-
|
|
245
|
+
//# sourceMappingURL=telemetry-CBISr5w4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telemetry-CBISr5w4.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 *\n * @example\n * ```ts\n * if (isGitHubActions()) {\n * core.setOutput('result', 'ok')\n * }\n * ```\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 *\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","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":";;;;;;;;;;;;;;;;;AAUA,SAAgB,kBAA2B;AACzC,QAAO,CAAC,CAAC,QAAQ,IAAI;;;;;;;;;;;;;;AAevB,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;;;;;;;;;;;;;;;;;;AAoBhB,SAAgB,YAAqB;AACnC,QAAO,CAAC,CAAC,QAAQ,OAAO,UAAU,QAAQ,OAAO,WAAW,KAAK,KAAK,CAAC,iBAAiB;;;;;;;ACrD1F,MAAM,eAAe;CAAC;CAAkB;CAAkB;CAAkB;;;;;;;;;;;;AAa5E,eAAsB,WAA6B;AACjD,MAAK,MAAM,UAAU,aACnB,KAAI;AACF,QAAMA,SAAY,QAAQ,OAAO;AACjC,SAAO;SACD;AAKV,QAAO;;;;;;;;;;;AAYT,eAAsB,gBAAmB,IAAyC;AAChF,KAAI,CAAE,MAAM,UAAU,CAAG,QAAO;AAEhC,KAAI;AACF,SAAO,MAAM,IAAI;SACX;AACN,SAAO;;;;;;;;;ACyEX,SAAgB,OAAgB;AAC9B,QAAO,iBAAiB;;;;;;AAO1B,SAAgB,sBAA+B;AAC7C,QACEC,UAAQ,IAAI,oBAAoB,OAChCA,UAAQ,IAAI,oBAAoB,UAChCA,UAAQ,IAAI,8BAA8B,OAC1CA,UAAQ,IAAI,8BAA8B;;;;;;AAQ9C,SAAgB,iBAAiB,OAAsD;CACrF,MAAM,UAAU,YAAY,GAAG,CAAC,SAAS,MAAM;CAC/C,MAAM,SAAS,YAAY,EAAE,CAAC,SAAS,MAAM;CAC7C,MAAM,YAAY,OAAO,KAAK,KAAK,CAAC,GAAG;CACvC,MAAM,cAAc,YAAY,OAAO,MAAM,SAAS,GAAG;CAEzD,MAAM,aAA6B;EACjC;GAAE,KAAK;GAAgB,OAAO,EAAE,aAAa,MAAM,SAAS;GAAE;EAC9D;GAAE,KAAK;GAAgB,OAAO,EAAE,aAAa,MAAM,aAAa;GAAE;EAClE;GAAE,KAAK;GAAqB,OAAO,EAAE,aAAa,MAAM,aAAa;GAAE;EACvE;GAAE,KAAK;GAAiB,OAAO,EAAE,aAAa,MAAM,UAAU;GAAE;EAChE;GAAE,KAAK;GAAW,OAAO,EAAE,WAAW,MAAM,IAAI;GAAE;EAClD;GAAE,KAAK;GAAsB,OAAO,EAAE,UAAU,MAAM,cAAc;GAAE;EACtE;GAAE,KAAK;GAAe,OAAO,EAAE,aAAa,MAAM,QAAQ;GAAE;EAC5D;GACE,KAAK;GACL,OAAO,EACL,YAAY,EACV,QAAQ,MAAM,QAAQ,KACnB,OAAwB,EACvB,aAAa,EACX,QAAQ,CACN;IAAE,KAAK;IAAQ,OAAO,EAAE,aAAa,EAAE,MAAM;IAAE,EAC/C;IAAE,KAAK;IAAW,OAAO,EAAE,aAAa,KAAK,UAAU;KAAE,GAAG,EAAE;KAAS,eAAe,KAAA;KAAW,CAAC,EAAE;IAAE,CACvG,EACF,EACF,EACF,EACF,EACF;GACF;EACF;AAED,QAAO,EACL,eAAe,CACb;EACE,UAAU,EACR,YAAY;GACV;IAAE,KAAK;IAAgB,OAAO,EAAE,aAAa,YAAY;IAAE;GAC3D;IAAE,KAAK;IAAmB,OAAO,EAAE,aAAa,MAAM,aAAa;IAAE;GACrE;IAAE,KAAK;IAA0B,OAAO,EAAE,aAAa,UAAU;IAAE;GACpE,EACF;EACD,YAAY,CACV;GACE,OAAO;IAAE,MAAM;IAAY,SAAS,MAAM;IAAa;GACvD,OAAO,CACL;IACE;IACA;IACA,MAAM,MAAM;IACZ,MAAM;IACN,mBAAmB,OAAO,YAAY;IACtC,iBAAiB,OAAO,UAAU;IAClC;IACA,QAAQ,EAAE,MAAO,MAAM,WAAW,YAAY,IAAI,GAA6B;IAChF,CACF;GACF,CACF;EACF,CACF,EACF;;;;;;;AAQH,eAAsB,cAAc,OAAsC;AACxE,KAAI,qBAAqB,CACvB;AAGF,OAAM,gBAAgB,YAAY;AAChC,MAAI;AACF,SAAM,MAAM,GAAG,cAAc,aAAa;IACxC,QAAQ;IACR,SAAS;KACP,gBAAgB;KAChB,0BAA0B;KAC1B,yBAAyB;KAC1B;IACD,MAAM,KAAK,UAAU,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"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-ByKO4r7w.cjs");
|
|
2
|
-
const require_constants = require("./constants-
|
|
2
|
+
const require_constants = require("./constants-D0XHAHeZ.cjs");
|
|
3
3
|
let node_crypto = require("node:crypto");
|
|
4
4
|
let node_dns = require("node:dns");
|
|
5
5
|
let node_os = require("node:os");
|
|
@@ -9,6 +9,13 @@ node_process = require_chunk.__toESM(node_process);
|
|
|
9
9
|
//#region ../../internals/utils/src/env.ts
|
|
10
10
|
/**
|
|
11
11
|
* Returns `true` when running inside a GitHub Actions workflow.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* if (isGitHubActions()) {
|
|
16
|
+
* core.setOutput('result', 'ok')
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
12
19
|
*/
|
|
13
20
|
function isGitHubActions() {
|
|
14
21
|
return !!process.env.GITHUB_ACTIONS;
|
|
@@ -17,19 +24,41 @@ function isGitHubActions() {
|
|
|
17
24
|
* Returns `true` when the process is running in a CI environment.
|
|
18
25
|
* Covers GitHub Actions, GitLab CI, CircleCI, Travis CI, Jenkins, Bitbucket,
|
|
19
26
|
* TeamCity, Buildkite, and Azure Pipelines.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* if (isCIEnvironment()) {
|
|
31
|
+
* logger.level = 'error'
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
20
34
|
*/
|
|
21
35
|
function isCIEnvironment() {
|
|
22
36
|
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
37
|
}
|
|
24
38
|
/**
|
|
25
|
-
* Returns `true` when the process has an interactive TTY
|
|
39
|
+
* Returns `true` when the process has an interactive TTY with a valid terminal
|
|
40
|
+
* width and is not running in CI.
|
|
41
|
+
*
|
|
42
|
+
* Some IDE-embedded terminals report `isTTY = true` but set `columns` to `0`,
|
|
43
|
+
* which breaks clack's box-drawing helpers (they call `String.prototype.repeat`
|
|
44
|
+
* with a negative count and throw a `RangeError`). We therefore require a
|
|
45
|
+
* positive column count before declaring the TTY usable.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* if (canUseTTY()) {
|
|
50
|
+
* renderProgressBar()
|
|
51
|
+
* }
|
|
52
|
+
* ```
|
|
26
53
|
*/
|
|
27
54
|
function canUseTTY() {
|
|
28
|
-
return !!process.stdout.isTTY && !isCIEnvironment();
|
|
55
|
+
return !!process.stdout.isTTY && (process.stdout.columns ?? 0) > 0 && !isCIEnvironment();
|
|
29
56
|
}
|
|
30
57
|
//#endregion
|
|
31
58
|
//#region ../../internals/utils/src/network.ts
|
|
32
|
-
/**
|
|
59
|
+
/**
|
|
60
|
+
* Well-known stable domains used as DNS probes to check internet connectivity.
|
|
61
|
+
*/
|
|
33
62
|
const TEST_DOMAINS = [
|
|
34
63
|
"dns.google.com",
|
|
35
64
|
"cloudflare.com",
|
|
@@ -37,7 +66,14 @@ const TEST_DOMAINS = [
|
|
|
37
66
|
];
|
|
38
67
|
/**
|
|
39
68
|
* Returns `true` when the system has internet connectivity.
|
|
40
|
-
*
|
|
69
|
+
* Probes DNS resolution against well-known stable domains.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```ts
|
|
73
|
+
* if (await isOnline()) {
|
|
74
|
+
* await fetchLatestVersion()
|
|
75
|
+
* }
|
|
76
|
+
* ```
|
|
41
77
|
*/
|
|
42
78
|
async function isOnline() {
|
|
43
79
|
for (const domain of TEST_DOMAINS) try {
|
|
@@ -48,6 +84,12 @@ async function isOnline() {
|
|
|
48
84
|
}
|
|
49
85
|
/**
|
|
50
86
|
* Executes `fn` only when the system is online. Returns `null` when offline or on error.
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```ts
|
|
90
|
+
* const version = await executeIfOnline(() => fetchLatestVersion('kubb'))
|
|
91
|
+
* // null when offline
|
|
92
|
+
* ```
|
|
51
93
|
*/
|
|
52
94
|
async function executeIfOnline(fn) {
|
|
53
95
|
if (!await isOnline()) return null;
|
|
@@ -237,4 +279,4 @@ Object.defineProperty(exports, "sendTelemetry", {
|
|
|
237
279
|
}
|
|
238
280
|
});
|
|
239
281
|
|
|
240
|
-
//# sourceMappingURL=telemetry-
|
|
282
|
+
//# sourceMappingURL=telemetry-YO-uwAbf.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telemetry-YO-uwAbf.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 *\n * @example\n * ```ts\n * if (isGitHubActions()) {\n * core.setOutput('result', 'ok')\n * }\n * ```\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 *\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","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":"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"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-ByKO4r7w.cjs");
|
|
2
|
-
const require_errors = require("./errors-
|
|
3
|
-
const require_telemetry = require("./telemetry-
|
|
2
|
+
const require_errors = require("./errors-CLCjoSg0.cjs");
|
|
3
|
+
const require_telemetry = require("./telemetry-YO-uwAbf.cjs");
|
|
4
4
|
const require_jiti = require("./jiti-Cd3S0xwr.cjs");
|
|
5
5
|
let node_process = require("node:process");
|
|
6
6
|
node_process = require_chunk.__toESM(node_process);
|
|
@@ -39,4 +39,4 @@ async function runValidate({ input, version }) {
|
|
|
39
39
|
//#endregion
|
|
40
40
|
exports.runValidate = runValidate;
|
|
41
41
|
|
|
42
|
-
//# sourceMappingURL=validate-
|
|
42
|
+
//# sourceMappingURL=validate-B-LfVNlS.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-
|
|
1
|
+
{"version":3,"file":"validate-B-LfVNlS.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"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./chunk--u3MIqq1.js";
|
|
2
|
-
import { t as getErrorMessage } from "./errors-
|
|
3
|
-
import { r as sendTelemetry, t as buildTelemetryEvent } from "./telemetry-
|
|
2
|
+
import { t as getErrorMessage } from "./errors-CjPmyZHy.js";
|
|
3
|
+
import { r as sendTelemetry, t as buildTelemetryEvent } from "./telemetry-CBISr5w4.js";
|
|
4
4
|
import { t as jiti } from "./jiti-e08mD2Ph.js";
|
|
5
5
|
import process from "node:process";
|
|
6
6
|
//#region src/runners/validate.ts
|
|
@@ -38,4 +38,4 @@ async function runValidate({ input, version }) {
|
|
|
38
38
|
//#endregion
|
|
39
39
|
export { runValidate };
|
|
40
40
|
|
|
41
|
-
//# sourceMappingURL=validate-
|
|
41
|
+
//# sourceMappingURL=validate-CIS8nJdd.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-
|
|
1
|
+
{"version":3,"file":"validate-CIS8nJdd.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"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./chunk--u3MIqq1.js";
|
|
2
|
-
import { n as defineCommand } from "./define
|
|
3
|
-
import { t as version } from "./package-
|
|
2
|
+
import { n as defineCommand } from "./define-Ctii4bel.js";
|
|
3
|
+
import { t as version } from "./package-DTEuw2ZR.js";
|
|
4
4
|
//#region src/commands/validate.ts
|
|
5
5
|
const command = defineCommand({
|
|
6
6
|
name: "validate",
|
|
@@ -12,7 +12,7 @@ const command = defineCommand({
|
|
|
12
12
|
required: true
|
|
13
13
|
} },
|
|
14
14
|
async run({ values }) {
|
|
15
|
-
const { runValidate } = await import("./validate-
|
|
15
|
+
const { runValidate } = await import("./validate-CIS8nJdd.js");
|
|
16
16
|
await runValidate({
|
|
17
17
|
input: values.input,
|
|
18
18
|
version
|
|
@@ -22,4 +22,4 @@ const command = defineCommand({
|
|
|
22
22
|
//#endregion
|
|
23
23
|
export { command };
|
|
24
24
|
|
|
25
|
-
//# sourceMappingURL=validate-
|
|
25
|
+
//# sourceMappingURL=validate-CT9EjxW0.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-
|
|
1
|
+
{"version":3,"file":"validate-CT9EjxW0.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"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require("./chunk-ByKO4r7w.cjs");
|
|
2
|
-
const require_define = require("./define-
|
|
3
|
-
const require_package = require("./package-
|
|
2
|
+
const require_define = require("./define-Bdn8j5VM.cjs");
|
|
3
|
+
const require_package = require("./package-CH6AW-ko.cjs");
|
|
4
4
|
//#region src/commands/validate.ts
|
|
5
5
|
const command = require_define.defineCommand({
|
|
6
6
|
name: "validate",
|
|
@@ -12,7 +12,7 @@ const command = require_define.defineCommand({
|
|
|
12
12
|
required: true
|
|
13
13
|
} },
|
|
14
14
|
async run({ values }) {
|
|
15
|
-
const { runValidate } = await Promise.resolve().then(() => require("./validate-
|
|
15
|
+
const { runValidate } = await Promise.resolve().then(() => require("./validate-B-LfVNlS.cjs"));
|
|
16
16
|
await runValidate({
|
|
17
17
|
input: values.input,
|
|
18
18
|
version: require_package.version
|
|
@@ -22,4 +22,4 @@ const command = require_define.defineCommand({
|
|
|
22
22
|
//#endregion
|
|
23
23
|
exports.command = command;
|
|
24
24
|
|
|
25
|
-
//# sourceMappingURL=validate-
|
|
25
|
+
//# sourceMappingURL=validate-D-Jv1vcb.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-
|
|
1
|
+
{"version":3,"file":"validate-D-Jv1vcb.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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/cli",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.21",
|
|
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",
|
|
@@ -58,14 +58,14 @@
|
|
|
58
58
|
"cosmiconfig": "^9.0.1",
|
|
59
59
|
"jiti": "2.5.1",
|
|
60
60
|
"tinyexec": "^1.0.4",
|
|
61
|
-
"@kubb/core": "5.0.0-alpha.
|
|
61
|
+
"@kubb/core": "5.0.0-alpha.21"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"source-map-support": "^0.5.21",
|
|
65
65
|
"@internals/utils": "0.0.0",
|
|
66
|
-
"@kubb/agent": "5.0.0-alpha.
|
|
67
|
-
"@kubb/mcp": "5.0.0-alpha.
|
|
68
|
-
"@kubb/oas": "5.0.0-alpha.
|
|
66
|
+
"@kubb/agent": "5.0.0-alpha.21",
|
|
67
|
+
"@kubb/mcp": "5.0.0-alpha.21",
|
|
68
|
+
"@kubb/oas": "5.0.0-alpha.21"
|
|
69
69
|
},
|
|
70
70
|
"engines": {
|
|
71
71
|
"node": ">=22"
|
package/src/constants.ts
CHANGED
|
@@ -1,33 +1,78 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* NPM registry endpoint used to check for @kubb/cli updates.
|
|
3
|
+
*/
|
|
2
4
|
export const KUBB_NPM_PACKAGE_URL = 'https://registry.npmjs.org/@kubb/cli/latest' as const
|
|
3
5
|
|
|
4
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* OpenTelemetry ingestion endpoint for anonymous usage telemetry.
|
|
8
|
+
*/
|
|
5
9
|
export const OTLP_ENDPOINT = 'https://otlp.kubb.dev' as const
|
|
6
10
|
|
|
7
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* Horizontal rule rendered above/below the plain-logger generation summary.
|
|
13
|
+
*/
|
|
8
14
|
export const SUMMARY_SEPARATOR = '─'.repeat(27)
|
|
9
15
|
|
|
10
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* Maximum number of █ characters in a plugin timing bar.
|
|
18
|
+
*/
|
|
11
19
|
export const SUMMARY_MAX_BAR_LENGTH = 10 as const
|
|
12
20
|
|
|
13
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* Divides elapsed milliseconds into bar-length units (1 block per 100 ms).
|
|
23
|
+
*/
|
|
14
24
|
export const SUMMARY_TIME_SCALE_DIVISOR = 100 as const
|
|
15
25
|
|
|
16
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* Glob pattern for paths the file watcher ignores.
|
|
28
|
+
*/
|
|
17
29
|
export const WATCHER_IGNORED_PATHS = '**/{.git,node_modules}/**' as const
|
|
18
30
|
|
|
19
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* Flags that short-circuit execution (help/version) — no telemetry notice is shown.
|
|
33
|
+
*/
|
|
34
|
+
export const QUITE_FLAGS = new Set(['--help', '-h', '--version', '-v'] as const)
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Flags accepted by the `generate` command.
|
|
38
|
+
*/
|
|
39
|
+
export const GENERATE_FLAGS = new Set(['--config', '-c', '--log-level', '-l', '--watch', '-w', '--debug', '-d', '--verbose', '-v', '--silent', '-s'] as const)
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Flags accepted by the `validate` command.
|
|
43
|
+
*/
|
|
44
|
+
export const VALIDATE_FLAGS = new Set(['--input', '-i'] as const)
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Flags accepted by the `init` command.
|
|
48
|
+
*/
|
|
49
|
+
export const INIT_FLAGS = new Set(['--yes', '-y'] as const)
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Flags accepted by the `agent start` command.
|
|
53
|
+
*/
|
|
54
|
+
export const AGENT_START_FLAGS = new Set(['--config', '-c', '--port', '-p', '--host', '--allow-write', '--allow-all'] as const)
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* All known CLI flags across every command.
|
|
58
|
+
*/
|
|
59
|
+
export const ARGS = new Set([...QUITE_FLAGS, ...GENERATE_FLAGS, ...VALIDATE_FLAGS, ...INIT_FLAGS, ...AGENT_START_FLAGS] as const)
|
|
60
|
+
|
|
20
61
|
export const agentDefaults = {
|
|
21
62
|
port: '3000',
|
|
22
63
|
host: 'localhost',
|
|
23
64
|
configFile: 'kubb.config.ts',
|
|
24
65
|
retryTimeout: '30000',
|
|
25
66
|
studioUrl: 'https://studio.kubb.dev',
|
|
26
|
-
/**
|
|
67
|
+
/**
|
|
68
|
+
* Relative path from the @kubb/agent package root to the server entry.
|
|
69
|
+
*/
|
|
27
70
|
serverEntryPath: '.output/server/index.mjs',
|
|
28
71
|
} as const
|
|
29
72
|
|
|
30
|
-
/**
|
|
73
|
+
/**
|
|
74
|
+
* Default values used during interactive `init` scaffolding.
|
|
75
|
+
*/
|
|
31
76
|
export const initDefaults = {
|
|
32
77
|
inputPath: './openapi.yaml',
|
|
33
78
|
outputPath: './src/gen',
|
|
@@ -73,4 +118,6 @@ export const pluginDefaultConfigs = {
|
|
|
73
118
|
})`,
|
|
74
119
|
} as const satisfies Record<string, string>
|
|
75
120
|
|
|
76
|
-
/**
|
|
121
|
+
/**
|
|
122
|
+
* Color palette used by randomCliColor() for deterministic plugin name coloring.
|
|
123
|
+
*/
|
package/src/index.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { styleText } from 'node:util'
|
|
2
2
|
import { createCLI } from '@internals/utils'
|
|
3
3
|
import { version } from '../package.json'
|
|
4
|
+
import { QUITE_FLAGS } from './constants.ts'
|
|
5
|
+
import { isFlag } from './utils/flags.ts'
|
|
4
6
|
import { isTelemetryDisabled } from './utils/telemetry.ts'
|
|
5
7
|
|
|
6
8
|
const cli = createCLI()
|
|
7
9
|
|
|
8
|
-
function shouldShowTelemetryNotice(argv: string
|
|
10
|
+
function shouldShowTelemetryNotice(argv: Array<string>): boolean {
|
|
9
11
|
if (isTelemetryDisabled()) {
|
|
10
12
|
return false
|
|
11
13
|
}
|
|
12
14
|
// Skip when the user is just asking for help or version info
|
|
13
|
-
|
|
14
|
-
if (argv.some((arg) => quietFlags.has(arg))) {
|
|
15
|
+
if (argv.some((arg) => isFlag(QUITE_FLAGS, arg))) {
|
|
15
16
|
return false
|
|
16
17
|
}
|
|
17
18
|
// Skip in non-interactive / scripting contexts
|
|
@@ -21,7 +22,7 @@ function shouldShowTelemetryNotice(argv: string[]): boolean {
|
|
|
21
22
|
return true
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
export async function run(argv: string
|
|
25
|
+
export async function run(argv: Array<string> = process.argv): Promise<void> {
|
|
25
26
|
if (shouldShowTelemetryNotice(argv)) {
|
|
26
27
|
console.log(
|
|
27
28
|
`${styleText('yellow', 'Notice:')} Kubb collects anonymous telemetry data to help improve the tool. No personal data or file contents are collected. \nTo disable, set ${styleText('cyan', 'KUBB_DISABLE_TELEMETRY=1')}.\n`,
|