@kubb/cli 5.0.0-beta.9 → 5.0.0-beta.91
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/LICENSE +17 -10
- package/README.md +48 -79
- package/bin/kubb.js +9 -3
- package/dist/Telemetry-7z2tIqPm.js +282 -0
- package/dist/Telemetry-7z2tIqPm.js.map +1 -0
- package/dist/{telemetry-B2iWkY5e.cjs → Telemetry-xcWb-UWT.cjs} +167 -116
- package/dist/Telemetry-xcWb-UWT.cjs.map +1 -0
- package/dist/{errors-CINO1EIv.js → errors-CMvLO2NE.js} +3 -15
- package/dist/{errors-CINO1EIv.js.map → errors-CMvLO2NE.js.map} +1 -1
- package/dist/{errors-CLCjoSg0.cjs → errors-DNxBUo3k.cjs} +2 -20
- package/dist/{errors-CLCjoSg0.cjs.map → errors-DNxBUo3k.cjs.map} +1 -1
- package/dist/generate-C9fJvlhv.js +87 -0
- package/dist/generate-C9fJvlhv.js.map +1 -0
- package/dist/generate-CIVRaeeA.cjs +87 -0
- package/dist/generate-CIVRaeeA.cjs.map +1 -0
- package/dist/index.cjs +33 -261
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +34 -262
- package/dist/index.js.map +1 -1
- package/dist/{init-bKtEOvhK.cjs → init-BBmle7Oc.cjs} +12 -13
- package/dist/init-BBmle7Oc.cjs.map +1 -0
- package/dist/{init-DOSXtcyb.js → init-DXjubhO6.js} +13 -13
- package/dist/init-DXjubhO6.js.map +1 -0
- package/dist/mcp-DLKKD_8s.js +21 -0
- package/dist/mcp-DLKKD_8s.js.map +1 -0
- package/dist/mcp-Dzgpeor_.cjs +20 -0
- package/dist/mcp-Dzgpeor_.cjs.map +1 -0
- package/dist/{package-DHGhrRW-.cjs → package-Bsc6NeTU.cjs} +2 -2
- package/dist/package-Bsc6NeTU.cjs.map +1 -0
- package/dist/package-CaBsNdoM.js +6 -0
- package/dist/package-CaBsNdoM.js.map +1 -0
- package/dist/{chunk-BvFE5Tac.js → rolldown-runtime-C0LytTxp.js} +0 -1
- package/dist/run-BBS4Sc38.js +1256 -0
- package/dist/run-BBS4Sc38.js.map +1 -0
- package/dist/{run-YsoCk5we.cjs → run-BNOCBw2y.cjs} +152 -98
- package/dist/run-BNOCBw2y.cjs.map +1 -0
- package/dist/{run-CQbj3ley.cjs → run-BdtVrLKu.cjs} +9 -15
- package/dist/run-BdtVrLKu.cjs.map +1 -0
- package/dist/run-Bgn3IPJt.cjs +1259 -0
- package/dist/run-Bgn3IPJt.cjs.map +1 -0
- package/dist/{run-CF97BWVa.js → run-CINOocLR.js} +138 -84
- package/dist/run-CINOocLR.js.map +1 -0
- package/dist/{run-CCZ24VKk.js → run-CaOjZRiQ.js} +7 -13
- package/dist/run-CaOjZRiQ.js.map +1 -0
- package/dist/run-D2vd34xp.cjs +33 -0
- package/dist/run-D2vd34xp.cjs.map +1 -0
- package/dist/run-lgrTO14E.js +32 -0
- package/dist/run-lgrTO14E.js.map +1 -0
- package/dist/tools-B23ltmWP.js +152 -0
- package/dist/tools-B23ltmWP.js.map +1 -0
- package/dist/tools-CeIABV0T.cjs +175 -0
- package/dist/tools-CeIABV0T.cjs.map +1 -0
- package/dist/{validate-Bj8vbvPt.cjs → validate-DaxZu9c3.cjs} +9 -10
- package/dist/validate-DaxZu9c3.cjs.map +1 -0
- package/dist/{validate-bHUrnYBv.js → validate-ugxFStuH.js} +10 -10
- package/dist/validate-ugxFStuH.js.map +1 -0
- package/package.json +14 -28
- package/dist/agent-C5F4itrc.js +0 -68
- package/dist/agent-C5F4itrc.js.map +0 -1
- package/dist/agent-d-lmeOr1.cjs +0 -70
- package/dist/agent-d-lmeOr1.cjs.map +0 -1
- package/dist/constants-B2JTeRBb.js +0 -42
- package/dist/constants-B2JTeRBb.js.map +0 -1
- package/dist/constants-BINTA5VZ.cjs +0 -77
- package/dist/constants-BINTA5VZ.cjs.map +0 -1
- package/dist/constants-BYGmiFs0.cjs +0 -139
- package/dist/constants-BYGmiFs0.cjs.map +0 -1
- package/dist/constants-DSJ-Xrbv.js +0 -116
- package/dist/constants-DSJ-Xrbv.js.map +0 -1
- package/dist/define-Bdn8j5VM.cjs +0 -54
- package/dist/define-Bdn8j5VM.cjs.map +0 -1
- package/dist/define-m_fp-Aqm.js +0 -43
- package/dist/define-m_fp-Aqm.js.map +0 -1
- package/dist/generate-BhfRufgh.js +0 -72
- package/dist/generate-BhfRufgh.js.map +0 -1
- package/dist/generate-BvuSxNYj.cjs +0 -71
- package/dist/generate-BvuSxNYj.cjs.map +0 -1
- package/dist/init-DOSXtcyb.js.map +0 -1
- package/dist/init-bKtEOvhK.cjs.map +0 -1
- package/dist/mcp-CKkbG0kp.cjs +0 -39
- package/dist/mcp-CKkbG0kp.cjs.map +0 -1
- package/dist/mcp-DzOfqX_j.js +0 -39
- package/dist/mcp-DzOfqX_j.js.map +0 -1
- package/dist/package-BgAYWN7y.js +0 -6
- package/dist/package-BgAYWN7y.js.map +0 -1
- package/dist/package-DHGhrRW-.cjs.map +0 -1
- package/dist/run-BObDb2qe.cjs +0 -1741
- package/dist/run-BObDb2qe.cjs.map +0 -1
- package/dist/run-BzpYYOQs.js +0 -121
- package/dist/run-BzpYYOQs.js.map +0 -1
- package/dist/run-CCZ24VKk.js.map +0 -1
- package/dist/run-CF97BWVa.js.map +0 -1
- package/dist/run-CQbj3ley.cjs.map +0 -1
- package/dist/run-D0hmRpHy.js +0 -49
- package/dist/run-D0hmRpHy.js.map +0 -1
- package/dist/run-DwdAwnLG.cjs +0 -125
- package/dist/run-DwdAwnLG.cjs.map +0 -1
- package/dist/run-Lr0Ctnu0.cjs +0 -50
- package/dist/run-Lr0Ctnu0.cjs.map +0 -1
- package/dist/run-P6D8TnXf.js +0 -1738
- package/dist/run-P6D8TnXf.js.map +0 -1
- package/dist/run-YsoCk5we.cjs.map +0 -1
- package/dist/shell-475fQKaX.cjs +0 -62
- package/dist/shell-475fQKaX.cjs.map +0 -1
- package/dist/shell-CN6DNqeC.js +0 -51
- package/dist/shell-CN6DNqeC.js.map +0 -1
- package/dist/telemetry-B2iWkY5e.cjs.map +0 -1
- package/dist/telemetry-BkektVz6.js +0 -243
- package/dist/telemetry-BkektVz6.js.map +0 -1
- package/dist/validate-Bj8vbvPt.cjs.map +0 -1
- package/dist/validate-bHUrnYBv.js.map +0 -1
- package/src/commands/agent/start.ts +0 -50
- package/src/commands/agent.ts +0 -10
- package/src/commands/generate.ts +0 -59
- package/src/commands/init.ts +0 -51
- package/src/commands/mcp.ts +0 -36
- package/src/commands/validate.ts +0 -22
- package/src/constants.ts +0 -48
- package/src/index.ts +0 -45
- package/src/loggers/clackLogger.ts +0 -460
- package/src/loggers/fileSystemLogger.ts +0 -151
- package/src/loggers/githubActionsLogger.ts +0 -367
- package/src/loggers/plainLogger.ts +0 -243
- package/src/loggers/types.ts +0 -7
- package/src/loggers/utils.ts +0 -252
- package/src/runners/agent/run.ts +0 -113
- package/src/runners/agent/utils.ts +0 -98
- package/src/runners/generate/run.ts +0 -276
- package/src/runners/generate/utils.ts +0 -209
- package/src/runners/init/run.ts +0 -211
- package/src/runners/init/utils.ts +0 -33
- package/src/runners/mcp/run.ts +0 -55
- package/src/runners/validate/run.ts +0 -63
- package/src/telemetry.ts +0 -280
- /package/dist/{chunk-ByKO4r7w.cjs → rolldown-runtime-Bx3C2hgW.cjs} +0 -0
|
@@ -1,26 +1,11 @@
|
|
|
1
|
-
const
|
|
2
|
-
const require_constants = require("./constants-BINTA5VZ.cjs");
|
|
1
|
+
const require_rolldown_runtime = require("./rolldown-runtime-Bx3C2hgW.cjs");
|
|
3
2
|
let node_crypto = require("node:crypto");
|
|
4
|
-
let node_dns = require("node:dns");
|
|
5
3
|
let node_os = require("node:os");
|
|
6
|
-
node_os =
|
|
4
|
+
node_os = require_rolldown_runtime.__toESM(node_os, 1);
|
|
7
5
|
let node_process = require("node:process");
|
|
8
|
-
node_process =
|
|
6
|
+
node_process = require_rolldown_runtime.__toESM(node_process, 1);
|
|
9
7
|
//#region ../../internals/utils/src/env.ts
|
|
10
8
|
/**
|
|
11
|
-
* Returns `true` when running inside a GitHub Actions workflow.
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```ts
|
|
15
|
-
* if (isGitHubActions()) {
|
|
16
|
-
* core.setOutput('result', 'ok')
|
|
17
|
-
* }
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
function isGitHubActions() {
|
|
21
|
-
return !!process.env.GITHUB_ACTIONS;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
9
|
* Returns `true` when the process is running in a CI environment.
|
|
25
10
|
* Covers GitHub Actions, GitLab CI, CircleCI, Travis CI, Jenkins, Bitbucket,
|
|
26
11
|
* TeamCity, Buildkite, and Azure Pipelines.
|
|
@@ -52,70 +37,137 @@ function isCIEnvironment() {
|
|
|
52
37
|
* ```
|
|
53
38
|
*/
|
|
54
39
|
function canUseTTY() {
|
|
55
|
-
return
|
|
40
|
+
return process.stdout.isTTY && (process.stdout.columns ?? 0) > 0 && !isCIEnvironment();
|
|
56
41
|
}
|
|
57
42
|
//#endregion
|
|
58
|
-
//#region ../../internals/utils/src/
|
|
59
|
-
/**
|
|
60
|
-
* Well-known stable domains used as DNS probes to check internet connectivity.
|
|
61
|
-
*/
|
|
62
|
-
const TEST_DOMAINS = [
|
|
63
|
-
"dns.google.com",
|
|
64
|
-
"cloudflare.com",
|
|
65
|
-
"one.one.one.one"
|
|
66
|
-
];
|
|
43
|
+
//#region ../../internals/utils/src/runtime.ts
|
|
67
44
|
/**
|
|
68
|
-
*
|
|
69
|
-
* Probes DNS resolution against well-known stable domains.
|
|
45
|
+
* Detects the JavaScript runtime executing the current process and exposes its name and version.
|
|
70
46
|
*
|
|
71
|
-
* @
|
|
72
|
-
* ```ts
|
|
73
|
-
* if (await isOnline()) {
|
|
74
|
-
* await fetchLatestVersion()
|
|
75
|
-
* }
|
|
76
|
-
* ```
|
|
47
|
+
* Prefer the shared {@link runtime} instance over constructing your own.
|
|
77
48
|
*/
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
49
|
+
var Runtime = class {
|
|
50
|
+
/**
|
|
51
|
+
* `true` when the current process is running under Bun.
|
|
52
|
+
*
|
|
53
|
+
* Detection keys off the global `Bun` object rather than `process.versions`,
|
|
54
|
+
* because Bun polyfills `process.versions.node` for Node compatibility and would
|
|
55
|
+
* otherwise look like Node.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* if (runtime.isBun) {
|
|
60
|
+
* await Bun.write(path, data)
|
|
61
|
+
* }
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
get isBun() {
|
|
65
|
+
return typeof Bun !== "undefined";
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* `true` when the current process is running under Deno.
|
|
69
|
+
*/
|
|
70
|
+
get isDeno() {
|
|
71
|
+
return typeof globalThis.Deno !== "undefined";
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* `true` when the current process is running under Node.
|
|
75
|
+
*
|
|
76
|
+
* Bun and Deno are excluded first so a polyfilled `process` does not register as Node.
|
|
77
|
+
*/
|
|
78
|
+
get isNode() {
|
|
79
|
+
return !this.isBun && !this.isDeno && typeof process !== "undefined" && process.versions?.node != null;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Name of the runtime executing the current process.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```ts
|
|
86
|
+
* runtime.name // 'bun' when run with `bun kubb`, 'node' otherwise
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
get name() {
|
|
90
|
+
if (this.isBun) return "bun";
|
|
91
|
+
if (this.isDeno) return "deno";
|
|
92
|
+
return "node";
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Version of the active runtime, or an empty string when it cannot be read.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```ts
|
|
99
|
+
* runtime.version // '1.3.11' under Bun, '22.22.2' under Node
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
get version() {
|
|
103
|
+
if (this.isBun) return process.versions.bun ?? "";
|
|
104
|
+
if (this.isDeno) return globalThis.Deno?.version?.deno ?? "";
|
|
105
|
+
return process.versions?.node ?? "";
|
|
106
|
+
}
|
|
107
|
+
};
|
|
85
108
|
/**
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
* @example
|
|
89
|
-
* ```ts
|
|
90
|
-
* const version = await executeIfOnline(() => fetchLatestVersion('kubb'))
|
|
91
|
-
* // null when offline
|
|
92
|
-
* ```
|
|
109
|
+
* Shared {@link Runtime} instance describing the JavaScript runtime executing the current process.
|
|
93
110
|
*/
|
|
94
|
-
|
|
95
|
-
if (!await isOnline()) return null;
|
|
96
|
-
try {
|
|
97
|
-
return await fn();
|
|
98
|
-
} catch {
|
|
99
|
-
return null;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
111
|
+
const runtime = new Runtime();
|
|
102
112
|
//#endregion
|
|
103
|
-
//#region src/
|
|
113
|
+
//#region src/constants.ts
|
|
104
114
|
/**
|
|
105
|
-
*
|
|
115
|
+
* NPM registry endpoint used to check for @kubb/cli updates.
|
|
106
116
|
*/
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
117
|
+
const KUBB_NPM_PACKAGE_URL = "https://registry.npmjs.org/@kubb/cli/latest";
|
|
118
|
+
/**
|
|
119
|
+
* OpenTelemetry ingestion endpoint for anonymous usage telemetry.
|
|
120
|
+
*/
|
|
121
|
+
const OTLP_ENDPOINT = "https://otlp.kubb.dev";
|
|
122
|
+
/**
|
|
123
|
+
* Glob pattern for paths the file watcher ignores.
|
|
124
|
+
*/
|
|
125
|
+
const WATCHER_IGNORED_PATHS = "**/{.git,node_modules}/**";
|
|
126
|
+
/**
|
|
127
|
+
* Upper bound in milliseconds for the npm update check, so a slow registry never stalls a run.
|
|
128
|
+
*/
|
|
129
|
+
const UPDATE_CHECK_TIMEOUT_MS = 3e3;
|
|
130
|
+
/**
|
|
131
|
+
* Flags that short-circuit execution (help and version). The telemetry notice is suppressed for these.
|
|
132
|
+
*/
|
|
133
|
+
const QUIET_FLAGS = /* @__PURE__ */ new Set([
|
|
134
|
+
"--help",
|
|
135
|
+
"-h",
|
|
136
|
+
"--version",
|
|
137
|
+
"-v"
|
|
138
|
+
]);
|
|
139
|
+
//#endregion
|
|
140
|
+
//#region src/Telemetry.ts
|
|
110
141
|
/**
|
|
111
142
|
* Returns `true` when telemetry is disabled via `DO_NOT_TRACK` or `KUBB_DISABLE_TELEMETRY`.
|
|
112
143
|
*/
|
|
113
|
-
function
|
|
144
|
+
function isDisabled() {
|
|
114
145
|
return node_process.default.env["DO_NOT_TRACK"] === "1" || node_process.default.env["DO_NOT_TRACK"] === "true" || node_process.default.env["KUBB_DISABLE_TELEMETRY"] === "1" || node_process.default.env["KUBB_DISABLE_TELEMETRY"] === "true";
|
|
115
146
|
}
|
|
116
147
|
/**
|
|
117
|
-
*
|
|
118
|
-
|
|
148
|
+
* Build an anonymous telemetry payload from a completed generation run.
|
|
149
|
+
*/
|
|
150
|
+
function buildTelemetryEvent(options) {
|
|
151
|
+
const [seconds, nanoseconds] = node_process.default.hrtime(options.hrStart);
|
|
152
|
+
const duration = Math.round(seconds * 1e3 + nanoseconds / 1e6);
|
|
153
|
+
return {
|
|
154
|
+
command: options.command,
|
|
155
|
+
kubbVersion: options.kubbVersion,
|
|
156
|
+
nodeVersion: node_process.default.versions.node.split(".")[0],
|
|
157
|
+
runtime: runtime.name,
|
|
158
|
+
runtimeVersion: runtime.version.split(".")[0],
|
|
159
|
+
platform: node_os.default.platform(),
|
|
160
|
+
ci: isCIEnvironment(),
|
|
161
|
+
plugins: options.plugins ?? [],
|
|
162
|
+
duration,
|
|
163
|
+
filesCreated: options.filesCreated ?? 0,
|
|
164
|
+
status: options.status
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Convert a {@link TelemetryEvent} into an OTLP-compatible JSON trace payload.
|
|
169
|
+
*
|
|
170
|
+
* @see https://opentelemetry.io/docs/languages/sdk-configuration/otlp-exporter/
|
|
119
171
|
*/
|
|
120
172
|
function buildOtlpPayload(event) {
|
|
121
173
|
const traceId = (0, node_crypto.randomBytes)(16).toString("hex");
|
|
@@ -135,6 +187,14 @@ function buildOtlpPayload(event) {
|
|
|
135
187
|
key: "kubb.node_version",
|
|
136
188
|
value: { stringValue: event.nodeVersion }
|
|
137
189
|
},
|
|
190
|
+
{
|
|
191
|
+
key: "kubb.runtime",
|
|
192
|
+
value: { stringValue: event.runtime }
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
key: "kubb.runtime_version",
|
|
196
|
+
value: { stringValue: event.runtimeVersion }
|
|
197
|
+
},
|
|
138
198
|
{
|
|
139
199
|
key: "kubb.platform",
|
|
140
200
|
value: { stringValue: event.platform }
|
|
@@ -169,7 +229,7 @@ function buildOtlpPayload(event) {
|
|
|
169
229
|
resource: { attributes: [
|
|
170
230
|
{
|
|
171
231
|
key: "service.name",
|
|
172
|
-
value: { stringValue: "kubb-
|
|
232
|
+
value: { stringValue: "kubb-core" }
|
|
173
233
|
},
|
|
174
234
|
{
|
|
175
235
|
key: "service.version",
|
|
@@ -182,7 +242,7 @@ function buildOtlpPayload(event) {
|
|
|
182
242
|
] },
|
|
183
243
|
scopeSpans: [{
|
|
184
244
|
scope: {
|
|
185
|
-
name: "kubb-
|
|
245
|
+
name: "kubb-core",
|
|
186
246
|
version: event.kubbVersion
|
|
187
247
|
},
|
|
188
248
|
spans: [{
|
|
@@ -199,75 +259,66 @@ function buildOtlpPayload(event) {
|
|
|
199
259
|
}] };
|
|
200
260
|
}
|
|
201
261
|
/**
|
|
202
|
-
* Send an anonymous telemetry event to the Kubb OTLP endpoint.
|
|
203
|
-
*
|
|
204
|
-
*
|
|
262
|
+
* Send an anonymous telemetry event to the Kubb OTLP endpoint. Respects `DO_NOT_TRACK` and
|
|
263
|
+
* `KUBB_DISABLE_TELEMETRY`, and fails silently so telemetry never interrupts a run. No file
|
|
264
|
+
* paths, OpenAPI specs, or secrets are sent.
|
|
205
265
|
*/
|
|
206
266
|
async function sendTelemetry(event) {
|
|
207
|
-
if (
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
} catch (_e) {}
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* Build an anonymous telemetry payload from a completed generation run.
|
|
225
|
-
* No file paths, OpenAPI specs, or secrets are included.
|
|
226
|
-
*/
|
|
227
|
-
function buildTelemetryEvent(options) {
|
|
228
|
-
const [seconds, nanoseconds] = node_process.default.hrtime(options.hrStart);
|
|
229
|
-
const duration = Math.round(seconds * 1e3 + nanoseconds / 1e6);
|
|
230
|
-
return {
|
|
231
|
-
command: options.command,
|
|
232
|
-
kubbVersion: options.kubbVersion,
|
|
233
|
-
nodeVersion: node_process.default.versions.node.split(".")[0],
|
|
234
|
-
platform: node_os.default.platform(),
|
|
235
|
-
ci: isCi(),
|
|
236
|
-
plugins: options.plugins ?? [],
|
|
237
|
-
duration,
|
|
238
|
-
filesCreated: options.filesCreated ?? 0,
|
|
239
|
-
status: options.status
|
|
240
|
-
};
|
|
267
|
+
if (isDisabled()) return;
|
|
268
|
+
try {
|
|
269
|
+
await fetch(`${OTLP_ENDPOINT}/v1/traces`, {
|
|
270
|
+
method: "POST",
|
|
271
|
+
headers: {
|
|
272
|
+
"Content-Type": "application/json",
|
|
273
|
+
"Kubb-Telemetry-Version": "1",
|
|
274
|
+
"Kubb-Telemetry-Source": "kubb-core"
|
|
275
|
+
},
|
|
276
|
+
body: JSON.stringify(buildOtlpPayload(event)),
|
|
277
|
+
signal: AbortSignal.timeout(5e3)
|
|
278
|
+
});
|
|
279
|
+
} catch (_e) {}
|
|
241
280
|
}
|
|
242
281
|
//#endregion
|
|
243
|
-
Object.defineProperty(exports, "
|
|
282
|
+
Object.defineProperty(exports, "KUBB_NPM_PACKAGE_URL", {
|
|
244
283
|
enumerable: true,
|
|
245
284
|
get: function() {
|
|
246
|
-
return
|
|
285
|
+
return KUBB_NPM_PACKAGE_URL;
|
|
247
286
|
}
|
|
248
287
|
});
|
|
249
|
-
Object.defineProperty(exports, "
|
|
288
|
+
Object.defineProperty(exports, "QUIET_FLAGS", {
|
|
250
289
|
enumerable: true,
|
|
251
290
|
get: function() {
|
|
252
|
-
return
|
|
291
|
+
return QUIET_FLAGS;
|
|
253
292
|
}
|
|
254
293
|
});
|
|
255
|
-
Object.defineProperty(exports, "
|
|
294
|
+
Object.defineProperty(exports, "UPDATE_CHECK_TIMEOUT_MS", {
|
|
256
295
|
enumerable: true,
|
|
257
296
|
get: function() {
|
|
258
|
-
return
|
|
297
|
+
return UPDATE_CHECK_TIMEOUT_MS;
|
|
259
298
|
}
|
|
260
299
|
});
|
|
261
|
-
Object.defineProperty(exports, "
|
|
300
|
+
Object.defineProperty(exports, "WATCHER_IGNORED_PATHS", {
|
|
262
301
|
enumerable: true,
|
|
263
302
|
get: function() {
|
|
264
|
-
return
|
|
303
|
+
return WATCHER_IGNORED_PATHS;
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
Object.defineProperty(exports, "buildTelemetryEvent", {
|
|
307
|
+
enumerable: true,
|
|
308
|
+
get: function() {
|
|
309
|
+
return buildTelemetryEvent;
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
Object.defineProperty(exports, "canUseTTY", {
|
|
313
|
+
enumerable: true,
|
|
314
|
+
get: function() {
|
|
315
|
+
return canUseTTY;
|
|
265
316
|
}
|
|
266
317
|
});
|
|
267
|
-
Object.defineProperty(exports, "
|
|
318
|
+
Object.defineProperty(exports, "isDisabled", {
|
|
268
319
|
enumerable: true,
|
|
269
320
|
get: function() {
|
|
270
|
-
return
|
|
321
|
+
return isDisabled;
|
|
271
322
|
}
|
|
272
323
|
});
|
|
273
324
|
Object.defineProperty(exports, "sendTelemetry", {
|
|
@@ -277,4 +328,4 @@ Object.defineProperty(exports, "sendTelemetry", {
|
|
|
277
328
|
}
|
|
278
329
|
});
|
|
279
330
|
|
|
280
|
-
//# sourceMappingURL=
|
|
331
|
+
//# sourceMappingURL=Telemetry-xcWb-UWT.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Telemetry-xcWb-UWT.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 * Quiet window in milliseconds that collapses a burst of watcher events (an editor save emits\n * several) into a single rebuild.\n */\nexport const WATCHER_DEBOUNCE_MS = 100\n\n/**\n * Upper bound in milliseconds for the npm update check, so a slow registry never stalls a run.\n */\nexport const UPDATE_CHECK_TIMEOUT_MS = 3_000\n\n/**\n * Flags that short-circuit execution (help and version). The telemetry notice is suppressed for these.\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\ntype OtlpKeyValue = {\n key: string\n value:\n | { stringValue: string }\n | { boolValue: boolean }\n | { intValue: number }\n | { arrayValue: { values: Array<{ kvlistValue: { values: Array<OtlpKeyValue> } }> } }\n | { kvlistValue: { values: Array<OtlpKeyValue> } }\n}\n\ntype OtlpSpan = {\n traceId: string\n spanId: string\n name: string\n kind: 1\n startTimeUnixNano: string\n endTimeUnixNano: string\n attributes: Array<OtlpKeyValue>\n status: { code: 1 | 2 }\n}\n\ntype OtlpExportTraceServiceRequest = {\n resourceSpans: Array<{\n resource: { attributes: Array<OtlpKeyValue> }\n scopeSpans: Array<{\n scope: { name: string; version: string }\n spans: Array<OtlpSpan>\n }>\n }>\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 snapshot of the plugin options. Values are included but cannot be traced back to a user.\n */\n options: Record<string, unknown>\n}\n\n/**\n * Anonymous snapshot of a single Kubb run, built by {@link buildTelemetryEvent} and sent by {@link sendTelemetry}.\n */\nexport type TelemetryEvent = {\n command: string\n kubbVersion: string\n /**\n * Major version of Node that executed the run, e.g. `'22'`.\n */\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 * Returns `true` when telemetry is disabled via `DO_NOT_TRACK` or `KUBB_DISABLE_TELEMETRY`.\n */\nexport function 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 */\nexport function buildTelemetryEvent(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 *\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: 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((p) => ({\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 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,\n startTimeUnixNano: String(startTimeNs),\n endTimeUnixNano: String(endTimeNs),\n attributes,\n status: {\n code: event.status === 'success' ? 1 : 2,\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. No file\n * paths, OpenAPI specs, or secrets are sent.\n */\nexport async function sendTelemetry(event: TelemetryEvent): Promise<void> {\n if (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(buildOtlpPayload(event)),\n signal: AbortSignal.timeout(5_000),\n })\n } catch (_e) {\n // Fail silently, telemetry must never break the run\n }\n}\n"],"mappings":"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"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./
|
|
1
|
+
import "./rolldown-runtime-C0LytTxp.js";
|
|
2
2
|
//#region ../../internals/utils/src/errors.ts
|
|
3
3
|
/**
|
|
4
4
|
* Coerces an unknown thrown value to an `Error` instance.
|
|
@@ -15,18 +15,6 @@ function toError(value) {
|
|
|
15
15
|
return value instanceof Error ? value : new Error(String(value));
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
|
-
* Extracts a human-readable message from any thrown value.
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* ```ts
|
|
22
|
-
* getErrorMessage(new Error('oops')) // 'oops'
|
|
23
|
-
* getErrorMessage('plain string') // 'plain string'
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
|
-
function getErrorMessage(value) {
|
|
27
|
-
return value instanceof Error ? value.message : String(value);
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
18
|
* Extracts the `.cause` of an `Error` as an `Error`, or `undefined` when absent or not an `Error`.
|
|
31
19
|
*
|
|
32
20
|
* @example
|
|
@@ -38,6 +26,6 @@ function toCause(error) {
|
|
|
38
26
|
return error.cause instanceof Error ? error.cause : void 0;
|
|
39
27
|
}
|
|
40
28
|
//#endregion
|
|
41
|
-
export {
|
|
29
|
+
export { toError as n, toCause as t };
|
|
42
30
|
|
|
43
|
-
//# sourceMappingURL=errors-
|
|
31
|
+
//# sourceMappingURL=errors-CMvLO2NE.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors-
|
|
1
|
+
{"version":3,"file":"errors-CMvLO2NE.js","names":[],"sources":["../../../internals/utils/src/errors.ts"],"sourcesContent":["/**\n * Thrown when one or more errors occur during a Kubb build.\n * Carries the full list of underlying errors on `errors`.\n *\n * @example\n * ```ts\n * throw new BuildError('Build failed', { errors: [err1, err2] })\n * ```\n */\nexport class BuildError extends Error {\n errors: Array<Error>\n\n constructor(message: string, options: { cause?: Error; errors: Array<Error> }) {\n super(message, { cause: options.cause })\n this.name = 'BuildError'\n this.errors = options.errors\n }\n}\n\n/**\n * Coerces an unknown thrown value to an `Error` instance.\n * Returns the value as-is when it is already an `Error`; otherwise wraps it with `String(value)`.\n *\n * @example\n * ```ts\n * try { ... } catch(err) {\n * throw new BuildError('Build failed', { cause: toError(err), errors: [] })\n * }\n * ```\n */\nexport function toError(value: unknown): Error {\n return value instanceof Error ? value : new Error(String(value))\n}\n\n/**\n * Extracts a human-readable message from any thrown value.\n *\n * @example\n * ```ts\n * getErrorMessage(new Error('oops')) // 'oops'\n * getErrorMessage('plain string') // 'plain string'\n * ```\n */\nexport function getErrorMessage(value: unknown): string {\n return value instanceof Error ? value.message : String(value)\n}\n\n/**\n * Extracts the `.cause` of an `Error` as an `Error`, or `undefined` when absent or not an `Error`.\n *\n * @example\n * ```ts\n * const cause = toCause(buildError) // Error | undefined\n * ```\n */\nexport function toCause(error: Error): Error | undefined {\n return error.cause instanceof Error ? error.cause : undefined\n}\n"],"mappings":";;;;;;;;;;;;;AA8BA,SAAgB,QAAQ,OAAuB;CAC7C,OAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC;AACjE;;;;;;;;;AAuBA,SAAgB,QAAQ,OAAiC;CACvD,OAAO,MAAM,iBAAiB,QAAQ,MAAM,QAAQ,KAAA;AACtD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require("./
|
|
1
|
+
require("./rolldown-runtime-Bx3C2hgW.cjs");
|
|
2
2
|
//#region ../../internals/utils/src/errors.ts
|
|
3
3
|
/**
|
|
4
4
|
* Coerces an unknown thrown value to an `Error` instance.
|
|
@@ -15,18 +15,6 @@ function toError(value) {
|
|
|
15
15
|
return value instanceof Error ? value : new Error(String(value));
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
|
-
* Extracts a human-readable message from any thrown value.
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* ```ts
|
|
22
|
-
* getErrorMessage(new Error('oops')) // 'oops'
|
|
23
|
-
* getErrorMessage('plain string') // 'plain string'
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
|
-
function getErrorMessage(value) {
|
|
27
|
-
return value instanceof Error ? value.message : String(value);
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
18
|
* Extracts the `.cause` of an `Error` as an `Error`, or `undefined` when absent or not an `Error`.
|
|
31
19
|
*
|
|
32
20
|
* @example
|
|
@@ -38,12 +26,6 @@ function toCause(error) {
|
|
|
38
26
|
return error.cause instanceof Error ? error.cause : void 0;
|
|
39
27
|
}
|
|
40
28
|
//#endregion
|
|
41
|
-
Object.defineProperty(exports, "getErrorMessage", {
|
|
42
|
-
enumerable: true,
|
|
43
|
-
get: function() {
|
|
44
|
-
return getErrorMessage;
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
29
|
Object.defineProperty(exports, "toCause", {
|
|
48
30
|
enumerable: true,
|
|
49
31
|
get: function() {
|
|
@@ -57,4 +39,4 @@ Object.defineProperty(exports, "toError", {
|
|
|
57
39
|
}
|
|
58
40
|
});
|
|
59
41
|
|
|
60
|
-
//# sourceMappingURL=errors-
|
|
42
|
+
//# sourceMappingURL=errors-DNxBUo3k.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors-
|
|
1
|
+
{"version":3,"file":"errors-DNxBUo3k.cjs","names":[],"sources":["../../../internals/utils/src/errors.ts"],"sourcesContent":["/**\n * Thrown when one or more errors occur during a Kubb build.\n * Carries the full list of underlying errors on `errors`.\n *\n * @example\n * ```ts\n * throw new BuildError('Build failed', { errors: [err1, err2] })\n * ```\n */\nexport class BuildError extends Error {\n errors: Array<Error>\n\n constructor(message: string, options: { cause?: Error; errors: Array<Error> }) {\n super(message, { cause: options.cause })\n this.name = 'BuildError'\n this.errors = options.errors\n }\n}\n\n/**\n * Coerces an unknown thrown value to an `Error` instance.\n * Returns the value as-is when it is already an `Error`; otherwise wraps it with `String(value)`.\n *\n * @example\n * ```ts\n * try { ... } catch(err) {\n * throw new BuildError('Build failed', { cause: toError(err), errors: [] })\n * }\n * ```\n */\nexport function toError(value: unknown): Error {\n return value instanceof Error ? value : new Error(String(value))\n}\n\n/**\n * Extracts a human-readable message from any thrown value.\n *\n * @example\n * ```ts\n * getErrorMessage(new Error('oops')) // 'oops'\n * getErrorMessage('plain string') // 'plain string'\n * ```\n */\nexport function getErrorMessage(value: unknown): string {\n return value instanceof Error ? value.message : String(value)\n}\n\n/**\n * Extracts the `.cause` of an `Error` as an `Error`, or `undefined` when absent or not an `Error`.\n *\n * @example\n * ```ts\n * const cause = toCause(buildError) // Error | undefined\n * ```\n */\nexport function toCause(error: Error): Error | undefined {\n return error.cause instanceof Error ? error.cause : undefined\n}\n"],"mappings":";;;;;;;;;;;;;AA8BA,SAAgB,QAAQ,OAAuB;CAC7C,OAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC;AACjE;;;;;;;;;AAuBA,SAAgB,QAAQ,OAAiC;CACvD,OAAO,MAAM,iBAAiB,QAAQ,MAAM,QAAQ,KAAA;AACtD"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import "./rolldown-runtime-C0LytTxp.js";
|
|
2
|
+
import { define } from "gunshi";
|
|
3
|
+
//#region src/commands/generate.ts
|
|
4
|
+
const REPORTER_NAMES = [
|
|
5
|
+
"cli",
|
|
6
|
+
"json",
|
|
7
|
+
"file"
|
|
8
|
+
];
|
|
9
|
+
/**
|
|
10
|
+
* Splits and validates the comma-separated `--reporter` value against the known reporter names.
|
|
11
|
+
*/
|
|
12
|
+
function parseReporters(value) {
|
|
13
|
+
const names = value.split(",").map((name) => name.trim()).filter(Boolean);
|
|
14
|
+
for (const name of names) if (!REPORTER_NAMES.includes(name)) throw new Error(`must be one of cli, json, file (got "${name}")`);
|
|
15
|
+
return names;
|
|
16
|
+
}
|
|
17
|
+
const command = define({
|
|
18
|
+
name: "generate",
|
|
19
|
+
description: "Generate TypeScript types, API clients, React Query hooks, Zod schemas, and more from an OpenAPI specification. Reads kubb.config.ts by default. Pass an OpenAPI file path as the first argument to override the input without editing the config.",
|
|
20
|
+
examples: [
|
|
21
|
+
"kubb generate",
|
|
22
|
+
"kubb generate ./openapi.yaml",
|
|
23
|
+
"kubb generate --config kubb.config.ts",
|
|
24
|
+
"kubb generate --watch"
|
|
25
|
+
].join("\n"),
|
|
26
|
+
args: {
|
|
27
|
+
input: {
|
|
28
|
+
type: "positional",
|
|
29
|
+
required: false,
|
|
30
|
+
description: "Path to the OpenAPI specification, overriding the config"
|
|
31
|
+
},
|
|
32
|
+
config: {
|
|
33
|
+
type: "string",
|
|
34
|
+
description: "Path to the Kubb config",
|
|
35
|
+
short: "c"
|
|
36
|
+
},
|
|
37
|
+
logLevel: {
|
|
38
|
+
type: "enum",
|
|
39
|
+
choices: [
|
|
40
|
+
"silent",
|
|
41
|
+
"info",
|
|
42
|
+
"verbose"
|
|
43
|
+
],
|
|
44
|
+
description: "Info, silent or verbose",
|
|
45
|
+
short: "l",
|
|
46
|
+
default: "info"
|
|
47
|
+
},
|
|
48
|
+
watch: {
|
|
49
|
+
type: "boolean",
|
|
50
|
+
description: "Watch mode based on the input file",
|
|
51
|
+
short: "w",
|
|
52
|
+
default: false
|
|
53
|
+
},
|
|
54
|
+
verbose: {
|
|
55
|
+
type: "boolean",
|
|
56
|
+
description: "Override logLevel to verbose",
|
|
57
|
+
default: false
|
|
58
|
+
},
|
|
59
|
+
silent: {
|
|
60
|
+
type: "boolean",
|
|
61
|
+
description: "Override logLevel to silent",
|
|
62
|
+
short: "s",
|
|
63
|
+
default: false
|
|
64
|
+
},
|
|
65
|
+
reporter: {
|
|
66
|
+
type: "custom",
|
|
67
|
+
description: "Reporters that render the run, comma-separated. Overrides config.reporters",
|
|
68
|
+
metavar: "cli|json|file",
|
|
69
|
+
parse: parseReporters
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
async run({ values }) {
|
|
73
|
+
const logLevel = values.verbose ? "verbose" : values.silent ? "silent" : values.logLevel;
|
|
74
|
+
const { run } = await import("./run-BBS4Sc38.js");
|
|
75
|
+
await run({
|
|
76
|
+
input: values.input,
|
|
77
|
+
configPath: values.config,
|
|
78
|
+
logLevel,
|
|
79
|
+
watch: values.watch,
|
|
80
|
+
reporters: values.reporter
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
//#endregion
|
|
85
|
+
export { command };
|
|
86
|
+
|
|
87
|
+
//# sourceMappingURL=generate-C9fJvlhv.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-C9fJvlhv.js","names":[],"sources":["../src/commands/generate.ts"],"sourcesContent":["import { define } from 'gunshi'\nimport type { ReporterName } from '@kubb/core'\n\nconst REPORTER_NAMES: Array<ReporterName> = ['cli', 'json', 'file']\n\n/**\n * Splits and validates the comma-separated `--reporter` value against the known reporter names.\n */\nfunction parseReporters(value: string): Array<ReporterName> {\n const names = value\n .split(',')\n .map((name) => name.trim())\n .filter(Boolean)\n\n for (const name of names) {\n if (!REPORTER_NAMES.includes(name as ReporterName)) {\n throw new Error(`must be one of cli, json, file (got \"${name}\")`)\n }\n }\n\n return names as Array<ReporterName>\n}\n\nexport const command = define({\n name: 'generate',\n description:\n 'Generate TypeScript types, API clients, React Query hooks, Zod schemas, and more from an OpenAPI specification. Reads kubb.config.ts by default. Pass an OpenAPI file path as the first argument to override the input without editing the config.',\n examples: ['kubb generate', 'kubb generate ./openapi.yaml', 'kubb generate --config kubb.config.ts', 'kubb generate --watch'].join('\\n'),\n args: {\n input: {\n type: 'positional',\n required: false,\n description: 'Path to the OpenAPI specification, overriding the config',\n },\n config: {\n type: 'string',\n description: 'Path to the Kubb config',\n short: 'c',\n },\n logLevel: {\n type: 'enum',\n choices: ['silent', 'info', 'verbose'] as const,\n description: 'Info, silent or verbose',\n short: 'l',\n default: 'info',\n },\n watch: {\n type: 'boolean',\n description: 'Watch mode based on the input file',\n short: 'w',\n default: false,\n },\n verbose: {\n type: 'boolean',\n description: 'Override logLevel to verbose',\n default: false,\n },\n silent: {\n type: 'boolean',\n description: 'Override logLevel to silent',\n short: 's',\n default: false,\n },\n reporter: {\n type: 'custom',\n description: 'Reporters that render the run, comma-separated. Overrides config.reporters',\n metavar: 'cli|json|file',\n parse: parseReporters,\n },\n },\n async run({ values }) {\n const logLevel = values.verbose ? 'verbose' : values.silent ? 'silent' : values.logLevel\n const { run } = await import('../runners/generate/run.ts')\n\n await run({\n input: values.input,\n configPath: values.config,\n logLevel,\n watch: values.watch,\n reporters: values.reporter,\n })\n },\n})\n"],"mappings":";;;AAGA,MAAM,iBAAsC;CAAC;CAAO;CAAQ;AAAM;;;;AAKlE,SAAS,eAAe,OAAoC;CAC1D,MAAM,QAAQ,MACX,MAAM,GAAG,CAAC,CACV,KAAK,SAAS,KAAK,KAAK,CAAC,CAAC,CAC1B,OAAO,OAAO;CAEjB,KAAK,MAAM,QAAQ,OACjB,IAAI,CAAC,eAAe,SAAS,IAAoB,GAC/C,MAAM,IAAI,MAAM,wCAAwC,KAAK,GAAG;CAIpE,OAAO;AACT;AAEA,MAAa,UAAU,OAAO;CAC5B,MAAM;CACN,aACE;CACF,UAAU;EAAC;EAAiB;EAAgC;EAAyC;CAAuB,CAAC,CAAC,KAAK,IAAI;CACvI,MAAM;EACJ,OAAO;GACL,MAAM;GACN,UAAU;GACV,aAAa;EACf;EACA,QAAQ;GACN,MAAM;GACN,aAAa;GACb,OAAO;EACT;EACA,UAAU;GACR,MAAM;GACN,SAAS;IAAC;IAAU;IAAQ;GAAS;GACrC,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,OAAO;GACL,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,SAAS;GACP,MAAM;GACN,aAAa;GACb,SAAS;EACX;EACA,QAAQ;GACN,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;EACX;EACA,UAAU;GACR,MAAM;GACN,aAAa;GACb,SAAS;GACT,OAAO;EACT;CACF;CACA,MAAM,IAAI,EAAE,UAAU;EACpB,MAAM,WAAW,OAAO,UAAU,YAAY,OAAO,SAAS,WAAW,OAAO;EAChF,MAAM,EAAE,QAAQ,MAAM,OAAO;EAE7B,MAAM,IAAI;GACR,OAAO,OAAO;GACd,YAAY,OAAO;GACnB;GACA,OAAO,OAAO;GACd,WAAW,OAAO;EACpB,CAAC;CACH;AACF,CAAC"}
|