@kubb/cli 5.20.3 → 5.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/dist/{Telemetry-B35TOnPl.js → Telemetry-BhTLEYwh.js} +2 -2
  2. package/dist/{Telemetry-B35TOnPl.js.map → Telemetry-BhTLEYwh.js.map} +1 -1
  3. package/dist/{Telemetry-Dg805qAM.cjs → Telemetry-JW5aPuIg.cjs} +2 -2
  4. package/dist/{Telemetry-Dg805qAM.cjs.map → Telemetry-JW5aPuIg.cjs.map} +1 -1
  5. package/dist/{background-D-B63qcQ.js → background-BiY18dWr.js} +2 -2
  6. package/dist/{background-D-B63qcQ.js.map → background-BiY18dWr.js.map} +1 -1
  7. package/dist/{background-CPSKQhPc.cjs → background-ClORtnNm.cjs} +2 -2
  8. package/dist/{background-CPSKQhPc.cjs.map → background-ClORtnNm.cjs.map} +1 -1
  9. package/dist/{background-CH9QVMqK.js → background-N-_UTHNT.js} +1 -1
  10. package/dist/configFile-CFaV_To0.cjs.map +1 -1
  11. package/dist/credentials-DZH7HT4w.js.map +1 -1
  12. package/dist/index.cjs +9 -9
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.js +9 -9
  15. package/dist/intro-PFXmY9bD.cjs.map +1 -1
  16. package/dist/log-B_uVM704.js.map +1 -1
  17. package/dist/log-BzmBldY6.cjs.map +1 -1
  18. package/dist/{mcp-DVSKKH3E.cjs → mcp-7JMboUx2.cjs} +2 -2
  19. package/dist/{mcp-DVSKKH3E.cjs.map → mcp-7JMboUx2.cjs.map} +1 -1
  20. package/dist/{mcp-Cwr149AK.js → mcp-ue2vjz2J.js} +2 -2
  21. package/dist/{mcp-Cwr149AK.js.map → mcp-ue2vjz2J.js.map} +1 -1
  22. package/dist/package-BoMS1AZ6.js +5 -0
  23. package/dist/package-BoMS1AZ6.js.map +1 -0
  24. package/dist/{package-DKlE1AQe.cjs → package-Bxc60RcQ.cjs} +2 -2
  25. package/dist/package-Bxc60RcQ.cjs.map +1 -0
  26. package/dist/registry-CTVAqQFn.cjs.map +1 -1
  27. package/dist/reporters-B6p0n7s3.js.map +1 -1
  28. package/dist/reporters-DLK4D0js.cjs.map +1 -1
  29. package/dist/{run-BL_-t-RX.cjs → run-BGrgzLo2.cjs} +2 -2
  30. package/dist/{run-BL_-t-RX.cjs.map → run-BGrgzLo2.cjs.map} +1 -1
  31. package/dist/{run-CfYOu60_.js → run-Bl3rprW8.js} +3 -3
  32. package/dist/{run-CfYOu60_.js.map → run-Bl3rprW8.js.map} +1 -1
  33. package/dist/{run-DaCXL5ag.js → run-C3J0YrXl.js} +2 -2
  34. package/dist/{run-DaCXL5ag.js.map → run-C3J0YrXl.js.map} +1 -1
  35. package/dist/{run-2b0RzJyO.cjs → run-C994a4Y5.cjs} +2 -2
  36. package/dist/run-C994a4Y5.cjs.map +1 -0
  37. package/dist/{run-3lIJ7joF.js → run-CE4pXu0n.js} +2 -2
  38. package/dist/{run-3lIJ7joF.js.map → run-CE4pXu0n.js.map} +1 -1
  39. package/dist/{run-BMh1Ixjn.js → run-CUQ0GuHO.js} +2 -2
  40. package/dist/{run-BMh1Ixjn.js.map → run-CUQ0GuHO.js.map} +1 -1
  41. package/dist/{run-Ki_o4eiJ.js → run-Cb1lJjC_.js} +1 -1
  42. package/dist/run-Cz4jqsVH.cjs.map +1 -1
  43. package/dist/{run-CXeCAVrR.cjs → run-D07CFyBy.cjs} +5 -5
  44. package/dist/run-D07CFyBy.cjs.map +1 -0
  45. package/dist/run-D15oxCOd.cjs.map +1 -1
  46. package/dist/{run-9MZAwdcP.cjs → run-D3lgs00n.cjs} +2 -2
  47. package/dist/run-D3lgs00n.cjs.map +1 -0
  48. package/dist/{run-DLgooVef.js → run-DMZvyW7F.js} +5 -5
  49. package/dist/{run-DLgooVef.js.map → run-DMZvyW7F.js.map} +1 -1
  50. package/dist/{run-BuJlyr3W.js → run-DvQUP5ea.js} +2 -2
  51. package/dist/{run-BuJlyr3W.js.map → run-DvQUP5ea.js.map} +1 -1
  52. package/dist/{run-D8LqSVPs.cjs → run-Nh3NdjRM.cjs} +2 -2
  53. package/dist/{run-D8LqSVPs.cjs.map → run-Nh3NdjRM.cjs.map} +1 -1
  54. package/dist/{run-C4OxWQGW.cjs → run-h-R9yKUi.cjs} +3 -3
  55. package/dist/run-h-R9yKUi.cjs.map +1 -0
  56. package/dist/run-w8oRvtdl.cjs.map +1 -1
  57. package/dist/{snapshot-CSuC2f6G.js → snapshot-C6c3fg6g.js} +2 -2
  58. package/dist/{snapshot-CSuC2f6G.js.map → snapshot-C6c3fg6g.js.map} +1 -1
  59. package/dist/{snapshot-wKmOdzfU.cjs → snapshot-DIU2jDHY.cjs} +2 -2
  60. package/dist/snapshot-DIU2jDHY.cjs.map +1 -0
  61. package/dist/{status-DM_g7tT2.cjs → status-C1M8ggsY.cjs} +2 -2
  62. package/dist/{status-DM_g7tT2.cjs.map → status-C1M8ggsY.cjs.map} +1 -1
  63. package/dist/{status-BfmfeiqJ.js → status-DwTnX_1X.js} +2 -2
  64. package/dist/{status-BfmfeiqJ.js.map → status-DwTnX_1X.js.map} +1 -1
  65. package/dist/{studio-BP0V78Eo.js → studio-DtSk5Z-c.js} +11 -11
  66. package/dist/{studio-BP0V78Eo.js.map → studio-DtSk5Z-c.js.map} +1 -1
  67. package/dist/{studio-Bn_o8VeS.cjs → studio-NeCXG9kR.cjs} +11 -11
  68. package/dist/{studio-Bn_o8VeS.cjs.map → studio-NeCXG9kR.cjs.map} +1 -1
  69. package/dist/studioWorker.js +2 -2
  70. package/dist/summary-n4osDoch.cjs.map +1 -1
  71. package/dist/{validate-BfJ_tykD.cjs → validate-DFRXoUyQ.cjs} +2 -2
  72. package/dist/{validate-BfJ_tykD.cjs.map → validate-DFRXoUyQ.cjs.map} +1 -1
  73. package/dist/{validate-DJzR1IDq.js → validate-jfKFC1n1.js} +2 -2
  74. package/dist/{validate-DJzR1IDq.js.map → validate-jfKFC1n1.js.map} +1 -1
  75. package/package.json +7 -7
  76. package/dist/package-C2zS-roY.js +0 -5
  77. package/dist/package-C2zS-roY.js.map +0 -1
  78. package/dist/package-DKlE1AQe.cjs.map +0 -1
  79. package/dist/run-2b0RzJyO.cjs.map +0 -1
  80. package/dist/run-9MZAwdcP.cjs.map +0 -1
  81. package/dist/run-C4OxWQGW.cjs.map +0 -1
  82. package/dist/run-CXeCAVrR.cjs.map +0 -1
  83. package/dist/snapshot-wKmOdzfU.cjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"reporters-DLK4D0js.cjs","names":["logLevelMap","styleText","styleText","process","formatMsWithColor","getElapsedMs","styleText","logLevelMap","memo","styleText","logLevelMap","process","relative","Diagnostics","styleText","getInputKind","resolve","read","pluralize","logLevelMap","pluralize","relative","styleText","styleText","logLevelMap","toPermissionFlag","process","getElapsedMs","Diagnostics","pluralize","formatMs","process","formatMs","getElapsedMs","styleText","pluralize","formatBar","formatMsWithColor","styleText","relative","process","readdir","inParallel","join","read","hash","readFileSync","matchesStored","defaultWriter","createCliReporter","memo","logLevelMap","resolve","hasOutputPasses","isPathInside","readFile","createOutputManifest","cacheStorage","process"],"sources":["../src/loggers/features/context.ts","../src/loggers/features/generation.ts","../src/loggers/features/phases.ts","../src/loggers/specFrame.ts","../src/loggers/features/problems.ts","../src/loggers/features/progress.ts","../src/loggers/features/session.ts","../src/loggers/features/spinner.ts","../src/loggers/features/walk.ts","../src/loggers/features/index.ts","../src/runners/generate/utils.ts","../src/loggers/reporters.ts"],"sourcesContent":["import { styleText } from 'node:util'\nimport { type Config, type Hookable, type KubbHooks, logLevel as logLevelMap } from '@kubb/core'\nimport type { LoggerWriter } from '../types.ts'\n\n/**\n * What `installLogger` shares with its features: the writer, the verbosity flags, and the two\n * run-wide flags a feature flips for the others to read.\n */\nexport type LoggerContext = {\n hooks: Hookable<KubbHooks>\n writer: LoggerWriter\n logLevel: number\n silent: boolean\n human: boolean\n /** Set once a rich `kubb studio` session connects: each run then shows as one job line. */\n session: boolean\n /** Whether a config's group is open, so a problem can wait for its end. */\n groupOpen: boolean\n /** Prefixes a `[HH:MM:SS]` timestamp at verbose and above. */\n text: (message: string) => string\n /** `✓ message info`, with the info dimmed. */\n line: (symbol: string, message: string, info?: string) => string\n /** Registers a per-run hook. In a Studio session the job line stands for the whole run, so these stay quiet. */\n onRun: <Name extends keyof KubbHooks & string>(name: Name, fn: (...args: KubbHooks[Name]) => unknown) => () => void\n}\n\nexport function createLoggerContext({ hooks, writer, logLevel }: { hooks: Hookable<KubbHooks>; writer: LoggerWriter; logLevel: number }): LoggerContext {\n const text = (message: string) => (logLevel >= logLevelMap.verbose ? `${styleText('dim', `[${clock()}]`)} ${message}` : message)\n const ctx: LoggerContext = {\n hooks,\n writer,\n logLevel,\n silent: logLevel <= logLevelMap.silent,\n human: writer.audience === 'human',\n session: false,\n groupOpen: false,\n text,\n line: (symbol, message, info) => text([symbol, message, info && styleText('dim', info)].filter(Boolean).join(' ')),\n onRun(name, fn) {\n return hooks.hook(name, (...args) => (ctx.session ? undefined : fn(...args)))\n },\n }\n return ctx\n}\n\n/** `HH:MM:SS` in 24-hour time. */\nexport function clock(date = new Date()): string {\n return date.toLocaleTimeString('en-US', { hour12: false, hour: '2-digit', minute: '2-digit', second: '2-digit' })\n}\n\n/** Display path for a config's input: the string form, or its `path` field when the input is an object. */\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","import { styleText } from 'node:util'\nimport type { SummaryRenderer } from '@kubb/core'\nimport type { LogStatus } from '../types.ts'\nimport { getInputPath, type LoggerContext } from './context.ts'\nimport type { Phases } from './phases.ts'\nimport type { Problems } from './problems.ts'\nimport type { Progress } from './progress.ts'\nimport type { Spinner } from './spinner.ts'\nimport type { Walk } from './walk.ts'\n\n/**\n * One config's run: the group it opens, the state every feature resets at its start, and the\n * closing line, which the lifecycle end draws too for a run that threw before its summary.\n */\nexport function createGeneration(\n ctx: LoggerContext,\n { spinner, progress, walk, phases, problems }: { spinner: Spinner; progress: Progress; walk: Walk; phases: Phases; problems: Problems },\n): { renderSummary: SummaryRenderer } {\n const { writer, silent, human, text, hooks, onRun } = ctx\n\n function reset() {\n spinner.reset()\n progress.reset()\n walk.reset()\n phases.reset()\n problems.reset()\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 (!ctx.groupOpen) {\n return\n }\n ctx.groupOpen = false\n\n spinner.stop()\n progress.stop()\n writer.groupEnd(status === 'failed' ? styleText('red', problems.failedTitle()) : styleText('green', '✓ Generation succeeded'))\n }\n\n hooks.hook('kubb:lifecycle:start', () => {\n reset()\n })\n\n onRun('kubb:generation:start', ({ config }) => {\n closeGroup('failed')\n reset()\n\n walk.state.totalPlugins = config.plugins?.length ?? 0\n progress.state.inMemory = config.storage?.name === 'memory'\n problems.setSpec(config)\n\n if (silent) {\n return\n }\n\n const input = getInputPath(config)\n writer.group(text([styleText('bold', config.name ?? 'kubb'), input ? styleText('dim', input) : undefined].filter(Boolean).join(' ')))\n ctx.groupOpen = true\n\n spinner.start('Parsing spec')\n })\n\n onRun('kubb:generation:end', async ({ diagnostics = [] }) => {\n spinner.stop()\n progress.stop()\n problems.state.diagnostics = diagnostics\n await problems.flush()\n })\n\n hooks.hook('kubb:lifecycle:end', async () => {\n await problems.flush()\n closeGroup('failed')\n reset()\n })\n\n const renderSummary: SummaryRenderer = (lines, { status }) => {\n if (silent || !ctx.groupOpen) {\n return\n }\n\n spinner.stop()\n progress.stop()\n if (human) closeGroup(status)\n ctx.groupOpen = false\n writer.diagnostic([...lines])\n }\n\n return { renderSummary }\n}\n","import process from 'node:process'\nimport { styleText } from 'node:util'\nimport { getElapsedMs } from '@internals/utils'\nimport { logLevel as logLevelMap } from '@kubb/core'\nimport { formatMsWithColor } from '../banner.ts'\nimport type { LoggerContext } from './context.ts'\nimport type { Spinner } from './spinner.ts'\n\nexport type Phases = ReturnType<typeof createPhases>\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 = StartPhaseOptions & {\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 /**\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}\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/** A hook's display name: its `name`, or the command line it runs. */\nfunction formatHookLabel({ command, name, args }: { command: string; name?: string; args?: ReadonlyArray<string> }): string {\n return name ?? (args?.length ? `${command} ${args.join(' ')}` : command)\n}\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/** The format, lint and post-generate phases, and the hooks and messages they buffer while their step owns the line. */\nexport function createPhases({ writer, silent, logLevel, text, line, onRun }: LoggerContext, spinner: Spinner) {\n const state = {\n phase: null as Phase | null,\n hooks: new Map<string, { hrStart: [number, number]; lines: Array<string> }>(),\n }\n\n function startPhase(options: StartPhaseOptions) {\n state.phase = { ...options, failed: false, hrStart: process.hrtime(), lines: [], output: [] }\n spinner.start(options.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 spinner.stop(phase.failed ? `${phase.failure} after ${duration}` : `${phase.success} 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 onRun('kubb:format:start', () => startPhase(PHASES.format))\n onRun('kubb:format:end', endPhase)\n onRun('kubb:lint:start', () => startPhase(PHASES.lint))\n onRun('kubb:lint:end', endPhase)\n onRun('kubb:hooks:start', () => startPhase(PHASES.hooks))\n onRun('kubb:hooks:end', endPhase)\n\n onRun('kubb:hook:end', (ctx) => {\n const { id, command, name, args, success, error } = ctx\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. `stdout` and `stderr` only exist on a failed result.\n if (!ctx.success) {\n if (ctx.stdout) console.log(ctx.stdout)\n if (ctx.stderr) console.error(ctx.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', formatHookLabel({ command, name, 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 spinner.stop()\n writer.step(text(result))\n writeOutput(active.lines)\n })\n\n // Not registered at silent: the missing `kubb:hook:line` listener is also what tells the runner not to stream.\n if (!silent) {\n onRun('kubb:info', ({ message, info }) => {\n const formatted = line(styleText('blue', 'ℹ'), message, info)\n\n // Info carries something new (the auto-detected tool), so inside a phase it waits for the phase to print.\n if (state.phase) {\n state.phase.lines.push(formatted)\n return\n }\n if (spinner.message(formatted)) {\n return\n }\n writer.info(formatted)\n })\n\n onRun('kubb:success', ({ message, info }) => {\n const formatted = line(styleText('green', '✓'), message, logLevel >= logLevelMap.info ? info : undefined)\n\n // The phase step's own result already reports these successes, so let the step carry them.\n if (spinner.message(formatted)) {\n return\n }\n writer.success(formatted)\n })\n\n onRun('kubb:hook:start', ({ id, command, name, args }) => {\n if (!id) {\n return\n }\n state.hooks.set(id, { hrStart: process.hrtime(), lines: [] })\n spinner.message(text(`Running ${styleText('dim', formatHookLabel({ command, name, args }))}`))\n })\n\n onRun('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 return {\n /** The phase whose step owns the line, so a failure or an info line can wait for it. */\n get phase(): Phase | null {\n return state.phase\n },\n reset() {\n state.phase = null\n state.hooks = new Map()\n },\n }\n}\n","import { styleText } from 'node:util'\nimport { memo } from '@internals/utils'\nimport type { Adapter, DiagnosticLocation } from '@kubb/core'\n\n/**\n * A location in source text, with a terminal code frame that underlines it.\n */\nexport type SpecPosition = {\n line: number\n column: number\n frame: Array<string>\n}\n\n// Diagnostics of one run share a source, so its line starts are indexed once. Splitting a large\n// spec per diagnostic made code frames the slowest part of a run.\nconst startsBySource = memo.create<string, Array<number>>({ max: 1 })\n\nfunction lineStarts(source: string): Array<number> {\n return memo(startsBySource, source, () => {\n const starts = [0]\n for (const match of source.matchAll(/\\n/g)) starts.push(match.index + 1)\n return starts\n })\n}\n\n/** The index of the last line start at or before `offset`, found by binary search. */\nfunction lineIndex(starts: Array<number>, offset: number, low = 0, high = starts.length - 1): number {\n if (low >= high) return low\n const mid = (low + high + 1) >> 1\n return starts[mid]! <= offset ? lineIndex(starts, offset, mid, high) : lineIndex(starts, offset, low, mid - 1)\n}\n\n/**\n * Where `location` sits in `source` according to its adapter, with a code frame. `undefined` when the adapter cannot place it.\n */\nexport function locateInSpec({ adapter, source, location }: { adapter: Adapter; source: string; location: DiagnosticLocation }): SpecPosition | undefined {\n try {\n const range = adapter.locate?.(source, location)\n if (!range) return undefined\n const starts = lineStarts(source)\n const index = lineIndex(starts, range.start)\n const lineText = (number: number) => source.slice(starts[number - 1], number < starts.length ? starts[number]! - 1 : source.length).replace(/\\r$/, '')\n const line = index + 1\n const column = range.start - starts[index]! + 1\n const text = lineText(line)\n const width = String(line).length\n const gutter = (number?: number) => styleText('dim', `${number === undefined ? ''.padStart(width) : String(number).padStart(width)} │`)\n const carets = '^'.repeat(Math.max(1, Math.min(range.end - range.start, text.length - column + 1)))\n return {\n line,\n column,\n frame: [\n ...(line > 1 ? [`${gutter(line - 1)} ${lineText(line - 1)}`] : []),\n `${gutter(line)} ${text}`,\n `${gutter()} ${' '.repeat(column - 1)}${styleText('red', carets)}`,\n ],\n }\n } catch {\n return undefined\n }\n}\n","import { relative, resolve } from 'node:path'\nimport process from 'node:process'\nimport { styleText } from 'node:util'\nimport { read } from '@internals/utils'\nimport type { Adapter, Config, Diagnostic, DiagnosticFormatOptions, ProblemDiagnostic } from '@kubb/core'\nimport { Diagnostics, getInputKind, logLevel as logLevelMap } from '@kubb/core'\nimport { pluralize } from '../../ui/text.ts'\nimport { locateInSpec } from '../specFrame.ts'\nimport { getInputPath, type LoggerContext } from './context.ts'\nimport type { Phases } from './phases.ts'\nimport type { Progress } from './progress.ts'\nimport type { Spinner } from './spinner.ts'\n\nexport type Problems = ReturnType<typeof createProblems>\n\n/** Warnings, errors and diagnostics: printed as they come, or held back and grouped by plugin once a human's build ends. */\nexport function createProblems(ctx: LoggerContext, spinner: Spinner, progress: Progress, phases: Phases) {\n const { writer, silent, human, logLevel, text, line, hooks } = ctx\n const { audience } = writer\n const formatOptions: DiagnosticFormatOptions = {\n audience,\n verbose: logLevel >= logLevelMap.verbose,\n // The code lines up at the right edge, inside the group indent and the human view's per-problem indent.\n width: Math.min(process.stdout.columns || 80, 100) - (audience === 'human' ? 4 : 2),\n }\n const state = {\n /** Problems held back so the human view can print them grouped by plugin once the build ends. */\n problems: [] as Array<ProblemDiagnostic>,\n /** The finished config's diagnostics, for the closing verdict. */\n diagnostics: [] as Array<Diagnostic>,\n /** A local-file input, which a located diagnostic points into; `load` parses it once, on the first such diagnostic. */\n spec: undefined as { path: string; adapter: Adapter; source: Promise<string | undefined> } | undefined,\n }\n\n /** Format options for one problem, with its line and column in a local spec when its pointer resolves there. */\n async function optionsFor(problem: ProblemDiagnostic): Promise<DiagnosticFormatOptions> {\n const { location } = problem\n const { spec } = state\n if (!location || !spec) {\n return formatOptions\n }\n\n const source = await spec.source\n const position = source && locateInSpec({ adapter: spec.adapter, source, location })\n if (!position) {\n return formatOptions\n }\n return { ...formatOptions, position: { file: relative(process.cwd(), spec.path), ...position } }\n }\n\n /**\n * Prints problems grouped under their plugin's name, each with the code aligned at the right.\n */\n async function writeProblems(problems: ReadonlyArray<ProblemDiagnostic>) {\n if (!problems.length) {\n return\n }\n const formatted = await Promise.all(problems.map(async (problem) => Diagnostics.format(problem, await optionsFor(problem))))\n if (!human) {\n for (const lines of formatted) writer.diagnostic(lines)\n return\n }\n\n const byPlugin = Map.groupBy(\n problems.map((problem, index) => ({ plugin: problem.plugin ?? '', lines: formatted[index]! })),\n ({ plugin }) => plugin,\n )\n const lines = [...byPlugin].flatMap(([plugin, group]) => [\n ...(plugin ? [` ${styleText('bold', plugin)}`, ''] : []),\n ...group.flatMap((entry) => [...entry.lines.map((entryLine) => ` ${entryLine}`), '']),\n ])\n writer.diagnostic(lines.slice(0, -1))\n }\n\n hooks.hook('kubb:warn', ({ message, info }) => {\n if (logLevel < logLevelMap.warn) {\n return\n }\n\n writer.warn(line(styleText('yellow', '⚠'), message, logLevel >= logLevelMap.info ? info : undefined))\n })\n\n // Unguarded: a failure stays visible even at silent.\n hooks.hook('kubb:error', ({ error }) => {\n const phase = phases.phase\n if (phase) {\n phase.failed = true\n }\n\n // Rendered as a `KUBB_UNKNOWN` diagnostic, so the output alone says what broke and where. The\n // name tells a `TypeError` from a plain `Error`.\n const message = error.name === 'Error' || Diagnostics.isError(error) ? error.message : `${error.name}: ${error.message}`\n const help = Diagnostics.isError(error) ? error.diagnostic.help : undefined\n const [headline = '', ...details] = Diagnostics.format({ code: Diagnostics.code.unknown, severity: 'error', message, help, cause: error }, formatOptions)\n\n if (!human) {\n spinner.stop()\n progress.stop()\n writer.diagnostic([headline, ...details])\n return\n }\n\n // The writer draws the error symbol, so the message goes in bare.\n if (spinner.active) {\n spinner.stop(message, 'failed')\n } else {\n writer.error(text(message))\n }\n if (details.length) {\n writer.block(details.map(text))\n }\n })\n\n hooks.hook('kubb:diagnostic', async ({ 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 // A Studio job's problems show in Studio; its job line counts the errors.\n if (ctx.session && !Diagnostics.isUpdate(diagnostic)) {\n return\n }\n\n spinner.stop()\n progress.stop()\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 // Inside a build, the human view waits for the end to group by plugin.\n if (human && ctx.groupOpen) {\n state.problems.push(diagnostic)\n return\n }\n await writeProblems([diagnostic])\n })\n\n return {\n state,\n /** Points located diagnostics into the config's input when it is a local file. */\n setSpec(config: Config) {\n const input = getInputPath(config)\n if (input && config.adapter?.locate && getInputKind(input) === 'file') {\n const path = resolve(config.root, input)\n // Read lazily, once, and only when a diagnostic needs a frame.\n let source: Promise<string | undefined> | undefined\n state.spec = {\n path,\n adapter: config.adapter,\n get source() {\n return (source ??= read(path).catch(() => undefined))\n },\n }\n }\n },\n /** Prints the problems held back so far. */\n flush() {\n return writeProblems(state.problems.splice(0))\n },\n /** `✖ Failed 1 error · 1 warning in plugin-ts` once the build ended, or `✗ Generation failed` for a run that stopped early. */\n failedTitle(): string {\n const { errors, warnings } = Diagnostics.count(state.diagnostics)\n const counts = [errors && pluralize(errors, 'error'), warnings && pluralize(warnings, 'warning')].filter(Boolean).join(' · ')\n if (!human || !counts) {\n return '✗ Generation failed'\n }\n const plugins = Diagnostics.failedPlugins(state.diagnostics)\n return `✖ Failed ${counts}${plugins.length ? ` in ${plugins.join(', ')}` : ''}`\n },\n reset() {\n Object.assign(state, { problems: [], diagnostics: [], spec: undefined })\n },\n }\n}\n","import { relative } from 'node:path'\nimport { styleText } from 'node:util'\nimport { logLevel as logLevelMap } from '@kubb/core'\nimport { pluralize } from '../../ui/text.ts'\nimport type { WriterProgress } from '../types.ts'\nimport type { LoggerContext } from './context.ts'\nimport type { Spinner } from './spinner.ts'\n\nexport type Progress = ReturnType<typeof createProgress>\n\n/** The progress bar over the file writes, and the counts the summary line shows. */\nexport function createProgress({ writer, silent, human, logLevel, text, onRun }: LoggerContext, spinner: Spinner) {\n // Plain output prints every advance as its own line, so it names each file only at the verbose level.\n const nameFiles = human || logLevel >= logLevelMap.verbose\n const state = {\n progress: null as WriterProgress | null,\n totalFiles: 0,\n processedFiles: 0,\n /** Whether this run keeps its files in memory, as a `kubb studio` run without `--allow-write` does. */\n inMemory: false,\n }\n\n function stop(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 if (!silent) {\n onRun('kubb:files:processing:start', ({ files }) => {\n spinner.stop()\n state.totalFiles = files.length\n state.processedFiles = 0\n\n state.progress = writer.progress(files.length)\n state.progress.start(text(`${state.inMemory ? 'Generating' : 'Writing'} ${pluralize(files.length, 'file')}`))\n })\n\n onRun('kubb:files:processing:update', ({ files }) => {\n for (const { file, config } of files) {\n state.processedFiles++\n if (nameFiles) state.progress?.advance(`${state.inMemory ? 'Generating' : 'Writing'} ${relative(config.root, file.path)}`)\n }\n })\n\n onRun('kubb:files:processing:end', ({ files, unchanged }) => {\n const skipped = unchanged.length ? styleText('dim', ` · ${unchanged.length} unchanged`) : ''\n stop(\n state.inMemory\n ? `Generated ${pluralize(state.processedFiles, 'file')} in memory`\n : `Wrote ${pluralize(files.length - unchanged.length, 'file')}${skipped}`,\n )\n })\n }\n\n return {\n state,\n stop,\n reset() {\n stop()\n Object.assign(state, { totalFiles: 0, processedFiles: 0, inMemory: false })\n },\n }\n}\n","import process from 'node:process'\nimport { styleText } from 'node:util'\nimport { formatMs, getElapsedMs } from '@internals/utils'\nimport { Diagnostics, logLevel as logLevelMap } from '@kubb/core'\nimport { pluralize, toPermissionFlag } from '../../ui/text.ts'\nimport { clock, type LoggerContext } from './context.ts'\nimport type { Spinner } from './spinner.ts'\n\n/** One line of a Studio session's job log: the time, the command, who asked for it, and how it ended. */\nfunction formatJobLine({ command, result, requestedBy }: { command: string; result: string; requestedBy?: string }): string {\n const by = requestedBy ? `${styleText('dim', `by ${requestedBy}`.padEnd(16))} ` : ''\n return `${styleText('dim', clock())} ${command.padEnd(10)} ${by}${result}`\n}\n\n/**\n * A `kubb studio` session. It emits these on the same emitter as its generations, so one logger\n * renders the whole command: the connection, then one job line per command.\n */\nexport function createSession(ctx: LoggerContext, spinner: Spinner) {\n const { writer, silent, human, logLevel, text, hooks } = ctx\n\n hooks.hook('studio:disconnected', ({ code, reason }) => {\n if (logLevel < logLevelMap.warn) {\n return\n }\n\n spinner.stop()\n // 4002 is `AgentCloseCode.SUPERSEDED`, spelled out because `@kubb/studio` is an optional peer.\n if (code === 4002) {\n writer.warn(text('⚠ Another process connected to Kubb Studio as this agent, so this one stopped'))\n return\n }\n writer.warn(text(`⚠ Kubb Studio ended the session (${reason || `code ${code}`})`))\n })\n\n hooks.hook('studio:warn', ({ message, permission }) => {\n if (logLevel < logLevelMap.warn) {\n return\n }\n const remedy = permission ? `; pass ${toPermissionFlag(permission)} to allow it` : ''\n // A warning drawn under a running spinner leaves a stale spinner frame above it, so it pauses the spinner like a job line does.\n const paused = spinner.active\n spinner.stop()\n writer.warn(text(`⚠ ${message}${remedy}`))\n if (paused) spinner.start('Ready for jobs')\n })\n\n // Unguarded, like `kubb:error`: a failure stays visible even at silent.\n hooks.hook('studio:error', ({ error }) => {\n if (spinner.active) {\n spinner.stop(error.message, 'failed')\n return\n }\n writer.error(text(error.message))\n })\n\n if (silent) {\n return\n }\n\n // The last generation's outcome, for the job line `studio:command` prints after it.\n let job: { fileCount: number; ms: number; errors: number } | null = null\n\n hooks.hook('studio:connected', ({ url, versions: { studio, kubb, agent } }) => {\n ctx.session = human\n spinner.stop()\n // The runtime version shows only when it differs from the host's.\n const versions = [`v${agent}`, kubb !== agent ? `runtime v${kubb}` : undefined, `Studio v${studio}`].filter(Boolean).join(' · ')\n writer.success(text(`✓ Connected to ${styleText('cyan', url)} ${styleText('dim', `· ${versions}`)}`))\n spinner.start('Ready for jobs')\n })\n\n hooks.hook('kubb:generation:start', () => {\n if (ctx.session) spinner.message(text('Generating'))\n })\n\n hooks.hook('kubb:generation:end', ({ diagnostics = [], filesCreated = 0, status, hrStart = process.hrtime() }) => {\n job = { fileCount: filesCreated, ms: getElapsedMs(hrStart), errors: status === 'failed' ? Diagnostics.count(diagnostics).errors : 0 }\n })\n\n hooks.hook('studio:command', ({ command, info, requestedBy, failed }) => {\n spinner.stop()\n const took = command === 'generate' && job ? `${pluralize(job.fileCount, 'file')} in ${formatMs(job.ms)} ` : ''\n const result = failed\n ? `${styleText('red', '✖')} ${job?.errors ? pluralize(job.errors, 'error') : 'failed'}, see Studio`\n : `${styleText('green', '✓')} ${took}${styleText('dim', `(${info})`)}`\n writer.info(formatJobLine({ command, requestedBy, result }))\n job = null\n spinner.start('Ready for jobs')\n })\n\n hooks.hook('studio:reconnecting', ({ delayMs }) => {\n spinner.stop()\n writer.info(text(styleText('dim', `Retrying connection to Kubb Studio in ${formatMs(delayMs)}`)))\n })\n}\n","import type { LogStatus, WriterSpinner } from '../types.ts'\nimport type { LoggerContext } from './context.ts'\n\nexport type Spinner = ReturnType<typeof createSpinner>\n\n/** The step whose end is not known when it starts: the spec parse, the node walk, a phase, or a Studio session waiting for jobs. */\nexport function createSpinner({ writer, silent, text }: LoggerContext) {\n let spinner: WriterSpinner | null = null\n\n function stop(message?: string, status: LogStatus = 'success') {\n const active = spinner\n if (!active) {\n return\n }\n spinner = null\n\n if (message === undefined) {\n active.clear()\n return\n }\n if (status === 'failed') {\n active.error(text(message))\n return\n }\n active.stop(text(message))\n }\n\n return {\n /** Whether a spinner is drawing right now. */\n get active(): boolean {\n return spinner !== null\n },\n start(message: string) {\n if (silent) {\n return\n }\n\n spinner = writer.spinner()\n spinner.start(text(message))\n },\n stop,\n /** Redraws the spinner's line. `false` when no spinner is running, so the caller prints the line itself. */\n message(line: string): boolean {\n if (!spinner) {\n return false\n }\n spinner.message(line)\n return true\n },\n reset: () => stop(),\n }\n}\n","import process from 'node:process'\nimport { styleText } from 'node:util'\nimport { formatMs, getElapsedMs } from '@internals/utils'\nimport { formatBar, formatMsWithColor } from '../banner.ts'\nimport { pluralize } from '../../ui/text.ts'\nimport type { LoggerContext } from './context.ts'\nimport type { Progress } from './progress.ts'\nimport type { Spinner } from './spinner.ts'\n\nexport type Walk = ReturnType<typeof createWalk>\n\n/** Milliseconds between redraws of the live generation block, about clack's spinner frame rate. */\nconst WALK_REDRAW_MS = 80\n\nfunction createState() {\n return {\n totalPlugins: 0,\n completedPlugins: 0,\n failedPlugins: 0,\n /** `process.hrtime()` snapshot taken at the start of generation, for the elapsed time. */\n hrStart: process.hrtime(),\n /** Plugin results held back while the generation step owns the line. */\n pluginLines: [] as Array<string>,\n /** The node walk's live state: the spec's node total, the distinct nodes generated, and each plugin's count and current node. */\n walk: { total: 0, visited: new Set<string>(), plugins: new Map<string, { count: number; current: string }>() },\n lastWalkDraw: 0,\n }\n}\n\n/** The node walk the plugins share: the live generation block, and the plugin results printed once the walk ends. */\nexport function createWalk({ writer, silent, human, text, onRun }: LoggerContext, spinner: Spinner, progress: Progress) {\n const state = createState()\n\n /** The progress summary line the clack logger shows, `null` when there is nothing to display. */\n function buildProgressLine(): string | null {\n const parts: Array<string> = []\n const duration = formatMs(getElapsedMs(state.hrStart))\n const { totalFiles, processedFiles } = progress.state\n\n if (state.totalPlugins > 0) {\n const failed = state.failedPlugins > 0 ? ` ${styleText('red', `(${state.failedPlugins} failed)`)}` : ''\n parts.push(`Plugins ${styleText('green', state.completedPlugins.toString())}/${state.totalPlugins}${failed}`)\n }\n\n if (totalFiles > 0) {\n parts.push(`Files ${styleText('green', processedFiles.toString())}/${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 if (!silent) {\n onRun('kubb:build:start', ({ nodeCounts: { schemas, operations } }) => {\n state.walk.total = schemas + operations\n const details = `${pluralize(schemas, 'schema')} · ${pluralize(operations, 'operation')} · ${formatMs(getElapsedMs(state.hrStart))}`\n spinner.stop(`Parsed spec ${styleText('dim', details)}`)\n spinner.start('Generating')\n })\n\n // Plugins all end after one shared node walk, so per-node hooks keep the step live; plain output would get a line per node.\n if (human) {\n const onNode = (key: string, name: string, plugin: string) => {\n const { total, visited, plugins } = state.walk\n visited.add(key)\n plugins.set(plugin, { count: (plugins.get(plugin)?.count ?? 0) + 1, current: name })\n\n // Counting stays per node; the redraw waits for the spinner's next frame.\n const now = Date.now()\n if (now - state.lastWalkDraw < WALK_REDRAW_MS) return\n state.lastWalkDraw = now\n\n const elapsed = styleText('dim', formatMs(getElapsedMs(state.hrStart)))\n const head = total\n ? `Generating ${formatBar(visited.size, total)} ${visited.size}/${total} nodes ${elapsed}`\n : `Generating ${pluralize(visited.size, 'node')} ${elapsed}`\n const width = Math.max(...[...plugins.keys()].map((pluginName) => pluginName.length))\n const rows = [...plugins].map(\n ([pluginName, row]) =>\n `${styleText('dim', '│')} ${pluginName.padEnd(width)} ${styleText('dim', String(row.count).padStart(4))} ${styleText('cyan', row.current)}`,\n )\n spinner.message(text([head, ...rows].join('\\n')))\n }\n\n onRun('kubb:generate:schema', (node, { plugin }) => onNode(`schema:${node.name}`, node.name ?? 'schema', plugin.name))\n onRun('kubb:generate:operation', (node, { plugin }) => onNode(`operation:${node.operationId}`, node.operationId, plugin.name))\n }\n\n // Buffered, not printed: a step redraws over anything written while it runs.\n onRun('kubb:plugin:end', ({ plugin, duration, success }) => {\n state[success ? 'completedPlugins' : 'failedPlugins']++\n state.pluginLines.push(text(`${plugin.name} ${success ? 'completed' : 'failed'} in ${formatMsWithColor(duration)}`))\n })\n\n onRun('kubb:plugins:end', () => {\n const failed = state.failedPlugins > 0\n spinner.stop(buildProgressLine() ?? undefined, failed ? 'failed' : 'success')\n\n if (state.pluginLines.length) {\n writer.block(state.pluginLines)\n state.pluginLines = []\n }\n })\n }\n\n return {\n state,\n reset() {\n Object.assign(state, createState())\n },\n }\n}\n","import type { Hookable, KubbHooks, SummaryRenderer } from '@kubb/core'\nimport type { LoggerWriter } from '../types.ts'\nimport { createLoggerContext } from './context.ts'\nimport { createGeneration } from './generation.ts'\nimport { createPhases } from './phases.ts'\nimport { createProblems } from './problems.ts'\nimport { createProgress } from './progress.ts'\nimport { createSession } from './session.ts'\nimport { createSpinner } from './spinner.ts'\nimport { createWalk } from './walk.ts'\n\n/**\n * Wires a {@link LoggerWriter} onto the run's hooks. Each feature registers the hooks for one\n * concern, so every writer reports the same run in the same order: one group per config, a step\n * over the plugin work, a progress bar for the writes, one step per output phase, then the summary.\n * It hands back `renderSummary`, which writes the `cli` reporter's summary inside the group opened\n * for that config and closes the group.\n */\nexport function installLogger({ hooks, writer, logLevel }: { hooks: Hookable<KubbHooks>; writer: LoggerWriter; logLevel: number }): {\n renderSummary: SummaryRenderer\n} {\n const ctx = createLoggerContext({ hooks, writer, logLevel })\n const spinner = createSpinner(ctx)\n const progress = createProgress(ctx, spinner)\n const walk = createWalk(ctx, spinner, progress)\n const phases = createPhases(ctx, spinner)\n const problems = createProblems(ctx, spinner, progress, phases)\n createSession(ctx, spinner)\n return createGeneration(ctx, { spinner, progress, walk, phases, problems })\n}\n","import { hash } from 'node:crypto'\nimport { readFileSync } from 'node:fs'\nimport { readdir } from 'node:fs/promises'\nimport { join, relative } from 'node:path'\nimport process from 'node:process'\nimport { styleText } from 'node:util'\nimport { inParallel, matchesStored, read } from '@internals/utils'\nimport type { Hookable, KubbHooks, OutputManifest, Storage } from '@kubb/core'\n\n/** Glob pattern for paths the file watcher ignores. */\nconst WATCHER_IGNORED_PATHS = '**/{.git,node_modules}/**' as const\n\n/**\n * Quiet window in milliseconds that collapses a burst of watcher events (an editor save emits several) into one rebuild.\n * It outlasts chokidar's 100 ms atomic-save window, which holds back the event of a write-then-rename save.\n */\nconst WATCHER_DEBOUNCE_MS = 250\n\n/** `14:02:11 petStore.yaml changed`, the line a watcher prints when its input changes. */\nexport function formatChange({ target, removed = false, now = new Date() }: { target: string; removed?: boolean; now?: Date }): string {\n return `${styleText('dim', now.toTimeString().slice(0, 8))} ${styleText('bold', target)} ${removed ? 'removed' : 'changed'}`\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 call. `cb` must never reject: its result is not awaited, so the caller\n * serializes and reports its own builds. Resolves to a function that stops watching.\n */\nexport async function startWatcher(\n path: Array<string>,\n cb: (path: Array<string>) => Promise<void>,\n log: WatcherLog = { info: console.log, error: console.log },\n): Promise<() => Promise<void>> {\n const { watch } = await import('chokidar')\n // `ignoreInitial` skips the `add` events chokidar fires for existing files at startup, which\n // would otherwise rebuild right after the initial run.\n const watcher = watch(path, { ignorePermissionErrors: true, ignored: WATCHER_IGNORED_PATHS, ignoreInitial: true })\n\n for (const signal of ['SIGINT', 'SIGTERM'] as const) {\n process.once(signal, () => void watcher.close())\n }\n\n let debounceTimer: ReturnType<typeof setTimeout> | null = null\n\n watcher.on('all', (type, file) => {\n log.info(formatChange({ target: relative(process.cwd(), file), removed: type === 'unlink' }))\n if (debounceTimer) clearTimeout(debounceTimer)\n debounceTimer = setTimeout(() => {\n debounceTimer = null\n void cb(path)\n }, WATCHER_DEBOUNCE_MS)\n })\n\n return async () => {\n if (debounceTimer) clearTimeout(debounceTimer)\n await watcher.close()\n }\n}\n\n/**\n * What one build produced: the schema and operation names the plugins generated.\n */\nexport type BuildSnapshot = {\n schemas: Set<string>\n operations: Set<string>\n}\n\nfunction createSnapshot(): BuildSnapshot {\n return { schemas: new Set(), operations: new Set() }\n}\n\n/**\n * Collects a {@link BuildSnapshot} from the hooks while a build runs. `take` hands back the finished\n * build's snapshot and starts the next one.\n */\nexport function trackBuild(hooks: Hookable<KubbHooks>): { take(): BuildSnapshot } {\n let current = createSnapshot()\n\n hooks.hook('kubb:generate:schema', (node) => {\n if (node.name) current.schemas.add(node.name)\n })\n hooks.hook('kubb:generate:operation', (node) => {\n current.operations.add(node.operationId)\n })\n\n return {\n take() {\n const snapshot = current\n current = createSnapshot()\n return snapshot\n },\n }\n}\n\ntype NameChange = { added: number; removed: number }\n\n/**\n * How a rebuild differs from the build before it: the spec's added and removed schemas and operations.\n */\nexport type BuildDiff = {\n schemas: NameChange\n operations: NameChange\n}\n\nfunction diffNames(previous: Set<string>, next: Set<string>): NameChange {\n return { added: [...next].filter((name) => !previous.has(name)).length, removed: [...previous].filter((name) => !next.has(name)).length }\n}\n\n/**\n * Compares two {@link BuildSnapshot}s by name.\n */\nexport function diffBuilds(previous: BuildSnapshot, next: BuildSnapshot): BuildDiff {\n return {\n schemas: diffNames(previous.schemas, next.schemas),\n operations: diffNames(previous.operations, next.operations),\n }\n}\n\n/** A changed file with how many lines it gains and loses, counted as a multiset, which is cheap and close enough for a plan. */\nexport type FileChange = { status: 'A' | 'M' | 'D'; path: string; added?: number; removed?: number }\n\ntype Lines = Iterable<string | number>\n\nfunction splitLines(text: string): Array<string> {\n return text ? text.split('\\n') : []\n}\n\n// A loop, not a spread into an array of characters: this runs over every line of the old output on each clean run.\nfunction hashLine(line: string): number {\n let hash = 0x811c9dc5\n for (const char of line) hash = Math.imul(hash ^ char.codePointAt(0)!, 0x01000193)\n return hash\n}\n\nfunction hashLines(text: string): Int32Array {\n return Int32Array.from(splitLines(text), hashLine)\n}\n\nfunction countLineChanges({ before, after }: { before: Lines; after: Lines }): { added: number; removed: number } {\n const remaining = new Map<string | number, number>()\n for (const line of before) remaining.set(line, (remaining.get(line) ?? 0) + 1)\n const added = [...after].filter((line) => {\n const count = remaining.get(line) ?? 0\n if (count === 0) return true\n remaining.set(line, count - 1)\n return false\n }).length\n const removed = [...remaining.values()].reduce((sum, count) => sum + count, 0)\n return { added, removed }\n}\n\n/**\n * Reads the output before generation, so cleaning the directory cannot erase the diff baseline.\n * A missing directory or an unreadable file is skipped. This keeps every file's text for the whole\n * run, so only a dry run and a run with output passes use it: they compare against the output read\n * back at the end.\n */\nexport async function readOutputFiles(outputPath: string): Promise<Map<string, string>> {\n const entries = await readdir(outputPath, { recursive: true, withFileTypes: true }).catch(() => [])\n const files = new Map<string, string>()\n await inParallel({\n items: entries.filter((entry) => entry.isFile()).map((entry) => join(entry.parentPath, entry.name)),\n limit: 50,\n run: async (filePath) => {\n const source = await read(filePath).catch(() => null)\n if (source !== null) files.set(filePath, source)\n },\n })\n return files\n}\n\n/**\n * Hashes of a file `output.clean` deleted, enough to tell whether its regenerated copy changed and by how many lines.\n */\nexport type FileFingerprint = {\n length: number\n digest: string\n lines: Int32Array\n deletedLines: number\n}\n\nexport function fingerprintFile(text: string): FileFingerprint {\n const body = text.trimEnd()\n const trimmed = body.trimStart()\n // A deleted file also counts the blank lines above its first line, which trimming drops.\n const leading = body.slice(0, body.length - trimmed.length).split('\\n').length - 1\n const lines = hashLines(trimmed)\n\n return { length: trimmed.length, digest: hash('sha1', trimmed), lines, deletedLines: body ? lines.length + leading : 0 }\n}\n\n/**\n * Fingerprints every file under the output folder right before `output.clean` empties it, one file at a time, so the\n * old tree is never held in memory. A missing directory or an unreadable file is skipped.\n */\nexport async function readOutputFingerprints(outputPath: string): Promise<Map<string, FileFingerprint>> {\n const entries = await readdir(outputPath, { recursive: true, withFileTypes: true }).catch(() => [])\n const fingerprints = new Map<string, FileFingerprint>()\n for (const entry of entries) {\n if (!entry.isFile()) continue\n const filePath = join(entry.parentPath, entry.name)\n try {\n // Synchronous on purpose: one read at a time is several times faster here than a pool of `fs.promises` reads.\n fingerprints.set(filePath, fingerprintFile(readFileSync(filePath, 'utf8')))\n } catch {\n /* unreadable, so it cannot be compared */\n }\n }\n return fingerprints\n}\n\n/**\n * How one generated file differs from its copy before generation: `undefined` when both hold the\n * same output, otherwise the change with its line counts. `previous` is the stored text, the\n * {@link FileFingerprint} of a file `output.clean` deleted, or `null` for a new file. The manifest\n * recognizes output a formatter rewrote.\n */\nexport function diffFile({\n path,\n next,\n previous,\n manifest,\n}: {\n path: string\n next: string\n previous: string | FileFingerprint | null\n manifest?: Pick<OutputManifest, 'isUpToDate'>\n}): FileChange | undefined {\n if (previous === null) return { status: 'A', path, added: splitLines(next.trimEnd()).length, removed: 0 }\n if (typeof previous !== 'string') {\n const trimmed = next.trim()\n if (trimmed.length === previous.length && hash('sha1', trimmed) === previous.digest) return undefined\n return { status: 'M', path, ...countLineChanges({ before: previous.lines, after: hashLines(trimmed) }) }\n }\n if (matchesStored({ stored: previous, source: next }) || manifest?.isUpToDate({ key: path, source: next, disk: previous })) return undefined\n return { status: 'M', path, ...countLineChanges({ before: splitLines(previous.trim()), after: splitLines(next.trim()) }) }\n}\n\n/**\n * The totals the summary prints, plus the files that came out the same.\n */\nexport type ChangeTally = { added: number; modified: number; deleted: number; linesAdded: number; linesRemoved: number; unchanged: number }\n\nconst statusKeys = { A: 'added', M: 'modified', D: 'deleted' } as const\n\n/**\n * Adds one file's outcome to the totals: a {@link FileChange}, or `undefined` for an unchanged file.\n */\nexport function tallyChange({ tally, change }: { tally: ChangeTally; change: FileChange | undefined }): void {\n if (!change) {\n tally.unchanged++\n return\n }\n tally[statusKeys[change.status]]++\n tally.linesAdded += change.added ?? 0\n tally.linesRemoved += change.removed ?? 0\n}\n\nexport function createChangeTally(): ChangeTally {\n return { added: 0, modified: 0, deleted: 0, linesAdded: 0, linesRemoved: 0, unchanged: 0 }\n}\n\n/**\n * Compares generated output with the files captured before generation. The manifest recognizes\n * output rewritten by a formatter, and `clean` includes files the run would delete.\n */\nexport async function diffOutput({\n storage,\n paths,\n clean,\n manifest,\n previousFiles,\n}: {\n storage: Storage\n paths: ReadonlySet<string>\n clean: boolean\n manifest?: Pick<OutputManifest, 'isUpToDate'>\n /**\n * The output captured before a real run, including files removed by cleaning.\n */\n previousFiles: ReadonlyMap<string, string>\n}): Promise<{ files: Array<FileChange>; unchanged: number }> {\n // `null` marks an unchanged file. A path the storage does not hold leaves a hole, which `filter` skips.\n const results: Array<FileChange | null> = []\n await inParallel({\n items: [...paths],\n limit: 50,\n run: async (filePath, index) => {\n const next = await storage.readItem(filePath)\n if (next === null) return\n results[index] = diffFile({ path: filePath, next, previous: previousFiles.get(filePath) ?? null, manifest }) ?? null\n },\n })\n const files = results.filter((result) => result !== null)\n const unchanged = results.filter((result) => result === null).length\n if (clean) {\n for (const [filePath, source] of previousFiles) {\n if (!paths.has(filePath)) files.push({ status: 'D', path: filePath, added: 0, removed: splitLines(source.trimEnd()).length })\n }\n }\n\n return { files, unchanged }\n}\n\ntype KeyInput = Pick<NodeJS.ReadStream, 'isTTY' | 'setRawMode' | 'resume' | 'pause' | 'setEncoding' | 'on'>\n\ntype KeyOptions = {\n rebuild: () => void\n /**\n * Ends the process with this exit code: `0` for `q`, `130` for ctrl+c, which raw mode turns into a key.\n */\n quit: (code: number) => void\n input?: KeyInput\n}\n\n/**\n * Reads `r` (rebuild) and `q` (quit) from an interactive stdin in raw mode, and keeps ctrl+c\n * working. Returns `undefined` when stdin is not a TTY. Otherwise returns `arm`, which turns raw\n * mode back on: a spinner restores the terminal when it stops, so call it after each build. Raw mode\n * is restored on exit.\n */\nexport function listenForKeys({ rebuild, quit, input = process.stdin }: KeyOptions): (() => void) | undefined {\n if (!input.isTTY) return undefined\n\n const arm = () => {\n input.setRawMode(true)\n input.resume()\n }\n input.setEncoding('utf8')\n input.on('data', (data: string) => {\n const key = data.trim()\n if (key === 'r') {\n rebuild()\n return\n }\n if (key === 'q' || data === '\\u0003') {\n input.setRawMode(false)\n input.pause()\n quit(key === 'q' ? 0 : 130)\n }\n })\n process.once('exit', () => input.setRawMode(false))\n arm()\n\n return arm\n}\n","import process from 'node:process'\nimport { resolve } from 'node:path'\nimport { readFile } from 'node:fs/promises'\nimport { isPathInside, memo } from '@internals/utils'\nimport type { GenerationResult, Hookable, KubbGenerationEndContext, KubbHooks, Reporter, ReporterContext } from '@kubb/core'\nimport { cacheStorage, createCliReporter, createOutputManifest, hasOutputPasses, logLevel as logLevelMap } from '@kubb/core'\nimport { writer as defaultWriter } from '../ui/log.ts'\nimport { installLogger } from './features/index.ts'\nimport type { LoggerWriter } from './types.ts'\nimport {\n type ChangeTally,\n createChangeTally,\n diffFile,\n diffOutput,\n type FileFingerprint,\n readOutputFiles,\n readOutputFingerprints,\n tallyChange,\n} from '../runners/generate/utils.ts'\n\ntype LiveChanges = {\n tally: ChangeTally\n // The files `output.clean` is about to delete, the only trace of them once the folder is emptied.\n fingerprints: Map<string, FileFingerprint>\n processed: Set<string>\n}\n\ntype GenerationRun = {\n outputPath: string\n filesUnchanged: number\n paths: Set<string>\n // Read-back runs only: the whole output as it was before generation.\n previous?: Map<string, string>\n reading?: Promise<Map<string, string>>\n // A run without output passes counts each file as it is written, against the stored text the write already read.\n live?: LiveChanges\n}\n\n/** Installs the live logger and wires the selected reporters. `cli` renders its summary through the logger, and is skipped when `json` owns stdout. */\nfunction setupReporters(\n context: Hookable<KubbHooks>,\n {\n logLevel,\n reporters,\n writer = defaultWriter(),\n dryRun = false,\n fileChanges = false,\n }: {\n /** Output verbosity. Use the `logLevel` constants exported from `@kubb/core`. */\n logLevel: number\n reporters: ReadonlyArray<Reporter>\n /** Overrides the terminal-based pick, e.g. the plain writer for `kubb studio snapshot`. */\n writer?: LoggerWriter\n /**\n * Labels the memory-backed generation as a preview rather than a completed write.\n */\n dryRun?: boolean\n /**\n * Hands `fileChanges` to every reporter, not only `cli`.\n */\n fileChanges?: boolean\n },\n): void {\n const hasJson = reporters.some((reporter) => reporter.name === 'json')\n const selected = reporters.flatMap((reporter) => {\n if (reporter.name !== 'cli') return [reporter]\n if (hasJson) return []\n return [createCliReporter({ render: installLogger({ hooks: context, writer, logLevel }).renderSummary })]\n })\n const ctx: ReporterContext = { logLevel }\n const pluginFiles = selected.some((reporter) => reporter.needsPluginFiles) ? memo.create<string, Array<string>>() : undefined\n const seen = new Set<string>()\n if (pluginFiles) {\n context.hook('kubb:plugin:end', ({ plugin, files }) => {\n for (const file of files) {\n if (seen.has(file.path)) continue\n seen.add(file.path)\n memo(pluginFiles, plugin.name, () => []).push(file.path)\n }\n })\n }\n\n // Configs generate one at a time, so the last write before `kubb:generation:end` is this config's.\n let run: GenerationRun | undefined\n const trackChanges = (fileChanges || selected.some((reporter) => reporter.name === 'cli')) && logLevel > logLevelMap.silent\n context.hook('kubb:generation:start', ({ config }) => {\n pluginFiles?.clear()\n seen.clear()\n const outputPath = resolve(config.root, config.output.path)\n const tracked = trackChanges && (dryRun || config.storage?.name === 'fs')\n const live = ((): LiveChanges | undefined => {\n // Output passes rewrite stored files and a dry run compares through the manifest, so both read the output back.\n if (!tracked || dryRun || hasOutputPasses(config)) return undefined\n return { tally: createChangeTally(), fingerprints: new Map(), processed: new Set() }\n })()\n run = {\n outputPath,\n filesUnchanged: 0,\n paths: new Set(),\n live,\n // Read while the plugins generate; `kubb:plugins:end` waits for it, before cleaning can erase the baseline.\n reading: tracked && !live ? readOutputFiles(outputPath) : undefined,\n }\n })\n context.hook('kubb:plugins:end', async ({ config }) => {\n if (!run) return\n if (run.reading) run.previous = await run.reading\n // The last moment the old files exist: the storage empties the folder right after this hook.\n if (run.live && config.output.clean) run.live.fingerprints = await readOutputFingerprints(run.outputPath)\n })\n context.hook('kubb:files:processing:start', async ({ files }) => {\n if (!run?.previous) return\n const { previous, outputPath } = run\n // Plugin output can live outside the main output folder; capture it before writes start.\n for (const file of files) {\n if (previous.has(file.path) || isPathInside(outputPath, file.path)) continue\n const source = await readFile(file.path, 'utf8').catch(() => null)\n if (source !== null) previous.set(file.path, source)\n }\n })\n context.hook('kubb:file:processed', ({ file, source, stored = null }) => {\n const live = run?.live\n if (!live) return\n // The storage writes the trimmed source and skips a blank one, which leaves the stored file as it was.\n const next = source.trim()\n if (!next) return\n live.processed.add(file.path)\n tallyChange({ tally: live.tally, change: diffFile({ path: file.path, next, previous: stored ?? live.fingerprints.get(file.path) ?? null }) })\n })\n context.hook('kubb:files:processing:end', ({ files, unchanged }) => {\n if (!run) return\n run.filesUnchanged = unchanged.length\n run.paths = new Set(files.map((file) => file.path))\n })\n\n /** The run's totals: counted while writing, or worked out by reading the output back. */\n async function countChanges({\n config,\n storage,\n current,\n }: Pick<KubbGenerationEndContext, 'config' | 'storage'> & { current: GenerationRun }): Promise<ChangeTally | undefined> {\n const { live, paths, previous } = current\n if (live) {\n const { tally, fingerprints, processed } = live\n for (const [filePath, fingerprint] of fingerprints) {\n if (!paths.has(filePath)) tallyChange({ tally, change: { status: 'D', path: filePath, removed: fingerprint.deletedLines } })\n }\n // A blank file left whatever the storage held in place, so a stored copy counts as unchanged.\n for (const filePath of paths.difference(processed)) {\n if ((await storage.readItem(filePath)) !== null) tally.unchanged++\n }\n return tally\n }\n if (!previous) return undefined\n const manifest = dryRun ? await createOutputManifest({ storage, cache: cacheStorage({ root: config.root }) }) : undefined\n const diff = await diffOutput({ storage, paths, clean: Boolean(config.output.clean), manifest, previousFiles: previous })\n const changes = createChangeTally()\n changes.unchanged = diff.unchanged\n for (const file of diff.files) tallyChange({ tally: changes, change: file })\n return changes\n }\n\n context.hook('kubb:generation:end', async ({ config, storage, diagnostics = [], filesCreated = 0, status = 'success', hrStart = process.hrtime() }) => {\n const current = run\n run = undefined\n const result: GenerationResult = { config, diagnostics, filesCreated, filesUnchanged: current?.filesUnchanged ?? 0, dryRun, status, hrStart }\n const cliResult = { ...result }\n const counted = current && status !== 'failed' ? await countChanges({ config, storage, current }) : undefined\n if (counted) {\n const { unchanged, ...changes } = counted\n cliResult.filesCreated = changes.added + changes.modified + unchanged\n cliResult.filesUnchanged = unchanged\n cliResult.fileChanges = changes\n }\n for (const reporter of selected) {\n const grouped = reporter.needsPluginFiles && pluginFiles?.size ? [...pluginFiles].map(([plugin, files]) => ({ plugin, files: [...files] })) : undefined\n await reporter.report({ ...(reporter.name === 'cli' || fileChanges ? cliResult : result), pluginFiles: grouped }, ctx)\n }\n })\n\n context.hook('kubb:lifecycle:end', async () => {\n for (const reporter of selected) await reporter.drain?.(ctx)\n })\n}\n\nexport default setupReporters\n\n/** Picks the reporters whose `name` is in `names`, in the given order (the CLI maps `--reporter` to this); duplicates and unknown names are skipped. */\nexport function selectReporters(reporters: ReadonlyArray<Reporter>, names: ReadonlyArray<string>): Array<Reporter> {\n return [...new Set(names)].flatMap((name) => reporters.find((reporter) => reporter.name === name) ?? [])\n}\n"],"mappings":";;;;;;;;;;;;;;;AA0BA,SAAgB,oBAAoB,EAAE,OAAO,QAAQ,YAAmG;CACtJ,MAAM,QAAQ,YAAqB,YAAYA,WAAAA,SAAY,UAAU,IAAA,GAAGC,UAAAA,UAAAA,CAAU,OAAO,IAAI,MAAM,EAAE,EAAE,EAAE,GAAG,YAAY;CACxH,MAAM,MAAqB;EACzB;EACA;EACA;EACA,QAAQ,YAAYD,WAAAA,SAAY;EAChC,OAAO,OAAO,aAAa;EAC3B,SAAS;EACT,WAAW;EACX;EACA,OAAO,QAAQ,SAAS,SAAS,KAAK;GAAC;GAAQ;GAAS,SAAA,GAAQC,UAAAA,UAAAA,CAAU,OAAO,IAAI;EAAC,CAAC,CAAC,OAAO,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AAkB;GAAG;GAAQ;GAAQ;EAAQ;EAC5I,MAAM,YAAY,EAAE,GAAG,OAAO;EAC9B,MAAM,UAAU,WAAW,WAAW,WAAW,MAAM,aAAa;GAAE;GAAQ;GAAS;EAAQ,CAAC,IAAI,KAAA;EACpG,IAAI,SAAS;GACX,MAAM,EAAE,WAAW,GAAG,YAAY;GAClC,UAAU,eAAe,QAAQ,QAAQ,QAAQ,WAAW;GAC5D,UAAU,iBAAiB;GAC3B,UAAU,cAAc;EAC1B;EACA,KAAK,MAAM,YAAY,UAAU;GAC/B,MAAM,UAAU,SAAS,oBAAoB,aAAa,OAAO,CAAC,GAAG,WAAW,CAAC,CAAC,KAAK,CAAC,QAAQ,YAAY;IAAE;IAAQ,OAAO,CAAC,GAAG,KAAK;GAAE,EAAE,IAAI,KAAA;GAC9I,MAAM,SAAS,OAAO;IAAE,GAAI,SAAS,SAAS,SAAS,cAAc,YAAY;IAAS,aAAa;GAAQ,GAAG,GAAG;EACvH;CACF,CAAC;CAED,QAAQ,KAAK,sBAAsB,YAAY;EAC7C,KAAK,MAAM,YAAY,UAAU,MAAM,SAAS,QAAQ,GAAG;CAC7D,CAAC;AACH;;AAKA,SAAgB,gBAAgB,WAAoC,OAA+C;CACjH,OAAO,CAAC,GAAG,IAAI,IAAI,KAAK,CAAC,CAAC,CAAC,SAAS,SAAS,UAAU,MAAM,aAAa,SAAS,SAAS,IAAI,KAAK,CAAC,CAAC;AACzG"}
