@kubb/cli 5.0.0-beta.58 → 5.0.0-beta.59
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/{Telemetry-C66uYyC2.js → Telemetry-CVdyJarO.js} +5 -5
- package/dist/Telemetry-CVdyJarO.js.map +1 -0
- package/dist/{Telemetry-BuDSora3.cjs → Telemetry-DrppRqqW.cjs} +5 -5
- package/dist/Telemetry-DrppRqqW.cjs.map +1 -0
- package/dist/{generate-CUzq1qsk.js → generate-BbsQHH-y.js} +2 -2
- package/dist/{generate-CUzq1qsk.js.map → generate-BbsQHH-y.js.map} +1 -1
- package/dist/{generate-BvFZapz6.cjs → generate-CaKRt0pU.cjs} +2 -2
- package/dist/{generate-BvFZapz6.cjs.map → generate-CaKRt0pU.cjs.map} +1 -1
- package/dist/index.cjs +6 -6
- package/dist/index.js +6 -6
- package/dist/{init-5OqRlzjq.js → init-DhbYO6XT.js} +2 -2
- package/dist/{init-5OqRlzjq.js.map → init-DhbYO6XT.js.map} +1 -1
- package/dist/{init-C_zHpnzZ.cjs → init-u_F7NZaV.cjs} +2 -2
- package/dist/{init-C_zHpnzZ.cjs.map → init-u_F7NZaV.cjs.map} +1 -1
- package/dist/{mcp-Cl1MNHgn.js → mcp-DAcdYGPz.js} +3 -3
- package/dist/{mcp-Cl1MNHgn.js.map → mcp-DAcdYGPz.js.map} +1 -1
- package/dist/{mcp-DALMmqXK.cjs → mcp-DBcAUX1p.cjs} +3 -3
- package/dist/{mcp-DALMmqXK.cjs.map → mcp-DBcAUX1p.cjs.map} +1 -1
- package/dist/{package-DkAWgV_y.cjs → package-BAbAGPib.cjs} +2 -2
- package/dist/package-BAbAGPib.cjs.map +1 -0
- package/dist/package-BNgAvZIJ.js +6 -0
- package/dist/package-BNgAvZIJ.js.map +1 -0
- package/dist/{run-BwQr5Sl7.cjs → run-0V1yc9LV.cjs} +12 -8
- package/dist/run-0V1yc9LV.cjs.map +1 -0
- package/dist/{run-DCXY-eRK.cjs → run-9ZhHuNZQ.cjs} +2 -2
- package/dist/{run-DCXY-eRK.cjs.map → run-9ZhHuNZQ.cjs.map} +1 -1
- package/dist/{run-Bj64iPU_.cjs → run-BQO_tPlc.cjs} +2 -2
- package/dist/{run-Bj64iPU_.cjs.map → run-BQO_tPlc.cjs.map} +1 -1
- package/dist/{run-Dq3ztIKi.js → run-BQbeARLx.js} +12 -8
- package/dist/run-BQbeARLx.js.map +1 -0
- package/dist/{run-CUkZ6gnP.js → run-CYnDu3ch.js} +2 -2
- package/dist/{run-CUkZ6gnP.js.map → run-CYnDu3ch.js.map} +1 -1
- package/dist/{run-OWQyNzZx.js → run-h8NTawHO.js} +2 -2
- package/dist/{run-OWQyNzZx.js.map → run-h8NTawHO.js.map} +1 -1
- package/dist/{validate-S1A5pXu4.cjs → validate-3qzRzz3x.cjs} +3 -3
- package/dist/{validate-S1A5pXu4.cjs.map → validate-3qzRzz3x.cjs.map} +1 -1
- package/dist/{validate-krgUtbKa.js → validate-Bcq9SN0T.js} +3 -3
- package/dist/{validate-krgUtbKa.js.map → validate-Bcq9SN0T.js.map} +1 -1
- package/package.json +5 -5
- package/src/Telemetry.ts +16 -7
- package/src/constants.ts +1 -1
- package/src/loggers/clackLogger.ts +2 -2
- package/src/loggers/plainLogger.ts +1 -1
- package/src/loggers/utils.ts +4 -2
- package/src/runners/generate/run.ts +1 -1
- package/src/runners/generate/utils.ts +2 -0
- package/dist/Telemetry-BuDSora3.cjs.map +0 -1
- package/dist/Telemetry-C66uYyC2.js.map +0 -1
- package/dist/package-Dexb-Hm2.js +0 -6
- package/dist/package-Dexb-Hm2.js.map +0 -1
- package/dist/package-DkAWgV_y.cjs.map +0 -1
- package/dist/run-BwQr5Sl7.cjs.map +0 -1
- package/dist/run-Dq3ztIKi.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./chunk-C0LytTxp.js";
|
|
2
2
|
import { t as getErrorMessage } from "./errors-BsemQCMn.js";
|
|
3
|
-
import { t as Telemetry } from "./Telemetry-
|
|
3
|
+
import { t as Telemetry } from "./Telemetry-CVdyJarO.js";
|
|
4
4
|
import { styleText } from "node:util";
|
|
5
5
|
import process from "node:process";
|
|
6
6
|
//#region src/runners/validate/run.ts
|
|
@@ -48,4 +48,4 @@ async function run({ input, version }, dependencies = { loadValidateModule }) {
|
|
|
48
48
|
//#endregion
|
|
49
49
|
export { run };
|
|
50
50
|
|
|
51
|
-
//# sourceMappingURL=run-
|
|
51
|
+
//# sourceMappingURL=run-CYnDu3ch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-
|
|
1
|
+
{"version":3,"file":"run-CYnDu3ch.js","names":[],"sources":["../src/runners/validate/run.ts"],"sourcesContent":["import process from 'node:process'\nimport { styleText } from 'node:util'\nimport { getErrorMessage } from '@internals/utils'\nimport { Telemetry } from '../../Telemetry.ts'\n\ntype ValidateOptions = {\n /**\n * Path or URL to the OpenAPI/Swagger file to validate.\n */\n input: string\n /**\n * Current `@kubb/cli` version string, used for the telemetry payload.\n */\n version: string\n}\n\ntype ValidateModule = typeof import('@kubb/adapter-oas')\ntype ValidateDependencies = {\n /**\n * Loads `@kubb/adapter-oas`. Injected so tests can substitute a mock.\n */\n loadValidateModule: () => Promise<ValidateModule>\n}\n\n/**\n * Dynamically loads `@kubb/adapter-oas` for OpenAPI validation.\n */\nexport function loadValidateModule(): Promise<ValidateModule> {\n return import('@kubb/adapter-oas') as Promise<ValidateModule>\n}\n\n/**\n * Validates an OpenAPI/Swagger file at `input` using `@kubb/adapter-oas`.\n * Exits the process with code 1 on validation failure or missing dependency.\n */\nexport async function run({ input, version }: ValidateOptions, dependencies: ValidateDependencies = { loadValidateModule }): Promise<void> {\n const hrStart = process.hrtime()\n const report = (status: 'success' | 'failed') => Telemetry.send(Telemetry.build({ command: 'validate', kubbVersion: version, hrStart, status }))\n try {\n const { adapterOas } = await dependencies.loadValidateModule()\n const adapter = adapterOas()\n if (!adapter.validate) {\n throw new Error('The loaded adapter does not support validation.')\n }\n await adapter.validate(input, { throwOnError: true })\n await report('success')\n console.log('✅ Validation success')\n } catch (error) {\n await report('failed')\n if (error instanceof Error && /@kubb\\/adapter-oas/.test(error.message)) {\n console.error(styleText('red', 'The @kubb/adapter-oas package is not installed.'))\n console.error('')\n console.error('Install it with:')\n console.error(styleText('cyan', ' npm install @kubb/adapter-oas'))\n console.error(styleText('cyan', ' # or'))\n console.error(styleText('cyan', ' pnpm install @kubb/adapter-oas'))\n console.error('')\n }\n console.error('❌ Validation failed')\n console.error(getErrorMessage(error))\n process.exit(1)\n }\n}\n"],"mappings":";;;;;;;;;AA2BA,SAAgB,qBAA8C;CAC5D,OAAO,OAAO;AAChB;;;;;AAMA,eAAsB,IAAI,EAAE,OAAO,WAA4B,eAAqC,EAAE,mBAAmB,GAAkB;CACzI,MAAM,UAAU,QAAQ,OAAO;CAC/B,MAAM,UAAU,WAAiC,UAAU,KAAK,UAAU,MAAM;EAAE,SAAS;EAAY,aAAa;EAAS;EAAS;CAAO,CAAC,CAAC;CAC/I,IAAI;EACF,MAAM,EAAE,eAAe,MAAM,aAAa,mBAAmB;EAC7D,MAAM,UAAU,WAAW;EAC3B,IAAI,CAAC,QAAQ,UACX,MAAM,IAAI,MAAM,iDAAiD;EAEnE,MAAM,QAAQ,SAAS,OAAO,EAAE,cAAc,KAAK,CAAC;EACpD,MAAM,OAAO,SAAS;EACtB,QAAQ,IAAI,sBAAsB;CACpC,SAAS,OAAO;EACd,MAAM,OAAO,QAAQ;EACrB,IAAI,iBAAiB,SAAS,qBAAqB,KAAK,MAAM,OAAO,GAAG;GACtE,QAAQ,MAAM,UAAU,OAAO,iDAAiD,CAAC;GACjF,QAAQ,MAAM,EAAE;GAChB,QAAQ,MAAM,kBAAkB;GAChC,QAAQ,MAAM,UAAU,QAAQ,iCAAiC,CAAC;GAClE,QAAQ,MAAM,UAAU,QAAQ,QAAQ,CAAC;GACzC,QAAQ,MAAM,UAAU,QAAQ,kCAAkC,CAAC;GACnE,QAAQ,MAAM,EAAE;EAClB;EACA,QAAQ,MAAM,qBAAqB;EACnC,QAAQ,MAAM,gBAAgB,KAAK,CAAC;EACpC,QAAQ,KAAK,CAAC;CAChB;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./chunk-C0LytTxp.js";
|
|
2
2
|
import { t as getErrorMessage } from "./errors-BsemQCMn.js";
|
|
3
|
-
import { t as Telemetry } from "./Telemetry-
|
|
3
|
+
import { t as Telemetry } from "./Telemetry-CVdyJarO.js";
|
|
4
4
|
import { styleText } from "node:util";
|
|
5
5
|
import process from "node:process";
|
|
6
6
|
//#region src/runners/mcp/run.ts
|
|
@@ -29,4 +29,4 @@ async function run({ version, port, host }) {
|
|
|
29
29
|
//#endregion
|
|
30
30
|
export { run };
|
|
31
31
|
|
|
32
|
-
//# sourceMappingURL=run-
|
|
32
|
+
//# sourceMappingURL=run-h8NTawHO.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-
|
|
1
|
+
{"version":3,"file":"run-h8NTawHO.js","names":[],"sources":["../src/runners/mcp/run.ts"],"sourcesContent":["import process from 'node:process'\nimport { styleText } from 'node:util'\nimport { getErrorMessage } from '@internals/utils'\nimport { Telemetry } from '../../Telemetry.ts'\nimport type * as McpModule from '@kubb/mcp'\n\ntype McpOptions = {\n /**\n * Current `@kubb/cli` version string, used for the telemetry payload.\n */\n version: string\n /**\n * TCP port for the HTTP MCP server. When `undefined`, the server uses stdio transport.\n */\n port?: string\n /**\n * Hostname to bind to when running in HTTP mode.\n *\n * @default 'localhost'\n */\n host?: string\n}\n\nexport async function run({ version, port, host }: McpOptions): Promise<void> {\n const { run: startMcpServer } = (await import('@kubb/mcp')) as typeof McpModule\n const hrStart = process.hrtime()\n const report = (status: 'success' | 'failed') => Telemetry.send(Telemetry.build({ command: 'mcp', kubbVersion: version, hrStart, status }))\n try {\n console.log(styleText('cyan', '⏳ Starting MCP server...'))\n console.warn(styleText('yellow', 'This feature is still under development, use with caution'))\n await startMcpServer(undefined, { port: port !== undefined ? Number(port) : undefined, host })\n await report('success')\n } catch (error) {\n await report('failed')\n console.error(getErrorMessage(error))\n }\n}\n"],"mappings":";;;;;;AAuBA,eAAsB,IAAI,EAAE,SAAS,MAAM,QAAmC;CAC5E,MAAM,EAAE,KAAK,mBAAoB,MAAM,OAAO;CAC9C,MAAM,UAAU,QAAQ,OAAO;CAC/B,MAAM,UAAU,WAAiC,UAAU,KAAK,UAAU,MAAM;EAAE,SAAS;EAAO,aAAa;EAAS;EAAS;CAAO,CAAC,CAAC;CAC1I,IAAI;EACF,QAAQ,IAAI,UAAU,QAAQ,0BAA0B,CAAC;EACzD,QAAQ,KAAK,UAAU,UAAU,2DAA2D,CAAC;EAC7F,MAAM,eAAe,KAAA,GAAW;GAAE,MAAM,SAAS,KAAA,IAAY,OAAO,IAAI,IAAI,KAAA;GAAW;EAAK,CAAC;EAC7F,MAAM,OAAO,SAAS;CACxB,SAAS,OAAO;EACd,MAAM,OAAO,QAAQ;EACrB,QAAQ,MAAM,gBAAgB,KAAK,CAAC;CACtC;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require("./chunk-Bx3C2hgW.cjs");
|
|
2
2
|
const require_define = require("./define-C4AB3POr.cjs");
|
|
3
|
-
const require_package = require("./package-
|
|
3
|
+
const require_package = require("./package-BAbAGPib.cjs");
|
|
4
4
|
//#region src/commands/validate.ts
|
|
5
5
|
const command = require_define.defineCommand({
|
|
6
6
|
name: "validate",
|
|
@@ -13,7 +13,7 @@ const command = require_define.defineCommand({
|
|
|
13
13
|
required: true
|
|
14
14
|
} },
|
|
15
15
|
async run({ values }) {
|
|
16
|
-
const { run } = await Promise.resolve().then(() => require("./run-
|
|
16
|
+
const { run } = await Promise.resolve().then(() => require("./run-BQO_tPlc.cjs"));
|
|
17
17
|
await run({
|
|
18
18
|
input: values.input,
|
|
19
19
|
version: require_package.version
|
|
@@ -23,4 +23,4 @@ const command = require_define.defineCommand({
|
|
|
23
23
|
//#endregion
|
|
24
24
|
exports.command = command;
|
|
25
25
|
|
|
26
|
-
//# sourceMappingURL=validate-
|
|
26
|
+
//# sourceMappingURL=validate-3qzRzz3x.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-
|
|
1
|
+
{"version":3,"file":"validate-3qzRzz3x.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:\n 'Parse and validate an OpenAPI/Swagger file for structural correctness. Reports schema errors, missing required fields, and malformed references. Use this before running generate to catch spec issues early.',\n examples: ['kubb validate --input ./openapi.yaml', 'kubb validate --input https://petstore3.swagger.io/api/v3/openapi.json'],\n options: {\n input: {\n type: 'string',\n description: 'Path or URL to the OpenAPI/Swagger file to validate',\n short: 'i',\n required: true,\n },\n },\n async run({ values }) {\n const { run } = await import('../runners/validate/run.ts')\n\n await run({ input: values.input, version })\n },\n})\n"],"mappings":";;;;AAGA,MAAa,UAAUA,eAAAA,cAAc;CACnC,MAAM;CACN,aACE;CACF,UAAU,CAAC,wCAAwC,wEAAwE;CAC3H,SAAS,EACP,OAAO;EACL,MAAM;EACN,aAAa;EACb,OAAO;EACP,UAAU;CACZ,EACF;CACA,MAAM,IAAI,EAAE,UAAU;EACpB,MAAM,EAAE,QAAQ,MAAA,QAAA,QAAA,CAAA,CAAA,WAAA,QAAM,oBAAA,CAAA;EAEtB,MAAM,IAAI;GAAE,OAAO,OAAO;GAAO,SAAA,gBAAA;EAAQ,CAAC;CAC5C;AACF,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./chunk-C0LytTxp.js";
|
|
2
2
|
import { n as defineCommand } from "./define-C63T4jp6.js";
|
|
3
|
-
import { t as version } from "./package-
|
|
3
|
+
import { t as version } from "./package-BNgAvZIJ.js";
|
|
4
4
|
//#region src/commands/validate.ts
|
|
5
5
|
const command = defineCommand({
|
|
6
6
|
name: "validate",
|
|
@@ -13,7 +13,7 @@ const command = defineCommand({
|
|
|
13
13
|
required: true
|
|
14
14
|
} },
|
|
15
15
|
async run({ values }) {
|
|
16
|
-
const { run } = await import("./run-
|
|
16
|
+
const { run } = await import("./run-CYnDu3ch.js");
|
|
17
17
|
await run({
|
|
18
18
|
input: values.input,
|
|
19
19
|
version
|
|
@@ -23,4 +23,4 @@ const command = defineCommand({
|
|
|
23
23
|
//#endregion
|
|
24
24
|
export { command };
|
|
25
25
|
|
|
26
|
-
//# sourceMappingURL=validate-
|
|
26
|
+
//# sourceMappingURL=validate-Bcq9SN0T.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-
|
|
1
|
+
{"version":3,"file":"validate-Bcq9SN0T.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:\n 'Parse and validate an OpenAPI/Swagger file for structural correctness. Reports schema errors, missing required fields, and malformed references. Use this before running generate to catch spec issues early.',\n examples: ['kubb validate --input ./openapi.yaml', 'kubb validate --input https://petstore3.swagger.io/api/v3/openapi.json'],\n options: {\n input: {\n type: 'string',\n description: 'Path or URL to the OpenAPI/Swagger file to validate',\n short: 'i',\n required: true,\n },\n },\n async run({ values }) {\n const { run } = await import('../runners/validate/run.ts')\n\n await run({ input: values.input, version })\n },\n})\n"],"mappings":";;;;AAGA,MAAa,UAAU,cAAc;CACnC,MAAM;CACN,aACE;CACF,UAAU,CAAC,wCAAwC,wEAAwE;CAC3H,SAAS,EACP,OAAO;EACL,MAAM;EACN,aAAa;EACb,OAAO;EACP,UAAU;CACZ,EACF;CACA,MAAM,IAAI,EAAE,UAAU;EACpB,MAAM,EAAE,QAAQ,MAAM,OAAO;EAE7B,MAAM,IAAI;GAAE,OAAO,OAAO;GAAO;EAAQ,CAAC;CAC5C;AACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/cli",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.59",
|
|
4
4
|
"description": "Official CLI for Kubb. Run kubb generate, kubb init, kubb validate, and kubb mcp to manage the full code generation lifecycle from OpenAPI/Swagger specs.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -52,16 +52,16 @@
|
|
|
52
52
|
"cosmiconfig": "^9.0.2",
|
|
53
53
|
"jiti": "^2.7.0",
|
|
54
54
|
"tinyexec": "~1.1.2",
|
|
55
|
-
"@kubb/core": "5.0.0-beta.
|
|
55
|
+
"@kubb/core": "5.0.0-beta.59"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@internals/shared": "0.0.0",
|
|
59
59
|
"@internals/utils": "0.0.0",
|
|
60
|
-
"@kubb/adapter-oas": "5.0.0-beta.
|
|
60
|
+
"@kubb/adapter-oas": "5.0.0-beta.59"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
|
-
"@kubb/adapter-oas": "5.0.0-beta.
|
|
64
|
-
"@kubb/mcp": "5.0.0-beta.
|
|
63
|
+
"@kubb/adapter-oas": "5.0.0-beta.59",
|
|
64
|
+
"@kubb/mcp": "5.0.0-beta.59"
|
|
65
65
|
},
|
|
66
66
|
"peerDependenciesMeta": {
|
|
67
67
|
"@kubb/adapter-oas": {
|
package/src/Telemetry.ts
CHANGED
|
@@ -35,10 +35,17 @@ type OtlpInstrumentationScope = {
|
|
|
35
35
|
droppedAttributesCount?: number
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
/**
|
|
38
|
+
/**
|
|
39
|
+
* @see https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/trace/v1/trace.proto#L103
|
|
40
|
+
*/
|
|
39
41
|
type OtlpSpanKind = 0 | 1 | 2 | 3 | 4 | 5
|
|
40
42
|
|
|
41
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* Span status code.
|
|
45
|
+
* - `0` is unset
|
|
46
|
+
* - `1` is OK
|
|
47
|
+
* - `2` is error
|
|
48
|
+
*/
|
|
42
49
|
type OtlpStatusCode = 0 | 1 | 2
|
|
43
50
|
|
|
44
51
|
type OtlpStatus = {
|
|
@@ -91,7 +98,9 @@ type OtlpResourceSpans = {
|
|
|
91
98
|
schemaUrl?: string
|
|
92
99
|
}
|
|
93
100
|
|
|
94
|
-
/**
|
|
101
|
+
/**
|
|
102
|
+
* Root payload sent to POST /v1/traces.
|
|
103
|
+
*/
|
|
95
104
|
type OtlpExportTraceServiceRequest = {
|
|
96
105
|
resourceSpans: Array<OtlpResourceSpans>
|
|
97
106
|
}
|
|
@@ -105,7 +114,7 @@ export type TelemetryPlugin = {
|
|
|
105
114
|
*/
|
|
106
115
|
name: string
|
|
107
116
|
/**
|
|
108
|
-
*
|
|
117
|
+
* Anonymized snapshot of the plugin options. Values are included but cannot be traced back to a user.
|
|
109
118
|
*/
|
|
110
119
|
options: Record<string, unknown>
|
|
111
120
|
}
|
|
@@ -131,9 +140,9 @@ export type TelemetryEvent = {
|
|
|
131
140
|
}
|
|
132
141
|
|
|
133
142
|
/**
|
|
134
|
-
* Anonymous OTLP usage telemetry for
|
|
135
|
-
*
|
|
136
|
-
*
|
|
143
|
+
* Anonymous OTLP usage telemetry for a Kubb run. The API is static, so call it as `Telemetry.build(...)`
|
|
144
|
+
* and `Telemetry.send(...)`. No file paths, OpenAPI specs, or secrets are sent, and sending fails
|
|
145
|
+
* silently so a failed request never breaks the run.
|
|
137
146
|
*/
|
|
138
147
|
export class Telemetry {
|
|
139
148
|
/**
|
package/src/constants.ts
CHANGED
|
@@ -14,6 +14,6 @@ export const OTLP_ENDPOINT = 'https://otlp.kubb.dev' as const
|
|
|
14
14
|
export const WATCHER_IGNORED_PATHS = '**/{.git,node_modules}/**' as const
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
* Flags that short-circuit execution (help
|
|
17
|
+
* Flags that short-circuit execution (help and version). The telemetry notice is suppressed for these.
|
|
18
18
|
*/
|
|
19
19
|
export const QUIET_FLAGS = new Set<string>(['--help', '-h', '--version', '-v'])
|
|
@@ -8,7 +8,7 @@ import { defineLogger } from './defineLogger.ts'
|
|
|
8
8
|
import { buildProgressLine, createProgressCounters, formatCommandWithArgs, formatMessage, recordPluginResult, resetProgressCounters } from './utils.ts'
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
* TTY logger with
|
|
11
|
+
* TTY logger for local development, with spinners and progress bars.
|
|
12
12
|
*/
|
|
13
13
|
export const clackLogger = defineLogger({
|
|
14
14
|
name: 'clack',
|
|
@@ -379,7 +379,7 @@ Run \`npm install -g @kubb/cli\` to update`,
|
|
|
379
379
|
active.taskLog.success(getMessage(`${styleText('dim', commandWithArgs)} completed in ${duration}`))
|
|
380
380
|
} else {
|
|
381
381
|
// The hook's output already reached the taskLog live via `kubb:hook:line`, so `showLog`
|
|
382
|
-
// replays it here
|
|
382
|
+
// replays it here. `kubb:hook:end` carries no captured output on the streaming path.
|
|
383
383
|
const reason = error?.message ? ` (${error.message})` : ''
|
|
384
384
|
active.taskLog.error(getMessage(`${styleText('dim', commandWithArgs)} failed${reason}`), { showLog: true })
|
|
385
385
|
}
|
|
@@ -5,7 +5,7 @@ import { defineLogger } from './defineLogger.ts'
|
|
|
5
5
|
import { createHookTimer, formatCommandWithArgs, formatMessage } from './utils.ts'
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* Plain console adapter for non-TTY environments
|
|
8
|
+
* Plain console adapter for non-TTY environments, built on `console.log`.
|
|
9
9
|
*/
|
|
10
10
|
export const plainLogger = defineLogger({
|
|
11
11
|
name: 'plain',
|
package/src/loggers/utils.ts
CHANGED
|
@@ -156,7 +156,9 @@ export function createHookTimer(): HookTimer {
|
|
|
156
156
|
|
|
157
157
|
/**
|
|
158
158
|
* Join a command and its optional args into a single display string.
|
|
159
|
-
*
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* `formatCommandWithArgs('prettier', ['--write', '.']) → 'prettier --write .'`
|
|
160
162
|
*/
|
|
161
163
|
export function formatCommandWithArgs(command: string, args?: ReadonlyArray<string>): string {
|
|
162
164
|
return args?.length ? `${command} ${args.join(' ')}` : command
|
|
@@ -190,7 +192,7 @@ export function installReporter(context: LoggerContext, reporter: Reporter, ctx:
|
|
|
190
192
|
|
|
191
193
|
/**
|
|
192
194
|
* Installs the live logger (the TUI view) and the given reporters (the output). The reporters are
|
|
193
|
-
* already selected by the caller (the CLI maps `--reporter` to names via `selectReporters`)
|
|
195
|
+
* already selected by the caller (the CLI maps `--reporter` to names via `selectReporters`). This
|
|
194
196
|
* only wires them. Loggers receive hook subprocess output through `kubb:hook:line` and the
|
|
195
197
|
* `stdout`/`stderr` on `kubb:hook:end`, so nothing is returned here.
|
|
196
198
|
*
|
|
@@ -50,7 +50,7 @@ type RunToolPassOptions = {
|
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
52
|
* Registers a one-shot `kubb:hook:end` listener for `hookId` BEFORE the caller emits `kubb:hook:start`,
|
|
53
|
-
*
|
|
53
|
+
* so a synchronous emitter can't fire end before the listener is attached.
|
|
54
54
|
*/
|
|
55
55
|
function waitForHookEnd(
|
|
56
56
|
hooks: AsyncEventEmitter<KubbHooks>,
|
|
@@ -118,8 +118,10 @@ type ExecuteHooksOptions = {
|
|
|
118
118
|
* Tokenizes a shell command string, respecting single and double quotes.
|
|
119
119
|
*
|
|
120
120
|
* @example
|
|
121
|
+
* ```ts
|
|
121
122
|
* tokenize('git commit -m "initial commit"')
|
|
122
123
|
* // → ['git', 'commit', '-m', 'initial commit']
|
|
124
|
+
* ```
|
|
123
125
|
*/
|
|
124
126
|
function tokenize(command: string): Array<string> {
|
|
125
127
|
return (command.match(/[^\s"']+|"([^"]*)"|'([^']*)'/g) ?? []).map((token) => token.replace(/^["']|["']$/g, ''))
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Telemetry-BuDSora3.cjs","names":["process","os"],"sources":["../../../internals/utils/src/env.ts","../../../internals/utils/src/runtime.ts","../src/constants.ts","../src/Telemetry.ts"],"sourcesContent":["/**\n * Returns `true` when the process is running in a CI environment.\n * Covers GitHub Actions, GitLab CI, CircleCI, Travis CI, Jenkins, Bitbucket,\n * TeamCity, Buildkite, and Azure Pipelines.\n *\n * @example\n * ```ts\n * if (isCIEnvironment()) {\n * logger.level = 'error'\n * }\n * ```\n */\nexport function isCIEnvironment(): boolean {\n return !!(\n process.env.CI ||\n process.env.GITHUB_ACTIONS ||\n process.env.GITLAB_CI ||\n process.env.BITBUCKET_BUILD_NUMBER ||\n process.env.JENKINS_URL ||\n process.env.CIRCLECI ||\n process.env.TRAVIS ||\n process.env.TEAMCITY_VERSION ||\n process.env.BUILDKITE ||\n process.env.TF_BUILD\n )\n}\n\n/**\n * Returns `true` when the process has an interactive TTY with a valid terminal\n * width and is not running in CI.\n *\n * Some IDE-embedded terminals report `isTTY = true` but set `columns` to `0`,\n * which breaks clack's box-drawing helpers (they call `String.prototype.repeat`\n * with a negative count and throw a `RangeError`). We therefore require a\n * positive column count before declaring the TTY usable.\n *\n * @example\n * ```ts\n * if (canUseTTY()) {\n * renderProgressBar()\n * }\n * ```\n */\nexport function canUseTTY(): boolean {\n return process.stdout.isTTY && (process.stdout.columns ?? 0) > 0 && !isCIEnvironment()\n}\n","/**\n * Name of the JavaScript runtime executing the current process.\n */\ntype RuntimeName = 'bun' | 'deno' | 'node'\n\n/**\n * Detects the JavaScript runtime executing the current process and exposes its name and version.\n *\n * Prefer the shared {@link runtime} instance over constructing your own.\n */\nclass Runtime {\n /**\n * `true` when the current process is running under Bun.\n *\n * Detection keys off the global `Bun` object rather than `process.versions`,\n * because Bun polyfills `process.versions.node` for Node compatibility and would\n * otherwise look like Node.\n *\n * @example\n * ```ts\n * if (runtime.isBun) {\n * await Bun.write(path, data)\n * }\n * ```\n */\n get isBun(): boolean {\n return typeof Bun !== 'undefined'\n }\n\n /**\n * `true` when the current process is running under Deno.\n */\n get isDeno(): boolean {\n return typeof (globalThis as { Deno?: unknown }).Deno !== 'undefined'\n }\n\n /**\n * `true` when the current process is running under Node.\n *\n * Bun and Deno are excluded first so a polyfilled `process` does not register as Node.\n */\n get isNode(): boolean {\n return !this.isBun && !this.isDeno && typeof process !== 'undefined' && process.versions?.node != null\n }\n\n /**\n * Name of the runtime executing the current process.\n *\n * @example\n * ```ts\n * runtime.name // 'bun' when run with `bun kubb`, 'node' otherwise\n * ```\n */\n get name(): RuntimeName {\n if (this.isBun) return 'bun'\n if (this.isDeno) return 'deno'\n\n return 'node'\n }\n\n /**\n * Version of the active runtime, or an empty string when it cannot be read.\n *\n * @example\n * ```ts\n * runtime.version // '1.3.11' under Bun, '22.22.2' under Node\n * ```\n */\n get version(): string {\n if (this.isBun) return process.versions.bun ?? ''\n if (this.isDeno) return (globalThis as { Deno?: { version?: { deno?: string } } }).Deno?.version?.deno ?? ''\n\n return process.versions?.node ?? ''\n }\n}\n\n/**\n * Shared {@link Runtime} instance describing the JavaScript runtime executing the current process.\n */\nexport const runtime = new Runtime()\n","/**\n * NPM registry endpoint used to check for @kubb/cli updates.\n */\nexport const KUBB_NPM_PACKAGE_URL = 'https://registry.npmjs.org/@kubb/cli/latest' as const\n\n/**\n * OpenTelemetry ingestion endpoint for anonymous usage telemetry.\n */\nexport const OTLP_ENDPOINT = 'https://otlp.kubb.dev' as const\n\n/**\n * Glob pattern for paths the file watcher ignores.\n */\nexport const WATCHER_IGNORED_PATHS = '**/{.git,node_modules}/**' as const\n\n/**\n * Flags that short-circuit execution (help/version), no telemetry notice is shown.\n */\nexport const QUIET_FLAGS = new Set<string>(['--help', '-h', '--version', '-v'])\n","import { randomBytes } from 'node:crypto'\nimport os from 'node:os'\nimport process from 'node:process'\nimport { isCIEnvironment, runtime } from '@internals/utils'\nimport { OTLP_ENDPOINT } from './constants.ts'\n\n// OpenTelemetry OTLP JSON types\n// https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/trace/v1/trace.proto\n// https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/common/v1/common.proto\n\ntype OtlpStringValue = { stringValue: string }\ntype OtlpBoolValue = { boolValue: boolean }\ntype OtlpIntValue = { intValue: number }\ntype OtlpDoubleValue = { doubleValue: number }\ntype OtlpBytesValue = { bytesValue: string }\ntype OtlpArrayValue = { arrayValue: { values: Array<OtlpAnyValue> } }\ntype OtlpKvListValue = { kvlistValue: { values: Array<OtlpKeyValue> } }\n\ntype OtlpAnyValue = OtlpStringValue | OtlpBoolValue | OtlpIntValue | OtlpDoubleValue | OtlpBytesValue | OtlpArrayValue | OtlpKvListValue\n\ntype OtlpKeyValue = {\n key: string\n value: OtlpAnyValue\n}\n\ntype OtlpResource = {\n attributes: Array<OtlpKeyValue>\n droppedAttributesCount?: number\n}\n\ntype OtlpInstrumentationScope = {\n name: string\n version?: string\n attributes?: Array<OtlpKeyValue>\n droppedAttributesCount?: number\n}\n\n/** https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/trace/v1/trace.proto#L103 */\ntype OtlpSpanKind = 0 | 1 | 2 | 3 | 4 | 5\n\n/** 0 = STATUS_CODE_UNSET, 1 = STATUS_CODE_OK, 2 = STATUS_CODE_ERROR */\ntype OtlpStatusCode = 0 | 1 | 2\n\ntype OtlpStatus = {\n code: OtlpStatusCode\n message?: string\n}\n\ntype OtlpSpan = {\n traceId: string\n spanId: string\n traceState?: string\n parentSpanId?: string\n name: string\n kind: OtlpSpanKind\n startTimeUnixNano: string\n endTimeUnixNano: string\n attributes?: Array<OtlpKeyValue>\n droppedAttributesCount?: number\n events?: Array<OtlpSpanEvent>\n droppedEventsCount?: number\n links?: Array<OtlpSpanLink>\n droppedLinksCount?: number\n status?: OtlpStatus\n}\n\ntype OtlpSpanEvent = {\n timeUnixNano: string\n name: string\n attributes?: Array<OtlpKeyValue>\n droppedAttributesCount?: number\n}\n\ntype OtlpSpanLink = {\n traceId: string\n spanId: string\n traceState?: string\n attributes?: Array<OtlpKeyValue>\n droppedAttributesCount?: number\n}\n\ntype OtlpScopeSpans = {\n scope: OtlpInstrumentationScope\n spans: Array<OtlpSpan>\n schemaUrl?: string\n}\n\ntype OtlpResourceSpans = {\n resource: OtlpResource\n scopeSpans: Array<OtlpScopeSpans>\n schemaUrl?: string\n}\n\n/** Root payload sent to POST /v1/traces */\ntype OtlpExportTraceServiceRequest = {\n resourceSpans: Array<OtlpResourceSpans>\n}\n\n/**\n * Anonymous plugin name and options snapshot sent with each telemetry event.\n */\nexport type TelemetryPlugin = {\n /**\n * Plugin name as registered in the Kubb config, e.g. `'@kubb/plugin-ts'`.\n */\n name: string\n /**\n * anonymized plugin options snapshot, values are included but cannot be traced back to the user.\n */\n options: Record<string, unknown>\n}\n\nexport type TelemetryEvent = {\n command: string\n kubbVersion: string\n nodeVersion: string\n /**\n * Name of the JavaScript runtime that executed the run, `'bun'`, `'deno'`, or `'node'`.\n */\n runtime: string\n /**\n * Major version of the active runtime, e.g. `'1'` under Bun or `'22'` under Node.\n */\n runtimeVersion: string\n platform: string\n ci: boolean\n plugins: Array<TelemetryPlugin>\n duration: number\n filesCreated: number\n status: 'success' | 'failed'\n}\n\n/**\n * Anonymous OTLP usage telemetry for the Kubb run. All methods are static, so call them as\n * `Telemetry.build(...)`, `Telemetry.send(...)`, and `Telemetry.isDisabled()`. No file paths,\n * OpenAPI specs, or secrets are ever included, and sending fails silently to never break a run.\n */\nexport class Telemetry {\n /**\n * Returns `true` when telemetry is disabled via `DO_NOT_TRACK` or `KUBB_DISABLE_TELEMETRY`.\n */\n static get isDisabled(): boolean {\n return (\n process.env['DO_NOT_TRACK'] === '1' ||\n process.env['DO_NOT_TRACK'] === 'true' ||\n process.env['KUBB_DISABLE_TELEMETRY'] === '1' ||\n process.env['KUBB_DISABLE_TELEMETRY'] === 'true'\n )\n }\n\n /**\n * Build an anonymous telemetry payload from a completed generation run.\n */\n static build(options: {\n command: 'generate' | 'mcp' | 'validate' | 'agent'\n kubbVersion: string\n plugins?: Array<TelemetryPlugin>\n hrStart: [number, number]\n filesCreated?: number\n status: 'success' | 'failed'\n }): TelemetryEvent {\n const [seconds, nanoseconds] = process.hrtime(options.hrStart)\n const duration = Math.round(seconds * 1000 + nanoseconds / 1e6)\n\n return {\n command: options.command,\n kubbVersion: options.kubbVersion,\n nodeVersion: process.versions.node.split('.')[0] as string,\n runtime: runtime.name,\n runtimeVersion: runtime.version.split('.')[0] as string,\n platform: os.platform(),\n ci: isCIEnvironment(),\n plugins: options.plugins ?? [],\n duration,\n filesCreated: options.filesCreated ?? 0,\n status: options.status,\n }\n }\n\n /**\n * Convert a {@link TelemetryEvent} into an OTLP-compatible JSON trace payload.\n * See https://opentelemetry.io/docs/languages/sdk-configuration/otlp-exporter/\n */\n static buildOtlpPayload(event: TelemetryEvent): OtlpExportTraceServiceRequest {\n const traceId = randomBytes(16).toString('hex')\n const spanId = randomBytes(8).toString('hex')\n const endTimeNs = BigInt(Date.now()) * 1_000_000n\n const startTimeNs = endTimeNs - BigInt(event.duration) * 1_000_000n\n\n const attributes: Array<OtlpKeyValue> = [\n { key: 'kubb.command', value: { stringValue: event.command } },\n { key: 'kubb.version', value: { stringValue: event.kubbVersion } },\n { key: 'kubb.node_version', value: { stringValue: event.nodeVersion } },\n { key: 'kubb.runtime', value: { stringValue: event.runtime } },\n { key: 'kubb.runtime_version', value: { stringValue: event.runtimeVersion } },\n { key: 'kubb.platform', value: { stringValue: event.platform } },\n { key: 'kubb.ci', value: { boolValue: event.ci } },\n { key: 'kubb.files_created', value: { intValue: event.filesCreated } },\n { key: 'kubb.status', value: { stringValue: event.status } },\n {\n key: 'kubb.plugins',\n value: {\n arrayValue: {\n values: event.plugins.map(\n (p): OtlpKvListValue => ({\n kvlistValue: {\n values: [\n { key: 'name', value: { stringValue: p.name } },\n {\n key: 'options',\n value: {\n stringValue: JSON.stringify({\n ...p.options,\n usedEnumNames: undefined,\n }),\n },\n },\n ],\n },\n }),\n ),\n },\n },\n },\n ]\n\n return {\n resourceSpans: [\n {\n resource: {\n attributes: [\n { key: 'service.name', value: { stringValue: 'kubb-core' } },\n {\n key: 'service.version',\n value: { stringValue: event.kubbVersion },\n },\n { key: 'telemetry.sdk.language', value: { stringValue: 'nodejs' } },\n ],\n },\n scopeSpans: [\n {\n scope: { name: 'kubb-core', version: event.kubbVersion },\n spans: [\n {\n traceId,\n spanId,\n name: event.command,\n kind: 1 satisfies OtlpSpanKind,\n startTimeUnixNano: String(startTimeNs),\n endTimeUnixNano: String(endTimeNs),\n attributes,\n status: {\n code: (event.status === 'success' ? 1 : 2) satisfies OtlpStatusCode,\n },\n },\n ],\n },\n ],\n },\n ],\n }\n }\n\n /**\n * Send an anonymous telemetry event to the Kubb OTLP endpoint. Respects `DO_NOT_TRACK` and\n * `KUBB_DISABLE_TELEMETRY`, and fails silently so telemetry never interrupts a run.\n */\n static async send(event: TelemetryEvent): Promise<void> {\n if (Telemetry.isDisabled) {\n return\n }\n\n try {\n await fetch(`${OTLP_ENDPOINT}/v1/traces`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Kubb-Telemetry-Version': '1',\n 'Kubb-Telemetry-Source': 'kubb-core',\n },\n body: JSON.stringify(Telemetry.buildOtlpPayload(event)),\n signal: AbortSignal.timeout(5_000),\n })\n } catch (_e) {\n // Fail silently, telemetry must never break the run\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAYA,SAAgB,kBAA2B;CACzC,OAAO,CAAC,EACN,QAAQ,IAAI,MACZ,QAAQ,IAAI,kBACZ,QAAQ,IAAI,aACZ,QAAQ,IAAI,0BACZ,QAAQ,IAAI,eACZ,QAAQ,IAAI,YACZ,QAAQ,IAAI,UACZ,QAAQ,IAAI,oBACZ,QAAQ,IAAI,aACZ,QAAQ,IAAI;AAEhB;;;;;;;;;;;;;;;;;AAkBA,SAAgB,YAAqB;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M,QAAQ,KACnB,OAAwB,EACvB,aAAa,EACX,QAAQ,CACN;KAAE,KAAK;KAAQ,OAAO,EAAE,aAAa,EAAE,KAAK;IAAE,GAC9C;KACE,KAAK;KACL,OAAO,EACL,aAAa,KAAK,UAAU;MAC1B,GAAG,EAAE;MACL,eAAe,KAAA;KACjB,CAAC,EACH;IACF,CACF,EACF,EACF,EACF,EACF,EACF;GACF;EACF;EAEA,OAAO,EACL,eAAe,CACb;GACE,UAAU,EACR,YAAY;IACV;KAAE,KAAK;KAAgB,OAAO,EAAE,aAAa,YAAY;IAAE;IAC3D;KACE,KAAK;KACL,OAAO,EAAE,aAAa,MAAM,YAAY;IAC1C;IACA;KAAE,KAAK;KAA0B,OAAO,EAAE,aAAa,SAAS;IAAE;GACpE,EACF;GACA,YAAY,CACV;IACE,OAAO;KAAE,MAAM;KAAa,SAAS,MAAM;IAAY;IACvD,OAAO,CACL;KACE;KACA;KACA,MAAM,MAAM;KACZ,MAAM;KACN,mBAAmB,OAAO,WAAW;KACrC,iBAAiB,OAAO,SAAS;KACjC;KACA,QAAQ,EACN,MAAO,MAAM,WAAW,YAAY,IAAI,EAC1C;IACF,CACF;GACF,CACF;EACF,CACF,EACF;CACF;;;;;CAMA,aAAa,KAAK,OAAsC;EACtD,IAAI,UAAU,YACZ;EAGF,IAAI;GACF,MAAM,MAAM,GAAG,cAAc,aAAa;IACxC,QAAQ;IACR,SAAS;KACP,gBAAgB;KAChB,0BAA0B;KAC1B,yBAAyB;IAC3B;IACA,MAAM,KAAK,UAAU,UAAU,iBAAiB,KAAK,CAAC;IACtD,QAAQ,YAAY,QAAQ,GAAK;GACnC,CAAC;EACH,SAAS,IAAI,CAEb;CACF;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Telemetry-C66uYyC2.js","names":["process"],"sources":["../../../internals/utils/src/env.ts","../../../internals/utils/src/runtime.ts","../src/constants.ts","../src/Telemetry.ts"],"sourcesContent":["/**\n * Returns `true` when the process is running in a CI environment.\n * Covers GitHub Actions, GitLab CI, CircleCI, Travis CI, Jenkins, Bitbucket,\n * TeamCity, Buildkite, and Azure Pipelines.\n *\n * @example\n * ```ts\n * if (isCIEnvironment()) {\n * logger.level = 'error'\n * }\n * ```\n */\nexport function isCIEnvironment(): boolean {\n return !!(\n process.env.CI ||\n process.env.GITHUB_ACTIONS ||\n process.env.GITLAB_CI ||\n process.env.BITBUCKET_BUILD_NUMBER ||\n process.env.JENKINS_URL ||\n process.env.CIRCLECI ||\n process.env.TRAVIS ||\n process.env.TEAMCITY_VERSION ||\n process.env.BUILDKITE ||\n process.env.TF_BUILD\n )\n}\n\n/**\n * Returns `true` when the process has an interactive TTY with a valid terminal\n * width and is not running in CI.\n *\n * Some IDE-embedded terminals report `isTTY = true` but set `columns` to `0`,\n * which breaks clack's box-drawing helpers (they call `String.prototype.repeat`\n * with a negative count and throw a `RangeError`). We therefore require a\n * positive column count before declaring the TTY usable.\n *\n * @example\n * ```ts\n * if (canUseTTY()) {\n * renderProgressBar()\n * }\n * ```\n */\nexport function canUseTTY(): boolean {\n return process.stdout.isTTY && (process.stdout.columns ?? 0) > 0 && !isCIEnvironment()\n}\n","/**\n * Name of the JavaScript runtime executing the current process.\n */\ntype RuntimeName = 'bun' | 'deno' | 'node'\n\n/**\n * Detects the JavaScript runtime executing the current process and exposes its name and version.\n *\n * Prefer the shared {@link runtime} instance over constructing your own.\n */\nclass Runtime {\n /**\n * `true` when the current process is running under Bun.\n *\n * Detection keys off the global `Bun` object rather than `process.versions`,\n * because Bun polyfills `process.versions.node` for Node compatibility and would\n * otherwise look like Node.\n *\n * @example\n * ```ts\n * if (runtime.isBun) {\n * await Bun.write(path, data)\n * }\n * ```\n */\n get isBun(): boolean {\n return typeof Bun !== 'undefined'\n }\n\n /**\n * `true` when the current process is running under Deno.\n */\n get isDeno(): boolean {\n return typeof (globalThis as { Deno?: unknown }).Deno !== 'undefined'\n }\n\n /**\n * `true` when the current process is running under Node.\n *\n * Bun and Deno are excluded first so a polyfilled `process` does not register as Node.\n */\n get isNode(): boolean {\n return !this.isBun && !this.isDeno && typeof process !== 'undefined' && process.versions?.node != null\n }\n\n /**\n * Name of the runtime executing the current process.\n *\n * @example\n * ```ts\n * runtime.name // 'bun' when run with `bun kubb`, 'node' otherwise\n * ```\n */\n get name(): RuntimeName {\n if (this.isBun) return 'bun'\n if (this.isDeno) return 'deno'\n\n return 'node'\n }\n\n /**\n * Version of the active runtime, or an empty string when it cannot be read.\n *\n * @example\n * ```ts\n * runtime.version // '1.3.11' under Bun, '22.22.2' under Node\n * ```\n */\n get version(): string {\n if (this.isBun) return process.versions.bun ?? ''\n if (this.isDeno) return (globalThis as { Deno?: { version?: { deno?: string } } }).Deno?.version?.deno ?? ''\n\n return process.versions?.node ?? ''\n }\n}\n\n/**\n * Shared {@link Runtime} instance describing the JavaScript runtime executing the current process.\n */\nexport const runtime = new Runtime()\n","/**\n * NPM registry endpoint used to check for @kubb/cli updates.\n */\nexport const KUBB_NPM_PACKAGE_URL = 'https://registry.npmjs.org/@kubb/cli/latest' as const\n\n/**\n * OpenTelemetry ingestion endpoint for anonymous usage telemetry.\n */\nexport const OTLP_ENDPOINT = 'https://otlp.kubb.dev' as const\n\n/**\n * Glob pattern for paths the file watcher ignores.\n */\nexport const WATCHER_IGNORED_PATHS = '**/{.git,node_modules}/**' as const\n\n/**\n * Flags that short-circuit execution (help/version), no telemetry notice is shown.\n */\nexport const QUIET_FLAGS = new Set<string>(['--help', '-h', '--version', '-v'])\n","import { randomBytes } from 'node:crypto'\nimport os from 'node:os'\nimport process from 'node:process'\nimport { isCIEnvironment, runtime } from '@internals/utils'\nimport { OTLP_ENDPOINT } from './constants.ts'\n\n// OpenTelemetry OTLP JSON types\n// https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/trace/v1/trace.proto\n// https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/common/v1/common.proto\n\ntype OtlpStringValue = { stringValue: string }\ntype OtlpBoolValue = { boolValue: boolean }\ntype OtlpIntValue = { intValue: number }\ntype OtlpDoubleValue = { doubleValue: number }\ntype OtlpBytesValue = { bytesValue: string }\ntype OtlpArrayValue = { arrayValue: { values: Array<OtlpAnyValue> } }\ntype OtlpKvListValue = { kvlistValue: { values: Array<OtlpKeyValue> } }\n\ntype OtlpAnyValue = OtlpStringValue | OtlpBoolValue | OtlpIntValue | OtlpDoubleValue | OtlpBytesValue | OtlpArrayValue | OtlpKvListValue\n\ntype OtlpKeyValue = {\n key: string\n value: OtlpAnyValue\n}\n\ntype OtlpResource = {\n attributes: Array<OtlpKeyValue>\n droppedAttributesCount?: number\n}\n\ntype OtlpInstrumentationScope = {\n name: string\n version?: string\n attributes?: Array<OtlpKeyValue>\n droppedAttributesCount?: number\n}\n\n/** https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/trace/v1/trace.proto#L103 */\ntype OtlpSpanKind = 0 | 1 | 2 | 3 | 4 | 5\n\n/** 0 = STATUS_CODE_UNSET, 1 = STATUS_CODE_OK, 2 = STATUS_CODE_ERROR */\ntype OtlpStatusCode = 0 | 1 | 2\n\ntype OtlpStatus = {\n code: OtlpStatusCode\n message?: string\n}\n\ntype OtlpSpan = {\n traceId: string\n spanId: string\n traceState?: string\n parentSpanId?: string\n name: string\n kind: OtlpSpanKind\n startTimeUnixNano: string\n endTimeUnixNano: string\n attributes?: Array<OtlpKeyValue>\n droppedAttributesCount?: number\n events?: Array<OtlpSpanEvent>\n droppedEventsCount?: number\n links?: Array<OtlpSpanLink>\n droppedLinksCount?: number\n status?: OtlpStatus\n}\n\ntype OtlpSpanEvent = {\n timeUnixNano: string\n name: string\n attributes?: Array<OtlpKeyValue>\n droppedAttributesCount?: number\n}\n\ntype OtlpSpanLink = {\n traceId: string\n spanId: string\n traceState?: string\n attributes?: Array<OtlpKeyValue>\n droppedAttributesCount?: number\n}\n\ntype OtlpScopeSpans = {\n scope: OtlpInstrumentationScope\n spans: Array<OtlpSpan>\n schemaUrl?: string\n}\n\ntype OtlpResourceSpans = {\n resource: OtlpResource\n scopeSpans: Array<OtlpScopeSpans>\n schemaUrl?: string\n}\n\n/** Root payload sent to POST /v1/traces */\ntype OtlpExportTraceServiceRequest = {\n resourceSpans: Array<OtlpResourceSpans>\n}\n\n/**\n * Anonymous plugin name and options snapshot sent with each telemetry event.\n */\nexport type TelemetryPlugin = {\n /**\n * Plugin name as registered in the Kubb config, e.g. `'@kubb/plugin-ts'`.\n */\n name: string\n /**\n * anonymized plugin options snapshot, values are included but cannot be traced back to the user.\n */\n options: Record<string, unknown>\n}\n\nexport type TelemetryEvent = {\n command: string\n kubbVersion: string\n nodeVersion: string\n /**\n * Name of the JavaScript runtime that executed the run, `'bun'`, `'deno'`, or `'node'`.\n */\n runtime: string\n /**\n * Major version of the active runtime, e.g. `'1'` under Bun or `'22'` under Node.\n */\n runtimeVersion: string\n platform: string\n ci: boolean\n plugins: Array<TelemetryPlugin>\n duration: number\n filesCreated: number\n status: 'success' | 'failed'\n}\n\n/**\n * Anonymous OTLP usage telemetry for the Kubb run. All methods are static, so call them as\n * `Telemetry.build(...)`, `Telemetry.send(...)`, and `Telemetry.isDisabled()`. No file paths,\n * OpenAPI specs, or secrets are ever included, and sending fails silently to never break a run.\n */\nexport class Telemetry {\n /**\n * Returns `true` when telemetry is disabled via `DO_NOT_TRACK` or `KUBB_DISABLE_TELEMETRY`.\n */\n static get isDisabled(): boolean {\n return (\n process.env['DO_NOT_TRACK'] === '1' ||\n process.env['DO_NOT_TRACK'] === 'true' ||\n process.env['KUBB_DISABLE_TELEMETRY'] === '1' ||\n process.env['KUBB_DISABLE_TELEMETRY'] === 'true'\n )\n }\n\n /**\n * Build an anonymous telemetry payload from a completed generation run.\n */\n static build(options: {\n command: 'generate' | 'mcp' | 'validate' | 'agent'\n kubbVersion: string\n plugins?: Array<TelemetryPlugin>\n hrStart: [number, number]\n filesCreated?: number\n status: 'success' | 'failed'\n }): TelemetryEvent {\n const [seconds, nanoseconds] = process.hrtime(options.hrStart)\n const duration = Math.round(seconds * 1000 + nanoseconds / 1e6)\n\n return {\n command: options.command,\n kubbVersion: options.kubbVersion,\n nodeVersion: process.versions.node.split('.')[0] as string,\n runtime: runtime.name,\n runtimeVersion: runtime.version.split('.')[0] as string,\n platform: os.platform(),\n ci: isCIEnvironment(),\n plugins: options.plugins ?? [],\n duration,\n filesCreated: options.filesCreated ?? 0,\n status: options.status,\n }\n }\n\n /**\n * Convert a {@link TelemetryEvent} into an OTLP-compatible JSON trace payload.\n * See https://opentelemetry.io/docs/languages/sdk-configuration/otlp-exporter/\n */\n static buildOtlpPayload(event: TelemetryEvent): OtlpExportTraceServiceRequest {\n const traceId = randomBytes(16).toString('hex')\n const spanId = randomBytes(8).toString('hex')\n const endTimeNs = BigInt(Date.now()) * 1_000_000n\n const startTimeNs = endTimeNs - BigInt(event.duration) * 1_000_000n\n\n const attributes: Array<OtlpKeyValue> = [\n { key: 'kubb.command', value: { stringValue: event.command } },\n { key: 'kubb.version', value: { stringValue: event.kubbVersion } },\n { key: 'kubb.node_version', value: { stringValue: event.nodeVersion } },\n { key: 'kubb.runtime', value: { stringValue: event.runtime } },\n { key: 'kubb.runtime_version', value: { stringValue: event.runtimeVersion } },\n { key: 'kubb.platform', value: { stringValue: event.platform } },\n { key: 'kubb.ci', value: { boolValue: event.ci } },\n { key: 'kubb.files_created', value: { intValue: event.filesCreated } },\n { key: 'kubb.status', value: { stringValue: event.status } },\n {\n key: 'kubb.plugins',\n value: {\n arrayValue: {\n values: event.plugins.map(\n (p): OtlpKvListValue => ({\n kvlistValue: {\n values: [\n { key: 'name', value: { stringValue: p.name } },\n {\n key: 'options',\n value: {\n stringValue: JSON.stringify({\n ...p.options,\n usedEnumNames: undefined,\n }),\n },\n },\n ],\n },\n }),\n ),\n },\n },\n },\n ]\n\n return {\n resourceSpans: [\n {\n resource: {\n attributes: [\n { key: 'service.name', value: { stringValue: 'kubb-core' } },\n {\n key: 'service.version',\n value: { stringValue: event.kubbVersion },\n },\n { key: 'telemetry.sdk.language', value: { stringValue: 'nodejs' } },\n ],\n },\n scopeSpans: [\n {\n scope: { name: 'kubb-core', version: event.kubbVersion },\n spans: [\n {\n traceId,\n spanId,\n name: event.command,\n kind: 1 satisfies OtlpSpanKind,\n startTimeUnixNano: String(startTimeNs),\n endTimeUnixNano: String(endTimeNs),\n attributes,\n status: {\n code: (event.status === 'success' ? 1 : 2) satisfies OtlpStatusCode,\n },\n },\n ],\n },\n ],\n },\n ],\n }\n }\n\n /**\n * Send an anonymous telemetry event to the Kubb OTLP endpoint. Respects `DO_NOT_TRACK` and\n * `KUBB_DISABLE_TELEMETRY`, and fails silently so telemetry never interrupts a run.\n */\n static async send(event: TelemetryEvent): Promise<void> {\n if (Telemetry.isDisabled) {\n return\n }\n\n try {\n await fetch(`${OTLP_ENDPOINT}/v1/traces`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Kubb-Telemetry-Version': '1',\n 'Kubb-Telemetry-Source': 'kubb-core',\n },\n body: JSON.stringify(Telemetry.buildOtlpPayload(event)),\n signal: AbortSignal.timeout(5_000),\n })\n } catch (_e) {\n // Fail silently, telemetry must never break the run\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAYA,SAAgB,kBAA2B;CACzC,OAAO,CAAC,EACN,QAAQ,IAAI,MACZ,QAAQ,IAAI,kBACZ,QAAQ,IAAI,aACZ,QAAQ,IAAI,0BACZ,QAAQ,IAAI,eACZ,QAAQ,IAAI,YACZ,QAAQ,IAAI,UACZ,QAAQ,IAAI,oBACZ,QAAQ,IAAI,aACZ,QAAQ,IAAI;AAEhB;;;;;;;;;;;;;;;;;AAkBA,SAAgB,YAAqB;CACnC,OAAO,QAAQ,OAAO,UAAU,QAAQ,OAAO,WAAW,KAAK,KAAK,CAAC,gBAAgB;AACvF;;;;;;;;ACnCA,IAAM,UAAN,MAAc;;;;;;;;;;;;;;;CAeZ,IAAI,QAAiB;EACnB,OAAO,OAAO,QAAQ;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L,eAAe,CACb;GACE,UAAU,EACR,YAAY;IACV;KAAE,KAAK;KAAgB,OAAO,EAAE,aAAa,YAAY;IAAE;IAC3D;KACE,KAAK;KACL,OAAO,EAAE,aAAa,MAAM,YAAY;IAC1C;IACA;KAAE,KAAK;KAA0B,OAAO,EAAE,aAAa,SAAS;IAAE;GACpE,EACF;GACA,YAAY,CACV;IACE,OAAO;KAAE,MAAM;KAAa,SAAS,MAAM;IAAY;IACvD,OAAO,CACL;KACE;KACA;KACA,MAAM,MAAM;KACZ,MAAM;KACN,mBAAmB,OAAO,WAAW;KACrC,iBAAiB,OAAO,SAAS;KACjC;KACA,QAAQ,EACN,MAAO,MAAM,WAAW,YAAY,IAAI,EAC1C;IACF,CACF;GACF,CACF;EACF,CACF,EACF;CACF;;;;;CAMA,aAAa,KAAK,OAAsC;EACtD,IAAI,UAAU,YACZ;EAGF,IAAI;GACF,MAAM,MAAM,GAAG,cAAc,aAAa;IACxC,QAAQ;IACR,SAAS;KACP,gBAAgB;KAChB,0BAA0B;KAC1B,yBAAyB;IAC3B;IACA,MAAM,KAAK,UAAU,UAAU,iBAAiB,KAAK,CAAC;IACtD,QAAQ,YAAY,QAAQ,GAAK;GACnC,CAAC;EACH,SAAS,IAAI,CAEb;CACF;AACF"}
|
package/dist/package-Dexb-Hm2.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"package-Dexb-Hm2.js","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"package-DkAWgV_y.cjs","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}
|