@kubb/cli 5.0.0-beta.54 → 5.0.0-beta.55

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 (74) hide show
  1. package/README.md +0 -1
  2. package/dist/{Telemetry-DC5WVMB9.cjs → Telemetry-BuDSora3.cjs} +83 -112
  3. package/dist/Telemetry-BuDSora3.cjs.map +1 -0
  4. package/dist/{Telemetry-BZH4YIxq.js → Telemetry-C66uYyC2.js} +82 -111
  5. package/dist/Telemetry-C66uYyC2.js.map +1 -0
  6. package/dist/define-C4AB3POr.cjs.map +1 -1
  7. package/dist/define-C63T4jp6.js.map +1 -1
  8. package/dist/{generate-CSu0xUcm.js → generate-CByoI4cQ.js} +3 -9
  9. package/dist/generate-CByoI4cQ.js.map +1 -0
  10. package/dist/{generate-BRt2AlAO.cjs → generate-Dg9jZ8xa.cjs} +3 -9
  11. package/dist/generate-Dg9jZ8xa.cjs.map +1 -0
  12. package/dist/index.cjs +8 -22
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.js +8 -22
  15. package/dist/index.js.map +1 -1
  16. package/dist/{init-CnVtpZfe.js → init-C7KqFbJT.js} +3 -3
  17. package/dist/{init-CnVtpZfe.js.map → init-C7KqFbJT.js.map} +1 -1
  18. package/dist/{init-YMqAAWFE.cjs → init-Cptp_SSW.cjs} +3 -3
  19. package/dist/{init-YMqAAWFE.cjs.map → init-Cptp_SSW.cjs.map} +1 -1
  20. package/dist/{mcp-B2wwhU2v.cjs → mcp-CM19f7rG.cjs} +3 -3
  21. package/dist/{mcp-B2wwhU2v.cjs.map → mcp-CM19f7rG.cjs.map} +1 -1
  22. package/dist/{mcp-CnP9ZVBz.js → mcp-ClbeosGy.js} +3 -3
  23. package/dist/{mcp-CnP9ZVBz.js.map → mcp-ClbeosGy.js.map} +1 -1
  24. package/dist/{package-C8wmoP1B.cjs → package-dLlE0LgE.cjs} +2 -2
  25. package/dist/package-dLlE0LgE.cjs.map +1 -0
  26. package/dist/package-scFCPMiP.js +6 -0
  27. package/dist/package-scFCPMiP.js.map +1 -0
  28. package/dist/{run-C-omuksC.js → run-BG7Giryi.js} +36 -99
  29. package/dist/run-BG7Giryi.js.map +1 -0
  30. package/dist/{run-DMWGLJUx.cjs → run-Bj64iPU_.cjs} +2 -2
  31. package/dist/{run-DMWGLJUx.cjs.map → run-Bj64iPU_.cjs.map} +1 -1
  32. package/dist/{run-4WGNek3a.cjs → run-BoR5nxtV.cjs} +86 -168
  33. package/dist/run-BoR5nxtV.cjs.map +1 -0
  34. package/dist/{run-C7cr0qhi.js → run-CUkZ6gnP.js} +2 -2
  35. package/dist/{run-C7cr0qhi.js.map → run-CUkZ6gnP.js.map} +1 -1
  36. package/dist/{run-Cou32en2.js → run-CY0htF8O.js} +83 -165
  37. package/dist/run-CY0htF8O.js.map +1 -0
  38. package/dist/{run-DGMgkbD3.cjs → run-DCXY-eRK.cjs} +2 -2
  39. package/dist/{run-DGMgkbD3.cjs.map → run-DCXY-eRK.cjs.map} +1 -1
  40. package/dist/{run-BtjzfTz3.cjs → run-DpKny2hT.cjs} +30 -93
  41. package/dist/run-DpKny2hT.cjs.map +1 -0
  42. package/dist/{run-DLVIbuN0.js → run-OWQyNzZx.js} +2 -2
  43. package/dist/{run-DLVIbuN0.js.map → run-OWQyNzZx.js.map} +1 -1
  44. package/dist/tools-BU99bhi8.js +152 -0
  45. package/dist/tools-BU99bhi8.js.map +1 -0
  46. package/dist/tools-_Xp8-_zy.cjs +175 -0
  47. package/dist/tools-_Xp8-_zy.cjs.map +1 -0
  48. package/dist/{validate-BlNh3LLm.js → validate-BtKwM4zb.js} +3 -3
  49. package/dist/{validate-BlNh3LLm.js.map → validate-BtKwM4zb.js.map} +1 -1
  50. package/dist/{validate-Bqf5fxQp.cjs → validate-Cj5IIh1M.cjs} +3 -3
  51. package/dist/{validate-Bqf5fxQp.cjs.map → validate-Cj5IIh1M.cjs.map} +1 -1
  52. package/package.json +5 -5
  53. package/src/Telemetry.ts +20 -22
  54. package/src/commands/generate.ts +0 -6
  55. package/src/constants.ts +1 -1
  56. package/src/index.ts +4 -21
  57. package/src/runners/generate/run.ts +12 -16
  58. package/src/runners/generate/utils.ts +18 -19
  59. package/src/runners/init/utils.ts +9 -3
  60. package/dist/Telemetry-BZH4YIxq.js.map +0 -1
  61. package/dist/Telemetry-DC5WVMB9.cjs.map +0 -1
  62. package/dist/generate-BRt2AlAO.cjs.map +0 -1
  63. package/dist/generate-CSu0xUcm.js.map +0 -1
  64. package/dist/package-C8wmoP1B.cjs.map +0 -1
  65. package/dist/package-CNNBB6JV.js +0 -6
  66. package/dist/package-CNNBB6JV.js.map +0 -1
  67. package/dist/run-4WGNek3a.cjs.map +0 -1
  68. package/dist/run-BtjzfTz3.cjs.map +0 -1
  69. package/dist/run-C-omuksC.js.map +0 -1
  70. package/dist/run-Cou32en2.js.map +0 -1
  71. package/dist/shell-DsgkfUSW.js +0 -51
  72. package/dist/shell-DsgkfUSW.js.map +0 -1
  73. package/dist/shell-Lh-vLWwH.cjs +0 -62
  74. package/dist/shell-Lh-vLWwH.cjs.map +0 -1
@@ -1,66 +1,11 @@
1
1
  import "./chunk-C0LytTxp.js";
2
- import { t as spawnAsync } from "./shell-DsgkfUSW.js";
2
+ import { t as detectPackageManager } from "./tools-BU99bhi8.js";
3
3
  import { styleText } from "node:util";
4
- import fs, { existsSync, readFileSync } from "node:fs";
5
- import path, { join } from "node:path";
6
- import process$1 from "node:process";
4
+ import fs from "node:fs";
5
+ import path from "node:path";
6
+ import process from "node:process";
7
7
  import * as clack from "@clack/prompts";
