@kubb/cli 5.5.6 → 5.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/dist/{Telemetry-CMXOVUKB.js → Telemetry-RBcAjNxj.js} +18 -43
  2. package/dist/Telemetry-RBcAjNxj.js.map +1 -0
  3. package/dist/{Telemetry-DDHXBdEz.cjs → Telemetry-bGdFBaGt.cjs} +27 -89
  4. package/dist/Telemetry-bGdFBaGt.cjs.map +1 -0
  5. package/dist/agent-BPIqnEl2.js +59 -0
  6. package/dist/agent-BPIqnEl2.js.map +1 -0
  7. package/dist/agent-DElUuYuy.cjs +120 -0
  8. package/dist/agent-DElUuYuy.cjs.map +1 -0
  9. package/dist/{background-DxlRE9O5.js → background-0PMj56FJ.js} +6 -5
  10. package/dist/background-0PMj56FJ.js.map +1 -0
  11. package/dist/background-BqS01QDb.js +2 -0
  12. package/dist/{background-Bbcc2TdN.cjs → background-R0T_7Szu.cjs} +8 -7
  13. package/dist/background-R0T_7Szu.cjs.map +1 -0
  14. package/dist/commands-BAgGrcvc.js +65 -0
  15. package/dist/commands-BAgGrcvc.js.map +1 -0
  16. package/dist/commands-Si-RFAS6.cjs +71 -0
  17. package/dist/commands-Si-RFAS6.cjs.map +1 -0
  18. package/dist/config-8Xl4yZmw.js +146 -0
  19. package/dist/config-8Xl4yZmw.js.map +1 -0
  20. package/dist/config-ByfJSj3q.cjs +164 -0
  21. package/dist/config-ByfJSj3q.cjs.map +1 -0
  22. package/dist/constants-CdxpgX3_.cjs.map +1 -1
  23. package/dist/constants-DHRspBTo.js.map +1 -1
  24. package/dist/{errors-C-wEou02.cjs → errors-CMbMAwyW.cjs} +2 -2
  25. package/dist/{errors-C-wEou02.cjs.map → errors-CMbMAwyW.cjs.map} +1 -1
  26. package/dist/index.cjs +431 -22
  27. package/dist/index.cjs.map +1 -1
  28. package/dist/index.js +429 -20
  29. package/dist/index.js.map +1 -1
  30. package/dist/output-B6Ondw0g.js +776 -0
  31. package/dist/output-B6Ondw0g.js.map +1 -0
  32. package/dist/output-i3s5c4Xu.cjs +878 -0
  33. package/dist/output-i3s5c4Xu.cjs.map +1 -0
  34. package/dist/run-3I2NPeXG.cjs +31 -0
  35. package/dist/run-3I2NPeXG.cjs.map +1 -0
  36. package/dist/{run-C-jBKNbI.cjs → run-BkLJ5mXn.cjs} +22 -43
  37. package/dist/run-BkLJ5mXn.cjs.map +1 -0
  38. package/dist/run-CZlkqkDc.js +30 -0
  39. package/dist/run-CZlkqkDc.js.map +1 -0
  40. package/dist/run-CmNDNEjR.js +346 -0
  41. package/dist/run-CmNDNEjR.js.map +1 -0
  42. package/dist/{run-BdTwxLCW.js → run-D5AeacqK.js} +9 -23
  43. package/dist/run-D5AeacqK.js.map +1 -0
  44. package/dist/{run-y6LRyWdS.cjs → run-D8Wz_17X.cjs} +41 -60
  45. package/dist/run-D8Wz_17X.cjs.map +1 -0
  46. package/dist/{run-Dn8HVjnM.js → run-DQoKTiGk.js} +23 -44
  47. package/dist/run-DQoKTiGk.js.map +1 -0
  48. package/dist/{run-BDaZPU-1.js → run-Dgph0WYk.js} +25 -49
  49. package/dist/run-Dgph0WYk.js.map +1 -0
  50. package/dist/run-t8nm7zcT.cjs +348 -0
  51. package/dist/run-t8nm7zcT.cjs.map +1 -0
  52. package/dist/{run-CZz_GbE4.cjs → run-yvuot2N9.cjs} +12 -26
  53. package/dist/run-yvuot2N9.cjs.map +1 -0
  54. package/dist/{snapshot-B5mc4gpC.js → snapshot-CkHXR0Nl.js} +5 -5
  55. package/dist/snapshot-CkHXR0Nl.js.map +1 -0
  56. package/dist/{snapshot-DnCxZfmM.cjs → snapshot-D4nKbwkw.cjs} +9 -9
  57. package/dist/snapshot-D4nKbwkw.cjs.map +1 -0
  58. package/dist/studioWorker.js +2 -2
  59. package/package.json +7 -7
  60. package/dist/Telemetry-CMXOVUKB.js.map +0 -1
  61. package/dist/Telemetry-DDHXBdEz.cjs.map +0 -1
  62. package/dist/agent-DiB4CRre.cjs +0 -38
  63. package/dist/agent-DiB4CRre.cjs.map +0 -1
  64. package/dist/agent-yA5vrXJB.js +0 -26
  65. package/dist/agent-yA5vrXJB.js.map +0 -1
  66. package/dist/background-Bbcc2TdN.cjs.map +0 -1
  67. package/dist/background-CFNncNYT.js +0 -2
  68. package/dist/background-DxlRE9O5.js.map +0 -1
  69. package/dist/connect-C9tTngda.js +0 -11
  70. package/dist/connect-C9tTngda.js.map +0 -1
  71. package/dist/connect-CJ7BhOcs.cjs +0 -11
  72. package/dist/connect-CJ7BhOcs.cjs.map +0 -1
  73. package/dist/generate-BUqZ_7GB.cjs +0 -92
  74. package/dist/generate-BUqZ_7GB.cjs.map +0 -1
  75. package/dist/generate-q2m01zRd.js +0 -92
  76. package/dist/generate-q2m01zRd.js.map +0 -1
  77. package/dist/gunshiDryRun-DdKJuVn1.js +0 -2
  78. package/dist/init-Ckpwkfvz.cjs +0 -58
  79. package/dist/init-Ckpwkfvz.cjs.map +0 -1
  80. package/dist/init-DukE9Uw4.js +0 -58
  81. package/dist/init-DukE9Uw4.js.map +0 -1
  82. package/dist/login-Bc19oiFE.cjs +0 -11
  83. package/dist/login-Bc19oiFE.cjs.map +0 -1
  84. package/dist/login-Do3nns0B.js +0 -11
  85. package/dist/login-Do3nns0B.js.map +0 -1
  86. package/dist/logout-BvHFvCeI.cjs +0 -16
  87. package/dist/logout-BvHFvCeI.cjs.map +0 -1
  88. package/dist/logout-COxoIMum.js +0 -16
  89. package/dist/logout-COxoIMum.js.map +0 -1
  90. package/dist/mcp-B-GxGgVr.js +0 -19
  91. package/dist/mcp-B-GxGgVr.js.map +0 -1
  92. package/dist/mcp-B3B-rE7W.cjs +0 -18
  93. package/dist/mcp-B3B-rE7W.cjs.map +0 -1
  94. package/dist/output-CVLosNZq.cjs +0 -411
  95. package/dist/output-CVLosNZq.cjs.map +0 -1
  96. package/dist/output-FDo-db-w.js +0 -321
  97. package/dist/output-FDo-db-w.js.map +0 -1
  98. package/dist/package-Ci2fcoOV.js +0 -6
  99. package/dist/package-Ci2fcoOV.js.map +0 -1
  100. package/dist/package-Do9rJ7D3.cjs +0 -11
  101. package/dist/package-Do9rJ7D3.cjs.map +0 -1
  102. package/dist/rolldown-runtime-qbf5tadS.cjs +0 -38
  103. package/dist/run-BDaZPU-1.js.map +0 -1
  104. package/dist/run-BdTwxLCW.js.map +0 -1
  105. package/dist/run-C-jBKNbI.cjs.map +0 -1
  106. package/dist/run-CAcQlhub.js +0 -295
  107. package/dist/run-CAcQlhub.js.map +0 -1
  108. package/dist/run-CSoFhDyK.cjs +0 -297
  109. package/dist/run-CSoFhDyK.cjs.map +0 -1
  110. package/dist/run-CZz_GbE4.cjs.map +0 -1
  111. package/dist/run-CaEbo-te.js +0 -40
  112. package/dist/run-CaEbo-te.js.map +0 -1
  113. package/dist/run-CihzLZmR.cjs +0 -41
  114. package/dist/run-CihzLZmR.cjs.map +0 -1
  115. package/dist/run-Dn8HVjnM.js.map +0 -1
  116. package/dist/run-y6LRyWdS.cjs.map +0 -1
  117. package/dist/shared-Cl-OLpNh.cjs +0 -81
  118. package/dist/shared-Cl-OLpNh.cjs.map +0 -1
  119. package/dist/shared-DaHA7QFQ.js +0 -58
  120. package/dist/shared-DaHA7QFQ.js.map +0 -1
  121. package/dist/snapshot-B5mc4gpC.js.map +0 -1
  122. package/dist/snapshot-DnCxZfmM.cjs.map +0 -1
  123. package/dist/start-B-GXO8tS.cjs +0 -12
  124. package/dist/start-B-GXO8tS.cjs.map +0 -1
  125. package/dist/start-Dbfx_8zG.js +0 -12
  126. package/dist/start-Dbfx_8zG.js.map +0 -1
  127. package/dist/status-DDajNc8w.js +0 -17
  128. package/dist/status-DDajNc8w.js.map +0 -1
  129. package/dist/status-DusS7DfO.cjs +0 -17
  130. package/dist/status-DusS7DfO.cjs.map +0 -1
  131. package/dist/stop-C5t7Yx0t.js +0 -11
  132. package/dist/stop-C5t7Yx0t.js.map +0 -1
  133. package/dist/stop-zmM3A0Re.cjs +0 -11
  134. package/dist/stop-zmM3A0Re.cjs.map +0 -1
  135. package/dist/studio--IOOl_VB.js +0 -174
  136. package/dist/studio--IOOl_VB.js.map +0 -1
  137. package/dist/studio-CJ2XhtRd.cjs +0 -174
  138. package/dist/studio-CJ2XhtRd.cjs.map +0 -1
  139. package/dist/utils-C3HZOWL_.js +0 -1107
  140. package/dist/utils-C3HZOWL_.js.map +0 -1
  141. package/dist/utils-ClRbJfxu.cjs +0 -1210
  142. package/dist/utils-ClRbJfxu.cjs.map +0 -1
  143. package/dist/validate-BcB0tFQ6.cjs +0 -19
  144. package/dist/validate-BcB0tFQ6.cjs.map +0 -1
  145. package/dist/validate-QpkCbIFJ.js +0 -20
  146. package/dist/validate-QpkCbIFJ.js.map +0 -1
