@kubb/cli 5.12.1 → 5.12.3

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 (65) hide show
  1. package/README.md +3 -0
  2. package/dist/{Telemetry-D-IDgRfq.cjs → Telemetry-CDO1ICOK.cjs} +2 -2
  3. package/dist/{Telemetry-D-IDgRfq.cjs.map → Telemetry-CDO1ICOK.cjs.map} +1 -1
  4. package/dist/{Telemetry-wyeU72_v.js → Telemetry-xhC8-Vyn.js} +2 -2
  5. package/dist/{Telemetry-wyeU72_v.js.map → Telemetry-xhC8-Vyn.js.map} +1 -1
  6. package/dist/{background-D0g61wus.js → background-COPnOEZ1.js} +1 -1
  7. package/dist/{background-DY-7vFSm.cjs → background-D2LpT9f4.cjs} +2 -2
  8. package/dist/{background-DY-7vFSm.cjs.map → background-D2LpT9f4.cjs.map} +1 -1
  9. package/dist/{background-B49o0iOw.js → background-uBrxdVDR.js} +2 -2
  10. package/dist/{background-B49o0iOw.js.map → background-uBrxdVDR.js.map} +1 -1
  11. package/dist/credentials-CZK6zPLv.js.map +1 -1
  12. package/dist/credentials-DDaKqtJn.cjs.map +1 -1
  13. package/dist/index.cjs +38 -19
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.js +38 -19
  16. package/dist/index.js.map +1 -1
  17. package/dist/{registry-DSDoBaVk.cjs → registry-BKyP8vWm.cjs} +3 -3
  18. package/dist/{registry-DSDoBaVk.cjs.map → registry-BKyP8vWm.cjs.map} +1 -1
  19. package/dist/{registry-BS1M25zz.js → registry-CBcmeWFe.js} +3 -3
  20. package/dist/{registry-BS1M25zz.js.map → registry-CBcmeWFe.js.map} +1 -1
  21. package/dist/{reporters-BXNKLBLf.js → reporters-Dd8dW6po.js} +4 -4
  22. package/dist/{reporters-BXNKLBLf.js.map → reporters-Dd8dW6po.js.map} +1 -1
  23. package/dist/{reporters-C4xq0GFT.cjs → reporters-uyy4d-rb.cjs} +4 -4
  24. package/dist/{reporters-C4xq0GFT.cjs.map → reporters-uyy4d-rb.cjs.map} +1 -1
  25. package/dist/{run-DNzoHmRZ.cjs → run-BiNNfH9p.cjs} +6 -6
  26. package/dist/{run-DNzoHmRZ.cjs.map → run-BiNNfH9p.cjs.map} +1 -1
  27. package/dist/{run-Byr2y0hI.js → run-C-Qj8rGT.js} +4 -4
  28. package/dist/{run-Byr2y0hI.js.map → run-C-Qj8rGT.js.map} +1 -1
  29. package/dist/{run-Bd_ZfPG1.js → run-C-iy2alt.js} +25 -7
  30. package/dist/run-C-iy2alt.js.map +1 -0
  31. package/dist/{run-bSFXs9i3.cjs → run-CaIWyYX7.cjs} +2 -2
  32. package/dist/{run-bSFXs9i3.cjs.map → run-CaIWyYX7.cjs.map} +1 -1
  33. package/dist/{run-CuRCXhQb.js → run-CivlWrUP.js} +6 -6
  34. package/dist/{run-CuRCXhQb.js.map → run-CivlWrUP.js.map} +1 -1
  35. package/dist/{run-z960932J.js → run-D2tp1iy3.js} +2 -2
  36. package/dist/{run-z960932J.js.map → run-D2tp1iy3.js.map} +1 -1
  37. package/dist/{run-DcX-F_wC.js → run-D8CyGEhZ.js} +1 -1
  38. package/dist/{run-4DWl8vSu.cjs → run-DLL5vVCe.cjs} +4 -4
  39. package/dist/{run-4DWl8vSu.cjs.map → run-DLL5vVCe.cjs.map} +1 -1
  40. package/dist/{run-C9EYgEqG.cjs → run-Deh1VHMP.cjs} +25 -7
  41. package/dist/run-Deh1VHMP.cjs.map +1 -0
  42. package/dist/{snapshot-DzzsJSWr.cjs → snapshot-BDlMKdLT.cjs} +6 -6
  43. package/dist/{snapshot-DzzsJSWr.cjs.map → snapshot-BDlMKdLT.cjs.map} +1 -1
  44. package/dist/{snapshot-CLgI_qzL.js → snapshot-hkBgN59R.js} +6 -6
  45. package/dist/{snapshot-CLgI_qzL.js.map → snapshot-hkBgN59R.js.map} +1 -1
  46. package/dist/{status-DrKO_t5S.js → status-C8vkwg_L.js} +3 -3
  47. package/dist/{status-DrKO_t5S.js.map → status-C8vkwg_L.js.map} +1 -1
  48. package/dist/{status-B50z7yha.cjs → status-CLv6fxZ_.cjs} +3 -3
  49. package/dist/{status-B50z7yha.cjs.map → status-CLv6fxZ_.cjs.map} +1 -1
  50. package/dist/studioWorker.js +2 -2
  51. package/dist/{summary-Bi_pAA9i.js → summary-BASjQtTi.js} +3 -3
  52. package/dist/{summary-Bi_pAA9i.js.map → summary-BASjQtTi.js.map} +1 -1
  53. package/dist/{summary-C8QI_30-.cjs → summary-D18R-dbI.cjs} +3 -3
  54. package/dist/{summary-C8QI_30-.cjs.map → summary-D18R-dbI.cjs.map} +1 -1
  55. package/dist/{text-Sp4fptq1.cjs → text-B9kNqOjo.cjs} +2 -2
  56. package/dist/{text-Sp4fptq1.cjs.map → text-B9kNqOjo.cjs.map} +1 -1
  57. package/dist/{text-DgzXienb.js → text-CLsQw856.js} +2 -2
  58. package/dist/{text-DgzXienb.js.map → text-CLsQw856.js.map} +1 -1
  59. package/dist/{utils-Dju97QYB.cjs → utils-B1jRXHoA.cjs} +3 -3
  60. package/dist/{utils-Dju97QYB.cjs.map → utils-B1jRXHoA.cjs.map} +1 -1
  61. package/dist/{utils-BDDF8GOv.js → utils-Bon2anw0.js} +3 -3
  62. package/dist/{utils-BDDF8GOv.js.map → utils-Bon2anw0.js.map} +1 -1
  63. package/package.json +7 -7
  64. package/dist/run-Bd_ZfPG1.js.map +0 -1
  65. package/dist/run-C9EYgEqG.cjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["Diagnostics","command","defineWithTypes","dryRunId","command","define","define","command","command","connectCommand","command","command","define","command","connectCommand","define","command","process","command","define","connectCommand","startCommand","loginCommand","logoutCommand","statusCommand","snapshotCommand","command","define","styleText","process","path","fs","x","read","Diagnostics","write","process","formatMs","getElapsedMs","isRichOutput","clack","createSpinner","getErrorMessage","Diagnostics","toShortId","clack","run","process","logCommandSummary","isInteractiveRun","styleText","registryUrl","toRegistryId","path","findConfigFile","withSpinner","fetchRegistryIndex","readInstalledPackages","read","closestIds","incompatibility","installSpec","command","define","clack","Diagnostics","KUBB_CONFIG_FILENAME","getConfigs","createKubb","run","process","createSpinner","styleText","isInteractiveRun","fetchRegistryIndex","registryUrl","incompatibility","exists","path","pluralize","initDefaults","KUBB_PACKAGE_NAME","version","installSpec","write","formatMs","getElapsedMs","command","defineWithTypes","dryRunId","readInstalledPackages","fetchRegistryIndex","getErrorMessage","isOutdated","run","process","registryUrl","styleText","command","define","createSpinner","path","readOutputFiles","Hookable","diffFiles","pluralize","getErrorMessage","run","process","logCommandSummary","isInteractiveRun","styleText","toRegistryId","withSpinner","fetchRegistryIndex","registryUrl","readInstalledPackages","bumpOf","isOutdated","incompatibility","clack","toShortId","installSpec","findConfigFile","defineWithTypes","dryRunId","isTelemetryDisabled","styleText","cli","generateCommand","initCommand","validateCommand","mcpCommand","studioCommand","addCommand","updateCommand","listCommand","wantsMascot","getBanner","version","dryrun"],"sources":["../src/commands/shared.ts","../src/commands/generate.ts","../src/commands/mcp.ts","../src/commands/studio/studioCommand.ts","../src/commands/studio/connect.ts","../src/commands/studio/login.ts","../src/commands/studio/logout.ts","../src/commands/studio/snapshot.ts","../src/commands/studio/background.ts","../src/commands/studio/status.ts","../src/commands/studio/index.ts","../src/commands/validate.ts","../src/deprecatedFlags.ts","../../../internals/shared/src/init.ts","../src/runners/init/utils.ts","../src/runners/installWithSpinner.ts","../src/runners/add/run.ts","../src/runners/init/run.ts","../src/ui/table.ts","../src/runners/list/run.ts","../src/runners/update/run.ts","../src/index.ts"],"sourcesContent":["import { pluginId as dryRunId } from '@gunshi/plugin-dryrun'\nimport type { DryRunExtension } from '@gunshi/plugin-dryrun'\n\nexport { dryRunId }\n\n/** Extension shape gunshi's command context carries with `@gunshi/plugin-dryrun`; the `extensions` type parameter of `defineWithTypes`. */\nexport type DryRunExtensions = {\n [dryRunId]: DryRunExtension\n}\n\nexport const configArg = {\n config: {\n type: 'string',\n description: 'Path to the Kubb config',\n short: 'c',\n },\n} as const\n\nexport const yesArg = {\n yes: {\n type: 'boolean',\n description: 'Skip the confirmation',\n short: 'y',\n default: false,\n },\n} as const\n\nexport const logLevelArg = {\n logLevel: {\n type: 'enum',\n choices: ['silent', 'info', 'verbose'] as const,\n description: 'Info, silent or verbose',\n short: 'l',\n default: 'info',\n toKebab: true,\n },\n} as const\n\nexport const studioConnectionArgs = {\n url: {\n type: 'string',\n description: 'Base URL of the Kubb Studio instance',\n },\n token: {\n type: 'string',\n description: 'Organization CI API key for `snapshot`. Defaults to KUBB_TOKEN',\n },\n} as const\n\nexport const studioPermissionArgs = {\n allowRead: {\n type: 'boolean',\n description: 'Read the source of files a generation produced. Asked for once per project when omitted',\n default: false,\n toKebab: true,\n },\n allowReadAst: {\n type: 'boolean',\n description: 'Read the parsed spec (the Kubb AST). Asked for once per project when omitted',\n default: false,\n toKebab: true,\n },\n allowWrite: {\n type: 'boolean',\n description: 'Write generated files to disk. Asked for once per project when omitted',\n default: false,\n toKebab: true,\n },\n allowConfigEdit: {\n type: 'boolean',\n description: 'Let Studio change plugin options in kubb.config.ts. Asked for once per project when omitted',\n default: false,\n toKebab: true,\n },\n allowExec: {\n type: 'boolean',\n description: 'Run the formatter, the linter, and output.postGenerate after a generation',\n default: false,\n toKebab: true,\n },\n} as const\n","import { defineWithTypes } from 'gunshi'\nimport { Diagnostics, type ReporterName } from '@kubb/core'\nimport { configArg, dryRunId, type DryRunExtensions, logLevelArg } from './shared.ts'\n\nconst REPORTER_NAMES: Array<ReporterName> = ['cli', 'json', 'file', 'html']\n\n/**\n * Splits and validates the comma-separated `--reporter` value against the known reporter names.\n */\nfunction parseReporters(value: string): Array<ReporterName> {\n const names = value\n .split(',')\n .map((name) => name.trim())\n .filter(Boolean)\n\n for (const name of names) {\n if (!REPORTER_NAMES.includes(name as ReporterName)) {\n throw new Diagnostics.Error({\n code: Diagnostics.code.unknown,\n severity: 'error',\n message: `must be one of cli, json, file, html (got \"${name}\")`,\n help: 'Use one of cli, json, file, html.',\n })\n }\n }\n\n return names as Array<ReporterName>\n}\n\n/**\n * Resolves the effective log level, letting the `--verbose` and `--silent` flags win over `--log-level`.\n */\nfunction resolveLogLevel({ verbose, silent, logLevel }: { verbose: boolean; silent: boolean; logLevel: string }): string {\n if (verbose) return 'verbose'\n if (silent) return 'silent'\n return logLevel\n}\n\nexport const command = defineWithTypes<{ extensions: DryRunExtensions }>()({\n name: 'generate',\n // The runner plays the animated mascot itself, so the shared header would print it twice.\n rendering: { header: null },\n description: 'Generate types, clients, hooks, and schemas from an OpenAPI specification.',\n examples: [\n 'kubb generate # generate from kubb.config.ts',\n 'kubb generate ./openapi.yaml # generate from this spec instead of the config input',\n 'kubb generate --config kubb.config.ts',\n 'kubb generate --watch # regenerate whenever the spec changes',\n 'kubb generate --dry-run # preview the run without writing files',\n 'kubb generate --reporter html # write an HTML run report',\n 'kubb studio # connect this project to Kubb Studio and generate from the browser',\n 'kubb studio --allow-write # let Studio write the generated files to disk',\n 'kubb studio login # pair this machine with Studio without connecting',\n ].join('\\n'),\n toKebab: true,\n args: {\n input: {\n type: 'positional',\n required: false,\n description: 'Path to the OpenAPI specification, overriding the config',\n },\n ...configArg,\n ...logLevelArg,\n watch: {\n type: 'boolean',\n description: 'Watch mode: rebuilds when the local input file changes',\n short: 'w',\n default: false,\n },\n verbose: {\n type: 'boolean',\n description: 'Override logLevel to verbose',\n default: false,\n },\n silent: {\n type: 'boolean',\n description: 'Override logLevel to silent',\n short: 's',\n default: false,\n },\n reporter: {\n type: 'custom',\n description: 'Reporters that render the run: cli, json, file, html. Comma-separated. Overrides config.reporters',\n metavar: 'cli|json|file|html',\n parse: parseReporters,\n },\n },\n async run(ctx) {\n const { values } = ctx\n const logLevel = resolveLogLevel(values)\n const { run } = await import('../runners/generate/run.ts')\n\n await run({\n input: values.input,\n configPath: values.config,\n logLevel,\n watch: values.watch,\n reporters: values.reporter,\n dryRun: ctx.extensions[dryRunId].enabled,\n })\n },\n})\n","import { define } from 'gunshi'\n\n/** The runner is imported when the command runs, so listing `kubb --help` never loads `@kubb/mcp`. */\nexport const command = define({\n name: 'mcp',\n description: 'Start an MCP server for code generation from an AI assistant.',\n examples: ['kubb mcp', '# Then add to your MCP client config:', '# { \"mcpServers\": { \"kubb\": { \"command\": \"npx\", \"args\": [\"kubb\", \"mcp\"] } } }'].join('\\n'),\n // gunshi prints the header to stdout, which the MCP stdio transport owns.\n rendering: { header: null },\n async run() {\n const { run } = await import('../runners/mcp/run.ts')\n await run()\n },\n})\n","import { type Args, define } from 'gunshi'\nimport type { StudioOptions, StudioValues } from '../../runners/studio/run.ts'\n\n/**\n * Defines a `kubb studio` subcommand. The runner, and with it `@kubb/studio`, loads only when the\n * command runs, so `kubb --help` never does.\n */\nexport function studioCommand({\n action,\n block,\n ...definition\n}: {\n name: string\n description: string\n examples?: string\n args?: Args\n /** Opens a block a later `logOutro` closes, for a command that keeps running. */\n block?: boolean\n /** The command body, given the options built from its flags. */\n action: (options: StudioOptions) => Promise<unknown>\n}) {\n return define({\n ...definition,\n toKebab: true,\n async run({ values }) {\n const { runStudio } = await import('../../runners/studio/run.ts')\n await runStudio(values as StudioValues, action, { block })\n },\n })\n}\n","import { configArg, logLevelArg, studioConnectionArgs, studioPermissionArgs } from '../shared.ts'\nimport { studioCommand } from './studioCommand.ts'\n\nexport const command = studioCommand({\n name: 'connect',\n description: 'Connect this project to Kubb Studio and generate from the browser.',\n examples: [\n 'kubb studio connect',\n 'kubb studio connect --allow-read',\n 'kubb studio connect --allow-write --allow-exec',\n 'kubb studio connect --url http://localhost:3000',\n ].join('\\n'),\n args: {\n ...configArg,\n ...studioConnectionArgs,\n ...studioPermissionArgs,\n open: {\n type: 'boolean',\n description: 'Open the approval page in a browser while pairing',\n default: true,\n negatable: true,\n },\n ...logLevelArg,\n },\n block: true,\n async action(options) {\n const { connect } = await import('../../runners/studio/run.ts')\n await connect(options)\n },\n})\n","import { command as connectCommand } from './connect.ts'\nimport { studioCommand } from './studioCommand.ts'\n\nexport const command = studioCommand({\n name: 'login',\n description: 'Pair this machine with Kubb Studio without connecting.',\n examples: ['kubb studio login', 'kubb studio login --url http://localhost:3000'].join('\\n'),\n args: connectCommand.args,\n async action(options) {\n const { login } = await import('../../runners/studio/run.ts')\n await login(options)\n },\n})\n","import { studioCommand } from './studioCommand.ts'\n\nexport const command = studioCommand({\n name: 'logout',\n description: 'Forget the stored Kubb Studio token.',\n examples: 'kubb studio logout',\n args: {},\n async action() {\n const { stopWorker } = await import('../../runners/studio/background.ts')\n const { clearCredentials } = await import('../../runners/studio/credentials.ts')\n await stopWorker()\n await clearCredentials()\n console.log('Signed out of Kubb Studio.')\n },\n})\n","import { define } from 'gunshi'\nimport { configArg, logLevelArg, studioConnectionArgs } from '../shared.ts'\n\nexport const command = define({\n name: 'snapshot',\n description: 'Generate and publish a Kubb Studio snapshot from CI.',\n examples: ['kubb studio snapshot', 'kubb studio snapshot --json'].join('\\n'),\n toKebab: true,\n args: {\n ...configArg,\n ...studioConnectionArgs,\n id: {\n type: 'string',\n description: 'Stable identity for the CI agent, such as a pull request. Auto-detected on GitHub Actions, GitLab CI, Bitbucket Pipelines and CircleCI',\n },\n baseId: {\n type: 'string',\n description:\n \"Identity of another CI agent, such as the base branch's, to also compare this snapshot with. Auto-detected on GitHub pull requests and GitLab merge requests\",\n toKebab: true,\n },\n name: {\n type: 'string',\n description: 'Package name for the generated tarball. Defaults to the name in package.json',\n },\n packageVersion: {\n type: 'string',\n description: 'Package version for the generated tarball. Defaults to the version in package.json',\n toKebab: true,\n },\n json: {\n type: 'boolean',\n description: 'Print the result as one JSON object instead of a summary',\n default: false,\n },\n ...logLevelArg,\n },\n async run(ctx) {\n const { runner } = await import('../../runners/studio/snapshot.ts')\n await runner(ctx)\n },\n})\n","import { define } from 'gunshi'\nimport { command as connectCommand } from './connect.ts'\nimport { studioCommand } from './studioCommand.ts'\n\nexport const command = studioCommand({\n name: 'start',\n description: 'Keep this project connected to Kubb Studio in the background.',\n args: connectCommand.args,\n async action(options) {\n const { startWorker } = await import('../../runners/studio/background.ts')\n await startWorker(options)\n },\n})\n\nexport const stopCommand = define({\n name: 'stop',\n description: \"Stop this project's background connection and keep its pairing.\",\n async run() {\n const { stopWorker } = await import('../../runners/studio/background.ts')\n await stopWorker()\n console.log('Background connection stopped.')\n },\n})\n","import process from 'node:process'\nimport { studioConnectionArgs } from '../shared.ts'\nimport { studioCommand } from './studioCommand.ts'\n\nexport const command = studioCommand({\n name: 'status',\n description: 'Show the project worker, Kubb Studio pairing, and saved permissions.',\n examples: 'kubb studio status',\n args: { url: studioConnectionArgs.url },\n async action(options) {\n const { getWorkerLogPath, getWorkerStatus } = await import('../../runners/studio/background.ts')\n const { readCredentials } = await import('../../runners/studio/credentials.ts')\n const { formatStatus } = await import('../../runners/studio/status.ts')\n\n const [worker, credentials] = await Promise.all([getWorkerStatus(), readCredentials()])\n console.log(\n ['', ...formatStatus({ studioUrl: options.studioUrl, credentials, worker, project: process.cwd(), logPath: getWorkerLogPath() }), ''].join('\\n'),\n )\n },\n})\n","import { define } from 'gunshi'\nimport { command as connectCommand } from './connect.ts'\nimport { command as loginCommand } from './login.ts'\nimport { command as logoutCommand } from './logout.ts'\nimport { command as snapshotCommand } from './snapshot.ts'\nimport { command as startCommand, stopCommand } from './background.ts'\nimport { command as statusCommand } from './status.ts'\n\nexport const command = define({\n ...connectCommand,\n name: 'studio',\n description: 'Connect this project to Kubb Studio, or manage its pairing and snapshots.',\n examples: ['kubb studio', 'kubb studio --allow-read', 'kubb studio login', 'kubb studio status', 'kubb studio logout', 'kubb studio snapshot'].join('\\n'),\n subCommands: {\n start: startCommand,\n stop: stopCommand,\n connect: connectCommand,\n login: loginCommand,\n logout: logoutCommand,\n status: statusCommand,\n snapshot: snapshotCommand,\n },\n})\n\n/**\n * Sends `kubb studio --flag value` to `kubb studio connect`, the same runner. gunshi picks a\n * subcommand from the first token that is not a flag, so `--url http://…` would read the URL as one.\n */\nexport function routeStudioFlags(args: Array<string>): Array<string> {\n const [name, next] = args\n if (name !== 'studio' || !next?.startsWith('-') || next === '--help' || next === '-h') return args\n\n return ['studio', 'connect', ...args.slice(1)]\n}\n","import { define } from 'gunshi'\nimport { configArg } from './shared.ts'\n\n/** The runner is imported when the command runs, so listing `kubb --help` never loads `@kubb/adapter-oas`. */\nexport const command = define({\n name: 'validate',\n description: 'Check a specification with the configured adapter before generating.',\n examples: ['kubb validate ./openapi.yaml', 'kubb validate https://petstore3.swagger.io/api/v3/openapi.json'].join('\\n'),\n args: {\n ...configArg,\n input: {\n type: 'positional',\n description: 'Path or URL to the specification to validate',\n required: true,\n },\n },\n async run({ values }) {\n const { run } = await import('../runners/validate/run.ts')\n await run({ input: values.input, configPath: values.config })\n },\n})\n","import { styleText } from 'node:util'\n\n/**\n * Maps each camelCase flag removed in favor of kebab-case (kubb-labs/kubb#4046) to its\n * replacement. Drop this table, and the rewrite it drives, once the deprecation window ends.\n */\nconst DEPRECATED_FLAGS: Record<string, string> = {\n allowWrite: 'allow-write',\n allowConfigEdit: 'allow-config-edit',\n allowExec: 'allow-exec',\n logLevel: 'log-level',\n dryRun: 'dry-run',\n packageVersion: 'package-version',\n}\n\n/** Flags a single command renamed, rewritten only for that command, since the old name is a common word. */\nconst DEPRECATED_COMMAND_FLAGS: Record<string, Record<string, string>> = {\n update: { check: 'dry-run' },\n}\n\nconst FLAG_PATTERN = /^--([a-zA-Z][\\w-]*)(=.*)?$/\n\n/**\n * Rewrites a deprecated camelCase flag to its kebab-case replacement and warns on stderr, so a\n * script written against the old flag names keeps working during the deprecation window instead\n * of failing with an unknown-option error.\n */\nexport function resolveDeprecatedFlags(args: Array<string>): Array<string> {\n const commandFlags = DEPRECATED_COMMAND_FLAGS[args[0] ?? ''] ?? {}\n\n return args.map((arg) => {\n const match = FLAG_PATTERN.exec(arg)\n const name = match?.[1]\n const replacement = name ? (DEPRECATED_FLAGS[name] ?? commandFlags[name]) : undefined\n\n if (!name || !replacement) {\n return arg\n }\n\n console.error(\n `${styleText('yellow', 'Warning:')} --${name} is deprecated, use --${replacement} instead. --${name} will be removed in a future major version.`,\n )\n\n return `--${replacement}${match?.[2] ?? ''}`\n })\n}\n","/** The `kubb.config.ts` `kubb init` writes before `kubb add` puts each plugin in. */\nexport function generateConfigFile({ inputPath, outputPath }: { inputPath: string; outputPath: string }): string {\n return `import { defineConfig } from 'kubb/config'\n\nexport default defineConfig({\n input: '${inputPath}',\n output: {\n path: '${outputPath}',\n clean: true,\n },\n plugins: [],\n})\n`\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\nimport process from 'node:process'\nimport { read, write } from '@internals/utils'\nimport { Diagnostics, type ExtensionManifest, type RegistryEntry } from '@kubb/core'\nimport { x } from 'tinyexec'\n\nexport type PackageManagerName = 'npm' | 'pnpm' | 'yarn' | 'bun'\n\n/** Metadata describing a package manager's lock file and commands. */\nexport type PackageManagerInfo = {\n /** Identifier used in CLI commands, e.g. `pnpm`, `yarn`. */\n name: PackageManagerName\n /** Lock file names that identify this package manager in a project root. */\n lockFiles: ReadonlyArray<string>\n /** Subcommands passed to the package manager binary to create a `package.json`. */\n initCommand: ReadonlyArray<string>\n /** Subcommands passed to the package manager binary to install a dev dependency. */\n installCommand: ReadonlyArray<string>\n /** Subcommands passed to the package manager binary before a `package.json` script name. */\n runCommand: ReadonlyArray<string>\n}\n\n/** Metadata for each supported package manager, keyed by its short name. */\nexport const packageManagers: Record<PackageManagerName, PackageManagerInfo> = {\n pnpm: {\n name: 'pnpm',\n lockFiles: ['pnpm-lock.yaml'],\n initCommand: ['init'],\n installCommand: ['add', '-D'],\n runCommand: [],\n },\n yarn: {\n name: 'yarn',\n lockFiles: ['yarn.lock'],\n initCommand: ['init', '-y'],\n installCommand: ['add', '-D'],\n runCommand: [],\n },\n bun: {\n name: 'bun',\n lockFiles: ['bun.lock', 'bun.lockb'],\n initCommand: ['init', '-y'],\n installCommand: ['add', '-d'],\n runCommand: ['run'],\n },\n npm: {\n name: 'npm',\n lockFiles: ['package-lock.json'],\n initCommand: ['init', '-y'],\n installCommand: ['install', '--save-dev'],\n runCommand: ['run'],\n },\n}\n\n/** Minimal shape of `package.json` fields read during detection. */\ntype PackageJson = {\n /** The `packageManager` field from `package.json` (e.g. `\"pnpm@9.0.0\"`). */\n packageManager?: string\n scripts?: Record<string, string>\n}\n\n/** Detects the package manager for `cwd`: the `packageManager` field in `package.json`, then a lock file, then `npm`. */\nexport function detectPackageManager(cwd: string = process.cwd()): PackageManagerInfo {\n const packageJsonPath = path.join(cwd, 'package.json')\n if (fs.existsSync(packageJsonPath)) {\n try {\n const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8')) as PackageJson\n const pmField = packageJson.packageManager\n if (typeof pmField === 'string') {\n const name = pmField.split('@')[0]\n if (name && name in packageManagers) {\n return packageManagers[name as PackageManagerName]\n }\n }\n } catch {\n // Continue to lock file detection\n }\n }\n\n for (const pm of Object.values(packageManagers)) {\n if (pm.lockFiles.some((lockFile) => fs.existsSync(path.join(cwd, lockFile)))) {\n return pm\n }\n }\n\n return packageManagers.npm\n}\n\n/**\n * Initializes a new `package.json` at `cwd` using the detected package manager.\n */\nexport async function initPackageJson(cwd: string, packageManager: PackageManagerInfo): Promise<void> {\n await x(packageManager.name, [...packageManager.initCommand], {\n nodeOptions: { cwd, stdio: 'inherit' },\n throwOnError: true,\n })\n}\n\n/** How many trailing lines of a failed install's output the error keeps. */\nconst INSTALL_OUTPUT_LINES = 20\nconst INSTALL_TIMEOUT_MS = 5 * 60_000\n\n/**\n * Installs the given packages at `cwd` using the detected package manager. Each output line goes\n * to `onLine`, so the caller can show it while the install runs; a failed install also keeps the\n * end of the output in the error.\n */\nexport async function installPackages(\n packages: Array<string>,\n packageManager: PackageManagerInfo,\n cwd: string = process.cwd(),\n onLine?: (line: string) => void,\n): Promise<void> {\n const args = [...packageManager.installCommand, ...packages]\n // No stdin, so a package manager that wants input fails instead of waiting. The timeout ends a stalled install.\n const result = x(packageManager.name, args, {\n nodeOptions: { cwd, stdio: ['ignore', 'pipe', 'pipe'] },\n timeout: INSTALL_TIMEOUT_MS,\n throwOnError: false,\n })\n const lines: Array<string> = []\n for await (const line of result) {\n lines.push(line)\n onLine?.(line)\n }\n if (result.exitCode === 0) return\n if (result.exitCode === undefined) throw new Error(`\\`${packageManager.name} ${args.join(' ')}\\` timed out after ${INSTALL_TIMEOUT_MS / 60_000} minutes`)\n\n const output = lines.slice(-INSTALL_OUTPUT_LINES).join('\\n')\n throw new Error(`\\`${packageManager.name} ${args.join(' ')}\\` failed with exit code ${result.exitCode}${output ? `:\\n${output}` : ''}`)\n}\n\n/**\n * What the selected plugins' `manifests` say is missing from the selection: a `dependencies`\n * entry, or a `client` plugin next to a `consumer`. Empty when nothing is missing.\n * `optionalDependencies` are skipped, since `kubb init` writes the default options.\n */\nexport function missingPluginDependencies(manifests: Array<ExtensionManifest>): Array<string> {\n const selected = manifests.map((manifest) => manifest.name)\n const hasClient = manifests.some((manifest) => manifest.role === 'client')\n return manifests.flatMap((manifest) => [\n ...(manifest.dependencies ?? []).filter((name) => !selected.includes(name)).map((name) => `${manifest.name} needs ${name}.`),\n ...(manifest.role === 'consumer' && !hasClient ? [`${manifest.name} needs a client plugin, such as plugin-axios or plugin-fetch.`] : []),\n ])\n}\n\nasync function readPackageJson(cwd: string): Promise<PackageJson> {\n try {\n return JSON.parse(await read(path.join(cwd, 'package.json'))) as PackageJson\n } catch {\n return {}\n }\n}\n\nconst SPEC_FILE = /^(openapi|swagger)[\\w.-]*\\.(ya?ml|json)$/i\nconst SKIPPED_DIRS = new Set(['node_modules', 'dist', 'build', 'coverage'])\n\n/**\n * Finds OpenAPI spec files up to `depth` folders below `cwd`, shallowest first, as `./`-relative\n * paths. Walks one level at a time and stops after `limit` files, so a large repo stays fast.\n */\nexport async function findSpecFiles(cwd: string, { depth = 3, limit = 20 }: { depth?: number; limit?: number } = {}): Promise<Array<string>> {\n const found: Array<string> = []\n let level: Array<string> = ['']\n for (let current = 0; current <= depth && level.length && found.length < limit; current++) {\n const listings = await Promise.all(\n level.map(async (dir) => ({ dir, entries: await fs.promises.readdir(path.join(cwd, dir), { withFileTypes: true }).catch(() => []) })),\n )\n level = []\n for (const { dir, entries } of listings) {\n for (const entry of entries.toSorted((a, b) => a.name.localeCompare(b.name))) {\n if (entry.isFile() && SPEC_FILE.test(entry.name)) found.push(`./${path.posix.join(dir, entry.name)}`)\n if (entry.isDirectory() && !entry.name.startsWith('.') && !SKIPPED_DIRS.has(entry.name)) level.push(path.posix.join(dir, entry.name))\n }\n }\n }\n return found.slice(0, limit)\n}\n\n/** The spec version and operation count, when the file states them. */\nexport type SpecInfo = { version?: string; operations?: number }\n\nconst SPEC_HEAD_BYTES = 256 * 1024\nconst METHOD = '(?:get|put|post|delete|options|head|patch|trace)'\n\n/**\n * Reads the OpenAPI or Swagger version and counts the operations from the first 256 KB of the\n * file, so a large spec is never parsed. The count is left out when the file is longer.\n */\nexport async function readSpecInfo(file: string): Promise<SpecInfo> {\n const handle = await fs.promises.open(file)\n try {\n const buffer = Buffer.alloc(SPEC_HEAD_BYTES)\n const { bytesRead } = await handle.read(buffer, 0, SPEC_HEAD_BYTES, 0)\n const head = buffer.toString('utf-8', 0, bytesRead)\n const complete = bytesRead < SPEC_HEAD_BYTES\n const version = head.match(/^\\s*[\"']?(?:openapi|swagger)[\"']?\\s*:\\s*[\"']?(\\d[\\d.]*)/m)?.[1]\n // shortcut: counts method keys at any depth, so a schema property named `get` counts too; use the adapter when that matters.\n const methods = new RegExp(`^\\\\s*[\"']?${METHOD}[\"']?\\\\s*:\\\\s*(?:\\\\{|$)`, 'gm')\n return { version, operations: complete ? (head.match(methods)?.length ?? 0) : undefined }\n } finally {\n await handle.close()\n }\n}\n\n/** Finds a plugin by registry id, slug, or short name, so `ts`, `plugin-ts`, and `kubb-labs/plugin-ts` all match. */\nexport function findPlugin({ plugins, id }: { plugins: Array<RegistryEntry>; id: string }): RegistryEntry | undefined {\n const ids = id.includes('/') ? [id] : [`kubb-labs/${id}`, `kubb-labs/plugin-${id}`]\n return plugins.find((entry) => ids.includes(entry.id))\n}\n\n/**\n * Turns the comma-separated `--plugins` value into registry entries.\n *\n * @throws when an id is not in `plugins`.\n */\nexport function parsePluginsFlag({ plugins, value }: { plugins: Array<RegistryEntry>; value: string }): Array<RegistryEntry> {\n const ids = value\n .split(',')\n .map((id) => id.trim())\n .filter(Boolean)\n const unknown = ids.filter((id) => !findPlugin({ plugins, id }))\n if (unknown.length)\n throw new Diagnostics.Error({\n code: Diagnostics.code.pluginNotFound,\n severity: 'error',\n message: `Not in the Kubb registry: ${unknown.join(', ')}. Browse the plugins at https://kubb.dev/extensions.`,\n help: 'Use plugin ids from https://kubb.dev/extensions, such as plugin-ts or ts.',\n })\n return ids.map((id) => findPlugin({ plugins, id })!)\n}\n\n/** Adds `\"generate\": \"kubb generate\"` to the `package.json` scripts at `cwd`. Returns `false`, and changes nothing, when a `generate` script exists. */\nexport async function addGenerateScript(cwd: string): Promise<boolean> {\n const file = path.join(cwd, 'package.json')\n const source = await read(file)\n const packageJson = JSON.parse(source) as PackageJson\n if (packageJson.scripts?.generate !== undefined) return false\n const indent = source.match(/^[ \\t]+/m)?.[0] ?? ' '\n const updated = { ...packageJson, scripts: { ...packageJson.scripts, generate: 'kubb generate' } }\n await write(file, JSON.stringify(updated, null, indent))\n return true\n}\n\n/** Reads the `generate` script from the `package.json` at `cwd`. */\nexport async function generateScript(cwd: string): Promise<string | undefined> {\n return (await readPackageJson(cwd)).scripts?.generate\n}\n","import process from 'node:process'\nimport * as clack from '@clack/prompts'\nimport { formatMs, getElapsedMs } from '@internals/utils'\nimport { isRichOutput } from '../utils/env.ts'\nimport { createSpinner } from '../ui/spinner.ts'\nimport { installPackages, type PackageManagerInfo } from './init/utils.ts'\n\n/** How many package manager lines stay visible under the install title while it runs. */\nconst LOG_LINES = 6\n\n/**\n * Installs `packages` and reports how long it took. A rich terminal shows the package manager's\n * last lines under the title while the install runs and clears them when it succeeds; a plain one\n * prints the start and end lines. A failed install keeps the output, reports the failure and rethrows.\n */\nexport async function installWithSpinner({\n packages,\n names,\n packageManager,\n cwd,\n install = installPackages,\n}: {\n packages: Array<string>\n names: string\n packageManager: PackageManagerInfo\n cwd: string\n /** Runs the install itself, so a dry run can skip it. */\n install?: typeof installPackages\n}): Promise<void> {\n const start = process.hrtime()\n const task = createTask(`Installing ${names} with ${packageManager.name}`)\n try {\n await install(packages, packageManager, cwd, task.message)\n } catch (error) {\n task.error('Install failed')\n throw error\n }\n task.success(`Installed ${names} with ${packageManager.name} in ${formatMs(getElapsedMs(start))}`)\n}\n\ntype Task = { message: (line: string) => void; error: (text: string) => void; success: (text: string) => void }\n\n// clack's taskLog prints nothing at the end outside a TTY, so a plain terminal keeps the spinner writer.\n// The failure keeps no log: the thrown error already carries the last lines.\nfunction createTask(title: string): Task {\n if (isRichOutput()) {\n const log = clack.taskLog({ title, limit: LOG_LINES })\n return { message: (line) => log.message(line), error: (text) => log.error(text, { showLog: false }), success: (text) => log.success(text) }\n }\n const spinner = createSpinner()\n spinner.start(title)\n return { message: () => {}, error: (text) => spinner.error(text), success: (text) => spinner.stop(text) }\n}\n","import path from 'node:path'\nimport process from 'node:process'\nimport { styleText } from 'node:util'\nimport * as clack from '@clack/prompts'\nimport { define } from 'gunshi'\nimport { findConfigFile } from '@internals/shared'\nimport { getErrorMessage, read } from '@internals/utils'\nimport { Diagnostics, type ExtensionManifest, readInstalledPackages, type RegistryDetail, type RegistryEntry } from '@kubb/core'\nimport { configArg, yesArg } from '../../commands/shared.ts'\nimport { isInteractiveRun, logIntro } from '../../ui/intro.ts'\nimport { logBlock, logError, logStep, logWarn } from '../../ui/log.ts'\nimport { withSpinner } from '../../ui/spinner.ts'\nimport { logCommandSummary } from '../../ui/summary.ts'\nimport { closestIds, fetchRegistryIndex, incompatibility, installSpec, registryUrl, toRegistryId, toShortId } from '../../utils/registry.ts'\nimport { detectPackageManager } from '../init/utils.ts'\nimport { installWithSpinner } from '../installWithSpinner.ts'\n\nexport type AddOptions = {\n /**\n * `owner/slug`, or a bare `slug` for an official extension. Asked for when omitted.\n */\n id?: string\n configPath?: string\n yes: boolean\n install: boolean\n}\n\ntype ConfigTarget = Pick<RegistryDetail, 'artifact' | 'manifest'>\n\n/** The import and the `defineConfig` property to merge into `kubb.config.ts` by hand. */\nfunction toSnippet({ artifact, manifest }: ConfigTarget): string {\n const call = `${manifest.export}()`\n const property: Record<ExtensionManifest['kind'], string> = {\n plugin: `plugins: [..., ${call}],`,\n adapter: `adapter: ${call},`,\n parser: `parsers: [..., ${call}],`,\n }\n return [`import { ${manifest.export} } from '${artifact.package}'`, '', property[manifest.kind]].join('\\n')\n}\n\n/** The `add-plugin` edits for `details`, and the manifests the edits read their export names from. */\nfunction toConfigEdits(details: Array<ConfigTarget>) {\n return {\n edits: details.map(({ artifact }) => ({ operation: 'add-plugin' as const, plugin: artifact.package })),\n extensions: new Map(details.map(({ artifact, manifest }) => [artifact.package, { package: artifact.package, version: artifact.version, manifest }])),\n }\n}\n\n/** The lines adding `details` would put in the config `source`, trimmed, or why it could not add them. */\nasync function previewConfig({ details, source }: { details: Array<ConfigTarget>; source: string }): Promise<{ lines: Array<string> } | { reason: string }> {\n try {\n const { applyConfigEdits } = await import('@kubb/studio')\n const result = applyConfigEdits({ source, ...toConfigEdits(details) })\n const failed = result.outcomes.find((outcome) => !outcome.applied)\n if (failed) return { reason: failed.reason ?? 'the config file was not changed' }\n const remaining = source.split('\\n')\n const lines = result.source.split('\\n').filter((line) => {\n const index = remaining.indexOf(line)\n if (index !== -1) remaining.splice(index, 1)\n return index === -1\n })\n return { lines: lines.map((line) => line.trim()) }\n } catch (error) {\n return { reason: getErrorMessage(error) }\n }\n}\n\nasync function selectExtension({\n entries,\n versions,\n registry,\n}: {\n entries: Array<RegistryEntry>\n versions: Map<string, unknown>\n registry: string\n}): Promise<string | undefined> {\n if (!entries.length)\n throw new Diagnostics.Error({\n code: Diagnostics.code.unknown,\n severity: 'error',\n message: `The registry at ${registry} lists no extensions.`,\n help: 'Check that `KUBB_REGISTRY` points at a Kubb registry, or unset it to use https://kubb.dev/registry.',\n })\n\n // Filters in memory, so typing never waits on the network.\n const searchText = new Map(entries.map((entry) => [entry.id, `${entry.id} ${entry.manifest.displayName} ${entry.manifest.description}`.toLowerCase()]))\n const options = entries\n .toSorted((a, b) => a.id.localeCompare(b.id))\n .map((entry) => {\n const installed = versions.has(entry.artifact.package)\n return { value: entry.id, label: toShortId(entry.id), hint: installed ? 'installed' : summarize(entry.manifest.description), disabled: installed }\n })\n\n const id = await clack.autocomplete({\n message: `Add an extension · ${entries.length} in the registry`,\n placeholder: 'Search',\n options,\n filter: (search, option) => searchText.get(option.value)?.includes(search.toLowerCase()) ?? false,\n })\n return clack.isCancel(id) ? undefined : id\n}\n\n/** Asks whether to also add the required plugins the config lacks. `--yes` adds them. */\nasync function confirmDependencies({\n entry,\n missing,\n yes,\n}: {\n entry: RegistryEntry\n missing: Array<RegistryEntry>\n yes: boolean\n}): Promise<boolean | undefined> {\n if (!missing.length || yes) return true\n const names = missing.map((dependency) => dependency.manifest.name).join(', ')\n const answer = await clack.select({\n message: `${entry.manifest.name} needs ${names}. Add ${names} as well?`,\n options: [\n { value: true, label: `Yes, add ${missing.length === 1 ? 'both' : 'all'}`, hint: 'recommended' },\n { value: false, label: `Only ${entry.manifest.name}`, hint: 'generate fails until you add it' },\n ],\n initialValue: true,\n })\n return clack.isCancel(answer) ? undefined : answer\n}\n\n/** The first sentence of a registry description, cut to one terminal line. */\nexport function summarize(description: string, max = 64): string {\n const sentence = description.split(/\\.\\s/)[0]!.replace(/\\.$/, '')\n return sentence.length > max ? `${sentence.slice(0, max - 1).trimEnd()}…` : sentence\n}\n\n/**\n * Installs an extension from the Kubb registry at its reviewed version and, for a plugin, adds it to\n * `kubb.config.ts`, offering to add the plugins it needs as well. Without an id, asks which one.\n * Previews the packages and config lines before asking. Refuses when the running Kubb or Node.js\n * version is outside its compatibility.\n */\nexport async function run({ id: input, configPath, yes, install }: AddOptions): Promise<void> {\n const cwd = process.cwd()\n const hrStart = process.hrtime()\n const summary = (title: string, status: Parameters<typeof logCommandSummary>[0]['status'], lines: ReadonlyArray<string>) =>\n logCommandSummary({ title, status, hrStart, block: true, lines })\n const installedPackages: Array<string> = []\n const configured: Array<RegistryEntry> = []\n logIntro({ title: isInteractiveRun({ yes }) ? undefined : styleText('bgCyan', styleText('black', ' Kubb Add ')) })\n\n try {\n const registry = registryUrl()\n if (!input && yes)\n throw new Diagnostics.Error({\n code: Diagnostics.code.unknown,\n severity: 'error',\n message: 'Pass a registry id, such as plugin-zod, when using --yes.',\n help: 'Run `kubb add plugin-zod --yes`, or drop `--yes` to pick from a list.',\n })\n const inputId = input ? toRegistryId(input) : undefined\n const foundConfig = configPath ? path.resolve(configPath) : findConfigFile(cwd)\n const [entries, installed, configSource] = await withSpinner({\n message: 'Reading the registry',\n promise: Promise.all([\n fetchRegistryIndex({ registry }),\n readInstalledPackages({ root: cwd }),\n foundConfig ? read(foundConfig).catch(() => undefined) : undefined,\n ]),\n })\n const versions = new Map(installed.map((item) => [item.package, item.version]))\n\n const id = inputId ?? (await selectExtension({ entries, versions, registry }))\n if (!id) {\n summary('Add canceled', 'canceled', [' No changes made'])\n return\n }\n const entry = entries.find((candidate) => candidate.id === id)\n if (!entry) {\n const suggestions = closestIds({ input: id, ids: entries.map((entry) => entry.id) }).map(toShortId)\n summary(`No extension named ${input ?? id}`, 'failed', [\n ...suggestions.map((suggestion) => ` kubb add ${suggestion}`),\n ' Browse all kubb.dev/extensions',\n ])\n process.exitCode = 1\n return\n }\n const { artifact, manifest } = entry\n const kind = manifest.kind.charAt(0).toUpperCase() + manifest.kind.slice(1)\n\n const problem = incompatibility(manifest)\n if (problem)\n throw new Diagnostics.Error({\n code: Diagnostics.code.incompatibleExtension,\n severity: 'error',\n message: problem,\n help: 'Upgrade Kubb or Node.js to a version the extension supports.',\n })\n\n const configFile = manifest.kind === 'plugin' ? foundConfig : undefined\n if (manifest.kind === 'plugin' && !configFile)\n throw new Diagnostics.Error({\n code: Diagnostics.code.unknown,\n severity: 'error',\n message: 'No kubb.config.ts found. Run `kubb init` first, or pass --config.',\n help: 'Run `kubb init` to create a config, or pass its path with `--config`.',\n })\n const configName = configFile ? path.relative(cwd, configFile) || configFile : undefined\n\n const byName = new Map(entries.map((candidate) => [candidate.manifest.name, candidate]))\n const inConfig = (name: string) => {\n const dependency = byName.get(name)\n return dependency ? !!configSource?.includes(`${dependency.manifest.export}(`) : installed.some((item) => item.manifest?.name === name)\n }\n const dependencies = manifest.dependencies ?? []\n const missing = configFile ? dependencies.filter((name) => !inConfig(name)).flatMap((name) => byName.get(name) ?? []) : []\n const withDependencies = await confirmDependencies({ entry, missing, yes })\n if (withDependencies === undefined) {\n summary('Add canceled', 'canceled', [` ${kind} ${manifest.name}`, ' No changes made'])\n return\n }\n const targets = [...(withDependencies ? missing : []), entry]\n const specs = targets.filter((target) => target === entry || !versions.has(target.artifact.package)).map((target) => installSpec(target.artifact))\n\n const dependencyStatus = (name: string) => {\n if (inConfig(name)) return `${name} ${styleText('green', '✓ installed')}`\n return targets.some((target) => target.manifest.name === name) ? `${name} ${styleText('cyan', '+ adding')}` : `${name} ${styleText('yellow', 'missing')}`\n }\n const preview = configFile && configSource !== undefined ? await previewConfig({ details: targets, source: configSource }) : undefined\n logStep(`${kind} ${styleText('cyan', manifest.name)} v${artifact.version} · ${summarize(manifest.description)}`)\n logBlock([\n ...(dependencies.length ? [`Needs ${dependencies.map(dependencyStatus).join(' ')}`] : []),\n install ? `Installs ${specs.join(' ')}` : 'Installs nothing (--no-install)',\n ...(configName ? [`Config ${configName}`] : [`Config prints the ${manifest.kind} snippet to add`]),\n ...(preview && 'lines' in preview ? preview.lines.map((line) => styleText('green', ` + ${line}`)) : []),\n ...(preview && 'reason' in preview ? [styleText('yellow', ` cannot edit it: ${preview.reason}`)] : []),\n ])\n\n const confirmed = yes || (await clack.confirm({ message: 'Add it?', initialValue: true }))\n if (clack.isCancel(confirmed) || !confirmed) {\n summary('Add canceled', 'canceled', [` ${kind} ${manifest.name}`, ' No changes made'])\n return\n }\n\n const packageManager = detectPackageManager(cwd)\n const packages = () => (install ? `${installedPackages.length} installed with ${packageManager.name}` : 'installation skipped (--no-install)')\n if (install) {\n const names = targets.filter((target) => specs.includes(installSpec(target.artifact))).map((target) => target.artifact.package)\n await installWithSpinner({ packages: specs, names: names.join(', '), packageManager, cwd })\n installedPackages.push(...names)\n }\n\n const unconfigured: Array<RegistryEntry> = configFile ? [] : [entry]\n if (configFile) {\n for (const target of targets) {\n try {\n const { writeConfigEdits } = await import('@kubb/studio')\n const { outcomes, changed } = await writeConfigEdits({ filePath: configFile, ...toConfigEdits([target]) })\n if (!outcomes[0]?.applied) throw new Error(outcomes[0]?.reason ?? 'the config file was not changed')\n if (changed) configured.push(target)\n logStep(`${target.manifest.export}() configured in ${configName}`)\n } catch (error) {\n logWarn(`Could not edit ${configName}: ${getErrorMessage(error)}`)\n unconfigured.push(target)\n }\n }\n }\n\n const manual = unconfigured.length > 0\n if (manual)\n logBlock([\n 'Add the import to your Kubb config and merge the property into its defineConfig call:',\n '',\n ...unconfigured.map((target) => toSnippet(target)),\n ])\n const dependenciesMissing = !withDependencies && missing.length > 0\n const title = manual\n ? `${kind} needs configuration`\n : dependenciesMissing\n ? 'Plugin configured; dependencies missing'\n : configured.length\n ? install\n ? 'Plugin ready'\n : 'Plugin configured'\n : 'Plugin already configured'\n summary(title, manual || dependenciesMissing ? 'warning' : 'success', [\n ` Packages ${packages()}`,\n ...configured.map((target) => styleText('green', ` + ${target.manifest.export}()`)),\n '',\n ...(!install ? [`Install ${specs.join(' ')} to use it.`] : []),\n ...(dependenciesMissing ? [`Missing plugins ${missing.map((target) => target.manifest.name).join(', ')}`] : []),\n manual ? 'Add the snippet above, then run kubb generate.' : 'Next kubb generate',\n `Options kubb.dev/extensions/${entry.id}`,\n ])\n } catch (error) {\n logError(getErrorMessage(error))\n summary('Add failed', 'failed', installedPackages.length ? [` Packages ${installedPackages.join(', ')} installed`] : [' No changes made'])\n process.exitCode = 1\n }\n}\n\nexport const command = define({\n name: 'add',\n description: 'Find and install plugins, adapters, and parsers from the Kubb registry.',\n examples: [\n 'kubb add',\n 'kubb add plugin-zod',\n 'kubb add kubb-labs/plugin-react-query',\n 'kubb add acme/plugin-x --yes',\n 'kubb add plugin-zod --no-install',\n ].join('\\n'),\n toKebab: true,\n args: {\n id: {\n type: 'positional',\n description: 'Registry id: owner/slug, or a slug for an official extension. Asked for when omitted',\n required: false,\n },\n ...configArg,\n ...yesArg,\n install: {\n type: 'boolean',\n description: 'Install the package. Pass --no-install to only edit the config',\n negatable: true,\n default: true,\n },\n },\n run: ({ values }) => run({ id: values.id, configPath: values.config, yes: values.yes, install: values.install }),\n})\n","import path from 'node:path'\nimport process from 'node:process'\nimport { styleText } from 'node:util'\nimport * as clack from '@clack/prompts'\nimport type { DryRunExtension } from '@gunshi/plugin-dryrun'\nimport { defineWithTypes } from 'gunshi'\nimport { generateConfigFile, initDefaults, KUBB_CONFIG_FILENAME, KUBB_PACKAGE_NAME } from '@internals/shared'\nimport { exists, formatMs, getElapsedMs, write } from '@internals/utils'\nimport { createKubb, Diagnostics, type RegistryEntry } from '@kubb/core'\nimport { dryRunId, type DryRunExtensions } from '../../commands/shared.ts'\nimport { getConfigs } from '../../config.ts'\nimport { pluralize } from '../../ui/text.ts'\nimport { isInteractiveRun, logIntro, logOutro } from '../../ui/intro.ts'\nimport { logBlock, logError, logStep, logWarn } from '../../ui/log.ts'\nimport { createSpinner } from '../../ui/spinner.ts'\nimport { fetchRegistryIndex, incompatibility, installSpec, registryUrl } from '../../utils/registry.ts'\nimport { installWithSpinner } from '../installWithSpinner.ts'\nimport {\n addGenerateScript,\n detectPackageManager,\n findPlugin,\n findSpecFiles,\n generateScript,\n initPackageJson,\n installPackages,\n missingPluginDependencies,\n type PackageManagerInfo,\n parsePluginsFlag,\n readSpecInfo,\n} from './utils.ts'\nimport { version } from '../../../package.json'\n\nfunction cancelAndExit(message = 'Operation canceled.'): never {\n clack.cancel(message)\n process.exit(0)\n}\n\nfunction unwrap<T>(value: T): Exclude<T, symbol> {\n if (clack.isCancel(value)) cancelAndExit()\n return value as Exclude<T, symbol>\n}\n\ntype InitOptions = {\n /**\n * When `true`, skips all interactive prompts and uses the detected or default values.\n */\n yes: boolean\n /**\n * Input path flag value from `--input`. When provided, skips the input prompt.\n */\n input?: string\n /**\n * Output directory flag value from `--output`. When provided, skips the output prompt.\n */\n output?: string\n /**\n * Comma-separated plugin list from `--plugins`, e.g. `'plugin-ts,zod'`. When provided, skips the plugin selection prompt.\n */\n plugins?: string\n /**\n * Dry-run extension from `@gunshi/plugin-dryrun`. When enabled, package installation, file\n * writes, and the first run are skipped.\n */\n dryRun: DryRunExtension\n}\n\ntype Choices = {\n inputPath: string\n outputPath: string\n plugins: Array<RegistryEntry>\n}\n\n/** The full `kubb.config.ts` for `choices`, with each plugin added the way `kubb add` adds it. */\nasync function buildConfig({ inputPath, outputPath, plugins }: Choices): Promise<string> {\n const { applyConfigEdits } = await import('@kubb/studio')\n const { source, outcomes } = applyConfigEdits({\n source: generateConfigFile({ inputPath, outputPath }),\n edits: plugins.map((entry) => ({ operation: 'add-plugin', plugin: entry.artifact.package })),\n extensions: new Map(plugins.map(({ artifact, manifest }) => [artifact.package, { package: artifact.package, version: artifact.version, manifest }])),\n })\n const failed = outcomes.find((outcome) => !outcome.applied)\n if (failed && failed.edit.operation === 'add-plugin')\n throw new Diagnostics.Error({\n code: Diagnostics.code.unknown,\n severity: 'error',\n message: `Could not add ${failed.edit.plugin} to ${KUBB_CONFIG_FILENAME}: ${failed.reason}`,\n help: `Run kubb init without that plugin, then add it with kubb add.`,\n })\n return source\n}\n\n/** Generates from the config at `configPath` without reporters, and returns how many files it wrote. */\nasync function firstRun(configPath: string): Promise<number> {\n const { configs } = await getConfigs({ configPath })\n let files = 0\n for (const config of configs) {\n const result = await createKubb(config).generate()\n if (!result.success) throw new Error(result.diagnostics.flatMap((diagnostic) => (diagnostic.severity === 'error' ? [diagnostic.message] : [])).join('\\n'))\n files += result.files.length\n }\n return files\n}\n\n/** The command that runs `kubb generate`: the `generate` script when it runs Kubb, otherwise `npx kubb generate`. */\nfunction generateCommand({ packageManager, script, watch }: { packageManager: PackageManagerInfo; script: string | undefined; watch: boolean }): string {\n if (script !== 'kubb generate') return `npx kubb generate${watch ? ' --watch' : ''}`\n const run = [packageManager.name, ...packageManager.runCommand, 'generate'].join(' ')\n if (!watch) return run\n return packageManager.name === 'npm' ? `${run} -- --watch` : `${run} --watch`\n}\n\n/**\n * Runs the Kubb setup wizard: detects the package manager and specs, asks for the spec, plugins, and\n * output folder, shows the config for review, then installs, writes `kubb.config.ts`, adds a\n * `generate` script, and runs the first generation.\n * Pass `yes: true` to skip all prompts and print one line per step.\n */\nexport async function run({ yes, input: inputFlag, output: outputFlag, plugins: pluginsFlag, dryRun }: InitOptions): Promise<void> {\n const cwd = process.cwd()\n\n /** Runs `task` behind a spinner, or prints one line when it is done in `--yes` mode. */\n async function step<T>({ start, task, done, failed }: { start: string; task: () => Promise<T>; done: (result: T) => string; failed: string }): Promise<T> {\n const spinner = createSpinner()\n if (!yes) spinner.start(start)\n try {\n const result = await task()\n if (yes) console.log(`${styleText('green', '✓')} ${done(result)}`)\n else spinner.stop(done(result))\n return result\n } catch (error) {\n if (!yes) spinner.error(failed)\n throw error\n }\n }\n\n if (!yes) logIntro({ title: isInteractiveRun({ yes, dryRun: dryRun.enabled }) ? undefined : 'Set up Kubb' })\n\n try {\n // Start the registry fetch now but await it only at the plugin step, so the first prompt never waits on the network\n const registry = fetchRegistryIndex({ registry: registryUrl() }).then((entries) =>\n entries.filter((entry) => entry.kind === 'plugin' && !incompatibility(entry.manifest)),\n )\n registry.catch(() => {})\n // Warm the module cache for buildConfig while the user answers, so the review shows up without waiting\n if (!yes) import('@kubb/studio').catch(() => {})\n\n if (!(await exists(path.join(cwd, 'package.json')))) {\n if (!yes) {\n const shouldInit = unwrap(await clack.confirm({ message: 'No package.json found. Would you like to create one?', initialValue: true }))\n if (!shouldInit) cancelAndExit()\n }\n\n const packageManager = detectPackageManager(cwd)\n await step({\n start: `Initializing package.json with ${packageManager.name}`,\n task: () => initPackageJson(cwd, packageManager),\n done: () => `Created package.json with ${packageManager.name}`,\n failed: 'Could not create package.json',\n })\n }\n\n const packageManager = detectPackageManager(cwd)\n const specs = await findSpecFiles(cwd)\n\n if (!yes) {\n logStep(`Package manager ${packageManager.name}`)\n if (specs[0]) {\n const { version: specVersion, operations } = await readSpecInfo(path.join(cwd, specs[0]))\n const details = [\n specs[0].slice(2),\n specVersion ? `${specVersion.startsWith('2') ? 'Swagger' : 'OpenAPI'} ${specVersion}` : undefined,\n operations === undefined ? undefined : pluralize(operations, 'operation'),\n specs.length > 1 ? `+${specs.length - 1} more` : undefined,\n ]\n logStep(`Found ${details.filter(Boolean).join(' · ')}`)\n }\n }\n\n // `--plugins` and `--yes` need the registry before any prompt; the interactive path reads it at the plugin step\n const plugins = pluginsFlag || yes ? await registry : undefined\n const defaultPlugins = (entries: Array<RegistryEntry>) => initDefaults.plugins.flatMap((id) => findPlugin({ plugins: entries, id }) ?? [])\n\n const flagPlugins = pluginsFlag && plugins ? parsePluginsFlag({ plugins, value: pluginsFlag }) : undefined\n\n let choices: Choices = {\n inputPath: inputFlag ?? specs[0] ?? initDefaults.inputPath,\n outputPath: outputFlag ?? initDefaults.outputPath,\n plugins: flagPlugins ?? (plugins ? defaultPlugins(plugins) : []),\n }\n if (yes && !choices.plugins.length) {\n throw new Error('The registry has no default plugin. Pass --plugins to choose one.')\n }\n\n async function askInput(current: string): Promise<string> {\n const choice = specs.length\n ? unwrap(\n await clack.select({\n message: 'Which spec should Kubb read?',\n options: [\n ...specs.map((spec) => ({ value: spec, label: spec, hint: 'found in this repo' })),\n { value: 'url', label: 'A URL' },\n { value: 'file', label: 'Another file' },\n ],\n initialValue: specs.includes(current) ? current : /^https?:\\/\\//.test(current) ? 'url' : 'file',\n }),\n )\n : /^https?:\\/\\//.test(current)\n ? 'url'\n : 'file'\n if (specs.includes(choice)) return choice\n const isUrl = choice === 'url'\n const initial = isUrl === /^https?:\\/\\//.test(current) && !specs.includes(current) ? current : undefined\n return unwrap(\n await clack.text({\n message: isUrl ? 'Spec URL' : 'Spec path',\n placeholder: isUrl ? 'https://example.com/openapi.yaml' : initDefaults.inputPath,\n initialValue: initial,\n defaultValue: isUrl ? undefined : initDefaults.inputPath,\n validate: (value) => {\n if (isUrl && !/^https?:\\/\\//.test(value ?? '')) return 'Enter an http(s) URL'\n },\n }),\n )\n }\n\n async function askPlugins(previous: Array<RegistryEntry>): Promise<Array<RegistryEntry>> {\n const plugins = await registry\n const current = previous.length ? previous : defaultPlugins(plugins)\n const width = Math.max(...plugins.map((entry) => entry.manifest.displayName.length))\n const nameWidth = Math.max(...plugins.map((entry) => entry.manifest.name.length))\n const values = unwrap(\n await clack.multiselect({\n message: 'What should Kubb generate?',\n options: plugins.map(({ id, manifest }) => ({\n value: id,\n label: `${manifest.displayName.padEnd(width)} ${styleText('dim', manifest.name.padEnd(nameWidth))}`.trimEnd(),\n })),\n initialValues: current.map((entry) => entry.id),\n required: true,\n }),\n )\n return plugins.filter((entry) => values.includes(entry.id))\n }\n\n // Flags for all three choices leave nothing to ask or review, as before the review step existed\n const answered = yes || Boolean(inputFlag && outputFlag && pluginsFlag)\n if (!answered) {\n let firstPass = true\n while (true) {\n // The first pass skips the questions a flag answered; \"Change a choice\" asks them all again.\n choices = {\n inputPath: firstPass && inputFlag ? inputFlag : await askInput(choices.inputPath),\n plugins: firstPass && flagPlugins ? flagPlugins : await askPlugins(choices.plugins),\n outputPath:\n firstPass && outputFlag\n ? outputFlag\n : unwrap(await clack.text({ message: 'Output folder', placeholder: choices.outputPath, defaultValue: choices.outputPath })),\n }\n firstPass = false\n const missing = missingPluginDependencies(choices.plugins.map((entry) => entry.manifest))\n if (missing.length) {\n logWarn(`${missing.join('\\n')}\\nAdd the missing plugins.`)\n continue\n }\n const config = await buildConfig(choices)\n const packages = [KUBB_PACKAGE_NAME, ...choices.plugins.map((entry) => entry.artifact.package)]\n logStep(`Review ${KUBB_CONFIG_FILENAME}`)\n logBlock([...config.trimEnd().split('\\n'), '', `${styleText('dim', 'Installs')} ${packages.join(' ')} with ${packageManager.name}`])\n const configExists = await exists(path.join(cwd, KUBB_CONFIG_FILENAME))\n const confirmed = unwrap(\n await clack.select({\n message: configExists ? `${KUBB_CONFIG_FILENAME} exists. Overwrite it?` : 'Create it?',\n options: [\n { value: true, label: 'Yes' },\n { value: false, label: 'Change a choice' },\n ],\n }),\n )\n if (confirmed) break\n }\n }\n\n // Check the selection against the plugins' manifests before installing anything\n const missing = missingPluginDependencies(choices.plugins.map((entry) => entry.manifest))\n if (missing.length) {\n throw new Diagnostics.Error({\n code: Diagnostics.code.missingDependency,\n severity: 'error',\n message: `${missing.join('\\n')}\\nAdd the missing plugins and run kubb init again.`,\n })\n }\n\n const configPath = path.join(cwd, KUBB_CONFIG_FILENAME)\n if (answered && !yes && (await exists(configPath))) {\n const overwrite = unwrap(await clack.confirm({ message: `${KUBB_CONFIG_FILENAME} exists. Overwrite it?`, initialValue: false }))\n if (!overwrite) cancelAndExit('Keeping existing configuration.')\n }\n\n // Install `kubb` at the running CLI's version and each plugin at the version the registry pins\n const packagesToInstall = [`${KUBB_PACKAGE_NAME}@${version}`, ...choices.plugins.map((entry) => installSpec(entry.artifact))]\n const packageNames = [KUBB_PACKAGE_NAME, ...choices.plugins.map((entry) => entry.artifact.package)]\n const dry = { message: `install ${packagesToInstall.length} packages with ${packageManager.name}` }\n if (yes) {\n await step({\n start: '',\n task: async () => void (await dryRun.run(() => installPackages(packagesToInstall, packageManager, cwd), dry)),\n done: () => `Installed ${packageNames.join(' ')} with ${packageManager.name}`,\n failed: 'Installation failed',\n })\n } else {\n await installWithSpinner({\n packages: packagesToInstall,\n names: `${packagesToInstall.length} packages`,\n packageManager,\n cwd,\n install: async (packages, packageManager, cwd, onLine) => void (await dryRun.run(() => installPackages(packages, packageManager, cwd, onLine), dry)),\n })\n }\n\n await step({\n start: `Writing ${KUBB_CONFIG_FILENAME}`,\n task: async () => dryRun.run(async () => void (await write(configPath, await buildConfig(choices))), { message: `write ${KUBB_CONFIG_FILENAME}` }),\n done: () => `Wrote ${KUBB_CONFIG_FILENAME}`,\n failed: `Could not write ${KUBB_CONFIG_FILENAME}`,\n })\n\n const scriptAdded = await dryRun.run(() => addGenerateScript(cwd), {\n message: 'add a generate script to package.json',\n resolve: async () => (await generateScript(cwd)) === undefined,\n })\n if (scriptAdded && !yes) logStep('Added \"generate\": \"kubb generate\" to package.json')\n\n const script = scriptAdded ? 'kubb generate' : await generateScript(cwd)\n const runStart = process.hrtime()\n try {\n await dryRun.run(\n () =>\n step({\n start: 'Running the first generation',\n task: () => firstRun(configPath),\n done: (files) =>\n yes\n ? `Generated ${pluralize(files, 'file')} in ${choices.outputPath}`\n : `First run ${pluralize(files, 'file')} in ${choices.outputPath} · ${formatMs(getElapsedMs(runStart))}`,\n failed: 'First run failed',\n }),\n { message: 'run the first generation', resolve: () => 0 },\n )\n } catch (error) {\n logError(error instanceof Error ? error.message : String(error))\n const message = `Kubb is set up, but the first run failed. Fix the error, then run ${generateCommand({ packageManager, script, watch: false })}.`\n if (yes) console.log(message)\n else logOutro(styleText('yellow', message))\n process.exitCode = 1\n return\n }\n\n if (yes) {\n console.log(`Kubb is set up. Run ${generateCommand({ packageManager, script, watch: false })} after changing the spec.`)\n return\n }\n logOutro(`${styleText('green', '✓ Kubb is set up')}\\n ${styleText('dim', 'Next')} ${generateCommand({ packageManager, script, watch: true })}`)\n } catch (error) {\n logError(styleText('red', 'An error occurred during initialization'))\n if (error instanceof Error) {\n logError(error.message)\n }\n process.exit(1)\n }\n}\n\nexport const command = defineWithTypes<{ extensions: DryRunExtensions }>()({\n name: 'init',\n description: 'Set up a config, install plugins, and run the first generation.',\n examples: [\n 'kubb init',\n 'kubb init --yes',\n 'kubb init --input ./openapi.yaml --output ./src/gen --plugins plugin-ts,plugin-zod',\n 'kubb init --yes --input ./openapi.yaml --plugins ts,zod --output src/api',\n 'kubb init --plugins plugin-ts,plugin-axios,plugin-react-query',\n 'kubb init --yes --dry-run',\n ].join('\\n'),\n toKebab: true,\n args: {\n yes: {\n type: 'boolean',\n description: 'Skip prompts and use the detected spec, the default plugin, and the default output folder',\n short: 'y',\n default: false,\n },\n input: {\n type: 'string',\n description: 'Path to the OpenAPI specification',\n short: 'i',\n metavar: 'path',\n },\n output: {\n type: 'string',\n description: 'Output directory for generated files',\n short: 'o',\n metavar: 'path',\n },\n plugins: {\n type: 'string',\n description:\n 'Comma-separated Kubb registry ids of the plugins to add, the same ids `kubb add` takes (plugin-ts, plugin-zod, acme/plugin-x), or short names (ts, zod)',\n metavar: 'plugin-ts,plugin-zod,...',\n },\n },\n run: ({ values, extensions }) => run({ yes: values.yes, input: values.input, output: values.output, plugins: values.plugins, dryRun: extensions[dryRunId] }),\n})\n","/** Pads each column to its widest cell, one line per row. */\nexport function formatTable(rows: ReadonlyArray<ReadonlyArray<string>>): Array<string> {\n const widths = Array.from({ length: Math.max(0, ...rows.map((row) => row.length)) }, (_, index) => Math.max(...rows.map((row) => row[index]?.length ?? 0)))\n return rows.map((row) =>\n row\n .map((cell, index) => cell.padEnd(widths[index]!))\n .join(' ')\n .trimEnd(),\n )\n}\n","import process from 'node:process'\nimport { styleText } from 'node:util'\nimport { getErrorMessage } from '@internals/utils'\nimport { define } from 'gunshi'\nimport { readInstalledPackages, type RegistryEntry } from '@kubb/core'\nimport { logOutro } from '../../ui/intro.ts'\nimport { logBlock, logError, logWarn } from '../../ui/log.ts'\nimport { formatTable } from '../../ui/table.ts'\nimport { fetchRegistryIndex, isOutdated, registryUrl } from '../../utils/registry.ts'\n\nexport type ListRow = {\n id?: string\n package: string\n installed?: string\n registry?: string\n update: boolean\n}\n\n/**\n * The installed packages that ship a `kubb-extension.json` or have a registry entry, with the\n * version the registry pins.\n */\nexport async function listExtensions({ cwd, registry }: { cwd: string; registry: string }): Promise<Array<ListRow>> {\n const [installed, entries] = await Promise.all([\n readInstalledPackages({ root: cwd }),\n fetchRegistryIndex({ registry }).catch((error: unknown): Array<RegistryEntry> => {\n logWarn(`Showing installed extensions only: ${getErrorMessage(error)}`)\n return []\n }),\n ])\n const byPackage = new Map(entries.map((entry) => [entry.artifact.package, entry]))\n\n return installed.flatMap(({ package: name, version, manifest }): Array<ListRow> => {\n const entry = byPackage.get(name)\n if (!entry && !manifest) return []\n const latest = entry?.artifact.version\n return [{ id: entry?.id, package: name, installed: version, registry: latest, update: !!latest && isOutdated({ installed: version, latest }) }]\n })\n}\n\n/** Prints the installed extensions as a table. */\nexport async function run(): Promise<void> {\n try {\n const rows = await listExtensions({ cwd: process.cwd(), registry: registryUrl() })\n if (!rows.length) {\n logOutro('No installed extensions found.')\n return\n }\n\n const header = ['ID', 'PACKAGE', 'INSTALLED', 'REGISTRY', 'UPDATE']\n const cells = rows.map((row) => [row.id ?? '-', row.package, row.installed ?? '-', row.registry ?? '-', row.update ? 'yes' : 'no'])\n const [head, ...body] = formatTable([header, ...cells])\n logBlock([styleText('dim', head!), ...body])\n } catch (error) {\n logError(getErrorMessage(error))\n process.exitCode = 1\n }\n}\n\nexport const command = define({\n name: 'list',\n description: 'List installed extensions, their versions, and available updates.',\n examples: 'kubb list',\n run: () => run(),\n})\n","import path from 'node:path'\nimport process from 'node:process'\nimport { styleText } from 'node:util'\nimport * as clack from '@clack/prompts'\nimport { defineWithTypes } from 'gunshi'\nimport { findConfigFile } from '@internals/shared'\nimport { getErrorMessage } from '@internals/utils'\nimport { Hookable, type KubbHooks, readInstalledPackages, type RegistryEntry } from '@kubb/core'\nimport { pluralize } from '../../ui/text.ts'\nimport { dryRunId, type DryRunExtensions, yesArg } from '../../commands/shared.ts'\nimport { isInteractiveRun, logIntro } from '../../ui/intro.ts'\nimport { logBlock, logError, logStep, logWarn } from '../../ui/log.ts'\nimport { createSpinner, withSpinner } from '../../ui/spinner.ts'\nimport { logCommandSummary } from '../../ui/summary.ts'\nimport { formatTable } from '../../ui/table.ts'\nimport { bumpOf, fetchRegistryIndex, incompatibility, installSpec, isOutdated, registryUrl, toRegistryId, toShortId } from '../../utils/registry.ts'\nimport { detectPackageManager } from '../init/utils.ts'\nimport { installWithSpinner } from '../installWithSpinner.ts'\nimport { diffFiles, type FileChange, readOutputFiles } from '../generate/utils.ts'\n\nexport type UpdateOptions = {\n /**\n * Registry ids to update. Empty updates every installed extension the registry lists.\n */\n ids: Array<string>\n /**\n * List the updates without installing anything.\n */\n dryRun: boolean\n yes: boolean\n}\n\n/**\n * Generates every config in this process, the way `kubb generate` does, and returns the output files\n * it changed. Runs after the install, so the config loads the new versions. `undefined` when the\n * config fails to load or a build fails.\n */\nasync function regenerate({\n cwd,\n configPath,\n}: {\n cwd: string\n configPath: string\n}): Promise<{ files: Array<FileChange>; unchanged: number; output: string } | undefined> {\n const spinner = createSpinner()\n spinner.start('Generating with the new versions')\n try {\n // Imported here, so the config loader and the generate path never slow down `kubb --help`.\n const [{ getConfigs }, { generate }] = await Promise.all([import('../../config.ts'), import('../generate/run.ts')])\n const { configs } = await getConfigs({ configPath })\n const dirs = configs.map((config) => path.resolve(config.root ?? cwd, config.output.path))\n const before = new Map((await Promise.all(dirs.map(readOutputFiles))).flatMap((files) => [...files]))\n const hooks = new Hookable<KubbHooks>()\n for (const config of configs) {\n if (!(await generate({ config, hooks }))) throw new Error('Generation failed')\n }\n const after = new Map((await Promise.all(dirs.map(readOutputFiles))).flatMap((files) => [...files]))\n const diff = diffFiles(before, after)\n spinner.stop(diff.files.length ? `Generated: ${pluralize(diff.files.length, 'file')} changed` : 'Generated: no files changed')\n return { ...diff, output: dirs.map((dir) => path.relative(cwd, dir) || '.').join(', ') }\n } catch (error) {\n spinner.error(`Generation failed: ${getErrorMessage(error)}`)\n return undefined\n }\n}\n\n/**\n * Moves installed extensions to the version the registry pins. Shows each version change with its\n * bump, asks which to install with majors left out, installs them, and regenerates to show which\n * files changed. With `dryRun`, only lists the updates and installs nothing.\n */\nexport async function run({ ids, dryRun, yes }: UpdateOptions): Promise<void> {\n const cwd = process.cwd()\n const hrStart = process.hrtime()\n const installedPackages: Array<string> = []\n const summary = (title: string, status: Parameters<typeof logCommandSummary>[0]['status'], lines: ReadonlyArray<string>) =>\n logCommandSummary({ title, status, hrStart, block: true, lines })\n logIntro({ title: isInteractiveRun({ yes, dryRun }) ? undefined : styleText('bgCyan', styleText('black', ' Kubb Update ')) })\n\n try {\n const wanted = new Set(ids.map(toRegistryId))\n const [entries, installed] = await withSpinner({\n message: 'Checking the registry',\n promise: Promise.all([fetchRegistryIndex({ registry: registryUrl() }), readInstalledPackages({ root: cwd })]),\n })\n const versions = new Map(installed.map((item) => [item.package, item.version]))\n\n const tracked = entries.filter((entry) => versions.has(entry.artifact.package) && (!wanted.size || wanted.has(entry.id)))\n for (const id of wanted) {\n if (!tracked.some((entry) => entry.id === id)) logWarn(`${id} is not installed, or not in the registry.`)\n }\n\n const current = ({ artifact }: RegistryEntry) => versions.get(artifact.package)\n const isMajor = (entry: RegistryEntry) => bumpOf({ installed: current(entry), latest: entry.artifact.version }) === 'major'\n const outdated = tracked.filter((entry) => isOutdated({ installed: current(entry), latest: entry.artifact.version }))\n const proposals = outdated.filter((entry) => {\n const problem = incompatibility(entry.manifest)\n if (problem) logWarn(`Skipped ${entry.id}: ${problem}`)\n return !problem\n })\n\n if (!proposals.length) {\n const title = outdated.length ? 'No compatible updates available' : 'Already up to date'\n summary(tracked.length ? title : 'No installed extensions to update', outdated.length ? 'warning' : 'success', [\n ` ${tracked.length - outdated.length} of ${tracked.length} up to date`,\n ...(ids.length ? ['', `No updates for ${ids.join(', ')}.`] : []),\n ])\n return\n }\n\n if (tracked.length) {\n const header = ['Extension', 'Current', 'Latest', '']\n const rows = tracked.map((entry) => {\n if (!outdated.includes(entry)) return [entry.artifact.package, current(entry) ?? '-', 'up to date', '']\n const bump = bumpOf({ installed: current(entry), latest: entry.artifact.version }) ?? ''\n return [entry.artifact.package, current(entry) ?? 'not installed', entry.artifact.version, bump === 'major' ? 'major · breaking' : bump]\n })\n const lines = formatTable([header, ...rows])\n logStep(`Checked ${pluralize(tracked.length, 'extension')} against the registry`)\n logBlock([\n styleText('dim', lines[0]!),\n ...lines.slice(1).map((line, index) => {\n if (!outdated.includes(tracked[index]!)) return styleText('dim', line)\n return line.endsWith('major · breaking') ? styleText('yellow', line) : line\n }),\n ])\n }\n\n if (dryRun) {\n summary('Updates available', 'planned', [`Dry run: nothing was installed. Run kubb update to install ${proposals.length === 1 ? 'it' : 'them'}.`])\n return\n }\n\n // A major can break the generated code, so it is never picked for you.\n const defaults = proposals.filter((entry) => !isMajor(entry))\n const chosen = yes\n ? defaults.map((entry) => entry.id)\n : await clack.multiselect({\n message: 'Select the updates to install',\n options: proposals.map((entry) => ({\n value: entry.id,\n label: entry.artifact.package,\n hint: `${current(entry) ?? 'not installed'} → ${entry.artifact.version}`,\n })),\n initialValues: defaults.map((entry) => entry.id),\n required: false,\n })\n if (clack.isCancel(chosen)) {\n summary('Update canceled', 'canceled', [' No changes made'])\n return\n }\n const selected = proposals.filter((entry) => chosen.includes(entry.id))\n\n const skipped = proposals\n .filter((entry) => !selected.includes(entry))\n .map((entry) => {\n const kind = entry.manifest.kind.charAt(0).toUpperCase() + entry.manifest.kind.slice(1)\n return ` ${styleText('dim', 'Skipped')} ${kind} ${entry.artifact.package} ${entry.artifact.version} ${styleText('dim', `run kubb update ${toShortId(entry.id)} later`)}`\n })\n if (!selected.length) {\n summary('No updates installed', 'canceled', [' No updates selected.', ...skipped])\n return\n }\n\n const packageManager = detectPackageManager(cwd)\n const names = selected.map(({ artifact }) => artifact.package).join(', ')\n await installWithSpinner({\n packages: selected.map(({ artifact }) => installSpec(artifact)),\n names,\n packageManager,\n cwd,\n })\n installedPackages.push(...selected.map((entry) => entry.artifact.package))\n\n // Regenerating rewrites output files, so it is asked for. `--yes` only accepts the install.\n const foundConfig = findConfigFile(cwd)\n const regenerateNow =\n foundConfig && !yes && (await clack.confirm({ message: 'Regenerate now? This rewrites the generated files.', initialValue: true })) === true\n const configPath = regenerateNow ? foundConfig : undefined\n const changed = configPath ? await regenerate({ cwd, configPath }) : undefined\n\n const generationFailed = Boolean(configPath && !changed)\n const fileCounts = { A: 0, M: 0, D: 0 }\n for (const file of changed?.files ?? []) fileCounts[file.status]++\n summary(generationFailed ? 'Extensions updated; generation failed' : 'Update complete', generationFailed ? 'warning' : 'success', [\n ` Packages ${selected.length} installed with ${packageManager.name}${skipped.length ? ` · ${skipped.length} skipped` : ''}`,\n ...skipped,\n ...(changed ? [` Files ${fileCounts.A} added · ${fileCounts.M} modified · ${fileCounts.D} deleted`] : []),\n ...(!configPath ? [' Regeneration not run'] : []),\n ...(generationFailed ? ['', 'Fix the generation error, then run kubb generate.'] : []),\n ])\n } catch (error) {\n logError(getErrorMessage(error))\n summary('Update failed', 'failed', installedPackages.length ? [` Packages ${installedPackages.join(', ')} installed`] : [' No changes made'])\n process.exitCode = 1\n }\n}\n\nexport const command = defineWithTypes<{ extensions: DryRunExtensions }>()({\n name: 'update',\n description: 'Update installed extensions, regenerate, and summarize file changes.',\n examples: ['kubb update', 'kubb update --dry-run', 'kubb update plugin-zod plugin-ts --yes'].join('\\n'),\n args: {\n ids: {\n type: 'positional',\n description: 'Registry ids to update, all installed extensions when omitted',\n multiple: true,\n },\n ...yesArg,\n },\n run: ({ values, extensions }) => run({ ids: values.ids ?? [], dryRun: extensions[dryRunId].enabled, yes: values.yes }),\n})\n","import { styleText } from 'node:util'\nimport dryrun from '@gunshi/plugin-dryrun'\nimport { cli } from 'gunshi'\nimport { isDisabled as isTelemetryDisabled } from './Telemetry.ts'\nimport { version } from '../package.json'\nimport { getBanner, wantsMascot } from './ui/mascot.ts'\nimport { command as generateCommand } from './commands/generate.ts'\nimport { command as mcpCommand } from './commands/mcp.ts'\nimport { command as studioCommand, routeStudioFlags } from './commands/studio/index.ts'\nimport { command as validateCommand } from './commands/validate.ts'\nimport { resolveDeprecatedFlags } from './deprecatedFlags.ts'\nimport { command as addCommand } from './runners/add/run.ts'\nimport { command as initCommand } from './runners/init/run.ts'\nimport { command as listCommand } from './runners/list/run.ts'\nimport { command as updateCommand } from './runners/update/run.ts'\n\n/** Flags that short-circuit execution (help and version). The telemetry notice is suppressed for these. */\nconst QUIET_FLAGS = new Set<string>(['--help', '-h', '--version', '-v', '--json'])\n\n/**\n * Entry point for the `kubb` CLI. Prints the telemetry notice unless telemetry is disabled or a\n * quiet flag is passed, then runs the given command, or `generate` when none is given.\n */\nexport async function run(argv: Array<string> = process.argv.slice(2)): Promise<void> {\n const args = routeStudioFlags(resolveDeprecatedFlags(argv))\n const isQuietFlag = args.some((arg) => QUIET_FLAGS.has(arg))\n // `--reporter json` and `--json` own stdout, so the header must not land there.\n const isJsonOutput =\n args.includes('--json') || args.some((arg, index) => /^--reporter=.*\\bjson\\b/.test(arg) || (arg === '--reporter' && /\\bjson\\b/.test(args[index + 1] ?? '')))\n\n // stderr, so the notice never lands in a stream a client parses, such as `kubb mcp` stdio.\n if (!isTelemetryDisabled() && !isQuietFlag) {\n console.error(\n `${styleText('yellow', 'Notice:')} Kubb collects anonymous telemetry data to help improve the tool. No personal data or file contents are collected. \\nTo disable, set ${styleText('cyan', 'KUBB_DISABLE_TELEMETRY=1')}.\\n`,\n )\n }\n\n // validate, mcp and studio import their runner when they run, so an optional peer (@kubb/adapter-oas, @kubb/mcp, @kubb/studio) loads only then.\n await cli(args, generateCommand, {\n name: 'kubb',\n version,\n // Not `generateCommand.description`: gunshi prints this on every subcommand's help too, so\n // `kubb studio --help` would open with a paragraph about generating types.\n description: 'Generate code from an OpenAPI specification, manage Kubb extensions, or connect the project to Kubb Studio.',\n subCommands: {\n generate: generateCommand,\n init: initCommand,\n validate: validateCommand,\n mcp: mcpCommand,\n studio: studioCommand,\n add: addCommand,\n update: updateCommand,\n list: listCommand,\n },\n fallbackToEntry: true,\n // The mascot opens only the long-running commands; `generate` turns this off and plays its animated banner instead.\n renderHeader: isJsonOutput\n ? null\n : async (ctx) => {\n if (!wantsMascot({ commandPath: ctx.commandPath, values: ctx.values })) return ''\n\n // Gunshi adds a blank line after returned headers; the first prompt already supplies its guide.\n ctx.log(getBanner(version, ctx.commandPath.join(' ') || 'generate'))\n return ''\n },\n strict: true,\n plugins: [dryrun({ name: 'dry-run' })],\n onErrorCommand: async (_ctx, error) => {\n process.exitCode = 1\n console.error(error)\n },\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAUA,MAAa,YAAY,EACvB,QAAQ;CACN,MAAM;CACN,aAAa;CACb,OAAO;AACT,EACF;AAEA,MAAa,SAAS,EACpB,KAAK;CACH,MAAM;CACN,aAAa;CACb,OAAO;CACP,SAAS;AACX,EACF;AAEA,MAAa,cAAc,EACzB,UAAU;CACR,MAAM;CACN,SAAS;EAAC;EAAU;EAAQ;CAAS;CACrC,aAAa;CACb,OAAO;CACP,SAAS;CACT,SAAS;AACX,EACF;AAEA,MAAa,uBAAuB;CAClC,KAAK;EACH,MAAM;EACN,aAAa;CACf;CACA,OAAO;EACL,MAAM;EACN,aAAa;CACf;AACF;AAEA,MAAa,uBAAuB;CAClC,WAAW;EACT,MAAM;EACN,aAAa;EACb,SAAS;EACT,SAAS;CACX;CACA,cAAc;EACZ,MAAM;EACN,aAAa;EACb,SAAS;EACT,SAAS;CACX;CACA,YAAY;EACV,MAAM;EACN,aAAa;EACb,SAAS;EACT,SAAS;CACX;CACA,iBAAiB;EACf,MAAM;EACN,aAAa;EACb,SAAS;EACT,SAAS;CACX;CACA,WAAW;EACT,MAAM;EACN,aAAa;EACb,SAAS;EACT,SAAS;CACX;AACF;;;AC5EA,MAAM,iBAAsC;CAAC;CAAO;CAAQ;CAAQ;AAAM;;;;AAK1E,SAAS,eAAe,OAAoC;CAC1D,MAAM,QAAQ,MACX,MAAM,GAAG,CAAC,CACV,KAAK,SAAS,KAAK,KAAK,CAAC,CAAC,CAC1B,OAAO,OAAO;CAEjB,KAAK,MAAM,QAAQ,OAC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AAAA,CAAO,EAAE,MAAM,UAAU,CAAC,CAAC;EACrC,gBAAgB,OAAO,MAAM,UAAU;GACrC,QAAQ,WAAW;GACnB,QAAQ,MAAM,KAAK;EACrB;CACF,CAAC;AACH"}
