@kubb/cli 5.18.0 → 5.18.1

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 (87) hide show
  1. package/dist/{Telemetry-CEZZ5IZu.cjs → Telemetry-BYgov4z_.cjs} +2 -2
  2. package/dist/{Telemetry-CEZZ5IZu.cjs.map → Telemetry-BYgov4z_.cjs.map} +1 -1
  3. package/dist/{Telemetry-B53gR0bc.js → Telemetry-Cp69T_s5.js} +2 -2
  4. package/dist/{Telemetry-B53gR0bc.js.map → Telemetry-Cp69T_s5.js.map} +1 -1
  5. package/dist/{background-C0z3j90s.js → background-Bfi--bxk.js} +1 -1
  6. package/dist/{background-CLQbyB3a.cjs → background-C3uNn_Fm.cjs} +2 -2
  7. package/dist/{background-CLQbyB3a.cjs.map → background-C3uNn_Fm.cjs.map} +1 -1
  8. package/dist/{background-ZOt9iygO.js → background-DMrtU-ho.js} +2 -2
  9. package/dist/{background-ZOt9iygO.js.map → background-DMrtU-ho.js.map} +1 -1
  10. package/dist/{configFile-CVfWdtKh.cjs → configFile-BPHxtrEM.cjs} +2 -2
  11. package/dist/{configFile-CVfWdtKh.cjs.map → configFile-BPHxtrEM.cjs.map} +1 -1
  12. package/dist/{configFile-IHj8fRIw.js → configFile-L5i7gGUc.js} +2 -2
  13. package/dist/{configFile-IHj8fRIw.js.map → configFile-L5i7gGUc.js.map} +1 -1
  14. package/dist/index.cjs +11 -11
  15. package/dist/index.js +11 -11
  16. package/dist/{installWithSpinner-BAlTSQlE.js → installWithSpinner-CNDzLZw-.js} +2 -2
  17. package/dist/{installWithSpinner-BAlTSQlE.js.map → installWithSpinner-CNDzLZw-.js.map} +1 -1
  18. package/dist/{installWithSpinner-X9J7yxiR.cjs → installWithSpinner-CnE4dIza.cjs} +2 -2
  19. package/dist/{installWithSpinner-X9J7yxiR.cjs.map → installWithSpinner-CnE4dIza.cjs.map} +1 -1
  20. package/dist/{mcp-BkXSM9Fj.cjs → mcp-BJN5QxDo.cjs} +2 -2
  21. package/dist/{mcp-BkXSM9Fj.cjs.map → mcp-BJN5QxDo.cjs.map} +1 -1
  22. package/dist/{mcp-Dq3uJ97p.js → mcp-UEW7we9u.js} +2 -2
  23. package/dist/{mcp-Dq3uJ97p.js.map → mcp-UEW7we9u.js.map} +1 -1
  24. package/dist/package-BpdY4HQ3.js +5 -0
  25. package/dist/package-BpdY4HQ3.js.map +1 -0
  26. package/dist/{package-CHCCjtOD.cjs → package-Dggb9xyT.cjs} +2 -2
  27. package/dist/package-Dggb9xyT.cjs.map +1 -0
  28. package/dist/{run-Cgy4_JPy.js → run-5u7cHD85.js} +4 -4
  29. package/dist/{run-Cgy4_JPy.js.map → run-5u7cHD85.js.map} +1 -1
  30. package/dist/{run-DNWkBPyg.js → run-BPNvgmxl.js} +4 -4
  31. package/dist/{run-DNWkBPyg.js.map → run-BPNvgmxl.js.map} +1 -1
  32. package/dist/{run-CGb2TsqT.cjs → run-Bhnfsdiy.cjs} +5 -5
  33. package/dist/{run-CGb2TsqT.cjs.map → run-Bhnfsdiy.cjs.map} +1 -1
  34. package/dist/{run-DT4hTOR2.cjs → run-BxNbFsmc.cjs} +3 -3
  35. package/dist/{run-DT4hTOR2.cjs.map → run-BxNbFsmc.cjs.map} +1 -1
  36. package/dist/{run-BZa2J0G_.js → run-C0R7L7L2.js} +3 -3
  37. package/dist/{run-BZa2J0G_.js.map → run-C0R7L7L2.js.map} +1 -1
  38. package/dist/{run-CehHtecn.js → run-CC-EP2jq.js} +2 -2
  39. package/dist/{run-CehHtecn.js.map → run-CC-EP2jq.js.map} +1 -1
  40. package/dist/{run-Djq5PZCq.js → run-CHY2W9iA.js} +5 -5
  41. package/dist/{run-Djq5PZCq.js.map → run-CHY2W9iA.js.map} +1 -1
  42. package/dist/{run-DyF7mcCI.cjs → run-CJU21pHF.cjs} +4 -4
  43. package/dist/{run-DyF7mcCI.cjs.map → run-CJU21pHF.cjs.map} +1 -1
  44. package/dist/{run-CCcxqBn-.js → run-CdTnJT4l.js} +1 -1
  45. package/dist/{run-fS5N3YT4.cjs → run-ClGHsAGH.cjs} +2 -2
  46. package/dist/{run-fS5N3YT4.cjs.map → run-ClGHsAGH.cjs.map} +1 -1
  47. package/dist/{run-DCggecSY.cjs → run-D-FHx4uQ.cjs} +4 -4
  48. package/dist/{run-DCggecSY.cjs.map → run-D-FHx4uQ.cjs.map} +1 -1
  49. package/dist/{run-B-fiM91f.js → run-DExY9DhW.js} +2 -2
  50. package/dist/{run-B-fiM91f.js.map → run-DExY9DhW.js.map} +1 -1
  51. package/dist/{run-Nh2f1Sw4.cjs → run-DMFf2RZD.cjs} +2 -2
  52. package/dist/{run-Nh2f1Sw4.cjs.map → run-DMFf2RZD.cjs.map} +1 -1
  53. package/dist/{run-P42MCJh7.js → run-DZ1QTR1a.js} +5 -5
  54. package/dist/{run-P42MCJh7.js.map → run-DZ1QTR1a.js.map} +1 -1
  55. package/dist/{run-DHfFHNfG.js → run-Dx8QpT_k.js} +3 -3
  56. package/dist/{run-DHfFHNfG.js.map → run-Dx8QpT_k.js.map} +1 -1
  57. package/dist/{run-qtDg9hZk.cjs → run-LKk28sEo.cjs} +5 -5
  58. package/dist/{run-qtDg9hZk.cjs.map → run-LKk28sEo.cjs.map} +1 -1
  59. package/dist/{run-PqKD04Dm.cjs → run-xcqUiR62.cjs} +3 -3
  60. package/dist/{run-PqKD04Dm.cjs.map → run-xcqUiR62.cjs.map} +1 -1
  61. package/dist/{snapshot-Dhh62LA9.cjs → snapshot-BpeflkVz.cjs} +2 -2
  62. package/dist/{snapshot-Dhh62LA9.cjs.map → snapshot-BpeflkVz.cjs.map} +1 -1
  63. package/dist/{snapshot-C0WMz4h6.js → snapshot-CGIL9UYR.js} +2 -2
  64. package/dist/{snapshot-C0WMz4h6.js.map → snapshot-CGIL9UYR.js.map} +1 -1
  65. package/dist/{status-Boyu19J6.cjs → status-B0x3TjS6.cjs} +2 -2
  66. package/dist/{status-Boyu19J6.cjs.map → status-B0x3TjS6.cjs.map} +1 -1
  67. package/dist/{status-DGUZGoOW.js → status-BpRlYybp.js} +2 -2
  68. package/dist/{status-DGUZGoOW.js.map → status-BpRlYybp.js.map} +1 -1
  69. package/dist/{studio-DO_ZVow1.js → studio-BZ03iok0.js} +11 -11
  70. package/dist/{studio-DO_ZVow1.js.map → studio-BZ03iok0.js.map} +1 -1
  71. package/dist/{studio-B9S_cGKE.cjs → studio-DXxg-23D.cjs} +11 -11
  72. package/dist/{studio-B9S_cGKE.cjs.map → studio-DXxg-23D.cjs.map} +1 -1
  73. package/dist/studioWorker.js +2 -2
  74. package/dist/{utils-uSJAZuvP.cjs → utils-DeXBGzGJ.cjs} +2 -2
  75. package/dist/utils-DeXBGzGJ.cjs.map +1 -0
  76. package/dist/{utils-CeMUE4P0.js → utils-f1C7RiEI.js} +2 -2
  77. package/dist/utils-f1C7RiEI.js.map +1 -0
  78. package/dist/{validate-CU54Odyp.cjs → validate-D_aoov0x.cjs} +2 -2
  79. package/dist/{validate-CU54Odyp.cjs.map → validate-D_aoov0x.cjs.map} +1 -1
  80. package/dist/{validate-W_4MBwS4.js → validate-HLW1Lljc.js} +2 -2
  81. package/dist/{validate-W_4MBwS4.js.map → validate-HLW1Lljc.js.map} +1 -1
  82. package/package.json +7 -7
  83. package/dist/package-BKe7tRfp.js +0 -5
  84. package/dist/package-BKe7tRfp.js.map +0 -1
  85. package/dist/package-CHCCjtOD.cjs.map +0 -1
  86. package/dist/utils-CeMUE4P0.js.map +0 -1
  87. package/dist/utils-uSJAZuvP.cjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"configFile-IHj8fRIw.js","names":[],"sources":["../../../internals/shared/src/configFile/ast.ts","../../../internals/shared/src/configFile/types.ts","../../../internals/shared/src/configFile/rules.ts","../../../internals/shared/src/configFile/text.ts","../../../internals/shared/src/configFile/configFile.ts"],"sourcesContent":["import { getErrorMessage } from '@internals/utils'\nimport { type Comment, type Expression, type Program, parse } from 'yuku-parser'\n\nexport type {\n ArrayExpression,\n AssignmentExpression,\n BindingProperty,\n CallExpression,\n Comment,\n Expression,\n ImportDeclaration,\n ObjectExpression,\n ObjectPropertyKind,\n Program,\n RestElement,\n SpreadElement,\n VariableDeclaration,\n} from 'yuku-parser'\n\n/** Node types the config editor reads from the yuku AST. */\nexport const nodeTypes = {\n arrayExpression: 'ArrayExpression',\n arrowFunctionExpression: 'ArrowFunctionExpression',\n assignmentExpression: 'AssignmentExpression',\n blockStatement: 'BlockStatement',\n callExpression: 'CallExpression',\n exportDefaultDeclaration: 'ExportDefaultDeclaration',\n expressionStatement: 'ExpressionStatement',\n functionExpression: 'FunctionExpression',\n identifier: 'Identifier',\n importDeclaration: 'ImportDeclaration',\n importSpecifier: 'ImportSpecifier',\n literal: 'Literal',\n memberExpression: 'MemberExpression',\n objectExpression: 'ObjectExpression',\n objectPattern: 'ObjectPattern',\n property: 'Property',\n returnStatement: 'ReturnStatement',\n spreadElement: 'SpreadElement',\n tSAsExpression: 'TSAsExpression',\n tSSatisfiesExpression: 'TSSatisfiesExpression',\n templateLiteral: 'TemplateLiteral',\n unaryExpression: 'UnaryExpression',\n variableDeclaration: 'VariableDeclaration',\n} as const\n\nexport const commentTypes = { line: 'Line' } as const\nexport const propertyKinds = { init: 'init' } as const\nexport const unaryOperators = { minus: '-', plus: '+' } as const\nconst diagnosticSeverities = { error: 'error' } as const\n\n/** A parsed file: its statements and every comment in it, or why it could not be parsed. */\ntype ParsedSource = { program: Program; comments: Array<Comment> } | { reason: string }\n\n/**\n * Parses `source` as a TypeScript module. Never throws: a syntax error, or a native parser that\n * cannot load on this platform, comes back as a `reason`.\n */\nexport function parseSource(source: string): ParsedSource {\n try {\n // Parentheses are dropped, so `export default (defineConfig({}))` reads as the call itself.\n const { program, comments, diagnostics } = parse(source, { lang: 'ts', sourceType: 'module', preserveParens: false })\n if (diagnostics.some((diagnostic) => diagnostic.severity === diagnosticSeverities.error)) return { reason: 'the config file could not be parsed' }\n return { program, comments }\n } catch (error) {\n return { reason: `the config parser could not load on this platform: ${getErrorMessage(error)}` }\n }\n}\n\n/** Parses `source` as one expression, such as a commented-out `pluginTs({ ... })` call. */\nexport function parseExpression(source: string): Expression | undefined {\n const parsed = parseSource(source)\n if ('reason' in parsed) return undefined\n const [statement] = parsed.program.body\n return parsed.program.body.length === 1 && statement?.type === nodeTypes.expressionStatement ? statement.expression : undefined\n}\n","import type { ValueOf } from '@internals/utils'\nimport type { ExtensionKind, ExtensionManifest } from '@kubb/core'\n\n/** Which `defineConfig(...)` entry an edit targets: its index or `name`, the first entry when omitted. */\nexport type ConfigRef = string | number\n\n/** A literal option value that survives a JSON round trip. */\nexport type OptionValue = string | number | boolean | null | Array<OptionValue> | { [key: string]: OptionValue }\n\nexport const extensionKinds = { plugin: 'plugin', adapter: 'adapter', parser: 'parser' } as const satisfies Record<string, ExtensionKind>\n\nexport const ConfigEditOperation = {\n SET_OPTION: 'set-option',\n REMOVE_OPTION: 'remove-option',\n ADD_PLUGIN: 'add-plugin',\n REMOVE_EXTENSION: 'remove-extension',\n DISABLE_PLUGIN: 'disable-plugin',\n ENABLE_PLUGIN: 'enable-plugin',\n SET_INPUT: 'set-input',\n SET_OUTPUT: 'set-output',\n REMOVE_OUTPUT: 'remove-output',\n} as const\nexport type ConfigEditOperation = ValueOf<typeof ConfigEditOperation>\n\n/**\n * One change to `kubb.config.ts`. `plugin` is the package name, and `kind` picks the `plugins` entry\n * (default), the `adapter`, or a `parsers` entry. `path` walks nested option objects.\n */\nexport type ConfigEdit =\n | { operation: typeof ConfigEditOperation.SET_OPTION; config?: ConfigRef; kind?: ExtensionKind; plugin: string; path: Array<string>; value: unknown }\n | { operation: typeof ConfigEditOperation.REMOVE_OPTION; config?: ConfigRef; kind?: ExtensionKind; plugin: string; path: Array<string> }\n /** With `kind: 'parser'`, adds to `parsers`. A config without `parsers` gets the defaults written next to it, so they keep running. */\n | {\n operation: typeof ConfigEditOperation.ADD_PLUGIN\n config?: ConfigRef\n kind?: typeof extensionKinds.plugin | typeof extensionKinds.parser\n plugin: string\n options?: Record<string, unknown>\n }\n /** Deletes every call of a plugin, or a parser with `kind: 'parser'`, a disabled block included, and the imports nothing else uses. */\n | {\n operation: typeof ConfigEditOperation.REMOVE_EXTENSION\n config?: ConfigRef\n kind?: typeof extensionKinds.plugin | typeof extensionKinds.parser\n plugin: string\n }\n | { operation: typeof ConfigEditOperation.DISABLE_PLUGIN; config?: ConfigRef; plugin: string }\n | { operation: typeof ConfigEditOperation.ENABLE_PLUGIN; config?: ConfigRef; plugin: string }\n | { operation: typeof ConfigEditOperation.SET_INPUT; config?: ConfigRef; input: string }\n | { operation: typeof ConfigEditOperation.SET_OUTPUT; config?: ConfigRef; path: Array<string>; value: unknown }\n | { operation: typeof ConfigEditOperation.REMOVE_OUTPUT; config?: ConfigRef; path: Array<string> }\n\n/** Option keys, each with whether Studio may write it. `locked` lists the code paths inside a partly literal object. */\nexport type OptionsView = Record<string, { literal: boolean; value?: OptionValue; locked?: Array<Array<string>> }>\n\n/** A factory call in `plugins`, `adapter`, or `parsers`. `importName` is the local name, alias included. */\nexport type PluginView = {\n importName: string\n packageName: string\n options: OptionsView\n /** The call is commented out by `disable-plugin`. */\n disabled?: true\n}\n\nexport type ConfigView = {\n name?: string\n plugins: Array<PluginView>\n adapter?: PluginView\n parsers?: Array<PluginView>\n /** The root `output` members Studio may set, absent when `output` is not an object literal. */\n output?: OptionsView\n}\n\n/** The config file as Studio may edit it, or why it cannot. */\nexport type ConfigFileView = { managed: true; configs: Array<ConfigView> } | { managed: false; reason: string }\n\nexport type ConfigEditOutcome = {\n edit: ConfigEdit\n applied: boolean\n reason?: string\n}\n\nexport type ExtensionEntry = {\n package: string\n version: string\n manifest: ExtensionManifest\n /** Ships with `kubb` at its version, so updating `kubb` updates it and `kubb update` cannot. */\n bundled?: true\n}\n\n/** Installed extensions by package name, the only ones Studio may import besides `@kubb/plugin-*`. */\nexport type InstalledExtensions = ReadonlyMap<string, ExtensionEntry>\n","import { type ExtensionKind, isPackageName } from '@kubb/core'\nimport { camelCase } from '@internals/utils'\nimport { extensionKinds, type InstalledExtensions, type OptionValue } from './types.ts'\n\n/** `@kubb/plugin-ts` becomes `plugin-ts`, the `name` Kubb plugin factories use. */\nexport function toPluginName(packageName: string): string {\n return packageName.split('/').pop() ?? packageName\n}\n\n/** `@kubb/plugin-react-query` becomes `pluginReactQuery`, the export a plugin package uses by convention. */\nexport function toExportName(packageName: string): string {\n return camelCase(toPluginName(packageName))\n}\n\nconst KUBB_PLUGIN_SPECIFIER = /^@kubb\\/plugin-[\\w.-]+$/\n\n/** Only a `@kubb/plugin-*` package or an installed extension of `kind` may be imported, never a path or URL. */\nexport function isAllowedPlugin({\n packageName,\n extensions,\n kind = extensionKinds.plugin,\n}: {\n packageName: string\n extensions: InstalledExtensions\n kind?: ExtensionKind\n}): boolean {\n if (!isPackageName(packageName)) return false\n return (kind === extensionKinds.plugin && KUBB_PLUGIN_SPECIFIER.test(packageName)) || extensions.get(packageName)?.manifest.kind === kind\n}\n\nconst UNSAFE_KEYS = new Set(['__proto__', 'constructor', 'prototype'])\n\n/** Whether `key` can be an option key without reaching the object's prototype. */\nexport function isSafeKey(key: string): boolean {\n return !UNSAFE_KEYS.has(key)\n}\n\nexport function isPlainObject(value: unknown): value is Record<string, unknown> {\n if (typeof value !== 'object' || value === null) return false\n const prototype = Object.getPrototypeOf(value)\n return prototype === null || prototype === Object.prototype\n}\n\n/** Whether `value` survives a JSON round trip, so an edit never writes a lossy copy into the file. */\nexport function isOptionValue(value: unknown): value is OptionValue {\n if (value === null || typeof value === 'string' || typeof value === 'boolean') return true\n if (typeof value === 'number') return Number.isFinite(value)\n if (Array.isArray(value)) return value.every(isOptionValue)\n if (isPlainObject(value)) return Object.entries(value).every(([key, entry]) => isSafeKey(key) && isOptionValue(entry))\n\n return false\n}\n\n/** The root `output` members Studio may set, with the values each takes. */\nconst OUTPUT_VALUES: Record<string, (value: unknown) => boolean> = {\n barrel: (value) => value === false || (isPlainObject(value) && Object.keys(value).length === 1 && (value.type === 'named' || value.type === 'all')),\n format: (value) => value === false || ['auto', 'prettier', 'biome', 'oxfmt'].includes(value as string),\n lint: (value) => value === false || ['auto', 'eslint', 'biome', 'oxlint'].includes(value as string),\n clean: (value) => typeof value === 'boolean',\n defaultBanner: (value) => value === false || value === 'simple' || value === 'full',\n}\n\nexport function isOutputKey(key: string): boolean {\n return Object.hasOwn(OUTPUT_VALUES, key)\n}\n\nexport function isOutputValue({ key, value }: { key: string; value: unknown }): boolean {\n return isOutputKey(key) && OUTPUT_VALUES[key]!(value)\n}\n\nexport function pickOutput<T>(output: Record<string, T>): Record<string, T> {\n return Object.fromEntries(Object.entries(output).filter(([key]) => isOutputKey(key)))\n}\n","import type { ValueOf } from '@internals/utils'\nimport { type ArrayExpression, nodeTypes, type ObjectExpression } from './ast.ts'\nimport type { OptionValue } from './types.ts'\n\n/**\n * A valid JavaScript identifier, so an import name can only ever print as `import { name } from`,\n * never as source that breaks out of the import statement.\n */\nexport const IDENTIFIER_PATTERN = /^[A-Za-z_$][\\w$]*$/\n\nexport const quotes = { single: `'`, double: `\"` } as const\nexport type Quote = ValueOf<typeof quotes>\n\n/** `source` with the text between `start` and `end` replaced by `text`. */\nexport function replaceText(source: string, start: number, end: number, text = ''): string {\n return `${source.slice(0, start)}${text}${source.slice(end)}`\n}\n\n/** The 1-based line and 0-based column of `offset` in `source`. */\nexport function getPosition(source: string, offset: number): { line: number; column: number } {\n return { line: source.slice(0, offset).split('\\n').length, column: offset - source.lastIndexOf('\\n', offset - 1) - 1 }\n}\n\n/** Writes `value` as a single-line literal with the file's quote style. */\nexport function printValue(value: OptionValue, quote: Quote): string {\n if (typeof value === 'string') {\n // JSON's escaping covers every character that could end the literal or the line.\n const escaped = JSON.stringify(value).slice(1, -1)\n return quote === quotes.double ? `\"${escaped}\"` : `'${escaped.replaceAll(`\\\\\"`, `\"`).replaceAll(`'`, `\\\\'`)}'`\n }\n if (value === null || typeof value !== 'object') return String(value)\n if (Array.isArray(value)) return `[${value.map((item) => printValue(item, quote)).join(', ')}]`\n\n const entries = Object.entries(value)\n return entries.length ? `{ ${entries.map(([key, item]) => `${printKey(key, quote)}: ${printValue(item, quote)}`).join(', ')} }` : '{}'\n}\n\n/** An object key as source text: bare when it is an identifier, quoted otherwise. */\nexport function printKey(key: string, quote: Quote): string {\n return IDENTIFIER_PATTERN.test(key) ? key : printValue(key, quote)\n}\n\n/** `value` wrapped in one object per key of `path`: `wrapPath(['enum', 'type'], 'enum')` is `{ enum: { type: 'enum' } }`. */\nexport function wrapPath(path: Array<string>, value: OptionValue): OptionValue {\n return path.reduceRight<OptionValue>((inner, key) => ({ [key]: inner }), value)\n}\n\n/**\n * Adds `text` as the last item of an object or array literal, following its layout: on a line of\n * its own with the last item's indentation when the literal spans lines, inline otherwise.\n */\nexport function appendItem(source: string, container: ObjectExpression | ArrayExpression, text: string): string {\n const { start, end } = container\n const items: Array<{ start: number; end: number } | null> = container.type === nodeTypes.objectExpression ? container.properties : container.elements\n const last = items.filter((item) => item !== null).at(-1)\n\n if (!last) {\n const inner = source.slice(start + 1, end - 1)\n // A comment inside the empty literal stays, after the new item.\n if (inner.trim()) return replaceText(source, start + 1, start + 1, /^\\s/.test(inner) ? `${text},` : `${text}, `)\n return replaceText(source, start, end, container.type === nodeTypes.objectExpression ? `{ ${text} }` : `[${text}]`)\n }\n\n const between = source.slice(last.end, end - 1)\n // The closing bracket shares the last item's line: add the item inline.\n if (!between.includes('\\n')) return replaceText(source, last.end, last.end, `, ${text}`)\n\n const lineStart = source.lastIndexOf('\\n', last.start - 1) + 1\n const indent = source.slice(lineStart).match(/^[ \\t]*/)?.[0] ?? ''\n // After the last item's comma and any comment on its line, so neither moves. `between` holds a\n // newline, so one always follows.\n const lineEnd = source.indexOf('\\n', last.end)\n const comma = /^\\s*,/.test(between)\n\n return `${source.slice(0, last.end)}${comma ? '' : ','}${source.slice(last.end, lineEnd)}\\n${indent}${text}${comma ? ',' : ''}${source.slice(lineEnd)}`\n}\n\n/** Drops the item at `index` from an object or array literal, with its own lines when it sits on them alone. */\nexport function removeItem(source: string, node: ObjectExpression | ArrayExpression, index: number): string {\n const items: Array<{ start: number; end: number }> =\n node.type === nodeTypes.objectExpression ? node.properties : node.elements.filter((element) => element !== null)\n if (items.length === 1) return replaceText(source, node.start, node.end, node.type === nodeTypes.objectExpression ? '{}' : '[]')\n\n const { start, end } = items[index]!\n const lineStart = source.lastIndexOf('\\n', start - 1) + 1\n const nextNewline = source.indexOf('\\n', end)\n const lineEnd = nextNewline === -1 ? source.length : nextNewline\n if (!source.slice(lineStart, start).trim() && /^\\s*,?\\s*(\\/\\/.*)?$/.test(source.slice(end, lineEnd))) {\n return replaceText(source, lineStart, Math.min(lineEnd + 1, source.length))\n }\n\n const next = items[index + 1]\n return next ? replaceText(source, start, next.start) : replaceText(source, items[index - 1]!.end, end)\n}\n","import type { ExtensionKind } from '@kubb/core'\nimport { getErrorMessage, read, writeRaw } from '@internals/utils'\nimport type { ValueOf } from '@internals/utils'\nimport {\n type AssignmentExpression,\n type BindingProperty,\n type CallExpression,\n type Comment,\n type Expression,\n type ImportDeclaration,\n type ObjectExpression,\n type ObjectPropertyKind,\n type Program,\n type RestElement,\n type SpreadElement,\n type VariableDeclaration,\n commentTypes,\n nodeTypes,\n parseExpression,\n parseSource,\n propertyKinds,\n unaryOperators,\n} from './ast.ts'\nimport { isAllowedPlugin, isOptionValue, isOutputKey, isOutputValue, isSafeKey, pickOutput, toExportName } from './rules.ts'\nimport { appendItem, getPosition, IDENTIFIER_PATTERN, printKey, printValue, quotes, type Quote, removeItem, replaceText, wrapPath } from './text.ts'\nimport {\n type ConfigEdit,\n ConfigEditOperation,\n type ConfigEditOutcome,\n type ConfigFileView,\n type ConfigRef,\n type ConfigView,\n extensionKinds,\n type InstalledExtensions,\n type OptionsView,\n type OptionValue,\n type PluginView,\n} from './types.ts'\n\n/** The marker `disable-plugin` writes, with the block's line count so `enable-plugin` restores exactly those lines. */\nconst DISABLED_MARKER_PATTERN = /^kubb:disabled (.+)\\s+(\\d+)$/\n\nconst OPERATIONS = new Set<string>(Object.values(ConfigEditOperation))\nconst OPTION_OPERATIONS = new Set<string>([ConfigEditOperation.SET_OPTION, ConfigEditOperation.REMOVE_OPTION])\nconst OUTPUT_OPERATIONS = new Set<string>([ConfigEditOperation.SET_OUTPUT, ConfigEditOperation.REMOVE_OUTPUT])\nconst KINDS = new Set<string>(Object.values(extensionKinds))\n\n/** Identifiers the editor matches by name. */\nconst identifiers = { defineConfig: 'defineConfig', require: 'require', module: 'module', exports: 'exports' } as const\n\nconst moduleKinds = { esm: 'esm', cjs: 'cjs' } as const\ntype ModuleKind = ValueOf<typeof moduleKinds>\n\ntype EditResult = { source: string } | { reason: string }\ntype ParsedConfig = { program: Program; comments: Array<Comment>; configs: Array<ObjectExpression>; kind: ModuleKind }\ntype ValueNode = Expression | SpreadElement | null | undefined\ntype Import = { from: string; exported: string }\ntype FactoryCall = { importName: string; exportName: string; packageName: string; call: CallExpression }\ntype DisabledBlock = { packageName: string; line: number; end: number; code: Array<string> }\ntype OutputEdit = Extract<ConfigEdit, { operation: typeof ConfigEditOperation.SET_OUTPUT | typeof ConfigEditOperation.REMOVE_OUTPUT }>\ntype OptionEdit = Extract<ConfigEdit, { operation: typeof ConfigEditOperation.SET_OPTION | typeof ConfigEditOperation.REMOVE_OPTION }>\ntype AddPluginEdit = Extract<ConfigEdit, { operation: typeof ConfigEditOperation.ADD_PLUGIN }>\ntype DisablePluginEdit = Extract<ConfigEdit, { operation: typeof ConfigEditOperation.DISABLE_PLUGIN }>\ntype RemoveExtensionEdit = Extract<ConfigEdit, { operation: typeof ConfigEditOperation.REMOVE_EXTENSION }>\n\nfunction isNonEmptyString(value: unknown): value is string {\n return typeof value === 'string' && value !== ''\n}\n\n/** Edits cross the wire, so their shape is checked before anything reads them. */\nfunction validateEdit(edit: ConfigEdit): string | undefined {\n const { operation, plugin, config, path, kind, input } = (typeof edit === 'object' && edit !== null ? edit : {}) as Record<string, unknown>\n\n if (typeof operation !== 'string' || !OPERATIONS.has(operation)) return `unknown operation ${JSON.stringify(operation)}`\n if (config !== undefined && typeof config !== 'string' && !Number.isSafeInteger(config)) return 'config must name an entry or give its index'\n\n if (operation === ConfigEditOperation.SET_INPUT) {\n return typeof input === 'string' && input.trim() !== '' ? undefined : 'the edit names no input'\n }\n\n const isOption = OPTION_OPERATIONS.has(operation)\n const isOutput = OUTPUT_OPERATIONS.has(operation)\n\n if (!isOutput && !isNonEmptyString(plugin)) return 'the edit names no plugin'\n\n if (kind !== undefined) {\n if (typeof kind !== 'string' || !KINDS.has(kind)) return `unknown kind ${JSON.stringify(kind)}`\n const takesKind = operation === ConfigEditOperation.ADD_PLUGIN || operation === ConfigEditOperation.REMOVE_EXTENSION\n if (takesKind && kind === extensionKinds.adapter) return `${operation} takes a plugin or a parser, since a config has one adapter`\n if (!isOption && !takesKind) return `${operation} edits the plugins array, so it takes no kind`\n }\n\n if (!isOption && !isOutput) return undefined\n\n if (!Array.isArray(path) || !path.every(isNonEmptyString)) return 'path must be a list of option names'\n if (path.length === 0) return 'no option path given'\n\n const unsafe = path.find((key) => !isSafeKey(key))\n if (unsafe !== undefined) return `${unsafe} cannot be used as an option name`\n\n if (isOutput && !isOutputKey(path[0]!)) return `output.${path[0]} can only be changed in the config file`\n\n return undefined\n}\n\n// Finding the config\n\n/** Steps through `as`/`satisfies` and `() => ...` wrappers to the config object. */\nfunction unwrapValue(node: ValueNode): ValueNode {\n if (!node) return undefined\n if (node.type === nodeTypes.tSAsExpression || node.type === nodeTypes.tSSatisfiesExpression) return unwrapValue(node.expression)\n if (node.type !== nodeTypes.arrowFunctionExpression && node.type !== nodeTypes.functionExpression) return node\n if (node.body?.type !== nodeTypes.blockStatement) return unwrapValue(node.body as Expression | null)\n\n const returned = node.body.body.find((statement) => statement.type === nodeTypes.returnStatement)\n return unwrapValue(returned?.type === nodeTypes.returnStatement ? returned.argument : undefined)\n}\n\nfunction isModuleExports(node: AssignmentExpression['left']): boolean {\n return (\n node.type === nodeTypes.memberExpression &&\n !node.computed &&\n node.object.type === nodeTypes.identifier &&\n node.object.name === identifiers.module &&\n node.property.type === nodeTypes.identifier &&\n node.property.name === identifiers.exports\n )\n}\n\n/** The exported config value and how the file exports it. */\nfunction findExport(program: Program): { exported: ValueNode; kind: ModuleKind } {\n for (const node of program.body) {\n if (node.type === nodeTypes.exportDefaultDeclaration) {\n // A `function` or `class` declaration is never a `defineConfig(...)` call, so `findConfigs` refuses it.\n return { exported: node.declaration as Expression, kind: moduleKinds.esm }\n }\n if (node.type === nodeTypes.expressionStatement && node.expression.type === nodeTypes.assignmentExpression && isModuleExports(node.expression.left)) {\n return { exported: node.expression.right, kind: moduleKinds.cjs }\n }\n }\n return { exported: undefined, kind: moduleKinds.esm }\n}\n\n/** Every config object in `export default` or `module.exports = defineConfig(...)`, or why the file is unmanaged. */\nfunction findConfigs(source: string): ParsedConfig | { reason: string } {\n const parsed = parseSource(source)\n if ('reason' in parsed) return parsed\n\n const { exported, kind } = findExport(parsed.program)\n const value = unwrapValue(exported)\n if (!value) return { reason: 'no `export default` or `module.exports` found' }\n if (value.type !== nodeTypes.callExpression || value.callee.type !== nodeTypes.identifier || value.callee.name !== identifiers.defineConfig) {\n return { reason: 'the exported config is not a defineConfig(...) call' }\n }\n\n const argument = unwrapValue(value.arguments[0])\n if (!argument) return { reason: 'defineConfig(...) was called without a config' }\n\n const entries = argument.type === nodeTypes.arrayExpression ? argument.elements.map((element) => unwrapValue(element)) : [argument]\n const configs = entries.filter((entry): entry is ObjectExpression => entry?.type === nodeTypes.objectExpression)\n if (configs.length !== entries.length) return { reason: 'config is not an object literal' }\n\n return { ...parsed, configs, kind }\n}\n\nfunction findConfigEntry(configs: Array<ObjectExpression>, ref: ConfigRef | undefined): ObjectExpression | undefined {\n return typeof ref === 'string' ? configs.find((entry) => getConfigName(entry) === ref) : configs[ref ?? 0]\n}\n\n// Reading object literals\n\nfunction getKey(entry: ObjectPropertyKind | BindingProperty | RestElement): string | undefined {\n if (entry.type !== nodeTypes.property || entry.computed) return undefined\n if (entry.key.type === nodeTypes.identifier) return entry.key.name\n return entry.key.type === nodeTypes.literal && typeof entry.key.value === 'string' ? entry.key.value : undefined\n}\n\n/** The last one wins when the key repeats, as at runtime. */\nfunction findProperty(node: ObjectExpression, key: string): { member: ObjectPropertyKind; index: number } | undefined {\n const index = node.properties.findLastIndex((entry) => getKey(entry) === key)\n return index === -1 ? undefined : { member: node.properties[index]!, index }\n}\n\nfunction getValue(node: ObjectExpression, key: string): ValueNode {\n const member = findProperty(node, key)?.member\n return member?.type === nodeTypes.property ? member.value : member\n}\n\nfunction getConfigName(config: ObjectExpression): string | undefined {\n const name = getValue(config, 'name')\n return name?.type === nodeTypes.literal && typeof name.value === 'string' ? name.value : undefined\n}\n\nfunction isOverridden(node: ObjectExpression, index: number): boolean {\n return node.properties.slice(index + 1).some((entry) => entry.type === nodeTypes.spreadElement)\n}\n\n/** `key: value`, not a method, getter, setter, or `{ key }` shorthand. */\nfunction isPlainProperty(member: Extract<ObjectPropertyKind, { type: typeof nodeTypes.property }>): boolean {\n return !member.method && !member.shorthand && member.kind === propertyKinds.init\n}\n\n/** A literal's value, `undefined` for code. */\nfunction readLiteral(node: ValueNode): OptionValue | undefined {\n switch (node?.type) {\n case nodeTypes.literal:\n // A bigint or a regex is code, not a value JSON can carry. A regex Node cannot compile also has a `null` value.\n return 'regex' in node || 'bigint' in node ? undefined : (node.value as OptionValue)\n case nodeTypes.templateLiteral:\n return node.expressions.length ? undefined : (node.quasis[0]?.value.cooked ?? '')\n case nodeTypes.unaryExpression: {\n const value = readLiteral(node.argument)\n if (typeof value !== 'number') return undefined\n if (node.operator === unaryOperators.minus) return -value\n if (node.operator === unaryOperators.plus) return value\n return undefined\n }\n case nodeTypes.arrayExpression: {\n const values = node.elements.map((element) => readLiteral(element))\n return values.every((value) => value !== undefined) ? values : undefined\n }\n case nodeTypes.objectExpression: {\n const entries: Record<string, OptionValue> = {}\n for (const entry of node.properties) {\n if (entry.type !== nodeTypes.property) return undefined\n const key = getKey(entry)\n const value = readLiteral(entry.value)\n // A `__proto__` key would replace the object's prototype instead of adding an entry.\n if (key === undefined || !isSafeKey(key) || value === undefined) return undefined\n entries[key] = value\n }\n return entries\n }\n }\n return undefined\n}\n\n// Imports and factory calls\n\nfunction getRequirePath(node: ValueNode): string | undefined {\n if (node?.type !== nodeTypes.callExpression || node.callee.type !== nodeTypes.identifier || node.callee.name !== identifiers.require) return undefined\n const [argument] = node.arguments\n return argument?.type === nodeTypes.literal && typeof argument.value === 'string' ? argument.value : undefined\n}\n\n/** `import { exported as local } from '...'`. A default or namespace import has no exported name, so its local name stands in. */\nfunction importBindings(statement: ImportDeclaration): Array<[string, Import]> {\n return statement.specifiers.map((specifier) => {\n const imported = specifier.type === nodeTypes.importSpecifier ? specifier.imported : specifier.local\n const exported = imported.type === nodeTypes.identifier ? imported.name : imported.value\n return [specifier.local.name, { from: statement.source.value, exported }]\n })\n}\n\n/** `const { exported: local } = require('...')`. */\nfunction requireBindings(statement: VariableDeclaration): Array<[string, Import]> {\n return statement.declarations.flatMap((declarator): Array<[string, Import]> => {\n const from = getRequirePath(declarator.init)\n if (from === undefined || declarator.id.type !== nodeTypes.objectPattern) return []\n\n return declarator.id.properties.flatMap((entry): Array<[string, Import]> => {\n if (entry.type !== nodeTypes.property || entry.value.type !== nodeTypes.identifier) return []\n return [[entry.value.name, { from, exported: getKey(entry) ?? entry.value.name }]]\n })\n })\n}\n\nfunction getImports(program: Program): Map<string, Import> {\n return new Map(\n program.body.flatMap((statement) => {\n if (statement.type === nodeTypes.importDeclaration) return importBindings(statement)\n if (statement.type === nodeTypes.variableDeclaration) return requireBindings(statement)\n return []\n }),\n )\n}\n\nfunction isImportStatement(node: Program['body'][number], kind: ModuleKind): boolean {\n if (kind === moduleKinds.esm) return node.type === nodeTypes.importDeclaration\n return node.type === nodeTypes.variableDeclaration && node.declarations.some((declarator) => getRequirePath(declarator.init) !== undefined)\n}\n\n/** The quote of the first string literal in the file, so new code matches it. */\nfunction detectQuote(node: unknown): Quote | undefined {\n if (!node || typeof node !== 'object') return undefined\n const { type, raw } = node as { type?: string; raw?: unknown }\n if (type === nodeTypes.literal && typeof raw === 'string' && (raw[0] === quotes.single || raw[0] === quotes.double)) return raw[0]\n for (const child of Object.values(node)) {\n const quote = detectQuote(child)\n if (quote) return quote\n }\n return undefined\n}\n\n/** The `adapter` value, or the elements of the `plugins` or `parsers` array. */\nfunction factoryNodes(config: ObjectExpression, kind: ExtensionKind): Array<ValueNode> {\n if (kind === extensionKinds.adapter) return [getValue(config, 'adapter')]\n const array = getValue(config, `${kind}s`)\n return array?.type === nodeTypes.arrayExpression ? array.elements : []\n}\n\n/** The factory calls of one kind whose callee the file imports. */\nfunction findCalls(program: Program, config: ObjectExpression, kind: ExtensionKind = extensionKinds.plugin): Array<FactoryCall> {\n const imports = getImports(program)\n return factoryNodes(config, kind).flatMap((node) => {\n if (node?.type !== nodeTypes.callExpression || node.callee.type !== nodeTypes.identifier) return []\n const imported = imports.get(node.callee.name)\n return imported ? [{ importName: node.callee.name, exportName: imported.exported, packageName: imported.from, call: node }] : []\n })\n}\n\n// Disabled plugins\n\n/** Whether nothing but whitespace precedes `offset` on its line. */\nfunction startsLine(source: string, offset: number): boolean {\n return source.slice(source.lastIndexOf('\\n', offset - 1) + 1, offset).trim() === ''\n}\n\n/** The `disable-plugin` blocks in this config, read from marker comments since the call is no longer a node. */\nfunction findDisabled(source: string, comments: Array<Comment>, config: ObjectExpression): Array<DisabledBlock> {\n const lines = source.split('\\n')\n\n return comments.flatMap((comment) => {\n const match = comment.type === commentTypes.line ? comment.value.trim().match(DISABLED_MARKER_PATTERN) : null\n // Only markers inside this entry, on a line of their own, so another entry or a trailing comment never matches.\n if (!match || comment.start < config.start || comment.end > config.end || !startsLine(source, comment.start)) return []\n\n const line = getPosition(source, comment.start).line\n const end = line + Number(match[2])\n const code = lines.slice(line, end).map((text) => text.replace(/^(\\s*)\\/\\/ ?/, '$1').replace(/^\\s+$/, ''))\n return [{ packageName: match[1]!, line, end, code }]\n })\n}\n\n// Reading options\n\n/** Literal members as `value` and code paths as `locked`, `undefined` for a computed key. */\nfunction readEditable(node: ObjectExpression, prefix: Array<string> = []): { value: Record<string, OptionValue>; locked: Array<Array<string>> } | undefined {\n const value: Record<string, OptionValue> = {}\n const locked: Array<Array<string>> = []\n\n for (const [index, entry] of node.properties.entries()) {\n if (entry.type === nodeTypes.spreadElement) continue\n const key = getKey(entry)\n if (key === undefined) return undefined\n if (findProperty(node, key)?.index !== index) continue\n\n const path = [...prefix, key]\n // A `__proto__` key replaces the prototype, so it reads as code.\n if (!isSafeKey(key)) {\n locked.push(path)\n continue\n }\n\n const member = isOverridden(node, index) ? undefined : entry.value\n const literal = readLiteral(member)\n if (literal !== undefined) {\n value[key] = literal\n continue\n }\n if (member?.type !== nodeTypes.objectExpression) {\n locked.push(path)\n continue\n }\n\n const nested = readEditable(member, path)\n if (!nested) return undefined\n value[key] = nested.value\n locked.push(...nested.locked)\n }\n return { value, locked }\n}\n\nfunction readObjectOptions(options: ObjectExpression): OptionsView {\n const entries: OptionsView = {}\n for (const [index, entry] of options.properties.entries()) {\n const key = getKey(entry)\n if (key === undefined || !isSafeKey(key)) continue\n\n const member = entry.type === nodeTypes.property && !isOverridden(options, index) ? entry.value : undefined\n const value = readLiteral(member)\n if (value !== undefined) {\n entries[key] = { literal: true, value }\n continue\n }\n entries[key] = { literal: false, ...(member?.type === nodeTypes.objectExpression ? readEditable(member) : undefined) }\n }\n return entries\n}\n\nfunction readCallOptions(call: CallExpression): OptionsView {\n const options = call.arguments[0]\n return options?.type === nodeTypes.objectExpression ? readObjectOptions(options) : {}\n}\n\nfunction readDisabledOptions(code: Array<string>): OptionsView {\n const call = parseExpression(code.join('\\n').trim().replace(/,$/, ''))\n return call?.type === nodeTypes.callExpression ? readCallOptions(call) : {}\n}\n\nfunction toPluginView({ importName, packageName, call }: FactoryCall): PluginView {\n return { importName, packageName, options: readCallOptions(call) }\n}\n\n/** Active and disabled plugins, in source order so a disabled plugin keeps its place. */\nfunction readPlugins({ source, parsed, config }: { source: string; parsed: ParsedConfig; config: ObjectExpression }): Array<PluginView> {\n const importNames = new Map([...getImports(parsed.program)].map(([local, { from }]) => [from, local]))\n\n const active = findCalls(parsed.program, config).map((call) => ({ line: getPosition(source, call.call.start).line, plugin: toPluginView(call) }))\n const disabled = findDisabled(source, parsed.comments, config).map(({ packageName, line, code }) => ({\n line,\n plugin: {\n importName: importNames.get(packageName) ?? toExportName(packageName),\n packageName,\n options: readDisabledOptions(code),\n disabled: true as const,\n },\n }))\n\n return [...active, ...disabled].sort((a, b) => a.line - b.line).map(({ plugin }) => plugin)\n}\n\nfunction readConfigView({ source, parsed, config }: { source: string; parsed: ParsedConfig; config: ObjectExpression }): ConfigView {\n const [adapter] = findCalls(parsed.program, config, extensionKinds.adapter).map(toPluginView)\n const parsers = findCalls(parsed.program, config, extensionKinds.parser).map(toPluginView)\n const output = getOutput(config)\n\n return {\n name: getConfigName(config),\n plugins: readPlugins({ source, parsed, config }),\n ...(adapter && { adapter }),\n ...(parsers.length ? { parsers } : {}),\n ...(!('reason' in output) && { output: pickOutput(readObjectOptions(output.object)) }),\n }\n}\n\n/** Which plugins the file declares and which options Studio may write. */\nexport function readConfig(source: string): ConfigFileView {\n const parsed = findConfigs(source)\n if ('reason' in parsed) return { managed: false, reason: parsed.reason }\n\n return { managed: true, configs: parsed.configs.map((config) => readConfigView({ source, parsed, config })) }\n}\n\n/** The modules the file imports, empty when it cannot be parsed. */\nexport function readImports(source: string): Array<string> {\n const parsed = parseSource(source)\n if ('reason' in parsed) return []\n return [...new Set([...getImports(parsed.program).values()].map(({ from }) => from))]\n}\n\n// Editing options\n\ntype FoundPath = { object: ObjectExpression; index: number; value: Expression } | { object: ObjectExpression; missing: number } | { reason: string }\n\n/** Follows `path` to its literal, or to the first missing key. Refuses a value set in code. */\nfunction findPath(options: ObjectExpression, path: Array<string>): FoundPath {\n let object = options\n\n for (const [depth, key] of path.entries()) {\n const found = findProperty(object, key)\n if (!found) return { object, missing: depth }\n if (isOverridden(object, found.index)) {\n return { reason: `${path.slice(0, depth + 1).join('.')} can be overridden by a spread after it, so it is customized in code` }\n }\n\n const { member, index } = found\n const isLast = depth === path.length - 1\n if (isLast) {\n return member.type === nodeTypes.property && readLiteral(member.value) !== undefined\n ? { object, index, value: member.value }\n : { reason: `${path.join('.')} is customized in code` }\n }\n if (member.type !== nodeTypes.property || member.value.type !== nodeTypes.objectExpression) {\n return { reason: `${key} is not an object, so ${path.join('.')} cannot be reached` }\n }\n object = member.value\n }\n return { reason: 'no option path given' }\n}\n\nfunction setAtPath({\n source,\n options,\n path,\n value,\n quote,\n}: {\n source: string\n options: ObjectExpression\n path: Array<string>\n value: OptionValue\n quote: Quote\n}): EditResult {\n const target = findPath(options, path)\n if ('reason' in target) return target\n if ('missing' in target) {\n const [key, ...rest] = path.slice(target.missing)\n return { source: appendItem(source, target.object, `${printKey(key!, quote)}: ${printValue(wrapPath(rest, value), quote)}`) }\n }\n return { source: replaceText(source, target.value.start, target.value.end, printValue(value, quote)) }\n}\n\nfunction removeAtPath({ source, options, path }: { source: string; options: ObjectExpression; path: Array<string> }): EditResult {\n const target = findPath(options, path)\n if ('reason' in target) return target\n if ('missing' in target) return { source }\n return { source: removeItem(source, target.object, target.index) }\n}\n\nfunction setOption(source: string, call: CallExpression, path: Array<string>, value: unknown, quote: Quote): EditResult {\n if (!isOptionValue(value)) return { reason: 'the value is not a literal that can be written to a config file' }\n\n const options = call.arguments[0]\n if (!options) {\n const closing = call.end - 1\n if (source[closing] !== ')') return { reason: 'the factory call could not be located in the file' }\n return { source: replaceText(source, closing, closing, printValue(wrapPath(path, value), quote)) }\n }\n if (options.type !== nodeTypes.objectExpression) return { reason: 'the factory was not called with an object literal' }\n return setAtPath({ source, options, path, value, quote })\n}\n\nfunction removeOption(source: string, call: CallExpression, path: Array<string>): EditResult {\n const options = call.arguments[0]\n if (!options) return { source }\n if (options.type !== nodeTypes.objectExpression) return { reason: 'the factory was not called with an object literal' }\n return removeAtPath({ source, options, path })\n}\n\nfunction editOption({\n source,\n parsed,\n config,\n edit,\n quote,\n extensions,\n}: {\n source: string\n parsed: ParsedConfig\n config: ObjectExpression\n edit: OptionEdit\n quote: Quote\n extensions: InstalledExtensions\n}): EditResult {\n const kind = edit.kind ?? extensionKinds.plugin\n // A package can ship several factories (`parserTs`, `parserTsx`), so prefer the export its manifest names.\n const calls = findCalls(parsed.program, config, kind).filter((entry) => entry.packageName === edit.plugin)\n const exportName = extensions.get(edit.plugin)?.manifest.export ?? toExportName(edit.plugin)\n const call = (calls.find((entry) => entry.exportName === exportName) ?? calls[0])?.call\n\n if (!call) {\n if (kind === extensionKinds.adapter) return { reason: `${edit.plugin} is not the config's adapter` }\n const disabled = kind === extensionKinds.plugin && findDisabled(source, parsed.comments, config).some((block) => block.packageName === edit.plugin)\n return { reason: disabled ? `${edit.plugin} is disabled, enable it first` : `${edit.plugin} is not in the ${kind}s array` }\n }\n\n if (edit.operation === ConfigEditOperation.SET_OPTION) return setOption(source, call, edit.path, edit.value, quote)\n return removeOption(source, call, edit.path)\n}\n\n// Editing the config's own fields\n\nfunction setInput(source: string, config: ObjectExpression, input: string, quote: Quote): EditResult {\n const value = printValue(input, quote)\n const found = findProperty(config, 'input')\n if (!found) return { source: appendItem(source, config, `input: ${value}`) }\n if (found.member.type !== nodeTypes.property || !isPlainProperty(found.member)) return { reason: 'input is not a plain property' }\n if (isOverridden(config, found.index)) return { reason: 'a spread after input could override it' }\n return { source: replaceText(source, found.member.value.start, found.member.value.end, value) }\n}\n\nfunction getOutput(config: ObjectExpression): { object: ObjectExpression } | { reason: string } {\n const found = findProperty(config, 'output')\n if (found?.member.type !== nodeTypes.property || found.member.value.type !== nodeTypes.objectExpression) return { reason: 'output is not an object literal' }\n if (isOverridden(config, found.index)) return { reason: 'a spread after output could override it' }\n return { object: found.member.value }\n}\n\nfunction editOutput({ source, config, edit, quote }: { source: string; config: ObjectExpression; edit: OutputEdit; quote: Quote }): EditResult {\n const output = getOutput(config)\n if ('reason' in output) return output\n if (edit.operation === ConfigEditOperation.REMOVE_OUTPUT) return removeAtPath({ source, options: output.object, path: edit.path })\n\n const [key, ...rest] = edit.path\n if (!isOptionValue(edit.value) || !isOutputValue({ key: key!, value: wrapPath(rest, edit.value) }))\n return { reason: `the value is not one output.${key} takes` }\n return setAtPath({ source, options: output.object, path: edit.path, value: edit.value, quote })\n}\n\n// Adding, disabling, and enabling plugins\n\n/** Adds the import after the last one, matching its semicolon style. */\nfunction addImport({\n source,\n parsed,\n importNames,\n moduleSpecifier,\n quote,\n}: {\n source: string\n parsed: ParsedConfig\n importNames: Array<string>\n moduleSpecifier: string\n quote: Quote\n}): string {\n const lastImport = parsed.program.body.findLast((node) => isImportStatement(node, parsed.kind))\n const afterLine = lastImport ? getPosition(source, lastImport.end).line : 0\n const lines = source.split('\\n')\n\n const semicolon = afterLine > 0 && lines[afterLine - 1]?.trimEnd().endsWith(';') ? ';' : ''\n const specifier = `${quote}${moduleSpecifier}${quote}`\n const statement =\n parsed.kind === moduleKinds.esm ? `import { ${importNames.join(', ')} } from ${specifier}` : `const { ${importNames.join(', ')} } = require(${specifier})`\n\n lines.splice(afterLine, 0, `${statement}${semicolon}`)\n if (afterLine === 0) lines.splice(1, 0, '')\n\n return lines.join('\\n')\n}\n\n/**\n * The parsers `defineConfig` applies when a config sets no `parsers`, by import name. Adding a parser\n * to such a config writes these too, or the new array would replace them.\n */\nconst DEFAULT_PARSERS = [\n { importName: 'parserTs', packageName: '@kubb/parser-ts' },\n { importName: 'parserTsx', packageName: '@kubb/parser-ts' },\n { importName: 'parserMd', packageName: '@kubb/parser-md' },\n] as const\n\n/**\n * Adds a plugin to `plugins`, or with `kind: 'parser'` a parser to `parsers`. Replaying the same add\n * is a no-op, while an import name taken by another package is an error.\n */\nfunction addPlugin({\n source,\n parsed,\n config,\n edit,\n quote,\n extensions,\n}: {\n source: string\n parsed: ParsedConfig\n config: ObjectExpression\n edit: AddPluginEdit\n quote: Quote\n extensions: InstalledExtensions\n}): EditResult {\n const kind = edit.kind ?? extensionKinds.plugin\n const isParser = kind === extensionKinds.parser\n if (!isAllowedPlugin({ packageName: edit.plugin, extensions, kind })) {\n return {\n reason: isParser ? `\"${edit.plugin}\" is not an installed Kubb parser` : `\"${edit.plugin}\" is not a @kubb/plugin-* package or an installed Kubb plugin`,\n }\n }\n\n const importName = extensions.get(edit.plugin)?.manifest.export ?? toExportName(edit.plugin)\n if (!IDENTIFIER_PATTERN.test(importName)) return { reason: `\"${importName}\" is not a valid import name` }\n // A package can ship several parsers (`parserTs` and `parserTsx`), so a parser is matched by its export too.\n if (findCalls(parsed.program, config, kind).some((entry) => entry.packageName === edit.plugin && (!isParser || entry.exportName === importName))) {\n return { source }\n }\n\n const options = edit.options ?? {}\n if (!isOptionValue(options)) return { reason: 'the options are not literals that can be written to a config file' }\n\n const key = `${kind}s`\n const array = getValue(config, key)\n if (array ? array.type !== nodeTypes.arrayExpression : !isParser) return { reason: `${key} is not an array literal` }\n // A config without `parsers` runs the defaults, so the new array lists them before the added parser.\n const defaults = isParser && !array ? DEFAULT_PARSERS.filter((parser) => parser.importName !== importName) : []\n\n // The missing imports by package, so `parserTs` and `parserTsx` share one line.\n const imports = getImports(parsed.program)\n const missing = new Map<string, Array<string>>()\n for (const item of [...defaults, { importName, packageName: edit.plugin }]) {\n const from = imports.get(item.importName)?.from\n if (from && from !== item.packageName) return { reason: `${item.importName} is already imported from ${from}` }\n if (!from) missing.set(item.packageName, [...(missing.get(item.packageName) ?? []), item.importName])\n }\n\n // The array sits below the imports, so adding to it first leaves the import lines where they are.\n const call = `${importName}(${Object.keys(options).length ? printValue(options, quote) : ''})`\n const next =\n array?.type === nodeTypes.arrayExpression\n ? appendItem(source, array, call)\n : appendItem(source, config, `parsers: [${[...defaults.map((parser) => `${parser.importName}()`), call].join(', ')}]`)\n\n return {\n source: [...missing].reduceRight(\n (current, [moduleSpecifier, importNames]) => addImport({ source: current, parsed, importNames, moduleSpecifier, quote }),\n next,\n ),\n }\n}\n\n/** One item per line, so a call can be commented out alone. Skipped when comments sit between items. */\nfunction splitPlugins(source: string, config: ObjectExpression): string | undefined {\n const array = getValue(config, 'plugins')\n if (array?.type !== nodeTypes.arrayExpression) return undefined\n\n const items = array.elements.flatMap((element) => (element ? [element] : []))\n const { start, end } = array\n const gaps = [source.slice(start + 1, items[0]?.start ?? end - 1), ...items.map((item, index) => source.slice(item.end, items[index + 1]?.start ?? end - 1))]\n if (!items.length || gaps.some((gap) => !/^[\\s,]*$/.test(gap))) return undefined\n\n const lineStart = source.lastIndexOf('\\n', start - 1) + 1\n const indent = source.slice(lineStart).match(/^[ \\t]*/)?.[0] ?? ''\n const lines = items.map((item) => `${indent} ${source.slice(item.start, item.end)},`)\n\n return replaceText(source, start, end, `[\\n${lines.join('\\n')}\\n${indent}]`)\n}\n\nfunction disablePlugin(source: string, program: Program, config: ObjectExpression, plugin: string): EditResult {\n const call = findCalls(program, config).find((entry) => entry.packageName === plugin)?.call\n if (!call) return { reason: `${plugin} is not in the plugins array` }\n\n const start = getPosition(source, call.start)\n const end = getPosition(source, call.end)\n const lines = source.split('\\n')\n const from = start.line - 1\n const to = end.line - 1\n const firstLine = lines[from] ?? ''\n\n // Only safe when the call sits alone on its lines: anything else on its first line, or on its last\n // line besides a trailing comma, would be swallowed into the comment and corrupt the file.\n if (firstLine.slice(0, start.column).trim() || !/^,?\\s*$/.test((lines[to] ?? '').slice(end.column))) {\n return { reason: `${plugin} shares a line with other code, so it cannot be commented out safely` }\n }\n\n const indent = firstLine.match(/^\\s*/)?.[0] ?? ''\n const commented = lines.slice(from, to + 1).map((line) => (line.trim() ? `${indent}// ${line.slice(indent.length)}` : `${indent}//`))\n lines.splice(from, commented.length, `${indent}// kubb:disabled ${plugin} ${commented.length}`, ...commented)\n\n return { source: lines.join('\\n') }\n}\n\n/** Disables the plugin, first putting a one-line `plugins: [a(), b()]` (what `add-plugin` writes) on separate lines. */\nfunction disablePluginInConfig({\n source,\n parsed,\n config,\n edit,\n}: {\n source: string\n parsed: ParsedConfig\n config: ObjectExpression\n edit: DisablePluginEdit\n}): EditResult {\n const result = disablePlugin(source, parsed.program, config, edit.plugin)\n if (!('reason' in result) || !result.reason.includes('shares a line')) return result\n\n const split = splitPlugins(source, config)\n if (split === undefined) return result\n\n const reparsed = findConfigs(split)\n const reparsedConfig = 'reason' in reparsed ? undefined : findConfigEntry(reparsed.configs, edit.config)\n if ('reason' in reparsed || !reparsedConfig) return result\n\n return disablePlugin(split, reparsed.program, reparsedConfig, edit.plugin)\n}\n\nfunction enablePlugin(source: string, comments: Array<Comment>, config: ObjectExpression, plugin: string): EditResult {\n const block = findDisabled(source, comments, config).find((entry) => entry.packageName === plugin)\n if (!block) return { reason: `${plugin} is not disabled` }\n\n const lines = source.split('\\n')\n lines.splice(block.line - 1, block.end - block.line + 1, ...block.code)\n return { source: lines.join('\\n') }\n}\n\n// Removing extensions\n\n/** Drops the import statements of `packageName` once nothing else in the file uses their names. */\nfunction removeUnusedImports(source: string, packageName: string): string {\n const parsed = parseSource(source)\n if ('reason' in parsed) return source\n\n // From the last statement up, so the offsets of the earlier ones stay valid.\n return parsed.program.body.reduceRight((current, statement) => {\n const bindings =\n statement.type === nodeTypes.importDeclaration\n ? importBindings(statement)\n : statement.type === nodeTypes.variableDeclaration\n ? requireBindings(statement)\n : []\n if (!bindings.length || bindings.some(([, { from }]) => from !== packageName)) return current\n\n const rest = replaceText(current, statement.start, statement.end)\n if (bindings.some(([local]) => new RegExp(`(?<![\\\\w$])${local.replaceAll('$', '\\\\$')}(?![\\\\w$])`).test(rest))) return current\n\n const lineStart = current.lastIndexOf('\\n', statement.start - 1) + 1\n const lineEnd = current.indexOf('\\n', statement.end)\n const after = lineEnd === -1 ? current.length : lineEnd + 1\n // At the top of the file, the blank line after the import goes too, so the file does not start with one.\n return replaceText(current, lineStart, lineStart === 0 && current[after] === '\\n' ? after + 1 : after)\n }, source)\n}\n\n/**\n * Removes every call of a plugin or parser package, and the block `disable-plugin` commented out,\n * then its unused imports. Removing what the config does not hold is a no-op. Refuses to empty\n * `parsers`, since a config with no parser cannot print files.\n */\nfunction removeExtension(source: string, edit: RemoveExtensionEdit): EditResult {\n const kind = edit.kind ?? extensionKinds.plugin\n let current = source\n\n // One call at a time, re-parsing in between, since each removal moves the ones after it.\n for (;;) {\n const parsed = findConfigs(current)\n if ('reason' in parsed) return parsed\n const config = findConfigEntry(parsed.configs, edit.config)\n if (!config) return { reason: `no config entry found for ${JSON.stringify(edit.config)}` }\n\n const array = getValue(config, `${kind}s`)\n const calls = findCalls(parsed.program, config, kind).filter((entry) => entry.packageName === edit.plugin)\n const block = findDisabled(current, parsed.comments, config).find((entry) => entry.packageName === edit.plugin)\n\n if (calls[0] && array?.type === nodeTypes.arrayExpression) {\n const elements = array.elements.filter((element) => element !== null)\n if (kind === extensionKinds.parser && elements.length === calls.length) return { reason: `${edit.plugin} is the last parser in the parsers array` }\n current = removeItem(current, array, elements.indexOf(calls[0].call))\n continue\n }\n if (block && kind === extensionKinds.plugin) {\n const lines = current.split('\\n')\n lines.splice(block.line - 1, block.end - block.line + 1)\n current = lines.join('\\n')\n continue\n }\n return { source: current === source ? source : removeUnusedImports(current, edit.plugin) }\n }\n}\n\n// Applying edits\n\n/** Every edit re-parses the file, since the previous one rewrote it. */\nfunction applyEdit({ source, edit, extensions }: { source: string; edit: ConfigEdit; extensions: InstalledExtensions }): EditResult {\n const parsed = findConfigs(source)\n if ('reason' in parsed) return parsed\n\n const config = findConfigEntry(parsed.configs, edit.config)\n if (!config) return { reason: `no config entry found for ${JSON.stringify(edit.config)}` }\n const quote = detectQuote(parsed.program) ?? quotes.single\n\n switch (edit.operation) {\n case ConfigEditOperation.SET_INPUT:\n return setInput(source, config, edit.input, quote)\n case ConfigEditOperation.SET_OUTPUT:\n case ConfigEditOperation.REMOVE_OUTPUT:\n return editOutput({ source, config, edit, quote })\n case ConfigEditOperation.DISABLE_PLUGIN:\n return disablePluginInConfig({ source, parsed, config, edit })\n case ConfigEditOperation.ENABLE_PLUGIN:\n return enablePlugin(source, parsed.comments, config, edit.plugin)\n case ConfigEditOperation.ADD_PLUGIN:\n return addPlugin({ source, parsed, config, edit, quote, extensions })\n case ConfigEditOperation.REMOVE_EXTENSION:\n return removeExtension(source, edit)\n case ConfigEditOperation.SET_OPTION:\n case ConfigEditOperation.REMOVE_OPTION:\n return editOption({ source, parsed, config, edit, quote, extensions })\n }\n}\n\n/** Applies edits in place, touching only the text each targets. A refused edit is reported and the rest still run. */\nexport function editConfig({ source, edits, extensions = new Map() }: { source: string; edits: Array<ConfigEdit>; extensions?: InstalledExtensions }): {\n source: string\n outcomes: Array<ConfigEditOutcome>\n changed: boolean\n} {\n let current = source\n\n const outcomes = edits.map((edit): ConfigEditOutcome => {\n const invalid = validateEdit(edit)\n if (invalid) return { edit, applied: false, reason: invalid }\n\n try {\n const result = applyEdit({ source: current, edit, extensions })\n if ('reason' in result) return { edit, applied: false, reason: result.reason }\n current = result.source\n return { edit, applied: true }\n } catch (error) {\n return { edit, applied: false, reason: getErrorMessage(error) }\n }\n })\n\n return { source: current, outcomes, changed: current !== source }\n}\n\n/** Applies `edits` to `filePath`, writing only when something changed. */\nexport async function editConfigFile({ filePath, edits, extensions }: { filePath: string; edits: Array<ConfigEdit>; extensions?: InstalledExtensions }) {\n const current = await read(filePath)\n const result = editConfig({ source: current, edits, extensions })\n if (result.changed) await writeRaw(filePath, result.source)\n return result\n}\n"],"mappings":";;;;;;;;AAoBA,MAAa,YAAY;CACvB,iBAAiB;CACjB,yBAAyB;CACzB,sBAAsB;CACtB,gBAAgB;CAChB,gBAAgB;CAChB,0BAA0B;CAC1B,qBAAqB;CACrB,oBAAoB;CACpB,YAAY;CACZ,mBAAmB;CACnB,iBAAiB;CACjB,SAAS;CACT,kBAAkB;CAClB,kBAAkB;CAClB,eAAe;CACf,UAAU;CACV,iBAAiB;CACjB,eAAe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AQ,OAAO;IAAE;IAAM,SAAS;IAAO,QAAQ,OAAO;GAAO;GAC7E,UAAU,OAAO;GACjB,OAAO;IAAE;IAAM,SAAS;GAAK;EAC/B,SAAS,OAAO;GACd,OAAO;IAAE;IAAM,SAAS;IAAO,QAAQ,gBAAgB,KAAK;GAAE;EAChE;CACF,CAAC;CAED,OAAO;EAAE,QAAQ;EAAS;EAAU,SAAS,YAAY;CAAO;AAClE;;AAGA,eAAsB,eAAe,EAAE,UAAU,OAAO,cAAgG;CAEtJ,MAAM,SAAS,WAAW;EAAE,QAAQ,MADd,KAAK,QAAQ;EACU;EAAO;CAAW,CAAC;CAChE,IAAI,OAAO,SAAS,MAAM,SAAS,UAAU,OAAO,MAAM;CAC1D,OAAO;AACT"}
