@kubb/cli 5.0.0-alpha.8 → 5.0.0-beta.75
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/README.md +4 -2
- package/bin/kubb.js +6 -0
- package/dist/{agent-B116NMCE.cjs → agent-BEgI2HXH.cjs} +5 -5
- package/dist/agent-BEgI2HXH.cjs.map +1 -0
- package/dist/agent-B_pirbeB.cjs +116 -0
- package/dist/agent-B_pirbeB.cjs.map +1 -0
- package/dist/{agent-CFRroclh.js → agent-CTdJEHEs.js} +5 -5
- package/dist/agent-CTdJEHEs.js.map +1 -0
- package/dist/agent-Ev5hU5hH.js +112 -0
- package/dist/agent-Ev5hU5hH.js.map +1 -0
- package/dist/{constants-BTUap0zs.cjs → constants-CnDXa1R6.cjs} +60 -20
- package/dist/constants-CnDXa1R6.cjs.map +1 -0
- package/dist/constants-aL3CP_Wq.js +95 -0
- package/dist/constants-aL3CP_Wq.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-BblrHXQC.js → generate-Cg8yufrw.js} +556 -262
- package/dist/generate-Cg8yufrw.js.map +1 -0
- package/dist/{generate-D58EaZny.cjs → generate-DDCwNQNo.cjs} +3 -3
- package/dist/generate-DDCwNQNo.cjs.map +1 -0
- package/dist/{generate-D_pi7lhe.cjs → generate-K8MJ9aQF.cjs} +563 -269
- package/dist/generate-K8MJ9aQF.cjs.map +1 -0
- package/dist/{generate-B8tpu0Dc.js → generate-YPtfjsg4.js} +3 -3
- package/dist/generate-YPtfjsg4.js.map +1 -0
- package/dist/index.cjs +48 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +48 -21
- package/dist/index.js.map +1 -1
- package/dist/{init-B56F3Qon.cjs → init-Bu95ML_u.cjs} +4 -4
- package/dist/init-Bu95ML_u.cjs.map +1 -0
- package/dist/{init-hmolV6B4.cjs → init-CZ5Xq2Hd.cjs} +45 -58
- package/dist/init-CZ5Xq2Hd.cjs.map +1 -0
- package/dist/{init-C-InrmSY.js → init-eNRlotJK.js} +41 -54
- package/dist/init-eNRlotJK.js.map +1 -0
- package/dist/{init-v0GeyJkz.js → init-ooJeOBGt.js} +4 -4
- package/dist/init-ooJeOBGt.js.map +1 -0
- package/dist/{mcp-0AmU5JUD.js → mcp-C-d5N1wZ.js} +4 -4
- package/dist/{mcp-0AmU5JUD.js.map → mcp-C-d5N1wZ.js.map} +1 -1
- package/dist/{mcp-ChHFPRzD.cjs → mcp-CLcDV4Jm.cjs} +5 -6
- package/dist/mcp-CLcDV4Jm.cjs.map +1 -0
- package/dist/{mcp-D2SHEg_d.js → mcp-D7EIR9fR.js} +4 -5
- package/dist/mcp-D7EIR9fR.js.map +1 -0
- package/dist/{mcp-B0Jz5z2r.cjs → mcp-Dpu8vzzj.cjs} +4 -4
- package/dist/{mcp-B0Jz5z2r.cjs.map → mcp-Dpu8vzzj.cjs.map} +1 -1
- package/dist/{package-CbrJTkI2.cjs → package-D5arPDnh.cjs} +2 -2
- package/dist/package-D5arPDnh.cjs.map +1 -0
- package/dist/package-DqZsMLZ9.js +6 -0
- package/dist/package-DqZsMLZ9.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-Cn9X1I5B.cjs → telemetry-DN95_2pF.cjs} +50 -8
- package/dist/telemetry-DN95_2pF.cjs.map +1 -0
- package/dist/{telemetry-DxiR7clS.js → telemetry-LgT_sdPe.js} +48 -6
- package/dist/telemetry-LgT_sdPe.js.map +1 -0
- package/dist/{validate-D5CuvkLl.js → validate-CIR3_lZI.js} +4 -4
- package/dist/validate-CIR3_lZI.js.map +1 -0
- package/dist/{validate-D8Zb-dns.cjs → validate-DcqUb4DM.cjs} +4 -4
- package/dist/validate-DcqUb4DM.cjs.map +1 -0
- package/dist/{validate-l8vLmwKA.js → validate-kLJoT_hi.js} +5 -13
- package/dist/validate-kLJoT_hi.js.map +1 -0
- package/dist/{validate-Bbrn3Q-A.cjs → validate-yKKzqEZ5.cjs} +6 -14
- package/dist/validate-yKKzqEZ5.cjs.map +1 -0
- package/package.json +47 -46
- package/src/commands/agent/start.ts +20 -4
- package/src/commands/generate.ts +35 -6
- package/src/commands/init.ts +6 -1
- package/src/commands/validate.ts +6 -1
- package/src/constants.ts +50 -22
- package/src/index.ts +10 -12
- package/src/loggers/clackLogger.ts +57 -50
- package/src/loggers/fileSystemLogger.ts +17 -18
- package/src/loggers/githubActionsLogger.ts +25 -26
- package/src/loggers/plainLogger.ts +24 -25
- package/src/runners/agent.ts +81 -34
- package/src/runners/generate.ts +90 -100
- package/src/runners/init.ts +24 -51
- package/src/runners/mcp.ts +17 -4
- package/src/runners/validate.ts +19 -15
- package/src/types.ts +11 -0
- package/src/utils/executeHooks.ts +15 -15
- package/src/utils/flags.ts +9 -0
- package/src/utils/getConfig.ts +10 -0
- package/src/utils/getCosmiConfig.ts +21 -12
- package/src/utils/getSummary.ts +1 -1
- package/src/utils/runHook.ts +29 -13
- package/src/utils/telemetry.ts +16 -3
- package/bin/kubb.cjs +0 -18
- package/dist/agent-B116NMCE.cjs.map +0 -1
- package/dist/agent-C6o_6GSJ.cjs +0 -92
- package/dist/agent-C6o_6GSJ.cjs.map +0 -1
- package/dist/agent-CFRroclh.js.map +0 -1
- package/dist/agent-L50VNhXv.js +0 -88
- package/dist/agent-L50VNhXv.js.map +0 -1
- package/dist/constants-BTUap0zs.cjs.map +0 -1
- package/dist/constants-CM3dJzjK.js +0 -67
- 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-B8tpu0Dc.js.map +0 -1
- package/dist/generate-BblrHXQC.js.map +0 -1
- package/dist/generate-D58EaZny.cjs.map +0 -1
- package/dist/generate-D_pi7lhe.cjs.map +0 -1
- package/dist/init-B56F3Qon.cjs.map +0 -1
- package/dist/init-C-InrmSY.js.map +0 -1
- package/dist/init-hmolV6B4.cjs.map +0 -1
- package/dist/init-v0GeyJkz.js.map +0 -1
- package/dist/jiti-Cd3S0xwr.cjs +0 -16
- package/dist/jiti-Cd3S0xwr.cjs.map +0 -1
- package/dist/jiti-e08mD2Ph.js +0 -11
- package/dist/jiti-e08mD2Ph.js.map +0 -1
- package/dist/mcp-ChHFPRzD.cjs.map +0 -1
- package/dist/mcp-D2SHEg_d.js.map +0 -1
- package/dist/package-BAVK5o-U.js +0 -6
- package/dist/package-BAVK5o-U.js.map +0 -1
- package/dist/package-CbrJTkI2.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/dist/validate-Bbrn3Q-A.cjs.map +0 -1
- package/dist/validate-D5CuvkLl.js.map +0 -1
- package/dist/validate-D8Zb-dns.cjs.map +0 -1
- package/dist/validate-l8vLmwKA.js.map +0 -1
- package/src/utils/getIntro.ts +0 -1
- package/src/utils/jiti.ts +0 -9
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./chunk--u3MIqq1.js";
|
|
2
|
-
import {
|
|
2
|
+
import { r as OTLP_ENDPOINT } from "./constants-aL3CP_Wq.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-LgT_sdPe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telemetry-LgT_sdPe.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 {\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-cli' } },\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-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: {\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.\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
|
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-DqZsMLZ9.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-kLJoT_hi.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-CIR3_lZI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-CIR3_lZI.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: {\n type: 'string',\n description: 'Path to Swagger/OpenAPI file',\n short: 'i',\n required: true,\n },\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;EACL,MAAM;EACN,aAAa;EACb,OAAO;EACP,UAAU;EACX,EACF;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-D5arPDnh.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-yKKzqEZ5.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-DcqUb4DM.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-DcqUb4DM.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: {\n type: 'string',\n description: 'Path to Swagger/OpenAPI file',\n short: 'i',\n required: true,\n },\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;EACL,MAAM;EACN,aAAa;EACb,OAAO;EACP,UAAU;EACX,EACF;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"}
|
|
@@ -1,21 +1,13 @@
|
|
|
1
1
|
import "./chunk--u3MIqq1.js";
|
|
2
|
-
import { t as getErrorMessage } from "./errors-
|
|
3
|
-
import { r as sendTelemetry, t as buildTelemetryEvent } from "./telemetry-
|
|
4
|
-
import { t as jiti } from "./jiti-e08mD2Ph.js";
|
|
2
|
+
import { t as getErrorMessage } from "./errors-CjPmyZHy.js";
|
|
3
|
+
import { r as sendTelemetry, t as buildTelemetryEvent } from "./telemetry-LgT_sdPe.js";
|
|
5
4
|
import process from "node:process";
|
|
5
|
+
import { parseDocument, validateDocument } from "@kubb/adapter-oas";
|
|
6
6
|
//#region src/runners/validate.ts
|
|
7
7
|
async function runValidate({ input, version }) {
|
|
8
|
-
let mod;
|
|
9
|
-
try {
|
|
10
|
-
mod = await jiti.import("@kubb/oas", { default: true });
|
|
11
|
-
} catch (_e) {
|
|
12
|
-
console.error(`Import of '@kubb/oas' is required to do validation`);
|
|
13
|
-
process.exit(1);
|
|
14
|
-
}
|
|
15
|
-
const { parse } = mod;
|
|
16
8
|
const hrStart = process.hrtime();
|
|
17
9
|
try {
|
|
18
|
-
await (await
|
|
10
|
+
await validateDocument(await parseDocument(input), { throwOnError: true });
|
|
19
11
|
await sendTelemetry(buildTelemetryEvent({
|
|
20
12
|
command: "validate",
|
|
21
13
|
kubbVersion: version,
|
|
@@ -38,4 +30,4 @@ async function runValidate({ input, version }) {
|
|
|
38
30
|
//#endregion
|
|
39
31
|
export { runValidate };
|
|
40
32
|
|
|
41
|
-
//# sourceMappingURL=validate-
|
|
33
|
+
//# sourceMappingURL=validate-kLJoT_hi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-kLJoT_hi.js","names":[],"sources":["../src/runners/validate.ts"],"sourcesContent":["import process from 'node:process'\nimport { getErrorMessage } from '@internals/utils'\nimport { parseDocument, validateDocument } from '@kubb/adapter-oas'\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 const hrStart = process.hrtime()\n try {\n const document = await parseDocument(input)\n await validateDocument(document, { throwOnError: true })\n\n await sendTelemetry(\n buildTelemetryEvent({\n command: 'validate',\n kubbVersion: version,\n hrStart,\n status: 'success',\n }),\n )\n console.log('✅ Validation success')\n } catch (error) {\n await sendTelemetry(\n buildTelemetryEvent({\n command: 'validate',\n kubbVersion: version,\n hrStart,\n status: 'failed',\n }),\n )\n console.error('❌ Validation failed')\n console.error(getErrorMessage(error))\n process.exit(1)\n }\n}\n"],"mappings":";;;;;;AAUA,eAAsB,YAAY,EAAE,OAAO,WAA2C;CACpF,MAAM,UAAU,QAAQ,QAAQ;AAChC,KAAI;AAEF,QAAM,iBAAiB,MADA,cAAc,MAAM,EACV,EAAE,cAAc,MAAM,CAAC;AAExD,QAAM,cACJ,oBAAoB;GAClB,SAAS;GACT,aAAa;GACb;GACA,QAAQ;GACT,CAAC,CACH;AACD,UAAQ,IAAI,uBAAuB;UAC5B,OAAO;AACd,QAAM,cACJ,oBAAoB;GAClB,SAAS;GACT,aAAa;GACb;GACA,QAAQ;GACT,CAAC,CACH;AACD,UAAQ,MAAM,sBAAsB;AACpC,UAAQ,MAAM,gBAAgB,MAAM,CAAC;AACrC,UAAQ,KAAK,EAAE"}
|
|
@@ -1,22 +1,14 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-ByKO4r7w.cjs");
|
|
2
|
-
const require_errors = require("./errors-
|
|
3
|
-
const require_telemetry = require("./telemetry-
|
|
4
|
-
const require_jiti = require("./jiti-Cd3S0xwr.cjs");
|
|
2
|
+
const require_errors = require("./errors-CLCjoSg0.cjs");
|
|
3
|
+
const require_telemetry = require("./telemetry-DN95_2pF.cjs");
|
|
5
4
|
let node_process = require("node:process");
|
|
6
|
-
node_process = require_chunk.__toESM(node_process);
|
|
5
|
+
node_process = require_chunk.__toESM(node_process, 1);
|
|
6
|
+
let _kubb_adapter_oas = require("@kubb/adapter-oas");
|
|
7
7
|
//#region src/runners/validate.ts
|
|
8
8
|
async function runValidate({ input, version }) {
|
|
9
|
-
let mod;
|
|
10
|
-
try {
|
|
11
|
-
mod = await require_jiti.jiti.import("@kubb/oas", { default: true });
|
|
12
|
-
} catch (_e) {
|
|
13
|
-
console.error(`Import of '@kubb/oas' is required to do validation`);
|
|
14
|
-
node_process.default.exit(1);
|
|
15
|
-
}
|
|
16
|
-
const { parse } = mod;
|
|
17
9
|
const hrStart = node_process.default.hrtime();
|
|
18
10
|
try {
|
|
19
|
-
await (await
|
|
11
|
+
await (0, _kubb_adapter_oas.validateDocument)(await (0, _kubb_adapter_oas.parseDocument)(input), { throwOnError: true });
|
|
20
12
|
await require_telemetry.sendTelemetry(require_telemetry.buildTelemetryEvent({
|
|
21
13
|
command: "validate",
|
|
22
14
|
kubbVersion: version,
|
|
@@ -39,4 +31,4 @@ async function runValidate({ input, version }) {
|
|
|
39
31
|
//#endregion
|
|
40
32
|
exports.runValidate = runValidate;
|
|
41
33
|
|
|
42
|
-
//# sourceMappingURL=validate-
|
|
34
|
+
//# sourceMappingURL=validate-yKKzqEZ5.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-yKKzqEZ5.cjs","names":["process","sendTelemetry","buildTelemetryEvent","getErrorMessage"],"sources":["../src/runners/validate.ts"],"sourcesContent":["import process from 'node:process'\nimport { getErrorMessage } from '@internals/utils'\nimport { parseDocument, validateDocument } from '@kubb/adapter-oas'\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 const hrStart = process.hrtime()\n try {\n const document = await parseDocument(input)\n await validateDocument(document, { throwOnError: true })\n\n await sendTelemetry(\n buildTelemetryEvent({\n command: 'validate',\n kubbVersion: version,\n hrStart,\n status: 'success',\n }),\n )\n console.log('✅ Validation success')\n } catch (error) {\n await sendTelemetry(\n buildTelemetryEvent({\n command: 'validate',\n kubbVersion: version,\n hrStart,\n status: 'failed',\n }),\n )\n console.error('❌ Validation failed')\n console.error(getErrorMessage(error))\n process.exit(1)\n }\n}\n"],"mappings":";;;;;;;AAUA,eAAsB,YAAY,EAAE,OAAO,WAA2C;CACpF,MAAM,UAAUA,aAAAA,QAAQ,QAAQ;AAChC,KAAI;AAEF,SAAA,GAAA,kBAAA,kBAAuB,OAAA,GAAA,kBAAA,eADc,MAAM,EACV,EAAE,cAAc,MAAM,CAAC;AAExD,QAAMC,kBAAAA,cACJC,kBAAAA,oBAAoB;GAClB,SAAS;GACT,aAAa;GACb;GACA,QAAQ;GACT,CAAC,CACH;AACD,UAAQ,IAAI,uBAAuB;UAC5B,OAAO;AACd,QAAMD,kBAAAA,cACJC,kBAAAA,oBAAoB;GAClB,SAAS;GACT,aAAa;GACb;GACA,QAAQ;GACT,CAAC,CACH;AACD,UAAQ,MAAM,sBAAsB;AACpC,UAAQ,MAAMC,eAAAA,gBAAgB,MAAM,CAAC;AACrC,eAAA,QAAQ,KAAK,EAAE"}
|
package/package.json
CHANGED
|
@@ -1,41 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/cli",
|
|
3
|
-
"version": "5.0.0-
|
|
3
|
+
"version": "5.0.0-beta.75",
|
|
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",
|
|
7
|
+
"code-generator",
|
|
8
|
+
"codegen",
|
|
7
9
|
"command-line",
|
|
8
10
|
"command-line-tool",
|
|
9
|
-
"
|
|
10
|
-
"typescript",
|
|
11
|
-
"openapi",
|
|
12
|
-
"swagger",
|
|
11
|
+
"kubb",
|
|
13
12
|
"oas",
|
|
14
|
-
"
|
|
15
|
-
"codegen",
|
|
16
|
-
"sdk-generator",
|
|
13
|
+
"openapi",
|
|
17
14
|
"plugins",
|
|
18
|
-
"
|
|
15
|
+
"sdk-generator",
|
|
16
|
+
"swagger",
|
|
17
|
+
"terminal",
|
|
18
|
+
"typescript"
|
|
19
19
|
],
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"author": "stijnvanhulle",
|
|
20
22
|
"repository": {
|
|
21
23
|
"type": "git",
|
|
22
24
|
"url": "git+https://github.com/kubb-labs/kubb.git",
|
|
23
25
|
"directory": "packages/cli"
|
|
24
26
|
},
|
|
25
|
-
"license": "MIT",
|
|
26
|
-
"author": "stijnvanhulle",
|
|
27
|
-
"sideEffects": false,
|
|
28
|
-
"type": "module",
|
|
29
|
-
"exports": {
|
|
30
|
-
".": {
|
|
31
|
-
"import": "./dist/index.js",
|
|
32
|
-
"require": "./dist/index.cjs"
|
|
33
|
-
},
|
|
34
|
-
"./package.json": "./package.json"
|
|
35
|
-
},
|
|
36
|
-
"types": "./dist/index.d.ts",
|
|
37
27
|
"bin": {
|
|
38
|
-
"kubb": "bin/kubb.
|
|
28
|
+
"kubb": "bin/kubb.js"
|
|
39
29
|
},
|
|
40
30
|
"files": [
|
|
41
31
|
"src",
|
|
@@ -45,6 +35,38 @@
|
|
|
45
35
|
"!/**/__tests__/**",
|
|
46
36
|
"!/**/__snapshots__/**"
|
|
47
37
|
],
|
|
38
|
+
"type": "module",
|
|
39
|
+
"sideEffects": false,
|
|
40
|
+
"main": "./dist/index.cjs",
|
|
41
|
+
"module": "./dist/index.js",
|
|
42
|
+
"types": "./dist/index.d.ts",
|
|
43
|
+
"exports": {
|
|
44
|
+
".": {
|
|
45
|
+
"import": "./dist/index.js",
|
|
46
|
+
"require": "./dist/index.cjs"
|
|
47
|
+
},
|
|
48
|
+
"./package.json": "./package.json"
|
|
49
|
+
},
|
|
50
|
+
"publishConfig": {
|
|
51
|
+
"access": "public",
|
|
52
|
+
"registry": "https://registry.npmjs.org/"
|
|
53
|
+
},
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"@clack/prompts": "^1.3.0",
|
|
56
|
+
"chokidar": "^5.0.0",
|
|
57
|
+
"cosmiconfig": "^9.0.1",
|
|
58
|
+
"tinyexec": "^1.1.2",
|
|
59
|
+
"unrun": "^0.2.37",
|
|
60
|
+
"@kubb/core": "5.0.0-beta.75",
|
|
61
|
+
"@kubb/adapter-oas": "5.0.0-beta.75"
|
|
62
|
+
},
|
|
63
|
+
"devDependencies": {
|
|
64
|
+
"@internals/utils": "0.0.0"
|
|
65
|
+
},
|
|
66
|
+
"optionalDependencies": {
|
|
67
|
+
"@kubb/agent": "5.0.0-beta.75",
|
|
68
|
+
"@kubb/mcp": "5.0.0-beta.75"
|
|
69
|
+
},
|
|
48
70
|
"size-limit": [
|
|
49
71
|
{
|
|
50
72
|
"path": "./dist/*.js",
|
|
@@ -52,36 +74,15 @@
|
|
|
52
74
|
"gzip": true
|
|
53
75
|
}
|
|
54
76
|
],
|
|
55
|
-
"
|
|
56
|
-
"@clack/prompts": "^1.1.0",
|
|
57
|
-
"chokidar": "^5.0.0",
|
|
58
|
-
"cosmiconfig": "^9.0.1",
|
|
59
|
-
"jiti": "2.5.1",
|
|
60
|
-
"tinyexec": "^1.0.4",
|
|
61
|
-
"@kubb/core": "5.0.0-alpha.8"
|
|
62
|
-
},
|
|
63
|
-
"devDependencies": {
|
|
64
|
-
"source-map-support": "^0.5.21",
|
|
65
|
-
"@internals/utils": "0.0.0",
|
|
66
|
-
"@kubb/agent": "5.0.0-alpha.8",
|
|
67
|
-
"@kubb/mcp": "5.0.0-alpha.8",
|
|
68
|
-
"@kubb/oas": "5.0.0-alpha.8"
|
|
69
|
-
},
|
|
77
|
+
"preferGlobal": true,
|
|
70
78
|
"engines": {
|
|
71
79
|
"node": ">=22"
|
|
72
80
|
},
|
|
73
|
-
"preferGlobal": true,
|
|
74
|
-
"publishConfig": {
|
|
75
|
-
"access": "public",
|
|
76
|
-
"registry": "https://registry.npmjs.org/"
|
|
77
|
-
},
|
|
78
|
-
"main": "./dist/index.cjs",
|
|
79
|
-
"module": "./dist/index.js",
|
|
80
81
|
"scripts": {
|
|
81
82
|
"build": "tsdown && size-limit",
|
|
82
83
|
"clean": "npx rimraf ./dist",
|
|
83
|
-
"lint": "
|
|
84
|
-
"lint:fix": "
|
|
84
|
+
"lint": "oxlint .",
|
|
85
|
+
"lint:fix": "oxlint --fix .",
|
|
85
86
|
"release": "pnpm publish --no-git-check",
|
|
86
87
|
"release:canary": "bash ../../.github/canary.sh && node ../../scripts/build.js canary && pnpm publish --no-git-check",
|
|
87
88
|
"start": "tsdown --watch",
|
|
@@ -6,15 +6,31 @@ export const command = defineCommand({
|
|
|
6
6
|
name: 'start',
|
|
7
7
|
description: 'Start the Agent server',
|
|
8
8
|
options: {
|
|
9
|
-
config: {
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
config: {
|
|
10
|
+
type: 'string',
|
|
11
|
+
description: 'Path to the Kubb config',
|
|
12
|
+
short: 'c',
|
|
13
|
+
},
|
|
14
|
+
port: {
|
|
15
|
+
type: 'string',
|
|
16
|
+
description: `Port for the server (default: ${agentDefaults.port})`,
|
|
17
|
+
short: 'p',
|
|
18
|
+
},
|
|
19
|
+
host: {
|
|
20
|
+
type: 'string',
|
|
21
|
+
description: 'Host for the server',
|
|
22
|
+
default: agentDefaults.host,
|
|
23
|
+
},
|
|
12
24
|
'allow-write': {
|
|
13
25
|
type: 'boolean',
|
|
14
26
|
description: 'Allow writing generated files to the filesystem. When not set, no files are written and the config patch is not persisted.',
|
|
15
27
|
default: false,
|
|
16
28
|
},
|
|
17
|
-
'allow-all': {
|
|
29
|
+
'allow-all': {
|
|
30
|
+
type: 'boolean',
|
|
31
|
+
description: 'Grant all permissions (implies --allow-write).',
|
|
32
|
+
default: false,
|
|
33
|
+
},
|
|
18
34
|
},
|
|
19
35
|
async run({ values }) {
|
|
20
36
|
const { runAgentStart } = await import('../../runners/agent.ts')
|
package/src/commands/generate.ts
CHANGED
|
@@ -5,7 +5,11 @@ export const command = defineCommand({
|
|
|
5
5
|
description: "[input] Generate files based on a 'kubb.config.ts' file",
|
|
6
6
|
arguments: ['[input]'],
|
|
7
7
|
options: {
|
|
8
|
-
config: {
|
|
8
|
+
config: {
|
|
9
|
+
type: 'string',
|
|
10
|
+
description: 'Path to the Kubb config',
|
|
11
|
+
short: 'c',
|
|
12
|
+
},
|
|
9
13
|
logLevel: {
|
|
10
14
|
type: 'string',
|
|
11
15
|
description: 'Info, silent, verbose or debug',
|
|
@@ -14,15 +18,40 @@ export const command = defineCommand({
|
|
|
14
18
|
hint: 'silent|info|verbose|debug',
|
|
15
19
|
enum: ['silent', 'info', 'verbose', 'debug'],
|
|
16
20
|
},
|
|
17
|
-
watch: {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
watch: {
|
|
22
|
+
type: 'boolean',
|
|
23
|
+
description: 'Watch mode based on the input file',
|
|
24
|
+
short: 'w',
|
|
25
|
+
default: false,
|
|
26
|
+
},
|
|
27
|
+
debug: {
|
|
28
|
+
type: 'boolean',
|
|
29
|
+
description: 'Override logLevel to debug',
|
|
30
|
+
short: 'd',
|
|
31
|
+
default: false,
|
|
32
|
+
},
|
|
33
|
+
verbose: {
|
|
34
|
+
type: 'boolean',
|
|
35
|
+
description: 'Override logLevel to verbose',
|
|
36
|
+
short: 'v',
|
|
37
|
+
default: false,
|
|
38
|
+
},
|
|
39
|
+
silent: {
|
|
40
|
+
type: 'boolean',
|
|
41
|
+
description: 'Override logLevel to silent',
|
|
42
|
+
short: 's',
|
|
43
|
+
default: false,
|
|
44
|
+
},
|
|
21
45
|
},
|
|
22
46
|
async run({ values, positionals }) {
|
|
23
47
|
const logLevel = values.debug ? 'debug' : values.verbose ? 'verbose' : values.silent ? 'silent' : values.logLevel
|
|
24
48
|
const { runGenerateCommand } = await import('../runners/generate.ts')
|
|
25
49
|
|
|
26
|
-
await runGenerateCommand({
|
|
50
|
+
await runGenerateCommand({
|
|
51
|
+
input: positionals[0],
|
|
52
|
+
configPath: values.config,
|
|
53
|
+
logLevel,
|
|
54
|
+
watch: values.watch,
|
|
55
|
+
})
|
|
27
56
|
},
|
|
28
57
|
})
|
package/src/commands/init.ts
CHANGED
|
@@ -5,7 +5,12 @@ export const command = defineCommand({
|
|
|
5
5
|
name: 'init',
|
|
6
6
|
description: 'Initialize a new Kubb project with interactive setup',
|
|
7
7
|
options: {
|
|
8
|
-
yes: {
|
|
8
|
+
yes: {
|
|
9
|
+
type: 'boolean',
|
|
10
|
+
description: 'Skip prompts and use default options',
|
|
11
|
+
short: 'y',
|
|
12
|
+
default: false,
|
|
13
|
+
},
|
|
9
14
|
},
|
|
10
15
|
async run({ values }) {
|
|
11
16
|
const { runInit } = await import('../runners/init.ts')
|
package/src/commands/validate.ts
CHANGED
|
@@ -5,7 +5,12 @@ export const command = defineCommand({
|
|
|
5
5
|
name: 'validate',
|
|
6
6
|
description: 'Validate a Swagger/OpenAPI file',
|
|
7
7
|
options: {
|
|
8
|
-
input: {
|
|
8
|
+
input: {
|
|
9
|
+
type: 'string',
|
|
10
|
+
description: 'Path to Swagger/OpenAPI file',
|
|
11
|
+
short: 'i',
|
|
12
|
+
required: true,
|
|
13
|
+
},
|
|
9
14
|
},
|
|
10
15
|
async run({ values }) {
|
|
11
16
|
const { runValidate } = await import('../runners/validate.ts')
|
package/src/constants.ts
CHANGED
|
@@ -1,37 +1,64 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Default filename for the Kubb configuration file.
|
|
3
|
+
*
|
|
4
|
+
* Used by the `init` command when scaffolding new projects and by the `agent` default config.
|
|
5
|
+
*/
|
|
6
|
+
export const KUBB_CONFIG_FILENAME = 'kubb.config.ts' as const
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* NPM registry endpoint used to check for @kubb/cli updates.
|
|
10
|
+
*/
|
|
2
11
|
export const KUBB_NPM_PACKAGE_URL = 'https://registry.npmjs.org/@kubb/cli/latest' as const
|
|
3
12
|
|
|
4
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* OpenTelemetry ingestion endpoint for anonymous usage telemetry.
|
|
15
|
+
*/
|
|
5
16
|
export const OTLP_ENDPOINT = 'https://otlp.kubb.dev' as const
|
|
6
17
|
|
|
7
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* Horizontal rule rendered above/below the plain-logger generation summary.
|
|
20
|
+
*/
|
|
8
21
|
export const SUMMARY_SEPARATOR = '─'.repeat(27)
|
|
9
22
|
|
|
10
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* Maximum number of █ characters in a plugin timing bar.
|
|
25
|
+
*/
|
|
11
26
|
export const SUMMARY_MAX_BAR_LENGTH = 10 as const
|
|
12
27
|
|
|
13
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* Divides elapsed milliseconds into bar-length units (1 block per 100 ms).
|
|
30
|
+
*/
|
|
14
31
|
export const SUMMARY_TIME_SCALE_DIVISOR = 100 as const
|
|
15
32
|
|
|
16
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* Glob pattern for paths the file watcher ignores.
|
|
35
|
+
*/
|
|
17
36
|
export const WATCHER_IGNORED_PATHS = '**/{.git,node_modules}/**' as const
|
|
18
37
|
|
|
19
|
-
/**
|
|
38
|
+
/**
|
|
39
|
+
* Flags that short-circuit execution (help/version) — no telemetry notice is shown.
|
|
40
|
+
*/
|
|
41
|
+
export const QUIET_FLAGS = new Set(['--help', '-h', '--version', '-v'] as const)
|
|
42
|
+
|
|
20
43
|
export const agentDefaults = {
|
|
21
44
|
port: '3000',
|
|
22
45
|
host: 'localhost',
|
|
23
|
-
configFile:
|
|
46
|
+
configFile: KUBB_CONFIG_FILENAME,
|
|
24
47
|
retryTimeout: '30000',
|
|
25
48
|
studioUrl: 'https://studio.kubb.dev',
|
|
26
|
-
/**
|
|
49
|
+
/**
|
|
50
|
+
* Relative path from the @kubb/agent package root to the server entry.
|
|
51
|
+
*/
|
|
27
52
|
serverEntryPath: '.output/server/index.mjs',
|
|
28
53
|
} as const
|
|
29
54
|
|
|
30
|
-
/**
|
|
55
|
+
/**
|
|
56
|
+
* Default values used during interactive `init` scaffolding.
|
|
57
|
+
*/
|
|
31
58
|
export const initDefaults = {
|
|
32
59
|
inputPath: './openapi.yaml',
|
|
33
60
|
outputPath: './src/gen',
|
|
34
|
-
plugins: ['plugin-
|
|
61
|
+
plugins: ['plugin-ts'],
|
|
35
62
|
} as const
|
|
36
63
|
|
|
37
64
|
/**
|
|
@@ -40,7 +67,6 @@ export const initDefaults = {
|
|
|
40
67
|
* `as const` keeps the object deeply immutable.
|
|
41
68
|
*/
|
|
42
69
|
export const pluginDefaultConfigs = {
|
|
43
|
-
'plugin-oas': 'pluginOas()',
|
|
44
70
|
'plugin-ts': `pluginTs({
|
|
45
71
|
output: { path: 'models' },
|
|
46
72
|
})`,
|
|
@@ -50,18 +76,9 @@ export const pluginDefaultConfigs = {
|
|
|
50
76
|
'plugin-react-query': `pluginReactQuery({
|
|
51
77
|
output: { path: 'hooks' },
|
|
52
78
|
})`,
|
|
53
|
-
'plugin-solid-query': `pluginSolidQuery({
|
|
54
|
-
output: { path: 'hooks' },
|
|
55
|
-
})`,
|
|
56
|
-
'plugin-svelte-query': `pluginSvelteQuery({
|
|
57
|
-
output: { path: 'hooks' },
|
|
58
|
-
})`,
|
|
59
79
|
'plugin-vue-query': `pluginVueQuery({
|
|
60
80
|
output: { path: 'hooks' },
|
|
61
81
|
})`,
|
|
62
|
-
'plugin-swr': `pluginSwr({
|
|
63
|
-
output: { path: 'hooks' },
|
|
64
|
-
})`,
|
|
65
82
|
'plugin-zod': `pluginZod({
|
|
66
83
|
output: { path: 'zod' },
|
|
67
84
|
})`,
|
|
@@ -71,6 +88,17 @@ export const pluginDefaultConfigs = {
|
|
|
71
88
|
'plugin-msw': `pluginMsw({
|
|
72
89
|
output: { path: 'msw' },
|
|
73
90
|
})`,
|
|
91
|
+
'plugin-cypress': `pluginCypress({
|
|
92
|
+
output: { path: 'cypress' },
|
|
93
|
+
})`,
|
|
94
|
+
'plugin-mcp': `pluginMcp({
|
|
95
|
+
output: { path: 'mcp' },
|
|
96
|
+
})`,
|
|
97
|
+
'plugin-redoc': `pluginRedoc({
|
|
98
|
+
output: { path: 'redoc' },
|
|
99
|
+
})`,
|
|
74
100
|
} as const satisfies Record<string, string>
|
|
75
101
|
|
|
76
|
-
/**
|
|
102
|
+
/**
|
|
103
|
+
* Color palette used by randomCliColor() for deterministic plugin name coloring.
|
|
104
|
+
*/
|