8
- //#region ../../internals/utils/src/packageManager.ts
9
- /**
10
- * Metadata for each supported package manager, keyed by its short name.
11
- *
12
- * @example
13
- * ```ts
14
- * packageManagers.pnpm.installCommand // ['add', '-D']
15
- * packageManagers.npm.lockFile // 'package-lock.json'
16
- * ```
17
- */
18
- const packageManagers = {
19
- pnpm: {
20
- name: "pnpm",
21
- lockFile: "pnpm-lock.yaml",
22
- installCommand: ["add", "-D"]
23
- },
24
- yarn: {
25
- name: "yarn",
26
- lockFile: "yarn.lock",
27
- installCommand: ["add", "-D"]
28
- },
29
- bun: {
30
- name: "bun",
31
- lockFile: "bun.lockb",
32
- installCommand: ["add", "-d"]
33
- },
34
- npm: {
35
- name: "npm",
36
- lockFile: "package-lock.json",
37
- installCommand: ["install", "--save-dev"]
38
- }
39
- };
40
- /**
41
- * Detects the active package manager for the given directory.
42
- * Resolution order: `packageManager` field in `package.json`, then presence of a lock file.
43
- * Falls back to `npm` when no signal is found.
44
- *
45
- * @example
46
- * ```ts
47
- * detectPackageManager('/my/project') // { name: 'pnpm', lockFile: 'pnpm-lock.yaml', ... }
48
- * detectPackageManager() // falls back to npm when no lock file is found
49
- * ```
50
- */
51
- function detectPackageManager(cwd = process.cwd()) {
52
- const packageJsonPath = join(cwd, "package.json");
53
- if (existsSync(packageJsonPath)) try {
54
- const pmField = JSON.parse(readFileSync(packageJsonPath, "utf-8")).packageManager;
55
- if (typeof pmField === "string") {
56
- const name = pmField.split("@")[0];
57
- if (name && name in packageManagers) return packageManagers[name];
58
- }
59
- } catch {}
60
- for (const pm of Object.values(packageManagers)) if (existsSync(join(cwd, pm.lockFile))) return pm;
61
- return packageManagers.npm;
62
- }
63
- //#endregion
8
+ import { x } from "tinyexec";
64
9
  //#region ../../internals/shared/src/constants.ts
65
10
  const KUBB_CONFIG_FILENAME = "kubb.config.ts";
66
11
  const initDefaults = {
@@ -142,36 +87,16 @@ const availablePlugins = [
142
87
  }
143
88
  ];
144
89
  const pluginDefaultConfigs = {
145
- "plugin-ts": `pluginTs({
146
- output: { path: 'models' },
147
- })`,
148
- "plugin-client": `pluginClient({
149
- output: { path: 'clients' },
150
- })`,
151
- "plugin-react-query": `pluginReactQuery({
152
- output: { path: 'hooks' },
153
- })`,
154
- "plugin-vue-query": `pluginVueQuery({
155
- output: { path: 'hooks' },
156
- })`,
157
- "plugin-zod": `pluginZod({
158
- output: { path: 'zod' },
159
- })`,
160
- "plugin-faker": `pluginFaker({
161
- output: { path: 'mocks' },
162
- })`,
163
- "plugin-msw": `pluginMsw({
164
- output: { path: 'msw' },
165
- })`,
166
- "plugin-cypress": `pluginCypress({
167
- output: { path: 'cypress' },
168
- })`,
169
- "plugin-mcp": `pluginMcp({
170
- output: { path: 'mcp' },
171
- })`,
172
- "plugin-redoc": `pluginRedoc({
173
- output: { path: 'redoc' },
174
- })`
90
+ "plugin-ts": `pluginTs()`,
91
+ "plugin-client": `pluginClient()`,
92
+ "plugin-react-query": `pluginReactQuery()`,
93
+ "plugin-vue-query": `pluginVueQuery()`,
94
+ "plugin-zod": `pluginZod()`,
95
+ "plugin-faker": `pluginFaker()`,
96
+ "plugin-msw": `pluginMsw()`,
97
+ "plugin-cypress": `pluginCypress()`,
98
+ "plugin-mcp": `pluginMcp()`,
99
+ "plugin-redoc": `pluginRedoc()`
175
100
  };
176
101
  //#endregion
177
102
  //#region ../../internals/shared/src/init.ts