1
+ {"version":3,"file":"configFile-L5i7gGUc.js","names":[],"sources":["../../../internals/shared/src/configFile/ast.ts","../../../internals/shared/src/configFile/types.ts","../../../internals/shared/src/configFile/rules.ts","../../../internals/shared/src/configFile/text.ts","../../../internals/shared/src/configFile/configFile.ts"],"sourcesContent":["import { getErrorMessage } from '@internals/utils'\nimport { type Comment, type Expression, type Program, parse } from 'yuku-parser'\n\nexport type {\n ArrayExpression,\n AssignmentExpression,\n BindingProperty,\n CallExpression,\n Comment,\n Expression,\n ImportDeclaration,\n ObjectExpression,\n ObjectPropertyKind,\n Program,\n RestElement,\n SpreadElement,\n VariableDeclaration,\n} from 'yuku-parser'\n\n/** Node types the config editor reads from the yuku AST. */\nexport const nodeTypes = {\n arrayExpression: 'ArrayExpression',\n arrowFunctionExpression: 'ArrowFunctionExpression',\n assignmentExpression: 'AssignmentExpression',\n blockStatement: 'BlockStatement',\n callExpression: 'CallExpression',\n exportDefaultDeclaration: 'ExportDefaultDeclaration',\n expressionStatement: 'ExpressionStatement',\n functionExpression: 'FunctionExpression',\n identifier: 'Identifier',\n importDeclaration: 'ImportDeclaration',\n importSpecifier: 'ImportSpecifier',\n literal: 'Literal',\n memberExpression: 'MemberExpression',\n objectExpression: 'ObjectExpression',\n objectPattern: 'ObjectPattern',\n property: 'Property',\n returnStatement: 'ReturnStatement',\n spreadElement: 'SpreadElement',\n tSAsExpression: 'TSAsExpression',\n tSSatisfiesExpression: 'TSSatisfiesExpression',\n templateLiteral: 'TemplateLiteral',\n unaryExpression: 'UnaryExpression',\n variableDeclaration: 'VariableDeclaration',\n} as const\n\nexport const commentTypes = { line: 'Line' } as const\nexport const propertyKinds = { init: 'init' } as const\nexport const unaryOperators = { minus: '-', plus: '+' } as const\nconst diagnosticSeverities = { error: 'error' } as const\n\n/** A parsed file: its statements and every comment in it, or why it could not be parsed. */\ntype ParsedSource = { program: Program; comments: Array<Comment> } | { reason: string }\n\n/**\n * Parses `source` as a TypeScript module. Never throws: a syntax error, or a native parser that\n * cannot load on this platform, comes back as a `reason`.\n */\nexport function parseSource(source: string): ParsedSource {\n try {\n // Parentheses are dropped, so `export default (defineConfig({}))` reads as the call itself.\n const { program, comments, diagnostics } = parse(source, { lang: 'ts', sourceType: 'module', preserveParens: false })\n if (diagnostics.some((diagnostic) => diagnostic.severity === diagnosticSeverities.error)) return { reason: 'the config file could not be parsed' }\n return { program, comments }\n } catch (error) {\n return { reason: `the config parser could not load on this platform: ${getErrorMessage(error)}` }\n }\n}\n\n/** Parses `source` as one expression, such as a commented-out `pluginTs({ ... })` call. */\nexport function parseExpression(source: string): Expression | undefined {\n const parsed = parseSource(source)\n if ('reason' in parsed) return undefined\n const [statement] = parsed.program.body\n return parsed.program.body.length === 1 && statement?.type === nodeTypes.expressionStatement ? statement.expression : undefined\n}\n","import type { ValueOf } from '@internals/utils'\nimport type { ExtensionKind, ExtensionManifest } from '@kubb/core'\n\n/** Which `defineConfig(...)` entry an edit targets: its index or `name`, the first entry when omitted. */\nexport type ConfigRef = string | number\n\n/** A literal option value that survives a JSON round trip. */\nexport type OptionValue = string | number | boolean | null | Array<OptionValue> | { [key: string]: OptionValue }\n\nexport const extensionKinds = { plugin: 'plugin', adapter: 'adapter', parser: 'parser' } as const satisfies Record<string, ExtensionKind>\n\nexport const ConfigEditOperation = {\n SET_OPTION: 'set-option',\n REMOVE_OPTION: 'remove-option',\n ADD_PLUGIN: 'add-plugin',\n REMOVE_EXTENSION: 'remove-extension',\n DISABLE_PLUGIN: 'disable-plugin',\n ENABLE_PLUGIN: 'enable-plugin',\n SET_INPUT: 'set-input',\n SET_OUTPUT: 'set-output',\n REMOVE_OUTPUT: 'remove-output',\n} as const\nexport type ConfigEditOperation = ValueOf<typeof ConfigEditOperation>\n\n/**\n * One change to `kubb.config.ts`. `plugin` is the package name, and `kind` picks the `plugins` entry\n * (default), the `adapter`, or a `parsers` entry. `path` walks nested option objects.\n */\nexport type ConfigEdit =\n | { operation: typeof ConfigEditOperation.SET_OPTION; config?: ConfigRef; kind?: ExtensionKind; plugin: string; path: Array<string>; value: unknown }\n | { operation: typeof ConfigEditOperation.REMOVE_OPTION; config?: ConfigRef; kind?: ExtensionKind; plugin: string; path: Array<string> }\n /** With `kind: 'parser'`, adds to `parsers`. A config without `parsers` gets the defaults written next to it, so they keep running. */\n | {\n operation: typeof ConfigEditOperation.ADD_PLUGIN\n config?: ConfigRef\n kind?: typeof extensionKinds.plugin | typeof extensionKinds.parser\n plugin: string\n options?: Record<string, unknown>\n }\n /** Deletes every call of a plugin, or a parser with `kind: 'parser'`, a disabled block included, and the imports nothing else uses. */\n | {\n operation: typeof ConfigEditOperation.REMOVE_EXTENSION\n config?: ConfigRef\n kind?: typeof extensionKinds.plugin | typeof extensionKinds.parser\n plugin: string\n }\n | { operation: typeof ConfigEditOperation.DISABLE_PLUGIN; config?: ConfigRef; plugin: string }\n | { operation: typeof ConfigEditOperation.ENABLE_PLUGIN; config?: ConfigRef; plugin: string }\n | { operation: typeof ConfigEditOperation.SET_INPUT; config?: ConfigRef; input: string }\n | { operation: typeof ConfigEditOperation.SET_OUTPUT; config?: ConfigRef; path: Array<string>; value: unknown }\n | { operation: typeof ConfigEditOperation.REMOVE_OUTPUT; config?: ConfigRef; path: Array<string> }\n\n/** Option keys, each with whether Studio may write it. `locked` lists the code paths inside a partly literal object. */\nexport type OptionsView = Record<string, { literal: boolean; value?: OptionValue; locked?: Array<Array<string>> }>\n\n/** A factory call in `plugins`, `adapter`, or `parsers`. `importName` is the local name, alias included. */\nexport type PluginView = {\n importName: string\n packageName: string\n options: OptionsView\n /** The call is commented out by `disable-plugin`. */\n disabled?: true\n}\n\nexport type ConfigView = {\n name?: string\n plugins: Array<PluginView>\n adapter?: PluginView\n parsers?: Array<PluginView>\n /** The root `output` members Studio may set, absent when `output` is not an object literal. */\n output?: OptionsView\n}\n\n/** The config file as Studio may edit it, or why it cannot. */\nexport type ConfigFileView = { managed: true; configs: Array<ConfigView> } | { managed: false; reason: string }\n\nexport type ConfigEditOutcome = {\n edit: ConfigEdit\n applied: boolean\n reason?: string\n}\n\nexport type ExtensionEntry = {\n package: string\n version: string\n manifest: ExtensionManifest\n /** Ships with `kubb` at its version, so updating `kubb` updates it and `kubb update` cannot. */\n bundled?: true\n}\n\n/** Installed extensions by package name, the only ones Studio may import besides `@kubb/plugin-*`. */\nexport type InstalledExtensions = ReadonlyMap<string, ExtensionEntry>\n","import { type ExtensionKind, isPackageName } from '@kubb/core'\nimport { camelCase } from '@internals/utils'\nimport { extensionKinds, type InstalledExtensions, type OptionValue } from './types.ts'\n\n/** `@kubb/plugin-ts` becomes `plugin-ts`, the `name` Kubb plugin factories use. */\nexport function toPluginName(packageName: string): string {\n return packageName.split('/').pop() ?? packageName\n}\n\n/** `@kubb/plugin-react-query` becomes `pluginReactQuery`, the export a plugin package uses by convention. */\nexport function toExportName(packageName: string): string {\n return camelCase(toPluginName(packageName))\n}\n\nconst KUBB_PLUGIN_SPECIFIER = /^@kubb\\/plugin-[\\w.-]+$/\n\n/** Only a `@kubb/plugin-*` package or an installed extension of `kind` may be imported, never a path or URL. */\nexport function isAllowedPlugin({\n packageName,\n extensions,\n kind = extensionKinds.plugin,\n}: {\n packageName: string\n extensions: InstalledExtensions\n kind?: ExtensionKind\n}): boolean {\n if (!isPackageName(packageName)) return false\n return (kind === extensionKinds.plugin && KUBB_PLUGIN_SPECIFIER.test(packageName)) || extensions.get(packageName)?.manifest.kind === kind\n}\n\nconst UNSAFE_KEYS = new Set(['__proto__', 'constructor', 'prototype'])\n\n/** Whether `key` can be an option key without reaching the object's prototype. */\nexport function isSafeKey(key: string): boolean {\n return !UNSAFE_KEYS.has(key)\n}\n\nexport function isPlainObject(value: unknown): value is Record<string, unknown> {\n if (typeof value !== 'object' || value === null) return false\n const prototype = Object.getPrototypeOf(value)\n return prototype === null || prototype === Object.prototype\n}\n\n/** Whether `value` survives a JSON round trip, so an edit never writes a lossy copy into the file. */\nexport function isOptionValue(value: unknown): value is OptionValue {\n if (value === null || typeof value === 'string' || typeof value === 'boolean') return true\n if (typeof value === 'number') return Number.isFinite(value)\n if (Array.isArray(value)) return value.every(isOptionValue)\n if (isPlainObject(value)) return Object.entries(value).every(([key, entry]) => isSafeKey(key) && isOptionValue(entry))\n\n return false\n}\n\n/** The root `output` members Studio may set, with the values each takes. */\nconst OUTPUT_VALUES: Record<string, (value: unknown) => boolean> = {\n barrel: (value) => value === false || (isPlainObject(value) && Object.keys(value).length === 1 && (value.type === 'named' || value.type === 'all')),\n format: (value) => value === false || ['auto', 'prettier', 'biome', 'oxfmt'].includes(value as string),\n lint: (value) => value === false || ['auto', 'eslint', 'biome', 'oxlint'].includes(value as string),\n clean: (value) => typeof value === 'boolean',\n defaultBanner: (value) => value === false || value === 'simple' || value === 'full',\n}\n\nexport function isOutputKey(key: string): boolean {\n return Object.hasOwn(OUTPUT_VALUES, key)\n}\n\nexport function isOutputValue({ key, value }: { key: string; value: unknown }): boolean {\n return isOutputKey(key) && OUTPUT_VALUES[key]!(value)\n}\n\nexport function pickOutput<T>(output: Record<string, T>): Record<string, T> {\n return Object.fromEntries(Object.entries(output).filter(([key]) => isOutputKey(key)))\n}\n","import type { ValueOf } from '@internals/utils'\nimport { type ArrayExpression, nodeTypes, type ObjectExpression } from './ast.ts'\nimport type { OptionValue } from './types.ts'\n\n/**\n * A valid JavaScript identifier, so an import name can only ever print as `import { name } from`,\n * never as source that breaks out of the import statement.\n */\nexport const IDENTIFIER_PATTERN = /^[A-Za-z_$][\\w$]*$/\n\nexport const quotes = { single: `'`, double: `\"` } as const\nexport type Quote = ValueOf<typeof quotes>\n\n/** `source` with the text between `start` and `end` replaced by `text`. */\nexport function replaceText(source: string, start: number, end: number, text = ''): string {\n return `${source.slice(0, start)}${text}${source.slice(end)}`\n}\n\n/** The 1-based line and 0-based column of `offset` in `source`. */\nexport function getPosition(source: string, offset: number): { line: number; column: number } {\n return { line: source.slice(0, offset).split('\\n').length, column: offset - source.lastIndexOf('\\n', offset - 1) - 1 }\n}\n\n/** Writes `value` as a single-line literal with the file's quote style. */\nexport function printValue(value: OptionValue, quote: Quote): string {\n if (typeof value === 'string') {\n // JSON's escaping covers every character that could end the literal or the line.\n const escaped = JSON.stringify(value).slice(1, -1)\n return quote === quotes.double ? `\"${escaped}\"` : `'${escaped.replaceAll(`\\\\\"`, `\"`).replaceAll(`'`, `\\\\'`)}'`\n }\n if (value === null || typeof value !== 'object') return String(value)\n if (Array.isArray(value)) return `[${value.map((item) => printValue(item, quote)).join(', ')}]`\n\n const entries = Object.entries(value)\n return entries.length ? `{ ${entries.map(([key, item]) => `${printKey(key, quote)}: ${printValue(item, quote)}`).join(', ')} }` : '{}'\n}\n\n/** An object key as source text: bare when it is an identifier, quoted otherwise. */\nexport function printKey(key: string, quote: Quote): string {\n return IDENTIFIER_PATTERN.test(key) ? key : printValue(key, quote)\n}\n\n/** `value` wrapped in one object per key of `path`: `wrapPath(['enum', 'type'], 'enum')` is `{ enum: { type: 'enum' } }`. */\nexport function wrapPath(path: Array<string>, value: OptionValue): OptionValue {\n return path.reduceRight<OptionValue>((inner, key) => ({ [key]: inner }), value)\n}\n\n/**\n * Adds `text` as the last item of an object or array literal, following its layout: on a line of\n * its own with the last item's indentation when the literal spans lines, inline otherwise.\n */\nexport function appendItem(source: string, container: ObjectExpression | ArrayExpression, text: string): string {\n const { start, end } = container\n const items: Array<{ start: number; end: number } | null> = container.type === nodeTypes.objectExpression ? container.properties : container.elements\n const last = items.filter((item) => item !== null).at(-1)\n\n if (!last) {\n const inner = source.slice(start + 1, end - 1)\n // A comment inside the empty literal stays, after the new item.\n if (inner.trim()) return replaceText(source, start + 1, start + 1, /^\\s/.test(inner) ? `${text},` : `${text}, `)\n return replaceText(source, start, end, container.type === nodeTypes.objectExpression ? `{ ${text} }` : `[${text}]`)\n }\n\n const between = source.slice(last.end, end - 1)\n // The closing bracket shares the last item's line: add the item inline.\n if (!between.includes('\\n')) return replaceText(source, last.end, last.end, `, ${text}`)\n\n const lineStart = source.lastIndexOf('\\n', last.start - 1) + 1\n const indent = source.slice(lineStart).match(/^[ \\t]*/)?.[0] ?? ''\n // After the last item's comma and any comment on its line, so neither moves. `between` holds a\n // newline, so one always follows.\n const lineEnd = source.indexOf('\\n', last.end)\n const comma = /^\\s*,/.test(between)\n\n return `${source.slice(0, last.end)}${comma ? '' : ','}${source.slice(last.end, lineEnd)}\\n${indent}${text}${comma ? ',' : ''}${source.slice(lineEnd)}`\n}\n\n/** Drops the item at `index` from an object or array literal, with its own lines when it sits on them alone. */\nexport function removeItem(source: string, node: ObjectExpression | ArrayExpression, index: number): string {\n const items: Array<{ start: number; end: number }> =\n node.type === nodeTypes.objectExpression ? node.properties : node.elements.filter((element) => element !== null)\n if (items.length === 1) return replaceText(source, node.start, node.end, node.type === nodeTypes.objectExpression ? '{}' : '[]')\n\n const { start, end } = items[index]!\n const lineStart = source.lastIndexOf('\\n', start - 1) + 1\n const nextNewline = source.indexOf('\\n', end)\n const lineEnd = nextNewline === -1 ? source.length : nextNewline\n if (!source.slice(lineStart, start).trim() && /^\\s*,?\\s*(\\/\\/.*)?$/.test(source.slice(end, lineEnd))) {\n return replaceText(source, lineStart, Math.min(lineEnd + 1, source.length))\n }\n\n const next = items[index + 1]\n return next ? replaceText(source, start, next.start) : replaceText(source, items[index - 1]!.end, end)\n}\n","import type { ExtensionKind } from '@kubb/core'\nimport { getErrorMessage, read, writeRaw } from '@internals/utils'\nimport type { ValueOf } from '@internals/utils'\nimport {\n type AssignmentExpression,\n type BindingProperty,\n type CallExpression,\n type Comment,\n type Expression,\n type ImportDeclaration,\n type ObjectExpression,\n type ObjectPropertyKind,\n type Program,\n type RestElement,\n type SpreadElement,\n type VariableDeclaration,\n commentTypes,\n nodeTypes,\n parseExpression,\n parseSource,\n propertyKinds,\n unaryOperators,\n} from './ast.ts'\nimport { isAllowedPlugin, isOptionValue, isOutputKey, isOutputValue, isSafeKey, pickOutput, toExportName } from './rules.ts'\nimport { appendItem, getPosition, IDENTIFIER_PATTERN, printKey, printValue, quotes, type Quote, removeItem, replaceText, wrapPath } from './text.ts'\nimport {\n type ConfigEdit,\n ConfigEditOperation,\n type ConfigEditOutcome,\n type ConfigFileView,\n type ConfigRef,\n type ConfigView,\n extensionKinds,\n type InstalledExtensions,\n type OptionsView,\n type OptionValue,\n type PluginView,\n} from './types.ts'\n\n/** The marker `disable-plugin` writes, with the block's line count so `enable-plugin` restores exactly those lines. */\nconst DISABLED_MARKER_PATTERN = /^kubb:disabled (.+)\\s+(\\d+)$/\n\nconst OPERATIONS = new Set<string>(Object.values(ConfigEditOperation))\nconst OPTION_OPERATIONS = new Set<string>([ConfigEditOperation.SET_OPTION, ConfigEditOperation.REMOVE_OPTION])\nconst OUTPUT_OPERATIONS = new Set<string>([ConfigEditOperation.SET_OUTPUT, ConfigEditOperation.REMOVE_OUTPUT])\nconst KINDS = new Set<string>(Object.values(extensionKinds))\n\n/** Identifiers the editor matches by name. */\nconst identifiers = { defineConfig: 'defineConfig', require: 'require', module: 'module', exports: 'exports' } as const\n\nconst moduleKinds = { esm: 'esm', cjs: 'cjs' } as const\ntype ModuleKind = ValueOf<typeof moduleKinds>\n\ntype EditResult = { source: string } | { reason: string }\ntype ParsedConfig = { program: Program; comments: Array<Comment>; configs: Array<ObjectExpression>; kind: ModuleKind }\ntype ValueNode = Expression | SpreadElement | null | undefined\ntype Import = { from: string; exported: string }\ntype FactoryCall = { importName: string; exportName: string; packageName: string; call: CallExpression }\ntype DisabledBlock = { packageName: string; line: number; end: number; code: Array<string> }\ntype OutputEdit = Extract<ConfigEdit, { operation: typeof ConfigEditOperation.SET_OUTPUT | typeof ConfigEditOperation.REMOVE_OUTPUT }>\ntype OptionEdit = Extract<ConfigEdit, { operation: typeof ConfigEditOperation.SET_OPTION | typeof ConfigEditOperation.REMOVE_OPTION }>\ntype AddPluginEdit = Extract<ConfigEdit, { operation: typeof ConfigEditOperation.ADD_PLUGIN }>\ntype DisablePluginEdit = Extract<ConfigEdit, { operation: typeof ConfigEditOperation.DISABLE_PLUGIN }>\ntype RemoveExtensionEdit = Extract<ConfigEdit, { operation: typeof ConfigEditOperation.REMOVE_EXTENSION }>\n\nfunction isNonEmptyString(value: unknown): value is string {\n return typeof value === 'string' && value !== ''\n}\n\n/** Edits cross the wire, so their shape is checked before anything reads them. */\nfunction validateEdit(edit: ConfigEdit): string | undefined {\n const { operation, plugin, config, path, kind, input } = (typeof edit === 'object' && edit !== null ? edit : {}) as Record<string, unknown>\n\n if (typeof operation !== 'string' || !OPERATIONS.has(operation)) return `unknown operation ${JSON.stringify(operation)}`\n if (config !== undefined && typeof config !== 'string' && !Number.isSafeInteger(config)) return 'config must name an entry or give its index'\n\n if (operation === ConfigEditOperation.SET_INPUT) {\n return typeof input === 'string' && input.trim() !== '' ? undefined : 'the edit names no input'\n }\n\n const isOption = OPTION_OPERATIONS.has(operation)\n const isOutput = OUTPUT_OPERATIONS.has(operation)\n\n if (!isOutput && !isNonEmptyString(plugin)) return 'the edit names no plugin'\n\n if (kind !== undefined) {\n if (typeof kind !== 'string' || !KINDS.has(kind)) return `unknown kind ${JSON.stringify(kind)}`\n const takesKind = operation === ConfigEditOperation.ADD_PLUGIN || operation === ConfigEditOperation.REMOVE_EXTENSION\n if (takesKind && kind === extensionKinds.adapter) return `${operation} takes a plugin or a parser, since a config has one adapter`\n if (!isOption && !takesKind) return `${operation} edits the plugins array, so it takes no kind`\n }\n\n if (!isOption && !isOutput) return undefined\n\n if (!Array.isArray(path) || !path.every(isNonEmptyString)) return 'path must be a list of option names'\n if (path.length === 0) return 'no option path given'\n\n const unsafe = path.find((key) => !isSafeKey(key))\n if (unsafe !== undefined) return `${unsafe} cannot be used as an option name`\n\n if (isOutput && !isOutputKey(path[0]!)) return `output.${path[0]} can only be changed in the config file`\n\n return undefined\n}\n\n// Finding the config\n\n/** Steps through `as`/`satisfies` and `() => ...` wrappers to the config object. */\nfunction unwrapValue(node: ValueNode): ValueNode {\n if (!node) return undefined\n if (node.type === nodeTypes.tSAsExpression || node.type === nodeTypes.tSSatisfiesExpression) return unwrapValue(node.expression)\n if (node.type !== nodeTypes.arrowFunctionExpression && node.type !== nodeTypes.functionExpression) return node\n if (node.body?.type !== nodeTypes.blockStatement) return unwrapValue(node.body as Expression | null)\n\n const returned = node.body.body.find((statement) => statement.type === nodeTypes.returnStatement)\n return unwrapValue(returned?.type === nodeTypes.returnStatement ? returned.argument : undefined)\n}\n\nfunction isModuleExports(node: AssignmentExpression['left']): boolean {\n return (\n node.type === nodeTypes.memberExpression &&\n !node.computed &&\n node.object.type === nodeTypes.identifier &&\n node.object.name === identifiers.module &&\n node.property.type === nodeTypes.identifier &&\n node.property.name === identifiers.exports\n )\n}\n\n/** The exported config value and how the file exports it. */\nfunction findExport(program: Program): { exported: ValueNode; kind: ModuleKind } {\n for (const node of program.body) {\n if (node.type === nodeTypes.exportDefaultDeclaration) {\n // A `function` or `class` declaration is never a `defineConfig(...)` call, so `findConfigs` refuses it.\n return { exported: node.declaration as Expression, kind: moduleKinds.esm }\n }\n if (node.type === nodeTypes.expressionStatement && node.expression.type === nodeTypes.assignmentExpression && isModuleExports(node.expression.left)) {\n return { exported: node.expression.right, kind: moduleKinds.cjs }\n }\n }\n return { exported: undefined, kind: moduleKinds.esm }\n}\n\n/** Every config object in `export default` or `module.exports = defineConfig(...)`, or why the file is unmanaged. */\nfunction findConfigs(source: string): ParsedConfig | { reason: string } {\n const parsed = parseSource(source)\n if ('reason' in parsed) return parsed\n\n const { exported, kind } = findExport(parsed.program)\n const value = unwrapValue(exported)\n if (!value) return { reason: 'no `export default` or `module.exports` found' }\n if (value.type !== nodeTypes.callExpression || value.callee.type !== nodeTypes.identifier || value.callee.name !== identifiers.defineConfig) {\n return { reason: 'the exported config is not a defineConfig(...) call' }\n }\n\n const argument = unwrapValue(value.arguments[0])\n if (!argument) return { reason: 'defineConfig(...) was called without a config' }\n\n const entries = argument.type === nodeTypes.arrayExpression ? argument.elements.map((element) => unwrapValue(element)) : [argument]\n const configs = entries.filter((entry): entry is ObjectExpression => entry?.type === nodeTypes.objectExpression)\n if (configs.length !== entries.length) return { reason: 'config is not an object literal' }\n\n return { ...parsed, configs, kind }\n}\n\nfunction findConfigEntry(configs: Array<ObjectExpression>, ref: ConfigRef | undefined): ObjectExpression | undefined {\n return typeof ref === 'string' ? configs.find((entry) => getConfigName(entry) === ref) : configs[ref ?? 0]\n}\n\n// Reading object literals\n\nfunction getKey(entry: ObjectPropertyKind | BindingProperty | RestElement): string | undefined {\n if (entry.type !== nodeTypes.property || entry.computed) return undefined\n if (entry.key.type === nodeTypes.identifier) return entry.key.name\n return entry.key.type === nodeTypes.literal && typeof entry.key.value === 'string' ? entry.key.value : undefined\n}\n\n/** The last one wins when the key repeats, as at runtime. */\nfunction findProperty(node: ObjectExpression, key: string): { member: ObjectPropertyKind; index: number } | undefined {\n const index = node.properties.findLastIndex((entry) => getKey(entry) === key)\n return index === -1 ? undefined : { member: node.properties[index]!, index }\n}\n\nfunction getValue(node: ObjectExpression, key: string): ValueNode {\n const member = findProperty(node, key)?.member\n return member?.type === nodeTypes.property ? member.value : member\n}\n\nfunction getConfigName(config: ObjectExpression): string | undefined {\n const name = getValue(config, 'name')\n return name?.type === nodeTypes.literal && typeof name.value === 'string' ? name.value : undefined\n}\n\nfunction isOverridden(node: ObjectExpression, index: number): boolean {\n return node.properties.slice(index + 1).some((entry) => entry.type === nodeTypes.spreadElement)\n}\n\n/** `key: value`, not a method, getter, setter, or `{ key }` shorthand. */\nfunction isPlainProperty(member: Extract<ObjectPropertyKind, { type: typeof nodeTypes.property }>): boolean {\n return !member.method && !member.shorthand && member.kind === propertyKinds.init\n}\n\n/** A literal's value, `undefined` for code. */\nfunction readLiteral(node: ValueNode): OptionValue | undefined {\n switch (node?.type) {\n case nodeTypes.literal:\n // A bigint or a regex is code, not a value JSON can carry. A regex Node cannot compile also has a `null` value.\n return 'regex' in node || 'bigint' in node ? undefined : (node.value as OptionValue)\n case nodeTypes.templateLiteral:\n return node.expressions.length ? undefined : (node.quasis[0]?.value.cooked ?? '')\n case nodeTypes.unaryExpression: {\n const value = readLiteral(node.argument)\n if (typeof value !== 'number') return undefined\n if (node.operator === unaryOperators.minus) return -value\n if (node.operator === unaryOperators.plus) return value\n return undefined\n }\n case nodeTypes.arrayExpression: {\n const values = node.elements.map((element) => readLiteral(element))\n return values.every((value) => value !== undefined) ? values : undefined\n }\n case nodeTypes.objectExpression: {\n const entries: Record<string, OptionValue> = {}\n for (const entry of node.properties) {\n if (entry.type !== nodeTypes.property) return undefined\n const key = getKey(entry)\n const value = readLiteral(entry.value)\n // A `__proto__` key would replace the object's prototype instead of adding an entry.\n if (key === undefined || !isSafeKey(key) || value === undefined) return undefined\n entries[key] = value\n }\n return entries\n }\n }\n return undefined\n}\n\n// Imports and factory calls\n\nfunction getRequirePath(node: ValueNode): string | undefined {\n if (node?.type !== nodeTypes.callExpression || node.callee.type !== nodeTypes.identifier || node.callee.name !== identifiers.require) return undefined\n const [argument] = node.arguments\n return argument?.type === nodeTypes.literal && typeof argument.value === 'string' ? argument.value : undefined\n}\n\n/** `import { exported as local } from '...'`. A default or namespace import has no exported name, so its local name stands in. */\nfunction importBindings(statement: ImportDeclaration): Array<[string, Import]> {\n return statement.specifiers.map((specifier) => {\n const imported = specifier.type === nodeTypes.importSpecifier ? specifier.imported : specifier.local\n const exported = imported.type === nodeTypes.identifier ? imported.name : imported.value\n return [specifier.local.name, { from: statement.source.value, exported }]\n })\n}\n\n/** `const { exported: local } = require('...')`. */\nfunction requireBindings(statement: VariableDeclaration): Array<[string, Import]> {\n return statement.declarations.flatMap((declarator): Array<[string, Import]> => {\n const from = getRequirePath(declarator.init)\n if (from === undefined || declarator.id.type !== nodeTypes.objectPattern) return []\n\n return declarator.id.properties.flatMap((entry): Array<[string, Import]> => {\n if (entry.type !== nodeTypes.property || entry.value.type !== nodeTypes.identifier) return []\n return [[entry.value.name, { from, exported: getKey(entry) ?? entry.value.name }]]\n })\n })\n}\n\nfunction getImports(program: Program): Map<string, Import> {\n return new Map(\n program.body.flatMap((statement) => {\n if (statement.type === nodeTypes.importDeclaration) return importBindings(statement)\n if (statement.type === nodeTypes.variableDeclaration) return requireBindings(statement)\n return []\n }),\n )\n}\n\nfunction isImportStatement(node: Program['body'][number], kind: ModuleKind): boolean {\n if (kind === moduleKinds.esm) return node.type === nodeTypes.importDeclaration\n return node.type === nodeTypes.variableDeclaration && node.declarations.some((declarator) => getRequirePath(declarator.init) !== undefined)\n}\n\n/** The quote of the first string literal in the file, so new code matches it. */\nfunction detectQuote(node: unknown): Quote | undefined {\n if (!node || typeof node !== 'object') return undefined\n const { type, raw } = node as { type?: string; raw?: unknown }\n if (type === nodeTypes.literal && typeof raw === 'string' && (raw[0] === quotes.single || raw[0] === quotes.double)) return raw[0]\n for (const child of Object.values(node)) {\n const quote = detectQuote(child)\n if (quote) return quote\n }\n return undefined\n}\n\n/** The `adapter` value, or the elements of the `plugins` or `parsers` array. */\nfunction factoryNodes(config: ObjectExpression, kind: ExtensionKind): Array<ValueNode> {\n if (kind === extensionKinds.adapter) return [getValue(config, 'adapter')]\n const array = getValue(config, `${kind}s`)\n return array?.type === nodeTypes.arrayExpression ? array.elements : []\n}\n\n/** The factory calls of one kind whose callee the file imports. */\nfunction findCalls(program: Program, config: ObjectExpression, kind: ExtensionKind = extensionKinds.plugin): Array<FactoryCall> {\n const imports = getImports(program)\n return factoryNodes(config, kind).flatMap((node) => {\n if (node?.type !== nodeTypes.callExpression || node.callee.type !== nodeTypes.identifier) return []\n const imported = imports.get(node.callee.name)\n return imported ? [{ importName: node.callee.name, exportName: imported.exported, packageName: imported.from, call: node }] : []\n })\n}\n\n// Disabled plugins\n\n/** Whether nothing but whitespace precedes `offset` on its line. */\nfunction startsLine(source: string, offset: number): boolean {\n return source.slice(source.lastIndexOf('\\n', offset - 1) + 1, offset).trim() === ''\n}\n\n/** The `disable-plugin` blocks in this config, read from marker comments since the call is no longer a node. */\nfunction findDisabled(source: string, comments: Array<Comment>, config: ObjectExpression): Array<DisabledBlock> {\n const lines = source.split('\\n')\n\n return comments.flatMap((comment) => {\n const match = comment.type === commentTypes.line ? comment.value.trim().match(DISABLED_MARKER_PATTERN) : null\n // Only markers inside this entry, on a line of their own, so another entry or a trailing comment never matches.\n if (!match || comment.start < config.start || comment.end > config.end || !startsLine(source, comment.start)) return []\n\n const line = getPosition(source, comment.start).line\n const end = line + Number(match[2])\n const code = lines.slice(line, end).map((text) => text.replace(/^(\\s*)\\/\\/ ?/, '$1').replace(/^\\s+$/, ''))\n return [{ packageName: match[1]!, line, end, code }]\n })\n}\n\n// Reading options\n\n/** Literal members as `value` and code paths as `locked`, `undefined` for a computed key. */\nfunction readEditable(node: ObjectExpression, prefix: Array<string> = []): { value: Record<string, OptionValue>; locked: Array<Array<string>> } | undefined {\n const value: Record<string, OptionValue> = {}\n const locked: Array<Array<string>> = []\n\n for (const [index, entry] of node.properties.entries()) {\n if (entry.type === nodeTypes.spreadElement) continue\n const key = getKey(entry)\n if (key === undefined) return undefined\n if (findProperty(node, key)?.index !== index) continue\n\n const path = [...prefix, key]\n // A `__proto__` key replaces the prototype, so it reads as code.\n if (!isSafeKey(key)) {\n locked.push(path)\n continue\n }\n\n const member = isOverridden(node, index) ? undefined : entry.value\n const literal = readLiteral(member)\n if (literal !== undefined) {\n value[key] = literal\n continue\n }\n if (member?.type !== nodeTypes.objectExpression) {\n locked.push(path)\n continue\n }\n\n const nested = readEditable(member, path)\n if (!nested) return undefined\n value[key] = nested.value\n locked.push(...nested.locked)\n }\n return { value, locked }\n}\n\nfunction readObjectOptions(options: ObjectExpression): OptionsView {\n const entries: OptionsView = {}\n for (const [index, entry] of options.properties.entries()) {\n const key = getKey(entry)\n if (key === undefined || !isSafeKey(key)) continue\n\n const member = entry.type === nodeTypes.property && !isOverridden(options, index) ? entry.value : undefined\n const value = readLiteral(member)\n if (value !== undefined) {\n entries[key] = { literal: true, value }\n continue\n }\n entries[key] = { literal: false, ...(member?.type === nodeTypes.objectExpression ? readEditable(member) : undefined) }\n }\n return entries\n}\n\nfunction readCallOptions(call: CallExpression): OptionsView {\n const options = call.arguments[0]\n return options?.type === nodeTypes.objectExpression ? readObjectOptions(options) : {}\n}\n\nfunction readDisabledOptions(code: Array<string>): OptionsView {\n const call = parseExpression(code.join('\\n').trim().replace(/,$/, ''))\n return call?.type === nodeTypes.callExpression ? readCallOptions(call) : {}\n}\n\nfunction toPluginView({ importName, packageName, call }: FactoryCall): PluginView {\n return { importName, packageName, options: readCallOptions(call) }\n}\n\n/** Active and disabled plugins, in source order so a disabled plugin keeps its place. */\nfunction readPlugins({ source, parsed, config }: { source: string; parsed: ParsedConfig; config: ObjectExpression }): Array<PluginView> {\n const importNames = new Map([...getImports(parsed.program)].map(([local, { from }]) => [from, local]))\n\n const active = findCalls(parsed.program, config).map((call) => ({ line: getPosition(source, call.call.start).line, plugin: toPluginView(call) }))\n const disabled = findDisabled(source, parsed.comments, config).map(({ packageName, line, code }) => ({\n line,\n plugin: {\n importName: importNames.get(packageName) ?? toExportName(packageName),\n packageName,\n options: readDisabledOptions(code),\n disabled: true as const,\n },\n }))\n\n return [...active, ...disabled].sort((a, b) => a.line - b.line).map(({ plugin }) => plugin)\n}\n\nfunction readConfigView({ source, parsed, config }: { source: string; parsed: ParsedConfig; config: ObjectExpression }): ConfigView {\n const [adapter] = findCalls(parsed.program, config, extensionKinds.adapter).map(toPluginView)\n const parsers = findCalls(parsed.program, config, extensionKinds.parser).map(toPluginView)\n const output = getOutput(config)\n\n return {\n name: getConfigName(config),\n plugins: readPlugins({ source, parsed, config }),\n ...(adapter && { adapter }),\n ...(parsers.length ? { parsers } : {}),\n ...(!('reason' in output) && { output: pickOutput(readObjectOptions(output.object)) }),\n }\n}\n\n/** Which plugins the file declares and which options Studio may write. */\nexport function readConfig(source: string): ConfigFileView {\n const parsed = findConfigs(source)\n if ('reason' in parsed) return { managed: false, reason: parsed.reason }\n\n return { managed: true, configs: parsed.configs.map((config) => readConfigView({ source, parsed, config })) }\n}\n\n/** The modules the file imports, empty when it cannot be parsed. */\nexport function readImports(source: string): Array<string> {\n const parsed = parseSource(source)\n if ('reason' in parsed) return []\n return [...new Set([...getImports(parsed.program).values()].map(({ from }) => from))]\n}\n\n// Editing options\n\ntype FoundPath = { object: ObjectExpression; index: number; value: Expression } | { object: ObjectExpression; missing: number } | { reason: string }\n\n/** Follows `path` to its literal, or to the first missing key. Refuses a value set in code. */\nfunction findPath(options: ObjectExpression, path: Array<string>): FoundPath {\n let object = options\n\n for (const [depth, key] of path.entries()) {\n const found = findProperty(object, key)\n if (!found) return { object, missing: depth }\n if (isOverridden(object, found.index)) {\n return { reason: `${path.slice(0, depth + 1).join('.')} can be overridden by a spread after it, so it is customized in code` }\n }\n\n const { member, index } = found\n const isLast = depth === path.length - 1\n if (isLast) {\n return member.type === nodeTypes.property && readLiteral(member.value) !== undefined\n ? { object, index, value: member.value }\n : { reason: `${path.join('.')} is customized in code` }\n }\n if (member.type !== nodeTypes.property || member.value.type !== nodeTypes.objectExpression) {\n return { reason: `${key} is not an object, so ${path.join('.')} cannot be reached` }\n }\n object = member.value\n }\n return { reason: 'no option path given' }\n}\n\nfunction setAtPath({\n source,\n options,\n path,\n value,\n quote,\n}: {\n source: string\n options: ObjectExpression\n path: Array<string>\n value: OptionValue\n quote: Quote\n}): EditResult {\n const target = findPath(options, path)\n if ('reason' in target) return target\n if ('missing' in target) {\n const [key, ...rest] = path.slice(target.missing)\n return { source: appendItem(source, target.object, `${printKey(key!, quote)}: ${printValue(wrapPath(rest, value), quote)}`) }\n }\n return { source: replaceText(source, target.value.start, target.value.end, printValue(value, quote)) }\n}\n\nfunction removeAtPath({ source, options, path }: { source: string; options: ObjectExpression; path: Array<string> }): EditResult {\n const target = findPath(options, path)\n if ('reason' in target) return target\n if ('missing' in target) return { source }\n return { source: removeItem(source, target.object, target.index) }\n}\n\nfunction setOption(source: string, call: CallExpression, path: Array<string>, value: unknown, quote: Quote): EditResult {\n if (!isOptionValue(value)) return { reason: 'the value is not a literal that can be written to a config file' }\n\n const options = call.arguments[0]\n if (!options) {\n const closing = call.end - 1\n if (source[closing] !== ')') return { reason: 'the factory call could not be located in the file' }\n return { source: replaceText(source, closing, closing, printValue(wrapPath(path, value), quote)) }\n }\n if (options.type !== nodeTypes.objectExpression) return { reason: 'the factory was not called with an object literal' }\n return setAtPath({ source, options, path, value, quote })\n}\n\nfunction removeOption(source: string, call: CallExpression, path: Array<string>): EditResult {\n const options = call.arguments[0]\n if (!options) return { source }\n if (options.type !== nodeTypes.objectExpression) return { reason: 'the factory was not called with an object literal' }\n return removeAtPath({ source, options, path })\n}\n\nfunction editOption({\n source,\n parsed,\n config,\n edit,\n quote,\n extensions,\n}: {\n source: string\n parsed: ParsedConfig\n config: ObjectExpression\n edit: OptionEdit\n quote: Quote\n extensions: InstalledExtensions\n}): EditResult {\n const kind = edit.kind ?? extensionKinds.plugin\n // A package can ship several factories (`parserTs`, `parserTsx`), so prefer the export its manifest names.\n const calls = findCalls(parsed.program, config, kind).filter((entry) => entry.packageName === edit.plugin)\n const exportName = extensions.get(edit.plugin)?.manifest.export ?? toExportName(edit.plugin)\n const call = (calls.find((entry) => entry.exportName === exportName) ?? calls[0])?.call\n\n if (!call) {\n if (kind === extensionKinds.adapter) return { reason: `${edit.plugin} is not the config's adapter` }\n const disabled = kind === extensionKinds.plugin && findDisabled(source, parsed.comments, config).some((block) => block.packageName === edit.plugin)\n return { reason: disabled ? `${edit.plugin} is disabled, enable it first` : `${edit.plugin} is not in the ${kind}s array` }\n }\n\n if (edit.operation === ConfigEditOperation.SET_OPTION) return setOption(source, call, edit.path, edit.value, quote)\n return removeOption(source, call, edit.path)\n}\n\n// Editing the config's own fields\n\nfunction setInput(source: string, config: ObjectExpression, input: string, quote: Quote): EditResult {\n const value = printValue(input, quote)\n const found = findProperty(config, 'input')\n if (!found) return { source: appendItem(source, config, `input: ${value}`) }\n if (found.member.type !== nodeTypes.property || !isPlainProperty(found.member)) return { reason: 'input is not a plain property' }\n if (isOverridden(config, found.index)) return { reason: 'a spread after input could override it' }\n return { source: replaceText(source, found.member.value.start, found.member.value.end, value) }\n}\n\nfunction getOutput(config: ObjectExpression): { object: ObjectExpression } | { reason: string } {\n const found = findProperty(config, 'output')\n if (found?.member.type !== nodeTypes.property || found.member.value.type !== nodeTypes.objectExpression) return { reason: 'output is not an object literal' }\n if (isOverridden(config, found.index)) return { reason: 'a spread after output could override it' }\n return { object: found.member.value }\n}\n\nfunction editOutput({ source, config, edit, quote }: { source: string; config: ObjectExpression; edit: OutputEdit; quote: Quote }): EditResult {\n const output = getOutput(config)\n if ('reason' in output) return output\n if (edit.operation === ConfigEditOperation.REMOVE_OUTPUT) return removeAtPath({ source, options: output.object, path: edit.path })\n\n const [key, ...rest] = edit.path\n if (!isOptionValue(edit.value) || !isOutputValue({ key: key!, value: wrapPath(rest, edit.value) }))\n return { reason: `the value is not one output.${key} takes` }\n return setAtPath({ source, options: output.object, path: edit.path, value: edit.value, quote })\n}\n\n// Adding, disabling, and enabling plugins\n\n/** Adds the import after the last one, matching its semicolon style. */\nfunction addImport({\n source,\n parsed,\n importNames,\n moduleSpecifier,\n quote,\n}: {\n source: string\n parsed: ParsedConfig\n importNames: Array<string>\n moduleSpecifier: string\n quote: Quote\n}): string {\n const lastImport = parsed.program.body.findLast((node) => isImportStatement(node, parsed.kind))\n const afterLine = lastImport ? getPosition(source, lastImport.end).line : 0\n const lines = source.split('\\n')\n\n const semicolon = afterLine > 0 && lines[afterLine - 1]?.trimEnd().endsWith(';') ? ';' : ''\n const specifier = `${quote}${moduleSpecifier}${quote}`\n const statement =\n parsed.kind === moduleKinds.esm ? `import { ${importNames.join(', ')} } from ${specifier}` : `const { ${importNames.join(', ')} } = require(${specifier})`\n\n lines.splice(afterLine, 0, `${statement}${semicolon}`)\n if (afterLine === 0) lines.splice(1, 0, '')\n\n return lines.join('\\n')\n}\n\n/**\n * The parsers `defineConfig` applies when a config sets no `parsers`, by import name. Adding a parser\n * to such a config writes these too, or the new array would replace them.\n */\nconst DEFAULT_PARSERS = [\n { importName: 'parserTs', packageName: '@kubb/parser-ts' },\n { importName: 'parserTsx', packageName: '@kubb/parser-ts' },\n { importName: 'parserMd', packageName: '@kubb/parser-md' },\n] as const\n\n/**\n * Adds a plugin to `plugins`, or with `kind: 'parser'` a parser to `parsers`. Replaying the same add\n * is a no-op, while an import name taken by another package is an error.\n */\nfunction addPlugin({\n source,\n parsed,\n config,\n edit,\n quote,\n extensions,\n}: {\n source: string\n parsed: ParsedConfig\n config: ObjectExpression\n edit: AddPluginEdit\n quote: Quote\n extensions: InstalledExtensions\n}): EditResult {\n const kind = edit.kind ?? extensionKinds.plugin\n const isParser = kind === extensionKinds.parser\n if (!isAllowedPlugin({ packageName: edit.plugin, extensions, kind })) {\n return {\n reason: isParser ? `\"${edit.plugin}\" is not an installed Kubb parser` : `\"${edit.plugin}\" is not a @kubb/plugin-* package or an installed Kubb plugin`,\n }\n }\n\n const importName = extensions.get(edit.plugin)?.manifest.export ?? toExportName(edit.plugin)\n if (!IDENTIFIER_PATTERN.test(importName)) return { reason: `\"${importName}\" is not a valid import name` }\n // A package can ship several parsers (`parserTs` and `parserTsx`), so a parser is matched by its export too.\n if (findCalls(parsed.program, config, kind).some((entry) => entry.packageName === edit.plugin && (!isParser || entry.exportName === importName))) {\n return { source }\n }\n\n const options = edit.options ?? {}\n if (!isOptionValue(options)) return { reason: 'the options are not literals that can be written to a config file' }\n\n const key = `${kind}s`\n const array = getValue(config, key)\n if (array ? array.type !== nodeTypes.arrayExpression : !isParser) return { reason: `${key} is not an array literal` }\n // A config without `parsers` runs the defaults, so the new array lists them before the added parser.\n const defaults = isParser && !array ? DEFAULT_PARSERS.filter((parser) => parser.importName !== importName) : []\n\n // The missing imports by package, so `parserTs` and `parserTsx` share one line.\n const imports = getImports(parsed.program)\n const missing = new Map<string, Array<string>>()\n for (const item of [...defaults, { importName, packageName: edit.plugin }]) {\n const from = imports.get(item.importName)?.from\n if (from && from !== item.packageName) return { reason: `${item.importName} is already imported from ${from}` }\n if (!from) missing.set(item.packageName, [...(missing.get(item.packageName) ?? []), item.importName])\n }\n\n // The array sits below the imports, so adding to it first leaves the import lines where they are.\n const call = `${importName}(${Object.keys(options).length ? printValue(options, quote) : ''})`\n const next =\n array?.type === nodeTypes.arrayExpression\n ? appendItem(source, array, call)\n : appendItem(source, config, `parsers: [${[...defaults.map((parser) => `${parser.importName}()`), call].join(', ')}]`)\n\n return {\n source: [...missing].reduceRight(\n (current, [moduleSpecifier, importNames]) => addImport({ source: current, parsed, importNames, moduleSpecifier, quote }),\n next,\n ),\n }\n}\n\n/** One item per line, so a call can be commented out alone. Skipped when comments sit between items. */\nfunction splitPlugins(source: string, config: ObjectExpression): string | undefined {\n const array = getValue(config, 'plugins')\n if (array?.type !== nodeTypes.arrayExpression) return undefined\n\n const items = array.elements.flatMap((element) => (element ? [element] : []))\n const { start, end } = array\n const gaps = [source.slice(start + 1, items[0]?.start ?? end - 1), ...items.map((item, index) => source.slice(item.end, items[index + 1]?.start ?? end - 1))]\n if (!items.length || gaps.some((gap) => !/^[\\s,]*$/.test(gap))) return undefined\n\n const lineStart = source.lastIndexOf('\\n', start - 1) + 1\n const indent = source.slice(lineStart).match(/^[ \\t]*/)?.[0] ?? ''\n const lines = items.map((item) => `${indent} ${source.slice(item.start, item.end)},`)\n\n return replaceText(source, start, end, `[\\n${lines.join('\\n')}\\n${indent}]`)\n}\n\nfunction disablePlugin(source: string, program: Program, config: ObjectExpression, plugin: string): EditResult {\n const call = findCalls(program, config).find((entry) => entry.packageName === plugin)?.call\n if (!call) return { reason: `${plugin} is not in the plugins array` }\n\n const start = getPosition(source, call.start)\n const end = getPosition(source, call.end)\n const lines = source.split('\\n')\n const from = start.line - 1\n const to = end.line - 1\n const firstLine = lines[from] ?? ''\n\n // Only safe when the call sits alone on its lines: anything else on its first line, or on its last\n // line besides a trailing comma, would be swallowed into the comment and corrupt the file.\n if (firstLine.slice(0, start.column).trim() || !/^,?\\s*$/.test((lines[to] ?? '').slice(end.column))) {\n return { reason: `${plugin} shares a line with other code, so it cannot be commented out safely` }\n }\n\n const indent = firstLine.match(/^\\s*/)?.[0] ?? ''\n const commented = lines.slice(from, to + 1).map((line) => (line.trim() ? `${indent}// ${line.slice(indent.length)}` : `${indent}//`))\n lines.splice(from, commented.length, `${indent}// kubb:disabled ${plugin} ${commented.length}`, ...commented)\n\n return { source: lines.join('\\n') }\n}\n\n/** Disables the plugin, first putting a one-line `plugins: [a(), b()]` (what `add-plugin` writes) on separate lines. */\nfunction disablePluginInConfig({\n source,\n parsed,\n config,\n edit,\n}: {\n source: string\n parsed: ParsedConfig\n config: ObjectExpression\n edit: DisablePluginEdit\n}): EditResult {\n const result = disablePlugin(source, parsed.program, config, edit.plugin)\n if (!('reason' in result) || !result.reason.includes('shares a line')) return result\n\n const split = splitPlugins(source, config)\n if (split === undefined) return result\n\n const reparsed = findConfigs(split)\n const reparsedConfig = 'reason' in reparsed ? undefined : findConfigEntry(reparsed.configs, edit.config)\n if ('reason' in reparsed || !reparsedConfig) return result\n\n return disablePlugin(split, reparsed.program, reparsedConfig, edit.plugin)\n}\n\nfunction enablePlugin(source: string, comments: Array<Comment>, config: ObjectExpression, plugin: string): EditResult {\n const block = findDisabled(source, comments, config).find((entry) => entry.packageName === plugin)\n if (!block) return { reason: `${plugin} is not disabled` }\n\n const lines = source.split('\\n')\n lines.splice(block.line - 1, block.end - block.line + 1, ...block.code)\n return { source: lines.join('\\n') }\n}\n\n// Removing extensions\n\n/** Drops the import statements of `packageName` once nothing else in the file uses their names. */\nfunction removeUnusedImports(source: string, packageName: string): string {\n const parsed = parseSource(source)\n if ('reason' in parsed) return source\n\n // From the last statement up, so the offsets of the earlier ones stay valid.\n return parsed.program.body.reduceRight((current, statement) => {\n const bindings =\n statement.type === nodeTypes.importDeclaration\n ? importBindings(statement)\n : statement.type === nodeTypes.variableDeclaration\n ? requireBindings(statement)\n : []\n if (!bindings.length || bindings.some(([, { from }]) => from !== packageName)) return current\n\n const rest = replaceText(current, statement.start, statement.end)\n if (bindings.some(([local]) => new RegExp(`(?<![\\\\w$])${local.replaceAll('$', '\\\\$')}(?![\\\\w$])`).test(rest))) return current\n\n const lineStart = current.lastIndexOf('\\n', statement.start - 1) + 1\n const lineEnd = current.indexOf('\\n', statement.end)\n const after = lineEnd === -1 ? current.length : lineEnd + 1\n // At the top of the file, the blank line after the import goes too, so the file does not start with one.\n return replaceText(current, lineStart, lineStart === 0 && current[after] === '\\n' ? after + 1 : after)\n }, source)\n}\n\n/**\n * Removes every call of a plugin or parser package, and the block `disable-plugin` commented out,\n * then its unused imports. Removing what the config does not hold is a no-op. Refuses to empty\n * `parsers`, since a config with no parser cannot print files.\n */\nfunction removeExtension(source: string, edit: RemoveExtensionEdit): EditResult {\n const kind = edit.kind ?? extensionKinds.plugin\n let current = source\n\n // One call at a time, re-parsing in between, since each removal moves the ones after it.\n for (;;) {\n const parsed = findConfigs(current)\n if ('reason' in parsed) return parsed\n const config = findConfigEntry(parsed.configs, edit.config)\n if (!config) return { reason: `no config entry found for ${JSON.stringify(edit.config)}` }\n\n const array = getValue(config, `${kind}s`)\n const calls = findCalls(parsed.program, config, kind).filter((entry) => entry.packageName === edit.plugin)\n const block = findDisabled(current, parsed.comments, config).find((entry) => entry.packageName === edit.plugin)\n\n if (calls[0] && array?.type === nodeTypes.arrayExpression) {\n const elements = array.elements.filter((element) => element !== null)\n if (kind === extensionKinds.parser && elements.length === calls.length) return { reason: `${edit.plugin} is the last parser in the parsers array` }\n current = removeItem(current, array, elements.indexOf(calls[0].call))\n continue\n }\n if (block && kind === extensionKinds.plugin) {\n const lines = current.split('\\n')\n lines.splice(block.line - 1, block.end - block.line + 1)\n current = lines.join('\\n')\n continue\n }\n return { source: current === source ? source : removeUnusedImports(current, edit.plugin) }\n }\n}\n\n// Applying edits\n\n/** Every edit re-parses the file, since the previous one rewrote it. */\nfunction applyEdit({ source, edit, extensions }: { source: string; edit: ConfigEdit; extensions: InstalledExtensions }): EditResult {\n const parsed = findConfigs(source)\n if ('reason' in parsed) return parsed\n\n const config = findConfigEntry(parsed.configs, edit.config)\n if (!config) return { reason: `no config entry found for ${JSON.stringify(edit.config)}` }\n const quote = detectQuote(parsed.program) ?? quotes.single\n\n switch (edit.operation) {\n case ConfigEditOperation.SET_INPUT:\n return setInput(source, config, edit.input, quote)\n case ConfigEditOperation.SET_OUTPUT:\n case ConfigEditOperation.REMOVE_OUTPUT:\n return editOutput({ source, config, edit, quote })\n case ConfigEditOperation.DISABLE_PLUGIN:\n return disablePluginInConfig({ source, parsed, config, edit })\n case ConfigEditOperation.ENABLE_PLUGIN:\n return enablePlugin(source, parsed.comments, config, edit.plugin)\n case ConfigEditOperation.ADD_PLUGIN:\n return addPlugin({ source, parsed, config, edit, quote, extensions })\n case ConfigEditOperation.REMOVE_EXTENSION:\n return removeExtension(source, edit)\n case ConfigEditOperation.SET_OPTION:\n case ConfigEditOperation.REMOVE_OPTION:\n return editOption({ source, parsed, config, edit, quote, extensions })\n }\n}\n\n/** Applies edits in place, touching only the text each targets. A refused edit is reported and the rest still run. */\nexport function editConfig({ source, edits, extensions = new Map() }: { source: string; edits: Array<ConfigEdit>; extensions?: InstalledExtensions }): {\n source: string\n outcomes: Array<ConfigEditOutcome>\n changed: boolean\n} {\n let current = source\n\n const outcomes = edits.map((edit): ConfigEditOutcome => {\n const invalid = validateEdit(edit)\n if (invalid) return { edit, applied: false, reason: invalid }\n\n try {\n const result = applyEdit({ source: current, edit, extensions })\n if ('reason' in result) return { edit, applied: false, reason: result.reason }\n current = result.source\n return { edit, applied: true }\n } catch (error) {\n return { edit, applied: false, reason: getErrorMessage(error) }\n }\n })\n\n return { source: current, outcomes, changed: current !== source }\n}\n\n/** Applies `edits` to `filePath`, writing only when something changed. */\nexport async function editConfigFile({ filePath, edits, extensions }: { filePath: string; edits: Array<ConfigEdit>; extensions?: InstalledExtensions }) {\n const current = await read(filePath)\n const result = editConfig({ source: current, edits, extensions })\n if (result.changed) await writeRaw(filePath, result.source)\n return result\n}\n"],"mappings":";;;;;;;;AAoBA,MAAa,YAAY;CACvB,iBAAiB;CACjB,yBAAyB;CACzB,sBAAsB;CACtB,gBAAgB;CAChB,gBAAgB;CAChB,0BAA0B;CAC1B,qBAAqB;CACrB,oBAAoB;CACpB,YAAY;CACZ,mBAAmB;CACnB,iBAAiB;CACjB,SAAS;CACT,kBAAkB;CAClB,kBAAkB;CAClB,eAAe;CACf,UAAU;CACV,iBAAiB;CACjB,eAAe;CACf,gBAAgB;CAChB,uBAAuB;CACvB,iBAAiB;CACjB,iBAAiB;CACjB,qBAAqB;AACvB;AAEA,MAAa,eAAe,EAAE,MAAM,OAAO;AAC3C,MAAa,gBAAgB,EAAE,MAAM,OAAO;AAC5C,MAAa,iBAAiB;CAAE,OAAO;CAAK,MAAM;AAAI;AACtD,MAAM,uBAAuB,EAAE,OAAO,QAAQ;;;;;AAS9C,SAAgB,YAAY,QAA8B;CACxD,IAAI;EAEF,MAAM,EAAE,SAAS,UAAU,gBAAgB,MAAM,QAAQ;GAAE,MAAM;GAAM,YAAY;GAAU,gBAAgB;EAAM,CAAC;EACpH,IAAI,YAAY,MAAM,eAAe,WAAW,aAAa,qBAAqB,KAAK,GAAG,OAAO,EAAE,QAAQ,sCAAsC;EACjJ,OAAO;GAAE;GAA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@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_rolldown_runtime = require("./rolldown-runtime-C3-Zg-KD.cjs");
3
- const require_package = require("./package-CHCCjtOD.cjs");
4
- const require_Telemetry = require("./Telemetry-CEZZ5IZu.cjs");
3
+ const require_package = require("./package-Dggb9xyT.cjs");
4
+ const require_Telemetry = require("./Telemetry-BYgov4z_.cjs");
5
5
  const require_mascot = require("./mascot-CC-D4ON2.cjs");
6
6
  const require_shared = require("./shared-KKRMm1xX.cjs");
7
7
  let node_util = require("node:util");
@@ -88,7 +88,7 @@ const command = (0, gunshi.defineWithTypes)()({
88
88
  async run(ctx) {
89
89
  const { values } = ctx;
90
90
  const logLevel = resolveLogLevel(values);
91
- const { run } = await Promise.resolve().then(() => require("./run-PqKD04Dm.cjs"));
91
+ const { run } = await Promise.resolve().then(() => require("./run-xcqUiR62.cjs"));
92
92
  await run({
93
93
  input: values.input,
94
94
  configPath: values.config,
@@ -134,13 +134,13 @@ function resolveDeprecatedFlags(args) {
134
134
  // src/index.ts
135
135
  /** The subcommands besides `generate`, imported only when the run needs them, so `kubb generate` never loads their code. */
136
136
  const commandLoaders = {
137
- init: () => Promise.resolve().then(() => require("./run-CGb2TsqT.cjs")),
138
- validate: () => Promise.resolve().then(() => require("./validate-CU54Odyp.cjs")),
139
- mcp: () => Promise.resolve().then(() => require("./mcp-BkXSM9Fj.cjs")),
140
- studio: () => Promise.resolve().then(() => require("./studio-B9S_cGKE.cjs")),
141
- add: () => Promise.resolve().then(() => require("./run-DCggecSY.cjs")),
142
- update: () => Promise.resolve().then(() => require("./run-DyF7mcCI.cjs")),
143
- remove: () => Promise.resolve().then(() => require("./run-DT4hTOR2.cjs")),
137
+ init: () => Promise.resolve().then(() => require("./run-Bhnfsdiy.cjs")),
138
+ validate: () => Promise.resolve().then(() => require("./validate-D_aoov0x.cjs")),
139
+ mcp: () => Promise.resolve().then(() => require("./mcp-BJN5QxDo.cjs")),
140
+ studio: () => Promise.resolve().then(() => require("./studio-DXxg-23D.cjs")),
141
+ add: () => Promise.resolve().then(() => require("./run-D-FHx4uQ.cjs")),
142
+ update: () => Promise.resolve().then(() => require("./run-CJU21pHF.cjs")),
143
+ remove: () => Promise.resolve().then(() => require("./run-BxNbFsmc.cjs")),
144
144
  list: () => Promise.resolve().then(() => require("./run-CfumUZCl.cjs"))
145
145
  };
146
146
  /** Flags that print the root help, which lists every subcommand. */
@@ -164,7 +164,7 @@ async function run(argv = process.argv.slice(2)) {
164
164
  if (Object.hasOwn(commandLoaders, name)) names = [name];
165
165
  if (!names.length && resolvedArgs.some((arg) => HELP_FLAGS.has(arg))) names = Object.keys(commandLoaders);
166
166
  const modules = Object.fromEntries(await Promise.all(names.map(async (key) => [key, await commandLoaders[key]()])));
167
- const args = name === "studio" ? (await Promise.resolve().then(() => require("./studio-B9S_cGKE.cjs"))).routeStudioFlags(resolvedArgs) : resolvedArgs;
167
+ const args = name === "studio" ? (await Promise.resolve().then(() => require("./studio-DXxg-23D.cjs"))).routeStudioFlags(resolvedArgs) : resolvedArgs;
168
168
  const isQuietFlag = args.some((arg) => QUIET_FLAGS.has(arg));
169
169
  const isJsonOutput = args.includes("--json") || args.some((arg, index) => /^--reporter=.*\bjson\b/.test(arg) || arg === "--reporter" && /\bjson\b/.test(args[index + 1] ?? ""));
170
170
  if (!require_Telemetry.isDisabled() && !isQuietFlag) console.error(`${(0, node_util.styleText)("yellow", "Notice:")} Kubb collects anonymous telemetry data to help improve the tool. No personal data or file contents are collected. \nTo disable, set ${(0, node_util.styleText)("cyan", "KUBB_DISABLE_TELEMETRY=1")}.\n`);
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import "./rolldown-runtime-xo6NMXYd.js";
2
- import { t as version } from "./package-BKe7tRfp.js";
3
- import { t as isDisabled } from "./Telemetry-B53gR0bc.js";
2
+ import { t as version } from "./package-BpdY4HQ3.js";
3
+ import { t as isDisabled } from "./Telemetry-Cp69T_s5.js";
4
4
  import { r as wantsMascot, t as getBanner } from "./mascot-CmUUHLlx.js";
5
5
  import { n as dryRunId, r as logLevelArg, t as configArg } from "./shared-DcDHRtZx.js";
6
6
  import { styleText } from "node:util";
@@ -86,7 +86,7 @@ const command = defineWithTypes()({
86
86
  async run(ctx) {
87
87
  const { values } = ctx;
88
88
  const logLevel = resolveLogLevel(values);
89
- const { run } = await import("./run-BZa2J0G_.js");
89
+ const { run } = await import("./run-C0R7L7L2.js");
90
90
  await run({
91
91
  input: values.input,
92
92
  configPath: values.config,
@@ -132,13 +132,13 @@ function resolveDeprecatedFlags(args) {
132
132
  // src/index.ts
133
133
  /** The subcommands besides `generate`, imported only when the run needs them, so `kubb generate` never loads their code. */
134
134
  const commandLoaders = {
135
- init: () => import("./run-Djq5PZCq.js"),
136
- validate: () => import("./validate-W_4MBwS4.js"),
137
- mcp: () => import("./mcp-Dq3uJ97p.js"),
138
- studio: () => import("./studio-DO_ZVow1.js"),
139
- add: () => import("./run-Cgy4_JPy.js"),
140
- update: () => import("./run-DNWkBPyg.js"),
141
- remove: () => import("./run-DHfFHNfG.js"),
135
+ init: () => import("./run-CHY2W9iA.js"),
136
+ validate: () => import("./validate-HLW1Lljc.js"),
137
+ mcp: () => import("./mcp-UEW7we9u.js"),
138
+ studio: () => import("./studio-BZ03iok0.js"),
139
+ add: () => import("./run-5u7cHD85.js"),
140
+ update: () => import("./run-BPNvgmxl.js"),
141
+ remove: () => import("./run-Dx8QpT_k.js"),
142
142
  list: () => import("./run-Ch7Uuu-u.js")
143
143
  };
144
144
  /** Flags that print the root help, which lists every subcommand. */
@@ -162,7 +162,7 @@ async function run(argv = process.argv.slice(2)) {
162
162
  if (Object.hasOwn(commandLoaders, name)) names = [name];
163
163
  if (!names.length && resolvedArgs.some((arg) => HELP_FLAGS.has(arg))) names = Object.keys(commandLoaders);
164
164
  const modules = Object.fromEntries(await Promise.all(names.map(async (key) => [key, await commandLoaders[key]()])));
165
- const args = name === "studio" ? (await import("./studio-DO_ZVow1.js")).routeStudioFlags(resolvedArgs) : resolvedArgs;
165
+ const args = name === "studio" ? (await import("./studio-BZ03iok0.js")).routeStudioFlags(resolvedArgs) : resolvedArgs;
166
166
  const isQuietFlag = args.some((arg) => QUIET_FLAGS.has(arg));
167
167
  const isJsonOutput = args.includes("--json") || args.some((arg, index) => /^--reporter=.*\bjson\b/.test(arg) || arg === "--reporter" && /\bjson\b/.test(args[index + 1] ?? ""));
168
168
  if (!isDisabled() && !isQuietFlag) console.error(`${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`);
@@ -1,5 +1,5 @@
1
1
  import "./rolldown-runtime-xo6NMXYd.js";
2
- import { s as installPackages } from "./utils-CeMUE4P0.js";
2
+ import { s as installPackages } from "./utils-f1C7RiEI.js";
3
3
  import { n as getElapsedMs, t as formatMs } from "./time-C-wU7VhC.js";
4
4
  import { n as isRichOutput } from "./env-rv-VgSGN.js";
5
5
  import { t as createSpinner } from "./spinner-DxsAllRI.js";
@@ -46,4 +46,4 @@ function createTask(title) {
46
46
  }
47
47
  export { installWithSpinner as t };
48
48
 
49
- //# sourceMappingURL=installWithSpinner-BAlTSQlE.js.map
49
+ //# sourceMappingURL=installWithSpinner-CNDzLZw-.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"installWithSpinner-BAlTSQlE.js","names":[],"sources":["../src/runners/installWithSpinner.ts"],"sourcesContent":["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"],"mappings":";;;;;;;;;AAQA,MAAM,YAAY;;;;;;AAOlB,eAAsB,mBAAmB,EACvC,UACA,OACA,gBACA,KACA,UAAU,mBAQM;CAChB,MAAM,QAAQ,QAAQ,OAAO;CAC7B,MAAM,OAAO,WAAW,cAAc,MAAM,QAAQ,eAAe,MAAM;CACzE,IAAI;EACF,MAAM,QAAQ,UAAU,gBAAgB,KAAK,KAAK,OAAO;CAC3D,SAAS,OAAO;EACd,KAAK,MAAM,gBAAgB;EAC3B,MAAM;CACR;CACA,KAAK,QAAQ,aAAa,MAAM,QAAQ,eAAe,KAAK,MAAM,SAAS,aAAa,KAAK,CAAC,GAAG;AACnG;AAMA,SAAS,WAAW,OAAqB;CACvC,IAAI,aAAa,GAAG;EAClB,MAAM,MAAM,MAAM,QAAQ;GAAE;GAAO,OAAO;EAAU,CAAC;EACrD,OAAO;GAAE,UAAU,SAAS,IAAI,QAAQ,IAAI;GAAG,QAAQ,SAAS,IAAI,MAAM,MAAM,EAAE,SAAS,MAAM,CAAC;GAAG,UAAU,SAAS,IAAI,QAAQ,IAAI;EAAE;CAC5I;CACA,MAAM,UAAU,cAAc;CAC9B,QAAQ,MAAM,KAAK;CACnB,OAAO;EAAE,eAAe,CAAC;EAAG,QAAQ,SAAS,QAAQ,MAAM,IAAI;EAAG,UAAU,SAAS,QAAQ,KAAK,IAAI;CAAE;AAC1G"}
1
+ {"version":3,"file":"installWithSpinner-CNDzLZw-.js","names":[],"sources":["../src/runners/installWithSpinner.ts"],"sourcesContent":["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"],"mappings":";;;;;;;;;AAQA,MAAM,YAAY;;;;;;AAOlB,eAAsB,mBAAmB,EACvC,UACA,OACA,gBACA,KACA,UAAU,mBAQM;CAChB,MAAM,QAAQ,QAAQ,OAAO;CAC7B,MAAM,OAAO,WAAW,cAAc,MAAM,QAAQ,eAAe,MAAM;CACzE,IAAI;EACF,MAAM,QAAQ,UAAU,gBAAgB,KAAK,KAAK,OAAO;CAC3D,SAAS,OAAO;EACd,KAAK,MAAM,gBAAgB;EAC3B,MAAM;CACR;CACA,KAAK,QAAQ,aAAa,MAAM,QAAQ,eAAe,KAAK,MAAM,SAAS,aAAa,KAAK,CAAC,GAAG;AACnG;AAMA,SAAS,WAAW,OAAqB;CACvC,IAAI,aAAa,GAAG;EAClB,MAAM,MAAM,MAAM,QAAQ;GAAE;GAAO,OAAO;EAAU,CAAC;EACrD,OAAO;GAAE,UAAU,SAAS,IAAI,QAAQ,IAAI;GAAG,QAAQ,SAAS,IAAI,MAAM,MAAM,EAAE,SAAS,MAAM,CAAC;GAAG,UAAU,SAAS,IAAI,QAAQ,IAAI;EAAE;CAC5I;CACA,MAAM,UAAU,cAAc;CAC9B,QAAQ,MAAM,KAAK;CACnB,OAAO;EAAE,eAAe,CAAC;EAAG,QAAQ,SAAS,QAAQ,MAAM,IAAI;EAAG,UAAU,SAAS,QAAQ,KAAK,IAAI;CAAE;AAC1G"}
@@ -1,5 +1,5 @@
1
1
  const require_rolldown_runtime = require("./rolldown-runtime-C3-Zg-KD.cjs");
2
- const require_utils = require("./utils-uSJAZuvP.cjs");
2
+ const require_utils = require("./utils-DeXBGzGJ.cjs");
3
3
  const require_time = require("./time-3BKoci3G.cjs");
4
4
  const require_spinner = require("./spinner-RfMb7fd6.cjs");
5
5
  const require_env = require("./env-eu3XyKqJ.cjs");
@@ -53,4 +53,4 @@ Object.defineProperty(exports, "installWithSpinner", {
53
53
  }
54
54
  });
55
55
 
56
- //# sourceMappingURL=installWithSpinner-X9J7yxiR.cjs.map
56
+ //# sourceMappingURL=installWithSpinner-CnE4dIza.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"installWithSpinner-X9J7yxiR.cjs","names":["installPackages","process","formatMs","getElapsedMs","isRichOutput","clack","createSpinner"],"sources":["../src/runners/installWithSpinner.ts"],"sourcesContent":["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"],"mappings":";;;;;;;;;;;AAQA,MAAM,YAAY;;;;;;AAOlB,eAAsB,mBAAmB,EACvC,UACA,OACA,gBACA,KACA,UAAUA,cAAAA,mBAQM;CAChB,MAAM,QAAQC,aAAAA,QAAQ,OAAO;CAC7B,MAAM,OAAO,WAAW,cAAc,MAAM,QAAQ,eAAe,MAAM;CACzE,IAAI;EACF,MAAM,QAAQ,UAAU,gBAAgB,KAAK,KAAK,OAAO;CAC3D,SAAS,OAAO;EACd,KAAK,MAAM,gBAAgB;EAC3B,MAAM;CACR;CACA,KAAK,QAAQ,aAAa,MAAM,QAAQ,eAAe,KAAK,MAAMC,aAAAA,SAASC,aAAAA,aAAa,KAAK,CAAC,GAAG;AACnG;AAMA,SAAS,WAAW,OAAqB;CACvC,IAAIC,YAAAA,aAAa,GAAG;EAClB,MAAM,MAAMC,eAAM,QAAQ;GAAE;GAAO,OAAO;EAAU,CAAC;EACrD,OAAO;GAAE,UAAU,SAAS,IAAI,QAAQ,IAAI;GAAG,QAAQ,SAAS,IAAI,MAAM,MAAM,EAAE,SAAS,MAAM,CAAC;GAAG,UAAU,SAAS,IAAI,QAAQ,IAAI;EAAE;CAC5I;CACA,MAAM,UAAUC,gBAAAA,cAAc;CAC9B,QAAQ,MAAM,KAAK;CACnB,OAAO;EAAE,eAAe,CAAC;EAAG,QAAQ,SAAS,QAAQ,MAAM,IAAI;EAAG,UAAU,SAAS,QAAQ,KAAK,IAAI;CAAE;AAC1G"}
1
+ {"version":3,"file":"installWithSpinner-CnE4dIza.cjs","names":["installPackages","process","formatMs","getElapsedMs","isRichOutput","clack","createSpinner"],"sources":["../src/runners/installWithSpinner.ts"],"sourcesContent":["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"],"mappings":";;;;;;;;;;;AAQA,MAAM,YAAY;;;;;;AAOlB,eAAsB,mBAAmB,EACvC,UACA,OACA,gBACA,KACA,UAAUA,cAAAA,mBAQM;CAChB,MAAM,QAAQC,aAAAA,QAAQ,OAAO;CAC7B,MAAM,OAAO,WAAW,cAAc,MAAM,QAAQ,eAAe,MAAM;CACzE,IAAI;EACF,MAAM,QAAQ,UAAU,gBAAgB,KAAK,KAAK,OAAO;CAC3D,SAAS,OAAO;EACd,KAAK,MAAM,gBAAgB;EAC3B,MAAM;CACR;CACA,KAAK,QAAQ,aAAa,MAAM,QAAQ,eAAe,KAAK,MAAMC,aAAAA,SAASC,aAAAA,aAAa,KAAK,CAAC,GAAG;AACnG;AAMA,SAAS,WAAW,OAAqB;CACvC,IAAIC,YAAAA,aAAa,GAAG;EAClB,MAAM,MAAMC,eAAM,QAAQ;GAAE;GAAO,OAAO;EAAU,CAAC;EACrD,OAAO;GAAE,UAAU,SAAS,IAAI,QAAQ,IAAI;GAAG,QAAQ,SAAS,IAAI,MAAM,MAAM,EAAE,SAAS,MAAM,CAAC;GAAG,UAAU,SAAS,IAAI,QAAQ,IAAI;EAAE;CAC5I;CACA,MAAM,UAAUC,gBAAAA,cAAc;CAC9B,QAAQ,MAAM,KAAK;CACnB,OAAO;EAAE,eAAe,CAAC;EAAG,QAAQ,SAAS,QAAQ,MAAM,IAAI;EAAG,UAAU,SAAS,QAAQ,KAAK,IAAI;CAAE;AAC1G"}
@@ -11,10 +11,10 @@ const command = (0, require("gunshi").define)({
11
11
  ].join("\n"),
12
12
  rendering: { header: null },
13
13
  async run() {
14
- const { run } = await Promise.resolve().then(() => require("./run-Nh2f1Sw4.cjs"));
14
+ const { run } = await Promise.resolve().then(() => require("./run-DMFf2RZD.cjs"));
15
15
  await run();
16
16
  }
17
17
  });
18
18
  exports.command = command;
19
19
 
20
- //# sourceMappingURL=mcp-BkXSM9Fj.cjs.map
20
+ //# sourceMappingURL=mcp-BJN5QxDo.cjs.map