1
+ {"version":3,"file":"reporters-DLK4D0js.cjs","names":["logLevelMap","styleText","styleText","process","formatMsWithColor","getElapsedMs","styleText","logLevelMap","memo","styleText","logLevelMap","process","relative","Diagnostics","styleText","getInputKind","resolve","read","pluralize","logLevelMap","pluralize","relative","styleText","styleText","logLevelMap","toPermissionFlag","process","getElapsedMs","Diagnostics","pluralize","formatMs","process","formatMs","getElapsedMs","styleText","pluralize","formatBar","formatMsWithColor","styleText","process","relative","readdir","inParallel","join","read","hash","readFileSync","matchesStored","writer","defaultWriter","createCliReporter","memo","logLevelMap","resolve","hasOutputPasses","isPathInside","readFile","createOutputManifest","cacheStorage","process"],"sources":["../src/loggers/features/context.ts","../src/loggers/features/generation.ts","../src/loggers/features/phases.ts","../src/loggers/specFrame.ts","../src/loggers/features/problems.ts","../src/loggers/features/progress.ts","../src/loggers/features/session.ts","../src/loggers/features/spinner.ts","../src/loggers/features/walk.ts","../src/loggers/features/index.ts","../src/runners/generate/utils.ts","../src/loggers/reporters.ts"],"sourcesContent":["import { styleText } from 'node:util'\nimport { type Config, type Hookable, type KubbHooks, logLevel as logLevelMap } from '@kubb/core'\nimport type { LoggerWriter } from '../types.ts'\n\n/**\n * What `installLogger` shares with its features: the writer, the verbosity flags, and the two\n * run-wide flags a feature flips for the others to read.\n */\nexport type LoggerContext = {\n hooks: Hookable<KubbHooks>\n writer: LoggerWriter\n logLevel: number\n silent: boolean\n human: boolean\n /** Set once a rich `kubb studio` session connects: each run then shows as one job line. */\n session: boolean\n /** Whether a config's group is open, so a problem can wait for its end. */\n groupOpen: boolean\n /** Prefixes a `[HH:MM:SS]` timestamp at verbose and above. */\n text: (message: string) => string\n /** `✓ message info`, with the info dimmed. */\n line: (symbol: string, message: string, info?: string) => string\n /** Registers a per-run hook. In a Studio session the job line stands for the whole run, so these stay quiet. */\n onRun: <Name extends keyof KubbHooks & string>(name: Name, fn: (...args: KubbHooks[Name]) => unknown) => () => void\n}\n\nexport function createLoggerContext({ hooks, writer, logLevel }: { hooks: Hookable<KubbHooks>; writer: LoggerWriter; logLevel: number }): LoggerContext {\n const text = (message: string) => (logLevel >= logLevelMap.verbose ? `${styleText('dim', `[${clock()}]`)} ${message}` : message)\n const ctx: LoggerContext = {\n hooks,\n writer,\n logLevel,\n silent: logLevel <= logLevelMap.silent,\n human: writer.audience === 'human',\n session: false,\n groupOpen: false,\n text,\n line: (symbol, message, info) => text([symbol, message, info && styleText('dim', info)].filter(Boolean).join(' ')),\n onRun(name, fn) {\n return hooks.hook(name, (...args) => (ctx.session ? undefined : fn(...args)))\n },\n }\n return ctx\n}\n\n/** `HH:MM:SS` in 24-hour time. */\nexport function clock(date = new Date()): string {\n return date.toLocaleTimeString('en-US', { hour12: false, hour: '2-digit', minute: '2-digit', second: '2-digit' })\n}\n\n/** Display path for a config's input: the string form, or its `path` field when the input is an object. */\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","import { styleText } from 'node:util'\nimport type { SummaryRenderer } from '@kubb/core'\nimport type { LogStatus } from '../types.ts'\nimport { getInputPath, type LoggerContext } from './context.ts'\nimport type { Phases } from './phases.ts'\nimport type { Problems } from './problems.ts'\nimport type { Progress } from './progress.ts'\nimport type { Spinner } from './spinner.ts'\nimport type { Walk } from './walk.ts'\n\n/**\n * One config's run: the group it opens, the state every feature resets at its start, and the\n * closing line, which the lifecycle end draws too for a run that threw before its summary.\n */\nexport function createGeneration(\n ctx: LoggerContext,\n { spinner, progress, walk, phases, problems }: { spinner: Spinner; progress: Progress; walk: Walk; phases: Phases; problems: Problems },\n): { renderSummary: SummaryRenderer } {\n const { writer, silent, human, text, hooks, onRun } = ctx\n\n function reset() {\n spinner.reset()\n progress.reset()\n walk.reset()\n phases.reset()\n problems.reset()\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 (!ctx.groupOpen) {\n return\n }\n ctx.groupOpen = false\n\n spinner.stop()\n progress.stop()\n writer.groupEnd(status === 'failed' ? styleText('red', problems.failedTitle()) : styleText('green', '✓ Generation succeeded'))\n }\n\n hooks.hook('kubb:lifecycle:start', () => {\n reset()\n })\n\n onRun('kubb:generation:start', ({ config }) => {\n closeGroup('failed')\n reset()\n\n walk.state.totalPlugins = config.plugins?.length ?? 0\n progress.state.inMemory = config.storage?.name === 'memory'\n problems.setSpec(config)\n\n if (silent) {\n return\n }\n\n const input = getInputPath(config)\n writer.group(text([styleText('bold', config.name ?? 'kubb'), input ? styleText('dim', input) : undefined].filter(Boolean).join(' ')))\n ctx.groupOpen = true\n\n spinner.start('Parsing spec')\n })\n\n onRun('kubb:generation:end', async ({ diagnostics = [] }) => {\n spinner.stop()\n progress.stop()\n problems.state.diagnostics = diagnostics\n await problems.flush()\n })\n\n hooks.hook('kubb:lifecycle:end', async () => {\n await problems.flush()\n closeGroup('failed')\n reset()\n })\n\n const renderSummary: SummaryRenderer = (lines, { status }) => {\n if (silent || !ctx.groupOpen) {\n return\n }\n\n spinner.stop()\n progress.stop()\n if (human) closeGroup(status)\n ctx.groupOpen = false\n writer.diagnostic([...lines])\n }\n\n return { renderSummary }\n}\n","import process from 'node:process'\nimport { styleText } from 'node:util'\nimport { getElapsedMs } from '@internals/utils'\nimport { logLevel as logLevelMap } from '@kubb/core'\nimport { formatMsWithColor } from '../banner.ts'\nimport type { LoggerContext } from './context.ts'\nimport type { Spinner } from './spinner.ts'\n\nexport type Phases = ReturnType<typeof createPhases>\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 = StartPhaseOptions & {\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 /**\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}\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/** A hook's display name: its `name`, or the command line it runs. */\nfunction formatHookLabel({ command, name, args }: { command: string; name?: string; args?: ReadonlyArray<string> }): string {\n return name ?? (args?.length ? `${command} ${args.join(' ')}` : command)\n}\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/** The format, lint and post-generate phases, and the hooks and messages they buffer while their step owns the line. */\nexport function createPhases({ writer, silent, logLevel, text, line, onRun }: LoggerContext, spinner: Spinner) {\n const state = {\n phase: null as Phase | null,\n hooks: new Map<string, { hrStart: [number, number]; lines: Array<string> }>(),\n }\n\n function startPhase(options: StartPhaseOptions) {\n state.phase = { ...options, failed: false, hrStart: process.hrtime(), lines: [], output: [] }\n spinner.start(options.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 spinner.stop(phase.failed ? `${phase.failure} after ${duration}` : `${phase.success} 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 onRun('kubb:format:start', () => startPhase(PHASES.format))\n onRun('kubb:format:end', endPhase)\n onRun('kubb:lint:start', () => startPhase(PHASES.lint))\n onRun('kubb:lint:end', endPhase)\n onRun('kubb:hooks:start', () => startPhase(PHASES.hooks))\n onRun('kubb:hooks:end', endPhase)\n\n onRun('kubb:hook:end', (ctx) => {\n const { id, command, name, args, success, error } = ctx\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. `stdout` and `stderr` only exist on a failed result.\n if (!ctx.success) {\n if (ctx.stdout) console.log(ctx.stdout)\n if (ctx.stderr) console.error(ctx.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', formatHookLabel({ command, name, 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 spinner.stop()\n writer.step(text(result))\n writeOutput(active.lines)\n })\n\n // Not registered at silent: the missing `kubb:hook:line` listener is also what tells the runner not to stream.\n if (!silent) {\n onRun('kubb:info', ({ message, info }) => {\n const formatted = line(styleText('blue', 'ℹ'), message, info)\n\n // Info carries something new (the auto-detected tool), so inside a phase it waits for the phase to print.\n if (state.phase) {\n state.phase.lines.push(formatted)\n return\n }\n if (spinner.message(formatted)) {\n return\n }\n writer.info(formatted)\n })\n\n onRun('kubb:success', ({ message, info }) => {\n const formatted = line(styleText('green', '✓'), message, logLevel >= logLevelMap.info ? info : undefined)\n\n // The phase step's own result already reports these successes, so let the step carry them.\n if (spinner.message(formatted)) {\n return\n }\n writer.success(formatted)\n })\n\n onRun('kubb:hook:start', ({ id, command, name, args }) => {\n if (!id) {\n return\n }\n state.hooks.set(id, { hrStart: process.hrtime(), lines: [] })\n spinner.message(text(`Running ${styleText('dim', formatHookLabel({ command, name, args }))}`))\n })\n\n onRun('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 return {\n /** The phase whose step owns the line, so a failure or an info line can wait for it. */\n get phase(): Phase | null {\n return state.phase\n },\n reset() {\n state.phase = null\n state.hooks = new Map()\n },\n }\n}\n","import { styleText } from 'node:util'\nimport { memo } from '@internals/utils'\nimport type { Adapter, DiagnosticLocation } from '@kubb/core'\n\n/**\n * A location in source text, with a terminal code frame that underlines it.\n */\nexport type SpecPosition = {\n line: number\n column: number\n frame: Array<string>\n}\n\n// Diagnostics of one run share a source, so its line starts are indexed once. Splitting a large\n// spec per diagnostic made code frames the slowest part of a run.\nconst startsBySource = memo.create<string, Array<number>>({ max: 1 })\n\nfunction lineStarts(source: string): Array<number> {\n return memo(startsBySource, source, () => {\n const starts = [0]\n for (const match of source.matchAll(/\\n/g)) starts.push(match.index + 1)\n return starts\n })\n}\n\n/** The index of the last line start at or before `offset`, found by binary search. */\nfunction lineIndex(starts: Array<number>, offset: number, low = 0, high = starts.length - 1): number {\n if (low >= high) return low\n const mid = (low + high + 1) >> 1\n return starts[mid]! <= offset ? lineIndex(starts, offset, mid, high) : lineIndex(starts, offset, low, mid - 1)\n}\n\n/**\n * Where `location` sits in `source` according to its adapter, with a code frame. `undefined` when the adapter cannot place it.\n */\nexport function locateInSpec({ adapter, source, location }: { adapter: Adapter; source: string; location: DiagnosticLocation }): SpecPosition | undefined {\n try {\n const range = adapter.locate?.(source, location)\n if (!range) return undefined\n const starts = lineStarts(source)\n const index = lineIndex(starts, range.start)\n const lineText = (number: number) => source.slice(starts[number - 1], number < starts.length ? starts[number]! - 1 : source.length).replace(/\\r$/, '')\n const line = index + 1\n const column = range.start - starts[index]! + 1\n const text = lineText(line)\n const width = String(line).length\n const gutter = (number?: number) => styleText('dim', `${number === undefined ? ''.padStart(width) : String(number).padStart(width)} │`)\n const carets = '^'.repeat(Math.max(1, Math.min(range.end - range.start, text.length - column + 1)))\n return {\n line,\n column,\n frame: [\n ...(line > 1 ? [`${gutter(line - 1)} ${lineText(line - 1)}`] : []),\n `${gutter(line)} ${text}`,\n `${gutter()} ${' '.repeat(column - 1)}${styleText('red', carets)}`,\n ],\n }\n } catch {\n return undefined\n }\n}\n","import { relative, resolve } from 'node:path'\nimport process from 'node:process'\nimport { styleText } from 'node:util'\nimport { read } from '@internals/utils'\nimport type { Adapter, Config, Diagnostic, DiagnosticFormatOptions, ProblemDiagnostic } from '@kubb/core'\nimport { Diagnostics, getInputKind, logLevel as logLevelMap } from '@kubb/core'\nimport { pluralize } from '../../ui/text.ts'\nimport { locateInSpec } from '../specFrame.ts'\nimport { getInputPath, type LoggerContext } from './context.ts'\nimport type { Phases } from './phases.ts'\nimport type { Progress } from './progress.ts'\nimport type { Spinner } from './spinner.ts'\n\nexport type Problems = ReturnType<typeof createProblems>\n\n/** Warnings, errors and diagnostics: printed as they come, or held back and grouped by plugin once a human's build ends. */\nexport function createProblems(ctx: LoggerContext, spinner: Spinner, progress: Progress, phases: Phases) {\n const { writer, silent, human, logLevel, text, line, hooks } = ctx\n const { audience } = writer\n const formatOptions: DiagnosticFormatOptions = {\n audience,\n verbose: logLevel >= logLevelMap.verbose,\n // The code lines up at the right edge, inside the group indent and the human view's per-problem indent.\n width: Math.min(process.stdout.columns || 80, 100) - (audience === 'human' ? 4 : 2),\n }\n const state = {\n /** Problems held back so the human view can print them grouped by plugin once the build ends. */\n problems: [] as Array<ProblemDiagnostic>,\n /** The finished config's diagnostics, for the closing verdict. */\n diagnostics: [] as Array<Diagnostic>,\n /** A local-file input, which a located diagnostic points into; `load` parses it once, on the first such diagnostic. */\n spec: undefined as { path: string; adapter: Adapter; source: Promise<string | undefined> } | undefined,\n }\n\n /** Format options for one problem, with its line and column in a local spec when its pointer resolves there. */\n async function optionsFor(problem: ProblemDiagnostic): Promise<DiagnosticFormatOptions> {\n const { location } = problem\n const { spec } = state\n if (!location || !spec) {\n return formatOptions\n }\n\n const source = await spec.source\n const position = source && locateInSpec({ adapter: spec.adapter, source, location })\n if (!position) {\n return formatOptions\n }\n return { ...formatOptions, position: { file: relative(process.cwd(), spec.path), ...position } }\n }\n\n /**\n * Prints problems grouped under their plugin's name, each with the code aligned at the right.\n */\n async function writeProblems(problems: ReadonlyArray<ProblemDiagnostic>) {\n if (!problems.length) {\n return\n }\n const formatted = await Promise.all(problems.map(async (problem) => Diagnostics.format(problem, await optionsFor(problem))))\n if (!human) {\n for (const lines of formatted) writer.diagnostic(lines)\n return\n }\n\n const byPlugin = Map.groupBy(\n problems.map((problem, index) => ({ plugin: problem.plugin ?? '', lines: formatted[index]! })),\n ({ plugin }) => plugin,\n )\n const lines = [...byPlugin].flatMap(([plugin, group]) => [\n ...(plugin ? [` ${styleText('bold', plugin)}`, ''] : []),\n ...group.flatMap((entry) => [...entry.lines.map((entryLine) => ` ${entryLine}`), '']),\n ])\n writer.diagnostic(lines.slice(0, -1))\n }\n\n hooks.hook('kubb:warn', ({ message, info }) => {\n if (logLevel < logLevelMap.warn) {\n return\n }\n\n writer.warn(line(styleText('yellow', '⚠'), message, logLevel >= logLevelMap.info ? info : undefined))\n })\n\n // Unguarded: a failure stays visible even at silent.\n hooks.hook('kubb:error', ({ error }) => {\n const phase = phases.phase\n if (phase) {\n phase.failed = true\n }\n\n // Rendered as a `KUBB_UNKNOWN` diagnostic, so the output alone says what broke and where. The\n // name tells a `TypeError` from a plain `Error`.\n const message = error.name === 'Error' || Diagnostics.isError(error) ? error.message : `${error.name}: ${error.message}`\n const help = Diagnostics.isError(error) ? error.diagnostic.help : undefined\n const [headline = '', ...details] = Diagnostics.format({ code: Diagnostics.code.unknown, severity: 'error', message, help, cause: error }, formatOptions)\n\n if (!human) {\n spinner.stop()\n progress.stop()\n writer.diagnostic([headline, ...details])\n return\n }\n\n // The writer draws the error symbol, so the message goes in bare.\n if (spinner.active) {\n spinner.stop(message, 'failed')\n } else {\n writer.error(text(message))\n }\n if (details.length) {\n writer.block(details.map(text))\n }\n })\n\n hooks.hook('kubb:diagnostic', async ({ 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 // A Studio job's problems show in Studio; its job line counts the errors.\n if (ctx.session && !Diagnostics.isUpdate(diagnostic)) {\n return\n }\n\n spinner.stop()\n progress.stop()\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 // Inside a build, the human view waits for the end to group by plugin.\n if (human && ctx.groupOpen) {\n state.problems.push(diagnostic)\n return\n }\n await writeProblems([diagnostic])\n })\n\n return {\n state,\n /** Points located diagnostics into the config's input when it is a local file. */\n setSpec(config: Config) {\n const input = getInputPath(config)\n if (input && config.adapter?.locate && getInputKind(input) === 'file') {\n const path = resolve(config.root, input)\n // Read lazily, once, and only when a diagnostic needs a frame.\n let source: Promise<string | undefined> | undefined\n state.spec = {\n path,\n adapter: config.adapter,\n get source() {\n return (source ??= read(path).catch(() => undefined))\n },\n }\n }\n },\n /** Prints the problems held back so far. */\n flush() {\n return writeProblems(state.problems.splice(0))\n },\n /** `✖ Failed 1 error · 1 warning in plugin-ts` once the build ended, or `✗ Generation failed` for a run that stopped early. */\n failedTitle(): string {\n const { errors, warnings } = Diagnostics.count(state.diagnostics)\n const counts = [errors && pluralize(errors, 'error'), warnings && pluralize(warnings, 'warning')].filter(Boolean).join(' · ')\n if (!human || !counts) {\n return '✗ Generation failed'\n }\n const plugins = Diagnostics.failedPlugins(state.diagnostics)\n return `✖ Failed ${counts}${plugins.length ? ` in ${plugins.join(', ')}` : ''}`\n },\n reset() {\n Object.assign(state, { problems: [], diagnostics: [], spec: undefined })\n },\n }\n}\n","import { relative } from 'node:path'\nimport { styleText } from 'node:util'\nimport { logLevel as logLevelMap } from '@kubb/core'\nimport { pluralize } from '../../ui/text.ts'\nimport type { WriterProgress } from '../types.ts'\nimport type { LoggerContext } from './context.ts'\nimport type { Spinner } from './spinner.ts'\n\nexport type Progress = ReturnType<typeof createProgress>\n\n/** The progress bar over the file writes, and the counts the summary line shows. */\nexport function createProgress({ writer, silent, human, logLevel, text, onRun }: LoggerContext, spinner: Spinner) {\n // Plain output prints every advance as its own line, so it names each file only at the verbose level.\n const nameFiles = human || logLevel >= logLevelMap.verbose\n const state = {\n progress: null as WriterProgress | null,\n totalFiles: 0,\n processedFiles: 0,\n /** Whether this run keeps its files in memory, as a `kubb studio` run without `--allow-write` does. */\n inMemory: false,\n }\n\n function stop(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 if (!silent) {\n onRun('kubb:files:processing:start', ({ files }) => {\n spinner.stop()\n state.totalFiles = files.length\n state.processedFiles = 0\n\n state.progress = writer.progress(files.length)\n state.progress.start(text(`${state.inMemory ? 'Generating' : 'Writing'} ${pluralize(files.length, 'file')}`))\n })\n\n onRun('kubb:files:processing:update', ({ files }) => {\n for (const { file, config } of files) {\n state.processedFiles++\n if (nameFiles) state.progress?.advance(`${state.inMemory ? 'Generating' : 'Writing'} ${relative(config.root, file.path)}`)\n }\n })\n\n onRun('kubb:files:processing:end', ({ files, unchanged }) => {\n const skipped = unchanged.length ? styleText('dim', ` · ${unchanged.length} unchanged`) : ''\n stop(\n state.inMemory\n ? `Generated ${pluralize(state.processedFiles, 'file')} in memory`\n : `Wrote ${pluralize(files.length - unchanged.length, 'file')}${skipped}`,\n )\n })\n }\n\n return {\n state,\n stop,\n reset() {\n stop()\n Object.assign(state, { totalFiles: 0, processedFiles: 0, inMemory: false })\n },\n }\n}\n","import process from 'node:process'\nimport { styleText } from 'node:util'\nimport { formatMs, getElapsedMs } from '@internals/utils'\nimport { Diagnostics, logLevel as logLevelMap } from '@kubb/core'\nimport { pluralize, toPermissionFlag } from '../../ui/text.ts'\nimport { clock, type LoggerContext } from './context.ts'\nimport type { Spinner } from './spinner.ts'\n\n/** One line of a Studio session's job log: the time, the command, who asked for it, and how it ended. */\nfunction formatJobLine({ command, result, requestedBy }: { command: string; result: string; requestedBy?: string }): string {\n const by = requestedBy ? `${styleText('dim', `by ${requestedBy}`.padEnd(16))} ` : ''\n return `${styleText('dim', clock())} ${command.padEnd(10)} ${by}${result}`\n}\n\n/**\n * A `kubb studio` session. It emits these on the same emitter as its generations, so one logger\n * renders the whole command: the connection, then one job line per command.\n */\nexport function createSession(ctx: LoggerContext, spinner: Spinner) {\n const { writer, silent, human, logLevel, text, hooks } = ctx\n\n hooks.hook('studio:disconnected', ({ code, reason }) => {\n if (logLevel < logLevelMap.warn) {\n return\n }\n\n spinner.stop()\n // 4002 is `AgentCloseCode.SUPERSEDED`, spelled out because `@kubb/studio` is an optional peer.\n if (code === 4002) {\n writer.warn(text('⚠ Another process connected to Kubb Studio as this agent, so this one stopped'))\n return\n }\n writer.warn(text(`⚠ Kubb Studio ended the session (${reason || `code ${code}`})`))\n })\n\n hooks.hook('studio:warn', ({ message, permission }) => {\n if (logLevel < logLevelMap.warn) {\n return\n }\n const remedy = permission ? `; pass ${toPermissionFlag(permission)} to allow it` : ''\n // A warning drawn under a running spinner leaves a stale spinner frame above it, so it pauses the spinner like a job line does.\n const paused = spinner.active\n spinner.stop()\n writer.warn(text(`⚠ ${message}${remedy}`))\n if (paused) spinner.start('Ready for jobs')\n })\n\n // Unguarded, like `kubb:error`: a failure stays visible even at silent.\n hooks.hook('studio:error', ({ error }) => {\n if (spinner.active) {\n spinner.stop(error.message, 'failed')\n return\n }\n writer.error(text(error.message))\n })\n\n if (silent) {\n return\n }\n\n // The last generation's outcome, for the job line `studio:command` prints after it.\n let job: { fileCount: number; ms: number; errors: number } | null = null\n\n hooks.hook('studio:connected', ({ url, versions: { studio, kubb, agent } }) => {\n ctx.session = human\n spinner.stop()\n // The runtime version shows only when it differs from the host's.\n const versions = [`v${agent}`, kubb !== agent ? `runtime v${kubb}` : undefined, `Studio v${studio}`].filter(Boolean).join(' · ')\n writer.success(text(`✓ Connected to ${styleText('cyan', url)} ${styleText('dim', `· ${versions}`)}`))\n spinner.start('Ready for jobs')\n })\n\n hooks.hook('kubb:generation:start', () => {\n if (ctx.session) spinner.message(text('Generating'))\n })\n\n hooks.hook('kubb:generation:end', ({ diagnostics = [], filesCreated = 0, status, hrStart = process.hrtime() }) => {\n job = { fileCount: filesCreated, ms: getElapsedMs(hrStart), errors: status === 'failed' ? Diagnostics.count(diagnostics).errors : 0 }\n })\n\n hooks.hook('studio:command', ({ command, info, requestedBy, failed }) => {\n spinner.stop()\n const took = command === 'generate' && job ? `${pluralize(job.fileCount, 'file')} in ${formatMs(job.ms)} ` : ''\n const result = failed\n ? `${styleText('red', '✖')} ${job?.errors ? pluralize(job.errors, 'error') : 'failed'}, see Studio`\n : `${styleText('green', '✓')} ${took}${styleText('dim', `(${info})`)}`\n writer.info(formatJobLine({ command, requestedBy, result }))\n job = null\n spinner.start('Ready for jobs')\n })\n\n hooks.hook('studio:reconnecting', ({ delayMs }) => {\n spinner.stop()\n writer.info(text(styleText('dim', `Retrying connection to Kubb Studio in ${formatMs(delayMs)}`)))\n })\n}\n","import type { LogStatus, WriterSpinner } from '../types.ts'\nimport type { LoggerContext } from './context.ts'\n\nexport type Spinner = ReturnType<typeof createSpinner>\n\n/** The step whose end is not known when it starts: the spec parse, the node walk, a phase, or a Studio session waiting for jobs. */\nexport function createSpinner({ writer, silent, text }: LoggerContext) {\n let spinner: WriterSpinner | null = null\n\n function stop(message?: string, status: LogStatus = 'success') {\n const active = spinner\n if (!active) {\n return\n }\n spinner = null\n\n if (message === undefined) {\n active.clear()\n return\n }\n if (status === 'failed') {\n active.error(text(message))\n return\n }\n active.stop(text(message))\n }\n\n return {\n /** Whether a spinner is drawing right now. */\n get active(): boolean {\n return spinner !== null\n },\n start(message: string) {\n if (silent) {\n return\n }\n\n spinner = writer.spinner()\n spinner.start(text(message))\n },\n stop,\n /** Redraws the spinner's line. `false` when no spinner is running, so the caller prints the line itself. */\n message(line: string): boolean {\n if (!spinner) {\n return false\n }\n spinner.message(line)\n return true\n },\n reset: () => stop(),\n }\n}\n","import process from 'node:process'\nimport { styleText } from 'node:util'\nimport { formatMs, getElapsedMs } from '@internals/utils'\nimport { formatBar, formatMsWithColor } from '../banner.ts'\nimport { pluralize } from '../../ui/text.ts'\nimport type { LoggerContext } from './context.ts'\nimport type { Progress } from './progress.ts'\nimport type { Spinner } from './spinner.ts'\n\nexport type Walk = ReturnType<typeof createWalk>\n\n/** Milliseconds between redraws of the live generation block, about clack's spinner frame rate. */\nconst WALK_REDRAW_MS = 80\n\nfunction createState() {\n return {\n totalPlugins: 0,\n completedPlugins: 0,\n failedPlugins: 0,\n /** `process.hrtime()` snapshot taken at the start of generation, for the elapsed time. */\n hrStart: process.hrtime(),\n /** Plugin results held back while the generation step owns the line. */\n pluginLines: [] as Array<string>,\n /** The node walk's live state: the spec's node total, the distinct nodes generated, and each plugin's count and current node. */\n walk: { total: 0, visited: new Set<string>(), plugins: new Map<string, { count: number; current: string }>() },\n lastWalkDraw: 0,\n }\n}\n\n/** The node walk the plugins share: the live generation block, and the plugin results printed once the walk ends. */\nexport function createWalk({ writer, silent, human, text, onRun }: LoggerContext, spinner: Spinner, progress: Progress) {\n const state = createState()\n\n /** The progress summary line the clack logger shows, `null` when there is nothing to display. */\n function buildProgressLine(): string | null {\n const parts: Array<string> = []\n const duration = formatMs(getElapsedMs(state.hrStart))\n const { totalFiles, processedFiles } = progress.state\n\n if (state.totalPlugins > 0) {\n const failed = state.failedPlugins > 0 ? ` ${styleText('red', `(${state.failedPlugins} failed)`)}` : ''\n parts.push(`Plugins ${styleText('green', state.completedPlugins.toString())}/${state.totalPlugins}${failed}`)\n }\n\n if (totalFiles > 0) {\n parts.push(`Files ${styleText('green', processedFiles.toString())}/${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 if (!silent) {\n onRun('kubb:build:start', ({ nodeCounts: { schemas, operations } }) => {\n state.walk.total = schemas + operations\n const details = `${pluralize(schemas, 'schema')} · ${pluralize(operations, 'operation')} · ${formatMs(getElapsedMs(state.hrStart))}`\n spinner.stop(`Parsed spec ${styleText('dim', details)}`)\n spinner.start('Generating')\n })\n\n // Plugins all end after one shared node walk, so per-node hooks keep the step live; plain output would get a line per node.\n if (human) {\n const onNode = (key: string, name: string, plugin: string) => {\n const { total, visited, plugins } = state.walk\n visited.add(key)\n plugins.set(plugin, { count: (plugins.get(plugin)?.count ?? 0) + 1, current: name })\n\n // Counting stays per node; the redraw waits for the spinner's next frame.\n const now = Date.now()\n if (now - state.lastWalkDraw < WALK_REDRAW_MS) return\n state.lastWalkDraw = now\n\n const elapsed = styleText('dim', formatMs(getElapsedMs(state.hrStart)))\n const head = total\n ? `Generating ${formatBar(visited.size, total)} ${visited.size}/${total} nodes ${elapsed}`\n : `Generating ${pluralize(visited.size, 'node')} ${elapsed}`\n const width = Math.max(...[...plugins.keys()].map((pluginName) => pluginName.length))\n const rows = [...plugins].map(\n ([pluginName, row]) =>\n `${styleText('dim', '│')} ${pluginName.padEnd(width)} ${styleText('dim', String(row.count).padStart(4))} ${styleText('cyan', row.current)}`,\n )\n spinner.message(text([head, ...rows].join('\\n')))\n }\n\n onRun('kubb:generate:schema', (node, { plugin }) => onNode(`schema:${node.name}`, node.name ?? 'schema', plugin.name))\n onRun('kubb:generate:operation', (node, { plugin }) => onNode(`operation:${node.operationId}`, node.operationId, plugin.name))\n }\n\n // Buffered, not printed: a step redraws over anything written while it runs.\n onRun('kubb:plugin:end', ({ plugin, duration, success }) => {\n state[success ? 'completedPlugins' : 'failedPlugins']++\n state.pluginLines.push(text(`${plugin.name} ${success ? 'completed' : 'failed'} in ${formatMsWithColor(duration)}`))\n })\n\n onRun('kubb:plugins:end', () => {\n const failed = state.failedPlugins > 0\n spinner.stop(buildProgressLine() ?? undefined, failed ? 'failed' : 'success')\n\n if (state.pluginLines.length) {\n writer.block(state.pluginLines)\n state.pluginLines = []\n }\n })\n }\n\n return {\n state,\n reset() {\n Object.assign(state, createState())\n },\n }\n}\n","import type { Hookable, KubbHooks, SummaryRenderer } from '@kubb/core'\nimport type { LoggerWriter } from '../types.ts'\nimport { createLoggerContext } from './context.ts'\nimport { createGeneration } from './generation.ts'\nimport { createPhases } from './phases.ts'\nimport { createProblems } from './problems.ts'\nimport { createProgress } from './progress.ts'\nimport { createSession } from './session.ts'\nimport { createSpinner } from './spinner.ts'\nimport { createWalk } from './walk.ts'\n\n/**\n * Wires a {@link LoggerWriter} onto the run's hooks. Each feature registers the hooks for one\n * concern, so every writer reports the same run in the same order: one group per config, a step\n * over the plugin work, a progress bar for the writes, one step per output phase, then the summary.\n * It hands back `renderSummary`, which writes the `cli` reporter's summary inside the group opened\n * for that config and closes the group.\n */\nexport function installLogger({ hooks, writer, logLevel }: { hooks: Hookable<KubbHooks>; writer: LoggerWriter; logLevel: number }): {\n renderSummary: SummaryRenderer\n} {\n const ctx = createLoggerContext({ hooks, writer, logLevel })\n const spinner = createSpinner(ctx)\n const progress = createProgress(ctx, spinner)\n const walk = createWalk(ctx, spinner, progress)\n const phases = createPhases(ctx, spinner)\n const problems = createProblems(ctx, spinner, progress, phases)\n createSession(ctx, spinner)\n return createGeneration(ctx, { spinner, progress, walk, phases, problems })\n}\n","import { hash } from 'node:crypto'\nimport { readFileSync } from 'node:fs'\nimport { readdir } from 'node:fs/promises'\nimport { join, relative } from 'node:path'\nimport process from 'node:process'\nimport { styleText } from 'node:util'\nimport { inParallel, matchesStored, read } from '@internals/utils'\nimport type { Hookable, KubbHooks, OutputManifest, Storage } from '@kubb/core'\n\n/** Glob pattern for paths the file watcher ignores. */\nconst WATCHER_IGNORED_PATHS = '**/{.git,node_modules}/**' as const\n\n/**\n * Quiet window in milliseconds that collapses a burst of watcher events (an editor save emits several) into one rebuild.\n * It outlasts chokidar's 100 ms atomic-save window, which holds back the event of a write-then-rename save.\n */\nconst WATCHER_DEBOUNCE_MS = 250\n\n/** `14:02:11 petStore.yaml changed`, the line a watcher prints when its input changes. */\nexport function formatChange({ target, removed = false, now = new Date() }: { target: string; removed?: boolean; now?: Date }): string {\n return `${styleText('dim', now.toTimeString().slice(0, 8))} ${styleText('bold', target)} ${removed ? 'removed' : 'changed'}`\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 call. `cb` must never reject: its result is not awaited, so the caller\n * serializes and reports its own builds. Resolves to a function that stops watching.\n */\nexport async function startWatcher(\n path: Array<string>,\n cb: (path: Array<string>) => Promise<void>,\n log: WatcherLog = { info: console.log, error: console.log },\n): Promise<() => Promise<void>> {\n const { watch } = await import('chokidar')\n // `ignoreInitial` skips the `add` events chokidar fires for existing files at startup, which\n // would otherwise rebuild right after the initial run.\n const watcher = watch(path, { ignorePermissionErrors: true, ignored: WATCHER_IGNORED_PATHS, ignoreInitial: true })\n\n for (const signal of ['SIGINT', 'SIGTERM'] as const) {\n process.once(signal, () => void watcher.close())\n }\n\n let debounceTimer: ReturnType<typeof setTimeout> | null = null\n\n watcher.on('all', (type, file) => {\n log.info(formatChange({ target: relative(process.cwd(), file), removed: type === 'unlink' }))\n if (debounceTimer) clearTimeout(debounceTimer)\n debounceTimer = setTimeout(() => {\n debounceTimer = null\n void cb(path)\n }, WATCHER_DEBOUNCE_MS)\n })\n\n return async () => {\n if (debounceTimer) clearTimeout(debounceTimer)\n await watcher.close()\n }\n}\n\n/**\n * What one build produced: the schema and operation names the plugins generated.\n */\nexport type BuildSnapshot = {\n schemas: Set<string>\n operations: Set<string>\n}\n\nfunction createSnapshot(): BuildSnapshot {\n return { schemas: new Set(), operations: new Set() }\n}\n\n/**\n * Collects a {@link BuildSnapshot} from the hooks while a build runs. `take` hands back the finished\n * build's snapshot and starts the next one.\n */\nexport function trackBuild(hooks: Hookable<KubbHooks>): { take(): BuildSnapshot } {\n let current = createSnapshot()\n\n hooks.hook('kubb:generate:schema', (node) => {\n if (node.name) current.schemas.add(node.name)\n })\n hooks.hook('kubb:generate:operation', (node) => {\n current.operations.add(node.operationId)\n })\n\n return {\n take() {\n const snapshot = current\n current = createSnapshot()\n return snapshot\n },\n }\n}\n\ntype NameChange = { added: number; removed: number }\n\n/**\n * How a rebuild differs from the build before it: the spec's added and removed schemas and operations.\n */\nexport type BuildDiff = {\n schemas: NameChange\n operations: NameChange\n}\n\nfunction diffNames(previous: Set<string>, next: Set<string>): NameChange {\n return { added: [...next].filter((name) => !previous.has(name)).length, removed: [...previous].filter((name) => !next.has(name)).length }\n}\n\n/**\n * Compares two {@link BuildSnapshot}s by name.\n */\nexport function diffBuilds(previous: BuildSnapshot, next: BuildSnapshot): BuildDiff {\n return {\n schemas: diffNames(previous.schemas, next.schemas),\n operations: diffNames(previous.operations, next.operations),\n }\n}\n\n/** A changed file with how many lines it gains and loses, counted as a multiset, which is cheap and close enough for a plan. */\nexport type FileChange = { status: 'A' | 'M' | 'D'; path: string; added?: number; removed?: number }\n\ntype Lines = Iterable<string | number>\n\nfunction splitLines(text: string): Array<string> {\n return text ? text.split('\\n') : []\n}\n\n// A loop, not a spread into an array of characters: this runs over every line of the old output on each clean run.\nfunction hashLine(line: string): number {\n let hash = 0x811c9dc5\n for (const char of line) hash = Math.imul(hash ^ char.codePointAt(0)!, 0x01000193)\n return hash\n}\n\nfunction hashLines(text: string): Int32Array {\n return Int32Array.from(splitLines(text), hashLine)\n}\n\nfunction countLineChanges({ before, after }: { before: Lines; after: Lines }): { added: number; removed: number } {\n const remaining = new Map<string | number, number>()\n for (const line of before) remaining.set(line, (remaining.get(line) ?? 0) + 1)\n const added = [...after].filter((line) => {\n const count = remaining.get(line) ?? 0\n if (count === 0) return true\n remaining.set(line, count - 1)\n return false\n }).length\n const removed = [...remaining.values()].reduce((sum, count) => sum + count, 0)\n return { added, removed }\n}\n\n/**\n * Reads the output before generation, so cleaning the directory cannot erase the diff baseline.\n * A missing directory or an unreadable file is skipped. This keeps every file's text for the whole\n * run, so only a dry run and a run with output passes use it: they compare against the output read\n * back at the end.\n */\nexport async function readOutputFiles(outputPath: string): Promise<Map<string, string>> {\n const entries = await readdir(outputPath, { recursive: true, withFileTypes: true }).catch(() => [])\n const files = new Map<string, string>()\n await inParallel({\n items: entries.filter((entry) => entry.isFile()).map((entry) => join(entry.parentPath, entry.name)),\n limit: 50,\n run: async (filePath) => {\n const source = await read(filePath).catch(() => null)\n if (source !== null) files.set(filePath, source)\n },\n })\n return files\n}\n\n/**\n * Hashes of a file `output.clean` deleted, enough to tell whether its regenerated copy changed and by how many lines.\n */\nexport type FileFingerprint = {\n length: number\n digest: string\n lines: Int32Array\n deletedLines: number\n}\n\nexport function fingerprintFile(text: string): FileFingerprint {\n const body = text.trimEnd()\n const trimmed = body.trimStart()\n // A deleted file also counts the blank lines above its first line, which trimming drops.\n const leading = body.slice(0, body.length - trimmed.length).split('\\n').length - 1\n const lines = hashLines(trimmed)\n\n return { length: trimmed.length, digest: hash('sha1', trimmed), lines, deletedLines: body ? lines.length + leading : 0 }\n}\n\n/**\n * Fingerprints every file under the output folder right before `output.clean` empties it, one file at a time, so the\n * old tree is never held in memory. A missing directory or an unreadable file is skipped.\n */\nexport async function readOutputFingerprints(outputPath: string): Promise<Map<string, FileFingerprint>> {\n const entries = await readdir(outputPath, { recursive: true, withFileTypes: true }).catch(() => [])\n const fingerprints = new Map<string, FileFingerprint>()\n for (const entry of entries) {\n if (!entry.isFile()) continue\n const filePath = join(entry.parentPath, entry.name)\n try {\n // Synchronous on purpose: one read at a time is several times faster here than a pool of `fs.promises` reads.\n fingerprints.set(filePath, fingerprintFile(readFileSync(filePath, 'utf8')))\n } catch {\n /* unreadable, so it cannot be compared */\n }\n }\n return fingerprints\n}\n\n/**\n * How one generated file differs from its copy before generation: `undefined` when both hold the\n * same output, otherwise the change with its line counts. `previous` is the stored text, the\n * {@link FileFingerprint} of a file `output.clean` deleted, or `null` for a new file. The manifest\n * recognizes output a formatter rewrote.\n */\nexport function diffFile({\n path,\n next,\n previous,\n manifest,\n}: {\n path: string\n next: string\n previous: string | FileFingerprint | null\n manifest?: Pick<OutputManifest, 'isUpToDate'>\n}): FileChange | undefined {\n if (previous === null) return { status: 'A', path, added: splitLines(next.trimEnd()).length, removed: 0 }\n if (typeof previous !== 'string') {\n const trimmed = next.trim()\n if (trimmed.length === previous.length && hash('sha1', trimmed) === previous.digest) return undefined\n return { status: 'M', path, ...countLineChanges({ before: previous.lines, after: hashLines(trimmed) }) }\n }\n if (matchesStored({ stored: previous, source: next }) || manifest?.isUpToDate({ key: path, source: next, disk: previous })) return undefined\n return { status: 'M', path, ...countLineChanges({ before: splitLines(previous.trim()), after: splitLines(next.trim()) }) }\n}\n\n/**\n * The totals the summary prints, plus the files that came out the same.\n */\nexport type ChangeTally = { added: number; modified: number; deleted: number; linesAdded: number; linesRemoved: number; unchanged: number }\n\nconst statusKeys = { A: 'added', M: 'modified', D: 'deleted' } as const\n\n/**\n * Adds one file's outcome to the totals: a {@link FileChange}, or `undefined` for an unchanged file.\n */\nexport function tallyChange({ tally, change }: { tally: ChangeTally; change: FileChange | undefined }): void {\n if (!change) {\n tally.unchanged++\n return\n }\n tally[statusKeys[change.status]]++\n tally.linesAdded += change.added ?? 0\n tally.linesRemoved += change.removed ?? 0\n}\n\nexport function createChangeTally(): ChangeTally {\n return { added: 0, modified: 0, deleted: 0, linesAdded: 0, linesRemoved: 0, unchanged: 0 }\n}\n\n/**\n * Compares generated output with the files captured before generation. The manifest recognizes\n * output rewritten by a formatter, and `clean` includes files the run would delete.\n */\nexport async function diffOutput({\n storage,\n paths,\n clean,\n manifest,\n previousFiles,\n}: {\n storage: Storage\n paths: ReadonlySet<string>\n clean: boolean\n manifest?: Pick<OutputManifest, 'isUpToDate'>\n /**\n * The output captured before a real run, including files removed by cleaning.\n */\n previousFiles: ReadonlyMap<string, string>\n}): Promise<{ files: Array<FileChange>; unchanged: number }> {\n // `null` marks an unchanged file. A path the storage does not hold leaves a hole, which `filter` skips.\n const results: Array<FileChange | null> = []\n await inParallel({\n items: [...paths],\n limit: 50,\n run: async (filePath, index) => {\n const next = await storage.readItem(filePath)\n if (next === null) return\n results[index] = diffFile({ path: filePath, next, previous: previousFiles.get(filePath) ?? null, manifest }) ?? null\n },\n })\n const files = results.filter((result) => result !== null)\n const unchanged = results.filter((result) => result === null).length\n if (clean) {\n for (const [filePath, source] of previousFiles) {\n if (!paths.has(filePath)) files.push({ status: 'D', path: filePath, added: 0, removed: splitLines(source.trimEnd()).length })\n }\n }\n\n return { files, unchanged }\n}\n\ntype KeyInput = Pick<NodeJS.ReadStream, 'isTTY' | 'setRawMode' | 'resume' | 'pause' | 'setEncoding' | 'on'>\n\ntype KeyOptions = {\n rebuild: () => void\n /**\n * Ends the process with this exit code: `0` for `q`, `130` for ctrl+c, which raw mode turns into a key.\n */\n quit: (code: number) => void\n input?: KeyInput\n}\n\n/**\n * Reads `r` (rebuild) and `q` (quit) from an interactive stdin in raw mode, and keeps ctrl+c\n * working. Returns `undefined` when stdin is not a TTY. Otherwise returns `arm`, which turns raw\n * mode back on: a spinner restores the terminal when it stops, so call it after each build. Raw mode\n * is restored on exit.\n */\nexport function listenForKeys({ rebuild, quit, input = process.stdin }: KeyOptions): (() => void) | undefined {\n if (!input.isTTY) return undefined\n\n const arm = () => {\n input.setRawMode(true)\n input.resume()\n }\n input.setEncoding('utf8')\n input.on('data', (data: string) => {\n const key = data.trim()\n if (key === 'r') {\n rebuild()\n return\n }\n if (key === 'q' || data === '\\u0003') {\n input.setRawMode(false)\n input.pause()\n quit(key === 'q' ? 0 : 130)\n }\n })\n process.once('exit', () => input.setRawMode(false))\n arm()\n\n return arm\n}\n","import process from 'node:process'\nimport { resolve } from 'node:path'\nimport { readFile } from 'node:fs/promises'\nimport { isPathInside, memo } from '@internals/utils'\nimport type { GenerationResult, Hookable, KubbGenerationEndContext, KubbHooks, Reporter, ReporterContext } from '@kubb/core'\nimport { cacheStorage, createCliReporter, createOutputManifest, hasOutputPasses, logLevel as logLevelMap } from '@kubb/core'\nimport { writer as defaultWriter } from '../ui/log.ts'\nimport { installLogger } from './features/index.ts'\nimport type { LoggerWriter } from './types.ts'\nimport {\n type ChangeTally,\n createChangeTally,\n diffFile,\n diffOutput,\n type FileFingerprint,\n readOutputFiles,\n readOutputFingerprints,\n tallyChange,\n} from '../runners/generate/utils.ts'\n\ntype LiveChanges = {\n tally: ChangeTally\n // The files `output.clean` is about to delete, the only trace of them once the folder is emptied.\n fingerprints: Map<string, FileFingerprint>\n processed: Set<string>\n}\n\ntype GenerationRun = {\n outputPath: string\n filesUnchanged: number\n paths: Set<string>\n // Read-back runs only: the whole output as it was before generation.\n previous?: Map<string, string>\n reading?: Promise<Map<string, string>>\n // A run without output passes counts each file as it is written, against the stored text the write already read.\n live?: LiveChanges\n}\n\n/** Installs the live logger and wires the selected reporters. `cli` renders its summary through the logger, and is skipped when `json` owns stdout. */\nfunction setupReporters(\n context: Hookable<KubbHooks>,\n {\n logLevel,\n reporters,\n writer = defaultWriter(),\n dryRun = false,\n fileChanges = false,\n }: {\n /** Output verbosity. Use the `logLevel` constants exported from `@kubb/core`. */\n logLevel: number\n reporters: ReadonlyArray<Reporter>\n /** Overrides the terminal-based pick, e.g. the plain writer for `kubb studio snapshot`. */\n writer?: LoggerWriter\n /**\n * Labels the memory-backed generation as a preview rather than a completed write.\n */\n dryRun?: boolean\n /**\n * Hands `fileChanges` to every reporter, not only `cli`.\n */\n fileChanges?: boolean\n },\n): void {\n const hasJson = reporters.some((reporter) => reporter.name === 'json')\n const selected = reporters.flatMap((reporter) => {\n if (reporter.name !== 'cli') return [reporter]\n if (hasJson) return []\n return [createCliReporter({ render: installLogger({ hooks: context, writer, logLevel }).renderSummary })]\n })\n const ctx: ReporterContext = { logLevel }\n const pluginFiles = selected.some((reporter) => reporter.needsPluginFiles) ? memo.create<string, Array<string>>() : undefined\n const seen = new Set<string>()\n if (pluginFiles) {\n context.hook('kubb:plugin:end', ({ plugin, files }) => {\n for (const file of files) {\n if (seen.has(file.path)) continue\n seen.add(file.path)\n memo(pluginFiles, plugin.name, () => []).push(file.path)\n }\n })\n }\n\n // Configs generate one at a time, so the last write before `kubb:generation:end` is this config's.\n let run: GenerationRun | undefined\n const trackChanges = (fileChanges || selected.some((reporter) => reporter.name === 'cli')) && logLevel > logLevelMap.silent\n context.hook('kubb:generation:start', ({ config }) => {\n pluginFiles?.clear()\n seen.clear()\n const outputPath = resolve(config.root, config.output.path)\n const tracked = trackChanges && (dryRun || config.storage?.name === 'fs')\n const live = ((): LiveChanges | undefined => {\n // Output passes rewrite stored files and a dry run compares through the manifest, so both read the output back.\n if (!tracked || dryRun || hasOutputPasses(config)) return undefined\n return { tally: createChangeTally(), fingerprints: new Map(), processed: new Set() }\n })()\n run = {\n outputPath,\n filesUnchanged: 0,\n paths: new Set(),\n live,\n // Read while the plugins generate; `kubb:plugins:end` waits for it, before cleaning can erase the baseline.\n reading: tracked && !live ? readOutputFiles(outputPath) : undefined,\n }\n })\n context.hook('kubb:plugins:end', async ({ config }) => {\n if (!run) return\n if (run.reading) run.previous = await run.reading\n // The last moment the old files exist: the storage empties the folder right after this hook.\n if (run.live && config.output.clean) run.live.fingerprints = await readOutputFingerprints(run.outputPath)\n })\n context.hook('kubb:files:processing:start', async ({ files }) => {\n if (!run?.previous) return\n const { previous, outputPath } = run\n // Plugin output can live outside the main output folder; capture it before writes start.\n for (const file of files) {\n if (previous.has(file.path) || isPathInside(outputPath, file.path)) continue\n const source = await readFile(file.path, 'utf8').catch(() => null)\n if (source !== null) previous.set(file.path, source)\n }\n })\n context.hook('kubb:file:processed', ({ file, source, stored = null }) => {\n const live = run?.live\n if (!live) return\n // The storage writes the trimmed source and skips a blank one, which leaves the stored file as it was.\n const next = source.trim()\n if (!next) return\n live.processed.add(file.path)\n tallyChange({ tally: live.tally, change: diffFile({ path: file.path, next, previous: stored ?? live.fingerprints.get(file.path) ?? null }) })\n })\n context.hook('kubb:files:processing:end', ({ files, unchanged }) => {\n if (!run) return\n run.filesUnchanged = unchanged.length\n run.paths = new Set(files.map((file) => file.path))\n })\n\n /** The run's totals: counted while writing, or worked out by reading the output back. */\n async function countChanges({\n config,\n storage,\n current,\n }: Pick<KubbGenerationEndContext, 'config' | 'storage'> & { current: GenerationRun }): Promise<ChangeTally | undefined> {\n const { live, paths, previous } = current\n if (live) {\n const { tally, fingerprints, processed } = live\n for (const [filePath, fingerprint] of fingerprints) {\n if (!paths.has(filePath)) tallyChange({ tally, change: { status: 'D', path: filePath, removed: fingerprint.deletedLines } })\n }\n // A blank file left whatever the storage held in place, so a stored copy counts as unchanged.\n for (const filePath of paths.difference(processed)) {\n if ((await storage.readItem(filePath)) !== null) tally.unchanged++\n }\n return tally\n }\n if (!previous) return undefined\n const manifest = dryRun ? await createOutputManifest({ storage, cache: cacheStorage({ root: config.root }) }) : undefined\n const diff = await diffOutput({ storage, paths, clean: Boolean(config.output.clean), manifest, previousFiles: previous })\n const changes = createChangeTally()\n changes.unchanged = diff.unchanged\n for (const file of diff.files) tallyChange({ tally: changes, change: file })\n return changes\n }\n\n context.hook('kubb:generation:end', async ({ config, storage, diagnostics = [], filesCreated = 0, status = 'success', hrStart = process.hrtime() }) => {\n const current = run\n run = undefined\n const result: GenerationResult = { config, diagnostics, filesCreated, filesUnchanged: current?.filesUnchanged ?? 0, dryRun, status, hrStart }\n const cliResult = { ...result }\n const counted = current && status !== 'failed' ? await countChanges({ config, storage, current }) : undefined\n if (counted) {\n const { unchanged, ...changes } = counted\n cliResult.filesCreated = changes.added + changes.modified + unchanged\n cliResult.filesUnchanged = unchanged\n cliResult.fileChanges = changes\n }\n for (const reporter of selected) {\n const grouped = reporter.needsPluginFiles && pluginFiles?.size ? [...pluginFiles].map(([plugin, files]) => ({ plugin, files: [...files] })) : undefined\n await reporter.report({ ...(reporter.name === 'cli' || fileChanges ? cliResult : result), pluginFiles: grouped }, ctx)\n }\n })\n\n context.hook('kubb:lifecycle:end', async () => {\n for (const reporter of selected) await reporter.drain?.(ctx)\n })\n}\n\nexport default setupReporters\n\n/** Picks the reporters whose `name` is in `names`, in the given order (the CLI maps `--reporter` to this); duplicates and unknown names are skipped. */\nexport function selectReporters(reporters: ReadonlyArray<Reporter>, names: ReadonlyArray<string>): Array<Reporter> {\n return [...new Set(names)].flatMap((name) => reporters.find((reporter) => reporter.name === name) ?? [])\n}\n"],"mappings":";;;;;;;;;;;;;;;AA0BA,SAAgB,oBAAoB,EAAE,OAAO,QAAQ,YAAmG;CACtJ,MAAM,QAAQ,YAAqB,YAAYA,WAAAA,SAAY,UAAU,IAAA,GAAGC,UAAAA,UAAAA,CAAU,OAAO,IAAI,MAAM,EAAE,EAAE,EAAE,GAAG,YAAY;CACxH,MAAM,MAAqB;EACzB;EACA;EACA;EACA,QAAQ,YAAYD,WAAAA,SAAY;EAChC,OAAO,OAAO,aAAa;EAC3B,SAAS;EACT,WAAW;EACX;EACA,OAAO,QAAQ,SAAS,SAAS,KAAK;GAAC;GAAQ;GAAS,SAAA,GAAQC,UAAAA,UAAAA,CAAU,OAAO,IAAI;EAAC,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,CAAC;EACjH,MAAM,MAAM,IAAI;GACd,OAAO,MAAM,KAAK,OAAO,GAAG,SAAU,IAAI,UAAU,KAAA,IAAY,GAAG,GAAG,IAAI,CAAE;EAC9E;CACF;CACA,OAAO;AACT;;AAGA,SAAgB,MAAM,uBAAO,IAAI,KAAK,GAAW;CAC/C,OAAO,KAAK,mBAAmB,SAAS;EAAE,QAAQ;EAAO,MAAM;EAAW,QAAQ;EAAW,QAAQ;CAAU,CAAC;AAClH;;AAGA,SAAgB,aAAa,QAAoC;CAC/D,MAAM,EAAE,UAAU;CAClB,IAAI,OAAO,UAAU,UAAU,OAAO;CACtC,OAAO,OAAO,OAAO,SAAS,WAAW,MAAM,OAAO,KAAA;AACxD;;;;;;ACzCA,SAAgB,iBACd,KACA,EAAE,SAAS,UAAU,MAAM,QAAQ,YACC;CACpC,MAAM,EAAE,QAAQ,QAAQ,OAAO,MAAM,OAAO,UAAU;CAEtD,SAAS,QAAQ;EACf,QAAQ,MAAM;EACd,SAAS,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B,YAAY;EAC7C,KAAK,MAAM,YAAY,UAAU,MAAM,SAAS,QAAQ,GAAG;CAC7D,CAAC;AACH;;AAKA,SAAgB,gBAAgB,WAAoC,OAA+C;CACjH,OAAO,CAAC,GAAG,IAAI,IAAI,KAAK,CAAC,CAAC,CAAC,SAAS,SAAS,UAAU,MAAM,aAAa,SAAS,SAAS,IAAI,KAAK,CAAC,CAAC;AACzG"}
@@ -1,6 +1,6 @@
1
1
  const require_rolldown_runtime = require("./rolldown-runtime-BV8xUvPy.cjs");
