@kubb/cli 5.11.4 → 5.11.6

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 (100) hide show
  1. package/dist/{Telemetry-Be1nltUh.cjs → Telemetry-Be3hIy6_.cjs} +2 -42
  2. package/dist/Telemetry-Be3hIy6_.cjs.map +1 -0
  3. package/dist/{Telemetry-CwaVQsvD.js → Telemetry-CfJAUDnh.js} +3 -31
  4. package/dist/Telemetry-CfJAUDnh.js.map +1 -0
  5. package/dist/{background-CQPyCSn0.js → background-BBpH2jmk.js} +7 -5
  6. package/dist/background-BBpH2jmk.js.map +1 -0
  7. package/dist/{background-mKdZ5HRx.cjs → background-BW-e9FCX.cjs} +5 -4
  8. package/dist/background-BW-e9FCX.cjs.map +1 -0
  9. package/dist/{background-aTbwrgui.js → background-DS2zOde-.js} +1 -1
  10. package/dist/config-Bh00Hwpw.js +132 -0
  11. package/dist/config-Bh00Hwpw.js.map +1 -0
  12. package/dist/config-D63Gum4F.cjs +169 -0
  13. package/dist/config-D63Gum4F.cjs.map +1 -0
  14. package/dist/config-iVdOcpro.js +1 -0
  15. package/dist/credentials-CZK6zPLv.js.map +1 -1
  16. package/dist/credentials-DDaKqtJn.cjs.map +1 -1
  17. package/dist/errors-Cl69p_vI.cjs +43 -0
  18. package/dist/errors-Cl69p_vI.cjs.map +1 -0
  19. package/dist/errors-DmC83ALX.js +32 -0
  20. package/dist/errors-DmC83ALX.js.map +1 -0
  21. package/dist/index.cjs +872 -307
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.js +863 -298
  24. package/dist/index.js.map +1 -1
  25. package/dist/registry-BlKLO4ft.cjs +272 -0
  26. package/dist/registry-BlKLO4ft.cjs.map +1 -0
  27. package/dist/registry-CgQYxUju.js +200 -0
  28. package/dist/registry-CgQYxUju.js.map +1 -0
  29. package/dist/reporters-Dl8lrJZG.js +817 -0
  30. package/dist/reporters-Dl8lrJZG.js.map +1 -0
  31. package/dist/reporters-TkCgd4dS.cjs +829 -0
  32. package/dist/reporters-TkCgd4dS.cjs.map +1 -0
  33. package/dist/{run-YHth5Afz.js → run-BJn0RSW2.js} +170 -76
  34. package/dist/run-BJn0RSW2.js.map +1 -0
  35. package/dist/{run-BWRmQxtE.cjs → run-BszyZwY3.cjs} +176 -82
  36. package/dist/run-BszyZwY3.cjs.map +1 -0
  37. package/dist/{run-Bczs5vbI.cjs → run-BtVKUjdK.cjs} +4 -3
  38. package/dist/{run-Bczs5vbI.cjs.map → run-BtVKUjdK.cjs.map} +1 -1
  39. package/dist/run-CFf0yxyY.cjs +94 -0
  40. package/dist/run-CFf0yxyY.cjs.map +1 -0
  41. package/dist/run-D_dD7xHp.js +93 -0
  42. package/dist/run-D_dD7xHp.js.map +1 -0
  43. package/dist/run-DsJJCzQD.js +1 -0
  44. package/dist/{run-B6VxJ_VM.js → run-KuzAqsjg.js} +3 -2
  45. package/dist/{run-B6VxJ_VM.js.map → run-KuzAqsjg.js.map} +1 -1
  46. package/dist/run-TrjCNL8e.cjs +227 -0
  47. package/dist/run-TrjCNL8e.cjs.map +1 -0
  48. package/dist/run-wkN1irUo.js +224 -0
  49. package/dist/run-wkN1irUo.js.map +1 -0
  50. package/dist/{snapshot-Cilp10vE.js → snapshot-CdGwHH15.js} +49 -62
  51. package/dist/snapshot-CdGwHH15.js.map +1 -0
  52. package/dist/{snapshot-D_rXnnMH.cjs → snapshot-u4L8mh4Y.cjs} +51 -64
  53. package/dist/snapshot-u4L8mh4Y.cjs.map +1 -0
  54. package/dist/status-DHPeR3bq.js +77 -0
  55. package/dist/status-DHPeR3bq.js.map +1 -0
  56. package/dist/status-dpSvxxtN.cjs +78 -0
  57. package/dist/status-dpSvxxtN.cjs.map +1 -0
  58. package/dist/studioWorker.js +2 -2
  59. package/dist/summary-6-rotl2L.cjs +46 -0
  60. package/dist/summary-6-rotl2L.cjs.map +1 -0
  61. package/dist/summary-DkSLti6f.js +41 -0
  62. package/dist/summary-DkSLti6f.js.map +1 -0
  63. package/dist/text-CMP4M19Z.js +239 -0
  64. package/dist/text-CMP4M19Z.js.map +1 -0
  65. package/dist/text-CknhKMvM.cjs +341 -0
  66. package/dist/text-CknhKMvM.cjs.map +1 -0
  67. package/dist/utils-CnjEJIdZ.js +612 -0
  68. package/dist/utils-CnjEJIdZ.js.map +1 -0
  69. package/dist/utils-DpKrXR2t.cjs +727 -0
  70. package/dist/utils-DpKrXR2t.cjs.map +1 -0
  71. package/package.json +7 -7
  72. package/dist/Telemetry-Be1nltUh.cjs.map +0 -1
  73. package/dist/Telemetry-CwaVQsvD.js.map +0 -1
  74. package/dist/background-CQPyCSn0.js.map +0 -1
  75. package/dist/background-mKdZ5HRx.cjs.map +0 -1
  76. package/dist/config-B56ZuVhi.js +0 -95
  77. package/dist/config-B56ZuVhi.js.map +0 -1
  78. package/dist/config-Cs4N79Fm.cjs +0 -113
  79. package/dist/config-Cs4N79Fm.cjs.map +0 -1
  80. package/dist/output-HgzJqkSF.cjs +0 -1076
  81. package/dist/output-HgzJqkSF.cjs.map +0 -1
  82. package/dist/output-PhkPtNP7.js +0 -937
  83. package/dist/output-PhkPtNP7.js.map +0 -1
  84. package/dist/registry-DYUhC7rH.js +0 -115
  85. package/dist/registry-DYUhC7rH.js.map +0 -1
  86. package/dist/registry-tk-v78fd.cjs +0 -157
  87. package/dist/registry-tk-v78fd.cjs.map +0 -1
  88. package/dist/run-AfjIBtiL.js +0 -39
  89. package/dist/run-AfjIBtiL.js.map +0 -1
  90. package/dist/run-BWRmQxtE.cjs.map +0 -1
  91. package/dist/run-B_Gr9TJ4.cjs +0 -345
  92. package/dist/run-B_Gr9TJ4.cjs.map +0 -1
  93. package/dist/run-CwrI0wRy.js +0 -1
  94. package/dist/run-DDoJGjWT.cjs +0 -40
  95. package/dist/run-DDoJGjWT.cjs.map +0 -1
  96. package/dist/run-SYKj8-Q5.js +0 -343
  97. package/dist/run-SYKj8-Q5.js.map +0 -1
  98. package/dist/run-YHth5Afz.js.map +0 -1
  99. package/dist/snapshot-Cilp10vE.js.map +0 -1
  100. package/dist/snapshot-D_rXnnMH.cjs.map +0 -1
