{"version":3,"file":"run-DZr8Idzx.cjs","names":["isValid","isCIEnvironment","kubbStorage","memoryStorage","process","trackRun","Kubb","Diagnostics","delay","isOutdated","version","styleText","pluralize","formatMs","getInputKind","path","trackBuild","diffBuilds","getElapsedMs","listenForKeys","startWatcher","logInfo","logError","logLevelMap","Hookable","cliReporter","createPlainWriter","logBanner","getConfigs","createSpinner","jsonReporter","fileReporter","htmlReporter","selectReporters"],"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,aAAA,GAAYA,OAAAA,QAAAA,CAAQ,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,m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