2
2
  const require_errors = require("./errors-Bewwe8mY.cjs");
3
- const require_Telemetry = require("./Telemetry-Dg805qAM.cjs");
3
+ const require_Telemetry = require("./Telemetry-JW5aPuIg.cjs");
4
4
  let node_util = require("node:util");
5
5
  let node_process = require("node:process");
6
6
  node_process = require_rolldown_runtime.__toESM(node_process, 1);
@@ -29,4 +29,4 @@ async function run() {
29
29
  }
30
30
  exports.run = run;
31
31
 
32
- //# sourceMappingURL=run-BL_-t-RX.cjs.map
32
+ //# sourceMappingURL=run-BGrgzLo2.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"run-BL_-t-RX.cjs","names":["trackRun","process","styleText","toError"],"sources":["../src/runners/mcp/run.ts"],"sourcesContent":["import process from 'node:process'\nimport { styleText } from 'node:util'\nimport { toError } from '@internals/utils'\nimport type * as McpModule from '@kubb/mcp'\nimport { trackRun } from '../../Telemetry.ts'\n\n/**\n * Starts the `@kubb/mcp` server over stdio and reports the outcome to telemetry.\n */\nexport async function run(): Promise<void> {\n const { run: startMcpServer } = (await import('@kubb/mcp')) as typeof McpModule\n\n const report = trackRun({ command: 'mcp', hrStart: process.hrtime() })\n\n try {\n // The MCP stdio transport owns stdout: anything else written there corrupts the JSON-RPC stream.\n console.error(styleText('cyan', '⏳ Starting MCP server...'))\n console.warn(styleText('yellow', 'This feature is still under development, use with caution'))\n const server = startMcpServer()\n // Report once the client introduces itself, so the event names the client (e.g. `claude-code`, `cursor-vscode`).\n server.on('initialize', ({ clientInfo }) => void report({ status: 'success', mcpClient: clientInfo.name }), { once: true })\n } catch (error) {\n await report({ status: 'failed' })\n console.error(toError(error).message)\n process.exitCode = 1\n }\n}\n"],"mappings":";;;;;;;;;;AASA,eAAsB,MAAqB;CACzC,MAAM,EAAE,KAAK,mBAAoB,MAAM,OAAO;CAE9C,MAAM,SAASA,kBAAAA,SAAS;EAAE,SAAS;EAAO,SAASC,aAAAA,QAAQ,OAAO;CAAE,CAAC;CAErE,IAAI;EAEF,QAAQ,OAAA,GAAMC,UAAAA,UAAAA,CAAU,QAAQ,0BAA0B,CAAC;EAC3D,QAAQ,MAAA,GAAKA,UAAAA,UAAAA,CAAU,UAAU,2DAA2D,CAAC;EAG7F,eAAK,CAAC,CAAC,GAAG,eAAe,EAAE,iBAAiB,KAAK,OAAO;GAAE,QAAQ;GAAW,WAAW,WAAW;EAAK,CAAC,GAAG,EAAE,MAAM,KAAK,CAAC;CAC5H,SAAS,OAAO;EACd,MAAM,OAAO,EAAE,QAAQ,SAAS,CAAC;EACjC,QAAQ,MAAMC,eAAAA,QAAQ,KAAK,CAAC,CAAC,OAAO;EACpC,aAAA,QAAA,WAAmB;CACrB;AACF"}
1
+ {"version":3,"file":"run-BGrgzLo2.cjs","names":["trackRun","process","styleText","toError"],"sources":["../src/runners/mcp/run.ts"],"sourcesContent":["import process from 'node:process'\nimport { styleText } from 'node:util'\nimport { toError } from '@internals/utils'\nimport type * as McpModule from '@kubb/mcp'\nimport { trackRun } from '../../Telemetry.ts'\n\n/**\n * Starts the `@kubb/mcp` server over stdio and reports the outcome to telemetry.\n */\nexport async function run(): Promise<void> {\n const { run: startMcpServer } = (await import('@kubb/mcp')) as typeof McpModule\n\n const report = trackRun({ command: 'mcp', hrStart: process.hrtime() })\n\n try {\n // The MCP stdio transport owns stdout: anything else written there corrupts the JSON-RPC stream.\n console.error(styleText('cyan', '⏳ Starting MCP server...'))\n console.warn(styleText('yellow', 'This feature is still under development, use with caution'))\n const server = startMcpServer()\n // Report once the client introduces itself, so the event names the client (e.g. `claude-code`, `cursor-vscode`).\n server.on('initialize', ({ clientInfo }) => void report({ status: 'success', mcpClient: clientInfo.name }), { once: true })\n } catch (error) {\n await report({ status: 'failed' })\n console.error(toError(error).message)\n process.exitCode = 1\n }\n}\n"],"mappings":";;;;;;;;;;AASA,eAAsB,MAAqB;CACzC,MAAM,EAAE,KAAK,mBAAoB,MAAM,OAAO;CAE9C,MAAM,SAASA,kBAAAA,SAAS;EAAE,SAAS;EAAO,SAASC,aAAAA,QAAQ,OAAO;CAAE,CAAC;CAErE,IAAI;EAEF,QAAQ,OAAA,GAAMC,UAAAA,UAAAA,CAAU,QAAQ,0BAA0B,CAAC;EAC3D,QAAQ,MAAA,GAAKA,UAAAA,UAAAA,CAAU,UAAU,2DAA2D,CAAC;EAC9E,eAEV,CAAC,CAAC,GAAG,eAAe,EAAE,iBAAiB,KAAK,OAAO;GAAE,QAAQ;GAAW,WAAW,WAAW;EAAK,CAAC,GAAG,EAAE,MAAM,KAAK,CAAC;CAC5H,SAAS,OAAO;EACd,MAAM,OAAO,EAAE,QAAQ,SAAS,CAAC;EACjC,QAAQ,MAAMC,eAAAA,QAAQ,KAAK,CAAC,CAAC,OAAO;EACpC,aAAA,QAAA,WAAmB;CACrB;AACF"}
@@ -1,7 +1,7 @@
1
1
  import "./rolldown-runtime-BowF1xt-.js";