@@ -0,0 +1,224 @@
1
+ import "./rolldown-runtime-CRm0XQPb.js";
2
+ import { a as getElapsedMs, i as formatMs, n as trackRun, r as version } from "./Telemetry-CfJAUDnh.js";
3
+ import { a as listenForKeys, c as startWatcher, i as fetchUrlBody, l as trackBuild, s as startUrlWatcher, t as diffBuilds, u as createSpinner } from "./utils-CnjEJIdZ.js";
4
+ import { a as logOutro, d as logStep, i as logIntro, l as logError, m as createPlainWriter, o as logSpacer, s as logTip, t as pluralize, u as logInfo } from "./text-CMP4M19Z.js";
5
+ import { d as logBanner, o as isOutdated } from "./registry-CgQYxUju.js";
6
+ import { t as getConfigs } from "./config-Bh00Hwpw.js";
7
+ import { n as setupReporters, t as selectReporters } from "./reporters-Dl8lrJZG.js";
8
+ import { styleText } from "node:util";
9
+ import process from "node:process";
10
+ import path from "node:path";
11
+ import { Diagnostics, Hookable, cliReporter, createKubb, fileReporter, getInputKind, htmlReporter, jsonReporter, logLevel, memoryStorage } from "@kubb/core";
12
+ //#region src/runners/generate/run.ts
13
+ /** NPM registry endpoint used to check for @kubb/cli updates. */
14
+ const KUBB_NPM_PACKAGE_URL = "https://registry.npmjs.org/@kubb/cli/latest";
15
+ /** Upper bound in milliseconds for the npm update check, so a slow registry never stalls a run. */
16
+ const UPDATE_CHECK_TIMEOUT_MS = 3e3;
17
+ async function generate(options) {
18
+ const { input, hooks, dryRun = false } = options;
19
+ const report = trackRun({
20
+ command: "generate",
21
+ hrStart: process.hrtime()
22
+ });
23
+ const config = {
24
+ ...options.config,
25
+ input: input ?? options.config.input,
26
+ storage: dryRun ? memoryStorage() : options.config.storage,
27
+ output: dryRun ? {
28
+ ...options.config.output,
29
+ format: false,
30
+ lint: false,
31
+ postGenerate: []
32
+ } : options.config.output
33
+ };
34
+ const kubb = createKubb(config, { hooks });
35
+ const result = await kubb.generate();
36
+ await report({
37
+ plugins: kubb.config.plugins.flatMap((p) => p && typeof p === "object" ? [{
38
+ name: p.meta?.name ?? p.name ?? "",
39
+ options: p.options ?? {}
40
+ }] : []),
41
+ filesCreated: result.files.length,
42
+ status: result.success ? "success" : "failed"
43
+ });
44
+ return result.success;
45
+ }
46
+ /** The latest published version, `undefined` when the registry does not answer in time. Never rejects. */
47
+ async function fetchLatestVersion() {
48
+ try {
49
+ return (await (await fetch(KUBB_NPM_PACKAGE_URL, { signal: AbortSignal.timeout(UPDATE_CHECK_TIMEOUT_MS) })).json()).version;
50
+ } catch {
51
+ return;
52
+ }
53
+ }
54
+ async function checkForUpdate({ hooks, latest }) {
55
+ const latestVersion = await latest;
56
+ if (latestVersion && isOutdated({
57
+ installed: version,
58
+ latest: latestVersion
59
+ })) await Diagnostics.emit(hooks, Diagnostics.update({
60
+ currentVersion: version,
61
+ latestVersion
62
+ }));
63
+ }
64
+ /** Prints `Rebuilt in 1.2s · +1 schema -2 operations`, without the names part when the spec kept the same names. */
65
+ function logRebuild({ diff: { schemas, operations }, durationMs }) {
66
+ const specChange = [
67
+ schemas.added && styleText("green", `+${pluralize(schemas.added, "schema")}`),
68
+ schemas.removed && styleText("red", `-${pluralize(schemas.removed, "schema")}`),
69
+ operations.added && styleText("green", `+${pluralize(operations.added, "operation")}`),
70
+ operations.removed && styleText("red", `-${pluralize(operations.removed, "operation")}`)
71
+ ].filter(Boolean).join(" ");
72
+ logStep([`Rebuilt in ${formatMs(durationMs)}`, specChange].filter(Boolean).join(styleText("dim", " · ")));
73
+ }
74
+ /**
75
+ * Runs the full Kubb generation lifecycle for the given CLI options.
76
+ * Loads configs, sets up the reporters (CLI `--reporter` picks which of `config.reporters` to trigger),
77
+ * checks for a newer version, and calls `generate` for each config entry.
78
+ */
79
+ async function run({ input, configPath, logLevel: logLevelKey, watch, reporters: cliReporters, dryRun }) {
80
+ const latest = fetchLatestVersion();
81
+ const logLevel$1 = logLevel[logLevelKey] ?? logLevel.info;
82
+ const hooks = new Hookable();
83
+ const requestedNames = cliReporters?.length ? cliReporters : ["cli"];
84
+ const json = requestedNames.includes("json");
85
+ const quiet = logLevel$1 <= logLevel.silent || json;
86
+ const errorHooks = json ? new Hookable() : hooks;
87
+ if (json) setupReporters(errorHooks, {
88
+ logLevel: logLevel$1,
89
+ reporters: [cliReporter],
90
+ writer: createPlainWriter(console.error)
91
+ });
92
+ const banner = quiet ? void 0 : logBanner(version);
93
+ const loading = getConfigs({
94
+ configPath,
95
+ input,
96
+ watch,
97
+ logLevel: logLevelKey
98
+ });
99
+ loading.catch(() => void 0);
100
+ await banner;
101
+ if (!quiet) logIntro({ title: "Configuration" });
102
+ const configSpinner = createSpinner();
103
+ let configs;
104
+ let resolvedConfigPath;
105
+ try {
106
+ if (!quiet) configSpinner.start("Loading config");
107
+ const loaded = await loading;
108
+ configs = loaded.configs;
109
+ resolvedConfigPath = loaded.configPath;
110
+ if (!quiet) configSpinner.stop(`Loaded ${styleText("dim", path.relative(process.cwd(), resolvedConfigPath))}`);
111
+ } catch (error) {
112
+ if (!quiet) configSpinner.error("Config failed loading");
113
+ if (!json) setupReporters(hooks, {
114
+ logLevel: logLevel$1,
115
+ reporters: [cliReporter]
116
+ });
117
+ await Diagnostics.emit(errorHooks, error);
118
+ if (!quiet) logOutro(styleText("red", "✗ Configuration failed"));
119
+ process.exit(1);
120
+ }
121
+ const available = configs[0]?.reporters?.length ? configs[0].reporters : [
122
+ cliReporter,
123
+ jsonReporter,
124
+ fileReporter,
125
+ htmlReporter
126
+ ];
127
+ const reporters = selectReporters(available, requestedNames);
128
+ setupReporters(hooks, {
129
+ logLevel: logLevel$1,
130
+ reporters,
131
+ dryRun
132
+ });
133
+ await hooks.callHook("kubb:lifecycle:start", { version });
134
+ await checkForUpdate({
135
+ hooks,
136
+ latest
137
+ });
138
+ if (!quiet) logOutro(`${pluralize(configs.length, "config")} ready`);
139
+ try {
140
+ let anyFailed = false;
141
+ const tracker = watch ? trackBuild(hooks) : void 0;
142
+ const rebuilds = [];
143
+ let armKeys;
144
+ let queue = Promise.resolve();
145
+ for (const config of configs) {
146
+ const effectiveInput = input ?? config.input;
147
+ const inputKind = typeof effectiveInput === "string" ? getInputKind(effectiveInput) : void 0;
148
+ const watchPath = inputKind === "file" || inputKind === "url" ? effectiveInput : void 0;
149
+ if (watchPath && tracker) {
150
+ const label = styleText("yellow", `Watching ${inputKind === "url" ? watchPath : path.relative(process.cwd(), watchPath)}`);
151
+ let previous;
152
+ const build = async () => {
153
+ const hrStart = process.hrtime();
154
+ const succeeded = await generate({
155
+ input,
156
+ config,
157
+ hooks,
158
+ dryRun
159
+ });
160
+ const snapshot = tracker.take();
161
+ if (previous) logRebuild({
162
+ diff: diffBuilds(previous, snapshot),
163
+ durationMs: getElapsedMs(hrStart)
164
+ });
165
+ previous = snapshot;
166
+ logStep(armKeys ? `${label} ${styleText("dim", "r rebuild · q quit")}` : label);
167
+ armKeys?.();
168
+ if (succeeded) {
169
+ logSpacer();
170
+ logTip();
171
+ }
172
+ };
173
+ let pending = false;
174
+ const rebuild = () => {
175
+ if (pending) return queue;
176
+ pending = true;
177
+ queue = queue.then(() => {
178
+ pending = false;
179
+ return build();
180
+ }).catch((error) => void Diagnostics.emit(errorHooks, error));
181
+ return queue;
182
+ };
183
+ rebuilds.push(rebuild);
184
+ if (!quiet) armKeys ??= listenForKeys({
185
+ rebuild: () => rebuilds.forEach((trigger) => void trigger()),
186
+ quit: (code) => void Promise.resolve(hooks.callHook("kubb:lifecycle:end")).finally(() => process.exit(code))
187
+ });
188
+ const initialBody = inputKind === "url" ? await fetchUrlBody(watchPath) : void 0;
189
+ await rebuild();
190
+ if (inputKind === "url") startUrlWatcher(watchPath, rebuild, {
191
+ log: {
192
+ info: logInfo,
193
+ error: logError
194
+ },
195
+ initialBody
196
+ });
197
+ else await startWatcher([watchPath], rebuild, {
198
+ info: logInfo,
199
+ error: logError
200
+ });
201
+ } else try {
202
+ if (!await generate({
203
+ input,
204
+ config,
205
+ hooks,
206
+ dryRun
207
+ })) anyFailed = true;
208
+ } catch (configError) {
209
+ await Diagnostics.emit(errorHooks, configError);
210
+ anyFailed = true;
211
+ }
212
+ }
213
+ await hooks.callHook("kubb:lifecycle:end");
214
+ if (!quiet && !watch && !anyFailed) logTip();
215
+ if (anyFailed) process.exit(1);
216
+ } catch (error) {
217
+ await Diagnostics.emit(errorHooks, error);
218
+ process.exit(1);
219
+ }
220
+ }
221
+ //#endregion
222
+ export { generate, run };
223
+
224
+ //# sourceMappingURL=run-wkN1irUo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-wkN1irUo.js","names":["logLevel","logLevelMap"],"sources":["../src/runners/generate/run.ts"],"sourcesContent":["import path from 'node:path'\nimport process from 'node:process'\nimport { styleText } from 'node:util'\nimport { formatMs, formatters, getElapsedMs, linters } 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 '../../ui/text.ts'\nimport setupReporters, { selectReporters } from '../../loggers/reporters.ts'\nimport { createPlainWriter } from '../../loggers/plainWriter.ts'\nimport { logIntro, logOutro, logSpacer, logTip } from '../../ui/intro.ts'\nimport { logError, logInfo, logStep } from '../../ui/log.ts'\nimport { logBanner } from '../../ui/mascot.ts'\nimport { createSpinner } from '../../ui/spinner.ts'\nimport { getConfigs } from '../../config.ts'\nimport { isOutdated } from '../../utils/registry.ts'\nimport { type BuildDiff, type BuildSnapshot, diffBuilds, fetchUrlBody, listenForKeys, startUrlWatcher, startWatcher, trackBuild } 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, skips formatting, linting, and\n * post-generate commands, and prints what would change on disk.\n */\n dryRun?: boolean\n}\n\nexport async 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 await report({\n // A setup that threw leaves no driver, so read the configured plugins instead.\n plugins: kubb.config.plugins.flatMap((p) =>\n p && typeof p === 'object' ? [{ name: p.meta?.name ?? p.name ?? '', options: (p.options ?? {}) as Record<string, unknown> }] : [],\n ),\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\n/** The latest published version, `undefined` when the registry does not answer in time. Never rejects. */\nasync function fetchLatestVersion(): Promise<string | undefined> {\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 return data.version\n } catch {\n // Ignore network errors\n return undefined\n }\n}\n\nasync function checkForUpdate({ hooks, latest }: { hooks: Hookable<KubbHooks>; latest: Promise<string | undefined> }): Promise<void> {\n const latestVersion = await latest\n if (latestVersion && isOutdated({ installed: version, latest: latestVersion })) {\n await Diagnostics.emit(hooks, Diagnostics.update({ currentVersion: version, latestVersion }))\n }\n}\n\n/** Prints `Rebuilt in 1.2s · +1 schema -2 operations`, without the names part when the spec kept the same names. */\nfunction logRebuild({ diff: { schemas, operations }, durationMs }: { diff: BuildDiff; durationMs: number }): void {\n const specChange = [\n schemas.added && styleText('green', `+${pluralize(schemas.added, 'schema')}`),\n schemas.removed && styleText('red', `-${pluralize(schemas.removed, 'schema')}`),\n operations.added && styleText('green', `+${pluralize(operations.added, 'operation')}`),\n operations.removed && styleText('red', `-${pluralize(operations.removed, 'operation')}`),\n ]\n .filter(Boolean)\n .join(' ')\n logStep([`Rebuilt in ${formatMs(durationMs)}`, specChange].filter(Boolean).join(styleText('dim', ' · ')))\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 // Started first so the registry request overlaps the banner and the config load.\n const latest = fetchLatestVersion()\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 json = requestedNames.includes('json')\n const quiet = logLevel <= logLevelMap.silent || json\n\n // Errors raised outside a build have no report entry. In `json` mode they go to a stderr logger,\n // so they are never silent and stdout stays one JSON document.\n const errorHooks = json ? new Hookable<KubbHooks>() : hooks\n if (json) setupReporters(errorHooks, { logLevel, reporters: [cliReporter], writer: createPlainWriter(console.error) })\n\n // The config loads while the banner plays; the output still prints in order once the banner is done.\n const banner = quiet ? undefined : logBanner(version)\n const loading = getConfigs({\n configPath,\n input,\n watch,\n logLevel: logLevelKey as CLIOptions['logLevel'],\n })\n // Handled below; this keeps a rejection during the banner from counting as unhandled.\n loading.catch(() => undefined)\n await banner\n\n if (!quiet) {\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 loading\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 if (!json) setupReporters(hooks, { logLevel, reporters: [cliReporter] })\n // A diagnostic thrown while the config file runs, such as invalid extension options, sits in the cause chain.\n await Diagnostics.emit(errorHooks, 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, dryRun })\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, latest })\n\n if (!quiet) logOutro(`${pluralize(configs.length, 'config')} ready`)\n\n try {\n let anyFailed = false\n // One tracker, one key listener and one build queue serve every watched config, so several configs never mix diffs or answer `r` twice.\n const tracker = watch ? trackBuild(hooks) : undefined\n const rebuilds: Array<() => Promise<void>> = []\n let armKeys: (() => void) | undefined\n // Configs share the hooks emitter, so every build, from any watcher or the `r` key, waits for the one before it.\n let queue = Promise.resolve()\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 && tracker) {\n const label = styleText('yellow', `Watching ${inputKind === 'url' ? watchPath : path.relative(process.cwd(), watchPath)}`)\n let previous: BuildSnapshot | undefined\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 () => {\n const hrStart = process.hrtime()\n const succeeded = await generate({ input, config, hooks, dryRun })\n const snapshot = tracker.take()\n if (previous) logRebuild({ diff: diffBuilds(previous, snapshot), durationMs: getElapsedMs(hrStart) })\n previous = snapshot\n\n logStep(armKeys ? `${label} ${styleText('dim', 'r rebuild · q quit')}` : label)\n armKeys?.()\n if (succeeded) {\n logSpacer()\n logTip()\n }\n }\n // A trigger that lands while this config's build is queued joins it; one that lands during the build queues one more. Never rejects.\n let pending = false\n const rebuild = (): Promise<void> => {\n if (pending) return queue\n pending = true\n queue = queue\n .then(() => {\n pending = false\n return build()\n })\n .catch((error) => void Diagnostics.emit(errorHooks, error))\n return queue\n }\n rebuilds.push(rebuild)\n if (!quiet) {\n armKeys ??= listenForKeys({\n rebuild: () => rebuilds.forEach((trigger) => void trigger()),\n quit: (code) => void Promise.resolve(hooks.callHook('kubb:lifecycle:end')).finally(() => process.exit(code)),\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 await rebuild()\n\n if (inputKind === 'url') {\n startUrlWatcher(watchPath, rebuild, { log: { info: logInfo, error: logError }, initialBody })\n } else {\n await startWatcher([watchPath], rebuild, { 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 Diagnostics.emit(errorHooks, 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 Diagnostics.emit(errorHooks, error)\n process.exit(1)\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAkCA,MAAM,uBAAuB;;AAG7B,MAAM,0BAA0B;AAqBhC,eAAsB,SAAS,SAA0C;CACvE,MAAM,EAAE,OAAO,OAAO,SAAS,UAAU;CAEzC,MAAM,SAAS,SAAS;EAAE,SAAS;EAAY,SAAS,QAAQ,OAAO;CAAE,CAAC;CAE1E,MAAM,SAAiB;EACrB,GAAG,QAAQ;EACX,OAAO,SAAS,QAAQ,OAAO;EAE/B,SAAS,SAAS,cAAc,IAAI,QAAQ,OAAO;EAEnD,QAAQ,SAAS;GAAE,GAAG,QAAQ,OAAO;GAAQ,QAAQ;GAAO,MAAM;GAAO,cAAc,CAAC;EAAE,IAAI,QAAQ,OAAO;CAC/G;CAIA,MAAM,OAAO,WAAW,QAAQ,EAAE,MAAM,CAAC;CACzC,MAAM,SAAS,MAAM,KAAK,SAAS;CAEnC,MAAM,OAAO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gBAA+B;KACnC,IAAI,SAAS,OAAO;KACpB,UAAU;KACV,QAAQ,MACL,WAAW;MACV,UAAU;MACV,OAAO,MAAM;KACf,CAAC,CAAC,CACD,OAAO,UAAU,KAAK,YAAY,KAAK,YAAY,KAAK,CAAC;KAC5D,OAAO;IACT;IACA,SAAS,KAAK,OAAO;IACrB,IAAI,CAAC,OACH,YAAY,cAAc;KACxB,eAAe,SAAS,SAAS,YAAY,KAAK,QAAQ,CAAC;KAC3D,OAAO,SAAS,KAAK,QAAQ,QAAQ,MAAM,SAAS,oBAAoB,CAAC,CAAC,CAAC,cAAc,QAAQ,KAAK,IAAI,CAAC;IAC7G,CAAC;IAOH,MAAM,cAAc,cAAc,QAAQ,MAAM,aAAa,SAAS,IAAI,KAAA;IAG1E,MAAM,QAAQ;IAEd,IAAI,cAAc,OAChB,gBAAgB,WAAW,SAAS;KAAE,KAAK;MAAE,MAAM;MAAS,OAAO;KAAS;KAAG;IAAY,CAAC;SAE5F,MAAM,aAAa,CAAC,SAAS,GAAG,SAAS;KAAE,MAAM;KAAS,OAAO;IAAS,CAAC;GAE/E,OACE,IAAI;IAEF,IAAI,CAAC,MADmB,SAAS;KAAE;KAAO;KAAQ;KAAO;IAAO,CAAC,GACjD,YAAY;GAC9B,SAAS,aAAa;IACpB,MAAM,YAAY,KAAK,YAAY,WAAW;IAC9C,YAAY;GACd;EAEJ;EAEA,MAAM,MAAM,SAAS,oBAAoB;EAIzC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,WACvB,OAAO;EAGT,IAAI,WACF,QAAQ,KAAK,CAAC;CAElB,SAAS,OAAO;EACd,MAAM,YAAY,KAAK,YAAY,KAAK;EACxC,QAAQ,KAAK,CAAC;CAChB;AACF"}
@@ -1,30 +1,15 @@
1
1
  import "./rolldown-runtime-CRm0XQPb.js";
