@kubb/cli 5.3.9 → 5.3.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{connect-DFd7vS7_.js → connect-nJxEjQeP.js} +2 -2
- package/dist/{connect-DFd7vS7_.js.map → connect-nJxEjQeP.js.map} +1 -1
- package/dist/{connect-bCESn4L8.cjs → connect-oUPv7QZH.cjs} +2 -2
- package/dist/{connect-bCESn4L8.cjs.map → connect-oUPv7QZH.cjs.map} +1 -1
- package/dist/{generate-Del-D4hj.js → generate-Ff4OuHBb.js} +2 -2
- package/dist/{generate-Del-D4hj.js.map → generate-Ff4OuHBb.js.map} +1 -1
- package/dist/{generate-Cl5hFNdC.cjs → generate-bPprSwp5.cjs} +2 -2
- package/dist/{generate-Cl5hFNdC.cjs.map → generate-bPprSwp5.cjs.map} +1 -1
- package/dist/index.cjs +7 -7
- package/dist/index.js +7 -7
- package/dist/{init-C5trdwre.cjs → init-C-7hXVK4.cjs} +3 -3
- package/dist/{init-C5trdwre.cjs.map → init-C-7hXVK4.cjs.map} +1 -1
- package/dist/{init-CBAmaPkc.js → init-DiLI89VC.js} +3 -3
- package/dist/{init-CBAmaPkc.js.map → init-DiLI89VC.js.map} +1 -1
- package/dist/{login-D-1xSRxT.js → login-5RHW6mSF.js} +2 -2
- package/dist/{login-D-1xSRxT.js.map → login-5RHW6mSF.js.map} +1 -1
- package/dist/{login-5QXmUaQN.cjs → login-B7vytZxR.cjs} +2 -2
- package/dist/{login-5QXmUaQN.cjs.map → login-B7vytZxR.cjs.map} +1 -1
- package/dist/{logout-XB0v_SY-.js → logout-DjqsnHYa.js} +2 -2
- package/dist/{logout-XB0v_SY-.js.map → logout-DjqsnHYa.js.map} +1 -1
- package/dist/{logout-B2vHFyac.cjs → logout-FPtE-NZD.cjs} +2 -2
- package/dist/{logout-B2vHFyac.cjs.map → logout-FPtE-NZD.cjs.map} +1 -1
- package/dist/{output-CdnsdD1b.js → output-C_Gk4p-8.js} +11 -32
- package/dist/output-C_Gk4p-8.js.map +1 -0
- package/dist/{output-DBBTlqPw.cjs → output-D-9bGS7y.cjs} +10 -37
- package/dist/output-D-9bGS7y.cjs.map +1 -0
- package/dist/package-B85RueQ-.js +6 -0
- package/dist/package-B85RueQ-.js.map +1 -0
- package/dist/{package-BwIh-jWZ.cjs → package-Q4QB8jvq.cjs} +2 -2
- package/dist/package-Q4QB8jvq.cjs.map +1 -0
- package/dist/{run-Bd-IwEch.js → run-0O4lQ17t.js} +4 -21
- package/dist/run-0O4lQ17t.js.map +1 -0
- package/dist/{run-CxglY4u6.cjs → run-B8V0CBvt.cjs} +5 -9
- package/dist/run-B8V0CBvt.cjs.map +1 -0
- package/dist/{run-CeTu1eSk.js → run-BEZhsX-8.js} +2 -2
- package/dist/{run-CeTu1eSk.js.map → run-BEZhsX-8.js.map} +1 -1
- package/dist/{run-ZPt0Sw9r.cjs → run-Bidc3n3b.cjs} +2 -2
- package/dist/{run-ZPt0Sw9r.cjs.map → run-Bidc3n3b.cjs.map} +1 -1
- package/dist/{run-DPuKGV20.cjs → run-CX822YNy.cjs} +2 -2
- package/dist/{run-DPuKGV20.cjs.map → run-CX822YNy.cjs.map} +1 -1
- package/dist/{run-SybIXc6w.cjs → run-D2n26-7g.cjs} +2 -2
- package/dist/{run-SybIXc6w.cjs.map → run-D2n26-7g.cjs.map} +1 -1
- package/dist/{run-CLhU86LM.js → run-DXSh1iZG.js} +2 -2
- package/dist/{run-CLhU86LM.js.map → run-DXSh1iZG.js.map} +1 -1
- package/dist/{run-C5HkzCUt.js → run-DbwEipoP.js} +5 -9
- package/dist/run-DbwEipoP.js.map +1 -0
- package/dist/{run-CIonyF_t.cjs → run-gZCWiNp4.cjs} +4 -21
- package/dist/run-gZCWiNp4.cjs.map +1 -0
- package/dist/{run-Df4x0iX_.js → run-ngs35PvK.js} +2 -2
- package/dist/{run-Df4x0iX_.js.map → run-ngs35PvK.js.map} +1 -1
- package/dist/{snapshot-DWNiluEm.cjs → snapshot-BXQQy03q.cjs} +3 -3
- package/dist/{snapshot-DWNiluEm.cjs.map → snapshot-BXQQy03q.cjs.map} +1 -1
- package/dist/{snapshot-Dhwz_MpL.js → snapshot-BtDwmaK5.js} +3 -3
- package/dist/{snapshot-Dhwz_MpL.js.map → snapshot-BtDwmaK5.js.map} +1 -1
- package/dist/{status-CxMC5vAa.cjs → status-Cah-W7G1.cjs} +2 -2
- package/dist/{status-CxMC5vAa.cjs.map → status-Cah-W7G1.cjs.map} +1 -1
- package/dist/{status-Cc3wqN4l.js → status-DLhsr9Yo.js} +2 -2
- package/dist/{status-Cc3wqN4l.js.map → status-DLhsr9Yo.js.map} +1 -1
- package/dist/{studio-CQ24bwGz.cjs → studio-DmXzeEfz.cjs} +7 -7
- package/dist/{studio-CQ24bwGz.cjs.map → studio-DmXzeEfz.cjs.map} +1 -1
- package/dist/{studio-jqKsQP5_.js → studio-DpJKKPVU.js} +7 -7
- package/dist/{studio-jqKsQP5_.js.map → studio-DpJKKPVU.js.map} +1 -1
- package/dist/{utils-BP0xq5AK.cjs → utils-CyfAlK9G.cjs} +5 -2
- package/dist/utils-CyfAlK9G.cjs.map +1 -0
- package/dist/{utils-B1_SWa35.js → utils-LvEYQf9I.js} +5 -2
- package/dist/utils-LvEYQf9I.js.map +1 -0
- package/package.json +8 -8
- package/dist/output-CdnsdD1b.js.map +0 -1
- package/dist/output-DBBTlqPw.cjs.map +0 -1
- package/dist/package-BwIh-jWZ.cjs.map +0 -1
- package/dist/package-CDw1YdJ8.js +0 -6
- package/dist/package-CDw1YdJ8.js.map +0 -1
- package/dist/run-Bd-IwEch.js.map +0 -1
- package/dist/run-C5HkzCUt.js.map +0 -1
- package/dist/run-CIonyF_t.cjs.map +0 -1
- package/dist/run-CxglY4u6.cjs.map +0 -1
- package/dist/utils-B1_SWa35.js.map +0 -1
- package/dist/utils-BP0xq5AK.cjs.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils-B1_SWa35.js","names":["logLevel","logLevelMap","writer","logLevel","logLevelMap"],"sources":["../../../internals/utils/src/tools.ts","../src/loggers/createLogger.ts","../src/loggers/clackLogger.ts","../src/loggers/plainLogger.ts","../src/loggers/utils.ts","../../../internals/shared/src/loader.ts","../src/runners/generate/utils.ts"],"sourcesContent":["import { spawn } from 'node:child_process'\n\n/**\n * How one formatter or linter is invoked: the executable, the argv it takes for an output\n * directory, and what to report when it is not installed.\n */\nexport type ToolCommand = {\n command: string\n args: (outputPath: string) => Array<string>\n errorMessage: string\n}\n\n/**\n * CLI command descriptors for each supported code formatter.\n */\nexport const formatters = {\n prettier: {\n command: 'prettier',\n args: (outputPath: string) => ['--ignore-unknown', '--write', outputPath],\n errorMessage: 'Prettier not found',\n },\n biome: {\n command: 'biome',\n args: (outputPath: string) => ['format', '--write', outputPath],\n errorMessage: 'Biome not found',\n },\n oxfmt: {\n command: 'oxfmt',\n args: (outputPath: string) => [outputPath],\n errorMessage: 'Oxfmt not found',\n },\n} as const satisfies Record<string, ToolCommand>\n\n/**\n * CLI command descriptors for each supported linter.\n */\nexport const linters = {\n eslint: {\n command: 'eslint',\n args: (outputPath: string) => [outputPath, '--fix'],\n errorMessage: 'Eslint not found',\n },\n biome: {\n command: 'biome',\n args: (outputPath: string) => ['lint', '--fix', outputPath],\n errorMessage: 'Biome not found',\n },\n oxlint: {\n command: 'oxlint',\n // --no-ignore so oxlint lints the folder even when it's gitignored (generated output dirs usually are).\n args: (outputPath: string) => ['--fix', '--no-ignore', outputPath],\n errorMessage: 'Oxlint not found',\n },\n} as const satisfies Record<string, ToolCommand>\n\n/**\n * Preference order for `format: 'auto'`, most-preferred first. Spelled out rather than taken from\n * the table's key order, which is arbitrary and would silently change what `auto` picks.\n */\nexport const FORMATTER_PREFERENCE = ['oxfmt', 'biome', 'prettier'] as const\n\n/**\n * Preference order for `lint: 'auto'`, most-preferred first.\n */\nexport const LINTER_PREFERENCE = ['oxlint', 'biome', 'eslint'] as const\n\n/**\n * Whether `name` is on PATH and answers `--version` with a zero exit.\n */\nexport function isToolAvailable(name: string): Promise<boolean> {\n return new Promise((resolve) => {\n const child = spawn(name, ['--version'], { stdio: 'ignore' })\n child.on('close', (code) => resolve(code === 0))\n child.on('error', () => resolve(false))\n })\n}\n\n/**\n * Returns the first installed executable from `candidates`, or `null` when none are found.\n *\n * Not memoized: a long-running host that probes repeatedly should cache the result itself, and a\n * `--watch` build should keep noticing a tool installed mid-session.\n */\nexport async function detectTool<TName extends string>(candidates: ReadonlyArray<TName>): Promise<TName | null> {\n for (const candidate of candidates) {\n if (await isToolAvailable(candidate)) {\n return candidate\n }\n }\n\n return null\n}\n\n/**\n * Tokenizes a shell command string, respecting single and double quotes.\n *\n * @example\n * ```ts\n * tokenize('git commit -m \"initial commit\"')\n * // → ['git', 'commit', '-m', 'initial commit']\n * ```\n */\nexport function tokenize(command: string): Array<string> {\n return (command.match(/[^\\s\"']+|\"([^\"]*)\"|'([^']*)'/g) ?? []).map((token) => token.replace(/^[\"']|[\"']$/g, ''))\n}\n","import { relative } from 'node:path'\nimport process from 'node:process'\nimport { styleText } from 'node:util'\nimport { getElapsedMs } from '@internals/utils'\nimport { Diagnostics, logLevel as logLevelMap } from '@kubb/core'\nimport { formatMsWithColor } from './banner.ts'\nimport type { LoggerContext, LoggerHandle, LoggerOptions, LoggerWriter, LogStatus, WriterProgress, WriterSpinner } from './defineLogger.ts'\nimport {\n buildProgressLine,\n createProgressCounters,\n formatCommandWithArgs,\n formatErrorFrames,\n formatMessage,\n formatVersions,\n getInputPath,\n pluralize,\n recordPluginResult,\n resetProgressCounters,\n} from './utils.ts'\n\n/**\n * One output phase while its step owns the line. A phase buffers what it is told, because a spinner\n * redraws over anything written under it, and prints the lot once it knows its own result.\n */\ntype Phase = {\n successLabel: string\n failureLabel: string\n /**\n * Whether each hook's own result is worth a line. Format and lint run one command, so the phase\n * result already says everything; the post-generate phase runs several.\n */\n showHookResults: boolean\n failed: boolean\n hrStart: [number, number]\n lines: Array<string>\n /**\n * Raw lines a hook printed, drawn outside the group.\n */\n output: Array<string>\n}\n\ntype StartPhaseOptions = {\n /**\n * Shown while the phase runs.\n */\n running: string\n success: string\n failure: string\n showHookResults?: boolean\n}\n\n/**\n * The three output phases, in the order the generate runner runs them.\n */\nconst PHASES = {\n format: { running: 'Formatting', success: 'Formatted', failure: 'Formatting failed' },\n lint: { running: 'Linting', success: 'Linted', failure: 'Linting failed' },\n hooks: {\n running: 'Running post-generate hooks',\n success: 'Post-generate hooks completed',\n failure: 'Post-generate hooks failed',\n showHookResults: true,\n },\n} as const satisfies Record<string, StartPhaseOptions>\n\n/**\n * Drops the blank lines a subprocess leaves at either end of its output, so its block does not open\n * or close on an empty row.\n */\nfunction trimBlankEdges(lines: ReadonlyArray<string>): Array<string> {\n const start = lines.findIndex((line) => line.trim())\n if (start === -1) {\n return []\n }\n\n return lines.slice(start, lines.findLastIndex((line) => line.trim()) + 1)\n}\n\n/**\n * Wires a {@link LoggerWriter} onto the run's hooks. This owns what a run says and in what order:\n * one group per config, a step over the plugin work, a progress bar for the writes, one step per\n * output phase, then the summary and the group's closing result. The writer only decides how each\n * line looks, so every logger reports the same run the same way.\n *\n * @example\n * ```ts\n * export const plainLogger = { name: 'plain', install: (context, options) => createLogger(writer)(context, options) }\n * ```\n */\nexport function createLogger(writer: LoggerWriter) {\n return function install(context: LoggerContext, options?: LoggerOptions): LoggerHandle {\n const logLevel = options?.logLevel ?? logLevelMap.info\n const silent = logLevel <= logLevelMap.silent\n const state = {\n ...createProgressCounters(),\n spinner: null as WriterSpinner | null,\n progress: null as WriterProgress | null,\n hooks: new Map<string, { hrStart: [number, number]; lines: Array<string> }>(),\n /**\n * Plugin results held back while the generation step owns the line.\n */\n pluginLines: [] as Array<string>,\n phase: null as Phase | null,\n groupOpen: false,\n }\n\n function text(message: string): string {\n return formatMessage(message, logLevel)\n }\n\n function startSpinner(message: string) {\n if (silent) {\n return\n }\n\n state.spinner = writer.spinner()\n state.spinner.start(text(message))\n }\n\n function stopSpinner(message?: string, status: LogStatus = 'success') {\n const spinner = state.spinner\n if (!spinner) {\n return\n }\n state.spinner = null\n\n if (message === undefined) {\n spinner.clear()\n return\n }\n if (status === 'failed') {\n spinner.error(text(message))\n return\n }\n spinner.stop(text(message))\n }\n\n function stopProgress(message?: string) {\n const progress = state.progress\n if (!progress) {\n return\n }\n state.progress = null\n progress.stop(message === undefined ? '' : text(message))\n }\n\n function startPhase({ running, success, failure, showHookResults = false }: StartPhaseOptions) {\n state.phase = { successLabel: success, failureLabel: failure, showHookResults, failed: false, hrStart: process.hrtime(), lines: [], output: [] }\n startSpinner(running)\n }\n\n function endPhase() {\n const phase = state.phase\n state.phase = null\n\n if (!phase || silent) {\n return\n }\n\n const duration = formatMsWithColor(getElapsedMs(phase.hrStart))\n\n stopSpinner(phase.failed ? `${phase.failureLabel} after ${duration}` : `${phase.successLabel} in ${duration}`, phase.failed ? 'failed' : 'success')\n\n if (phase.lines.length) {\n writer.block(phase.lines)\n }\n writeOutput(phase.output)\n }\n\n function writeOutput(lines: ReadonlyArray<string>) {\n const output = trimBlankEdges(lines)\n if (output.length) {\n writer.raw(output)\n }\n }\n\n // A run that throws before `kubb:generation:end` never reaches the summary, so the lifecycle\n // end calls this too rather than leave a group without its closing line.\n function closeGroup(status: LogStatus) {\n if (!state.groupOpen) {\n return\n }\n state.groupOpen = false\n\n stopSpinner()\n stopProgress()\n writer.groupEnd(status === 'failed' ? styleText('red', '✗ Generation failed') : styleText('green', '✓ Generation succeeded'))\n }\n\n function reset() {\n stopSpinner()\n stopProgress()\n resetProgressCounters(state)\n state.hooks.clear()\n state.pluginLines = []\n state.phase = null\n state.groupOpen = false\n }\n\n context.hook('kubb:info', ({ message, info }) => {\n if (silent) {\n return\n }\n\n const line = text([styleText('blue', 'ℹ'), message, info ? styleText('dim', info) : undefined].filter(Boolean).join(' '))\n\n // Info carries something new (the auto-detected tool), so inside a phase it waits for the\n // phase to print rather than being spent on a frame the next one overwrites.\n if (state.phase) {\n state.phase.lines.push(line)\n return\n }\n if (state.spinner) {\n state.spinner.message(line)\n return\n }\n writer.info(line)\n })\n\n context.hook('kubb:success', ({ message, info }) => {\n if (silent) {\n return\n }\n\n const line = text([styleText('green', '✓'), message, logLevel >= logLevelMap.info && info ? styleText('dim', info) : undefined].filter(Boolean).join(' '))\n\n // A phase step outlives the successes reported inside it, and its own result says the same\n // thing, so let the step carry them.\n if (state.spinner) {\n state.spinner.message(line)\n return\n }\n writer.success(line)\n })\n\n context.hook('kubb:warn', ({ message, info }) => {\n if (logLevel < logLevelMap.warn) {\n return\n }\n\n writer.warn(\n text([styleText('yellow', '⚠'), message, logLevel >= logLevelMap.info && info ? styleText('dim', info) : undefined].filter(Boolean).join(' ')),\n )\n })\n\n // Unguarded: a failure stays visible even at silent.\n context.hook('kubb:error', ({ error }) => {\n if (state.phase) {\n state.phase.failed = true\n }\n\n const line = [styleText('red', '✗'), error.message].join(' ')\n\n if (state.spinner) {\n stopSpinner(line, 'failed')\n } else {\n writer.error(text(line))\n }\n\n const frames = logLevel >= logLevelMap.verbose ? formatErrorFrames(error) : null\n if (!frames) {\n return\n }\n\n writer.block(frames.frames.map((frame) => text(styleText('dim', frame))))\n if (frames.cause) {\n writer.block([styleText('dim', frames.cause.header), ...frames.cause.frames.map((frame) => text(` ${styleText('dim', frame)}`))])\n }\n })\n\n context.hook('kubb:diagnostic', ({ diagnostic }) => {\n // Silent still surfaces errors so failures stay visible. It drops warnings and info.\n if (silent && diagnostic.severity !== 'error') {\n return\n }\n\n stopSpinner()\n stopProgress()\n\n if (Diagnostics.isUpdate(diagnostic)) {\n writer.update(\n [`\\`v${diagnostic.currentVersion}\\` → \\`v${diagnostic.latestVersion}\\``, 'Run `npm install -g @kubb/cli` to update'],\n 'Update available for `Kubb`',\n )\n return\n }\n\n const { headline, details } = Diagnostics.format(diagnostic)\n writer.diagnostic([headline, ...details])\n })\n\n // A `kubb studio` session emits these on the same emitter as its generations, so one logger\n // renders the whole command. The socket opens without being awaited, hence the step.\n context.hook('studio:connecting', ({ url }) => {\n startSpinner(`Connecting to ${styleText('cyan', url)}`)\n })\n\n context.hook('studio:connected', ({ url, versions }) => {\n if (silent) {\n return\n }\n\n const line = `Connected to ${styleText('cyan', url)} ${styleText('dim', `(${formatVersions(versions)})`)}`\n\n if (state.spinner) {\n stopSpinner(line)\n return\n }\n writer.success(text(`✓ ${line}`))\n })\n\n context.hook('studio:ready', () => {\n if (silent) {\n return\n }\n startSpinner('✓ Ready to receive jobs')\n })\n\n context.hook('studio:disconnected', ({ reason }) => {\n if (logLevel < logLevelMap.warn) {\n return\n }\n\n stopSpinner()\n writer.warn(text(`⚠ Kubb Studio ended the session (${reason})`))\n })\n\n context.hook('studio:command:start', ({ command }) => {\n if (silent) {\n return\n }\n stopSpinner()\n writer.info(text(`Kubb Studio asked to ${styleText('bold', command)}`))\n })\n\n context.hook('studio:command:end', ({ command, info }) => {\n if (silent) {\n return\n }\n writer.success(text(`✓ Finished ${command}${info ? ` ${styleText('dim', `(${info})`)}` : ''}`))\n startSpinner('✓ Ready to receive jobs')\n })\n\n context.hook('studio:warn', ({ message }) => {\n if (logLevel < logLevelMap.warn) {\n return\n }\n writer.warn(text(`⚠ ${message}`))\n })\n\n // Unguarded, like `kubb:error`: a failure stays visible even at silent.\n context.hook('studio:error', ({ error }) => {\n const line = `✗ ${error.message}`\n\n if (state.spinner) {\n stopSpinner(line, 'failed')\n return\n }\n writer.error(text(line))\n })\n\n context.hook('kubb:lifecycle:start', () => {\n reset()\n })\n\n context.hook('kubb:generation:start', ({ config }) => {\n closeGroup('failed')\n reset()\n\n state.totalPlugins = config.plugins?.length ?? 0\n\n if (silent) {\n return\n }\n\n const inputPath = getInputPath(config)\n\n writer.group(text([styleText('bold', config.name ?? 'kubb'), inputPath ? styleText('dim', inputPath) : undefined].filter(Boolean).join(' ')))\n state.groupOpen = true\n\n startSpinner('Generating')\n })\n\n context.hook('kubb:plugin:start', ({ plugin }) => {\n if (silent) {\n return\n }\n state.spinner?.message(text(`Generating ${styleText('dim', plugin.name)}`))\n })\n\n // Buffered, not printed: a step redraws over anything written while it runs.\n context.hook('kubb:plugin:end', ({ plugin, duration, success }) => {\n if (silent) {\n return\n }\n\n recordPluginResult(state, success)\n state.pluginLines.push(text(`${plugin.name} ${success ? 'completed' : 'failed'} in ${formatMsWithColor(duration)}`))\n })\n\n context.hook('kubb:plugins:end', () => {\n if (silent) {\n return\n }\n\n const failed = state.failedPlugins > 0\n stopSpinner(buildProgressLine(state) ?? 'No plugins ran', failed ? 'failed' : 'success')\n\n if (state.pluginLines.length) {\n writer.block(state.pluginLines)\n state.pluginLines = []\n }\n })\n\n context.hook('kubb:files:processing:start', ({ files }) => {\n if (silent) {\n return\n }\n\n stopSpinner()\n state.totalFiles = files.length\n state.processedFiles = 0\n\n state.progress = writer.progress(files.length)\n state.progress.start(text(`Writing ${pluralize(files.length, 'file')}`))\n })\n\n context.hook('kubb:files:processing:update', ({ files }) => {\n if (silent) {\n return\n }\n\n for (const { file, config } of files) {\n state.processedFiles++\n state.progress?.advance(`Writing ${relative(config.root, file.path)}`)\n }\n })\n\n context.hook('kubb:files:processing:end', () => {\n if (silent) {\n return\n }\n stopProgress(`Wrote ${pluralize(state.processedFiles, 'file')}`)\n })\n\n context.hook('kubb:format:start', () => startPhase(PHASES.format))\n context.hook('kubb:format:end', endPhase)\n context.hook('kubb:lint:start', () => startPhase(PHASES.lint))\n context.hook('kubb:lint:end', endPhase)\n context.hook('kubb:hooks:start', () => startPhase(PHASES.hooks))\n context.hook('kubb:hooks:end', endPhase)\n\n context.hook('kubb:hook:start', ({ id }) => {\n if (silent || !id) {\n return\n }\n state.hooks.set(id, { hrStart: process.hrtime(), lines: [] })\n })\n\n // Registered only when not silent, so its presence is what tells the runner to stream\n // (`kubb:hook:line` listenerCount). At silent level the listener is absent, so no streaming happens.\n if (!silent) {\n context.hook('kubb:hook:line', ({ id, line }) => {\n const active = state.hooks.get(id)\n if (!active) {\n return\n }\n\n // A phase step redraws its own line, so its output waits until the phase ends.\n if (state.phase) {\n active.lines.push(line)\n return\n }\n writer.raw([line])\n })\n }\n\n context.hook('kubb:hook:end', ({ id, command, name, args, success, error, stdout, stderr }) => {\n if (!id) {\n return\n }\n\n if (!success && state.phase) {\n state.phase.failed = true\n }\n\n if (silent) {\n // Even when silent, surface a failed hook's captured output.\n if (!success) {\n if (stdout) console.log(stdout)\n if (stderr) console.error(stderr)\n }\n return\n }\n\n const active = state.hooks.get(id)\n if (!active) {\n return\n }\n state.hooks.delete(id)\n\n const label = styleText('dim', name ?? formatCommandWithArgs(command, args))\n const reason = error?.message ? ` (${error.message})` : ''\n const result = success\n ? `${styleText('green', '✓')} ${label} in ${formatMsWithColor(getElapsedMs(active.hrStart))}`\n : `${styleText('red', '✗')} ${label} failed${reason}`\n\n const phase = state.phase\n if (phase) {\n if (phase.showHookResults || !success) {\n phase.lines.push(result)\n }\n phase.output.push(...active.lines)\n return\n }\n\n stopSpinner()\n writer.step(text(result))\n writeOutput(active.lines)\n })\n\n context.hook('kubb:generation:end', () => {\n stopSpinner()\n stopProgress()\n })\n\n context.hook('kubb:lifecycle:end', () => {\n closeGroup('failed')\n reset()\n })\n\n return {\n renderSummary(lines, { status }) {\n if (silent || !state.groupOpen) {\n return\n }\n\n closeGroup(status)\n writer.diagnostic([...lines])\n },\n }\n }\n}\n","import { styleText } from 'node:util'\nimport * as clack from '@clack/prompts'\nimport { createLogger } from './createLogger.ts'\nimport type { Logger, LoggerWriter } from './defineLogger.ts'\n\n/**\n * Draws with clack: a gutter bar per group, animated steps, and a progress bar for the writes.\n */\nconst writer: LoggerWriter = {\n group: (title) => clack.intro(title),\n groupEnd: (text) => clack.outro(text),\n step: (text) => clack.log.step(text, { spacing: 0 }),\n info: (text) => clack.log.info(text),\n success: (text) => clack.log.success(text),\n warn: (text) => clack.log.warn(text),\n error: (text) => clack.log.error(text),\n block: (lines) => clack.log.message(lines, { spacing: 0 }),\n // A subprocess's output is not Kubb's tree, so it goes out past clack and its gutter bar. The\n // step above it is already stopped by the time this runs.\n raw: (lines) => console.log(styleText('dim', lines.join('\\n'))),\n // The diagnostic carries its own code and indented rows, so clear clack's gutter and bar and let\n // the block stand on its own.\n diagnostic: (lines) => clack.log.message(lines, { symbol: '', secondarySymbol: '' }),\n update: (lines, title) =>\n clack.box(lines.join('\\n'), title, {\n width: 'auto',\n formatBorder: (border: string) => styleText('yellow', border),\n rounded: true,\n withGuide: false,\n contentAlign: 'center',\n titleAlign: 'center',\n }),\n spinner() {\n const spinner = clack.spinner()\n\n return {\n start: (text) => spinner.start(text),\n message: (text) => spinner.message(text),\n clear: () => spinner.clear(),\n stop: (text) => spinner.stop(text),\n error: (text) => spinner.error(text),\n }\n },\n progress(max) {\n const bar = clack.progress({ style: 'block', max, size: 30 })\n\n return {\n start: (text) => bar.start(text),\n advance: (text) => bar.advance(1, text),\n stop: (text) => bar.stop(text),\n }\n },\n}\n\n/**\n * TTY logger for local development, with animated steps and progress bars.\n */\nexport const clackLogger = {\n name: 'clack',\n install: createLogger(writer),\n} satisfies Logger\n","import { createLogger } from './createLogger.ts'\nimport type { Logger, LoggerWriter } from './defineLogger.ts'\n\n/**\n * Prefixes that stand in for the symbols clack draws, so plain output reads the same way.\n */\nconst SYMBOLS = { info: 'ℹ', warn: '⚠', error: '✗', step: '◇' } as const\n\nfunction write(line: string): void {\n console.log(line)\n}\n\n/**\n * Draws with `console.log` alone. Nothing animates, so a step prints when it starts and again when\n * it ends, and every message it was given in between.\n */\nconst writer: LoggerWriter = {\n group: write,\n groupEnd: write,\n step: (text) => write(`${SYMBOLS.step} ${text}`),\n info: write,\n success: write,\n warn: write,\n error: write,\n block: (lines) => write(lines.join('\\n')),\n raw: (lines) => write(lines.join('\\n')),\n diagnostic: (lines) => write(lines.join('\\n')),\n update: (lines, title) => write([title, ...lines].join('\\n')),\n spinner: () => ({\n start: write,\n message: write,\n clear: () => {},\n stop: (text) => text && write(text),\n error: (text) => write(`${SYMBOLS.error} ${text}`),\n }),\n progress: () => ({\n start: write,\n advance: write,\n stop: (text) => text && write(text),\n }),\n}\n\n/**\n * Console adapter for non-TTY environments, and for an AI coding agent reading the output. Reports\n * the same run in the same order as `clackLogger`, without the animation.\n */\nexport const plainLogger = {\n name: 'plain',\n install: createLogger(writer),\n} satisfies Logger\n","import process from 'node:process'\nimport { styleText } from 'node:util'\nimport { formatMs, getElapsedMs } from '@internals/utils'\nimport type { Config, Reporter, ReporterContext, ReporterPluginFiles } from '@kubb/core'\nimport { createCliReporter, logLevel as logLevelMap } from '@kubb/core'\nimport type { StudioConnectedContext } from '@kubb/studio'\nimport { getAgentName } from '../agent.ts'\nimport { canUseTTY } from '../utils/env.ts'\nimport type { LoggerContext, LoggerOptions } from './defineLogger.ts'\nimport { clackLogger } from './clackLogger.ts'\nimport { plainLogger } from './plainLogger.ts'\n\n/**\n * Display path for a config's input: the string form, or its `path` field when the input is an\n * object. Loggers show it alongside `Generation started`.\n */\nexport function getInputPath(config: Config): string | undefined {\n const { input } = config\n if (typeof input === 'string') return input\n return typeof input?.path === 'string' ? input.path : undefined\n}\n\n/**\n * Counts a noun, so a message never reads `1 files`.\n *\n * @example\n * `pluralize(1, 'config')` returns `'1 config'`\n */\nexport function pluralize(count: number, noun: string): string {\n return `${count} ${count === 1 ? noun : `${noun}s`}`\n}\n\n/**\n * Optionally prefix a message with a [HH:MM:SS] timestamp when logLevel >= verbose.\n * Shared across all logger adapters to avoid duplication.\n */\nexport function formatMessage(message: string, logLevel: number): string {\n if (logLevel >= logLevelMap.verbose) {\n const timestamp = new Date().toLocaleTimeString('en-US', {\n hour12: false,\n hour: '2-digit',\n minute: '2-digit',\n second: '2-digit',\n })\n return `${styleText('dim', `[${timestamp}]`)} ${message}`\n }\n return message\n}\n\n/**\n * Renders the versions from a `studio:connected` event as one parenthetical. The runtime is listed\n * only when it differs from the host, and Studio's only when it sent one.\n */\nexport function formatVersions({ studio, kubb, agent }: StudioConnectedContext['versions']): string {\n return [`v${agent}`, kubb !== agent ? `runtime v${kubb}` : undefined, studio ? `Studio v${studio}` : undefined].filter(Boolean).join(', ')\n}\n\n/**\n * Extracts the `.cause` of an `Error` as an `Error`, or `undefined` when absent or not an `Error`.\n */\nfunction toCause(error: Error): Error | undefined {\n return error.cause instanceof Error ? error.cause : undefined\n}\n\n/**\n * First stack frames for verbose error output, including an optional `cause` chain.\n */\nexport function formatErrorFrames(error: Error): { frames: Array<string>; cause?: { header: string; frames: Array<string> } } | null {\n if (!error.stack) {\n return null\n }\n\n const frames = error.stack\n .split('\\n')\n .slice(1, 4)\n .map((frame) => frame.trim())\n const caused = toCause(error)\n\n if (!caused?.stack) {\n return { frames }\n }\n\n return {\n frames,\n cause: {\n header: `└─ caused by ${caused.message}`,\n frames: caused.stack\n .split('\\n')\n .slice(1, 4)\n .map((frame) => frame.trim()),\n },\n }\n}\n\ntype ProgressState = {\n /**\n * Total number of plugins scheduled for this generation run.\n */\n totalPlugins: number\n /**\n * Number of plugins that have finished without error.\n */\n completedPlugins: number\n /**\n * Number of plugins that exited with an error.\n */\n failedPlugins: number\n /**\n * Total number of files expected to be written.\n */\n totalFiles: number\n /**\n * Number of files written so far.\n */\n processedFiles: number\n /**\n * `process.hrtime()` snapshot taken at the start of generation, used to compute elapsed time.\n */\n hrStart: [number, number]\n}\n\n/**\n * Build the progress summary line shown by the clack logger.\n * Returns null when there is nothing to display.\n */\nexport function buildProgressLine(state: ProgressState): string | null {\n const parts: Array<string> = []\n const duration = formatMs(getElapsedMs(state.hrStart))\n\n if (state.totalPlugins > 0) {\n const pluginStr =\n state.failedPlugins > 0\n ? `Plugins ${styleText('green', state.completedPlugins.toString())}/${state.totalPlugins} ${styleText('red', `(${state.failedPlugins} failed)`)}`\n : `Plugins ${styleText('green', state.completedPlugins.toString())}/${state.totalPlugins}`\n parts.push(pluginStr)\n }\n\n if (state.totalFiles > 0) {\n parts.push(`Files ${styleText('green', state.processedFiles.toString())}/${state.totalFiles}`)\n }\n\n if (parts.length === 0) {\n return null\n }\n\n parts.push(`${styleText('green', duration)} elapsed`)\n return parts.join(styleText('dim', ' | '))\n}\n\n/**\n * Creates the per-run progress counters used by the clack logger.\n */\nexport function createProgressCounters(): ProgressState {\n return {\n totalPlugins: 0,\n completedPlugins: 0,\n failedPlugins: 0,\n totalFiles: 0,\n processedFiles: 0,\n hrStart: process.hrtime(),\n }\n}\n\n/**\n * Resets the progress counters in place at the start/end of a generation run.\n */\nexport function resetProgressCounters(state: ProgressState): void {\n state.totalPlugins = 0\n state.completedPlugins = 0\n state.failedPlugins = 0\n state.totalFiles = 0\n state.processedFiles = 0\n state.hrStart = process.hrtime()\n}\n\n/**\n * Records a finished plugin against the progress counters.\n */\nexport function recordPluginResult(state: ProgressState, success: boolean): void {\n if (success) {\n state.completedPlugins++\n } else {\n state.failedPlugins++\n }\n}\n\n/**\n * Tracks per-hook start times so a logger can report a hook's elapsed duration.\n * Used by the plain logger, which keys timing by hook `id`.\n */\ntype HookTimer = {\n start(id: string): void\n /**\n * Returns the elapsed milliseconds since `start(id)`, or `undefined` when no start was recorded.\n */\n end(id: string): number | undefined\n}\n\n/**\n * Creates a {@link HookTimer} backed by a private `id → hrtime` map.\n */\nexport function createHookTimer(): HookTimer {\n const starts = new Map<string, [number, number]>()\n\n return {\n start(id: string): void {\n starts.set(id, process.hrtime())\n },\n end(id: string): number | undefined {\n const hrStart = starts.get(id)\n if (!hrStart) {\n return undefined\n }\n starts.delete(id)\n return getElapsedMs(hrStart)\n },\n }\n}\n\n/**\n * Join a command and its optional args into a single display string.\n *\n * @example With args\n * `formatCommandWithArgs('prettier', ['--write', '.'])` returns `'prettier --write .'`\n */\nexport function formatCommandWithArgs(command: string, args?: ReadonlyArray<string>): string {\n return args?.length ? `${command} ${args.join(' ')}` : command\n}\n\n/**\n * Bridges a {@link Reporter} onto the run's hook emitter: calls `report` with each config's\n * {@link GenerationResult} on `kubb:generation:end`. The reporter never touches the emitter.\n */\nexport function installReporter(context: LoggerContext, reporter: Reporter, ctx: ReporterContext): void {\n const pluginFiles = reporter.needsPluginFiles ? new Map<Config, Map<string, Set<string>>>() : undefined\n\n if (pluginFiles) {\n context.hook('kubb:plugin:end', ({ config, plugin, files }) => {\n const filesByPlugin = pluginFiles.get(config) ?? new Map<string, Set<string>>()\n const seen = new Set([...filesByPlugin.values()].flatMap((paths) => [...paths]))\n const added = files.filter((file) => !seen.has(file.path)).map((file) => file.path)\n\n if (added.length) filesByPlugin.set(plugin.name, new Set([...(filesByPlugin.get(plugin.name) ?? []), ...added]))\n\n pluginFiles.set(config, filesByPlugin)\n })\n }\n\n context.hook('kubb:generation:end', async ({ config, diagnostics = [], filesCreated = 0, status = 'success', hrStart = process.hrtime() }) => {\n const files = pluginFiles?.get(config)\n const grouped: ReporterPluginFiles | undefined = files && [...files].map(([plugin, paths]) => ({ plugin, files: [...paths] }))\n\n await reporter.report({ config, diagnostics, filesCreated, status, hrStart, pluginFiles: grouped }, ctx)\n\n pluginFiles?.delete(config)\n })\n\n if (reporter.drain) {\n context.hook('kubb:lifecycle:end', () => reporter.drain?.(ctx))\n }\n}\n\n/**\n * Installs the live logger (the TUI view) and the given reporters (the output). The reporters are\n * already selected by the caller (the CLI maps `--reporter` to names via `selectReporters`). This\n * only wires them. Loggers receive hook subprocess output through `kubb:hook:line` and the\n * `stdout`/`stderr` on `kubb:hook:end`, so nothing is returned here.\n *\n * Loggers and reporters are independent, except for `cli`: it both installs the live logger view\n * here and registers a reporter that renders the per-config summary through that logger, so the\n * summary lands inside the group the logger opened. The `json` reporter owns stdout, so the whole\n * `cli` reporter (live logger and summary) is skipped whenever `json` is among the reporters, even\n * if `cli` is also listed.\n */\nasync function setupReporters(context: LoggerContext, { logLevel, reporters }: LoggerOptions & { reporters: ReadonlyArray<Reporter> }): Promise<void> {\n const hasJson = reporters.some((reporter) => reporter.name === 'json')\n const ctx: ReporterContext = { logLevel }\n\n for (const reporter of reporters) {\n if (reporter.name !== 'cli') {\n installReporter(context, reporter, ctx)\n continue\n }\n\n if (hasJson) {\n continue\n }\n\n // Spinners and cursor-movement escapes are hard for an AI coding agent to parse, even over a pseudo-TTY.\n const logger = canUseTTY() && !getAgentName() ? clackLogger : plainLogger\n const handle = await logger.install(context, { logLevel })\n\n // The summary belongs inside the group the logger opened for this config, so hand the writing\n // to the logger rather than letting the reporter print alongside it.\n installReporter(context, createCliReporter({ render: handle?.renderSummary }), ctx)\n }\n}\n\nexport default setupReporters\n\n/**\n * Picks the reporters whose `name` matches one of `names`, in the order the names are given.\n * The config carries every available reporter, and the host selects which to activate by name\n * (the CLI maps `--reporter` to this). Duplicate names and names without a matching reporter are\n * skipped.\n */\nexport function selectReporters(reporters: ReadonlyArray<Reporter>, names: ReadonlyArray<string>): Array<Reporter> {\n const seen = new Set<string>()\n const selected: Array<Reporter> = []\n\n for (const name of names) {\n if (seen.has(name)) {\n continue\n }\n seen.add(name)\n\n const reporter = reporters.find((candidate) => candidate.name === name)\n if (reporter) {\n selected.push(reporter)\n }\n }\n\n return selected\n}\n","import { createJiti } from 'jiti'\n\n/**\n * jiti options for loading Kubb config modules: the automatic JSX runtime pointed at\n * `@kubb/renderer-jsx`, and `moduleCache` off so a re-load re-evaluates the file.\n */\nconst JITI_OPTIONS = {\n jsx: { runtime: 'automatic', importSource: '@kubb/renderer-jsx' },\n moduleCache: false,\n} satisfies Parameters<typeof createJiti>[1]\n\n/**\n * Per-call options for {@link ModuleLoader.load}.\n */\ntype LoadModuleOptions = {\n /**\n * Return the module's default export instead of the full namespace.\n */\n default?: boolean\n}\n\n/**\n * Loads `.ts`/`.js` modules via jiti.\n */\ntype ModuleLoader = {\n load<T = unknown>(filePath: string, options?: LoadModuleOptions): Promise<T>\n}\n\n/**\n * Creates a jiti-based loader for Kubb's TypeScript and JavaScript config modules.\n *\n * jiti transpiles TypeScript and the `@kubb/renderer-jsx` JSX runtime on the fly.\n *\n * @example\n * ```ts\n * const config = await createModuleLoader().load('/abs/kubb.config.ts', { default: true })\n * ```\n */\nexport function createModuleLoader(): ModuleLoader {\n const jiti = createJiti(import.meta.url, JITI_OPTIONS)\n\n return {\n load<T>(filePath: string, options?: LoadModuleOptions) {\n return (options?.default ? jiti.import(filePath, { default: true }) : jiti.import(filePath)) as Promise<T>\n },\n }\n}\n","import { randomUUID } from 'node:crypto'\nimport { basename, dirname, resolve } from 'node:path'\nimport process from 'node:process'\nimport { styleText } from 'node:util'\nimport { createModuleLoader } from '@internals/shared'\nimport { toError, tokenize } from '@internals/utils'\nimport type { CLIOptions, Config, KubbHooks, PossibleConfig, PostGenerateCommand, Hookable } from '@kubb/core'\nimport { NonZeroExitError, x } from 'tinyexec'\nimport { type LoadConfigResult, type LoadConfigSource, loadConfig } from 'unconfig'\nimport { isGreater, isValid, truncate } from 'verkit'\nimport { URL_WATCHER_INTERVAL_MS, URL_WATCHER_TIMEOUT_MS, WATCHER_DEBOUNCE_MS, WATCHER_IGNORED_PATHS } from '../../constants.ts'\n\nconst loader = createModuleLoader()\n\n// Kubb configs are JS/TS modules (they call `defineConfig`/`pluginX()`), so YAML and JSON are not\n// supported. The jiti loader handles every module format and the JSX runtime, returning the default export.\nconst tsLoader = (configFile: string) => loader.load(configFile, { default: true })\n\nconst MODULE_NAME = 'kubb'\n\nconst SEARCH_FILES = ['', '.config/', 'configs/'].flatMap((prefix) => [`${prefix}.${MODULE_NAME}rc`, `${prefix}${MODULE_NAME}.config`])\nconst SEARCH_EXTENSIONS = ['ts', 'mts', 'cts', 'js', 'mjs', 'cjs']\n\ntype GetConfigsOptions = {\n /**\n * Explicit path to the Kubb config file. When omitted, the loader searches up from the current directory.\n */\n configPath?: string\n /**\n * Optional OpenAPI input path or URL that overrides `config.input` for this run.\n */\n input?: string\n /**\n * Watch flag forwarded to the user's `defineConfig` function.\n */\n watch?: boolean\n /**\n * Log level forwarded to the user's `defineConfig` function.\n */\n logLevel?: CLIOptions['logLevel']\n}\n\ntype GetConfigsResult = {\n /**\n * Absolute path to the resolved config file.\n */\n configPath: string\n /**\n * Resolved and normalized array of Kubb configs, each guaranteed to have a `plugins` array.\n */\n configs: Array<Config>\n}\n\n/**\n * Discovers the Kubb config and resolves it into a normalized array of configs.\n * Every config in the result is guaranteed to have a `plugins` array.\n */\nexport async function getConfigs({ configPath, input, watch, logLevel }: GetConfigsOptions): Promise<GetConfigsResult> {\n const abs = configPath ? resolve(configPath) : undefined\n const sources: Array<LoadConfigSource<unknown>> = abs\n ? [{ files: [basename(abs)], extensions: [], parser: tsLoader }]\n : [{ files: SEARCH_FILES, extensions: SEARCH_EXTENSIONS, parser: tsLoader }]\n\n let result: LoadConfigResult<unknown>\n try {\n result = await loadConfig<unknown>({ cwd: abs ? dirname(abs) : process.cwd(), sources, merge: false })\n } catch (error) {\n throw new Error('Config failed loading', { cause: error })\n }\n\n const [filepath] = result.sources\n if (!result.config || !filepath) {\n throw new Error('Config not defined, create a kubb.config.js or pass through your config with the option --config')\n }\n\n const config = result.config as PossibleConfig<CLIOptions>\n const cli: CLIOptions = { config: configPath, input, watch, logLevel }\n const resolved = await (typeof config === 'function' ? config(cli) : config)\n const userConfigs = Array.isArray(resolved) ? resolved : [resolved]\n\n return {\n configPath: filepath,\n configs: userConfigs.map((item) => {\n const config: Config = { ...item, plugins: item.plugins ?? [] }\n return config\n }),\n }\n}\n\ntype RunPostGenerateOptions = {\n commands: Array<PostGenerateCommand>\n hooks: Hookable<KubbHooks>\n}\n\n/**\n * Outcome of a single hook subprocess, returned by `runHook` alongside the\n * `kubb:hook:end` hook it emits for the loggers.\n */\ntype HookResult = {\n /**\n * `true` when the command exited with code `0`.\n */\n success: boolean\n /**\n * What went wrong, `null` when the command succeeded.\n */\n error: Error | null\n /**\n * Captured stdout, only present on a non-zero exit.\n */\n stdout?: string\n /**\n * Captured stderr, only present on a non-zero exit.\n */\n stderr?: string\n}\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 isGreater(truncate(latest, 'patch') as string, truncate(current, 'patch') as string)\n}\n\n/**\n * Runs the `output.postGenerate` commands of a Kubb config in sequence and returns each command's\n * outcome, so the caller can turn failures into diagnostics.\n */\nexport async function runPostGenerate({ commands, hooks }: RunPostGenerateOptions): Promise<Array<HookResult>> {\n const results: Array<HookResult> = []\n\n for (const entry of commands) {\n const { command, name } = typeof entry === 'string' ? { command: entry, name: undefined } : entry\n const [cmd, ...args] = tokenize(command)\n if (!cmd) continue\n\n const hookId = randomUUID()\n const commandWithArgs = [cmd, ...args].join(' ')\n\n await hooks.callHook('kubb:hook:start', { id: hookId, command: cmd, name, args })\n results.push(await runHook({ id: hookId, command: cmd, name, args, commandWithArgs, hooks }))\n }\n\n return results\n}\n\ntype RunHookOptions = {\n id: string\n command: string\n name?: string\n args?: ReadonlyArray<string>\n commandWithArgs: string\n hooks: Hookable<KubbHooks>\n}\n\n/**\n * Spawns a hook command and returns its outcome, mirroring it through `kubb:hook:end` for the\n * loggers. A non-zero exit returns `success: false` rather than throwing, so the caller can turn\n * it into a diagnostic. Other spawn errors do the same. Output is streamed through `kubb:hook:line`\n * only while a listener is attached.\n */\nexport async function runHook({ id, command, name, args, commandWithArgs, hooks }: RunHookOptions): Promise<HookResult> {\n const emitEnd = async (result: HookResult): Promise<HookResult> => {\n await hooks.callHook('kubb:hook:end', { command, name, args, id, ...result })\n return result\n }\n\n // Only stream line-by-line when a logger is listening, so the non-streaming plain\n // logger doesn't pay to iterate the subprocess output.\n const stream = hooks.listenerCount('kubb:hook:line') > 0\n\n try {\n const proc = x(command, [...(args ?? [])], {\n nodeOptions: { detached: process.platform !== 'win32' },\n throwOnError: true,\n })\n\n if (stream) {\n for await (const line of proc) {\n await hooks.callHook('kubb:hook:line', { id, line })\n }\n }\n\n await proc\n await hooks.callHook('kubb:success', { message: `${styleText('dim', name ?? commandWithArgs)} successfully executed` })\n return emitEnd({ success: true, error: null })\n } catch (err) {\n if (!(err instanceof NonZeroExitError)) {\n return emitEnd({ success: false, error: toError(err) })\n }\n\n const stderr = err.output?.stderr ?? ''\n const stdout = err.output?.stdout ?? ''\n\n const error = new Error(`Hook execute failed: ${commandWithArgs}`)\n // Signal the failure via the result and `kubb:hook:end` only, carrying the captured output so\n // the logger can render it. The caller turns this into a coded diagnostic and emits that\n // through `Diagnostics.emit`, so emitting `kubb:error` here would render it twice.\n return emitEnd({ success: false, error, stdout, stderr })\n }\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.\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<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\n/**\n * Fetches the body of a remote spec URL, `undefined` when the server does not answer with a\n * readable 2xx body within the timeout. 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, timeoutMs: number = URL_WATCHER_TIMEOUT_MS): Promise<string | undefined> {\n try {\n const response = await fetch(url, { signal: AbortSignal.timeout(timeoutMs) })\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 poll = async (): Promise<void> => {\n controller = new AbortController()\n try {\n // The signal also aborts the body read, so a response that stalls mid-stream still times out.\n const signal = AbortSignal.any([controller.signal, AbortSignal.timeout(timeoutMs)])\n const response = await fetch(url, { signal })\n if (!response.ok) {\n throw new Error(`HTTP ${response.status}`)\n }\n const body = await response.text()\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 } catch {\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 }\n if (!stopped) {\n timer = setTimeout(() => void poll(), intervalMs)\n }\n }\n\n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UAAU;IACV,IAAI,MAAM,UAAU,OAAO,gBAAgB,IAAI,kCAAkC,CAAC;GACpF;EACF;EACA,IAAI,CAAC,SACH,QAAQ,iBAAiB,KAAK,KAAK,GAAG,UAAU;CAEpD;CAEA,KAAU;CAEV,OAAO;AACT"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils-BP0xq5AK.cjs","names":["spawn","logLevelMap","process","formatMsWithColor","getElapsedMs","styleText","Diagnostics","relative","writer","clack","styleText","logLevelMap","styleText","formatMs","getElapsedMs","process","canUseTTY","getAgentName","createCliReporter","jiti","createJiti","resolve","basename","loadConfig","dirname","process","isValid","isGreater","truncate","randomUUID","x","styleText","NonZeroExitError","toError","WATCHER_IGNORED_PATHS","URL_WATCHER_TIMEOUT_MS","URL_WATCHER_INTERVAL_MS"],"sources":["../../../internals/utils/src/tools.ts","../src/loggers/createLogger.ts","../src/loggers/clackLogger.ts","../src/loggers/plainLogger.ts","../src/loggers/utils.ts","../../../internals/shared/src/loader.ts","../src/runners/generate/utils.ts"],"sourcesContent":["import { spawn } from 'node:child_process'\n\n/**\n * How one formatter or linter is invoked: the executable, the argv it takes for an output\n * directory, and what to report when it is not installed.\n */\nexport type ToolCommand = {\n command: string\n args: (outputPath: string) => Array<string>\n errorMessage: string\n}\n\n/**\n * CLI command descriptors for each supported code formatter.\n */\nexport const formatters = {\n prettier: {\n command: 'prettier',\n args: (outputPath: string) => ['--ignore-unknown', '--write', outputPath],\n errorMessage: 'Prettier not found',\n },\n biome: {\n command: 'biome',\n args: (outputPath: string) => ['format', '--write', outputPath],\n errorMessage: 'Biome not found',\n },\n oxfmt: {\n command: 'oxfmt',\n args: (outputPath: string) => [outputPath],\n errorMessage: 'Oxfmt not found',\n },\n} as const satisfies Record<string, ToolCommand>\n\n/**\n * CLI command descriptors for each supported linter.\n */\nexport const linters = {\n eslint: {\n command: 'eslint',\n args: (outputPath: string) => [outputPath, '--fix'],\n errorMessage: 'Eslint not found',\n },\n biome: {\n command: 'biome',\n args: (outputPath: string) => ['lint', '--fix', outputPath],\n errorMessage: 'Biome not found',\n },\n oxlint: {\n command: 'oxlint',\n // --no-ignore so oxlint lints the folder even when it's gitignored (generated output dirs usually are).\n args: (outputPath: string) => ['--fix', '--no-ignore', outputPath],\n errorMessage: 'Oxlint not found',\n },\n} as const satisfies Record<string, ToolCommand>\n\n/**\n * Preference order for `format: 'auto'`, most-preferred first. Spelled out rather than taken from\n * the table's key order, which is arbitrary and would silently change what `auto` picks.\n */\nexport const FORMATTER_PREFERENCE = ['oxfmt', 'biome', 'prettier'] as const\n\n/**\n * Preference order for `lint: 'auto'`, most-preferred first.\n */\nexport const LINTER_PREFERENCE = ['oxlint', 'biome', 'eslint'] as const\n\n/**\n * Whether `name` is on PATH and answers `--version` with a zero exit.\n */\nexport function isToolAvailable(name: string): Promise<boolean> {\n return new Promise((resolve) => {\n const child = spawn(name, ['--version'], { stdio: 'ignore' })\n child.on('close', (code) => resolve(code === 0))\n child.on('error', () => resolve(false))\n })\n}\n\n/**\n * Returns the first installed executable from `candidates`, or `null` when none are found.\n *\n * Not memoized: a long-running host that probes repeatedly should cache the result itself, and a\n * `--watch` build should keep noticing a tool installed mid-session.\n */\nexport async function detectTool<TName extends string>(candidates: ReadonlyArray<TName>): Promise<TName | null> {\n for (const candidate of candidates) {\n if (await isToolAvailable(candidate)) {\n return candidate\n }\n }\n\n return null\n}\n\n/**\n * Tokenizes a shell command string, respecting single and double quotes.\n *\n * @example\n * ```ts\n * tokenize('git commit -m \"initial commit\"')\n * // → ['git', 'commit', '-m', 'initial commit']\n * ```\n */\nexport function tokenize(command: string): Array<string> {\n return (command.match(/[^\\s\"']+|\"([^\"]*)\"|'([^']*)'/g) ?? []).map((token) => token.replace(/^[\"']|[\"']$/g, ''))\n}\n","import { relative } from 'node:path'\nimport process from 'node:process'\nimport { styleText } from 'node:util'\nimport { getElapsedMs } from '@internals/utils'\nimport { Diagnostics, logLevel as logLevelMap } from '@kubb/core'\nimport { formatMsWithColor } from './banner.ts'\nimport type { LoggerContext, LoggerHandle, LoggerOptions, LoggerWriter, LogStatus, WriterProgress, WriterSpinner } from './defineLogger.ts'\nimport {\n buildProgressLine,\n createProgressCounters,\n formatCommandWithArgs,\n formatErrorFrames,\n formatMessage,\n formatVersions,\n getInputPath,\n pluralize,\n recordPluginResult,\n resetProgressCounters,\n} from './utils.ts'\n\n/**\n * One output phase while its step owns the line. A phase buffers what it is told, because a spinner\n * redraws over anything written under it, and prints the lot once it knows its own result.\n */\ntype Phase = {\n successLabel: string\n failureLabel: string\n /**\n * Whether each hook's own result is worth a line. Format and lint run one command, so the phase\n * result already says everything; the post-generate phase runs several.\n */\n showHookResults: boolean\n failed: boolean\n hrStart: [number, number]\n lines: Array<string>\n /**\n * Raw lines a hook printed, drawn outside the group.\n */\n output: Array<string>\n}\n\ntype StartPhaseOptions = {\n /**\n * Shown while the phase runs.\n */\n running: string\n success: string\n failure: string\n showHookResults?: boolean\n}\n\n/**\n * The three output phases, in the order the generate runner runs them.\n */\nconst PHASES = {\n format: { running: 'Formatting', success: 'Formatted', failure: 'Formatting failed' },\n lint: { running: 'Linting', success: 'Linted', failure: 'Linting failed' },\n hooks: {\n running: 'Running post-generate hooks',\n success: 'Post-generate hooks completed',\n failure: 'Post-generate hooks failed',\n showHookResults: true,\n },\n} as const satisfies Record<string, StartPhaseOptions>\n\n/**\n * Drops the blank lines a subprocess leaves at either end of its output, so its block does not open\n * or close on an empty row.\n */\nfunction trimBlankEdges(lines: ReadonlyArray<string>): Array<string> {\n const start = lines.findIndex((line) => line.trim())\n if (start === -1) {\n return []\n }\n\n return lines.slice(start, lines.findLastIndex((line) => line.trim()) + 1)\n}\n\n/**\n * Wires a {@link LoggerWriter} onto the run's hooks. This owns what a run says and in what order:\n * one group per config, a step over the plugin work, a progress bar for the writes, one step per\n * output phase, then the summary and the group's closing result. The writer only decides how each\n * line looks, so every logger reports the same run the same way.\n *\n * @example\n * ```ts\n * export const plainLogger = { name: 'plain', install: (context, options) => createLogger(writer)(context, options) }\n * ```\n */\nexport function createLogger(writer: LoggerWriter) {\n return function install(context: LoggerContext, options?: LoggerOptions): LoggerHandle {\n const logLevel = options?.logLevel ?? logLevelMap.info\n const silent = logLevel <= logLevelMap.silent\n const state = {\n ...createProgressCounters(),\n spinner: null as WriterSpinner | null,\n progress: null as WriterProgress | null,\n hooks: new Map<string, { hrStart: [number, number]; lines: Array<string> }>(),\n /**\n * Plugin results held back while the generation step owns the line.\n */\n pluginLines: [] as Array<string>,\n phase: null as Phase | null,\n groupOpen: false,\n }\n\n function text(message: string): string {\n return formatMessage(message, logLevel)\n }\n\n function startSpinner(message: string) {\n if (silent) {\n return\n }\n\n state.spinner = writer.spinner()\n state.spinner.start(text(message))\n }\n\n function stopSpinner(message?: string, status: LogStatus = 'success') {\n const spinner = state.spinner\n if (!spinner) {\n return\n }\n state.spinner = null\n\n if (message === undefined) {\n spinner.clear()\n return\n }\n if (status === 'failed') {\n spinner.error(text(message))\n return\n }\n spinner.stop(text(message))\n }\n\n function stopProgress(message?: string) {\n const progress = state.progress\n if (!progress) {\n return\n }\n state.progress = null\n progress.stop(message === undefined ? '' : text(message))\n }\n\n function startPhase({ running, success, failure, showHookResults = false }: StartPhaseOptions) {\n state.phase = { successLabel: success, failureLabel: failure, showHookResults, failed: false, hrStart: process.hrtime(), lines: [], output: [] }\n startSpinner(running)\n }\n\n function endPhase() {\n const phase = state.phase\n state.phase = null\n\n if (!phase || silent) {\n return\n }\n\n const duration = formatMsWithColor(getElapsedMs(phase.hrStart))\n\n stopSpinner(phase.failed ? `${phase.failureLabel} after ${duration}` : `${phase.successLabel} in ${duration}`, phase.failed ? 'failed' : 'success')\n\n if (phase.lines.length) {\n writer.block(phase.lines)\n }\n writeOutput(phase.output)\n }\n\n function writeOutput(lines: ReadonlyArray<string>) {\n const output = trimBlankEdges(lines)\n if (output.length) {\n writer.raw(output)\n }\n }\n\n // A run that throws before `kubb:generation:end` never reaches the summary, so the lifecycle\n // end calls this too rather than leave a group without its closing line.\n function closeGroup(status: LogStatus) {\n if (!state.groupOpen) {\n return\n }\n state.groupOpen = false\n\n stopSpinner()\n stopProgress()\n writer.groupEnd(status === 'failed' ? styleText('red', '✗ Generation failed') : styleText('green', '✓ Generation succeeded'))\n }\n\n function reset() {\n stopSpinner()\n stopProgress()\n resetProgressCounters(state)\n state.hooks.clear()\n state.pluginLines = []\n state.phase = null\n state.groupOpen = false\n }\n\n context.hook('kubb:info', ({ message, info }) => {\n if (silent) {\n return\n }\n\n const line = text([styleText('blue', 'ℹ'), message, info ? styleText('dim', info) : undefined].filter(Boolean).join(' '))\n\n // Info carries something new (the auto-detected tool), so inside a phase it waits for the\n // phase to print rather than being spent on a frame the next one overwrites.\n if (state.phase) {\n state.phase.lines.push(line)\n return\n }\n if (state.spinner) {\n state.spinner.message(line)\n return\n }\n writer.info(line)\n })\n\n context.hook('kubb:success', ({ message, info }) => {\n if (silent) {\n return\n }\n\n const line = text([styleText('green', '✓'), message, logLevel >= logLevelMap.info && info ? styleText('dim', info) : undefined].filter(Boolean).join(' '))\n\n // A phase step outlives the successes reported inside it, and its own result says the same\n // thing, so let the step carry them.\n if (state.spinner) {\n state.spinner.message(line)\n return\n }\n writer.success(line)\n })\n\n context.hook('kubb:warn', ({ message, info }) => {\n if (logLevel < logLevelMap.warn) {\n return\n }\n\n writer.warn(\n text([styleText('yellow', '⚠'), message, logLevel >= logLevelMap.info && info ? styleText('dim', info) : undefined].filter(Boolean).join(' ')),\n )\n })\n\n // Unguarded: a failure stays visible even at silent.\n context.hook('kubb:error', ({ error }) => {\n if (state.phase) {\n state.phase.failed = true\n }\n\n const line = [styleText('red', '✗'), error.message].join(' ')\n\n if (state.spinner) {\n stopSpinner(line, 'failed')\n } else {\n writer.error(text(line))\n }\n\n const frames = logLevel >= logLevelMap.verbose ? formatErrorFrames(error) : null\n if (!frames) {\n return\n }\n\n writer.block(frames.frames.map((frame) => text(styleText('dim', frame))))\n if (frames.cause) {\n writer.block([styleText('dim', frames.cause.header), ...frames.cause.frames.map((frame) => text(` ${styleText('dim', frame)}`))])\n }\n })\n\n context.hook('kubb:diagnostic', ({ diagnostic }) => {\n // Silent still surfaces errors so failures stay visible. It drops warnings and info.\n if (silent && diagnostic.severity !== 'error') {\n return\n }\n\n stopSpinner()\n stopProgress()\n\n if (Diagnostics.isUpdate(diagnostic)) {\n writer.update(\n [`\\`v${diagnostic.currentVersion}\\` → \\`v${diagnostic.latestVersion}\\``, 'Run `npm install -g @kubb/cli` to update'],\n 'Update available for `Kubb`',\n )\n return\n }\n\n const { headline, details } = Diagnostics.format(diagnostic)\n writer.diagnostic([headline, ...details])\n })\n\n // A `kubb studio` session emits these on the same emitter as its generations, so one logger\n // renders the whole command. The socket opens without being awaited, hence the step.\n context.hook('studio:connecting', ({ url }) => {\n startSpinner(`Connecting to ${styleText('cyan', url)}`)\n })\n\n context.hook('studio:connected', ({ url, versions }) => {\n if (silent) {\n return\n }\n\n const line = `Connected to ${styleText('cyan', url)} ${styleText('dim', `(${formatVersions(versions)})`)}`\n\n if (state.spinner) {\n stopSpinner(line)\n return\n }\n writer.success(text(`✓ ${line}`))\n })\n\n context.hook('studio:ready', () => {\n if (silent) {\n return\n }\n startSpinner('✓ Ready to receive jobs')\n })\n\n context.hook('studio:disconnected', ({ reason }) => {\n if (logLevel < logLevelMap.warn) {\n return\n }\n\n stopSpinner()\n writer.warn(text(`⚠ Kubb Studio ended the session (${reason})`))\n })\n\n context.hook('studio:command:start', ({ command }) => {\n if (silent) {\n return\n }\n stopSpinner()\n writer.info(text(`Kubb Studio asked to ${styleText('bold', command)}`))\n })\n\n context.hook('studio:command:end', ({ command, info }) => {\n if (silent) {\n return\n }\n writer.success(text(`✓ Finished ${command}${info ? ` ${styleText('dim', `(${info})`)}` : ''}`))\n startSpinner('✓ Ready to receive jobs')\n })\n\n context.hook('studio:warn', ({ message }) => {\n if (logLevel < logLevelMap.warn) {\n return\n }\n writer.warn(text(`⚠ ${message}`))\n })\n\n // Unguarded, like `kubb:error`: a failure stays visible even at silent.\n context.hook('studio:error', ({ error }) => {\n const line = `✗ ${error.message}`\n\n if (state.spinner) {\n stopSpinner(line, 'failed')\n return\n }\n writer.error(text(line))\n })\n\n context.hook('kubb:lifecycle:start', () => {\n reset()\n })\n\n context.hook('kubb:generation:start', ({ config }) => {\n closeGroup('failed')\n reset()\n\n state.totalPlugins = config.plugins?.length ?? 0\n\n if (silent) {\n return\n }\n\n const inputPath = getInputPath(config)\n\n writer.group(text([styleText('bold', config.name ?? 'kubb'), inputPath ? styleText('dim', inputPath) : undefined].filter(Boolean).join(' ')))\n state.groupOpen = true\n\n startSpinner('Generating')\n })\n\n context.hook('kubb:plugin:start', ({ plugin }) => {\n if (silent) {\n return\n }\n state.spinner?.message(text(`Generating ${styleText('dim', plugin.name)}`))\n })\n\n // Buffered, not printed: a step redraws over anything written while it runs.\n context.hook('kubb:plugin:end', ({ plugin, duration, success }) => {\n if (silent) {\n return\n }\n\n recordPluginResult(state, success)\n state.pluginLines.push(text(`${plugin.name} ${success ? 'completed' : 'failed'} in ${formatMsWithColor(duration)}`))\n })\n\n context.hook('kubb:plugins:end', () => {\n if (silent) {\n return\n }\n\n const failed = state.failedPlugins > 0\n stopSpinner(buildProgressLine(state) ?? 'No plugins ran', failed ? 'failed' : 'success')\n\n if (state.pluginLines.length) {\n writer.block(state.pluginLines)\n state.pluginLines = []\n }\n })\n\n context.hook('kubb:files:processing:start', ({ files }) => {\n if (silent) {\n return\n }\n\n stopSpinner()\n state.totalFiles = files.length\n state.processedFiles = 0\n\n state.progress = writer.progress(files.length)\n state.progress.start(text(`Writing ${pluralize(files.length, 'file')}`))\n })\n\n context.hook('kubb:files:processing:update', ({ files }) => {\n if (silent) {\n return\n }\n\n for (const { file, config } of files) {\n state.processedFiles++\n state.progress?.advance(`Writing ${relative(config.root, file.path)}`)\n }\n })\n\n context.hook('kubb:files:processing:end', () => {\n if (silent) {\n return\n }\n stopProgress(`Wrote ${pluralize(state.processedFiles, 'file')}`)\n })\n\n context.hook('kubb:format:start', () => startPhase(PHASES.format))\n context.hook('kubb:format:end', endPhase)\n context.hook('kubb:lint:start', () => startPhase(PHASES.lint))\n context.hook('kubb:lint:end', endPhase)\n context.hook('kubb:hooks:start', () => startPhase(PHASES.hooks))\n context.hook('kubb:hooks:end', endPhase)\n\n context.hook('kubb:hook:start', ({ id }) => {\n if (silent || !id) {\n return\n }\n state.hooks.set(id, { hrStart: process.hrtime(), lines: [] })\n })\n\n // Registered only when not silent, so its presence is what tells the runner to stream\n // (`kubb:hook:line` listenerCount). At silent level the listener is absent, so no streaming happens.\n if (!silent) {\n context.hook('kubb:hook:line', ({ id, line }) => {\n const active = state.hooks.get(id)\n if (!active) {\n return\n }\n\n // A phase step redraws its own line, so its output waits until the phase ends.\n if (state.phase) {\n active.lines.push(line)\n return\n }\n writer.raw([line])\n })\n }\n\n context.hook('kubb:hook:end', ({ id, command, name, args, success, error, stdout, stderr }) => {\n if (!id) {\n return\n }\n\n if (!success && state.phase) {\n state.phase.failed = true\n }\n\n if (silent) {\n // Even when silent, surface a failed hook's captured output.\n if (!success) {\n if (stdout) console.log(stdout)\n if (stderr) console.error(stderr)\n }\n return\n }\n\n const active = state.hooks.get(id)\n if (!active) {\n return\n }\n state.hooks.delete(id)\n\n const label = styleText('dim', name ?? formatCommandWithArgs(command, args))\n const reason = error?.message ? ` (${error.message})` : ''\n const result = success\n ? `${styleText('green', '✓')} ${label} in ${formatMsWithColor(getElapsedMs(active.hrStart))}`\n : `${styleText('red', '✗')} ${label} failed${reason}`\n\n const phase = state.phase\n if (phase) {\n if (phase.showHookResults || !success) {\n phase.lines.push(result)\n }\n phase.output.push(...active.lines)\n return\n }\n\n stopSpinner()\n writer.step(text(result))\n writeOutput(active.lines)\n })\n\n context.hook('kubb:generation:end', () => {\n stopSpinner()\n stopProgress()\n })\n\n context.hook('kubb:lifecycle:end', () => {\n closeGroup('failed')\n reset()\n })\n\n return {\n renderSummary(lines, { status }) {\n if (silent || !state.groupOpen) {\n return\n }\n\n closeGroup(status)\n writer.diagnostic([...lines])\n },\n }\n }\n}\n","import { styleText } from 'node:util'\nimport * as clack from '@clack/prompts'\nimport { createLogger } from './createLogger.ts'\nimport type { Logger, LoggerWriter } from './defineLogger.ts'\n\n/**\n * Draws with clack: a gutter bar per group, animated steps, and a progress bar for the writes.\n */\nconst writer: LoggerWriter = {\n group: (title) => clack.intro(title),\n groupEnd: (text) => clack.outro(text),\n step: (text) => clack.log.step(text, { spacing: 0 }),\n info: (text) => clack.log.info(text),\n success: (text) => clack.log.success(text),\n warn: (text) => clack.log.warn(text),\n error: (text) => clack.log.error(text),\n block: (lines) => clack.log.message(lines, { spacing: 0 }),\n // A subprocess's output is not Kubb's tree, so it goes out past clack and its gutter bar. The\n // step above it is already stopped by the time this runs.\n raw: (lines) => console.log(styleText('dim', lines.join('\\n'))),\n // The diagnostic carries its own code and indented rows, so clear clack's gutter and bar and let\n // the block stand on its own.\n diagnostic: (lines) => clack.log.message(lines, { symbol: '', secondarySymbol: '' }),\n update: (lines, title) =>\n clack.box(lines.join('\\n'), title, {\n width: 'auto',\n formatBorder: (border: string) => styleText('yellow', border),\n rounded: true,\n withGuide: false,\n contentAlign: 'center',\n titleAlign: 'center',\n }),\n spinner() {\n const spinner = clack.spinner()\n\n return {\n start: (text) => spinner.start(text),\n message: (text) => spinner.message(text),\n clear: () => spinner.clear(),\n stop: (text) => spinner.stop(text),\n error: (text) => spinner.error(text),\n }\n },\n progress(max) {\n const bar = clack.progress({ style: 'block', max, size: 30 })\n\n return {\n start: (text) => bar.start(text),\n advance: (text) => bar.advance(1, text),\n stop: (text) => bar.stop(text),\n }\n },\n}\n\n/**\n * TTY logger for local development, with animated steps and progress bars.\n */\nexport const clackLogger = {\n name: 'clack',\n install: createLogger(writer),\n} satisfies Logger\n","import { createLogger } from './createLogger.ts'\nimport type { Logger, LoggerWriter } from './defineLogger.ts'\n\n/**\n * Prefixes that stand in for the symbols clack draws, so plain output reads the same way.\n */\nconst SYMBOLS = { info: 'ℹ', warn: '⚠', error: '✗', step: '◇' } as const\n\nfunction write(line: string): void {\n console.log(line)\n}\n\n/**\n * Draws with `console.log` alone. Nothing animates, so a step prints when it starts and again when\n * it ends, and every message it was given in between.\n */\nconst writer: LoggerWriter = {\n group: write,\n groupEnd: write,\n step: (text) => write(`${SYMBOLS.step} ${text}`),\n info: write,\n success: write,\n warn: write,\n error: write,\n block: (lines) => write(lines.join('\\n')),\n raw: (lines) => write(lines.join('\\n')),\n diagnostic: (lines) => write(lines.join('\\n')),\n update: (lines, title) => write([title, ...lines].join('\\n')),\n spinner: () => ({\n start: write,\n message: write,\n clear: () => {},\n stop: (text) => text && write(text),\n error: (text) => write(`${SYMBOLS.error} ${text}`),\n }),\n progress: () => ({\n start: write,\n advance: write,\n stop: (text) => text && write(text),\n }),\n}\n\n/**\n * Console adapter for non-TTY environments, and for an AI coding agent reading the output. Reports\n * the same run in the same order as `clackLogger`, without the animation.\n */\nexport const plainLogger = {\n name: 'plain',\n install: createLogger(writer),\n} satisfies Logger\n","import process from 'node:process'\nimport { styleText } from 'node:util'\nimport { formatMs, getElapsedMs } from '@internals/utils'\nimport type { Config, Reporter, ReporterContext, ReporterPluginFiles } from '@kubb/core'\nimport { createCliReporter, logLevel as logLevelMap } from '@kubb/core'\nimport type { StudioConnectedContext } from '@kubb/studio'\nimport { getAgentName } from '../agent.ts'\nimport { canUseTTY } from '../utils/env.ts'\nimport type { LoggerContext, LoggerOptions } from './defineLogger.ts'\nimport { clackLogger } from './clackLogger.ts'\nimport { plainLogger } from './plainLogger.ts'\n\n/**\n * Display path for a config's input: the string form, or its `path` field when the input is an\n * object. Loggers show it alongside `Generation started`.\n */\nexport function getInputPath(config: Config): string | undefined {\n const { input } = config\n if (typeof input === 'string') return input\n return typeof input?.path === 'string' ? input.path : undefined\n}\n\n/**\n * Counts a noun, so a message never reads `1 files`.\n *\n * @example\n * `pluralize(1, 'config')` returns `'1 config'`\n */\nexport function pluralize(count: number, noun: string): string {\n return `${count} ${count === 1 ? noun : `${noun}s`}`\n}\n\n/**\n * Optionally prefix a message with a [HH:MM:SS] timestamp when logLevel >= verbose.\n * Shared across all logger adapters to avoid duplication.\n */\nexport function formatMessage(message: string, logLevel: number): string {\n if (logLevel >= logLevelMap.verbose) {\n const timestamp = new Date().toLocaleTimeString('en-US', {\n hour12: false,\n hour: '2-digit',\n minute: '2-digit',\n second: '2-digit',\n })\n return `${styleText('dim', `[${timestamp}]`)} ${message}`\n }\n return message\n}\n\n/**\n * Renders the versions from a `studio:connected` event as one parenthetical. The runtime is listed\n * only when it differs from the host, and Studio's only when it sent one.\n */\nexport function formatVersions({ studio, kubb, agent }: StudioConnectedContext['versions']): string {\n return [`v${agent}`, kubb !== agent ? `runtime v${kubb}` : undefined, studio ? `Studio v${studio}` : undefined].filter(Boolean).join(', ')\n}\n\n/**\n * Extracts the `.cause` of an `Error` as an `Error`, or `undefined` when absent or not an `Error`.\n */\nfunction toCause(error: Error): Error | undefined {\n return error.cause instanceof Error ? error.cause : undefined\n}\n\n/**\n * First stack frames for verbose error output, including an optional `cause` chain.\n */\nexport function formatErrorFrames(error: Error): { frames: Array<string>; cause?: { header: string; frames: Array<string> } } | null {\n if (!error.stack) {\n return null\n }\n\n const frames = error.stack\n .split('\\n')\n .slice(1, 4)\n .map((frame) => frame.trim())\n const caused = toCause(error)\n\n if (!caused?.stack) {\n return { frames }\n }\n\n return {\n frames,\n cause: {\n header: `└─ caused by ${caused.message}`,\n frames: caused.stack\n .split('\\n')\n .slice(1, 4)\n .map((frame) => frame.trim()),\n },\n }\n}\n\ntype ProgressState = {\n /**\n * Total number of plugins scheduled for this generation run.\n */\n totalPlugins: number\n /**\n * Number of plugins that have finished without error.\n */\n completedPlugins: number\n /**\n * Number of plugins that exited with an error.\n */\n failedPlugins: number\n /**\n * Total number of files expected to be written.\n */\n totalFiles: number\n /**\n * Number of files written so far.\n */\n processedFiles: number\n /**\n * `process.hrtime()` snapshot taken at the start of generation, used to compute elapsed time.\n */\n hrStart: [number, number]\n}\n\n/**\n * Build the progress summary line shown by the clack logger.\n * Returns null when there is nothing to display.\n */\nexport function buildProgressLine(state: ProgressState): string | null {\n const parts: Array<string> = []\n const duration = formatMs(getElapsedMs(state.hrStart))\n\n if (state.totalPlugins > 0) {\n const pluginStr =\n state.failedPlugins > 0\n ? `Plugins ${styleText('green', state.completedPlugins.toString())}/${state.totalPlugins} ${styleText('red', `(${state.failedPlugins} failed)`)}`\n : `Plugins ${styleText('green', state.completedPlugins.toString())}/${state.totalPlugins}`\n parts.push(pluginStr)\n }\n\n if (state.totalFiles > 0) {\n parts.push(`Files ${styleText('green', state.processedFiles.toString())}/${state.totalFiles}`)\n }\n\n if (parts.length === 0) {\n return null\n }\n\n parts.push(`${styleText('green', duration)} elapsed`)\n return parts.join(styleText('dim', ' | '))\n}\n\n/**\n * Creates the per-run progress counters used by the clack logger.\n */\nexport function createProgressCounters(): ProgressState {\n return {\n totalPlugins: 0,\n completedPlugins: 0,\n failedPlugins: 0,\n totalFiles: 0,\n processedFiles: 0,\n hrStart: process.hrtime(),\n }\n}\n\n/**\n * Resets the progress counters in place at the start/end of a generation run.\n */\nexport function resetProgressCounters(state: ProgressState): void {\n state.totalPlugins = 0\n state.completedPlugins = 0\n state.failedPlugins = 0\n state.totalFiles = 0\n state.processedFiles = 0\n state.hrStart = process.hrtime()\n}\n\n/**\n * Records a finished plugin against the progress counters.\n */\nexport function recordPluginResult(state: ProgressState, success: boolean): void {\n if (success) {\n state.completedPlugins++\n } else {\n state.failedPlugins++\n }\n}\n\n/**\n * Tracks per-hook start times so a logger can report a hook's elapsed duration.\n * Used by the plain logger, which keys timing by hook `id`.\n */\ntype HookTimer = {\n start(id: string): void\n /**\n * Returns the elapsed milliseconds since `start(id)`, or `undefined` when no start was recorded.\n */\n end(id: string): number | undefined\n}\n\n/**\n * Creates a {@link HookTimer} backed by a private `id → hrtime` map.\n */\nexport function createHookTimer(): HookTimer {\n const starts = new Map<string, [number, number]>()\n\n return {\n start(id: string): void {\n starts.set(id, process.hrtime())\n },\n end(id: string): number | undefined {\n const hrStart = starts.get(id)\n if (!hrStart) {\n return undefined\n }\n starts.delete(id)\n return getElapsedMs(hrStart)\n },\n }\n}\n\n/**\n * Join a command and its optional args into a single display string.\n *\n * @example With args\n * `formatCommandWithArgs('prettier', ['--write', '.'])` returns `'prettier --write .'`\n */\nexport function formatCommandWithArgs(command: string, args?: ReadonlyArray<string>): string {\n return args?.length ? `${command} ${args.join(' ')}` : command\n}\n\n/**\n * Bridges a {@link Reporter} onto the run's hook emitter: calls `report` with each config's\n * {@link GenerationResult} on `kubb:generation:end`. The reporter never touches the emitter.\n */\nexport function installReporter(context: LoggerContext, reporter: Reporter, ctx: ReporterContext): void {\n const pluginFiles = reporter.needsPluginFiles ? new Map<Config, Map<string, Set<string>>>() : undefined\n\n if (pluginFiles) {\n context.hook('kubb:plugin:end', ({ config, plugin, files }) => {\n const filesByPlugin = pluginFiles.get(config) ?? new Map<string, Set<string>>()\n const seen = new Set([...filesByPlugin.values()].flatMap((paths) => [...paths]))\n const added = files.filter((file) => !seen.has(file.path)).map((file) => file.path)\n\n if (added.length) filesByPlugin.set(plugin.name, new Set([...(filesByPlugin.get(plugin.name) ?? []), ...added]))\n\n pluginFiles.set(config, filesByPlugin)\n })\n }\n\n context.hook('kubb:generation:end', async ({ config, diagnostics = [], filesCreated = 0, status = 'success', hrStart = process.hrtime() }) => {\n const files = pluginFiles?.get(config)\n const grouped: ReporterPluginFiles | undefined = files && [...files].map(([plugin, paths]) => ({ plugin, files: [...paths] }))\n\n await reporter.report({ config, diagnostics, filesCreated, status, hrStart, pluginFiles: grouped }, ctx)\n\n pluginFiles?.delete(config)\n })\n\n if (reporter.drain) {\n context.hook('kubb:lifecycle:end', () => reporter.drain?.(ctx))\n }\n}\n\n/**\n * Installs the live logger (the TUI view) and the given reporters (the output). The reporters are\n * already selected by the caller (the CLI maps `--reporter` to names via `selectReporters`). This\n * only wires them. Loggers receive hook subprocess output through `kubb:hook:line` and the\n * `stdout`/`stderr` on `kubb:hook:end`, so nothing is returned here.\n *\n * Loggers and reporters are independent, except for `cli`: it both installs the live logger view\n * here and registers a reporter that renders the per-config summary through that logger, so the\n * summary lands inside the group the logger opened. The `json` reporter owns stdout, so the whole\n * `cli` reporter (live logger and summary) is skipped whenever `json` is among the reporters, even\n * if `cli` is also listed.\n */\nasync function setupReporters(context: LoggerContext, { logLevel, reporters }: LoggerOptions & { reporters: ReadonlyArray<Reporter> }): Promise<void> {\n const hasJson = reporters.some((reporter) => reporter.name === 'json')\n const ctx: ReporterContext = { logLevel }\n\n for (const reporter of reporters) {\n if (reporter.name !== 'cli') {\n installReporter(context, reporter, ctx)\n continue\n }\n\n if (hasJson) {\n continue\n }\n\n // Spinners and cursor-movement escapes are hard for an AI coding agent to parse, even over a pseudo-TTY.\n const logger = canUseTTY() && !getAgentName() ? clackLogger : plainLogger\n const handle = await logger.install(context, { logLevel })\n\n // The summary belongs inside the group the logger opened for this config, so hand the writing\n // to the logger rather than letting the reporter print alongside it.\n installReporter(context, createCliReporter({ render: handle?.renderSummary }), ctx)\n }\n}\n\nexport default setupReporters\n\n/**\n * Picks the reporters whose `name` matches one of `names`, in the order the names are given.\n * The config carries every available reporter, and the host selects which to activate by name\n * (the CLI maps `--reporter` to this). Duplicate names and names without a matching reporter are\n * skipped.\n */\nexport function selectReporters(reporters: ReadonlyArray<Reporter>, names: ReadonlyArray<string>): Array<Reporter> {\n const seen = new Set<string>()\n const selected: Array<Reporter> = []\n\n for (const name of names) {\n if (seen.has(name)) {\n continue\n }\n seen.add(name)\n\n const reporter = reporters.find((candidate) => candidate.name === name)\n if (reporter) {\n selected.push(reporter)\n }\n }\n\n return selected\n}\n","import { createJiti } from 'jiti'\n\n/**\n * jiti options for loading Kubb config modules: the automatic JSX runtime pointed at\n * `@kubb/renderer-jsx`, and `moduleCache` off so a re-load re-evaluates the file.\n */\nconst JITI_OPTIONS = {\n jsx: { runtime: 'automatic', importSource: '@kubb/renderer-jsx' },\n moduleCache: false,\n} satisfies Parameters<typeof createJiti>[1]\n\n/**\n * Per-call options for {@link ModuleLoader.load}.\n */\ntype LoadModuleOptions = {\n /**\n * Return the module's default export instead of the full namespace.\n */\n default?: boolean\n}\n\n/**\n * Loads `.ts`/`.js` modules via jiti.\n */\ntype ModuleLoader = {\n load<T = unknown>(filePath: string, options?: LoadModuleOptions): Promise<T>\n}\n\n/**\n * Creates a jiti-based loader for Kubb's TypeScript and JavaScript config modules.\n *\n * jiti transpiles TypeScript and the `@kubb/renderer-jsx` JSX runtime on the fly.\n *\n * @example\n * ```ts\n * const config = await createModuleLoader().load('/abs/kubb.config.ts', { default: true })\n * ```\n */\nexport function createModuleLoader(): ModuleLoader {\n const jiti = createJiti(import.meta.url, JITI_OPTIONS)\n\n return {\n load<T>(filePath: string, options?: LoadModuleOptions) {\n return (options?.default ? jiti.import(filePath, { default: true }) : jiti.import(filePath)) as Promise<T>\n },\n }\n}\n","import { randomUUID } from 'node:crypto'\nimport { basename, dirname, resolve } from 'node:path'\nimport process from 'node:process'\nimport { styleText } from 'node:util'\nimport { createModuleLoader } from '@internals/shared'\nimport { toError, tokenize } from '@internals/utils'\nimport type { CLIOptions, Config, KubbHooks, PossibleConfig, PostGenerateCommand, Hookable } from '@kubb/core'\nimport { NonZeroExitError, x } from 'tinyexec'\nimport { type LoadConfigResult, type LoadConfigSource, loadConfig } from 'unconfig'\nimport { isGreater, isValid, truncate } from 'verkit'\nimport { URL_WATCHER_INTERVAL_MS, URL_WATCHER_TIMEOUT_MS, WATCHER_DEBOUNCE_MS, WATCHER_IGNORED_PATHS } from '../../constants.ts'\n\nconst loader = createModuleLoader()\n\n// Kubb configs are JS/TS modules (they call `defineConfig`/`pluginX()`), so YAML and JSON are not\n// supported. The jiti loader handles every module format and the JSX runtime, returning the default export.\nconst tsLoader = (configFile: string) => loader.load(configFile, { default: true })\n\nconst MODULE_NAME = 'kubb'\n\nconst SEARCH_FILES = ['', '.config/', 'configs/'].flatMap((prefix) => [`${prefix}.${MODULE_NAME}rc`, `${prefix}${MODULE_NAME}.config`])\nconst SEARCH_EXTENSIONS = ['ts', 'mts', 'cts', 'js', 'mjs', 'cjs']\n\ntype GetConfigsOptions = {\n /**\n * Explicit path to the Kubb config file. When omitted, the loader searches up from the current directory.\n */\n configPath?: string\n /**\n * Optional OpenAPI input path or URL that overrides `config.input` for this run.\n */\n input?: string\n /**\n * Watch flag forwarded to the user's `defineConfig` function.\n */\n watch?: boolean\n /**\n * Log level forwarded to the user's `defineConfig` function.\n */\n logLevel?: CLIOptions['logLevel']\n}\n\ntype GetConfigsResult = {\n /**\n * Absolute path to the resolved config file.\n */\n configPath: string\n /**\n * Resolved and normalized array of Kubb configs, each guaranteed to have a `plugins` array.\n */\n configs: Array<Config>\n}\n\n/**\n * Discovers the Kubb config and resolves it into a normalized array of configs.\n * Every config in the result is guaranteed to have a `plugins` array.\n */\nexport async function getConfigs({ configPath, input, watch, logLevel }: GetConfigsOptions): Promise<GetConfigsResult> {\n const abs = configPath ? resolve(configPath) : undefined\n const sources: Array<LoadConfigSource<unknown>> = abs\n ? [{ files: [basename(abs)], extensions: [], parser: tsLoader }]\n : [{ files: SEARCH_FILES, extensions: SEARCH_EXTENSIONS, parser: tsLoader }]\n\n let result: LoadConfigResult<unknown>\n try {\n result = await loadConfig<unknown>({ cwd: abs ? dirname(abs) : process.cwd(), sources, merge: false })\n } catch (error) {\n throw new Error('Config failed loading', { cause: error })\n }\n\n const [filepath] = result.sources\n if (!result.config || !filepath) {\n throw new Error('Config not defined, create a kubb.config.js or pass through your config with the option --config')\n }\n\n const config = result.config as PossibleConfig<CLIOptions>\n const cli: CLIOptions = { config: configPath, input, watch, logLevel }\n const resolved = await (typeof config === 'function' ? config(cli) : config)\n const userConfigs = Array.isArray(resolved) ? resolved : [resolved]\n\n return {\n configPath: filepath,\n configs: userConfigs.map((item) => {\n const config: Config = { ...item, plugins: item.plugins ?? [] }\n return config\n }),\n }\n}\n\ntype RunPostGenerateOptions = {\n commands: Array<PostGenerateCommand>\n hooks: Hookable<KubbHooks>\n}\n\n/**\n * Outcome of a single hook subprocess, returned by `runHook` alongside the\n * `kubb:hook:end` hook it emits for the loggers.\n */\ntype HookResult = {\n /**\n * `true` when the command exited with code `0`.\n */\n success: boolean\n /**\n * What went wrong, `null` when the command succeeded.\n */\n error: Error | null\n /**\n * Captured stdout, only present on a non-zero exit.\n */\n stdout?: string\n /**\n * Captured stderr, only present on a non-zero exit.\n */\n stderr?: string\n}\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 isGreater(truncate(latest, 'patch') as string, truncate(current, 'patch') as string)\n}\n\n/**\n * Runs the `output.postGenerate` commands of a Kubb config in sequence and returns each command's\n * outcome, so the caller can turn failures into diagnostics.\n */\nexport async function runPostGenerate({ commands, hooks }: RunPostGenerateOptions): Promise<Array<HookResult>> {\n const results: Array<HookResult> = []\n\n for (const entry of commands) {\n const { command, name } = typeof entry === 'string' ? { command: entry, name: undefined } : entry\n const [cmd, ...args] = tokenize(command)\n if (!cmd) continue\n\n const hookId = randomUUID()\n const commandWithArgs = [cmd, ...args].join(' ')\n\n await hooks.callHook('kubb:hook:start', { id: hookId, command: cmd, name, args })\n results.push(await runHook({ id: hookId, command: cmd, name, args, commandWithArgs, hooks }))\n }\n\n return results\n}\n\ntype RunHookOptions = {\n id: string\n command: string\n name?: string\n args?: ReadonlyArray<string>\n commandWithArgs: string\n hooks: Hookable<KubbHooks>\n}\n\n/**\n * Spawns a hook command and returns its outcome, mirroring it through `kubb:hook:end` for the\n * loggers. A non-zero exit returns `success: false` rather than throwing, so the caller can turn\n * it into a diagnostic. Other spawn errors do the same. Output is streamed through `kubb:hook:line`\n * only while a listener is attached.\n */\nexport async function runHook({ id, command, name, args, commandWithArgs, hooks }: RunHookOptions): Promise<HookResult> {\n const emitEnd = async (result: HookResult): Promise<HookResult> => {\n await hooks.callHook('kubb:hook:end', { command, name, args, id, ...result })\n return result\n }\n\n // Only stream line-by-line when a logger is listening, so the non-streaming plain\n // logger doesn't pay to iterate the subprocess output.\n const stream = hooks.listenerCount('kubb:hook:line') > 0\n\n try {\n const proc = x(command, [...(args ?? [])], {\n nodeOptions: { detached: process.platform !== 'win32' },\n throwOnError: true,\n })\n\n if (stream) {\n for await (const line of proc) {\n await hooks.callHook('kubb:hook:line', { id, line })\n }\n }\n\n await proc\n await hooks.callHook('kubb:success', { message: `${styleText('dim', name ?? commandWithArgs)} successfully executed` })\n return emitEnd({ success: true, error: null })\n } catch (err) {\n if (!(err instanceof NonZeroExitError)) {\n return emitEnd({ success: false, error: toError(err) })\n }\n\n const stderr = err.output?.stderr ?? ''\n const stdout = err.output?.stdout ?? ''\n\n const error = new Error(`Hook execute failed: ${commandWithArgs}`)\n // Signal the failure via the result and `kubb:hook:end` only, carrying the captured output so\n // the logger can render it. The caller turns this into a coded diagnostic and emits that\n // through `Diagnostics.emit`, so emitting `kubb:error` here would render it twice.\n return emitEnd({ success: false, error, stdout, stderr })\n }\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.\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<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\n/**\n * Fetches the body of a remote spec URL, `undefined` when the server does not answer with a\n * readable 2xx body within the timeout. 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, timeoutMs: number = URL_WATCHER_TIMEOUT_MS): Promise<string | undefined> {\n try {\n const response = await fetch(url, { signal: AbortSignal.timeout(timeoutMs) })\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 poll = async (): Promise<void> => {\n controller = new AbortController()\n try {\n // The signal also aborts the body read, so a response that stalls mid-stream still times out.\n const signal = AbortSignal.any([controller.signal, AbortSignal.timeout(timeoutMs)])\n const response = await fetch(url, { signal })\n if (!response.ok) {\n throw new Error(`HTTP ${response.status}`)\n }\n const body = await response.text()\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 } catch {\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 }\n if (!stopped) {\n timer = setTimeout(() => void poll(), intervalMs)\n }\n }\n\n void poll()\n\n return stop\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAeA,MAAa,aAAa;CACxB,UAAU;EACR,SAAS;EACT,OAAO,eAAuB;GAAC;GAAoB;GAAW;EAAU;EACxE,cAAc;CAChB;CACA,OAAO;EACL,SAAS;EACT,OAAO,eAAuB;GAAC;GAAU;GAAW;EAAU;EAC9D,cAAc;CAChB;CACA,OAAO;EACL,SAAS;EACT,OAAO,eAAuB,CAAC,UAAU;EACzC,cAAc;CAChB;AACF;;;;AAKA,MAAa,UAAU;CACrB,QAAQ;EACN,SAAS;EACT,OAAO,eAAuB,CAAC,YAAY,OAAO;EAClD,cAAc;CAChB;CACA,OAAO;EACL,SAAS;EACT,OAAO,eAAuB;GAAC;GAAQ;GAAS;EAAU;EAC1D,cAAc;CAChB;CACA,QAAQ;EACN,SAAS;EAET,OAAO,eAAuB;GAAC;GAAS;GAAe;EAAU;EACjE,cAAc;CAChB;AACF;;;;;AAMA,MAAa,uBAAuB;CAAC;CAAS;CAAS;AAAU;;;;AAKjE,MAAa,oBAAoB;CAAC;CAAU;CAAS;AAAQ;;;;AAK7D,SAAgB,gBAAgB,MAAgC;CAC9D,OAAO,IAAI,SAAS,YAAY;EAC9B,MAAM,S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