2
2
  import { n as getElapsedMs, t as formatMs } from "./time-D7ONPPZf.js";
3
- import { t as version } from "./package-C2zS-roY.js";
4
- import { n as trackRun } from "./Telemetry-B35TOnPl.js";
3
+ import { t as version } from "./package-BoMS1AZ6.js";
4
+ import { n as trackRun } from "./Telemetry-BhTLEYwh.js";
5
5
  import { n as pluralize } from "./text-HYWAcipy.js";
6
6
  import { a as startWatcher, i as listenForKeys, n as setupReporters, o as trackBuild, r as diffBuilds, t as selectReporters } from "./reporters-B6p0n7s3.js";
7
7
  import { a as logWarn, i as logStep, n as logError, r as logInfo, s as createPlainWriter } from "./log-B_uVM704.js";
@@ -288,4 +288,4 @@ async function run({ input, configPath, logLevel: logLevelKey, watch: watchMode,
288
288
  }
289
289
  export { generate, run };
290
290
 
291
- //# sourceMappingURL=run-CfYOu60_.js.map
291
+ //# sourceMappingURL=run-Bl3rprW8.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"run-CfYOu60_.js","names":["delay","logLevel","logLevelMap"],"sources":["../src/utils/updateCheck.ts","../src/runners/generate/run.ts"],"sourcesContent":["import { isCIEnvironment } from '@internals/utils'\nimport { kubbStorage } from '@kubb/core'\nimport { isValid } from 'verkit'\n\n/** NPM registry endpoint used to check for @kubb/cli updates. */\nconst KUBB_NPM_PACKAGE_URL = 'https://registry.npmjs.org/@kubb/cli/latest' as const\n\n/** Upper bound in milliseconds for the npm update check, so a slow registry never stalls a run. */\nconst UPDATE_CHECK_TIMEOUT_MS = 3_000\n\n/** How long a stored registry answer stays fresh. */\nexport const UPDATE_CHECK_INTERVAL_MS = 24 * 60 * 60 * 1_000\n\nconst STORE_KEY = 'update-check.json'\n\ntype StoredCheck = {\n version: string\n checkedAt: number\n}\n\nfunction isStoredCheck(value: unknown): value is StoredCheck {\n const check = value as Partial<StoredCheck> | null\n return typeof check?.version === 'string' && isValid(check.version) && typeof check.checkedAt === 'number'\n}\n\n// A timestamp in the future, from a clock set back, counts as stale so it cannot hide updates.\nfunction isFresh(checkedAt: number): boolean {\n const age = Date.now() - checkedAt\n return age >= 0 && age < UPDATE_CHECK_INTERVAL_MS\n}\n\n/** The latest published version, `undefined` when the registry does not answer in time or `signal` aborts. Never rejects. */\nasync function fetchLatestVersion(signal: AbortSignal): Promise<string | undefined> {\n try {\n const res = await fetch(KUBB_NPM_PACKAGE_URL, { signal: AbortSignal.any([signal, AbortSignal.timeout(UPDATE_CHECK_TIMEOUT_MS)]) })\n if (!res.ok) return undefined\n const data = (await res.json()) as { version?: unknown }\n return typeof data.version === 'string' && isValid(data.version) ? data.version : undefined\n } catch {\n return undefined\n }\n}\n\n/**\n * The latest published `@kubb/cli` version for the update notice. Skipped in CI. Asks npm at most once per\n * {@link UPDATE_CHECK_INTERVAL_MS} and keeps the answer in `~/.kubb/cache` (or `KUBB_HOME`).\n * Resolves `undefined` when there is nothing to show. Never rejects.\n */\nexport async function getLatestVersion(signal: AbortSignal): Promise<string | undefined> {\n if (isCIEnvironment()) return undefined\n\n const storage = (() => {\n try {\n return kubbStorage({ base: 'cache' })\n } catch {\n return undefined\n }\n })()\n const stored = await storage?.getItem(STORE_KEY).catch(() => null)\n if (isStoredCheck(stored) && isFresh(stored.checkedAt)) return stored.version\n\n const latest = await fetchLatestVersion(signal)\n if (latest) await storage?.setItem(STORE_KEY, { version: latest, checkedAt: Date.now() }).catch(() => undefined)\n return latest\n}\n","import path from 'node:path'\nimport process from 'node:process'\nimport { setTimeout as delay } from 'node:timers/promises'\nimport { styleText } from 'node:util'\nimport { formatMs, formatters, getElapsedMs, linters } from '@internals/utils'\nimport {\n Hookable,\n type CLIOptions,\n cliReporter,\n type Config,\n Diagnostics,\n fileReporter,\n getInputKind,\n htmlReporter,\n jsonReporter,\n Kubb,\n type KubbHooks,\n logLevel as logLevelMap,\n memoryStorage,\n type ReporterName,\n} from '@kubb/core'\nimport { version } from '../../../package.json'\nimport { trackRun } from '../../Telemetry.ts'\nimport { pluralize } from '../../ui/text.ts'\nimport setupReporters, { selectReporters } from '../../loggers/reporters.ts'\nimport { createPlainWriter } from '../../loggers/plainWriter.ts'\nimport { logIntro, logOutro, logSpacer, logTip } from '../../ui/intro.ts'\nimport { logError, logInfo, logStep, logWarn } from '../../ui/log.ts'\nimport { logBanner } from '../../ui/mascot.ts'\nimport { createSpinner } from '../../ui/spinner.ts'\nimport { getConfigs } from '../../config.ts'\nimport { isOutdated } from '../../utils/registry.ts'\nimport { getLatestVersion } from '../../utils/updateCheck.ts'\nimport { type BuildDiff, type BuildSnapshot, diffBuilds, listenForKeys, startWatcher, trackBuild } from './utils.ts'\n\n/** The formatter names from `Config['output'].format`, without `'auto'` (detection, not a tool) and `false` (skip). */\ntype FormatterName = Exclude<NonNullable<Config['output']['format']>, 'auto' | false>\ntype LinterName = Exclude<NonNullable<Config['output']['lint']>, 'auto' | false>\n\n// Pinned here, not in `@internals/utils` (which must not import `@kubb/core`): a tool added to the union without a descriptor fails to compile.\nformatters satisfies Record<FormatterName, unknown>\nlinters satisfies Record<LinterName, unknown>\n\nfunction toRunConfig({ config, input, dryRun }: { config: Config; input?: string; dryRun: boolean }): Config {\n return {\n ...config,\n input: input ?? config.input,\n // Dry-run never touches disk, regardless of the config's own storage driver.\n storage: dryRun ? memoryStorage() : config.storage,\n // Also keeps core's `hasOutputPasses` false, so dry-run skips the output manifest write too.\n output: dryRun ? { ...config.output, format: false, lint: false, postGenerate: [] } : config.output,\n }\n}\n\ntype GenerateProps = {\n configs: Array<Config>\n hooks: Hookable<KubbHooks>\n}\n\n/**\n * Generates the configs and returns whether every build succeeded.\n */\nexport async function generate({ configs, hooks }: GenerateProps): Promise<boolean> {\n // Not awaited: a detached process sends each request, so it never delays the summary or the exit.\n const untrack = hooks.hook('kubb:generation:end', ({ config, filesCreated = 0, status = 'success', hrStart = process.hrtime() }) => {\n void trackRun({ command: 'generate', hrStart })({\n plugins: config.plugins.flatMap((p) =>\n p && typeof p === 'object' ? [{ name: p.meta?.name ?? p.name ?? '', options: (p.options ?? {}) as Record<string, unknown> }] : [],\n ),\n filesCreated,\n status,\n })\n })\n let succeeded = true\n try {\n for await (const { success, error } of Kubb.generate(configs, { hooks })) {\n if (error) await Diagnostics.emit(hooks, error)\n succeeded &&= success\n }\n } finally {\n untrack()\n }\n return succeeded\n}\n\ntype GenerateCommandOptions = {\n input?: string\n configPath?: string\n logLevel: string\n watch: boolean\n reporters?: Array<ReporterName>\n dryRun?: boolean\n}\n\n/** Upper bound in milliseconds for the update check's cache read or write once generation is done. */\nconst UPDATE_WAIT_MS = 1_000\n\n/** `promise`'s value, or `undefined` when it takes longer than `ms`. */\nfunction withTimeout<T>({ promise, ms }: { promise: Promise<T>; ms: number }): Promise<T | undefined> {\n const timer = new AbortController()\n const timeout = delay(ms, undefined, { signal: timer.signal }).catch(() => undefined)\n return Promise.race([promise, timeout]).finally(() => timer.abort())\n}\n\nasync function checkForUpdate({ hooks, latestVersion }: { hooks: Hookable<KubbHooks>; latestVersion: string | undefined }): Promise<void> {\n if (latestVersion && isOutdated({ installed: version, latest: latestVersion })) {\n await Diagnostics.emit(hooks, Diagnostics.update({ currentVersion: version, latestVersion }))\n }\n}\n\n/** Prints `Rebuilt in 1.2s · +1 schema -2 operations`, without the names part when the spec kept the same names. */\nfunction logRebuild({ diff: { schemas, operations }, durationMs }: { diff: BuildDiff; durationMs: number }): void {\n const specChange = [\n schemas.added && styleText('green', `+${pluralize(schemas.added, 'schema')}`),\n schemas.removed && styleText('red', `-${pluralize(schemas.removed, 'schema')}`),\n operations.added && styleText('green', `+${pluralize(operations.added, 'operation')}`),\n operations.removed && styleText('red', `-${pluralize(operations.removed, 'operation')}`),\n ]\n .filter(Boolean)\n .join(' ')\n logStep([`Rebuilt in ${formatMs(durationMs)}`, specChange].filter(Boolean).join(styleText('dim', ' · ')))\n}\n\n/**\n * Generates the configs, then again whenever a local `input` file changes. Returns whether the build succeeded when there is no file to watch.\n */\nasync function watch({ configs, hooks, quiet }: GenerateProps & { quiet: boolean }): Promise<boolean> {\n const watchPaths = [...new Set(configs.flatMap(({ input }) => (typeof input === 'string' && getInputKind(input) === 'file' ? [input] : [])))]\n if (!watchPaths.length) {\n if (!quiet) logWarn('Watch mode only follows a local `input` file, so the configs are generated once.')\n return generate({ configs, hooks })\n }\n\n const label = styleText('yellow', `Watching ${watchPaths.map((watchPath) => path.relative(process.cwd(), watchPath)).join(', ')}`)\n const tracker = trackBuild(hooks)\n let previous: BuildSnapshot | undefined\n // Don't removeAll() between builds, that would also drop logger and lifecycle\n // listeners. Plugin listeners are already disposed by safeBuild's dispose()\n // in its finally block, so re-running generate() on the same hooks emitter is safe.\n const build = async () => {\n const hrStart = process.hrtime()\n // Every config builds again, since an edited spec can change what the configs share.\n const succeeded = await generate({ configs, hooks })\n const snapshot = tracker.take()\n if (previous) logRebuild({ diff: diffBuilds(previous, snapshot), durationMs: getElapsedMs(hrStart) })\n previous = snapshot\n\n logStep(armKeys ? `${label} ${styleText('dim', 'r rebuild · q quit')}` : label)\n armKeys?.()\n if (succeeded) {\n logSpacer()\n logTip()\n }\n }\n // A trigger that lands while a build is queued joins it. One that lands during the build queues one more. Never rejects.\n let queue = Promise.resolve()\n let pending = false\n const rebuild = (): Promise<void> => {\n if (pending) return queue\n pending = true\n queue = queue\n .then(() => {\n pending = false\n return build()\n })\n .catch((error) => void Diagnostics.emit(hooks, error))\n return queue\n }\n const armKeys = quiet\n ? undefined\n : listenForKeys({\n rebuild: () => void rebuild(),\n quit: (code) => void Promise.resolve(hooks.callHook('kubb:lifecycle:end')).finally(() => process.exit(code)),\n })\n\n // The watcher ignores its startup state, so run the first build here. A failing one keeps watching so the user can fix the input.\n await rebuild()\n await startWatcher(watchPaths, rebuild, { info: logInfo, error: logError })\n return true\n}\n\n/**\n * Runs the full Kubb generation lifecycle for the given CLI options.\n * Loads configs, sets up the reporters (CLI `--reporter` picks which of `config.reporters` to trigger),\n * calls `generate` for each config entry, and prints an update notice when a newer version is known.\n */\nexport async function run({\n input,\n configPath,\n logLevel: logLevelKey,\n watch: watchMode,\n reporters: cliReporters,\n dryRun,\n}: GenerateCommandOptions): Promise<void> {\n // Started first: the notice prints at the end only when the stored answer or the registry is there by then.\n const updateCheck = new AbortController()\n const latestVersion = getLatestVersion(updateCheck.signal)\n const logLevel = logLevelMap[logLevelKey as keyof typeof logLevelMap] ?? logLevelMap.info\n const hooks = new Hookable<KubbHooks>()\n\n // CLI `--reporter` selects which reporters to trigger by name, defaulting to `cli`. `defineConfig`\n // registers the built-in reporters on the config; a config exported without it falls back to them below.\n const requestedNames: Array<ReporterName> = cliReporters?.length ? cliReporters : ['cli']\n\n // The `json` reporter owns stdout, so the command writes nothing of its own around it.\n const json = requestedNames.includes('json')\n const quiet = logLevel <= logLevelMap.silent || json\n\n // The run log goes to stderr in `json` mode, so an error with no report entry is never silent and stdout stays one JSON document.\n if (json) setupReporters(hooks, { logLevel, reporters: [cliReporter], writer: createPlainWriter(console.error) })\n\n // The config loads while the banner plays. Once it settles the banner jumps to its last frame, so\n // the build starts right away and no frame lands between log lines.\n const bannerCut = new AbortController()\n const banner = quiet ? undefined : logBanner({ version, signal: bannerCut.signal })\n const loading = getConfigs({\n configPath,\n input,\n watch: watchMode,\n logLevel: logLevelKey as CLIOptions['logLevel'],\n reporters: cliReporters,\n })\n // A rejection is handled below; this also keeps it from counting as unhandled during the banner.\n void loading.then(\n () => bannerCut.abort(),\n () => bannerCut.abort(),\n )\n await banner\n\n if (!quiet) {\n logIntro({ title: 'Configuration' })\n }\n\n // Load the config first so `config.reporters` can pick the reporters. A failure here has no\n // reporter installed yet, so fall back to the default `cli` reporter to surface it.\n const configSpinner = createSpinner()\n let configs: Array<Config>\n let resolvedConfigPath: string\n try {\n if (!quiet) configSpinner.start('Loading config')\n\n const loaded = await loading\n configs = loaded.configs\n resolvedConfigPath = loaded.configPath\n\n if (!quiet) configSpinner.stop(`Loaded ${styleText('dim', path.relative(process.cwd(), resolvedConfigPath))}`)\n } catch (error) {\n if (!quiet) configSpinner.error('Config failed loading')\n\n if (!json) setupReporters(hooks, { logLevel, reporters: [cliReporter] })\n // A diagnostic thrown while the config file runs, such as invalid extension options, sits in the cause chain.\n await Diagnostics.emit(hooks, error)\n\n if (!quiet) logOutro(styleText('red', '✗ Configuration failed'))\n process.exit(1)\n }\n\n // Without a reporter nothing is printed, not even an error, so a config written without\n // `defineConfig` gets the same built-ins it would have registered.\n const available = configs[0]?.reporters?.length ? configs[0].reporters : [cliReporter, jsonReporter, fileReporter, htmlReporter]\n const reporters = selectReporters(available, requestedNames)\n setupReporters(hooks, { logLevel, reporters, dryRun })\n\n await hooks.callHook('kubb:lifecycle:start', { version })\n\n const runConfigs = configs.map((config) => toRunConfig({ config, input, dryRun: dryRun ?? false }))\n\n if (!quiet) logOutro(`${pluralize(configs.length, 'config')} ready`)\n\n try {\n // One config that fails does not stop the others.\n const succeeded = await (watchMode ? watch({ configs: runConfigs, hooks, quiet }) : generate({ configs: runConfigs, hooks }))\n\n // Aborting settles a request in flight at once; the timeout covers a cache read or write on a stalled disk.\n updateCheck.abort()\n await checkForUpdate({ hooks, latestVersion: await withTimeout({ promise: latestVersion, ms: UPDATE_WAIT_MS }) })\n\n await hooks.callHook('kubb:lifecycle:end')\n\n // Watch mode prints a tip after each successful build. Regular generate commands need to\n // print one explicitly after the lifecycle group has closed so it stays outside the group.\n if (!quiet && !watchMode && succeeded) {\n logTip()\n }\n\n // `exitCode`, not `exit()`, so the payload piped to the telemetry process is flushed first.\n if (!succeeded) {\n process.exitCode = 1\n }\n } catch (error) {\n await Diagnostics.emit(hooks, error)\n process.exit(1)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAKA,MAAM,uBAAuB;;AAG7B,MAAM,0BAA0B;AAKhC,MAAM,YAAY;AAOlB,SAAS,cAAc,OAAsC;CAC3D,MAAM,QAAQ;CACd,OAAO,OAAO,OAAO,YAAY,YAAY,QAAQ,MAAM,OAAO,KAAK,OAAO,MAAM,cAAc;AACpG;AAGA,SAAS,QAAQ,WAA4B;CAC3C,MAAM,MAAM,KAAK,IAAI,IAAI;CACzB,OAAO,OAAO,KAAK,MAAA;AACrB;;AAGA,eAAe,mBAAmB,QAAkD;CAClF,IAAI;EACF,MAAM,MAAM,MAAM,MAAM,sBAAsB,EAAE,QAAQ,YAAY,IAAI,CAAC,QAAQ,YAAY,QAAQ,uBAAuB,CAAC,CAAC,EAAE,CAAC;EACjI,IAAI,CAAC,IAAI,IAAI,OAAO,KAAA;EACpB,MAAM,OAAQ,MAAM,IAAI,KAAK;EAC7B,OAAO,OAAO,KAAK,YAAY,YAAY,QAAQ,KAAK,OAAO,IAAI,KAAK,UAAU,KAAA;CACpF,QAAQ;EACN;CACF;AAC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C,MAAM,eAAe,OAAO;GAAE,UAAA;GAAU,WAAW,CAAC,WAAW;EAAE,CAAC;EAEvE,MAAM,YAAY,KAAK,OAAO,KAAK;EAEnC,IAAI,CAAC,OAAO,SAAS,UAAU,OAAO,wBAAwB,CAAC;EAC/D,QAAQ,KAAK,CAAC;CAChB;CAIA,MAAM,YAAY,QAAQ,EAAE,EAAE,WAAW,SAAS,QAAQ,EAAE,CAAC,YAAY;EAAC;EAAa;EAAc;EAAc;CAAY;CAC/H,MAAM,YAAY,gBAAgB,WAAW,cAAc;CAC3D,eAAe,OAAO;EAAE,UAAA;EAAU;EAAW;CAAO,CAAC;CAErD,MAAM,MAAM,SAAS,wBAAwB,EAAE,QAAQ,CAAC;CAExD,MAAM,aAAa,QAAQ,KAAK,WAAW,YAAY;EAAE;EAAQ;EAAO,QAAQ,UAAU;CAAM,CAAC,CAAC;CAElG,IAAI,CAAC,OAAO,SAAS,GAAG,UAAU,QAAQ,QAAQ,QAAQ,EAAE,OAAO;CAEnE,IAAI;EAEF,MAAM,YAAY,OAAO,YAAY,MAAM;GAAE,SAAS;GAAY;GAAO;EAAM,CAAC,IAAI,SAAS;GAAE,SAAS;GAAY;EAAM,CAAC;EAG3H,YAAY,MAAM;EAClB,MAAM,eAAe;GAAE;GAAO,eAAe,MAAM,YAAY;IAAE,SAAS;IAAe,IAAI;GAAe,CAAC;EAAE,CAAC;EAEhH,MAAM,MAAM,SAAS,oBAAoB;EAIzC,IAAI,CAAC,SAAS,CAAC,aAAa,WAC1B,OAAO;EAIT,IAAI,CAAC,WACH,QAAQ,WAAW;CAEvB,SAAS,OAAO;EACd,MAAM,YAAY,KAAK,OAAO,KAAK;EACnC,QAAQ,KAAK,CAAC;CAChB;AACF"}
1
+ {"version":3,"file":"run-Bl3rprW8.js","names":["delay","logLevel","logLevelMap"],"sources":["../src/utils/updateCheck.ts","../src/runners/generate/run.ts"],"sourcesContent":["import { isCIEnvironment } from '@internals/utils'\nimport { kubbStorage } from '@kubb/core'\nimport { isValid } from 'verkit'\n\n/** NPM registry endpoint used to check for @kubb/cli updates. */\nconst KUBB_NPM_PACKAGE_URL = 'https://registry.npmjs.org/@kubb/cli/latest' as const\n\n/** Upper bound in milliseconds for the npm update check, so a slow registry never stalls a run. */\nconst UPDATE_CHECK_TIMEOUT_MS = 3_000\n\n/** How long a stored registry answer stays fresh. */\nexport const UPDATE_CHECK_INTERVAL_MS = 24 * 60 * 60 * 1_000\n\nconst STORE_KEY = 'update-check.json'\n\ntype StoredCheck = {\n version: string\n checkedAt: number\n}\n\nfunction isStoredCheck(value: unknown): value is StoredCheck {\n const check = value as Partial<StoredCheck> | null\n return typeof check?.version === 'string' && isValid(check.version) && typeof check.checkedAt === 'number'\n}\n\n// A timestamp in the future, from a clock set back, counts as stale so it cannot hide updates.\nfunction isFresh(checkedAt: number): boolean {\n const age = Date.now() - checkedAt\n return age >= 0 && age < UPDATE_CHECK_INTERVAL_MS\n}\n\n/** The latest published version, `undefined` when the registry does not answer in time or `signal` aborts. Never rejects. */\nasync function fetchLatestVersion(signal: AbortSignal): Promise<string | undefined> {\n try {\n const res = await fetch(KUBB_NPM_PACKAGE_URL, { signal: AbortSignal.any([signal, AbortSignal.timeout(UPDATE_CHECK_TIMEOUT_MS)]) })\n if (!res.ok) return undefined\n const data = (await res.json()) as { version?: unknown }\n return typeof data.version === 'string' && isValid(data.version) ? data.version : undefined\n } catch {\n return undefined\n }\n}\n\n/**\n * The latest published `@kubb/cli` version for the update notice. Skipped in CI. Asks npm at most once per\n * {@link UPDATE_CHECK_INTERVAL_MS} and keeps the answer in `~/.kubb/cache` (or `KUBB_HOME`).\n * Resolves `undefined` when there is nothing to show. Never rejects.\n */\nexport async function getLatestVersion(signal: AbortSignal): Promise<string | undefined> {\n if (isCIEnvironment()) return undefined\n\n const storage = (() => {\n try {\n return kubbStorage({ base: 'cache' })\n } catch {\n return undefined\n }\n })()\n const stored = await storage?.getItem(STORE_KEY).catch(() => null)\n if (isStoredCheck(stored) && isFresh(stored.checkedAt)) return stored.version\n\n const latest = await fetchLatestVersion(signal)\n if (latest) await storage?.setItem(STORE_KEY, { version: latest, checkedAt: Date.now() }).catch(() => undefined)\n return latest\n}\n","import path from 'node:path'\nimport process from 'node:process'\nimport { setTimeout as delay } from 'node:timers/promises'\nimport { styleText } from 'node:util'\nimport { formatMs, formatters, getElapsedMs, linters } from '@internals/utils'\nimport {\n Hookable,\n type CLIOptions,\n cliReporter,\n type Config,\n Diagnostics,\n fileReporter,\n getInputKind,\n htmlReporter,\n jsonReporter,\n Kubb,\n type KubbHooks,\n logLevel as logLevelMap,\n memoryStorage,\n type ReporterName,\n} from '@kubb/core'\nimport { version } from '../../../package.json'\nimport { trackRun } from '../../Telemetry.ts'\nimport { pluralize } from '../../ui/text.ts'\nimport setupReporters, { selectReporters } from '../../loggers/reporters.ts'\nimport { createPlainWriter } from '../../loggers/plainWriter.ts'\nimport { logIntro, logOutro, logSpacer, logTip } from '../../ui/intro.ts'\nimport { logError, logInfo, logStep, logWarn } from '../../ui/log.ts'\nimport { logBanner } from '../../ui/mascot.ts'\nimport { createSpinner } from '../../ui/spinner.ts'\nimport { getConfigs } from '../../config.ts'\nimport { isOutdated } from '../../utils/registry.ts'\nimport { getLatestVersion } from '../../utils/updateCheck.ts'\nimport { type BuildDiff, type BuildSnapshot, diffBuilds, listenForKeys, startWatcher, trackBuild } from './utils.ts'\n\n/** The formatter names from `Config['output'].format`, without `'auto'` (detection, not a tool) and `false` (skip). */\ntype FormatterName = Exclude<NonNullable<Config['output']['format']>, 'auto' | false>\ntype LinterName = Exclude<NonNullable<Config['output']['lint']>, 'auto' | false>\n\n// Pinned here, not in `@internals/utils` (which must not import `@kubb/core`): a tool added to the union without a descriptor fails to compile.\nformatters satisfies Record<FormatterName, unknown>\nlinters satisfies Record<LinterName, unknown>\n\nfunction toRunConfig({ config, input, dryRun }: { config: Config; input?: string; dryRun: boolean }): Config {\n return {\n ...config,\n input: input ?? config.input,\n // Dry-run never touches disk, regardless of the config's own storage driver.\n storage: dryRun ? memoryStorage() : config.storage,\n // Also keeps core's `hasOutputPasses` false, so dry-run skips the output manifest write too.\n output: dryRun ? { ...config.output, format: false, lint: false, postGenerate: [] } : config.output,\n }\n}\n\ntype GenerateProps = {\n configs: Array<Config>\n hooks: Hookable<KubbHooks>\n}\n\n/**\n * Generates the configs and returns whether every build succeeded.\n */\nexport async function generate({ configs, hooks }: GenerateProps): Promise<boolean> {\n // Not awaited: a detached process sends each request, so it never delays the summary or the exit.\n const untrack = hooks.hook('kubb:generation:end', ({ config, filesCreated = 0, status = 'success', hrStart = process.hrtime() }) => {\n void trackRun({ command: 'generate', hrStart })({\n plugins: config.plugins.flatMap((p) =>\n p && typeof p === 'object' ? [{ name: p.meta?.name ?? p.name ?? '', options: (p.options ?? {}) as Record<string, unknown> }] : [],\n ),\n filesCreated,\n status,\n })\n })\n let succeeded = true\n try {\n for await (const { success, error } of Kubb.generate(configs, { hooks })) {\n if (error) await Diagnostics.emit(hooks, error)\n succeeded &&= success\n }\n } finally {\n untrack()\n }\n return succeeded\n}\n\ntype GenerateCommandOptions = {\n input?: string\n configPath?: string\n logLevel: string\n watch: boolean\n reporters?: Array<ReporterName>\n dryRun?: boolean\n}\n\n/** Upper bound in milliseconds for the update check's cache read or write once generation is done. */\nconst UPDATE_WAIT_MS = 1_000\n\n/** `promise`'s value, or `undefined` when it takes longer than `ms`. */\nfunction withTimeout<T>({ promise, ms }: { promise: Promise<T>; ms: number }): Promise<T | undefined> {\n const timer = new AbortController()\n const timeout = delay(ms, undefined, { signal: timer.signal }).catch(() => undefined)\n return Promise.race([promise, timeout]).finally(() => timer.abort())\n}\n\nasync function checkForUpdate({ hooks, latestVersion }: { hooks: Hookable<KubbHooks>; latestVersion: string | undefined }): Promise<void> {\n if (latestVersion && isOutdated({ installed: version, latest: latestVersion })) {\n await Diagnostics.emit(hooks, Diagnostics.update({ currentVersion: version, latestVersion }))\n }\n}\n\n/** Prints `Rebuilt in 1.2s · +1 schema -2 operations`, without the names part when the spec kept the same names. */\nfunction logRebuild({ diff: { schemas, operations }, durationMs }: { diff: BuildDiff; durationMs: number }): void {\n const specChange = [\n schemas.added && styleText('green', `+${pluralize(schemas.added, 'schema')}`),\n schemas.removed && styleText('red', `-${pluralize(schemas.removed, 'schema')}`),\n operations.added && styleText('green', `+${pluralize(operations.added, 'operation')}`),\n operations.removed && styleText('red', `-${pluralize(operations.removed, 'operation')}`),\n ]\n .filter(Boolean)\n .join(' ')\n logStep([`Rebuilt in ${formatMs(durationMs)}`, specChange].filter(Boolean).join(styleText('dim', ' · ')))\n}\n\n/**\n * Generates the configs, then again whenever a local `input` file changes. Returns whether the build succeeded when there is no file to watch.\n */\nasync function watch({ configs, hooks, quiet }: GenerateProps & { quiet: boolean }): Promise<boolean> {\n const watchPaths = [...new Set(configs.flatMap(({ input }) => (typeof input === 'string' && getInputKind(input) === 'file' ? [input] : [])))]\n if (!watchPaths.length) {\n if (!quiet) logWarn('Watch mode only follows a local `input` file, so the configs are generated once.')\n return generate({ configs, hooks })\n }\n\n const label = styleText('yellow', `Watching ${watchPaths.map((watchPath) => path.relative(process.cwd(), watchPath)).join(', ')}`)\n const tracker = trackBuild(hooks)\n let previous: BuildSnapshot | undefined\n // Don't removeAll() between builds, that would also drop logger and lifecycle\n // listeners. Plugin listeners are already disposed by safeBuild's dispose()\n // in its finally block, so re-running generate() on the same hooks emitter is safe.\n const build = async () => {\n const hrStart = process.hrtime()\n // Every config builds again, since an edited spec can change what the configs share.\n const succeeded = await generate({ configs, hooks })\n const snapshot = tracker.take()\n if (previous) logRebuild({ diff: diffBuilds(previous, snapshot), durationMs: getElapsedMs(hrStart) })\n previous = snapshot\n\n logStep(armKeys ? `${label} ${styleText('dim', 'r rebuild · q quit')}` : label)\n armKeys?.()\n if (succeeded) {\n logSpacer()\n logTip()\n }\n }\n // A trigger that lands while a build is queued joins it. One that lands during the build queues one more. Never rejects.\n let queue = Promise.resolve()\n let pending = false\n const rebuild = (): Promise<void> => {\n if (pending) return queue\n pending = true\n queue = queue\n .then(() => {\n pending = false\n return build()\n })\n .catch((error) => void Diagnostics.emit(hooks, error))\n return queue\n }\n const armKeys = quiet\n ? undefined\n : listenForKeys({\n rebuild: () => void rebuild(),\n quit: (code) => void Promise.resolve(hooks.callHook('kubb:lifecycle:end')).finally(() => process.exit(code)),\n })\n\n // The watcher ignores its startup state, so run the first build here. A failing one keeps watching so the user can fix the input.\n await rebuild()\n await startWatcher(watchPaths, rebuild, { info: logInfo, error: logError })\n return true\n}\n\n/**\n * Runs the full Kubb generation lifecycle for the given CLI options.\n * Loads configs, sets up the reporters (CLI `--reporter` picks which of `config.reporters` to trigger),\n * calls `generate` for each config entry, and prints an update notice when a newer version is known.\n */\nexport async function run({\n input,\n configPath,\n logLevel: logLevelKey,\n watch: watchMode,\n reporters: cliReporters,\n dryRun,\n}: GenerateCommandOptions): Promise<void> {\n // Started first: the notice prints at the end only when the stored answer or the registry is there by then.\n const updateCheck = new AbortController()\n const latestVersion = getLatestVersion(updateCheck.signal)\n const logLevel = logLevelMap[logLevelKey as keyof typeof logLevelMap] ?? logLevelMap.info\n const hooks = new Hookable<KubbHooks>()\n\n // CLI `--reporter` selects which reporters to trigger by name, defaulting to `cli`. `defineConfig`\n // registers the built-in reporters on the config; a config exported without it falls back to them below.\n const requestedNames: Array<ReporterName> = cliReporters?.length ? cliReporters : ['cli']\n\n // The `json` reporter owns stdout, so the command writes nothing of its own around it.\n const json = requestedNames.includes('json')\n const quiet = logLevel <= logLevelMap.silent || json\n\n // The run log goes to stderr in `json` mode, so an error with no report entry is never silent and stdout stays one JSON document.\n if (json) setupReporters(hooks, { logLevel, reporters: [cliReporter], writer: createPlainWriter(console.error) })\n\n // The config loads while the banner plays. Once it settles the banner jumps to its last frame, so\n // the build starts right away and no frame lands between log lines.\n const bannerCut = new AbortController()\n const banner = quiet ? undefined : logBanner({ version, signal: bannerCut.signal })\n const loading = getConfigs({\n configPath,\n input,\n watch: watchMode,\n logLevel: logLevelKey as CLIOptions['logLevel'],\n reporters: cliReporters,\n })\n // A rejection is handled below; this also keeps it from counting as unhandled during the banner.\n void loading.then(\n () => bannerCut.abort(),\n () => bannerCut.abort(),\n )\n await banner\n\n if (!quiet) {\n logIntro({ title: 'Configuration' })\n }\n\n // Load the config first so `config.reporters` can pick the reporters. A failure here has no\n // reporter installed yet, so fall back to the default `cli` reporter to surface it.\n const configSpinner = createSpinner()\n let configs: Array<Config>\n let resolvedConfigPath: string\n try {\n if (!quiet) configSpinner.start('Loading config')\n\n const loaded = await loading\n configs = loaded.configs\n resolvedConfigPath = loaded.configPath\n\n if (!quiet) configSpinner.stop(`Loaded ${styleText('dim', path.relative(process.cwd(), resolvedConfigPath))}`)\n } catch (error) {\n if (!quiet) configSpinner.error('Config failed loading')\n\n if (!json) setupReporters(hooks, { logLevel, reporters: [cliReporter] })\n // A diagnostic thrown while the config file runs, such as invalid extension options, sits in the cause chain.\n await Diagnostics.emit(hooks, error)\n\n if (!quiet) logOutro(styleText('red', '✗ Configuration failed'))\n process.exit(1)\n }\n\n // Without a reporter nothing is printed, not even an error, so a config written without\n // `defineConfig` gets the same built-ins it would have registered.\n const available = configs[0]?.reporters?.length ? configs[0].reporters : [cliReporter, jsonReporter, fileReporter, htmlReporter]\n const reporters = selectReporters(available, requestedNames)\n setupReporters(hooks, { logLevel, reporters, dryRun })\n\n await hooks.callHook('kubb:lifecycle:start', { version })\n\n const runConfigs = configs.map((config) => toRunConfig({ config, input, dryRun: dryRun ?? false }))\n\n if (!quiet) logOutro(`${pluralize(configs.length, 'config')} ready`)\n\n try {\n // One config that fails does not stop the others.\n const succeeded = await (watchMode ? watch({ configs: runConfigs, hooks, quiet }) : generate({ configs: runConfigs, hooks }))\n\n // Aborting settles a request in flight at once; the timeout covers a cache read or write on a stalled disk.\n updateCheck.abort()\n await checkForUpdate({ hooks, latestVersion: await withTimeout({ promise: latestVersion, ms: UPDATE_WAIT_MS }) })\n\n await hooks.callHook('kubb:lifecycle:end')\n\n // Watch mode prints a tip after each successful build. Regular generate commands need to\n // print one explicitly after the lifecycle group has closed so it stays outside the group.\n if (!quiet && !watchMode && succeeded) {\n logTip()\n }\n\n // `exitCode`, not `exit()`, so the payload piped to the telemetry process is flushed first.\n if (!succeeded) {\n process.exitCode = 1\n }\n } catch (error) {\n await Diagnostics.emit(hooks, error)\n process.exit(1)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAKA,MAAM,uBAAuB;;AAG7B,MAAM,0BAA0B;AAKhC,MAAM,YAAY;AAOlB,SAAS,cAAc,OAAsC;CAC3D,MAAM,QAAQ;CACd,OAAO,OAAO,OAAO,YAAY,YAAY,QAAQ,MAAM,OAAO,KAAK,OAAO,MAAM,cAAc;AACpG;AAGA,SAAS,QAAQ,WAA4B;CAC3C,MAAM,MAAM,KAAK,IAAI,IAAI;CACzB,OAAO,OAAO,KAAK,MAAA;AACrB;;AAGA,eAAe,mBAAmB,QAAkD;CAClF,IAAI;EACF,MAAM,MAAM,MAAM,MAAM,sBAAsB,EAAE,QAAQ,YAAY,IAAI,CAAC,QAAQ,YAAY,QAAQ,uBAAuB,CAAC,CAAC,EAAE,CAAC;EACjI,IAAI,CAAC,IAAI,IAAI,OAAO,KAAA;EACpB,MAAM,OAAQ,MAAM,IAAI,KAAK;EAC7B,OAAO,OAAO,KAAK,YAAY,YAAY,QAAQ,KAAK,OAAO,IAAI,KAAK,UAAU,KAAA;CACpF,QAAQ;EACN;CACF;AACF;;;;;;AAOA,eAAsB,iBAAiB,QAAkD;CACvF,IAAI,gBAAgB,GAAG,OAAO,KAAA;CAE9B,MAAM,iBAAiB;EACrB,IAAI;GACF,OAAO,YAAY,EAAE,MAAM,QAAQ,CAAC;EACtC,QAAQ;GACN;EACF;CACF,EAAA,CAAG;CACH,MAAM,SAAS,MAAM,SAAS,QAAQ,SAAS,CAAC,CAAC,YAAY,IAAI;CACjE,IAAI,cAAc,MAAM,KAAK,QAAQ,OAAO,SAAS,GAAG,OAAO,OAAO;CAEtE,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gB,WAAW,cAAc;CAC3D,eAAe,OAAO;EAAEA,UAAAA;EAAU;EAAW;CAAO,CAAC;CAErD,MAAM,MAAM,SAAS,wBAAwB,EAAE,QAAQ,CAAC;CAExD,MAAM,aAAa,QAAQ,KAAK,WAAW,YAAY;EAAE;EAAQ;EAAO,QAAQ,UAAU;CAAM,CAAC,CAAC;CAElG,IAAI,CAAC,OAAO,SAAS,GAAG,UAAU,QAAQ,QAAQ,QAAQ,EAAE,OAAO;CAEnE,IAAI;EAEF,MAAM,YAAY,OAAO,YAAY,MAAM;GAAE,SAAS;GAAY;GAAO;EAAM,CAAC,IAAI,SAAS;GAAE,SAAS;GAAY;EAAM,CAAC;EAG3H,YAAY,MAAM;EAClB,MAAM,eAAe;GAAE;GAAO,eAAe,MAAM,YAAY;IAAE,SAAS;IAAe,IAAI;GAAe,CAAC;EAAE,CAAC;EAEhH,MAAM,MAAM,SAAS,oBAAoB;EAIzC,IAAI,CAAC,SAAS,CAAC,aAAa,WAC1B,OAAO;EAIT,IAAI,CAAC,WACH,QAAQ,WAAW;CAEvB,SAAS,OAAO;EACd,MAAM,YAAY,KAAK,OAAO,KAAK;EACnC,QAAQ,KAAK,CAAC;CAChB;AACF"}
@@ -1,6 +1,6 @@
1
1
  import "./rolldown-runtime-BowF1xt-.js";
2
2
  import { n as toError } from "./errors-CEzFbRvL.js";
3
- import { n as trackRun } from "./Telemetry-B35TOnPl.js";
3
+ import { n as trackRun } from "./Telemetry-BhTLEYwh.js";
4
4
  import { styleText } from "node:util";
5
5
  import process from "node:process";
6
6
  // src/runners/mcp/run.ts
@@ -28,4 +28,4 @@ async function run() {
28
28
  }
29
29
  export { run };
30
30
 
31
- //# sourceMappingURL=run-DaCXL5ag.js.map
31
+ //# sourceMappingURL=run-C3J0YrXl.js.map