2
- import { o as runtime } from "./Telemetry-CwaVQsvD.js";
3
- import { r as loadConfigs, s as runStudio } from "./run-YHth5Afz.js";
4
- import { f as createPlainLogger, r as logBlock } from "./output-PhkPtNP7.js";
5
- import { r as setupReporters } from "./config-B56ZuVhi.js";
2
+ import { a as getElapsedMs, i as formatMs } from "./Telemetry-CfJAUDnh.js";
3
+ import { c as runStudio, i as loadConfigs } from "./run-BJn0RSW2.js";
4
+ import { v as read } from "./utils-CnjEJIdZ.js";
5
+ import { m as createPlainWriter, t as pluralize } from "./text-CMP4M19Z.js";
6
+ import { n as setupReporters } from "./reporters-Dl8lrJZG.js";
6
7
  import { styleText } from "node:util";
7
8
  import process from "node:process";
8
- import { readFile } from "node:fs/promises";
9
9
  import { dirname, join } from "node:path";
10
10
  import { readFileSync } from "node:fs";
11
11
  import { Diagnostics, Hookable, cliReporter, logLevel } from "@kubb/core";
12
12
  import { createSnapshot } from "@kubb/studio";
13
- //#region ../../internals/utils/src/fs.ts
14
- /**
15
- * Reads the file at `path` as a UTF-8 string.
16
- * Uses `Bun.file().text()` when running under Bun, `fs.readFile` otherwise.
17
- *
18
- * @example
19
- * ```ts
20
- * const source = await read('./src/Pet.ts')
21
- * ```
22
- */
23
- async function read(path) {
24
- if (runtime.isBun) return Bun.file(path).text();
25
- return readFile(path, { encoding: "utf8" });
26
- }
27
- //#endregion
28
13
  //#region src/runners/studio/ci.ts