@@ -0,0 +1,348 @@
1
+ const require_agent = require("./agent-DElUuYuy.cjs");
2
+ const require_errors = require("./errors-CMbMAwyW.cjs");
3
+ const require_Telemetry = require("./Telemetry-bGdFBaGt.cjs");
4
+ const require_output = require("./output-i3s5c4Xu.cjs");
5
+ const require_config = require("./config-ByfJSj3q.cjs");
6
+ let node_util = require("node:util");
7
+ let node_process = require("node:process");
8
+ node_process = require_agent.__toESM(node_process, 1);
9
+ let node_path = require("node:path");
10
+ node_path = require_agent.__toESM(node_path, 1);
11
+ let _kubb_core = require("@kubb/core");
12
+ let verkit = require("verkit");
13
+ //#region src/runners/generate/utils.ts
14
+ /** Glob pattern for paths the file watcher ignores. */
15
+ const WATCHER_IGNORED_PATHS = "**/{.git,node_modules}/**";
16
+ /** Quiet window in milliseconds that collapses a burst of watcher events (an editor save emits several) into one rebuild. */
17
+ const WATCHER_DEBOUNCE_MS = 100;
18
+ /** Interval in milliseconds between polls of a remote `input` URL in watch mode, which emits no filesystem events. */
19
+ const URL_WATCHER_INTERVAL_MS = 2e3;
20
+ /** Upper bound in milliseconds for one URL watcher request, headers and body read, so a hung server never stalls polling. */
21
+ const URL_WATCHER_TIMEOUT_MS = 1e4;
22
+ /**
23
+ * Returns `true` when `latest` is a newer semver version than `current`. Compares each numeric
24
+ * part, so `5.10.0` beats `5.9.0` where a plain string comparison would not. Prerelease
25
+ * suffixes are ignored, and a malformed version never reports an update.
26
+ *
27
+ * @example Double-digit minor
28
+ * `isNewerVersion('5.9.0', '5.10.0') // true`
29
+ *
30
+ * @example String comparison would get this wrong the other way
31
+ * `isNewerVersion('5.10.0', '5.9.0') // false`
32
+ */
33
+ function isNewerVersion(current, latest) {
34
+ if (!(0, verkit.isValid)(current) || !(0, verkit.isValid)(latest)) return false;
35
+ return (0, verkit.isGreaterThan)((0, verkit.truncate)(latest, "patch"), (0, verkit.truncate)(current, "patch"));
36
+ }
37
+ /**
38
+ * Wraps `run` so invocations never overlap: a trigger that lands while a run is in flight
39
+ * marks it dirty and runs once more after it finishes, no matter how many triggers arrived.
40
+ * Useful for event-driven reruns (a file watcher, a queue drain) where bursts should
41
+ * coalesce into a single trailing run.
42
+ *
43
+ * @example
44
+ * ```ts
45
+ * const rebuild = createSerialRunner({
46
+ * run: () => build(),
47
+ * onError: (error) => log.error(error.message),
48
+ * })
49
+ * watcher.on('change', () => void rebuild())
50
+ * ```
51
+ */
52
+ function createSerialRunner({ run, onError }) {
53
+ let running = false;
54
+ let dirty = false;
55
+ return async () => {
56
+ if (running) {
57
+ dirty = true;
58
+ return;
59
+ }
60
+ running = true;
61
+ do {
62
+ dirty = false;
63
+ try {
64
+ await run();
65
+ } catch (error) {
66
+ onError(require_errors.toError(error));
67
+ }
68
+ } while (dirty);
69
+ running = false;
70
+ };
71
+ }
72
+ /**
73
+ * Starts a file watcher on the given paths and calls `cb` on any change.
74
+ * Ignores `.git` and `node_modules` directories. Event bursts (an editor save emits several)
75
+ * are debounced into one build, and builds never overlap: changes during a build queue exactly
76
+ * one rebuild. Resolves to a function that stops watching.
77
+ */
78
+ async function startWatcher(path, cb, log = {
79
+ info: console.log,
80
+ error: console.log
81
+ }) {
82
+ const { watch } = await import("chokidar");
83
+ const watcher = watch(path, {
84
+ ignorePermissionErrors: true,
85
+ ignored: WATCHER_IGNORED_PATHS,
86
+ ignoreInitial: true
87
+ });
88
+ node_process.default.once("SIGINT", () => {
89
+ watcher.close();
90
+ });
91
+ node_process.default.once("SIGTERM", () => {
92
+ watcher.close();
93
+ });
94
+ const runBuild = createSerialRunner({
95
+ run: () => cb(path),
96
+ onError: () => log.error((0, node_util.styleText)("red", "Watcher failed"))
97
+ });
98
+ let debounceTimer = null;
99
+ watcher.on("all", (type, file) => {
100
+ log.info((0, node_util.styleText)("yellow", (0, node_util.styleText)("bold", `Change detected: ${type} ${file}`)));
101
+ if (debounceTimer) clearTimeout(debounceTimer);
102
+ debounceTimer = setTimeout(() => {
103
+ debounceTimer = null;
104
+ runBuild();
105
+ }, WATCHER_DEBOUNCE_MS);
106
+ });
107
+ return async () => {
108
+ if (debounceTimer) clearTimeout(debounceTimer);
109
+ await watcher.close();
110
+ };
111
+ }
112
+ /**
113
+ * Fetches the body of a remote spec URL, `undefined` when the server does not answer with a
114
+ * readable 2xx body before `signal` aborts. The caller seeds `startUrlWatcher` with the result, so
115
+ * the watcher compares polls against the content the initial build ran on.
116
+ */
117
+ async function fetchUrlBody(url, signal = AbortSignal.timeout(URL_WATCHER_TIMEOUT_MS)) {
118
+ try {
119
+ const response = await fetch(url, { signal });
120
+ if (!response.ok) return void 0;
121
+ return await response.text();
122
+ } catch {
123
+ return;
124
+ }
125
+ }
126
+ /**
127
+ * Polls a remote spec URL and calls `cb` whenever the response body changes. A remote document
128
+ * emits no filesystem events, so this is the URL counterpart of `startWatcher`.
129
+ *
130
+ * `initialBody` seeds the change detection, so an edit landing between the initial build and the
131
+ * first poll still rebuilds. An unreachable server (the API restarting between saves) is reported
132
+ * once per outage and polling continues; after it recovers, a rebuild happens only when the body
133
+ * actually differs from the last one seen, so a plain restart with an unchanged spec stays quiet.
134
+ * Each request is aborted after `timeoutMs`, so a hung response delays at most one poll.
135
+ *
136
+ * Returns a function that stops polling and aborts the in-flight request, so callers (and tests)
137
+ * can shut the watcher down without signaling the process.
138
+ */
139
+ function startUrlWatcher(url, cb, options = {}) {
140
+ const { log = {
141
+ info: console.log,
142
+ error: console.log
143
+ }, intervalMs = URL_WATCHER_INTERVAL_MS, timeoutMs = URL_WATCHER_TIMEOUT_MS, initialBody } = options;
144
+ let lastBody = initialBody;
145
+ let offline = false;
146
+ let timer = null;
147
+ let controller = null;
148
+ let stopped = false;
149
+ const stop = () => {
150
+ stopped = true;
151
+ if (timer) clearTimeout(timer);
152
+ controller?.abort();
153
+ };
154
+ node_process.default.once("SIGINT", stop);
155
+ node_process.default.once("SIGTERM", stop);
156
+ const runBuild = createSerialRunner({
157
+ run: () => cb([url]),
158
+ onError: () => log.error((0, node_util.styleText)("red", "Watcher failed"))
159
+ });
160
+ const schedule = () => {
161
+ if (!stopped) timer = setTimeout(() => void poll(), intervalMs);
162
+ };
163
+ const poll = async () => {
164
+ controller = new AbortController();
165
+ const body = await fetchUrlBody(url, AbortSignal.any([controller.signal, AbortSignal.timeout(timeoutMs)]));
166
+ if (body === void 0) {
167
+ if (!offline && !stopped) {
168
+ offline = true;
169
+ log.error((0, node_util.styleText)("red", `Cannot reach ${url}, polling until it responds again`));
170
+ }
171
+ schedule();
172
+ return;
173
+ }
174
+ if (offline) {
175
+ offline = false;
176
+ log.info((0, node_util.styleText)("yellow", `${url} is reachable again`));
177
+ }
178
+ const changed = lastBody !== void 0 && body !== lastBody;
179
+ if (changed) log.info((0, node_util.styleText)("yellow", (0, node_util.styleText)("bold", `Change detected: ${url}`)));
180
+ if (changed || lastBody === void 0) runBuild();
181
+ lastBody = body;
182
+ schedule();
183
+ };
184
+ poll();
185
+ return stop;
186
+ }
187
+ //#endregion
188
+ //#region src/runners/generate/run.ts
189
+ /** NPM registry endpoint used to check for @kubb/cli updates. */
190
+ const KUBB_NPM_PACKAGE_URL = "https://registry.npmjs.org/@kubb/cli/latest";
191
+ /** Upper bound in milliseconds for the npm update check, so a slow registry never stalls a run. */
192
+ const UPDATE_CHECK_TIMEOUT_MS = 3e3;
193
+ async function generate(options) {
194
+ const { input, hooks, dryRun = false } = options;
195
+ const report = require_Telemetry.trackRun({
196
+ command: "generate",
197
+ hrStart: node_process.default.hrtime()
198
+ });
199
+ const config = {
200
+ ...options.config,
201
+ input: input ?? options.config.input,
202
+ storage: dryRun ? (0, _kubb_core.memoryStorage)() : options.config.storage,
203
+ output: dryRun ? {
204
+ ...options.config.output,
205
+ format: false,
206
+ lint: false,
207
+ postGenerate: []
208
+ } : options.config.output
209
+ };
210
+ const kubb = (0, _kubb_core.createKubb)(config, { hooks });
211
+ const result = await kubb.generate();
212
+ if (dryRun) await hooks.callHook("kubb:info", {
213
+ message: "Dry run: no files were written",
214
+ info: `${result.files.length} file(s) would be generated`
215
+ });
216
+ await report({
217
+ plugins: Array.from(kubb.driver.plugins.values(), (p) => ({
218
+ name: p.name,
219
+ options: p.options
220
+ })),
221
+ filesCreated: result.files.length,
222
+ status: result.success ? "success" : "failed"
223
+ });
224
+ return result.success;
225
+ }
226
+ async function checkForUpdate(hooks) {
227
+ try {
228
+ const data = await (await fetch(KUBB_NPM_PACKAGE_URL, { signal: AbortSignal.timeout(UPDATE_CHECK_TIMEOUT_MS) })).json();
229
+ if (data.version && isNewerVersion(require_Telemetry.version, data.version)) await _kubb_core.Diagnostics.emit(hooks, _kubb_core.Diagnostics.update({
230
+ currentVersion: require_Telemetry.version,
231
+ latestVersion: data.version
232
+ }));
233
+ } catch {}
234
+ }
235
+ /**
236
+ * Runs the full Kubb generation lifecycle for the given CLI options.
237
+ * Loads configs, sets up the reporters (CLI `--reporter` picks which of `config.reporters` to trigger),
238
+ * checks for a newer version, and calls `generate` for each config entry.
239
+ */
240
+ async function run({ input, configPath, logLevel: logLevelKey, watch, reporters: cliReporters, dryRun }) {
241
+ const logLevel = _kubb_core.logLevel[logLevelKey] ?? _kubb_core.logLevel.info;
242
+ const hooks = new _kubb_core.Hookable();
243
+ const requestedNames = cliReporters?.length ? cliReporters : ["cli"];
244
+ const quiet = logLevel <= _kubb_core.logLevel.silent || requestedNames.includes("json");
245
+ if (!quiet) {
246
+ require_output.logBanner(require_Telemetry.version);
247
+ require_output.logIntro({ title: "Configuration" });
248
+ }
249
+ const configSpinner = require_output.createSpinner();
250
+ let configs;
251
+ let resolvedConfigPath;
252
+ try {
253
+ if (!quiet) configSpinner.start("Loading config");
254
+ const loaded = await require_config.getConfigs({
255
+ configPath,
256
+ input,
257
+ watch,
258
+ logLevel: logLevelKey
259
+ });
260
+ configs = loaded.configs;
261
+ resolvedConfigPath = loaded.configPath;
262
+ if (!quiet) configSpinner.stop(`Loaded ${(0, node_util.styleText)("dim", node_path.default.relative(node_process.default.cwd(), resolvedConfigPath))}`);
263
+ } catch (error) {
264
+ if (!quiet) configSpinner.error("Config failed loading");
265
+ require_config.setupReporters(hooks, {
266
+ logLevel,
267
+ reporters: [_kubb_core.cliReporter]
268
+ });
269
+ await hooks.callHook("kubb:error", { error: require_errors.toError(error) });
270
+ if (!quiet) require_output.logOutro((0, node_util.styleText)("red", "✗ Configuration failed"));
271
+ node_process.default.exit(1);
272
+ }
273
+ const available = configs[0]?.reporters?.length ? configs[0].reporters : [
274
+ _kubb_core.cliReporter,
275
+ _kubb_core.jsonReporter,
276
+ _kubb_core.fileReporter,
277
+ _kubb_core.htmlReporter
278
+ ];
279
+ const reporters = require_config.selectReporters(available, requestedNames);
280
+ require_config.setupReporters(hooks, {
281
+ logLevel,
282
+ reporters
283
+ });
284
+ await hooks.callHook("kubb:lifecycle:start", { version: require_Telemetry.version });
285
+ await checkForUpdate(hooks);
286
+ if (!quiet) require_output.logOutro(`${require_output.pluralize(configs.length, "config")} ready`);
287
+ try {
288
+ let anyFailed = false;
289
+ for (const config of configs) {
290
+ const effectiveInput = input ?? config.input;
291
+ const inputKind = typeof effectiveInput === "string" ? (0, _kubb_core.getInputKind)(effectiveInput) : void 0;
292
+ const watchPath = inputKind === "file" || inputKind === "url" ? effectiveInput : void 0;
293
+ if (watchPath && watch) {
294
+ const watchedPaths = [watchPath];
295
+ const build = async (paths) => {
296
+ const succeeded = await generate({
297
+ input,
298
+ config,
299
+ hooks,
300
+ dryRun
301
+ });
302
+ require_output.logStep((0, node_util.styleText)("yellow", `Watching for changes in ${paths.join(" and ")}`));
303
+ if (succeeded) {
304
+ require_output.logSpacer();
305
+ require_output.logTip();
306
+ }
307
+ };
308
+ const initialBody = inputKind === "url" ? await fetchUrlBody(watchPath) : void 0;
309
+ try {
310
+ await build(watchedPaths);
311
+ } catch (buildError) {
312
+ await hooks.callHook("kubb:error", { error: require_errors.toError(buildError) });
313
+ }
314
+ if (inputKind === "url") startUrlWatcher(watchPath, build, {
315
+ log: {
316
+ info: require_output.logInfo,
317
+ error: require_output.logError
318
+ },
319
+ initialBody
320
+ });
321
+ else await startWatcher(watchedPaths, build, {
322
+ info: require_output.logInfo,
323
+ error: require_output.logError
324
+ });
325
+ } else try {
326
+ if (!await generate({
327
+ input,
328
+ config,
329
+ hooks,
330
+ dryRun
331
+ })) anyFailed = true;
332
+ } catch (configError) {
333
+ await hooks.callHook("kubb:error", { error: require_errors.toError(configError) });
334
+ anyFailed = true;
335
+ }
336
+ }
337
+ await hooks.callHook("kubb:lifecycle:end");
338
+ if (!quiet && !watch && !anyFailed) require_output.logTip();
339
+ if (anyFailed) node_process.default.exit(1);
340
+ } catch (error) {
341
+ await hooks.callHook("kubb:error", { error: require_errors.toError(error) });
342
+ node_process.default.exit(1);
343
+ }
344
+ }
345
+ //#endregion
346
+ exports.run = run;
347
+
348
+ //# sourceMappingURL=run-t8nm7zcT.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-t8nm7zcT.cjs","names":["isValid","isGreaterThan","truncate","toError","styleText","trackRun","process","memoryStorage","createKubb","version","Diagnostics","logLevelMap","Hookable","createSpinner","getConfigs","styleText","path","cliReporter","toError","jsonReporter","fileReporter","htmlReporter","selectReporters","pluralize","getInputKind","logInfo","logError"],"sources":["../src/runners/generate/utils.ts","../src/runners/generate/run.ts"],"sourcesContent":["import process from 'node:process'\nimport { styleText } from 'node:util'\nimport { toError } from '@internals/utils'\nimport { isGreaterThan, isValid, truncate } from 'verkit'\n\n/** Glob pattern for paths the file watcher ignores. */\nconst WATCHER_IGNORED_PATHS = '**/{.git,node_modules}/**' as const\n\n/** Quiet window in milliseconds that collapses a burst of watcher events (an editor save emits several) into one rebuild. */\nconst WATCHER_DEBOUNCE_MS = 100\n\n/** Interval in milliseconds between polls of a remote `input` URL in watch mode, which emits no filesystem events. */\nconst URL_WATCHER_INTERVAL_MS = 2_000\n\n/** Upper bound in milliseconds for one URL watcher request, headers and body read, so a hung server never stalls polling. */\nconst URL_WATCHER_TIMEOUT_MS = 10_000\n\n/**\n * Returns `true` when `latest` is a newer semver version than `current`. Compares each numeric\n * part, so `5.10.0` beats `5.9.0` where a plain string comparison would not. Prerelease\n * suffixes are ignored, and a malformed version never reports an update.\n *\n * @example Double-digit minor\n * `isNewerVersion('5.9.0', '5.10.0') // true`\n *\n * @example String comparison would get this wrong the other way\n * `isNewerVersion('5.10.0', '5.9.0') // false`\n */\nexport function isNewerVersion(current: string, latest: string): boolean {\n if (!isValid(current) || !isValid(latest)) return false\n\n return isGreaterThan(truncate(latest, 'patch') as string, truncate(current, 'patch') as string)\n}\n\ntype SerialRunnerOptions = {\n /**\n * The async work to serialize.\n */\n run(): Promise<void>\n /**\n * Receives errors thrown by `run`, so a failure never rejects the returned trigger.\n */\n onError(error: Error): void\n}\n\n/**\n * Wraps `run` so invocations never overlap: a trigger that lands while a run is in flight\n * marks it dirty and runs once more after it finishes, no matter how many triggers arrived.\n * Useful for event-driven reruns (a file watcher, a queue drain) where bursts should\n * coalesce into a single trailing run.\n *\n * @example\n * ```ts\n * const rebuild = createSerialRunner({\n * run: () => build(),\n * onError: (error) => log.error(error.message),\n * })\n * watcher.on('change', () => void rebuild())\n * ```\n */\nexport function createSerialRunner({ run, onError }: SerialRunnerOptions): () => Promise<void> {\n let running = false\n let dirty = false\n\n return async (): Promise<void> => {\n if (running) {\n dirty = true\n return\n }\n running = true\n do {\n dirty = false\n try {\n await run()\n } catch (error) {\n onError(toError(error))\n }\n } while (dirty)\n running = false\n }\n}\n\ntype WatcherLog = {\n info: (message: string) => void\n error: (message: string) => void\n}\n\n/**\n * Starts a file watcher on the given paths and calls `cb` on any change.\n * Ignores `.git` and `node_modules` directories. Event bursts (an editor save emits several)\n * are debounced into one build, and builds never overlap: changes during a build queue exactly\n * one rebuild. Resolves to a function that stops watching.\n */\nexport async function startWatcher(\n path: Array<string>,\n cb: (path: Array<string>) => Promise<void>,\n log: WatcherLog = { info: console.log, error: console.log },\n): Promise<() => Promise<void>> {\n const { watch } = await import('chokidar')\n // `ignoreInitial` skips the `add` events chokidar fires for existing files at startup, which\n // would otherwise rebuild right after the initial run.\n const watcher = watch(path, { ignorePermissionErrors: true, ignored: WATCHER_IGNORED_PATHS, ignoreInitial: true })\n\n process.once('SIGINT', () => {\n watcher.close()\n })\n process.once('SIGTERM', () => {\n watcher.close()\n })\n\n // Bursts never overlap builds on the shared hooks emitter: a change during a build\n // queues exactly one rerun.\n const runBuild = createSerialRunner({\n run: () => cb(path),\n onError: () => log.error(styleText('red', 'Watcher failed')),\n })\n let debounceTimer: ReturnType<typeof setTimeout> | null = null\n\n watcher.on('all', (type, file) => {\n log.info(styleText('yellow', styleText('bold', `Change detected: ${type} ${file}`)))\n if (debounceTimer) clearTimeout(debounceTimer)\n debounceTimer = setTimeout(() => {\n debounceTimer = null\n void runBuild()\n }, WATCHER_DEBOUNCE_MS)\n })\n\n return async () => {\n if (debounceTimer) clearTimeout(debounceTimer)\n await watcher.close()\n }\n}\n\n/**\n * Fetches the body of a remote spec URL, `undefined` when the server does not answer with a\n * readable 2xx body before `signal` aborts. The caller seeds `startUrlWatcher` with the result, so\n * the watcher compares polls against the content the initial build ran on.\n */\nexport async function fetchUrlBody(url: string, signal: AbortSignal = AbortSignal.timeout(URL_WATCHER_TIMEOUT_MS)): Promise<string | undefined> {\n try {\n const response = await fetch(url, { signal })\n if (!response.ok) return undefined\n return await response.text()\n } catch {\n return undefined\n }\n}\n\ntype UrlWatcherOptions = {\n /**\n * Sink for watcher messages, `console.log` by default.\n */\n log?: WatcherLog\n /**\n * Time in milliseconds between polls.\n */\n intervalMs?: number\n /**\n * Upper bound in milliseconds for one poll request, covering headers and body read.\n */\n timeoutMs?: number\n /**\n * Body the initial build ran against, the baseline for change detection. When omitted (the\n * server was unreachable at startup), the first successful poll rebuilds so the output catches\n * up as soon as the server responds.\n */\n initialBody?: string\n}\n\n/**\n * Polls a remote spec URL and calls `cb` whenever the response body changes. A remote document\n * emits no filesystem events, so this is the URL counterpart of `startWatcher`.\n *\n * `initialBody` seeds the change detection, so an edit landing between the initial build and the\n * first poll still rebuilds. An unreachable server (the API restarting between saves) is reported\n * once per outage and polling continues; after it recovers, a rebuild happens only when the body\n * actually differs from the last one seen, so a plain restart with an unchanged spec stays quiet.\n * Each request is aborted after `timeoutMs`, so a hung response delays at most one poll.\n *\n * Returns a function that stops polling and aborts the in-flight request, so callers (and tests)\n * can shut the watcher down without signaling the process.\n */\nexport function startUrlWatcher(url: string, cb: (path: Array<string>) => Promise<void>, options: UrlWatcherOptions = {}): () => void {\n const { log = { info: console.log, error: console.log }, intervalMs = URL_WATCHER_INTERVAL_MS, timeoutMs = URL_WATCHER_TIMEOUT_MS, initialBody } = options\n\n let lastBody = initialBody\n let offline = false\n let timer: ReturnType<typeof setTimeout> | null = null\n let controller: AbortController | null = null\n let stopped = false\n\n const stop = () => {\n stopped = true\n if (timer) clearTimeout(timer)\n controller?.abort()\n }\n process.once('SIGINT', stop)\n process.once('SIGTERM', stop)\n\n // Builds never overlap on the shared hooks emitter: a change during a build queues exactly\n // one rerun.\n const runBuild = createSerialRunner({\n run: () => cb([url]),\n onError: () => log.error(styleText('red', 'Watcher failed')),\n })\n\n const schedule = () => {\n if (!stopped) {\n timer = setTimeout(() => void poll(), intervalMs)\n }\n }\n\n const poll = async (): Promise<void> => {\n controller = new AbortController()\n // The signal also aborts the body read, so a response that stalls mid-stream still times out.\n const body = await fetchUrlBody(url, AbortSignal.any([controller.signal, AbortSignal.timeout(timeoutMs)]))\n\n if (body === undefined) {\n // `lastBody` survives the outage so recovery rebuilds only on real content changes.\n if (!offline && !stopped) {\n offline = true\n log.error(styleText('red', `Cannot reach ${url}, polling until it responds again`))\n }\n schedule()\n return\n }\n\n if (offline) {\n offline = false\n log.info(styleText('yellow', `${url} is reachable again`))\n }\n const changed = lastBody !== undefined && body !== lastBody\n if (changed) {\n log.info(styleText('yellow', styleText('bold', `Change detected: ${url}`)))\n }\n if (changed || lastBody === undefined) {\n void runBuild()\n }\n lastBody = body\n schedule()\n }\n\n void poll()\n\n return stop\n}\n","import path from 'node:path'\nimport process from 'node:process'\nimport { styleText } from 'node:util'\nimport { formatters, linters, toError } from '@internals/utils'\nimport {\n Hookable,\n type CLIOptions,\n cliReporter,\n type Config,\n createKubb,\n Diagnostics,\n fileReporter,\n getInputKind,\n htmlReporter,\n jsonReporter,\n type KubbHooks,\n logLevel as logLevelMap,\n memoryStorage,\n type ReporterName,\n} from '@kubb/core'\nimport { version } from '../../../package.json'\nimport { trackRun } from '../../Telemetry.ts'\nimport { pluralize } from '../../loggers/createLogger.ts'\nimport setupReporters, { selectReporters } from '../../loggers/reporters.ts'\nimport { createSpinner, logBanner, logError, logInfo, logIntro, logOutro, logSpacer, logStep, logTip } from '../../loggers/output.ts'\nimport { getConfigs } from '../../config.ts'\nimport { fetchUrlBody, isNewerVersion, startUrlWatcher, startWatcher } from './utils.ts'\n\n/** NPM registry endpoint used to check for @kubb/cli updates. */\nconst KUBB_NPM_PACKAGE_URL = 'https://registry.npmjs.org/@kubb/cli/latest' as const\n\n/** Upper bound in milliseconds for the npm update check, so a slow registry never stalls a run. */\nconst UPDATE_CHECK_TIMEOUT_MS = 3_000\n\n/** The formatter names from `Config['output'].format`, without `'auto'` (detection, not a tool) and `false` (skip). */\ntype FormatterName = Exclude<NonNullable<Config['output']['format']>, 'auto' | false>\ntype LinterName = Exclude<NonNullable<Config['output']['lint']>, 'auto' | false>\n\n// Pinned here, not in `@internals/utils` (which must not import `@kubb/core`): a tool added to the union without a descriptor fails to compile.\nformatters satisfies Record<FormatterName, unknown>\nlinters satisfies Record<LinterName, unknown>\n\ntype GenerateProps = {\n input?: string\n config: Config\n hooks: Hookable<KubbHooks>\n /**\n * When `true`, generates in memory instead of writing to disk, and skips formatting, linting,\n * and post-generate commands.\n */\n dryRun?: boolean\n}\n\nasync function generate(options: GenerateProps): Promise<boolean> {\n const { input, hooks, dryRun = false } = options\n\n const report = trackRun({ command: 'generate', hrStart: process.hrtime() })\n\n const config: Config = {\n ...options.config,\n input: input ?? options.config.input,\n // Dry-run never touches disk, regardless of the config's own storage driver.\n storage: dryRun ? memoryStorage() : options.config.storage,\n // Also keeps core's `hasOutputPasses` false, so dry-run skips the output manifest write too.\n output: dryRun ? { ...options.config.output, format: false, lint: false, postGenerate: [] } : options.config.output,\n }\n\n // Core formats, lints and runs `output.postGenerate` after an error-free build, and reports\n // their failures as coded diagnostics that reach the summary, the json report and the exit code.\n const kubb = createKubb(config, { hooks })\n const result = await kubb.generate()\n\n if (dryRun) {\n await hooks.callHook('kubb:info', { message: 'Dry run: no files were written', info: `${result.files.length} file(s) would be generated` })\n }\n\n await report({\n plugins: Array.from(kubb.driver.plugins.values(), (p) => ({ name: p.name, options: p.options as Record<string, unknown> })),\n filesCreated: result.files.length,\n status: result.success ? 'success' : 'failed',\n })\n\n return result.success\n}\n\ntype GenerateCommandOptions = {\n input?: string\n configPath?: string\n logLevel: string\n watch: boolean\n reporters?: Array<ReporterName>\n dryRun?: boolean\n}\n\nasync function checkForUpdate(hooks: Hookable<KubbHooks>): Promise<void> {\n try {\n const res = await fetch(KUBB_NPM_PACKAGE_URL, { signal: AbortSignal.timeout(UPDATE_CHECK_TIMEOUT_MS) })\n const data = (await res.json()) as { version: string }\n if (data.version && isNewerVersion(version, data.version)) {\n await Diagnostics.emit(hooks, Diagnostics.update({ currentVersion: version, latestVersion: data.version }))\n }\n } catch {\n // Ignore network errors\n }\n}\n\n/**\n * Runs the full Kubb generation lifecycle for the given CLI options.\n * Loads configs, sets up the reporters (CLI `--reporter` picks which of `config.reporters` to trigger),\n * checks for a newer version, and calls `generate` for each config entry.\n */\nexport async function run({ input, configPath, logLevel: logLevelKey, watch, reporters: cliReporters, dryRun }: GenerateCommandOptions): Promise<void> {\n const logLevel = logLevelMap[logLevelKey as keyof typeof logLevelMap] ?? logLevelMap.info\n const hooks = new Hookable<KubbHooks>()\n\n // CLI `--reporter` selects which reporters to trigger by name, defaulting to `cli`. `defineConfig`\n // registers the built-in reporters on the config; a config exported without it falls back to them below.\n const requestedNames: Array<ReporterName> = cliReporters?.length ? cliReporters : ['cli']\n\n // The `json` reporter owns stdout, so the command writes nothing of its own around it.\n const quiet = logLevel <= logLevelMap.silent || requestedNames.includes('json')\n\n if (!quiet) {\n logBanner(version)\n logIntro({ title: 'Configuration' })\n }\n\n // Load the config first so `config.reporters` can pick the reporters. A failure here has no\n // reporter installed yet, so fall back to the default `cli` reporter to surface it.\n const configSpinner = createSpinner()\n let configs: Array<Config>\n let resolvedConfigPath: string\n try {\n if (!quiet) configSpinner.start('Loading config')\n\n const loaded = await getConfigs({\n configPath,\n input,\n watch,\n logLevel: logLevelKey as CLIOptions['logLevel'],\n })\n configs = loaded.configs\n resolvedConfigPath = loaded.configPath\n\n if (!quiet) configSpinner.stop(`Loaded ${styleText('dim', path.relative(process.cwd(), resolvedConfigPath))}`)\n } catch (error) {\n if (!quiet) configSpinner.error('Config failed loading')\n\n setupReporters(hooks, { logLevel, reporters: [cliReporter] })\n await hooks.callHook('kubb:error', { error: toError(error) })\n\n if (!quiet) logOutro(styleText('red', '✗ Configuration failed'))\n process.exit(1)\n }\n\n // Without a reporter nothing is printed, not even an error, so a config written without\n // `defineConfig` gets the same built-ins it would have registered.\n const available = configs[0]?.reporters?.length ? configs[0].reporters : [cliReporter, jsonReporter, fileReporter, htmlReporter]\n const reporters = selectReporters(available, requestedNames)\n setupReporters(hooks, { logLevel, reporters })\n\n await hooks.callHook('kubb:lifecycle:start', { version })\n\n // Inside the bootstrap group, so an update notice reads as part of the setup rather than as part\n // of the first config's generation.\n await checkForUpdate(hooks)\n\n if (!quiet) logOutro(`${pluralize(configs.length, 'config')} ready`)\n\n try {\n let anyFailed = false\n for (const config of configs) {\n const effectiveInput = input ?? config.input\n const inputKind = typeof effectiveInput === 'string' ? getInputKind(effectiveInput) : undefined\n const watchPath = inputKind === 'file' || inputKind === 'url' ? (effectiveInput as string) : undefined\n if (watchPath && watch) {\n const watchedPaths = [watchPath]\n // Don't removeAll() between builds, that would also drop logger and lifecycle\n // listeners. Plugin listeners are already disposed by safeBuild's dispose()\n // in its finally block, so re-running generate() on the same hooks emitter is safe.\n const build = async (paths: Array<string>) => {\n const succeeded = await generate({ input, config, hooks, dryRun })\n logStep(styleText('yellow', `Watching for changes in ${paths.join(' and ')}`))\n if (succeeded) {\n logSpacer()\n logTip()\n }\n }\n\n // For a URL input, capture the document before the build: it becomes the watcher's\n // change-detection baseline, so an edit landing before the first poll still rebuilds.\n // When the server is down the baseline stays undefined and the watcher rebuilds on its\n // first successful poll, so recovery with an unchanged document still generates output.\n const initialBody = inputKind === 'url' ? await fetchUrlBody(watchPath) : undefined\n\n // The watchers ignore their startup state, so run the first build here; a failing one keeps watching so the user can fix the input.\n try {\n await build(watchedPaths)\n } catch (buildError) {\n await hooks.callHook('kubb:error', { error: toError(buildError) })\n }\n\n if (inputKind === 'url') {\n startUrlWatcher(watchPath, build, { log: { info: logInfo, error: logError }, initialBody })\n } else {\n await startWatcher(watchedPaths, build, { info: logInfo, error: logError })\n }\n } else {\n try {\n const succeeded = await generate({ input, config, hooks, dryRun })\n if (!succeeded) anyFailed = true\n } catch (configError) {\n await hooks.callHook('kubb:error', { error: toError(configError) })\n anyFailed = true\n }\n }\n }\n\n await hooks.callHook('kubb:lifecycle:end')\n\n // Watch mode prints a tip after each successful build. Regular generate commands need to\n // print one explicitly after the lifecycle group has closed so it stays outside the group.\n if (!quiet && !watch && !anyFailed) {\n logTip()\n }\n\n if (anyFailed) {\n process.exit(1)\n }\n } catch (error) {\n await hooks.callHook('kubb:error', { error: toError(error) })\n process.exit(1)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAMA,MAAM,wBAAwB;;AAG9B,MAAM,sBAAsB;;AAG5B,MAAM,0BAA0B;;AAGhC,MAAM,yBAAyB;;;;;;;;;;;;AAa/B,SAAgB,eAAe,SAAiB,QAAyB;CACvE,IAAI,EAAA,GAACA,OAAAA,QAAAA,CAAQ,OAAO,KAAK,EAAA,GAACA,OAAAA,QAAAA,CAAQ,MAAM,GAAG,OAAO;CAElD,QAAA,GAAOC,OAAAA,cAAAA,EAAAA,GAAcC,OAAAA,SAAAA,CAAS,QAAQ,OAAO,IAAA,GAAaA,OAAAA,SAAAA,CAAS,SAAS,OAAO,CAAW;AAChG;;;;;;;;;;;;;;;;AA4BA,SAAgB,mBAAmB,EAAE,KAAK,WAAqD;CAC7F,IAAI,UAAU;CACd,IAAI,QAAQ;CAEZ,OAAO,YAA2B;EAChC,IAAI,SAAS;GACX,QAAQ;GACR;EACF;EACA,UAAU;EACV,GAAG;GACD,QAAQ;GACR,IAAI;IACF,MAAM,IAAI;GACZ,SAAS,OAAO;IACd,QAAQC,eAAAA,QAAQ,KAAK,CAAC;GACxB;EACF,SAAS;EACT,UAAU;CACZ;AACF;;;;;;;AAaA,eAAsB,aACpB,MACA,IACA,MAAkB;CAAE,MAAM,QAAQ;CAAK,OAAO,QAAQ;AAAI,GAC5B;CAC9B,MAAM,EAAE,UAAU,MAAM,OAAO;CAG/B,MAAM,UAAU,MAAM,MAAM;EAAE,wBAAwB;EAAM,SAAS;EAAuB,eAAe;CAAK,CAAC;CAEjH,aAAA,QAAQ,KAAK,gBAAgB;EAC3B,QAAQ,MAAM;CAChB,CAAC;CACD,aAAA,QAAQ,KAAK,iBAAiB;EAC5B,QAAQ,MAAM;CA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AAS,CAAC,SAAS,CAAC,WACvB,eAAA,OAAO;EAGT,IAAI,WACF,aAAA,QAAQ,KAAK,CAAC;CAElB,SAAS,OAAO;EACd,MAAM,MAAM,SAAS,cAAc,EAAE,OAAOA,eAAAA,QAAQ,KAAK,EAAE,CAAC;EAC5D,aAAA,QAAQ,KAAK,CAAC;CAChB;AACF"}
@@ -1,32 +1,28 @@
1
- const require_rolldown_runtime = require("./rolldown-runtime-qbf5tadS.cjs");
2
- const require_errors = require("./errors-C-wEou02.cjs");
3
- const require_Telemetry = require("./Telemetry-DDHXBdEz.cjs");
4
- const require_package = require("./package-Do9rJ7D3.cjs");
1
+ const require_agent = require("./agent-DElUuYuy.cjs");
2
+ const require_errors = require("./errors-CMbMAwyW.cjs");
3
+ const require_Telemetry = require("./Telemetry-bGdFBaGt.cjs");
5
4
  let node_util = require("node:util");