1
+ {"version":3,"file":"index.cjs","names":["Diagnostics","command","defineWithTypes","dryRunId","command","define","define","command","command","connectCommand","command","command","define","command","connectCommand","define","command","process","command","define","connectCommand","startCommand","loginCommand","logoutCommand","statusCommand","snapshotCommand","command","define","styleText","process","path","fs","x","read","Diagnostics","write","process","formatMs","getElapsedMs","isRichOutput","clack","createSpinner","getErrorMessage","Diagnostics","toShortId","clack","run","process","logCommandSummary","isInteractiveRun","styleText","registryUrl","toRegistryId","path","findConfigFile","withSpinner","fetchRegistryIndex","readInstalledPackages","read","closestIds","incompatibility","installSpec","command","define","clack","Diagnostics","KUBB_CONFIG_FILENAME","getConfigs","createKubb","run","process","createSpinner","styleText","isInteractiveRun","fetchRegistryIndex","registryUrl","incompatibility","exists","path","pluralize","initDefaults","KUBB_PACKAGE_NAME","version","installSpec","write","formatMs","getElapsedMs","command","defineWithTypes","dryRunId","readInstalledPackages","fetchRegistryIndex","getErrorMessage","isOutdated","run","process","registryUrl","styleText","command","define","createSpinner","path","readOutputFiles","Hookable","diffFiles","pluralize","getErrorMessage","run","process","logCommandSummary","isInteractiveRun","styleText","toRegistryId","withSpinner","fetchRegistryIndex","registryUrl","readInstalledPackages","bumpOf","isOutdated","incompatibility","clack","toShortId","installSpec","findConfigFile","defineWithTypes","dryRunId","isTelemetryDisabled","styleText","cli","generateCommand","initCommand","validateCommand","mcpCommand","studioCommand","addCommand","updateCommand","listCommand","wantsMascot","getBanner","version","dryrun"],"sources":["../src/commands/shared.ts","../src/commands/generate.ts","../src/commands/mcp.ts","../src/commands/studio/studioCommand.ts","../src/commands/studio/connect.ts","../src/commands/studio/login.ts","../src/commands/studio/logout.ts","../src/commands/studio/snapshot.ts","../src/commands/studio/background.ts","../src/commands/studio/status.ts","../src/commands/studio/index.ts","../src/commands/validate.ts","../src/deprecatedFlags.ts","../../../internals/shared/src/init.ts","../src/runners/init/utils.ts","../src/runners/installWithSpinner.ts","../src/runners/add/run.ts","../src/runners/init/run.ts","../src/ui/table.ts","../src/runners/list/run.ts","../src/runners/update/run.ts","../src/index.ts"],"sourcesContent":["import { pluginId as dryRunId } from '@gunshi/plugin-dryrun'\nimport type { DryRunExtension } from '@gunshi/plugin-dryrun'\n\nexport { dryRunId }\n\n/** Extension shape gunshi's command context carries with `@gunshi/plugin-dryrun`; the `extensions` type parameter of `defineWithTypes`. */\nexport type DryRunExtensions = {\n [dryRunId]: DryRunExtension\n}\n\nexport const configArg = {\n config: {\n type: 'string',\n description: 'Path to the Kubb config',\n short: 'c',\n },\n} as const\n\nexport const yesArg = {\n yes: {\n type: 'boolean',\n description: 'Skip the confirmation',\n short: 'y',\n default: false,\n },\n} as const\n\nexport const logLevelArg = {\n logLevel: {\n type: 'enum',\n choices: ['silent', 'info', 'verbose'] as const,\n description: 'Info, silent or verbose',\n short: 'l',\n default: 'info',\n toKebab: true,\n },\n} as const\n\nexport const studioConnectionArgs = {\n url: {\n type: 'string',\n description: 'Base URL of the Kubb Studio instance',\n },\n token: {\n type: 'string',\n description: 'Organization CI API key for `snapshot`. Defaults to KUBB_TOKEN',\n },\n} as const\n\nexport const studioPermissionArgs = {\n allowRead: {\n type: 'boolean',\n description: 'Read the source of files a generation produced. Asked for once per project when omitted',\n default: false,\n toKebab: true,\n },\n allowReadAst: {\n type: 'boolean',\n description: 'Read the parsed spec (the Kubb AST). Asked for once per project when omitted',\n default: false,\n toKebab: true,\n },\n allowWrite: {\n type: 'boolean',\n description: 'Write generated files to disk. Asked for once per project when omitted',\n default: false,\n toKebab: true,\n },\n allowConfigEdit: {\n type: 'boolean',\n description: 'Let Studio change plugin options in kubb.config.ts. Asked for once per project when omitted',\n default: false,\n toKebab: true,\n },\n allowInstall: {\n type: 'boolean',\n description: 'Let Studio install extensions from the registry with kubb add; needs --allow-config-edit too. Asked for once per project when omitted',\n default: false,\n toKebab: true,\n },\n allowUpdate: {\n type: 'boolean',\n description: 'Let Studio update installed extensions with kubb update. Asked for once per project when omitted',\n default: false,\n toKebab: true,\n },\n allowSaveInput: {\n type: 'boolean',\n description: 'Let Studio save the spec it sends as the input in kubb.config.ts; needs --allow-config-edit too. Asked for once per project when omitted',\n default: false,\n toKebab: true,\n },\n allowExec: {\n type: 'boolean',\n description: 'Run the formatter, the linter, and output.postGenerate after a generation',\n default: false,\n toKebab: true,\n },\n} as const\n","import { defineWithTypes } from 'gunshi'\nimport { Diagnostics, type ReporterName } from '@kubb/core'\nimport { configArg, dryRunId, type DryRunExtensions, logLevelArg } from './shared.ts'\n\nconst REPORTER_NAMES: Array<ReporterName> = ['cli', 'json', 'file', 'html']\n\n/**\n * Splits and validates the comma-separated `--reporter` value against the known reporter names.\n */\nfunction parseReporters(value: string): Array<ReporterName> {\n const names = value\n .split(',')\n .map((name) => name.trim())\n .filter(Boolean)\n\n for (const name of names) {\n if (!REPORTER_NAMES.includes(name as ReporterName)) {\n throw new Diagnostics.Error({\n code: Diagnostics.code.unknown,\n severity: 'error',\n message: `must be one of cli, json, file, html (got \"${name}\")`,\n help: 'Use one of cli, json, file, html.',\n })\n }\n }\n\n return names as Array<ReporterName>\n}\n\n/**\n * Resolves the effective log level, letting the `--verbose` and `--silent` flags win over `--log-level`.\n */\nfunction resolveLogLevel({ verbose, silent, logLevel }: { verbose: boolean; silent: boolean; logLevel: string }): string {\n if (verbose) return 'verbose'\n if (silent) return 'silent'\n return logLevel\n}\n\nexport const command = defineWithTypes<{ extensions: DryRunExtensions }>()({\n name: 'generate',\n // The runner plays the animated mascot itself, so the shared header would print it twice.\n rendering: { header: null },\n description: 'Generate types, clients, hooks, and schemas from an OpenAPI specification.',\n examples: [\n 'kubb generate # generate from kubb.config.ts',\n 'kubb generate ./openapi.yaml # generate from this spec instead of the config input',\n 'kubb generate --config kubb.config.ts',\n 'kubb generate --watch # regenerate whenever the spec changes',\n 'kubb generate --dry-run # preview the run without writing files',\n 'kubb generate --reporter html # write an HTML run report',\n 'kubb studio # connect this project to Kubb Studio and generate from the browser',\n 'kubb studio --allow-write # let Studio write the generated files to disk',\n 'kubb studio login # pair this machine with Studio without connecting',\n ].join('\\n'),\n toKebab: true,\n args: {\n input: {\n type: 'positional',\n required: false,\n description: 'Path to the OpenAPI specification, overriding the config',\n },\n ...configArg,\n ...logLevelArg,\n watch: {\n type: 'boolean',\n description: 'Watch mode: rebuilds when the local input file changes',\n short: 'w',\n default: false,\n },\n verbose: {\n type: 'boolean',\n description: 'Override logLevel to verbose',\n default: false,\n },\n silent: {\n type: 'boolean',\n description: 'Override logLevel to silent',\n short: 's',\n default: false,\n },\n reporter: {\n type: 'custom',\n description: 'Reporters that render the run: cli, json, file, html. Comma-separated. Overrides config.reporters',\n metavar: 'cli|json|file|html',\n parse: parseReporters,\n },\n },\n async run(ctx) {\n const { values } = ctx\n const logLevel = resolveLogLevel(values)\n const { run } = await import('../runners/generate/run.ts')\n\n await run({\n input: values.input,\n configPath: values.config,\n logLevel,\n watch: values.watch,\n reporters: values.reporter,\n dryRun: ctx.extensions[dryRunId].enabled,\n })\n },\n})\n","import { define } from 'gunshi'\n\n/** The runner is imported when the command runs, so listing `kubb --help` never loads `@kubb/mcp`. */\nexport const command = define({\n name: 'mcp',\n description: 'Start an MCP server for code generation from an AI assistant.',\n examples: ['kubb mcp', '# Then add to your MCP client config:', '# { \"mcpServers\": { \"kubb\": { \"command\": \"npx\", \"args\": [\"kubb\", \"mcp\"] } } }'].join('\\n'),\n // gunshi prints the header to stdout, which the MCP stdio transport owns.\n rendering: { header: null },\n async run() {\n const { run } = await import('../runners/mcp/run.ts')\n await run()\n },\n})\n","import { type Args, define } from 'gunshi'\nimport type { StudioOptions, StudioValues } from '../../runners/studio/run.ts'\n\n/**\n * Defines a `kubb studio` subcommand. The runner, and with it `@kubb/studio`, loads only when the\n * command runs, so `kubb --help` never does.\n */\nexport function studioCommand({\n action,\n block,\n ...definition\n}: {\n name: string\n description: string\n examples?: string\n args?: Args\n /** Opens a block a later `logOutro` closes, for a command that keeps running. */\n block?: boolean\n /** The command body, given the options built from its flags. */\n action: (options: StudioOptions) => Promise<unknown>\n}) {\n return define({\n ...definition,\n toKebab: true,\n async run({ values }) {\n const { runStudio } = await import('../../runners/studio/run.ts')\n await runStudio(values as StudioValues, action, { block })\n },\n })\n}\n","import { configArg, logLevelArg, studioConnectionArgs, studioPermissionArgs } from '../shared.ts'\nimport { studioCommand } from './studioCommand.ts'\n\nexport const command = studioCommand({\n name: 'connect',\n description: 'Connect this project to Kubb Studio and generate from the browser.',\n examples: [\n 'kubb studio connect',\n 'kubb studio connect --allow-read',\n 'kubb studio connect --allow-write --allow-exec',\n 'kubb studio connect --url http://localhost:3000',\n ].join('\\n'),\n args: {\n ...configArg,\n ...studioConnectionArgs,\n ...studioPermissionArgs,\n open: {\n type: 'boolean',\n description: 'Open the approval page in a browser while pairing',\n default: true,\n negatable: true,\n },\n ...logLevelArg,\n },\n block: true,\n async action(options) {\n const { connect } = await import('../../runners/studio/run.ts')\n await connect(options)\n },\n})\n","import { command as connectCommand } from './connect.ts'\nimport { studioCommand } from './studioCommand.ts'\n\nexport const command = studioCommand({\n name: 'login',\n description: 'Pair this machine with Kubb Studio without connecting.',\n examples: ['kubb studio login', 'kubb studio login --url http://localhost:3000'].join('\\n'),\n args: connectCommand.args,\n async action(options) {\n const { login } = await import('../../runners/studio/run.ts')\n await login(options)\n },\n})\n","import { studioCommand } from './studioCommand.ts'\n\nexport const command = studioCommand({\n name: 'logout',\n description: 'Forget the stored Kubb Studio token.',\n examples: 'kubb studio logout',\n args: {},\n async action() {\n const { stopWorker } = await import('../../runners/studio/background.ts')\n const { clearCredentials } = await import('../../runners/studio/credentials.ts')\n await stopWorker()\n await clearCredentials()\n console.log('Signed out of Kubb Studio.')\n },\n})\n","import { define } from 'gunshi'\nimport { configArg, logLevelArg, studioConnectionArgs } from '../shared.ts'\n\nexport const command = define({\n name: 'snapshot',\n description: 'Generate and publish a Kubb Studio snapshot from CI.',\n examples: ['kubb studio snapshot', 'kubb studio snapshot --json'].join('\\n'),\n toKebab: true,\n args: {\n ...configArg,\n ...studioConnectionArgs,\n id: {\n type: 'string',\n description: 'Stable identity for the CI agent, such as a pull request. Auto-detected on GitHub Actions, GitLab CI, Bitbucket Pipelines and CircleCI',\n },\n baseId: {\n type: 'string',\n description:\n \"Identity of another CI agent, such as the base branch's, to also compare this snapshot with. Auto-detected on GitHub pull requests and GitLab merge requests\",\n toKebab: true,\n },\n name: {\n type: 'string',\n description: 'Package name for the generated tarball. Defaults to the name in package.json',\n },\n packageVersion: {\n type: 'string',\n description: 'Package version for the generated tarball. Defaults to the version in package.json',\n toKebab: true,\n },\n json: {\n type: 'boolean',\n description: 'Print the result as one JSON object instead of a summary',\n default: false,\n },\n ...logLevelArg,\n },\n async run(ctx) {\n const { runner } = await import('../../runners/studio/snapshot.ts')\n await runner(ctx)\n },\n})\n","import { define } from 'gunshi'\nimport { command as connectCommand } from './connect.ts'\nimport { studioCommand } from './studioCommand.ts'\n\nexport const command = studioCommand({\n name: 'start',\n description: 'Keep this project connected to Kubb Studio in the background.',\n args: connectCommand.args,\n async action(options) {\n const { startWorker } = await import('../../runners/studio/background.ts')\n await startWorker(options)\n },\n})\n\nexport const stopCommand = define({\n name: 'stop',\n description: \"Stop this project's background connection and keep its pairing.\",\n async run() {\n const { stopWorker } = await import('../../runners/studio/background.ts')\n await stopWorker()\n console.log('Background connection stopped.')\n },\n})\n","import process from 'node:process'\nimport { studioConnectionArgs } from '../shared.ts'\nimport { studioCommand } from './studioCommand.ts'\n\nexport const command = studioCommand({\n name: 'status',\n description: 'Show the project worker, Kubb Studio pairing, and saved permissions.',\n examples: 'kubb studio status',\n args: { url: studioConnectionArgs.url },\n async action(options) {\n const { getWorkerLogPath, getWorkerStatus } = await import('../../runners/studio/background.ts')\n const { readCredentials } = await import('../../runners/studio/credentials.ts')\n const { formatStatus } = await import('../../runners/studio/status.ts')\n\n const [worker, credentials] = await Promise.all([getWorkerStatus(), readCredentials()])\n console.log(\n ['', ...formatStatus({ studioUrl: options.studioUrl, credentials, worker, project: process.cwd(), logPath: getWorkerLogPath() }), ''].join('\\n'),\n )\n },\n})\n","import { define } from 'gunshi'\nimport { command as connectCommand } from './connect.ts'\nimport { command as loginCommand } from './login.ts'\nimport { command as logoutCommand } from './logout.ts'\nimport { command as snapshotCommand } from './snapshot.ts'\nimport { command as startCommand, stopCommand } from './background.ts'\nimport { command as statusCommand } from './status.ts'\n\nexport const command = define({\n ...connectCommand,\n name: 'studio',\n description: 'Connect this project to Kubb Studio, or manage its pairing and snapshots.',\n examples: ['kubb studio', 'kubb studio --allow-read', 'kubb studio login', 'kubb studio status', 'kubb studio logout', 'kubb studio snapshot'].join('\\n'),\n subCommands: {\n start: startCommand,\n stop: stopCommand,\n connect: connectCommand,\n login: loginCommand,\n logout: logoutCommand,\n status: statusCommand,\n snapshot: snapshotCommand,\n },\n})\n\n/**\n * Sends `kubb studio --flag value` to `kubb studio connect`, the same runner. gunshi picks a\n * subcommand from the first token that is not a flag, so `--url http://…` would read the URL as one.\n */\nexport function routeStudioFlags(args: Array<string>): Array<string> {\n const [name, next] = args\n if (name !== 'studio' || !next?.startsWith('-') || next === '--help' || next === '-h') return args\n\n return ['studio', 'connect', ...args.slice(1)]\n}\n","import { define } from 'gunshi'\nimport { configArg } from './shared.ts'\n\n/** The runner is imported when the command runs, so listing `kubb --help` never loads `@kubb/adapter-oas`. */\nexport const command = define({\n name: 'validate',\n description: 'Check a specification with the configured adapter before generating.',\n examples: ['kubb validate ./openapi.yaml', 'kubb validate https://petstore3.swagger.io/api/v3/openapi.json'].join('\\n'),\n args: {\n ...configArg,\n input: {\n type: 'positional',\n description: 'Path or URL to the specification to validate',\n required: true,\n },\n },\n async run({ values }) {\n const { run } = await import('../runners/validate/run.ts')\n await run({ input: values.input, configPath: values.config })\n },\n})\n","import { styleText } from 'node:util'\n\n/**\n * Maps each camelCase flag removed in favor of kebab-case (kubb-labs/kubb#4046) to its\n * replacement. Drop this table, and the rewrite it drives, once the deprecation window ends.\n */\nconst DEPRECATED_FLAGS: Record<string, string> = {\n allowWrite: 'allow-write',\n allowConfigEdit: 'allow-config-edit',\n allowExec: 'allow-exec',\n logLevel: 'log-level',\n dryRun: 'dry-run',\n packageVersion: 'package-version',\n}\n\n/** Flags a single command renamed, rewritten only for that command, since the old name is a common word. */\nconst DEPRECATED_COMMAND_FLAGS: Record<string, Record<string, string>> = {\n update: { check: 'dry-run' },\n}\n\nconst FLAG_PATTERN = /^--([a-zA-Z][\\w-]*)(=.*)?$/\n\n/**\n * Rewrites a deprecated camelCase flag to its kebab-case replacement and warns on stderr, so a\n * script written against the old flag names keeps working during the deprecation window instead\n * of failing with an unknown-option error.\n */\nexport function resolveDeprecatedFlags(args: Array<string>): Array<string> {\n const commandFlags = DEPRECATED_COMMAND_FLAGS[args[0] ?? ''] ?? {}\n\n return args.map((arg) => {\n const match = FLAG_PATTERN.exec(arg)\n const name = match?.[1]\n const replacement = name ? (DEPRECATED_FLAGS[name] ?? commandFlags[name]) : undefined\n\n if (!name || !replacement) {\n return arg\n }\n\n console.error(\n `${styleText('yellow', 'Warning:')} --${name} is deprecated, use --${replacement} instead. --${name} will be removed in a future major version.`,\n )\n\n return `--${replacement}${match?.[2] ?? ''}`\n })\n}\n","/** The `kubb.config.ts` `kubb init` writes before `kubb add` puts each plugin in. */\nexport function generateConfigFile({ inputPath, outputPath }: { inputPath: string; outputPath: string }): string {\n return `import { defineConfig } from 'kubb/config'\n\nexport default defineConfig({\n input: '${inputPath}',\n output: {\n path: '${outputPath}',\n clean: true,\n },\n plugins: [],\n})\n`\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\nimport process from 'node:process'\nimport { read, write } from '@internals/utils'\nimport { Diagnostics, type ExtensionManifest, type RegistryEntry } from '@kubb/core'\nimport { x } from 'tinyexec'\n\nexport type PackageManagerName = 'npm' | 'pnpm' | 'yarn' | 'bun'\n\n/** Metadata describing a package manager's lock file and commands. */\nexport type PackageManagerInfo = {\n /** Identifier used in CLI commands, e.g. `pnpm`, `yarn`. */\n name: PackageManagerName\n /** Lock file names that identify this package manager in a project root. */\n lockFiles: ReadonlyArray<string>\n /** Subcommands passed to the package manager binary to create a `package.json`. */\n initCommand: ReadonlyArray<string>\n /** Subcommands passed to the package manager binary to install a dev dependency. */\n installCommand: ReadonlyArray<string>\n /** Subcommands passed to the package manager binary before a `package.json` script name. */\n runCommand: ReadonlyArray<string>\n}\n\n/** Metadata for each supported package manager, keyed by its short name. */\nexport const packageManagers: Record<PackageManagerName, PackageManagerInfo> = {\n pnpm: {\n name: 'pnpm',\n lockFiles: ['pnpm-lock.yaml'],\n initCommand: ['init'],\n installCommand: ['add', '-D'],\n runCommand: [],\n },\n yarn: {\n name: 'yarn',\n lockFiles: ['yarn.lock'],\n initCommand: ['init', '-y'],\n installCommand: ['add', '-D'],\n runCommand: [],\n },\n bun: {\n name: 'bun',\n lockFiles: ['bun.lock', 'bun.lockb'],\n initCommand: ['init', '-y'],\n installCommand: ['add', '-d'],\n runCommand: ['run'],\n },\n npm: {\n name: 'npm',\n lockFiles: ['package-lock.json'],\n initCommand: ['init', '-y'],\n installCommand: ['install', '--save-dev'],\n runCommand: ['run'],\n },\n}\n\n/** Minimal shape of `package.json` fields read during detection. */\ntype PackageJson = {\n /** The `packageManager` field from `package.json` (e.g. `\"pnpm@9.0.0\"`). */\n packageManager?: string\n scripts?: Record<string, string>\n}\n\n/** Detects the package manager for `cwd`: the `packageManager` field in `package.json`, then a lock file, then `npm`. */\nexport function detectPackageManager(cwd: string = process.cwd()): PackageManagerInfo {\n const packageJsonPath = path.join(cwd, 'package.json')\n if (fs.existsSync(packageJsonPath)) {\n try {\n const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8')) as PackageJson\n const pmField = packageJson.packageManager\n if (typeof pmField === 'string') {\n const name = pmField.split('@')[0]\n if (name && name in packageManagers) {\n return packageManagers[name as PackageManagerName]\n }\n }\n } catch {\n // Continue to lock file detection\n }\n }\n\n for (const pm of Object.values(packageManagers)) {\n if (pm.lockFiles.some((lockFile) => fs.existsSync(path.join(cwd, lockFile)))) {\n return pm\n }\n }\n\n return packageManagers.npm\n}\n\n/**\n * Initializes a new `package.json` at `cwd` using the detected package manager.\n */\nexport async function initPackageJson(cwd: string, packageManager: PackageManagerInfo): Promise<void> {\n await x(packageManager.name, [...packageManager.initCommand], {\n nodeOptions: { cwd, stdio: 'inherit' },\n throwOnError: true,\n })\n}\n\n/** How many trailing lines of a failed install's output the error keeps. */\nconst INSTALL_OUTPUT_LINES = 20\nconst INSTALL_TIMEOUT_MS = 5 * 60_000\n\n/**\n * Installs the given packages at `cwd` using the detected package manager. Each output line goes\n * to `onLine`, so the caller can show it while the install runs; a failed install also keeps the\n * end of the output in the error.\n */\nexport async function installPackages(\n packages: Array<string>,\n packageManager: PackageManagerInfo,\n cwd: string = process.cwd(),\n onLine?: (line: string) => void,\n): Promise<void> {\n const args = [...packageManager.installCommand, ...packages]\n // No stdin, so a package manager that wants input fails instead of waiting. The timeout ends a stalled install.\n const result = x(packageManager.name, args, {\n nodeOptions: { cwd, stdio: ['ignore', 'pipe', 'pipe'] },\n timeout: INSTALL_TIMEOUT_MS,\n throwOnError: false,\n })\n const lines: Array<string> = []\n for await (const line of result) {\n lines.push(line)\n onLine?.(line)\n }\n if (result.exitCode === 0) return\n if (result.exitCode === undefined) throw new Error(`\\`${packageManager.name} ${args.join(' ')}\\` timed out after ${INSTALL_TIMEOUT_MS / 60_000} minutes`)\n\n const output = lines.slice(-INSTALL_OUTPUT_LINES).join('\\n')\n throw new Error(`\\`${packageManager.name} ${args.join(' ')}\\` failed with exit code ${result.exitCode}${output ? `:\\n${output}` : ''}`)\n}\n\n/**\n * What the selected plugins' `manifests` say is missing from the selection: a `dependencies`\n * entry, or a `client` plugin next to a `consumer`. Empty when nothing is missing.\n * `optionalDependencies` are skipped, since `kubb init` writes the default options.\n */\nexport function missingPluginDependencies(manifests: Array<ExtensionManifest>): Array<string> {\n const selected = manifests.map((manifest) => manifest.name)\n const hasClient = manifests.some((manifest) => manifest.role === 'client')\n return manifests.flatMap((manifest) => [\n ...(manifest.dependencies ?? []).filter((name) => !selected.includes(name)).map((name) => `${manifest.name} needs ${name}.`),\n ...(manifest.role === 'consumer' && !hasClient ? [`${manifest.name} needs a client plugin, such as plugin-axios or plugin-fetch.`] : []),\n ])\n}\n\nasync function readPackageJson(cwd: string): Promise<PackageJson> {\n try {\n return JSON.parse(await read(path.join(cwd, 'package.json'))) as PackageJson\n } catch {\n return {}\n }\n}\n\nconst SPEC_FILE = /^(openapi|swagger)[\\w.-]*\\.(ya?ml|json)$/i\nconst SKIPPED_DIRS = new Set(['node_modules', 'dist', 'build', 'coverage'])\n\n/**\n * Finds OpenAPI spec files up to `depth` folders below `cwd`, shallowest first, as `./`-relative\n * paths. Walks one level at a time and stops after `limit` files, so a large repo stays fast.\n */\nexport async function findSpecFiles(cwd: string, { depth = 3, limit = 20 }: { depth?: number; limit?: number } = {}): Promise<Array<string>> {\n const found: Array<string> = []\n let level: Array<string> = ['']\n for (let current = 0; current <= depth && level.length && found.length < limit; current++) {\n const listings = await Promise.all(\n level.map(async (dir) => ({ dir, entries: await fs.promises.readdir(path.join(cwd, dir), { withFileTypes: true }).catch(() => []) })),\n )\n level = []\n for (const { dir, entries } of listings) {\n for (const entry of entries.toSorted((a, b) => a.name.localeCompare(b.name))) {\n if (entry.isFile() && SPEC_FILE.test(entry.name)) found.push(`./${path.posix.join(dir, entry.name)}`)\n if (entry.isDirectory() && !entry.name.startsWith('.') && !SKIPPED_DIRS.has(entry.name)) level.push(path.posix.join(dir, entry.name))\n }\n }\n }\n return found.slice(0, limit)\n}\n\n/** The spec version and operation count, when the file states them. */\nexport type SpecInfo = { version?: string; operations?: number }\n\nconst SPEC_HEAD_BYTES = 256 * 1024\nconst METHOD = '(?:get|put|post|delete|options|head|patch|trace)'\n\n/**\n * Reads the OpenAPI or Swagger version and counts the operations from the first 256 KB of the\n * file, so a large spec is never parsed. The count is left out when the file is longer.\n */\nexport async function readSpecInfo(file: string): Promise<SpecInfo> {\n const handle = await fs.promises.open(file)\n try {\n const buffer = Buffer.alloc(SPEC_HEAD_BYTES)\n const { bytesRead } = await handle.read(buffer, 0, SPEC_HEAD_BYTES, 0)\n const head = buffer.toString('utf-8', 0, bytesRead)\n const complete = bytesRead < SPEC_HEAD_BYTES\n const version = head.match(/^\\s*[\"']?(?:openapi|swagger)[\"']?\\s*:\\s*[\"']?(\\d[\\d.]*)/m)?.[1]\n // shortcut: counts method keys at any depth, so a schema property named `get` counts too; use the adapter when that matters.\n const methods = new RegExp(`^\\\\s*[\"']?${METHOD}[\"']?\\\\s*:\\\\s*(?:\\\\{|$)`, 'gm')\n return { version, operations: complete ? (head.match(methods)?.length ?? 0) : undefined }\n } finally {\n await handle.close()\n }\n}\n\n/** Finds a plugin by registry id, slug, or short name, so `ts`, `plugin-ts`, and `kubb-labs/plugin-ts` all match. */\nexport function findPlugin({ plugins, id }: { plugins: Array<RegistryEntry>; id: string }): RegistryEntry | undefined {\n const ids = id.includes('/') ? [id] : [`kubb-labs/${id}`, `kubb-labs/plugin-${id}`]\n return plugins.find((entry) => ids.includes(entry.id))\n}\n\n/**\n * Turns the comma-separated `--plugins` value into registry entries.\n *\n * @throws when an id is not in `plugins`.\n */\nexport function parsePluginsFlag({ plugins, value }: { plugins: Array<RegistryEntry>; value: string }): Array<RegistryEntry> {\n const ids = value\n .split(',')\n .map((id) => id.trim())\n .filter(Boolean)\n const unknown = ids.filter((id) => !findPlugin({ plugins, id }))\n if (unknown.length)\n throw new Diagnostics.Error({\n code: Diagnostics.code.pluginNotFound,\n severity: 'error',\n message: `Not in the Kubb registry: ${unknown.join(', ')}. Browse the plugins at https://kubb.dev/extensions.`,\n help: 'Use plugin ids from https://kubb.dev/extensions, such as plugin-ts or ts.',\n })\n return ids.map((id) => findPlugin({ plugins, id })!)\n}\n\n/** Adds `\"generate\": \"kubb generate\"` to the `package.json` scripts at `cwd`. Returns `false`, and changes nothing, when a `generate` script exists. */\nexport async function addGenerateScript(cwd: string): Promise<boolean> {\n const file = path.join(cwd, 'package.json')\n const source = await read(file)\n const packageJson = JSON.parse(source) as PackageJson\n if (packageJson.scripts?.generate !== undefined) return false\n const indent = source.match(/^[ \\t]+/m)?.[0] ?? ' '\n const updated = { ...packageJson, scripts: { ...packageJson.scripts, generate: 'kubb generate' } }\n await write(file, JSON.stringify(updated, null, indent))\n return true\n}\n\n/** Reads the `generate` script from the `package.json` at `cwd`. */\nexport async function generateScript(cwd: string): Promise<string | undefined> {\n return (await readPackageJson(cwd)).scripts?.generate\n}\n","import process from 'node:process'\nimport * as clack from '@clack/prompts'\nimport { formatMs, getElapsedMs } from '@internals/utils'\nimport { isRichOutput } from '../utils/env.ts'\nimport { createSpinner } from '../ui/spinner.ts'\nimport { installPackages, type PackageManagerInfo } from './init/utils.ts'\n\n/** How many package manager lines stay visible under the install title while it runs. */\nconst LOG_LINES = 6\n\n/**\n * Installs `packages` and reports how long it took. A rich terminal shows the package manager's\n * last lines under the title while the install runs and clears them when it succeeds; a plain one\n * prints the start and end lines. A failed install keeps the output, reports the failure and rethrows.\n */\nexport async function installWithSpinner({\n packages,\n names,\n packageManager,\n cwd,\n install = installPackages,\n}: {\n packages: Array<string>\n names: string\n packageManager: PackageManagerInfo\n cwd: string\n /** Runs the install itself, so a dry run can skip it. */\n install?: typeof installPackages\n}): Promise<void> {\n const start = process.hrtime()\n const task = createTask(`Installing ${names} with ${packageManager.name}`)\n try {\n await install(packages, packageManager, cwd, task.message)\n } catch (error) {\n task.error('Install failed')\n throw error\n }\n task.success(`Installed ${names} with ${packageManager.name} in ${formatMs(getElapsedMs(start))}`)\n}\n\ntype Task = { message: (line: string) => void; error: (text: string) => void; success: (text: string) => void }\n\n// clack's taskLog prints nothing at the end outside a TTY, so a plain terminal keeps the spinner writer.\n// The failure keeps no log: the thrown error already carries the last lines.\nfunction createTask(title: string): Task {\n if (isRichOutput()) {\n const log = clack.taskLog({ title, limit: LOG_LINES })\n return { message: (line) => log.message(line), error: (text) => log.error(text, { showLog: false }), success: (text) => log.success(text) }\n }\n const spinner = createSpinner()\n spinner.start(title)\n return { message: () => {}, error: (text) => spinner.error(text), success: (text) => spinner.stop(text) }\n}\n","import path from 'node:path'\nimport process from 'node:process'\nimport { styleText } from 'node:util'\nimport * as clack from '@clack/prompts'\nimport { define } from 'gunshi'\nimport { findConfigFile } from '@internals/shared'\nimport { getErrorMessage, read } from '@internals/utils'\nimport { Diagnostics, type ExtensionManifest, readInstalledPackages, type RegistryDetail, type RegistryEntry } from '@kubb/core'\nimport { configArg, yesArg } from '../../commands/shared.ts'\nimport { isInteractiveRun, logIntro } from '../../ui/intro.ts'\nimport { logBlock, logError, logStep, logWarn } from '../../ui/log.ts'\nimport { withSpinner } from '../../ui/spinner.ts'\nimport { logCommandSummary } from '../../ui/summary.ts'\nimport { closestIds, fetchRegistryIndex, incompatibility, installSpec, registryUrl, toRegistryId, toShortId } from '../../utils/registry.ts'\nimport { detectPackageManager } from '../init/utils.ts'\nimport { installWithSpinner } from '../installWithSpinner.ts'\n\nexport type AddOptions = {\n /**\n * `owner/slug`, or a bare `slug` for an official extension. Asked for when omitted.\n */\n id?: string\n configPath?: string\n yes: boolean\n install: boolean\n}\n\ntype ConfigTarget = Pick<RegistryDetail, 'artifact' | 'manifest'>\n\n/** The import and the `defineConfig` property to merge into `kubb.config.ts` by hand. */\nfunction toSnippet({ artifact, manifest }: ConfigTarget): string {\n const call = `${manifest.export}()`\n const property: Record<ExtensionManifest['kind'], string> = {\n plugin: `plugins: [..., ${call}],`,\n adapter: `adapter: ${call},`,\n parser: `parsers: [..., ${call}],`,\n }\n return [`import { ${manifest.export} } from '${artifact.package}'`, '', property[manifest.kind]].join('\\n')\n}\n\n/** The `add-plugin` edits for `details`, and the manifests the edits read their export names from. */\nfunction toConfigEdits(details: Array<ConfigTarget>) {\n return {\n edits: details.map(({ artifact }) => ({ operation: 'add-plugin' as const, plugin: artifact.package })),\n extensions: new Map(details.map(({ artifact, manifest }) => [artifact.package, { package: artifact.package, version: artifact.version, manifest }])),\n }\n}\n\n/** The lines adding `details` would put in the config `source`, trimmed, or why it could not add them. */\nasync function previewConfig({ details, source }: { details: Array<ConfigTarget>; source: string }): Promise<{ lines: Array<string> } | { reason: string }> {\n try {\n const { applyConfigEdits } = await import('@kubb/studio')\n const result = applyConfigEdits({ source, ...toConfigEdits(details) })\n const failed = result.outcomes.find((outcome) => !outcome.applied)\n if (failed) return { reason: failed.reason ?? 'the config file was not changed' }\n const remaining = source.split('\\n')\n const lines = result.source.split('\\n').filter((line) => {\n const index = remaining.indexOf(line)\n if (index !== -1) remaining.splice(index, 1)\n return index === -1\n })\n return { lines: lines.map((line) => line.trim()) }\n } catch (error) {\n return { reason: getErrorMessage(error) }\n }\n}\n\nasync function selectExtension({\n entries,\n versions,\n registry,\n}: {\n entries: Array<RegistryEntry>\n versions: Map<string, unknown>\n registry: string\n}): Promise<string | undefined> {\n if (!entries.length)\n throw new Diagnostics.Error({\n code: Diagnostics.code.unknown,\n severity: 'error',\n message: `The registry at ${registry} lists no extensions.`,\n help: 'Check that `KUBB_REGISTRY` points at a Kubb registry, or unset it to use https://kubb.dev/registry.',\n })\n\n // Filters in memory, so typing never waits on the network.\n const searchText = new Map(entries.map((entry) => [entry.id, `${entry.id} ${entry.manifest.displayName} ${entry.manifest.description}`.toLowerCase()]))\n const options = entries\n .toSorted((a, b) => a.id.localeCompare(b.id))\n .map((entry) => {\n const installed = versions.has(entry.artifact.package)\n return { value: entry.id, label: toShortId(entry.id), hint: installed ? 'installed' : summarize(entry.manifest.description), disabled: installed }\n })\n\n const id = await clack.autocomplete({\n message: `Add an extension · ${entries.length} in the registry`,\n placeholder: 'Search',\n options,\n filter: (search, option) => searchText.get(option.value)?.includes(search.toLowerCase()) ?? false,\n })\n return clack.isCancel(id) ? undefined : id\n}\n\n/** Asks whether to also add the required plugins the config lacks. `--yes` adds them. */\nasync function confirmDependencies({\n entry,\n missing,\n yes,\n}: {\n entry: RegistryEntry\n missing: Array<RegistryEntry>\n yes: boolean\n}): Promise<boolean | undefined> {\n if (!missing.length || yes) return true\n const names = missing.map((dependency) => dependency.manifest.name).join(', ')\n const answer = await clack.select({\n message: `${entry.manifest.name} needs ${names}. Add ${names} as well?`,\n options: [\n { value: true, label: `Yes, add ${missing.length === 1 ? 'both' : 'all'}`, hint: 'recommended' },\n { value: false, label: `Only ${entry.manifest.name}`, hint: 'generate fails until you add it' },\n ],\n initialValue: true,\n })\n return clack.isCancel(answer) ? undefined : answer\n}\n\n/** The first sentence of a registry description, cut to one terminal line. */\nexport function summarize(description: string, max = 64): string {\n const sentence = description.split(/\\.\\s/)[0]!.replace(/\\.$/, '')\n return sentence.length > max ? `${sentence.slice(0, max - 1).trimEnd()}…` : sentence\n}\n\n/**\n * Installs an extension from the Kubb registry at its reviewed version and, for a plugin, adds it to\n * `kubb.config.ts`, offering to add the plugins it needs as well. Without an id, asks which one.\n * Previews the packages and config lines before asking. Refuses when the running Kubb or Node.js\n * version is outside its compatibility.\n */\nexport async function run({ id: input, configPath, yes, install }: AddOptions): Promise<void> {\n const cwd = process.cwd()\n const hrStart = process.hrtime()\n const summary = (title: string, status: Parameters<typeof logCommandSummary>[0]['status'], lines: ReadonlyArray<string>) =>\n logCommandSummary({ title, status, hrStart, block: true, lines })\n const installedPackages: Array<string> = []\n const configured: Array<RegistryEntry> = []\n logIntro({ title: isInteractiveRun({ yes }) ? undefined : styleText('bgCyan', styleText('black', ' Kubb Add ')) })\n\n try {\n const registry = registryUrl()\n if (!input && yes)\n throw new Diagnostics.Error({\n code: Diagnostics.code.unknown,\n severity: 'error',\n message: 'Pass a registry id, such as plugin-zod, when using --yes.',\n help: 'Run `kubb add plugin-zod --yes`, or drop `--yes` to pick from a list.',\n })\n const inputId = input ? toRegistryId(input) : undefined\n const foundConfig = configPath ? path.resolve(configPath) : findConfigFile(cwd)\n const [entries, installed, configSource] = await withSpinner({\n message: 'Reading the registry',\n promise: Promise.all([\n fetchRegistryIndex({ registry }),\n readInstalledPackages({ root: cwd }),\n foundConfig ? read(foundConfig).catch(() => undefined) : undefined,\n ]),\n })\n const versions = new Map(installed.map((item) => [item.package, item.version]))\n\n const id = inputId ?? (await selectExtension({ entries, versions, registry }))\n if (!id) {\n summary('Add canceled', 'canceled', [' No changes made'])\n return\n }\n const entry = entries.find((candidate) => candidate.id === id)\n if (!entry) {\n const suggestions = closestIds({ input: id, ids: entries.map((entry) => entry.id) }).map(toShortId)\n summary(`No extension named ${input ?? id}`, 'failed', [\n ...suggestions.map((suggestion) => ` kubb add ${suggestion}`),\n ' Browse all kubb.dev/extensions',\n ])\n process.exitCode = 1\n return\n }\n const { artifact, manifest } = entry\n const kind = manifest.kind.charAt(0).toUpperCase() + manifest.kind.slice(1)\n\n const problem = incompatibility(manifest)\n if (problem)\n throw new Diagnostics.Error({\n code: Diagnostics.code.incompatibleExtension,\n severity: 'error',\n message: problem,\n help: 'Upgrade Kubb or Node.js to a version the extension supports.',\n })\n\n const configFile = manifest.kind === 'plugin' ? foundConfig : undefined\n if (manifest.kind === 'plugin' && !configFile)\n throw new Diagnostics.Error({\n code: Diagnostics.code.unknown,\n severity: 'error',\n message: 'No kubb.config.ts found. Run `kubb init` first, or pass --config.',\n help: 'Run `kubb init` to create a config, or pass its path with `--config`.',\n })\n const configName = configFile ? path.relative(cwd, configFile) || configFile : undefined\n\n const byName = new Map(entries.map((candidate) => [candidate.manifest.name, candidate]))\n const inConfig = (name: string) => {\n const dependency = byName.get(name)\n return dependency ? !!configSource?.includes(`${dependency.manifest.export}(`) : installed.some((item) => item.manifest?.name === name)\n }\n const dependencies = manifest.dependencies ?? []\n const missing = configFile ? dependencies.filter((name) => !inConfig(name)).flatMap((name) => byName.get(name) ?? []) : []\n const withDependencies = await confirmDependencies({ entry, missing, yes })\n if (withDependencies === undefined) {\n summary('Add canceled', 'canceled', [` ${kind} ${manifest.name}`, ' No changes made'])\n return\n }\n const targets = [...(withDependencies ? missing : []), entry]\n const specs = targets.filter((target) => target === entry || !versions.has(target.artifact.package)).map((target) => installSpec(target.artifact))\n\n const dependencyStatus = (name: string) => {\n if (inConfig(name)) return `${name} ${styleText('green', '✓ installed')}`\n return targets.some((target) => target.manifest.name === name) ? `${name} ${styleText('cyan', '+ adding')}` : `${name} ${styleText('yellow', 'missing')}`\n }\n const preview = configFile && configSource !== undefined ? await previewConfig({ details: targets, source: configSource }) : undefined\n logStep(`${kind} ${styleText('cyan', manifest.name)} v${artifact.version} · ${summarize(manifest.description)}`)\n logBlock([\n ...(dependencies.length ? [`Needs ${dependencies.map(dependencyStatus).join(' ')}`] : []),\n install ? `Installs ${specs.join(' ')}` : 'Installs nothing (--no-install)',\n ...(configName ? [`Config ${configName}`] : [`Config prints the ${manifest.kind} snippet to add`]),\n ...(preview && 'lines' in preview ? preview.lines.map((line) => styleText('green', ` + ${line}`)) : []),\n ...(preview && 'reason' in preview ? [styleText('yellow', ` cannot edit it: ${preview.reason}`)] : []),\n ])\n\n const confirmed = yes || (await clack.confirm({ message: 'Add it?', initialValue: true }))\n if (clack.isCancel(confirmed) || !confirmed) {\n summary('Add canceled', 'canceled', [` ${kind} ${manifest.name}`, ' No changes made'])\n return\n }\n\n const packageManager = detectPackageManager(cwd)\n const packages = () => (install ? `${installedPackages.length} installed with ${packageManager.name}` : 'installation skipped (--no-install)')\n if (install) {\n const names = targets.filter((target) => specs.includes(installSpec(target.artifact))).map((target) => target.artifact.package)\n await installWithSpinner({ packages: specs, names: names.join(', '), packageManager, cwd })\n installedPackages.push(...names)\n }\n\n const unconfigured: Array<RegistryEntry> = configFile ? [] : [entry]\n if (configFile) {\n for (const target of targets) {\n try {\n const { writeConfigEdits } = await import('@kubb/studio')\n const { outcomes, changed } = await writeConfigEdits({ filePath: configFile, ...toConfigEdits([target]) })\n if (!outcomes[0]?.applied) throw new Error(outcomes[0]?.reason ?? 'the config file was not changed')\n if (changed) configured.push(target)\n logStep(`${target.manifest.export}() configured in ${configName}`)\n } catch (error) {\n logWarn(`Could not edit ${configName}: ${getErrorMessage(error)}`)\n unconfigured.push(target)\n }\n }\n }\n\n const manual = unconfigured.length > 0\n // A plugin the command could not write into the config is a failure a caller can act on; an adapter or parser never gets written.\n if (manual && manifest.kind === 'plugin') process.exitCode = 1\n if (manual)\n logBlock([\n 'Add the import to your Kubb config and merge the property into its defineConfig call:',\n '',\n ...unconfigured.map((target) => toSnippet(target)),\n ])\n const dependenciesMissing = !withDependencies && missing.length > 0\n const title = manual\n ? `${kind} needs configuration`\n : dependenciesMissing\n ? 'Plugin configured; dependencies missing'\n : configured.length\n ? install\n ? 'Plugin ready'\n : 'Plugin configured'\n : 'Plugin already configured'\n summary(title, manual || dependenciesMissing ? 'warning' : 'success', [\n ` Packages ${packages()}`,\n ...configured.map((target) => styleText('green', ` + ${target.manifest.export}()`)),\n '',\n ...(!install ? [`Install ${specs.join(' ')} to use it.`] : []),\n ...(dependenciesMissing ? [`Missing plugins ${missing.map((target) => target.manifest.name).join(', ')}`] : []),\n manual ? 'Add the snippet above, then run kubb generate.' : 'Next kubb generate',\n `Options kubb.dev/extensions/${entry.id}`,\n ])\n } catch (error) {\n logError(getErrorMessage(error))\n summary('Add failed', 'failed', installedPackages.length ? [` Packages ${installedPackages.join(', ')} installed`] : [' No changes made'])\n process.exitCode = 1\n }\n}\n\nexport const command = define({\n name: 'add',\n description: 'Find and install plugins, adapters, and parsers from the Kubb registry.',\n examples: [\n 'kubb add',\n 'kubb add plugin-zod',\n 'kubb add kubb-labs/plugin-react-query',\n 'kubb add acme/plugin-x --yes',\n 'kubb add plugin-zod --no-install',\n ].join('\\n'),\n toKebab: true,\n args: {\n id: {\n type: 'positional',\n description: 'Registry id: owner/slug, or a slug for an official extension. Asked for when omitted',\n required: false,\n },\n ...configArg,\n ...yesArg,\n install: {\n type: 'boolean',\n description: 'Install the package. Pass --no-install to only edit the config',\n negatable: true,\n default: true,\n },\n },\n run: ({ values }) => run({ id: values.id, configPath: values.config, yes: values.yes, install: values.install }),\n})\n","import path from 'node:path'\nimport process from 'node:process'\nimport { styleText } from 'node:util'\nimport * as clack from '@clack/prompts'\nimport type { DryRunExtension } from '@gunshi/plugin-dryrun'\nimport { defineWithTypes } from 'gunshi'\nimport { generateConfigFile, initDefaults, KUBB_CONFIG_FILENAME, KUBB_PACKAGE_NAME } from '@internals/shared'\nimport { exists, formatMs, getElapsedMs, write } from '@internals/utils'\nimport { createKubb, Diagnostics, type RegistryEntry } from '@kubb/core'\nimport { dryRunId, type DryRunExtensions } from '../../commands/shared.ts'\nimport { getConfigs } from '../../config.ts'\nimport { pluralize } from '../../ui/text.ts'\nimport { isInteractiveRun, logIntro, logOutro } from '../../ui/intro.ts'\nimport { logBlock, logError, logStep, logWarn } from '../../ui/log.ts'\nimport { createSpinner } from '../../ui/spinner.ts'\nimport { fetchRegistryIndex, incompatibility, installSpec, registryUrl } from '../../utils/registry.ts'\nimport { installWithSpinner } from '../installWithSpinner.ts'\nimport {\n addGenerateScript,\n detectPackageManager,\n findPlugin,\n findSpecFiles,\n generateScript,\n initPackageJson,\n installPackages,\n missingPluginDependencies,\n type PackageManagerInfo,\n parsePluginsFlag,\n readSpecInfo,\n} from './utils.ts'\nimport { version } from '../../../package.json'\n\nfunction cancelAndExit(message = 'Operation canceled.'): never {\n clack.cancel(message)\n process.exit(0)\n}\n\nfunction unwrap<T>(value: T): Exclude<T, symbol> {\n if (clack.isCancel(value)) cancelAndExit()\n return value as Exclude<T, symbol>\n}\n\ntype InitOptions = {\n /**\n * When `true`, skips all interactive prompts and uses the detected or default values.\n */\n yes: boolean\n /**\n * Input path flag value from `--input`. When provided, skips the input prompt.\n */\n input?: string\n /**\n * Output directory flag value from `--output`. When provided, skips the output prompt.\n */\n output?: string\n /**\n * Comma-separated plugin list from `--plugins`, e.g. `'plugin-ts,zod'`. When provided, skips the plugin selection prompt.\n */\n plugins?: string\n /**\n * Dry-run extension from `@gunshi/plugin-dryrun`. When enabled, package installation, file\n * writes, and the first run are skipped.\n */\n dryRun: DryRunExtension\n}\n\ntype Choices = {\n inputPath: string\n outputPath: string\n plugins: Array<RegistryEntry>\n}\n\n/** The full `kubb.config.ts` for `choices`, with each plugin added the way `kubb add` adds it. */\nasync function buildConfig({ inputPath, outputPath, plugins }: Choices): Promise<string> {\n const { applyConfigEdits } = await import('@kubb/studio')\n const { source, outcomes } = applyConfigEdits({\n source: generateConfigFile({ inputPath, outputPath }),\n edits: plugins.map((entry) => ({ operation: 'add-plugin', plugin: entry.artifact.package })),\n extensions: new Map(plugins.map(({ artifact, manifest }) => [artifact.package, { package: artifact.package, version: artifact.version, manifest }])),\n })\n const failed = outcomes.find((outcome) => !outcome.applied)\n if (failed && failed.edit.operation === 'add-plugin')\n throw new Diagnostics.Error({\n code: Diagnostics.code.unknown,\n severity: 'error',\n message: `Could not add ${failed.edit.plugin} to ${KUBB_CONFIG_FILENAME}: ${failed.reason}`,\n help: `Run kubb init without that plugin, then add it with kubb add.`,\n })\n return source\n}\n\n/** Generates from the config at `configPath` without reporters, and returns how many files it wrote. */\nasync function firstRun(configPath: string): Promise<number> {\n const { configs } = await getConfigs({ configPath })\n let files = 0\n for (const config of configs) {\n const result = await createKubb(config).generate()\n if (!result.success) throw new Error(result.diagnostics.flatMap((diagnostic) => (diagnostic.severity === 'error' ? [diagnostic.message] : [])).join('\\n'))\n files += result.files.length\n }\n return files\n}\n\n/** The command that runs `kubb generate`: the `generate` script when it runs Kubb, otherwise `npx kubb generate`. */\nfunction generateCommand({ packageManager, script, watch }: { packageManager: PackageManagerInfo; script: string | undefined; watch: boolean }): string {\n if (script !== 'kubb generate') return `npx kubb generate${watch ? ' --watch' : ''}`\n const run = [packageManager.name, ...packageManager.runCommand, 'generate'].join(' ')\n if (!watch) return run\n return packageManager.name === 'npm' ? `${run} -- --watch` : `${run} --watch`\n}\n\n/**\n * Runs the Kubb setup wizard: detects the package manager and specs, asks for the spec, plugins, and\n * output folder, shows the config for review, then installs, writes `kubb.config.ts`, adds a\n * `generate` script, and runs the first generation.\n * Pass `yes: true` to skip all prompts and print one line per step.\n */\nexport async function run({ yes, input: inputFlag, output: outputFlag, plugins: pluginsFlag, dryRun }: InitOptions): Promise<void> {\n const cwd = process.cwd()\n\n /** Runs `task` behind a spinner, or prints one line when it is done in `--yes` mode. */\n async function step<T>({ start, task, done, failed }: { start: string; task: () => Promise<T>; done: (result: T) => string; failed: string }): Promise<T> {\n const spinner = createSpinner()\n if (!yes) spinner.start(start)\n try {\n const result = await task()\n if (yes) console.log(`${styleText('green', '✓')} ${done(result)}`)\n else spinner.stop(done(result))\n return result\n } catch (error) {\n if (!yes) spinner.error(failed)\n throw error\n }\n }\n\n if (!yes) logIntro({ title: isInteractiveRun({ yes, dryRun: dryRun.enabled }) ? undefined : 'Set up Kubb' })\n\n try {\n // Start the registry fetch now but await it only at the plugin step, so the first prompt never waits on the network\n const registry = fetchRegistryIndex({ registry: registryUrl() }).then((entries) =>\n entries.filter((entry) => entry.kind === 'plugin' && !incompatibility(entry.manifest)),\n )\n registry.catch(() => {})\n // Warm the module cache for buildConfig while the user answers, so the review shows up without waiting\n if (!yes) import('@kubb/studio').catch(() => {})\n\n if (!(await exists(path.join(cwd, 'package.json')))) {\n if (!yes) {\n const shouldInit = unwrap(await clack.confirm({ message: 'No package.json found. Would you like to create one?', initialValue: true }))\n if (!shouldInit) cancelAndExit()\n }\n\n const packageManager = detectPackageManager(cwd)\n await step({\n start: `Initializing package.json with ${packageManager.name}`,\n task: () => initPackageJson(cwd, packageManager),\n done: () => `Created package.json with ${packageManager.name}`,\n failed: 'Could not create package.json',\n })\n }\n\n const packageManager = detectPackageManager(cwd)\n const specs = await findSpecFiles(cwd)\n\n if (!yes) {\n logStep(`Package manager ${packageManager.name}`)\n if (specs[0]) {\n const { version: specVersion, operations } = await readSpecInfo(path.join(cwd, specs[0]))\n const details = [\n specs[0].slice(2),\n specVersion ? `${specVersion.startsWith('2') ? 'Swagger' : 'OpenAPI'} ${specVersion}` : undefined,\n operations === undefined ? undefined : pluralize(operations, 'operation'),\n specs.length > 1 ? `+${specs.length - 1} more` : undefined,\n ]\n logStep(`Found ${details.filter(Boolean).join(' · ')}`)\n }\n }\n\n // `--plugins` and `--yes` need the registry before any prompt; the interactive path reads it at the plugin step\n const plugins = pluginsFlag || yes ? await registry : undefined\n const defaultPlugins = (entries: Array<RegistryEntry>) => initDefaults.plugins.flatMap((id) => findPlugin({ plugins: entries, id }) ?? [])\n\n const flagPlugins = pluginsFlag && plugins ? parsePluginsFlag({ plugins, value: pluginsFlag }) : undefined\n\n let choices: Choices = {\n inputPath: inputFlag ?? specs[0] ?? initDefaults.inputPath,\n outputPath: outputFlag ?? initDefaults.outputPath,\n plugins: flagPlugins ?? (plugins ? defaultPlugins(plugins) : []),\n }\n if (yes && !choices.plugins.length) {\n throw new Error('The registry has no default plugin. Pass --plugins to choose one.')\n }\n\n async function askInput(current: string): Promise<string> {\n const choice = specs.length\n ? unwrap(\n await clack.select({\n message: 'Which spec should Kubb read?',\n options: [\n ...specs.map((spec) => ({ value: spec, label: spec, hint: 'found in this repo' })),\n { value: 'url', label: 'A URL' },\n { value: 'file', label: 'Another file' },\n ],\n initialValue: specs.includes(current) ? current : /^https?:\\/\\//.test(current) ? 'url' : 'file',\n }),\n )\n : /^https?:\\/\\//.test(current)\n ? 'url'\n : 'file'\n if (specs.includes(choice)) return choice\n const isUrl = choice === 'url'\n const initial = isUrl === /^https?:\\/\\//.test(current) && !specs.includes(current) ? current : undefined\n return unwrap(\n await clack.text({\n message: isUrl ? 'Spec URL' : 'Spec path',\n placeholder: isUrl ? 'https://example.com/openapi.yaml' : initDefaults.inputPath,\n initialValue: initial,\n defaultValue: isUrl ? undefined : initDefaults.inputPath,\n validate: (value) => {\n if (isUrl && !/^https?:\\/\\//.test(value ?? '')) return 'Enter an http(s) URL'\n },\n }),\n )\n }\n\n async function askPlugins(previous: Array<RegistryEntry>): Promise<Array<RegistryEntry>> {\n const plugins = await registry\n const current = previous.length ? previous : defaultPlugins(plugins)\n const width = Math.max(...plugins.map((entry) => entry.manifest.displayName.length))\n const nameWidth = Math.max(...plugins.map((entry) => entry.manifest.name.length))\n const values = unwrap(\n await clack.multiselect({\n message: 'What should Kubb generate?',\n options: plugins.map(({ id, manifest }) => ({\n value: id,\n label: `${manifest.displayName.padEnd(width)} ${styleText('dim', manifest.name.padEnd(nameWidth))}`.trimEnd(),\n })),\n initialValues: current.map((entry) => entry.id),\n required: true,\n }),\n )\n return plugins.filter((entry) => values.includes(entry.id))\n }\n\n // Flags for all three choices leave nothing to ask or review, as before the review step existed\n const answered = yes || Boolean(inputFlag && outputFlag && pluginsFlag)\n if (!answered) {\n let firstPass = true\n while (true) {\n // The first pass skips the questions a flag answered; \"Change a choice\" asks them all again.\n choices = {\n inputPath: firstPass && inputFlag ? inputFlag : await askInput(choices.inputPath),\n plugins: firstPass && flagPlugins ? flagPlugins : await askPlugins(choices.plugins),\n outputPath:\n firstPass && outputFlag\n ? outputFlag\n : unwrap(await clack.text({ message: 'Output folder', placeholder: choices.outputPath, defaultValue: choices.outputPath })),\n }\n firstPass = false\n const missing = missingPluginDependencies(choices.plugins.map((entry) => entry.manifest))\n if (missing.length) {\n logWarn(`${missing.join('\\n')}\\nAdd the missing plugins.`)\n continue\n }\n const config = await buildConfig(choices)\n const packages = [KUBB_PACKAGE_NAME, ...choices.plugins.map((entry) => entry.artifact.package)]\n logStep(`Review ${KUBB_CONFIG_FILENAME}`)\n logBlock([...config.trimEnd().split('\\n'), '', `${styleText('dim', 'Installs')} ${packages.join(' ')} with ${packageManager.name}`])\n const configExists = await exists(path.join(cwd, KUBB_CONFIG_FILENAME))\n const confirmed = unwrap(\n await clack.select({\n message: configExists ? `${KUBB_CONFIG_FILENAME} exists. Overwrite it?` : 'Create it?',\n options: [\n { value: true, label: 'Yes' },\n { value: false, label: 'Change a choice' },\n ],\n }),\n )\n if (confirmed) break\n }\n }\n\n // Check the selection against the plugins' manifests before installing anything\n const missing = missingPluginDependencies(choices.plugins.map((entry) => entry.manifest))\n if (missing.length) {\n throw new Diagnostics.Error({\n code: Diagnostics.code.missingDependency,\n severity: 'error',\n message: `${missing.join('\\n')}\\nAdd the missing plugins and run kubb init again.`,\n })\n }\n\n const configPath = path.join(cwd, KUBB_CONFIG_FILENAME)\n if (answered && !yes && (await exists(configPath))) {\n const overwrite = unwrap(await clack.confirm({ message: `${KUBB_CONFIG_FILENAME} exists. Overwrite it?`, initialValue: false }))\n if (!overwrite) cancelAndExit('Keeping existing configuration.')\n }\n\n // Install `kubb` at the running CLI's version and each plugin at the version the registry pins\n const packagesToInstall = [`${KUBB_PACKAGE_NAME}@${version}`, ...choices.plugins.map((entry) => installSpec(entry.artifact))]\n const packageNames = [KUBB_PACKAGE_NAME, ...choices.plugins.map((entry) => entry.artifact.package)]\n const dry = { message: `install ${packagesToInstall.length} packages with ${packageManager.name}` }\n if (yes) {\n await step({\n start: '',\n task: async () => void (await dryRun.run(() => installPackages(packagesToInstall, packageManager, cwd), dry)),\n done: () => `Installed ${packageNames.join(' ')} with ${packageManager.name}`,\n failed: 'Installation failed',\n })\n } else {\n await installWithSpinner({\n packages: packagesToInstall,\n names: `${packagesToInstall.length} packages`,\n packageManager,\n cwd,\n install: async (packages, packageManager, cwd, onLine) => void (await dryRun.run(() => installPackages(packages, packageManager, cwd, onLine), dry)),\n })\n }\n\n await step({\n start: `Writing ${KUBB_CONFIG_FILENAME}`,\n task: async () => dryRun.run(async () => void (await write(configPath, await buildConfig(choices))), { message: `write ${KUBB_CONFIG_FILENAME}` }),\n done: () => `Wrote ${KUBB_CONFIG_FILENAME}`,\n failed: `Could not write ${KUBB_CONFIG_FILENAME}`,\n })\n\n const scriptAdded = await dryRun.run(() => addGenerateScript(cwd), {\n message: 'add a generate script to package.json',\n resolve: async () => (await generateScript(cwd)) === undefined,\n })\n if (scriptAdded && !yes) logStep('Added \"generate\": \"kubb generate\" to package.json')\n\n const script = scriptAdded ? 'kubb generate' : await generateScript(cwd)\n const runStart = process.hrtime()\n try {\n await dryRun.run(\n () =>\n step({\n start: 'Running the first generation',\n task: () => firstRun(configPath),\n done: (files) =>\n yes\n ? `Generated ${pluralize(files, 'file')} in ${choices.outputPath}`\n : `First run ${pluralize(files, 'file')} in ${choices.outputPath} · ${formatMs(getElapsedMs(runStart))}`,\n failed: 'First run failed',\n }),\n { message: 'run the first generation', resolve: () => 0 },\n )\n } catch (error) {\n logError(error instanceof Error ? error.message : String(error))\n const message = `Kubb is set up, but the first run failed. Fix the error, then run ${generateCommand({ packageManager, script, watch: false })}.`\n if (yes) console.log(message)\n else logOutro(styleText('yellow', message))\n process.exitCode = 1\n return\n }\n\n if (yes) {\n console.log(`Kubb is set up. Run ${generateCommand({ packageManager, script, watch: false })} after changing the spec.`)\n return\n }\n logOutro(`${styleText('green', '✓ Kubb is set up')}\\n ${styleText('dim', 'Next')} ${generateCommand({ packageManager, script, watch: true })}`)\n } catch (error) {\n logError(styleText('red', 'An error occurred during initialization'))\n if (error instanceof Error) {\n logError(error.message)\n }\n process.exit(1)\n }\n}\n\nexport const command = defineWithTypes<{ extensions: DryRunExtensions }>()({\n name: 'init',\n description: 'Set up a config, install plugins, and run the first generation.',\n examples: [\n 'kubb init',\n 'kubb init --yes',\n 'kubb init --input ./openapi.yaml --output ./src/gen --plugins plugin-ts,plugin-zod',\n 'kubb init --yes --input ./openapi.yaml --plugins ts,zod --output src/api',\n 'kubb init --plugins plugin-ts,plugin-axios,plugin-react-query',\n 'kubb init --yes --dry-run',\n ].join('\\n'),\n toKebab: true,\n args: {\n yes: {\n type: 'boolean',\n description: 'Skip prompts and use the detected spec, the default plugin, and the default output folder',\n short: 'y',\n default: false,\n },\n input: {\n type: 'string',\n description: 'Path to the OpenAPI specification',\n short: 'i',\n metavar: 'path',\n },\n output: {\n type: 'string',\n description: 'Output directory for generated files',\n short: 'o',\n metavar: 'path',\n },\n plugins: {\n type: 'string',\n description:\n 'Comma-separated Kubb registry ids of the plugins to add, the same ids `kubb add` takes (plugin-ts, plugin-zod, acme/plugin-x), or short names (ts, zod)',\n metavar: 'plugin-ts,plugin-zod,...',\n },\n },\n run: ({ values, extensions }) => run({ yes: values.yes, input: values.input, output: values.output, plugins: values.plugins, dryRun: extensions[dryRunId] }),\n})\n","/** Pads each column to its widest cell, one line per row. */\nexport function formatTable(rows: ReadonlyArray<ReadonlyArray<string>>): Array<string> {\n const widths = Array.from({ length: Math.max(0, ...rows.map((row) => row.length)) }, (_, index) => Math.max(...rows.map((row) => row[index]?.length ?? 0)))\n return rows.map((row) =>\n row\n .map((cell, index) => cell.padEnd(widths[index]!))\n .join(' ')\n .trimEnd(),\n )\n}\n","import process from 'node:process'\nimport { styleText } from 'node:util'\nimport { getErrorMessage } from '@internals/utils'\nimport { define } from 'gunshi'\nimport { readInstalledPackages, type RegistryEntry } from '@kubb/core'\nimport { logOutro } from '../../ui/intro.ts'\nimport { logBlock, logError, logWarn } from '../../ui/log.ts'\nimport { formatTable } from '../../ui/table.ts'\nimport { fetchRegistryIndex, isOutdated, registryUrl } from '../../utils/registry.ts'\n\nexport type ListRow = {\n id?: string\n package: string\n installed?: string\n registry?: string\n update: boolean\n}\n\n/**\n * The installed packages that ship a `kubb-extension.json` or have a registry entry, with the\n * version the registry pins.\n */\nexport async function listExtensions({ cwd, registry }: { cwd: string; registry: string }): Promise<Array<ListRow>> {\n const [installed, entries] = await Promise.all([\n readInstalledPackages({ root: cwd }),\n fetchRegistryIndex({ registry }).catch((error: unknown): Array<RegistryEntry> => {\n logWarn(`Showing installed extensions only: ${getErrorMessage(error)}`)\n return []\n }),\n ])\n const byPackage = new Map(entries.map((entry) => [entry.artifact.package, entry]))\n\n return installed.flatMap(({ package: name, version, manifest }): Array<ListRow> => {\n const entry = byPackage.get(name)\n if (!entry && !manifest) return []\n const latest = entry?.artifact.version\n return [{ id: entry?.id, package: name, installed: version, registry: latest, update: !!latest && isOutdated({ installed: version, latest }) }]\n })\n}\n\n/** Prints the installed extensions as a table. */\nexport async function run(): Promise<void> {\n try {\n const rows = await listExtensions({ cwd: process.cwd(), registry: registryUrl() })\n if (!rows.length) {\n logOutro('No installed extensions found.')\n return\n }\n\n const header = ['ID', 'PACKAGE', 'INSTALLED', 'REGISTRY', 'UPDATE']\n const cells = rows.map((row) => [row.id ?? '-', row.package, row.installed ?? '-', row.registry ?? '-', row.update ? 'yes' : 'no'])\n const [head, ...body] = formatTable([header, ...cells])\n logBlock([styleText('dim', head!), ...body])\n } catch (error) {\n logError(getErrorMessage(error))\n process.exitCode = 1\n }\n}\n\nexport const command = define({\n name: 'list',\n description: 'List installed extensions, their versions, and available updates.',\n examples: 'kubb list',\n run: () => run(),\n})\n","import path from 'node:path'\nimport process from 'node:process'\nimport { styleText } from 'node:util'\nimport * as clack from '@clack/prompts'\nimport { defineWithTypes } from 'gunshi'\nimport { findConfigFile } from '@internals/shared'\nimport { getErrorMessage } from '@internals/utils'\nimport { Hookable, type KubbHooks, readInstalledPackages, type RegistryEntry } from '@kubb/core'\nimport { pluralize } from '../../ui/text.ts'\nimport { dryRunId, type DryRunExtensions, yesArg } from '../../commands/shared.ts'\nimport { isInteractiveRun, logIntro } from '../../ui/intro.ts'\nimport { logBlock, logError, logStep, logWarn } from '../../ui/log.ts'\nimport { createSpinner, withSpinner } from '../../ui/spinner.ts'\nimport { logCommandSummary } from '../../ui/summary.ts'\nimport { formatTable } from '../../ui/table.ts'\nimport { bumpOf, fetchRegistryIndex, incompatibility, installSpec, isOutdated, registryUrl, toRegistryId, toShortId } from '../../utils/registry.ts'\nimport { detectPackageManager } from '../init/utils.ts'\nimport { installWithSpinner } from '../installWithSpinner.ts'\nimport { diffFiles, type FileChange, readOutputFiles } from '../generate/utils.ts'\n\nexport type UpdateOptions = {\n /**\n * Registry ids to update. Empty updates every installed extension the registry lists.\n */\n ids: Array<string>\n /**\n * List the updates without installing anything.\n */\n dryRun: boolean\n yes: boolean\n}\n\n/**\n * Generates every config in this process, the way `kubb generate` does, and returns the output files\n * it changed. Runs after the install, so the config loads the new versions. `undefined` when the\n * config fails to load or a build fails.\n */\nasync function regenerate({\n cwd,\n configPath,\n}: {\n cwd: string\n configPath: string\n}): Promise<{ files: Array<FileChange>; unchanged: number; output: string } | undefined> {\n const spinner = createSpinner()\n spinner.start('Generating with the new versions')\n try {\n // Imported here, so the config loader and the generate path never slow down `kubb --help`.\n const [{ getConfigs }, { generate }] = await Promise.all([import('../../config.ts'), import('../generate/run.ts')])\n const { configs } = await getConfigs({ configPath })\n const dirs = configs.map((config) => path.resolve(config.root ?? cwd, config.output.path))\n const before = new Map((await Promise.all(dirs.map(readOutputFiles))).flatMap((files) => [...files]))\n const hooks = new Hookable<KubbHooks>()\n for (const config of configs) {\n if (!(await generate({ config, hooks }))) throw new Error('Generation failed')\n }\n const after = new Map((await Promise.all(dirs.map(readOutputFiles))).flatMap((files) => [...files]))\n const diff = diffFiles(before, after)\n spinner.stop(diff.files.length ? `Generated: ${pluralize(diff.files.length, 'file')} changed` : 'Generated: no files changed')\n return { ...diff, output: dirs.map((dir) => path.relative(cwd, dir) || '.').join(', ') }\n } catch (error) {\n spinner.error(`Generation failed: ${getErrorMessage(error)}`)\n return undefined\n }\n}\n\n/**\n * Moves installed extensions to the version the registry pins. Shows each version change with its\n * bump, asks which to install with majors left out, installs them, and regenerates to show which\n * files changed. With `dryRun`, only lists the updates and installs nothing.\n */\nexport async function run({ ids, dryRun, yes }: UpdateOptions): Promise<void> {\n const cwd = process.cwd()\n const hrStart = process.hrtime()\n const installedPackages: Array<string> = []\n const summary = (title: string, status: Parameters<typeof logCommandSummary>[0]['status'], lines: ReadonlyArray<string>) =>\n logCommandSummary({ title, status, hrStart, block: true, lines })\n logIntro({ title: isInteractiveRun({ yes, dryRun }) ? undefined : styleText('bgCyan', styleText('black', ' Kubb Update ')) })\n\n try {\n const wanted = new Set(ids.map(toRegistryId))\n const [entries, installed] = await withSpinner({\n message: 'Checking the registry',\n promise: Promise.all([fetchRegistryIndex({ registry: registryUrl() }), readInstalledPackages({ root: cwd })]),\n })\n const versions = new Map(installed.map((item) => [item.package, item.version]))\n\n const tracked = entries.filter((entry) => versions.has(entry.artifact.package) && (!wanted.size || wanted.has(entry.id)))\n for (const id of wanted) {\n if (!tracked.some((entry) => entry.id === id)) logWarn(`${id} is not installed, or not in the registry.`)\n }\n\n const current = ({ artifact }: RegistryEntry) => versions.get(artifact.package)\n const isMajor = (entry: RegistryEntry) => bumpOf({ installed: current(entry), latest: entry.artifact.version }) === 'major'\n const outdated = tracked.filter((entry) => isOutdated({ installed: current(entry), latest: entry.artifact.version }))\n const proposals = outdated.filter((entry) => {\n const problem = incompatibility(entry.manifest)\n if (problem) logWarn(`Skipped ${entry.id}: ${problem}`)\n return !problem\n })\n\n if (!proposals.length) {\n const title = outdated.length ? 'No compatible updates available' : 'Already up to date'\n summary(tracked.length ? title : 'No installed extensions to update', outdated.length ? 'warning' : 'success', [\n ` ${tracked.length - outdated.length} of ${tracked.length} up to date`,\n ...(ids.length ? ['', `No updates for ${ids.join(', ')}.`] : []),\n ])\n return\n }\n\n if (tracked.length) {\n const header = ['Extension', 'Current', 'Latest', '']\n const rows = tracked.map((entry) => {\n if (!outdated.includes(entry)) return [entry.artifact.package, current(entry) ?? '-', 'up to date', '']\n const bump = bumpOf({ installed: current(entry), latest: entry.artifact.version }) ?? ''\n return [entry.artifact.package, current(entry) ?? 'not installed', entry.artifact.version, bump === 'major' ? 'major · breaking' : bump]\n })\n const lines = formatTable([header, ...rows])\n logStep(`Checked ${pluralize(tracked.length, 'extension')} against the registry`)\n logBlock([\n styleText('dim', lines[0]!),\n ...lines.slice(1).map((line, index) => {\n if (!outdated.includes(tracked[index]!)) return styleText('dim', line)\n return line.endsWith('major · breaking') ? styleText('yellow', line) : line\n }),\n ])\n }\n\n if (dryRun) {\n summary('Updates available', 'planned', [`Dry run: nothing was installed. Run kubb update to install ${proposals.length === 1 ? 'it' : 'them'}.`])\n return\n }\n\n // A major can break the generated code, so it is only picked for you when you named it.\n const defaults = proposals.filter((entry) => wanted.has(entry.id) || !isMajor(entry))\n const chosen = yes\n ? defaults.map((entry) => entry.id)\n : await clack.multiselect({\n message: 'Select the updates to install',\n options: proposals.map((entry) => ({\n value: entry.id,\n label: entry.artifact.package,\n hint: `${current(entry) ?? 'not installed'} → ${entry.artifact.version}`,\n })),\n initialValues: defaults.map((entry) => entry.id),\n required: false,\n })\n if (clack.isCancel(chosen)) {\n summary('Update canceled', 'canceled', [' No changes made'])\n return\n }\n const selected = proposals.filter((entry) => chosen.includes(entry.id))\n\n const skipped = proposals\n .filter((entry) => !selected.includes(entry))\n .map((entry) => {\n const kind = entry.manifest.kind.charAt(0).toUpperCase() + entry.manifest.kind.slice(1)\n return ` ${styleText('dim', 'Skipped')} ${kind} ${entry.artifact.package} ${entry.artifact.version} ${styleText('dim', `run kubb update ${toShortId(entry.id)} later`)}`\n })\n if (!selected.length) {\n summary('No updates installed', 'canceled', [' No updates selected.', ...skipped])\n return\n }\n\n const packageManager = detectPackageManager(cwd)\n const names = selected.map(({ artifact }) => artifact.package).join(', ')\n await installWithSpinner({\n packages: selected.map(({ artifact }) => installSpec(artifact)),\n names,\n packageManager,\n cwd,\n })\n installedPackages.push(...selected.map((entry) => entry.artifact.package))\n\n // Regenerating rewrites output files, so it is asked for. `--yes` only accepts the install.\n const foundConfig = findConfigFile(cwd)\n const regenerateNow =\n foundConfig && !yes && (await clack.confirm({ message: 'Regenerate now? This rewrites the generated files.', initialValue: true })) === true\n const configPath = regenerateNow ? foundConfig : undefined\n const changed = configPath ? await regenerate({ cwd, configPath }) : undefined\n\n const generationFailed = Boolean(configPath && !changed)\n const fileCounts = { A: 0, M: 0, D: 0 }\n for (const file of changed?.files ?? []) fileCounts[file.status]++\n summary(generationFailed ? 'Extensions updated; generation failed' : 'Update complete', generationFailed ? 'warning' : 'success', [\n ` Packages ${selected.length} installed with ${packageManager.name}${skipped.length ? ` · ${skipped.length} skipped` : ''}`,\n ...skipped,\n ...(changed ? [` Files ${fileCounts.A} added · ${fileCounts.M} modified · ${fileCounts.D} deleted`] : []),\n ...(!configPath ? [' Regeneration not run'] : []),\n ...(generationFailed ? ['', 'Fix the generation error, then run kubb generate.'] : []),\n ])\n } catch (error) {\n logError(getErrorMessage(error))\n summary('Update failed', 'failed', installedPackages.length ? [` Packages ${installedPackages.join(', ')} installed`] : [' No changes made'])\n process.exitCode = 1\n }\n}\n\nexport const command = defineWithTypes<{ extensions: DryRunExtensions }>()({\n name: 'update',\n description: 'Update installed extensions, regenerate, and summarize file changes.',\n examples: ['kubb update', 'kubb update --dry-run', 'kubb update plugin-zod plugin-ts --yes'].join('\\n'),\n args: {\n ids: {\n type: 'positional',\n description: 'Registry ids to update, all installed extensions when omitted',\n multiple: true,\n },\n ...yesArg,\n },\n run: ({ values, extensions }) => run({ ids: values.ids ?? [], dryRun: extensions[dryRunId].enabled, yes: values.yes }),\n})\n","import { styleText } from 'node:util'\nimport dryrun from '@gunshi/plugin-dryrun'\nimport { cli } from 'gunshi'\nimport { isDisabled as isTelemetryDisabled } from './Telemetry.ts'\nimport { version } from '../package.json'\nimport { getBanner, wantsMascot } from './ui/mascot.ts'\nimport { command as generateCommand } from './commands/generate.ts'\nimport { command as mcpCommand } from './commands/mcp.ts'\nimport { command as studioCommand, routeStudioFlags } from './commands/studio/index.ts'\nimport { command as validateCommand } from './commands/validate.ts'\nimport { resolveDeprecatedFlags } from './deprecatedFlags.ts'\nimport { command as addCommand } from './runners/add/run.ts'\nimport { command as initCommand } from './runners/init/run.ts'\nimport { command as listCommand } from './runners/list/run.ts'\nimport { command as updateCommand } from './runners/update/run.ts'\n\n/** Flags that short-circuit execution (help and version). The telemetry notice is suppressed for these. */\nconst QUIET_FLAGS = new Set<string>(['--help', '-h', '--version', '-v', '--json'])\n\n/**\n * Entry point for the `kubb` CLI. Prints the telemetry notice unless telemetry is disabled or a\n * quiet flag is passed, then runs the given command, or `generate` when none is given.\n */\nexport async function run(argv: Array<string> = process.argv.slice(2)): Promise<void> {\n const args = routeStudioFlags(resolveDeprecatedFlags(argv))\n const isQuietFlag = args.some((arg) => QUIET_FLAGS.has(arg))\n // `--reporter json` and `--json` own stdout, so the header must not land there.\n const isJsonOutput =\n args.includes('--json') || args.some((arg, index) => /^--reporter=.*\\bjson\\b/.test(arg) || (arg === '--reporter' && /\\bjson\\b/.test(args[index + 1] ?? '')))\n\n // stderr, so the notice never lands in a stream a client parses, such as `kubb mcp` stdio.\n if (!isTelemetryDisabled() && !isQuietFlag) {\n console.error(\n `${styleText('yellow', 'Notice:')} Kubb collects anonymous telemetry data to help improve the tool. No personal data or file contents are collected. \\nTo disable, set ${styleText('cyan', 'KUBB_DISABLE_TELEMETRY=1')}.\\n`,\n )\n }\n\n // validate, mcp and studio import their runner when they run, so an optional peer (@kubb/adapter-oas, @kubb/mcp, @kubb/studio) loads only then.\n await cli(args, generateCommand, {\n name: 'kubb',\n version,\n // Not `generateCommand.description`: gunshi prints this on every subcommand's help too, so\n // `kubb studio --help` would open with a paragraph about generating types.\n description: 'Generate code from an OpenAPI specification, manage Kubb extensions, or connect the project to Kubb Studio.',\n subCommands: {\n generate: generateCommand,\n init: initCommand,\n validate: validateCommand,\n mcp: mcpCommand,\n studio: studioCommand,\n add: addCommand,\n update: updateCommand,\n list: listCommand,\n },\n fallbackToEntry: true,\n // The mascot opens only the long-running commands; `generate` turns this off and plays its animated banner instead.\n renderHeader: isJsonOutput\n ? null\n : async (ctx) => {\n if (!wantsMascot({ commandPath: ctx.commandPath, values: ctx.values })) return ''\n\n // Gunshi adds a blank line after returned headers; the first prompt already supplies its guide.\n ctx.log(getBanner(version, ctx.commandPath.join(' ') || 'generate'))\n return ''\n },\n strict: true,\n plugins: [dryrun({ name: 'dry-run' })],\n onErrorCommand: async (_ctx, error) => {\n process.exitCode = 1\n console.error(error)\n },\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAUA,MAAa,YAAY,EACvB,QAAQ;CACN,MAAM;CACN,aAAa;CACb,OAAO;AACT,EAC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