29
14
  function readGithubPullRequest(eventPath) {
30
15
  if (!eventPath) return;
@@ -114,27 +99,6 @@ async function findPackageJson(directory) {
114
99
  });
115
100
  return findPackageJson(parent);
116
101
  }
117
- /** Reads package.json only for whichever of name/version --name and --version did not supply. */
118
- async function resolvePackageMetadata(options) {
119
- if (options.name && options.packageVersion) return {
120
- name: options.name,
121
- version: options.packageVersion
122
- };
123
- const found = await findPackageJson(process.cwd());
124
- return {
125
- name: options.name ?? found.name,
126
- version: options.packageVersion ?? found.version
127
- };
128
- }
129
- function resolveToken(options) {
130
- const token = options.token ?? process.env.KUBB_TOKEN;
131
- if (!token) throw new Diagnostics.Error({
132
- code: Diagnostics.code.unknown,
133
- severity: "error",
134
- message: "An organization CI API key is required. Pass --token or set KUBB_TOKEN."
135
- });
136
- return token;
137
- }
138
102
  function resolveCiIdentity(options) {
139
103
  const detected = detectCi();
140
104
  const ci = options.id ? {
@@ -162,11 +126,13 @@ function absoluteUrl(studioUrl, path) {
162
126
  function toResult({ studioUrl, snapshot, ci }) {
163
127
  return {
164
128
  id: snapshot.id,
129
+ number: snapshot.number,
165
130
  name: snapshot.name,
166
131
  version: snapshot.version,
167
132
  integrity: snapshot.integrity,
168
133
  url: absoluteUrl(studioUrl, snapshot.url),
169
134
  snapshotIdUrl: absoluteUrl(studioUrl, snapshot.snapshotIdUrl),
135
+ webUrl: snapshot.webUrl ? absoluteUrl(studioUrl, snapshot.webUrl) : void 0,
170
136
  expiresAt: snapshot.expiresAt,
171
137
  agentUrl: absoluteUrl(studioUrl, `/agents/${snapshot.agent.slug ?? snapshot.agent.id}`),
172
138
  changes: snapshot.changes,
@@ -179,49 +145,69 @@ function toResult({ studioUrl, snapshot, ci }) {
179
145
  /** How many files differ, `against` what. */
180
146
  function describeChanges(changes, against) {
181
147
  const { added, changed, removed } = changes;
182
- return added.length + changed.length + removed.length ? `${added.length} added, ${changed.length} changed, ${removed.length} removed ${against}` : `No changes ${against}`;
148
+ const parts = [
149
+ added.length && `+${pluralize(added.length, "file")}`,
150
+ changed.length && `~${changed.length} changed`,
151
+ removed.length && `-${removed.length} removed`
152
+ ].filter(Boolean);
153
+ return parts.length ? `${parts.join(" ")} ${against}` : `No changes ${against}`;
183
154
  }
184
155
  /** One summary line: how many files changed, and since which run. */
185
156
  function formatChanges(changes) {
186
157
  if (!changes.base) return "First snapshot";
187
- return describeChanges(changes, `since ${changes.base.commit?.slice(0, 7) ?? changes.base.createdAt}`);
158
+ const { number, commit, createdAt } = changes.base;
159
+ return describeChanges(changes, `vs ${number ? `#${number}` : commit?.slice(0, 7) ?? createdAt}`);
188
160
  }
189
161
  /** One summary line: how the snapshot differs from the base branch's latest one. */
190
162
  function formatBranchChanges(changes) {
191
- if (changes.base) return describeChanges(changes, `against ${changes.branch}`);
163
+ if (changes.base) return describeChanges(changes, `vs ${changes.branch}`);
192
164
  return changes.baseFound ? `No snapshot of ${changes.branch} for this package yet` : `No snapshot of ${changes.branch} to compare with`;
193
165
  }
194
166
  function printSummary(result) {
195
- logBlock([
196
- `${styleText("dim", "Package".padEnd(10))} ${result.name ?? "(unnamed)"}@${result.version ?? "0.0.0"}`,
197
- `${styleText("dim", "Tarball".padEnd(10))} ${styleText("cyan", result.url)}`,
198
- `${styleText("dim", "Agent".padEnd(10))} ${result.agentUrl}`,
199
- ...result.branchChanges ? [`${styleText("dim", "Branch".padEnd(10))} ${formatBranchChanges(result.branchChanges)}`] : [],
200
- ...result.changes ? [`${styleText("dim", "Changes".padEnd(10))} ${formatChanges(result.changes)}`] : [],
201
- `${styleText("dim", "Expires".padEnd(10))} ${result.expiresAt}`
202
- ]);
167
+ const row = (label, value) => ` ${styleText("dim", label.padEnd(7))} ${value}`;
168
+ console.log([
169
+ "",
170
+ ...result.webUrl ? [row("View", styleText("cyan", result.webUrl))] : [],
171
+ ...result.changes ? [row("Diff", formatChanges(result.changes))] : [],
172
+ ...result.branchChanges ? [row("Branch", formatBranchChanges(result.branchChanges))] : [],
173
+ row("Use", `npm i ${result.url}`),
174
+ row("Expires", result.expiresAt.slice(0, 10))
175
+ ].join("\n"));
203
176
  }
204
177
  /**
205
178
  * Generates the project, packs it, and publishes it to Kubb Studio in one request, under the CI
206
179
  * agent the run's identity names.
207
180
  */
208
181
  async function snapshot(options) {
209
- const token = resolveToken(options);
210
- const { config } = await loadConfigs(options);
182
+ const token = options.token ?? process.env.KUBB_TOKEN;
183
+ if (!token) throw new Diagnostics.Error({
184
+ code: Diagnostics.code.unknown,
185
+ severity: "error",
186
+ message: "An organization CI API key is required. Pass --token or set KUBB_TOKEN."
187
+ });
188
+ const config = (await loadConfigs(options)).configs[0];
211
189
  const ci = resolveCiIdentity(options);
212
- const { name, version: packageVersion } = await resolvePackageMetadata(options);
190
+ const { name, version: packageVersion } = options.name && options.packageVersion ? {
191
+ name: options.name,
192
+ version: options.packageVersion
193
+ } : await findPackageJson(process.cwd()).then((found) => ({
194
+ name: options.name ?? found.name,
195
+ version: options.packageVersion ?? found.version
196
+ }));
213
197
  const logLevel$1 = logLevel[options.logLevel ?? "info"];
214
198
  const write = options.json ? (line) => console.error(line) : (line) => console.log(line);
215
199
  const hooks = new Hookable();
216
200
  setupReporters(hooks, {
217
- logLevel: logLevel$1,
201
+ logLevel: logLevel$1 > logLevel.info ? logLevel$1 : logLevel.silent,
218
202
  reporters: [cliReporter],
219
- logger: createPlainLogger(write)
203
+ writer: createPlainWriter(write)
220
204
  });
221
205
  const step = (message) => {
222
206
  if (logLevel$1 > logLevel.silent) write(message);
223
207
  };
224
- step("Generating the snapshot");
208
+ hooks.hook("kubb:generation:end", ({ filesCreated = 0, status, hrStart }) => {
209
+ if (status !== "failed" && hrStart) step(`✓ Generated ${pluralize(filesCreated, "file")} in ${formatMs(getElapsedMs(hrStart))}`);
210
+ });
225
211
  try {
226
212
  const published = await createSnapshot({
227
213
  studioUrl: options.studioUrl,
@@ -240,11 +226,12 @@ async function snapshot(options) {
240
226
  snapshot: published,
241
227
  ci
242
228
  });
243
- step("Snapshot published");
229
+ step(`✓ Packed ${result.name ?? name}@${result.version ?? packageVersion}`);
230
+ step(`✓ Published snapshot ${result.number ? `#${result.number}` : result.id} for ${ci.name}${ci.commit ? `@${ci.commit.slice(0, 7)}` : ""}`);
244
231
  if (options.json) console.log(JSON.stringify(result));
245
- if (!options.json) printSummary(result);
232
+ else printSummary(result);
246
233
  } catch (error) {
247
- step("Snapshot failed");
234
+ step("✖ Snapshot failed");
248
235
  throw error;
249
236
  }
250
237
  }
@@ -260,4 +247,4 @@ const runner = ({ values }) => runStudio(values, (options) => snapshot({
260
247
  //#endregion
261
248
  export { runner };
262
249
 
263
- //# sourceMappingURL=snapshot-Cilp10vE.js.map
250
+ //# sourceMappingURL=snapshot-CdGwHH15.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snapshot-CdGwHH15.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 { dirname, join } from 'node:path'\nimport process from 'node:process'\nimport { styleText } from 'node:util'\nimport { formatMs, getElapsedMs, read } from '@internals/utils'\nimport { cliReporter, Diagnostics, Hookable, type KubbHooks, logLevel as logLevelMap } from '@kubb/core'\nimport { createSnapshot } from '@kubb/studio'\nimport type { BranchSnapshotChanges, PublishedSnapshot, SnapshotChanges } from '@kubb/studio/protocol'\nimport { pluralize } from '../../ui/text.ts'\nimport { createPlainWriter } from '../../loggers/plainWriter.ts'\nimport setupReporters from '../../loggers/reporters.ts'\nimport { type CiContext, detectCi } from './ci.ts'\nimport { loadConfigs, runStudio, type SnapshotOptions } from './run.ts'\nimport type { command } from '../../commands/studio/snapshot.ts'\nimport type { CommandRunner } from 'gunshi'\n\n/**\n * Walks up from `directory` to the first package.json with a name and a version.\n */\nasync function findPackageJson(directory: string): Promise<{ name: string; version: string }> {\n const packageJson = JSON.parse(await read(join(directory, 'package.json')).catch(() => '{}')) as Partial<{ name: string; version: string }>\n if (packageJson.name && packageJson.version) return { name: packageJson.name, version: packageJson.version }\n\n const parent = dirname(directory)\n if (parent === directory)\n throw new Diagnostics.Error({\n code: Diagnostics.code.unknown,\n severity: 'error',\n message: `No package.json with a name and a version found above ${process.cwd()}`,\n help: 'Pass `--name` and `--version`, or run from a package with a package.json.',\n })\n\n return findPackageJson(parent)\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 Diagnostics.Error({\n code: Diagnostics.code.unknown,\n severity: 'error',\n message: 'Could not detect a supported CI provider (GitHub Actions, GitLab CI, Bitbucket Pipelines, CircleCI). Pass --id.',\n })\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\nfunction absoluteUrl(studioUrl: string, path: string): string {\n return new URL(path, `${studioUrl}/`).toString()\n}\n\ntype SnapshotResult = {\n id: string\n /** Sequence number on the CI agent, when Studio sends one. */\n number?: number\n name: string | null\n version: string | null\n integrity: string | null\n url: string\n snapshotIdUrl: string\n /** Studio page of the snapshot, when Studio sends one. */\n webUrl?: string\n expiresAt: string\n agentUrl: string\n /** What changed since the previous snapshot of this package on this agent. */\n changes?: SnapshotChanges\n /** What differs from the latest snapshot of the base branch, named by `branch`. */\n branchChanges?: BranchSnapshotChanges & { branch: string }\n}\n\nfunction toResult({ studioUrl, snapshot, ci }: { studioUrl: string; snapshot: PublishedSnapshot; ci: CiContext }): SnapshotResult {\n return {\n id: snapshot.id,\n number: snapshot.number,\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 webUrl: snapshot.webUrl ? absoluteUrl(studioUrl, snapshot.webUrl) : undefined,\n expiresAt: snapshot.expiresAt,\n agentUrl: absoluteUrl(studioUrl, `/agents/${snapshot.agent.slug ?? snapshot.agent.id}`),\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: SnapshotChanges, against: string): string {\n const { added, changed, removed } = changes\n const parts = [\n added.length && `+${pluralize(added.length, 'file')}`,\n changed.length && `~${changed.length} changed`,\n removed.length && `-${removed.length} removed`,\n ].filter(Boolean)\n\n return parts.length ? `${parts.join(' ')} ${against}` : `No changes ${against}`\n}\n\n/** One summary line: how many files changed, and since which run. */\nexport function formatChanges(changes: SnapshotChanges): string {\n if (!changes.base) {\n return 'First snapshot'\n }\n const { number, commit, createdAt } = changes.base\n\n return describeChanges(changes, `vs ${number ? `#${number}` : (commit?.slice(0, 7) ?? createdAt)}`)\n}\n\n/** One summary line: how the snapshot differs from the base branch's latest one. */\nexport function formatBranchChanges(changes: BranchSnapshotChanges & { branch: string }): string {\n if (changes.base) return describeChanges(changes, `vs ${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 const row = (label: string, value: string) => ` ${styleText('dim', label.padEnd(7))} ${value}`\n\n console.log(\n [\n '',\n ...(result.webUrl ? [row('View', styleText('cyan', result.webUrl))] : []),\n ...(result.changes ? [row('Diff', formatChanges(result.changes))] : []),\n ...(result.branchChanges ? [row('Branch', formatBranchChanges(result.branchChanges))] : []),\n row('Use', `npm i ${result.url}`),\n row('Expires', result.expiresAt.slice(0, 10)),\n ].join('\\n'),\n )\n}\n\n/**\n * Generates the project, packs it, and publishes it to Kubb Studio in one request, under the CI\n * agent the run's identity names.\n */\nexport async function snapshot(options: SnapshotOptions): Promise<void> {\n const token = options.token ?? process.env.KUBB_TOKEN\n if (!token) {\n throw new Diagnostics.Error({\n code: Diagnostics.code.unknown,\n severity: 'error',\n message: 'An organization CI API key is required. Pass --token or set KUBB_TOKEN.',\n })\n }\n // A snapshot publishes the first entry.\n const config = (await loadConfigs(options)).configs[0]!\n const ci = resolveCiIdentity(options)\n // package.json is read only for whichever of name/version --name and --version did not supply.\n const { name, version: packageVersion } =\n options.name && options.packageVersion\n ? { name: options.name, version: options.packageVersion }\n : await findPackageJson(process.cwd()).then((found) => ({ name: options.name ?? found.name, version: options.packageVersion ?? found.version }))\n const logLevel = logLevelMap[options.logLevel ?? 'info']\n\n const write = options.json ? (line: string) => console.error(line) : (line: string) => console.log(line)\n const hooks = new Hookable<KubbHooks>()\n // The steps below are the CI log; the run's own per-file output only shows when asked for with --log-level verbose.\n setupReporters(hooks, { logLevel: logLevel > logLevelMap.info ? logLevel : logLevelMap.silent, reporters: [cliReporter], writer: createPlainWriter(write) })\n const step = (message: string) => {\n if (logLevel > logLevelMap.silent) {\n write(message)\n }\n }\n\n hooks.hook('kubb:generation:end', ({ filesCreated = 0, status, hrStart }) => {\n if (status !== 'failed' && hrStart) step(`✓ Generated ${pluralize(filesCreated, 'file')} in ${formatMs(getElapsedMs(hrStart))}`)\n })\n\n try {\n const published = await createSnapshot({\n studioUrl: options.studioUrl,\n apiKey: token,\n config,\n hooks,\n id: ci.id,\n name: ci.name,\n packageName: name,\n version: packageVersion,\n commit: ci.commit,\n baseId: ci.base?.id,\n })\n const result = toResult({ studioUrl: options.studioUrl, snapshot: published, ci })\n\n step(`✓ Packed ${result.name ?? name}@${result.version ?? packageVersion}`)\n step(`✓ Published snapshot ${result.number ? `#${result.number}` : result.id} for ${ci.name}${ci.commit ? `@${ci.commit.slice(0, 7)}` : ''}`)\n\n if (options.json) console.log(JSON.stringify(result))\n else printSummary(result)\n } catch (error) {\n step('✖ Snapshot failed')\n throw error\n }\n}\n\nexport const runner: CommandRunner<{ args: typeof command.args; extensions: {} }> = ({ values }) =>\n runStudio(\n values,\n (options) =>\n snapshot({\n ...options,\n token: values.token,\n id: values.id,\n baseId: values.baseId,\n name: values.name,\n packageVersion: values.packageVersion,\n json: values.json,\n }),\n { json: values.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/D,MAAM,eAAe,IAAI,wBAAwB,IAA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