6
5
  let node_process = require("node:process");
7
- node_process = require_rolldown_runtime.__toESM(node_process, 1);
6
+ node_process = require_agent.__toESM(node_process, 1);
8
7
  //#region src/runners/validate/run.ts
9
8
  /**
10
9
  * Validates an OpenAPI/Swagger file at `input` using `@kubb/adapter-oas`.
11
10
  * Exits the process with code 1 on validation failure or missing dependency.
12
11
  */
13
- async function run({ input, version }) {
14
- const hrStart = node_process.default.hrtime();
15
- const report = (status) => require_Telemetry.sendTelemetry(require_Telemetry.buildTelemetryEvent({
12
+ async function run({ input }) {
13
+ const report = require_Telemetry.trackRun({
16
14
  command: "validate",
17
- kubbVersion: version,
18
- hrStart,
19
- status
20
- }));
15
+ hrStart: node_process.default.hrtime()
16
+ });
21
17
  try {
22
18
  const { adapterOas } = await import("@kubb/adapter-oas");
23
19
  const adapter = adapterOas();
24
20
  if (!adapter.validate) throw new Error("The loaded adapter does not support validation.");
25
21
  await adapter.validate(input, { throwOnError: true });
26
- await report("success");
22
+ await report({ status: "success" });
27
23
  console.log("✅ Validation success");
28
24
  } catch (error) {
29
- await report("failed");
25
+ await report({ status: "failed" });
30
26
  if (error instanceof Error && /@kubb\/adapter-oas/.test(error.message)) {
31
27
  console.error((0, node_util.styleText)("red", "The @kubb/adapter-oas package is not installed."));
32
28
  console.error("");
@@ -41,17 +37,7 @@ async function run({ input, version }) {
41
37
  node_process.default.exit(1);
42
38
  }
43
39
  }
44
- /**
45
- * Loaded on demand by `index.ts`, so `@kubb/adapter-oas` stays out of the process for every other
46
- * command.
47
- */
48
- const runner = async ({ values }) => {
49
- await run({
50
- input: values.input,
51
- version: require_package.version
52
- });
53
- };
54
40
  //#endregion
55
- exports.runner = runner;
41
+ exports.run = run;
56
42
 
57
- //# sourceMappingURL=run-CZz_GbE4.cjs.map
43
+ //# sourceMappingURL=run-yvuot2N9.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-yvuot2N9.cjs","names":["trackRun","process","styleText","toError"],"sources":["../src/runners/validate/run.ts"],"sourcesContent":["import process from 'node:process'\nimport { styleText } from 'node:util'\nimport { toError } from '@internals/utils'\nimport { trackRun } from '../../Telemetry.ts'\n\ntype ValidateOptions = {\n /**\n * Path or URL to the OpenAPI/Swagger file to validate.\n */\n input: string\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 }: ValidateOptions): Promise<void> {\n const report = trackRun({ command: 'validate', hrStart: process.hrtime() })\n\n try {\n const { adapterOas } = await import('@kubb/adapter-oas')\n\n const adapter = adapterOas()\n if (!adapter.validate) {\n throw new Error('The loaded adapter does not support validation.')\n }\n\n await adapter.validate(input, { throwOnError: true })\n await report({ status: 'success' })\n\n console.log('✅ Validation success')\n } catch (error) {\n await report({ status: '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(toError(error).message)\n\n process.exit(1)\n }\n}\n"],"mappings":";;;;;;;;;;;AAgBA,eAAsB,IAAI,EAAE,SAAyC;CACnE,MAAM,SAASA,kBAAAA,SAAS;EAAE,SAAS;EAAY,SAASC,aAAAA,QAAQ,OAAO;CAAE,CAAC;CAE1E,IAAI;EACF,MAAM,EAAE,eAAe,MAAM,OAAO;EAEpC,MAAM,UAAU,WAAW;EAC3B,IAAI,CAAC,QAAQ,UACX,MAAM,IAAI,MAAM,iDAAiD;EAGnE,MAAM,QAAQ,SAAS,OAAO,EAAE,cAAc,KAAK,CAAC;EACpD,MAAM,OAAO,EAAE,QAAQ,UAAU,CAAC;EAElC,QAAQ,IAAI,sBAAsB;CACpC,SAAS,OAAO;EACd,MAAM,OAAO,EAAE,QAAQ,SAAS,CAAC;EACjC,IAAI,iBAAiB,SAAS,qBAAqB,KAAK,MAAM,OAAO,GAAG;GACtE,QAAQ,OAAA,GAAMC,UAAAA,UAAAA,CAAU,OAAO,iDAAiD,CAAC;GACjF,QAAQ,MAAM,EAAE;GAChB,QAAQ,MAAM,kBAAkB;GAChC,QAAQ,OAAA,GAAMA,UAAAA,UAAAA,CAAU,QAAQ,iCAAiC,CAAC;GAClE,QAAQ,OAAA,GAAMA,UAAAA,UAAAA,CAAU,QAAQ,QAAQ,CAAC;GACzC,QAAQ,OAAA,GAAMA,UAAAA,UAAAA,CAAU,QAAQ,kCAAkC,CAAC;GACnE,QAAQ,MAAM,EAAE;EAClB;EACA,QAAQ,MAAM,qBAAqB;EACnC,QAAQ,MAAMC,eAAAA,QAAQ,KAAK,CAAC,CAAC,OAAO;EAEpC,aAAA,QAAQ,KAAK,CAAC;CAChB;AACF"}
@@ -1,7 +1,7 @@
1
1
  import "./rolldown-runtime-CRm0XQPb.js";
2
- import { d as read, n as createStudioOptions, o as run, r as loadConfigs, u as exists } from "./run-BDaZPU-1.js";
3
- import { c as createPlainLogger, f as setupReporters } from "./utils-C3HZOWL_.js";
4
- import { r as logBlock } from "./output-FDo-db-w.js";
2
+ import { d as exists, f as read, i as loadConfigs, n as createStudioOptions, s as run } from "./run-Dgph0WYk.js";
3
+ import { r as setupReporters } from "./config-8Xl4yZmw.js";
4
+ import { h as createPlainLogger, r as logBlock } from "./output-B6Ondw0g.js";
5
5
  import { styleText } from "node:util";
6
6
  import { randomUUID } from "node:crypto";
7
7
  import process from "node:process";
@@ -242,7 +242,7 @@ async function snapshot(options) {
242
242
  permissions: options.permission,
243
243
  loadConfig: async () => (await loadConfigs(options)).config,
244
244
  installLogger: async (hooks) => {
245
- await setupReporters(hooks, {
245
+ setupReporters(hooks, {
246
246
  logLevel: logLevel$1,
247
247
  reporters: [cliReporter],
248
248
  logger
@@ -324,4 +324,4 @@ const runner = async ({ values }) => {
324
324
  //#endregion
325
325
  export { runner };
326
326
 
327
- //# sourceMappingURL=snapshot-B5mc4gpC.js.map
327
+ //# sourceMappingURL=snapshot-CkHXR0Nl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snapshot-CkHXR0Nl.js","names":["logLevel","logLevelMap"],"sources":["../src/runners/studio/ci.ts","../src/runners/studio/snapshot.ts"],"sourcesContent":["import { readFileSync } from 'node:fs'\nimport process from 'node:process'\n\n/**\n * Stable identity for the CI agent a snapshot run registers or reuses.\n */\nexport type CiContext = {\n /**\n * Fed into the machine token, so the same merge or pull request reuses one agent.\n */\n id: string\n /**\n * Agent display name shown in Studio.\n */\n name: string\n /** The commit this run builds, so the next snapshot can diff against it. */\n commit?: string\n /** The branch a pull request merges into, and the `id` runs on that branch register under. */\n base?: { branch: string; id: string }\n}\n\ntype GithubPullRequest = { number: number; head?: { sha?: string }; base?: { ref?: string } }\n\nfunction readGithubPullRequest(eventPath: string | undefined): GithubPullRequest | undefined {\n if (!eventPath) {\n return undefined\n }\n\n try {\n const event = JSON.parse(readFileSync(eventPath, 'utf8')) as { pull_request?: GithubPullRequest }\n return event.pull_request?.number ? event.pull_request : undefined\n } catch {\n return undefined\n }\n}\n\n/** Reproduces GitLab's `CI_COMMIT_REF_SLUG` for a branch it gives no slug of, like a merge request's target. */\nexport function gitlabRefSlug(ref: string): string {\n return ref\n .toLowerCase()\n .replace(/[^a-z0-9]/gu, '-')\n .slice(0, 63)\n .replace(/^-+|-+$/g, '')\n}\n\n/**\n * Detects the CI provider from its environment variables and derives a stable identity from it.\n * The GitHub row reproduces `gh:<repositoryId>:<prNumber>`, the identity `kubb-labs/action` has\n * always registered agents under, so an existing repository keeps reusing its agent.\n */\nexport function detectCi(env: Record<string, string | undefined> = process.env): CiContext | null {\n if (env.GITHUB_ACTIONS) {\n const pullRequest = readGithubPullRequest(env.GITHUB_EVENT_PATH)\n const repositoryId = env.GITHUB_REPOSITORY_ID ?? env.GITHUB_REPOSITORY ?? ''\n const branch = env.GITHUB_REF?.startsWith('refs/heads/') ? env.GITHUB_REF.slice('refs/heads/'.length) : undefined\n // A branch run is scoped by its ref, which a pull request number never collides with.\n const scope = pullRequest?.number ?? (branch ? `refs/heads/${branch}` : env.GITHUB_RUN_ID) ?? ''\n const baseBranch = pullRequest?.base?.ref\n\n return {\n id: `gh:${repositoryId}:${scope}`,\n name: `${env.GITHUB_REPOSITORY ?? 'github'}#${pullRequest?.number ?? branch ?? scope}`,\n // The head commit, not the merge commit a pull request run checks out.\n commit: pullRequest?.head?.sha ?? env.GITHUB_SHA,\n base: baseBranch ? { branch: baseBranch, id: `gh:${repositoryId}:refs/heads/${baseBranch}` } : undefined,\n }\n }\n\n if (env.GITLAB_CI) {\n const scope = env.CI_MERGE_REQUEST_IID ?? env.CI_COMMIT_REF_SLUG ?? ''\n const baseBranch = env.CI_MERGE_REQUEST_TARGET_BRANCH_NAME\n\n return {\n id: `gl:${env.CI_PROJECT_ID ?? ''}:${scope}`,\n name: `${env.CI_PROJECT_PATH ?? 'gitlab'}#${scope}`,\n commit: env.CI_MERGE_REQUEST_SOURCE_BRANCH_SHA || env.CI_COMMIT_SHA,\n base: baseBranch ? { branch: baseBranch, id: `gl:${env.CI_PROJECT_ID ?? ''}:${gitlabRefSlug(baseBranch)}` } : undefined,\n }\n }\n\n if (env.BITBUCKET_BUILD_NUMBER) {\n const scope = env.BITBUCKET_PR_ID ?? env.BITBUCKET_BRANCH ?? ''\n\n return { id: `bb:${env.BITBUCKET_REPO_UUID ?? ''}:${scope}`, name: `${env.BITBUCKET_REPO_FULL_NAME ?? 'bitbucket'}#${scope}`, commit: env.BITBUCKET_COMMIT }\n }\n\n if (env.CIRCLECI) {\n // Owner-qualified: two projects with the same name under different CircleCI orgs must not\n // collide on one agent, since registering it purges the other project's live sessions.\n const owner = env.CIRCLE_PROJECT_USERNAME ?? ''\n const project = env.CIRCLE_PROJECT_REPONAME ?? 'circleci'\n const scope = env.CIRCLE_PR_NUMBER ?? env.CIRCLE_BRANCH ?? ''\n\n return { id: `circle:${owner}:${project}:${scope}`, name: `${owner ? `${owner}/` : ''}${project}#${scope}`, commit: env.CIRCLE_SHA1 }\n }\n\n return null\n}\n","import { randomUUID } from 'node:crypto'\nimport { dirname, join } from 'node:path'\nimport process from 'node:process'\nimport { styleText } from 'node:util'\nimport { exists, read } from '@internals/utils'\nimport { cliReporter, logLevel as logLevelMap } from '@kubb/core'\nimport {\n createAgent,\n createJob,\n machineTokenFrom,\n runConnection,\n waitForJob,\n type StudioBranchSnapshotChanges,\n type StudioSnapshot,\n type StudioSnapshotChanges,\n} from '@kubb/studio'\nimport { logBlock } from '../../loggers/output.ts'\nimport { createPlainLogger } from '../../loggers/plainLogger.ts'\nimport setupReporters from '../../loggers/reporters.ts'\nimport { type CiContext, detectCi } from './ci.ts'\nimport { createStudioOptions, loadConfigs, run, type SnapshotOptions } from './run.ts'\nimport type { command } from '../../commands/studio/snapshot.ts'\nimport type { CommandRunner } from 'gunshi'\n\n/**\n * How long to wait for Studio's `studio:ready` acknowledgement, above the client's own 10s\n * handshake-ack timeout.\n */\nconst READY_TIMEOUT_MS = 15_000\n\n/**\n * Longest `--timeout` accepted. Job records expire from Studio's storage after an hour.\n */\nconst MAX_TIMEOUT_SECONDS = 3600\n\nconst LOOPBACK_HOSTS = new Set(['localhost', '127.0.0.1', '::1'])\n\nasync function findPackageJson(startDirectory: string): Promise<{ name: string; version: string }> {\n let directory = startDirectory\n\n for (;;) {\n const file = join(directory, 'package.json')\n\n if (await exists(file)) {\n const packageJson = JSON.parse(await read(file)) as Partial<{ name: string; version: string }>\n\n if (packageJson.name && packageJson.version) {\n return { name: packageJson.name, version: packageJson.version }\n }\n }\n\n const parent = dirname(directory)\n\n if (parent === directory) {\n break\n }\n\n directory = parent\n }\n\n throw new Error(`No package.json with a name and a version found above ${startDirectory}`)\n}\n\n/** Reads package.json only for whichever of name/version --name and --version did not supply. */\nasync function resolvePackageMetadata(options: SnapshotOptions): Promise<{ name: string; version: string }> {\n if (options.name && options.packageVersion) {\n return { name: options.name, version: options.packageVersion }\n }\n\n const packageMetadata = await findPackageJson(process.cwd())\n\n return { name: options.name ?? packageMetadata.name, version: options.packageVersion ?? packageMetadata.version }\n}\n\nfunction resolveToken(options: SnapshotOptions): string {\n const token = options.token ?? process.env.KUBB_TOKEN\n\n if (!token) {\n throw new Error('An organization CI API key is required. Pass --token or set KUBB_TOKEN.')\n }\n\n return token\n}\n\nfunction resolveCiIdentity(options: SnapshotOptions): CiContext {\n const detected = detectCi()\n // A custom --id drops the detected base, since runs on that branch may use a custom id too.\n const ci = options.id ? { id: options.id, name: detected?.name ?? options.id, commit: detected?.commit } : detected\n\n if (!ci) {\n throw new Error('Could not detect a supported CI provider (GitHub Actions, GitLab CI, Bitbucket Pipelines, CircleCI). Pass --id.')\n }\n\n // An explicit --base-id may not name a branch, so it labels the comparison itself.\n const base = options.baseId ? { branch: options.baseId, id: options.baseId } : ci.base\n\n return { ...ci, base: base?.id === ci.id ? undefined : base }\n}\n\n/** Rejects a bad `--timeout` up front instead of letting it reach `waitForJob` as NaN or <= 0. */\nfunction resolveTimeoutMs(options: SnapshotOptions): number {\n const seconds = options.timeout ?? 600\n\n if (!Number.isFinite(seconds) || seconds <= 0) {\n throw new Error('--timeout must be a positive number of seconds')\n }\n\n return Math.min(seconds, MAX_TIMEOUT_SECONDS) * 1000\n}\n\n/** The CI key is a credential, so refuse to send it anywhere but HTTPS or a loopback dev host. */\nfunction assertSecureStudioUrl(studioUrl: string): void {\n const url = new URL(studioUrl)\n\n if (url.protocol !== 'https:' && !LOOPBACK_HOSTS.has(url.hostname)) {\n throw new Error(`Refusing to send the CI API key to ${studioUrl}. Use an https:// Studio URL, or a loopback host for local development.`)\n }\n}\n\nfunction absoluteUrl(studioUrl: string, path: string): string {\n return new URL(path, `${studioUrl}/`).toString()\n}\n\ntype SnapshotResult = {\n id: string\n name: string | null\n version: string | null\n integrity: string | null\n url: string\n snapshotIdUrl: string\n expiresAt: string\n agentUrl: string\n /** What changed since the previous snapshot of this package on this agent. */\n changes?: StudioSnapshotChanges\n /** What differs from the latest snapshot of the base branch, named by `branch`. */\n branchChanges?: StudioBranchSnapshotChanges & { branch: string }\n}\n\nfunction toResult(studioUrl: string, snapshot: StudioSnapshot, agentSlug: string, ci: CiContext): SnapshotResult {\n return {\n id: snapshot.id,\n name: snapshot.name,\n version: snapshot.version,\n integrity: snapshot.integrity,\n url: absoluteUrl(studioUrl, snapshot.url),\n snapshotIdUrl: absoluteUrl(studioUrl, snapshot.snapshotIdUrl),\n expiresAt: snapshot.expiresAt,\n agentUrl: absoluteUrl(studioUrl, `/agents/${agentSlug}`),\n changes: snapshot.changes,\n branchChanges: snapshot.branchChanges && ci.base ? { ...snapshot.branchChanges, branch: ci.base.branch } : undefined,\n }\n}\n\n/** How many files differ, `against` what. */\nfunction describeChanges(changes: StudioSnapshotChanges, against: string): string {\n const { added, changed, removed } = changes\n\n return added.length + changed.length + removed.length\n ? `${added.length} added, ${changed.length} changed, ${removed.length} removed ${against}`\n : `No changes ${against}`\n}\n\n/** One summary line: how many files changed, and since which run. */\nexport function formatChanges(changes: StudioSnapshotChanges): string {\n if (!changes.base) {\n return 'First snapshot'\n }\n\n return describeChanges(changes, `since ${changes.base.commit?.slice(0, 7) ?? changes.base.createdAt}`)\n}\n\n/** One summary line: how the snapshot differs from the base branch's latest one. */\nexport function formatBranchChanges(changes: StudioBranchSnapshotChanges & { branch: string }): string {\n if (changes.base) return describeChanges(changes, `against ${changes.branch}`)\n\n return changes.baseFound ? `No snapshot of ${changes.branch} for this package yet` : `No snapshot of ${changes.branch} to compare with`\n}\n\nfunction printSummary(result: SnapshotResult): void {\n logBlock([\n `${styleText('dim', 'Package'.padEnd(10))} ${result.name ?? '(unnamed)'}@${result.version ?? '0.0.0'}`,\n `${styleText('dim', 'Tarball'.padEnd(10))} ${styleText('cyan', result.url)}`,\n `${styleText('dim', 'Agent'.padEnd(10))} ${result.agentUrl}`,\n ...(result.branchChanges ? [`${styleText('dim', 'Branch'.padEnd(10))} ${formatBranchChanges(result.branchChanges)}`] : []),\n ...(result.changes ? [`${styleText('dim', 'Changes'.padEnd(10))} ${formatChanges(result.changes)}`] : []),\n `${styleText('dim', 'Expires'.padEnd(10))} ${result.expiresAt}`,\n ])\n}\n\n/**\n * Generates a Kubb Studio snapshot from a script: registers or reuses a CI agent, connects it,\n * queues a snapshot job, and polls until the tarball is ready. A snapshot job runs generation and\n * packs the tarball in one step, so this needs no separate generation run.\n */\nexport async function snapshot(options: SnapshotOptions): Promise<void> {\n const timeoutMs = resolveTimeoutMs(options)\n const token = resolveToken(options)\n assertSecureStudioUrl(options.studioUrl)\n const { configPath } = await loadConfigs(options)\n const ci = resolveCiIdentity(options)\n const { name, version: packageVersion } = await resolvePackageMetadata(options)\n const logLevel = logLevelMap[options.logLevel ?? 'info']\n\n // Set before the first `getMachineToken()` call (inside the connection), so the WebSocket\n // session registers under the same machine token `createAgent` just registered with Studio.\n process.env.KUBB_AGENT_SECRET = ci.id\n\n const write = options.json ? (line: string) => console.error(line) : (line: string) => console.log(line)\n const logger = createPlainLogger(write)\n const step = (message: string) => {\n if (logLevel > logLevelMap.silent) {\n write(message)\n }\n }\n\n step('Creating Kubb Studio agent')\n\n const agent = await createAgent({ studioUrl: options.studioUrl, token, name: ci.name, machineToken: machineTokenFrom(ci.id) })\n // Overlapping runs of one pipeline connect under the same CI agent. Naming this process lets the\n // snapshot job run here, on this run's checkout, and not on another run's.\n const instanceId = randomUUID()\n\n const { promise: ready, resolve: markReady } = Promise.withResolvers<void>()\n const shutdown = new AbortController()\n\n const connection = runConnection({\n credentials: { token: agent.token },\n signal: shutdown.signal,\n clientOptions: () => ({\n studioUrl: options.studioUrl,\n instanceId,\n configPath,\n root: process.cwd(),\n version: options.version,\n // Flags only: a script is never prompted and never reuses a saved answer.\n permissions: options.permission,\n loadConfig: async () => (await loadConfigs(options)).config,\n installLogger: async (hooks) => {\n setupReporters(hooks, { logLevel, reporters: [cliReporter], logger })\n hooks.hook('studio:ready', () => markReady())\n },\n }),\n // A CI agent's token comes from the organization key, so there is no pairing to fall back to.\n onTokenRejected: ({ error }) => Promise.reject(error),\n })\n const connectionLost = new AbortController()\n const connectionEnded = new Error('The Kubb Studio connection ended before the snapshot finished')\n void connection.then(\n () => connectionLost.abort(connectionEnded),\n (error) => connectionLost.abort(error),\n )\n const lost = connection.then(\n () => Promise.reject(connectionEnded),\n (error) => Promise.reject(error),\n )\n void lost.catch(() => {})\n\n try {\n let readyTimeout: ReturnType<typeof setTimeout> | undefined\n try {\n await Promise.race([\n ready,\n lost,\n new Promise<never>((_, reject) => {\n readyTimeout = setTimeout(() => reject(new Error('Timed out waiting for Kubb Studio to confirm the agent was ready')), READY_TIMEOUT_MS)\n }),\n ])\n } finally {\n clearTimeout(readyTimeout)\n }\n\n step('Creating snapshot job')\n\n const snapshotDeadline = Date.now() + timeoutMs\n const snapshotTimeoutMs = () => Math.max(snapshotDeadline - Date.now(), 1)\n\n const job = await createJob({\n studioUrl: options.studioUrl,\n token,\n type: 'snapshot',\n agentId: agent.id,\n instanceId,\n name,\n version: packageVersion,\n commit: ci.commit,\n baseId: ci.base?.id,\n timeoutMs: snapshotTimeoutMs(),\n signal: connectionLost.signal,\n })\n step(`Snapshot job queued: ${job.id}`)\n const finished = await Promise.race([\n waitForJob({\n studioUrl: options.studioUrl,\n token,\n id: job.id,\n timeoutMs: snapshotTimeoutMs(),\n signal: connectionLost.signal,\n }),\n lost,\n ])\n\n if (finished.status === 'failed') {\n throw new Error(finished.error ?? 'Snapshot job failed')\n }\n\n if (!finished.snapshot) {\n throw new Error('Snapshot job succeeded without a snapshot')\n }\n\n const result = toResult(options.studioUrl, finished.snapshot, agent.slug, ci)\n\n step('Snapshot published')\n\n if (options.json) {\n console.log(JSON.stringify(result))\n }\n if (!options.json) {\n printSummary(result)\n }\n } catch (error) {\n step('Snapshot failed')\n throw error\n } finally {\n step('Disconnecting from Kubb Studio')\n // Not awaited: a half-open socket must not hold the run open.\n shutdown.abort()\n }\n}\n\nexport const runner: CommandRunner<{ args: typeof command.args; extensions: {} }> = async ({ values }) => {\n const options: SnapshotOptions = {\n ...createStudioOptions(values),\n token: values.token,\n id: values.id,\n baseId: values.baseId,\n name: values.name,\n packageVersion: values.packageVersion,\n timeout: values.timeout,\n json: values.json,\n }\n await run(options, () => snapshot(options), { json: options.json })\n}\n"],"mappings":";;;;;;;;;;;;AAuBA,SAAS,sBAAsB,WAA8D;CAC3F,IAAI,CAAC,WACH;CAGF,IAAI;EACF,MAAM,QAAQ,KAAK,MAAM,aAAa,WAAW,MAAM,CAAC;EACxD,OAAO,MAAM,cAAc,SAAS,MAAM,eAAe,KAAA;CAC3D,QAAQ;EACN;CACF;AACF;;AAGA,SAAgB,cAAc,KAAqB;CACjD,OAAO,IACJ,YAAY,CAAC,CACb,QAAQ,eAAe,GAAG,CAAC,CAC3B,MAAM,GAAG,EAAE,CAAC,CACZ,QAAQ,YAAY,EAAE;AAC3B;;;;;;AAOA,SAAgB,SAAS,MAA0C,QAAQ,KAAuB;CAChG,IAAI,IAAI,gBAAgB;EACtB,MAAM,cAAc,sBAAsB,IAAI,iBAAiB;EAC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E,OAAO,EAAE,aAAa;CACxG,MAAM,UAA2B;EAC/B,GAAG,oBAAoB,MAAM;EAC7B,OAAO,OAAO;EACd,IAAI,OAAO;EACX,QAAQ,OAAO;EACf,MAAM,OAAO;EACb,gBAAgB,OAAO;EACvB,SAAS,OAAO;EAChB,MAAM,OAAO;CACf;CACA,MAAM,IAAI,eAAe,SAAS,OAAO,GAAG,EAAE,MAAM,QAAQ,KAAK,CAAC;AACpE"}
@@ -1,14 +1,14 @@
1
- const require_rolldown_runtime = require("./rolldown-runtime-qbf5tadS.cjs");
2
- const require_run = require("./run-y6LRyWdS.cjs");
3
- const require_utils = require("./utils-ClRbJfxu.cjs");
4
- const require_output = require("./output-CVLosNZq.cjs");
1
+ const require_agent = require("./agent-DElUuYuy.cjs");
2
+ const require_run = require("./run-D8Wz_17X.cjs");
3
+ const require_output = require("./output-i3s5c4Xu.cjs");
4
+ const require_config = require("./config-ByfJSj3q.cjs");
5
5
  let node_util = require("node:util");
6
6
  let node_crypto = require("node:crypto");
7
7
  let node_process = require("node:process");
8
- node_process = require_rolldown_runtime.__toESM(node_process, 1);
8
+ node_process = require_agent.__toESM(node_process, 1);
9
9
  let node_path = require("node:path");
10
- let node_fs = require("node:fs");
11
10
  let _kubb_core = require("@kubb/core");
11
+ let node_fs = require("node:fs");
12
12
  let _kubb_studio = require("@kubb/studio");
13
13
  //#region src/runners/studio/ci.ts
14
14
  function readGithubPullRequest(eventPath) {
@@ -217,7 +217,7 @@ async function snapshot(options) {
217
217
  const logLevel = _kubb_core.logLevel[options.logLevel ?? "info"];
218
218
  node_process.default.env.KUBB_AGENT_SECRET = ci.id;
219
219
  const write = options.json ? (line) => console.error(line) : (line) => console.log(line);
220
- const logger = require_utils.createPlainLogger(write);
220
+ const logger = require_output.createPlainLogger(write);
221
221
  const step = (message) => {
222
222
  if (logLevel > _kubb_core.logLevel.silent) write(message);
223
223
  };
@@ -243,7 +243,7 @@ async function snapshot(options) {
243
243
  permissions: options.permission,
244
244
  loadConfig: async () => (await require_run.loadConfigs(options)).config,
245
245
  installLogger: async (hooks) => {
246
- await require_utils.setupReporters(hooks, {
246
+ require_config.setupReporters(hooks, {
247
247
  logLevel,
248
248
  reporters: [_kubb_core.cliReporter],
249
249
  logger
@@ -325,4 +325,4 @@ const runner = async ({ values }) => {
325
325
  //#endregion
326
326
  exports.runner = runner;
327
327
 
328
- //# sourceMappingURL=snapshot-DnCxZfmM.cjs.map
328
+ //# sourceMappingURL=snapshot-D4nKbwkw.cjs.map