@@ -201,31 +126,43 @@ ${selectedPlugins.map((plugin) => {
201
126
  /**
202
127
  * Returns `true` when a `package.json` exists at `cwd`.
203
128
  */
204
- function hasPackageJson(cwd = process$1.cwd()) {
129
+ function hasPackageJson(cwd = process.cwd()) {
205
130
  return fs.existsSync(path.join(cwd, "package.json"));
206
131
  }
207
132
  /**
208
133
  * Initializes a new `package.json` at `cwd` using the detected package manager.
209
134
  */
210
135
  async function initPackageJson(cwd, packageManager) {
211
- await spawnAsync(packageManager.name, {
136
+ await x(packageManager.name, {
212
137
  npm: ["init", "-y"],
213
138
  pnpm: ["init"],
214
139
  yarn: ["init", "-y"],
215
140
  bun: ["init", "-y"]
216
- }[packageManager.name], { cwd });
141
+ }[packageManager.name], {
142
+ nodeOptions: {
143
+ cwd,
144
+ stdio: "inherit"
145
+ },
146
+ throwOnError: true
147
+ });
217
148
  }
218
149
  /**
219
150
  * Installs the given packages at `cwd` using the detected package manager.
220
151
  */
221
- async function installPackages(packages, packageManager, cwd = process$1.cwd()) {
222
- await spawnAsync(packageManager.name, [...packageManager.installCommand, ...packages], { cwd });
152
+ async function installPackages(packages, packageManager, cwd = process.cwd()) {
153
+ await x(packageManager.name, [...packageManager.installCommand, ...packages], {
154
+ nodeOptions: {
155
+ cwd,
156
+ stdio: "inherit"
157
+ },
158
+ throwOnError: true
159
+ });
223
160
  }
224
161
  //#endregion
225
162
  //#region src/runners/init/run.ts
226
163
  function cancelAndExit(message = "Operation canceled.") {
227
164
  clack.cancel(message);
228
- process$1.exit(0);
165
+ process.exit(0);
229
166
  }
230
167
  /**
231
168
  * Runs the interactive Kubb scaffolding wizard.
@@ -233,7 +170,7 @@ function cancelAndExit(message = "Operation canceled.") {
233
170
  * Pass `yes: true` to skip all prompts and use defaults.
234
171
  */
235
172
  async function run({ yes, version, input: inputFlag, output: outputFlag, plugins: pluginsFlag }) {
236
- const cwd = process$1.cwd();
173
+ const cwd = process.cwd();
237
174
  clack.intro(styleText("bgCyan", styleText("black", " Kubb Init ")));
238
175
  /**
239
176
  * Returns `flag` when provided, the `defaultValue` when `yes` is set,
@@ -350,10 +287,10 @@ async function run({ yes, version, input: inputFlag, output: outputFlag, plugins
350
287
  } catch (error) {
351
288
  clack.log.error(styleText("red", "An error occurred during initialization"));
352
289
  if (error instanceof Error) clack.log.error(error.message);
353
- process$1.exit(1);
290
+ process.exit(1);
354
291
  }
355
292
  }
356
293
  //#endregion
357
294
  export { run };
358
295
 
359
- //# sourceMappingURL=run-C-omuksC.js.map
296
+ //# sourceMappingURL=run-BG7Giryi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-BG7Giryi.js","names":[],"sources":["../../../internals/shared/src/constants.ts","../../../internals/shared/src/init.ts","../src/runners/init/utils.ts","../src/runners/init/run.ts"],"sourcesContent":["import type { PluginOption } from './types.ts'\n\nexport const KUBB_CONFIG_FILENAME = 'kubb.config.ts' as const\n\nexport const initDefaults = {\n inputPath: './openapi.yaml',\n outputPath: './src/gen',\n plugins: ['plugin-ts'],\n} as const\n\nexport const availablePlugins: Array<PluginOption> = [\n {\n value: 'plugin-ts',\n label: 'TypeScript',\n hint: 'Recommended',\n packageName: '@kubb/plugin-ts',\n importName: 'pluginTs',\n category: 'types',\n },\n {\n value: 'plugin-client',\n label: 'Client (Fetch/Axios)',\n packageName: '@kubb/plugin-client',\n importName: 'pluginClient',\n category: 'client',\n },\n {\n value: 'plugin-react-query',\n label: 'React Query / TanStack Query',\n packageName: '@kubb/plugin-react-query',\n importName: 'pluginReactQuery',\n category: 'framework',\n },\n {\n value: 'plugin-vue-query',\n label: 'Vue Query',\n packageName: '@kubb/plugin-vue-query',\n importName: 'pluginVueQuery',\n category: 'framework',\n },\n {\n value: 'plugin-zod',\n label: 'Zod Schemas',\n packageName: '@kubb/plugin-zod',\n importName: 'pluginZod',\n category: 'validation',\n },\n {\n value: 'plugin-faker',\n label: 'Faker.js Mocks',\n packageName: '@kubb/plugin-faker',\n importName: 'pluginFaker',\n category: 'mocks',\n },\n {\n value: 'plugin-msw',\n label: 'MSW Handlers',\n packageName: '@kubb/plugin-msw',\n importName: 'pluginMsw',\n category: 'mocks',\n },\n {\n value: 'plugin-cypress',\n label: 'Cypress Tests',\n packageName: '@kubb/plugin-cypress',\n importName: 'pluginCypress',\n category: 'testing',\n },\n {\n value: 'plugin-mcp',\n label: 'MCP Server (AI / Model Context Protocol)',\n packageName: '@kubb/plugin-mcp',\n importName: 'pluginMcp',\n category: 'ai',\n },\n {\n value: 'plugin-redoc',\n label: 'ReDoc Documentation',\n packageName: '@kubb/plugin-redoc',\n importName: 'pluginRedoc',\n category: 'documentation',\n },\n]\n\nexport const pluginDefaultConfigs = {\n 'plugin-ts': `pluginTs()`,\n 'plugin-client': `pluginClient()`,\n 'plugin-react-query': `pluginReactQuery()`,\n 'plugin-vue-query': `pluginVueQuery()`,\n 'plugin-zod': `pluginZod()`,\n 'plugin-faker': `pluginFaker()`,\n 'plugin-msw': `pluginMsw()`,\n 'plugin-cypress': `pluginCypress()`,\n 'plugin-mcp': `pluginMcp()`,\n 'plugin-redoc': `pluginRedoc()`,\n} as const satisfies Record<string, string>\n","import { pluginDefaultConfigs } from './constants.ts'\nimport type { PluginOption } from './types.ts'\n\nexport function generateConfigFile({\n selectedPlugins,\n inputPath,\n outputPath,\n}: {\n selectedPlugins: Array<PluginOption>\n inputPath: string\n outputPath: string\n}): string {\n const imports = selectedPlugins.map((plugin) => `import { ${plugin.importName} } from '${plugin.packageName}'`).join('\\n')\n\n const pluginConfigs = selectedPlugins\n .map((plugin) => {\n const config = (pluginDefaultConfigs as Record<string, string>)[plugin.value] ?? `${plugin.importName}()`\n return ` ${config},`\n })\n .join('\\n')\n\n return `import { defineConfig } from 'kubb'\n${imports}\n\nexport default defineConfig({\n root: '.',\n input: {\n path: '${inputPath}',\n },\n output: {\n path: '${outputPath}',\n clean: true,\n },\n plugins: [\n${pluginConfigs}\n ],\n})\n`\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\nimport process from 'node:process'\nimport type { PackageManagerInfo, PackageManagerName } from '@internals/utils'\nimport { x } from 'tinyexec'\n\n/**\n * Returns `true` when a `package.json` exists at `cwd`.\n */\nexport function hasPackageJson(cwd: string = process.cwd()): boolean {\n return fs.existsSync(path.join(cwd, 'package.json'))\n}\n\n/**\n * Initializes a new `package.json` at `cwd` using the detected package manager.\n */\nexport async function initPackageJson(cwd: string, packageManager: PackageManagerInfo): Promise<void> {\n const commands: Record<PackageManagerName, Array<string>> = {\n npm: ['init', '-y'],\n pnpm: ['init'],\n yarn: ['init', '-y'],\n bun: ['init', '-y'],\n }\n\n await x(packageManager.name, commands[packageManager.name], {\n nodeOptions: { cwd, stdio: 'inherit' },\n throwOnError: true,\n })\n}\n\n/**\n * Installs the given packages at `cwd` using the detected package manager.\n */\nexport async function installPackages(packages: Array<string>, packageManager: PackageManagerInfo, cwd: string = process.cwd()): Promise<void> {\n await x(packageManager.name, [...packageManager.installCommand, ...packages], {\n nodeOptions: { cwd, stdio: 'inherit' },\n throwOnError: true,\n })\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\nimport process from 'node:process'\nimport { styleText } from 'node:util'\nimport * as clack from '@clack/prompts'\nimport { detectPackageManager } from '@internals/utils'\nimport { availablePlugins, generateConfigFile, initDefaults, KUBB_CONFIG_FILENAME, type PluginOption } from '@internals/shared'\nimport { hasPackageJson, initPackageJson, installPackages } from './utils.ts'\n\nfunction cancelAndExit(message = 'Operation canceled.'): never {\n clack.cancel(message)\n process.exit(0)\n}\n\ntype InitOptions = {\n /**\n * When `true`, skips all interactive prompts and uses default values.\n */\n yes: boolean\n /**\n * Current `@kubb/cli` version string, shown in the outro and used for package installation.\n */\n version: string\n /**\n * Input path flag value from `--input`. When provided, skips the input prompt.\n */\n input?: string\n /**\n * Output directory flag value from `--output`. When provided, skips the output prompt.\n */\n output?: string\n /**\n * Comma-separated plugin list from `--plugins`, e.g. `'plugin-ts,plugin-zod'`. When provided, skips the plugin selection prompt.\n */\n plugins?: string\n}\n\n/**\n * Runs the interactive Kubb scaffolding wizard.\n * Detects the package manager, prompts for input/output paths and plugins, installs packages, and writes `kubb.config.ts`.\n * Pass `yes: true` to skip all prompts and use defaults.\n */\nexport async function run({ yes, version, input: inputFlag, output: outputFlag, plugins: pluginsFlag }: InitOptions): Promise<void> {\n const cwd = process.cwd()\n\n clack.intro(styleText('bgCyan', styleText('black', ' Kubb Init ')))\n\n /**\n * Returns `flag` when provided, the `defaultValue` when `yes` is set,\n * or calls `prompt()` for interactive input. Exits on cancellation.\n */\n async function resolveOrPrompt<T>(flag: T | undefined, defaultValue: T, logLabel: string, prompt: () => Promise<T | symbol>): Promise<T> {\n if (flag !== undefined) {\n clack.log.info(`${logLabel}: ${styleText('cyan', String(flag))}`)\n return flag\n }\n if (yes) {\n clack.log.info(`${logLabel}: ${styleText('cyan', String(defaultValue))}`)\n return defaultValue\n }\n const result = await prompt()\n if (clack.isCancel(result)) cancelAndExit()\n return result as T\n }\n\n try {\n // Check/create package.json, detect package manager once after the block\n if (!hasPackageJson(cwd)) {\n if (!yes) {\n const shouldInit = await clack.confirm({\n message: 'No package.json found. Would you like to create one?',\n initialValue: true,\n })\n\n if (clack.isCancel(shouldInit) || !shouldInit) {\n cancelAndExit()\n }\n }\n\n const packageManager = detectPackageManager(cwd)\n const spinner = clack.spinner()\n spinner.start(`Initializing package.json with ${packageManager.name}`)\n await initPackageJson(cwd, packageManager)\n spinner.stop(`Created package.json with ${packageManager.name}`)\n }\n\n const packageManager = detectPackageManager(cwd)\n if (hasPackageJson(cwd)) {\n clack.log.info(`Detected package manager: ${styleText('cyan', packageManager.name)}`)\n }\n\n // Prompt for OpenAPI spec path\n const inputPath = await resolveOrPrompt(inputFlag, initDefaults.inputPath, 'Using input path', () =>\n clack.text({\n message: 'Where is your OpenAPI specification located?',\n placeholder: initDefaults.inputPath,\n defaultValue: initDefaults.inputPath,\n validate: (value) => {\n if (!value) return 'Input path is required'\n },\n }),\n )\n\n // Prompt for output directory\n const outputPath = await resolveOrPrompt(outputFlag, initDefaults.outputPath, 'Using output path', () =>\n clack.text({\n message: 'Where should the generated files be output?',\n placeholder: initDefaults.outputPath,\n defaultValue: initDefaults.outputPath,\n validate: (value) => {\n if (!value) return 'Output path is required'\n },\n }),\n )\n\n // Plugin selection\n const defaultPlugins = availablePlugins.filter((p) => (initDefaults.plugins as ReadonlyArray<string>).includes(p.value))\n const pluginLabel = (plugins: Array<PluginOption>) => styleText('cyan', plugins.map((p) => p.label).join(', '))\n\n const selectedPlugins: Array<PluginOption> = await (async () => {\n if (pluginsFlag) {\n const requested = pluginsFlag\n .split(',')\n .map((v) => v.trim())\n .filter(Boolean)\n const plugins = availablePlugins.filter((p) => requested.includes(p.value))\n if (plugins.length === 0) {\n clack.log.warn(`No valid plugins found in --plugins value; falling back to default: ${pluginLabel(defaultPlugins)}`)\n return defaultPlugins\n }\n clack.log.info(`Using plugins: ${pluginLabel(plugins)}`)\n return plugins\n }\n if (yes) {\n clack.log.info(`Using plugins: ${pluginLabel(defaultPlugins)}`)\n return defaultPlugins\n }\n const values = await clack.multiselect({\n message: 'Select plugins to use:',\n options: availablePlugins.map(({ value, label, hint }) => ({ value, label, hint })),\n initialValues: [...initDefaults.plugins],\n required: true,\n })\n if (clack.isCancel(values)) cancelAndExit()\n return availablePlugins.filter((p) => (values as Array<string>).includes(p.value))\n })()\n\n // Install packages\n const packagesToInstall = ['kubb', ...selectedPlugins.map((p) => p.packageName)]\n\n const spinner = clack.spinner()\n spinner.start(`Installing ${packagesToInstall.length} packages with ${packageManager.name}`)\n\n try {\n await installPackages(packagesToInstall, packageManager, cwd)\n spinner.stop(`Installed ${packagesToInstall.length} packages`)\n } catch (error) {\n spinner.stop('Installation failed')\n throw error\n }\n\n // Generate config file\n const configSpinner = clack.spinner()\n configSpinner.start(`Creating ${KUBB_CONFIG_FILENAME}`)\n\n const configContent = generateConfigFile({ selectedPlugins, inputPath, outputPath })\n const configPath = path.join(cwd, KUBB_CONFIG_FILENAME)\n\n if (fs.existsSync(configPath)) {\n configSpinner.stop(`${KUBB_CONFIG_FILENAME} already exists`)\n\n if (!yes) {\n const shouldOverwrite = await clack.confirm({\n message: `${KUBB_CONFIG_FILENAME} already exists. Overwrite?`,\n initialValue: false,\n })\n\n if (clack.isCancel(shouldOverwrite) || !shouldOverwrite) {\n cancelAndExit('Keeping existing configuration. Packages have been installed.')\n }\n }\n\n configSpinner.start(`Overwriting ${KUBB_CONFIG_FILENAME}`)\n }\n\n await fs.promises.writeFile(configPath, configContent, 'utf-8')\n\n configSpinner.stop(`Created ${KUBB_CONFIG_FILENAME}`)\n\n clack.outro(\n styleText('green', '✓ All set!') +\n '\\n\\n' +\n styleText('dim', 'Next steps:') +\n '\\n' +\n styleText('cyan', ` 1. Make sure your OpenAPI spec is at: ${inputPath}`) +\n '\\n' +\n styleText('cyan', ' 2. Generate code with: npx kubb generate') +\n '\\n' +\n styleText('cyan', ` 3. Find generated files in: ${outputPath}`) +\n '\\n\\n' +\n styleText('dim', `Using ${packageManager.name} • Kubb v${version}`),\n )\n } catch (error) {\n clack.log.error(styleText('red', 'An error occurred during initialization'))\n if (error instanceof Error) {\n clack.log.error(error.message)\n }\n process.exit(1)\n }\n}\n"],"mappings":";;;;;;;;;AAEA,MAAa,uBAAuB;AAEpC,MAAa,eAAe;CAC1B,WAAW;CACX,YAAY;CACZ,SAAS,CAAC,WAAW;AACvB;AAEA,MAAa,mBAAwC;CACnD;EACE,OAAO;EACP,OAAO;EACP,MAAM;EACN,aAAa;EACb,YAAY;EACZ,UAAU;CACZ;CACA;EACE,OAAO;EACP,OAAO;EACP,aAAa;EACb,YAAY;EACZ,UAAU;CACZ;CACA;EACE,OAAO;EACP,OAAO;EACP,aAAa;EACb,YAAY;EACZ,UAAU;CACZ;CACA;EACE,OAAO;EACP,OAAO;EACP,aAAa;EACb,YAAY;EACZ,UAAU;CACZ;CACA;EACE,OAAO;EACP,OAAO;EACP,aAAa;EACb,YAAY;EACZ,UAAU;CACZ;CACA;EACE,OAAO;EACP,OAAO;EACP,aAAa;EACb,YAAY;EACZ,UAAU;CACZ;CACA;EACE,OAAO;EACP,OAAO;EACP,aAAa;EACb,YAAY;EACZ,UAAU;CACZ;CACA;EACE,OAAO;EACP,OAAO;EACP,aAAa;EACb,YAAY;EACZ,UAAU;CACZ;CACA;EACE,OAAO;EACP,OAAO;EACP,aAAa;EACb,YAAY;EACZ,UAAU;CACZ;CACA;EACE,OAAO;EACP,OAAO;EACP,aAAa;EACb,YAAY;EACZ,UAAU;CACZ;AACF;AAEA,MAAa,uBAAuB;CAClC,aAAa;CACb,iBAAiB;CACjB,sBAAsB;CACtB,oBAAoB;CACpB,cAAc;CACd,gBAAgB;CAChB,cAAc;CACd,kBAAkB;CAClB,cAAc;CACd,gBAAgB;AAClB;;;AC5FA,SAAgB,mBAAmB,EACjC,iBACA,WACA,cAKS;CAUT,OAAO;EATS,gBAAgB,KAAK,WAAW,YAAY,OAAO,WAAW,WAAW,OAAO,YAAY,EAAE,CAAC,CAAC,KAAK,IAU/G,EAAE;;;;;aAKG,UAAU;;;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AE;GAAiB;GAAW;EAAW,CAAC;EACnF,MAAM,aAAa,KAAK,KAAK,KAAK,oBAAoB;EAEtD,IAAI,GAAG,WAAW,UAAU,GAAG;GAC7B,cAAc,KAAK,GAAG,qBAAqB,gBAAgB;GAE3D,IAAI,CAAC,KAAK;IACR,MAAM,kBAAkB,MAAM,MAAM,QAAQ;KAC1C,SAAS,GAAG,qBAAqB;KACjC,cAAc;IAChB,CAAC;IAED,IAAI,MAAM,SAAS,eAAe,KAAK,CAAC,iBACtC,cAAc,+DAA+D;GAEjF;GAEA,cAAc,MAAM,eAAe,sBAAsB;EAC3D;EAEA,MAAM,GAAG,SAAS,UAAU,YAAY,eAAe,OAAO;EAE9D,cAAc,KAAK,WAAW,sBAAsB;EAEpD,MAAM,MACJ,UAAU,SAAS,YAAY,IAC7B,SACA,UAAU,OAAO,aAAa,IAC9B,OACA,UAAU,QAAQ,2CAA2C,WAAW,IACxE,OACA,UAAU,QAAQ,4CAA4C,IAC9D,OACA,UAAU,QAAQ,iCAAiC,YAAY,IAC/D,SACA,UAAU,OAAO,SAAS,eAAe,KAAK,WAAW,SAAS,CACtE;CACF,SAAS,OAAO;EACd,MAAM,IAAI,MAAM,UAAU,OAAO,yCAAyC,CAAC;EAC3E,IAAI,iBAAiB,OACnB,MAAM,IAAI,MAAM,MAAM,OAAO;EAE/B,QAAQ,KAAK,CAAC;CAChB;AACF"}
@@ -1,6 +1,6 @@
1
1
  const require_chunk = require("./chunk-Bx3C2hgW.cjs");
2
2
  const require_errors = require("./errors-DykI11xo.cjs");
3
- const require_Telemetry = require("./Telemetry-DC5WVMB9.cjs");
3
+ const require_Telemetry = require("./Telemetry-BuDSora3.cjs");
4
4
  let node_util = require("node:util");
5
5
  let node_process = require("node:process");
6
6
  node_process = require_chunk.__toESM(node_process, 1);
@@ -49,4 +49,4 @@ async function run({ input, version }, dependencies = { loadValidateModule }) {
49
49
  //#endregion
50
50
  exports.run = run;
51
51
 
52
- //# sourceMappingURL=run-DMWGLJUx.cjs.map
52
+ //# sourceMappingURL=run-Bj64iPU_.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"run-DMWGLJUx.cjs","names":["process","Telemetry","getErrorMessage"],"sources":["../src/runners/validate/run.ts"],"sourcesContent":["import process from 'node:process'\nimport { styleText } from 'node:util'\nimport { getErrorMessage } from '@internals/utils'\nimport { Telemetry } from '../../Telemetry.ts'\n\ntype ValidateOptions = {\n /**\n * Path or URL to the OpenAPI/Swagger file to validate.\n */\n input: string\n /**\n * Current `@kubb/cli` version string, used for the telemetry payload.\n */\n version: string\n}\n\ntype ValidateModule = typeof import('@kubb/adapter-oas')\ntype ValidateDependencies = {\n /**\n * Loads `@kubb/adapter-oas`. Injected so tests can substitute a mock.\n */\n loadValidateModule: () => Promise<ValidateModule>\n}\n\n/**\n * Dynamically loads `@kubb/adapter-oas` for OpenAPI validation.\n */\nexport function loadValidateModule(): Promise<ValidateModule> {\n return import('@kubb/adapter-oas') as Promise<ValidateModule>\n}\n\n/**\n * Validates an OpenAPI/Swagger file at `input` using `@kubb/adapter-oas`.\n * Exits the process with code 1 on validation failure or missing dependency.\n */\nexport async function run({ input, version }: ValidateOptions, dependencies: ValidateDependencies = { loadValidateModule }): Promise<void> {\n const hrStart = process.hrtime()\n const report = (status: 'success' | 'failed') => Telemetry.send(Telemetry.build({ command: 'validate', kubbVersion: version, hrStart, status }))\n try {\n const { adapterOas } = await dependencies.loadValidateModule()\n const adapter = adapterOas()\n if (!adapter.validate) {\n throw new Error('The loaded adapter does not support validation.')\n }\n await adapter.validate(input, { throwOnError: true })\n await report('success')\n console.log('✅ Validation success')\n } catch (error) {\n await report('failed')\n if (error instanceof Error && /@kubb\\/adapter-oas/.test(error.message)) {\n console.error(styleText('red', 'The @kubb/adapter-oas package is not installed.'))\n console.error('')\n console.error('Install it with:')\n console.error(styleText('cyan', ' npm install @kubb/adapter-oas'))\n console.error(styleText('cyan', ' # or'))\n console.error(styleText('cyan', ' pnpm install @kubb/adapter-oas'))\n console.error('')\n }\n console.error('❌ Validation failed')\n console.error(getErrorMessage(error))\n process.exit(1)\n }\n}\n"],"mappings":";;;;;;;;;;AA2BA,SAAgB,qBAA8C;CAC5D,OAAO,OAAO;AAChB;;;;;AAMA,eAAsB,IAAI,EAAE,OAAO,WAA4B,eAAqC,EAAE,mBAAmB,GAAkB;CACzI,MAAM,UAAUA,aAAAA,QAAQ,OAAO;CAC/B,MAAM,UAAU,WAAiCC,kBAAAA,UAAU,KAAKA,kBAAAA,UAAU,MAAM;EAAE,SAAS;EAAY,aAAa;EAAS;EAAS;CAAO,CAAC,CAAC;CAC/I,IAAI;EACF,MAAM,EAAE,eAAe,MAAM,aAAa,mBAAmB;EAC7D,MAAM,UAAU,WAAW;EAC3B,IAAI,CAAC,QAAQ,UACX,MAAM,IAAI,MAAM,iDAAiD;EAEnE,MAAM,QAAQ,SAAS,OAAO,EAAE,cAAc,KAAK,CAAC;EACpD,MAAM,OAAO,SAAS;EACtB,QAAQ,IAAI,sBAAsB;CACpC,SAAS,OAAO;EACd,MAAM,OAAO,QAAQ;EACrB,IAAI,iBAAiB,SAAS,qBAAqB,KAAK,MAAM,OAAO,GAAG;GACtE,QAAQ,OAAA,GAAA,UAAA,UAAA,CAAgB,OAAO,iDAAiD,CAAC;GACjF,QAAQ,MAAM,EAAE;GAChB,QAAQ,MAAM,kBAAkB;GAChC,QAAQ,OAAA,GAAA,UAAA,UAAA,CAAgB,QAAQ,iCAAiC,CAAC;GAClE,QAAQ,OAAA,GAAA,UAAA,UAAA,CAAgB,QAAQ,QAAQ,CAAC;GACzC,QAAQ,OAAA,GAAA,UAAA,UAAA,CAAgB,QAAQ,kCAAkC,CAAC;GACnE,QAAQ,MAAM,EAAE;EAClB;EACA,QAAQ,MAAM,qBAAqB;EACnC,QAAQ,MAAMC,eAAAA,gBAAgB,KAAK,CAAC;EACpC,aAAA,QAAQ,KAAK,CAAC;CAChB;AACF"}
1
+ {"version":3,"file":"run-Bj64iPU_.cjs","names":["process","Telemetry","getErrorMessage"],"sources":["../src/runners/validate/run.ts"],"sourcesContent":["import process from 'node:process'\nimport { styleText } from 'node:util'\nimport { getErrorMessage } from '@internals/utils'\nimport { Telemetry } from '../../Telemetry.ts'\n\ntype ValidateOptions = {\n /**\n * Path or URL to the OpenAPI/Swagger file to validate.\n */\n input: string\n /**\n * Current `@kubb/cli` version string, used for the telemetry payload.\n */\n version: string\n}\n\ntype ValidateModule = typeof import('@kubb/adapter-oas')\ntype ValidateDependencies = {\n /**\n * Loads `@kubb/adapter-oas`. Injected so tests can substitute a mock.\n */\n loadValidateModule: () => Promise<ValidateModule>\n}\n\n/**\n * Dynamically loads `@kubb/adapter-oas` for OpenAPI validation.\n */\nexport function loadValidateModule(): Promise<ValidateModule> {\n return import('@kubb/adapter-oas') as Promise<ValidateModule>\n}\n\n/**\n * Validates an OpenAPI/Swagger file at `input` using `@kubb/adapter-oas`.\n * Exits the process with code 1 on validation failure or missing dependency.\n */\nexport async function run({ input, version }: ValidateOptions, dependencies: ValidateDependencies = { loadValidateModule }): Promise<void> {\n const hrStart = process.hrtime()\n const report = (status: 'success' | 'failed') => Telemetry.send(Telemetry.build({ command: 'validate', kubbVersion: version, hrStart, status }))\n try {\n const { adapterOas } = await dependencies.loadValidateModule()\n const adapter = adapterOas()\n if (!adapter.validate) {\n throw new Error('The loaded adapter does not support validation.')\n }\n await adapter.validate(input, { throwOnError: true })\n await report('success')\n console.log('✅ Validation success')\n } catch (error) {\n await report('failed')\n if (error instanceof Error && /@kubb\\/adapter-oas/.test(error.message)) {\n console.error(styleText('red', 'The @kubb/adapter-oas package is not installed.'))\n console.error('')\n console.error('Install it with:')\n console.error(styleText('cyan', ' npm install @kubb/adapter-oas'))\n console.error(styleText('cyan', ' # or'))\n console.error(styleText('cyan', ' pnpm install @kubb/adapter-oas'))\n console.error('')\n }\n console.error('❌ Validation failed')\n console.error(getErrorMessage(error))\n process.exit(1)\n }\n}\n"],"mappings":";;;;;;;;;;AA2BA,SAAgB,qBAA8C;CAC5D,OAAO,OAAO;AAChB;;;;;AAMA,eAAsB,IAAI,EAAE,OAAO,WAA4B,eAAqC,EAAE,mBAAmB,GAAkB;CACzI,MAAM,UAAUA,aAAAA,QAAQ,OAAO;CAC/B,MAAM,UAAU,WAAiCC,kBAAAA,UAAU,KAAKA,kBAAAA,UAAU,MAAM;EAAE,SAAS;EAAY,aAAa;EAAS;EAAS;CAAO,CAAC,CAAC;CAC/I,IAAI;EACF,MAAM,EAAE,eAAe,MAAM,aAAa,mBAAmB;EAC7D,MAAM,UAAU,WAAW;EAC3B,IAAI,CAAC,QAAQ,UACX,MAAM,IAAI,MAAM,iDAAiD;EAEnE,MAAM,QAAQ,SAAS,OAAO,EAAE,cAAc,KAAK,CAAC;EACpD,MAAM,OAAO,SAAS;EACtB,QAAQ,IAAI,sBAAsB;CACpC,SAAS,OAAO;EACd,MAAM,OAAO,QAAQ;EACrB,IAAI,iBAAiB,SAAS,qBAAqB,KAAK,MAAM,OAAO,GAAG;GACtE,QAAQ,OAAA,GAAA,UAAA,UAAA,CAAgB,OAAO,iDAAiD,CAAC;GACjF,QAAQ,MAAM,EAAE;GAChB,QAAQ,MAAM,kBAAkB;GAChC,QAAQ,OAAA,GAAA,UAAA,UAAA,CAAgB,QAAQ,iCAAiC,CAAC;GAClE,QAAQ,OAAA,GAAA,UAAA,UAAA,CAAgB,QAAQ,QAAQ,CAAC;GACzC,QAAQ,OAAA,GAAA,UAAA,UAAA,CAAgB,QAAQ,kCAAkC,CAAC;GACnE,QAAQ,MAAM,EAAE;EAClB;EACA,QAAQ,MAAM,qBAAqB;EACnC,QAAQ,MAAMC,eAAAA,gBAAgB,KAAK,CAAC;EACpC,aAAA,QAAQ,KAAK,CAAC;CAChB;AACF"}
@@ -1,12 +1,11 @@
1
1
  const require_chunk = require("./chunk-Bx3C2hgW.cjs");
2
2
  const require_errors = require("./errors-DykI11xo.cjs");
3
- const require_Telemetry = require("./Telemetry-DC5WVMB9.cjs");
4
- const require_shell = require("./shell-Lh-vLWwH.cjs");
5
- const require_package = require("./package-C8wmoP1B.cjs");
3
+ const require_Telemetry = require("./Telemetry-BuDSora3.cjs");
4
+ const require_tools = require("./tools-_Xp8-_zy.cjs");
5
+ const require_package = require("./package-dLlE0LgE.cjs");
6
6
  let node_util = require("node:util");
7
7
  let node_events = require("node:events");
8
8
  let node_crypto = require("node:crypto");
9
- let node_child_process = require("node:child_process");
10
9
  let node_fs = require("node:fs");
11
10
  let node_path = require("node:path");
12
11
  node_path = require_chunk.__toESM(node_path, 1);
@@ -15,8 +14,9 @@ node_process = require_chunk.__toESM(node_process, 1);
15
14
  let _clack_prompts = require("@clack/prompts");
16
15
  _clack_prompts = require_chunk.__toESM(_clack_prompts, 1);
17
16
  let _kubb_core = require("@kubb/core");
18
- let cosmiconfig = require("cosmiconfig");
17
+ let node_url = require("node:url");
19
18
  let jiti = require("jiti");
19
+ let cosmiconfig = require("cosmiconfig");
20
20
  let tinyexec = require("tinyexec");
21
21
  //#region ../../internals/utils/src/asyncEventEmitter.ts
22
22
  /**
@@ -303,134 +303,6 @@ function formatMsWithColor(ms) {
303
303
  return (0, node_util.styleText)("red", formatted);
304
304
  }
305
305
  //#endregion
306
- //#region ../../internals/utils/src/formatters.ts
307
- /**
308
- * CLI command descriptors for each supported code formatter.
309
- *
310
- * Each entry contains the executable `command`, an `args` factory that maps an
311
- * output path to the correct argument list, and an `errorMessage` shown when
312
- * the formatter is not found.
313
- */
314
- const formatters = {
315
- prettier: {
316
- command: "prettier",
317
- args: (outputPath) => [
318
- "--ignore-unknown",
319
- "--write",
320
- outputPath
321
- ],
322
- errorMessage: "Prettier not found"
323
- },
324
- biome: {
325
- command: "biome",
326
- args: (outputPath) => [
327
- "format",
328
- "--write",
329
- outputPath
330
- ],
331
- errorMessage: "Biome not found"
332
- },
333
- oxfmt: {
334
- command: "oxfmt",
335
- args: (outputPath) => [outputPath],
336
- errorMessage: "Oxfmt not found"
337
- }
338
- };
339
- async function isFormatterAvailable(formatter) {
340
- return new Promise((resolve) => {
341
- const child = (0, node_child_process.spawn)(formatter, ["--version"], { stdio: "ignore" });
342
- child.on("close", (code) => resolve(code === 0));
343
- child.on("error", () => resolve(false));
344
- });
345
- }
346
- /**
347
- * Detects the first available code formatter on the current system.
348
- *
349
- * - Checks in preference order: `oxfmt`, `biome`, `prettier`.
350
- * - Returns `null` when none are found.
351
- *
352
- * @example
353
- * ```ts
354
- * const formatter = await detectFormatter()
355
- * if (formatter) {
356
- * console.log(`Using ${formatter} for formatting`)
357
- * }
358
- * ```
359
- */
360
- async function detectFormatter() {
361
- const formatterNames = new Set([
362
- "oxfmt",
363
- "biome",
364
- "prettier"
365
- ]);
366
- for (const formatter of formatterNames) if (await isFormatterAvailable(formatter)) return formatter;
367
- return null;
368
- }
369
- //#endregion
370
- //#region ../../internals/utils/src/linters.ts
371
- /**
372
- * CLI command descriptors for each supported linter.
373
- *
374
- * Each entry contains the executable `command`, an `args` factory that maps an
375
- * output path to the correct argument list, and an `errorMessage` shown when
376
- * the linter is not found.
377
- */
378
- const linters = {
379
- eslint: {
380
- command: "eslint",
381
- args: (outputPath) => [outputPath, "--fix"],
382
- errorMessage: "Eslint not found"
383
- },
384
- biome: {
385
- command: "biome",
386
- args: (outputPath) => [
387
- "lint",
388
- "--fix",
389
- outputPath
390
- ],
391
- errorMessage: "Biome not found"
392
- },
393
- oxlint: {
394
- command: "oxlint",
395
- args: (outputPath) => [
396
- "--fix",
397
- "--no-ignore",
398
- outputPath
399
- ],
400
- errorMessage: "Oxlint not found"
401
- }
402
- };
403
- async function isLinterAvailable(linter) {
404
- return new Promise((resolve) => {
405
- const child = (0, node_child_process.spawn)(linter, ["--version"], { stdio: "ignore" });
406
- child.on("close", (code) => resolve(code === 0));
407
- child.on("error", () => resolve(false));
408
- });
409
- }
410
- /**
411
- * Detects the first available linter on the current system.
412
- *
413
- * - Checks in preference order: `oxlint`, `biome`, `eslint`.
414
- * - Returns `null` when none are found.
415
- *
416
- * @example
417
- * ```ts
418
- * const linter = await detectLinter()
419
- * if (linter) {
420
- * console.log(`Using ${linter} for linting`)
421
- * }
422
- * ```
423
- */
424
- async function detectLinter() {
425
- const linterNames = new Set([
426
- "oxlint",
427
- "biome",
428
- "eslint"
429
- ]);
430
- for (const linter of linterNames) if (await isLinterAvailable(linter)) return linter;
431
- return null;
432
- }
433
- //#endregion
434
306
  //#region src/loggers/defineLogger.ts
435
307
  /**
436
308
  * Defines a typed logger. The `install` method subscribes to lifecycle events
@@ -988,15 +860,53 @@ function selectReporters(reporters, names) {
988
860
  return selected;
989
861
  }
990
862
  //#endregion
991
- //#region src/runners/generate/utils.ts
992
- const jiti$1 = (0, jiti.createJiti)(require("url").pathToFileURL(__filename).href, {
863
+ //#region ../../internals/shared/src/loader.ts
864
+ /**
865
+ * jiti options for loading Kubb config modules: the automatic JSX runtime pointed at
866
+ * `@kubb/renderer-jsx`, and `moduleCache` off so a re-load re-evaluates the file.
867
+ */
868
+ const JITI_OPTIONS = {
993
869
  jsx: {
994
870
  runtime: "automatic",
995
871
  importSource: "@kubb/renderer-jsx"
996
872
  },
997
873
  moduleCache: false
998
- });
999
- const tsLoader = (configFile) => jiti$1.import(configFile, { default: true });
874
+ };
875
+ /**
876
+ * Creates a runtime-aware loader for Kubb's TypeScript and JavaScript config modules.
877
+ *
878
+ * On Bun and Deno it imports the file natively, skipping jiti's transform step, and falls back to
879
+ * jiti only when the native import throws. On Node it always uses jiti, which transpiles TypeScript
880
+ * and the `@kubb/renderer-jsx` JSX runtime on the fly. The jiti instance is created lazily, so the
881
+ * Bun/Deno happy path never pays for it.
882
+ *
883
+ * @example
884
+ * ```ts
885
+ * const config = await createModuleLoader().load('/abs/kubb.config.ts', { default: true })
886
+ * ```
887
+ */
888
+ function createModuleLoader() {
889
+ let jiti$1;
890
+ const getJiti = () => jiti$1 ??= (0, jiti.createJiti)(require("url").pathToFileURL(__filename).href, JITI_OPTIONS);
891
+ const viaJiti = (filePath, options) => options?.default ? getJiti().import(filePath, { default: true }) : getJiti().import(filePath);
892
+ const viaNative = async (filePath, options) => {
893
+ const href = (0, node_url.pathToFileURL)(filePath).href;
894
+ const mod = await (options?.bust != null ? import(`${href}?t=${options.bust}`) : import(href));
895
+ return options?.default ? mod.default ?? mod : mod;
896
+ };
897
+ return { async load(filePath, options) {
898
+ if (require_Telemetry.runtime.isBun || require_Telemetry.runtime.isDeno) try {
899
+ return await viaNative(filePath, options);
900
+ } catch {
901
+ return viaJiti(filePath, options);
902
+ }
903
+ return viaJiti(filePath, options);
904
+ } };
905
+ }
906
+ //#endregion
907
+ //#region src/runners/generate/utils.ts
908
+ const loader = createModuleLoader();
909
+ const tsLoader = (configFile) => loader.load(configFile, { default: true });
1000
910
  const MODULE_NAME = "kubb";
1001
911
  const BASE_SEARCH_PLACES = [
1002
912
  "package.json",
@@ -1045,38 +955,41 @@ async function getCosmiConfig(configFile) {
1045
955
  * Discovers the Kubb config via cosmiconfig and resolves it into a normalized array of configs.
1046
956
  * Every config in the result is guaranteed to have a `plugins` array.
1047
957
  */
1048
- async function getConfigs({ configPath, input, watch, logLevel, noCache }) {
958
+ async function getConfigs({ configPath, input, watch, logLevel }) {
1049
959
  const result = await getCosmiConfig(configPath);
1050
960
  const cli = {
1051
961
  config: configPath,
1052
962
  input,
1053
963
  watch,
1054
- logLevel,
1055
- noCache
964
+ logLevel
1056
965
  };
1057
966
  const resolved = await (typeof result.config === "function" ? result.config(cli) : result.config);
1058
967
  const userConfigs = Array.isArray(resolved) ? resolved : [resolved];
1059
968
  return {
1060
969
  configPath: result.filepath,
1061
- configs: userConfigs.map((item) => {
1062
- const config = {
1063
- ...item,
1064
- plugins: item.plugins ?? []
1065
- };
1066
- return noCache ? {
1067
- ...config,
1068
- cache: void 0
1069
- } : config;
1070
- })
970
+ configs: userConfigs.map((item) => ({
971
+ ...item,
972
+ plugins: item.plugins ?? []
973
+ }))
1071
974
  };
1072
975
  }
1073
976
  /**
977
+ * Tokenizes a shell command string, respecting single and double quotes.
978
+ *
979
+ * @example
980
+ * tokenize('git commit -m "initial commit"')
981
+ * // → ['git', 'commit', '-m', 'initial commit']
982
+ */
983
+ function tokenize(command) {
984
+ return (command.match(/[^\s"']+|"([^"]*)"|'([^']*)'/g) ?? []).map((token) => token.replace(/^["']|["']$/g, ""));
985
+ }
986
+ /**
1074
987
  * Runs the `done` hooks defined in a Kubb config in sequence.
1075
988
  */
1076
989
  async function executeHooks({ configHooks, hooks }) {
1077
990
  const commands = Array.isArray(configHooks.done) ? configHooks.done : [configHooks.done].filter(Boolean);
1078
991
  for (const command of commands) {
1079
- const [cmd, ...args] = require_shell.tokenize(command);
992
+ const [cmd, ...args] = tokenize(command);
1080
993
  if (!cmd) continue;
1081
994
  const hookId = (0, node_crypto.hash)("sha256", command, "hex");
1082
995
  const commandWithArgs = [cmd, ...args].join(" ");
@@ -1281,8 +1194,12 @@ async function generate(options) {
1281
1194
  const toolPasses = [config.output.format && {
1282
1195
  code: _kubb_core.Diagnostics.code.formatFailed,
1283
1196
  toolValue: config.output.format,
1284
- detect: detectFormatter,
1285
- toolMap: formatters,
1197
+ detect: () => require_tools.detectTool([
1198
+ "oxfmt",
1199
+ "biome",
1200
+ "prettier"
1201
+ ]),
1202
+ toolMap: require_tools.formatters,
1286
1203
  toolLabel: "formatter",
1287
1204
  successPrefix: "Formatting",
1288
1205
  noToolMessage: "No formatter found (oxfmt, biome, or prettier). Skipping formatting.",
@@ -1291,8 +1208,12 @@ async function generate(options) {
1291
1208
  }, config.output.lint && {
1292
1209
  code: _kubb_core.Diagnostics.code.lintFailed,
1293
1210
  toolValue: config.output.lint,
1294
- detect: detectLinter,
1295
- toolMap: linters,
1211
+ detect: () => require_tools.detectTool([
1212
+ "oxlint",
1213
+ "biome",
1214
+ "eslint"
1215
+ ]),
1216
+ toolMap: require_tools.linters,
1296
1217
  toolLabel: "linter",
1297
1218
  successPrefix: "Linting",
1298
1219
  noToolMessage: "No linter found (oxlint, biome, or eslint). Skipping linting.",
@@ -1366,22 +1287,20 @@ function outputDiagnostic(code, label, caughtError) {
1366
1287
  };
1367
1288
  }
1368
1289
  async function checkForUpdate(hooks) {
1369
- await require_Telemetry.executeIfOnline(async () => {
1370
- try {
1371
- const data = await (await fetch(require_Telemetry.KUBB_NPM_PACKAGE_URL)).json();
1372
- if (data.version && require_package.version < data.version) await _kubb_core.Diagnostics.emit(hooks, _kubb_core.Diagnostics.update({
1373
- currentVersion: require_package.version,
1374
- latestVersion: data.version
1375
- }));
1376
- } catch {}
1377
- });
1290
+ try {
1291
+ const data = await (await fetch(require_Telemetry.KUBB_NPM_PACKAGE_URL)).json();
1292
+ if (data.version && require_package.version < data.version) await _kubb_core.Diagnostics.emit(hooks, _kubb_core.Diagnostics.update({
1293
+ currentVersion: require_package.version,
1294
+ latestVersion: data.version
1295
+ }));
1296
+ } catch {}
1378
1297
  }
1379
1298
  /**
1380
1299
  * Runs the full Kubb generation lifecycle for the given CLI options.
1381
1300
  * Loads configs, sets up the selected reporters (CLI `--reporter` overrides `config.reporters`),
1382
1301
  * checks for a newer version, and calls `generate` for each config entry.
1383
1302
  */
1384
- async function run({ input, configPath, logLevel: logLevelKey, watch, reporters: cliReporters, noCache }) {
1303
+ async function run({ input, configPath, logLevel: logLevelKey, watch, reporters: cliReporters }) {
1385
1304
  const logLevel = _kubb_core.logLevel[logLevelKey] ?? _kubb_core.logLevel.info;
1386
1305
  const hooks = new AsyncEventEmitter();
1387
1306
  let configs;
@@ -1391,8 +1310,7 @@ async function run({ input, configPath, logLevel: logLevelKey, watch, reporters:
1391
1310
  configPath,
1392
1311
  input,
1393
1312
  watch,
1394
- logLevel: logLevelKey,
1395
- noCache
1313
+ logLevel: logLevelKey
1396
1314
  });
1397
1315
  configs = loaded.configs;
1398
1316
  resolvedConfigPath = loaded.configPath;
@@ -1455,4 +1373,4 @@ async function run({ input, configPath, logLevel: logLevelKey, watch, reporters:
1455
1373
  //#endregion
1456
1374
  exports.run = run;
1457
1375
 
1458
- //# sourceMappingURL=run-4WGNek3a.cjs.map
1376
+ //# sourceMappingURL=run-BoR5nxtV.cjs.map