@kubb/cli 5.9.0 → 5.9.2

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 (98) hide show
  1. package/bin/kubb.js +1 -1
  2. package/dist/{Telemetry-D1jiXfo2.cjs → Telemetry-B_C4MVJd.cjs} +26 -66
  3. package/dist/Telemetry-B_C4MVJd.cjs.map +1 -0
  4. package/dist/{Telemetry-BivZAaw9.js → Telemetry-DER8LIO5.js} +26 -66
  5. package/dist/Telemetry-DER8LIO5.js.map +1 -0
  6. package/dist/{background-uIIElWXl.js → background-B0YbkZ0s.js} +2 -2
  7. package/dist/{background-uIIElWXl.js.map → background-B0YbkZ0s.js.map} +1 -1
  8. package/dist/{background-Cd2TGkLg.cjs → background-Bh4FDWa3.cjs} +2 -2
  9. package/dist/{background-Cd2TGkLg.cjs.map → background-Bh4FDWa3.cjs.map} +1 -1
  10. package/dist/background-DSKoOwcG.js +1 -0
  11. package/dist/{commands-BlNFxWKB.js → commands-BegVe5Mt.js} +3 -3
  12. package/dist/{commands-BlNFxWKB.js.map → commands-BegVe5Mt.js.map} +1 -1
  13. package/dist/{commands-ID-cYLXW.cjs → commands-hXDwA0zn.cjs} +3 -3
  14. package/dist/{commands-ID-cYLXW.cjs.map → commands-hXDwA0zn.cjs.map} +1 -1
  15. package/dist/{config-DAdYwK_D.js → config-B6UIKcl1.js} +13 -16
  16. package/dist/config-B6UIKcl1.js.map +1 -0
  17. package/dist/{config-CRBZcWwg.cjs → config-Bo9ro7vg.cjs} +13 -16
  18. package/dist/config-Bo9ro7vg.cjs.map +1 -0
  19. package/dist/constants-Cii4HX64.js +12 -0
  20. package/dist/constants-Cii4HX64.js.map +1 -0
  21. package/dist/constants-Df449N47.cjs +29 -0
  22. package/dist/constants-Df449N47.cjs.map +1 -0
  23. package/dist/index.cjs +19 -28
  24. package/dist/index.cjs.map +1 -1
  25. package/dist/index.js +19 -28
  26. package/dist/index.js.map +1 -1
  27. package/dist/{output-CWupdozw.cjs → output-BnK0scpX.cjs} +10 -15
  28. package/dist/output-BnK0scpX.cjs.map +1 -0
  29. package/dist/{output-B9Yw7vL0.js → output-qFt4vV7K.js} +10 -15
  30. package/dist/output-qFt4vV7K.js.map +1 -0
  31. package/dist/{reporters-C5HAypFq.cjs → reporters-B4rZOlo8.cjs} +2 -2
  32. package/dist/{reporters-C5HAypFq.cjs.map → reporters-B4rZOlo8.cjs.map} +1 -1
  33. package/dist/{reporters-CNZQUlXY.js → reporters-H21Jvrff.js} +2 -2
  34. package/dist/{reporters-CNZQUlXY.js.map → reporters-H21Jvrff.js.map} +1 -1
  35. package/dist/{run-VAkf24Cw.cjs → run-89YfZJuo.cjs} +3 -3
  36. package/dist/{run-VAkf24Cw.cjs.map → run-89YfZJuo.cjs.map} +1 -1
  37. package/dist/run-8HrdMihy.js +1 -0
  38. package/dist/{run-DnXUzX34.js → run-BCswmM8Q.js} +3 -5
  39. package/dist/run-BCswmM8Q.js.map +1 -0
  40. package/dist/{run-BF2Wq1Io.js → run-BQQhNg8I.js} +7 -7
  41. package/dist/{run-BF2Wq1Io.js.map → run-BQQhNg8I.js.map} +1 -1
  42. package/dist/{run-Ey756UCd.js → run-BYff_byB.js} +2 -2
  43. package/dist/{run-Ey756UCd.js.map → run-BYff_byB.js.map} +1 -1
  44. package/dist/{run-mx0KM8y5.js → run-BcMMYk7G.js} +10 -22
  45. package/dist/run-BcMMYk7G.js.map +1 -0
  46. package/dist/{run-DSeEZTnT.cjs → run-C8dyBAPb.cjs} +7 -7
  47. package/dist/{run-DSeEZTnT.cjs.map → run-C8dyBAPb.cjs.map} +1 -1
  48. package/dist/{run-USNnlQcA.js → run-CJHsZZB8.js} +41 -49
  49. package/dist/run-CJHsZZB8.js.map +1 -0
  50. package/dist/{run-yb2R1vt0.js → run-Ca_OX3WZ.js} +6 -7
  51. package/dist/run-Ca_OX3WZ.js.map +1 -0
  52. package/dist/{run-C5P5_H0R.cjs → run-Ct6kzKpg.cjs} +6 -6
  53. package/dist/run-Ct6kzKpg.cjs.map +1 -0
  54. package/dist/{run-D4cZ-1zg.cjs → run-D8EJ2hKI.cjs} +2 -2
  55. package/dist/{run-D4cZ-1zg.cjs.map → run-D8EJ2hKI.cjs.map} +1 -1
  56. package/dist/{run-E11sqsk0.cjs → run-DL2wLwBZ.cjs} +41 -49
  57. package/dist/run-DL2wLwBZ.cjs.map +1 -0
  58. package/dist/{run-DRR30f0e.js → run-Dej-hm91.js} +3 -3
  59. package/dist/{run-DRR30f0e.js.map → run-Dej-hm91.js.map} +1 -1
  60. package/dist/{run-CnBJroZW.cjs → run-DpAMfkm5.cjs} +2 -2
  61. package/dist/{run-CnBJroZW.cjs.map → run-DpAMfkm5.cjs.map} +1 -1
  62. package/dist/{run-ajUuT3vK.js → run-KLPSFEv-.js} +2 -2
  63. package/dist/{run-ajUuT3vK.js.map → run-KLPSFEv-.js.map} +1 -1
  64. package/dist/{run-DfkvTomI.cjs → run-e8gMz1M_.cjs} +3 -5
  65. package/dist/run-e8gMz1M_.cjs.map +1 -0
  66. package/dist/{run-CNXBX4kr.cjs → run-fg0ycsS_.cjs} +10 -22
  67. package/dist/run-fg0ycsS_.cjs.map +1 -0
  68. package/dist/{snapshot-D5OaRDf9.cjs → snapshot-B45A4RfA.cjs} +5 -5
  69. package/dist/{snapshot-D5OaRDf9.cjs.map → snapshot-B45A4RfA.cjs.map} +1 -1
  70. package/dist/{snapshot-CHKxNlYg.js → snapshot-C0WaZZiF.js} +5 -5
  71. package/dist/{snapshot-CHKxNlYg.js.map → snapshot-C0WaZZiF.js.map} +1 -1
  72. package/dist/studioWorker.js +2 -2
  73. package/dist/{utils-Dhx5PMpD.js → utils-BHW8kA8P.js} +11 -8
  74. package/dist/utils-BHW8kA8P.js.map +1 -0
  75. package/dist/{utils-ZcCFqERz.cjs → utils-BzQ46pgd.cjs} +16 -13
  76. package/dist/utils-BzQ46pgd.cjs.map +1 -0
  77. package/package.json +7 -7
  78. package/dist/Telemetry-BivZAaw9.js.map +0 -1
  79. package/dist/Telemetry-D1jiXfo2.cjs.map +0 -1
  80. package/dist/background-D0UaV1ZP.js +0 -1
  81. package/dist/config-CRBZcWwg.cjs.map +0 -1
  82. package/dist/config-DAdYwK_D.js.map +0 -1
  83. package/dist/constants-CdxpgX3_.cjs +0 -115
  84. package/dist/constants-CdxpgX3_.cjs.map +0 -1
  85. package/dist/constants-DHRspBTo.js +0 -92
  86. package/dist/constants-DHRspBTo.js.map +0 -1
  87. package/dist/output-B9Yw7vL0.js.map +0 -1
  88. package/dist/output-CWupdozw.cjs.map +0 -1
  89. package/dist/run-C5P5_H0R.cjs.map +0 -1
  90. package/dist/run-CNXBX4kr.cjs.map +0 -1
  91. package/dist/run-DfkvTomI.cjs.map +0 -1
  92. package/dist/run-DnXUzX34.js.map +0 -1
  93. package/dist/run-E11sqsk0.cjs.map +0 -1
  94. package/dist/run-USNnlQcA.js.map +0 -1
  95. package/dist/run-mx0KM8y5.js.map +0 -1
  96. package/dist/run-yb2R1vt0.js.map +0 -1
  97. package/dist/utils-Dhx5PMpD.js.map +0 -1
  98. package/dist/utils-ZcCFqERz.cjs.map +0 -1
@@ -1,7 +1,9 @@
1
1
  const require_agent = require("./agent-DElUuYuy.cjs");
2
- const require_constants = require("./constants-CdxpgX3_.cjs");
3
- const require_output = require("./output-CWupdozw.cjs");
4
- const require_utils = require("./utils-ZcCFqERz.cjs");
2
+ const require_constants = require("./constants-Df449N47.cjs");
3
+ const require_output = require("./output-BnK0scpX.cjs");
4
+ const require_registry = require("./registry-DER9aRyg.cjs");
5
+ const require_utils = require("./utils-BzQ46pgd.cjs");
6
+ const require_run = require("./run-Ct6kzKpg.cjs");
5
7
  let node_util = require("node:util");
6
8
  let node_process = require("node:process");
7
9
  node_process = require_agent.__toESM(node_process, 1);
@@ -12,19 +14,8 @@ _clack_prompts = require_agent.__toESM(_clack_prompts, 1);
12
14
  let node_fs = require("node:fs");
13
15
  node_fs = require_agent.__toESM(node_fs, 1);
14
16
  //#region ../../internals/shared/src/init.ts
15
- /**
16
- * Resolves a comma-separated plugin flag (e.g. `--plugins plugin-ts,plugin-zod`) into the
17
- * matching known plugin options. Unrecognized names are dropped, and a missing flag yields
18
- * an empty list.
19
- */
20
- function resolvePlugins(pluginsFlag) {
21
- if (!pluginsFlag) return [];
22
- const requested = pluginsFlag.split(",").map((value) => value.trim()).filter(Boolean);
23
- return require_constants.availablePlugins.filter((plugin) => requested.includes(plugin.value));
24
- }
25
17
  function generateConfigFile({ selectedPlugins, inputPath, outputPath }) {
26
- return `import { defineConfig } from 'kubb/config'
27
- ${selectedPlugins.map((plugin) => `import { ${plugin.importName} } from '${plugin.packageName}'`).join("\n")}
18
+ return `${[`import { defineConfig } from 'kubb/config'`, ...selectedPlugins.map((plugin) => `import { ${plugin.importName} } from '${plugin.packageName}'`)].join("\n")}
28
19
 
29
20
  export default defineConfig({
30
21
  input: '${inputPath}',
@@ -38,18 +29,6 @@ ${selectedPlugins.map((plugin) => ` ${plugin.importName}(),`).join("\n")}
38
29
  })
39
30
  `;
40
31
  }
41
- /**
42
- * Turns package names into install specifiers for the wizard.
43
- *
44
- * `kubb` is pinned to the exact version of the running CLI, since both ship from the same release
45
- * and resolving `kubb@beta` separately can land on a different version than the CLI doing the
46
- * scaffolding. Plugins release from their own repo on their own cadence, so they follow the
47
- * release channel of the CLI through its dist-tag.
48
- */
49
- function resolveInstallVersions({ packages, version }) {
50
- const tag = version.match(/-([a-z]+)/)?.[1] ?? "latest";
51
- return packages.map((name) => name === "kubb" ? `${name}@${version}` : `${name}@${tag}`);
52
- }
53
32
  //#endregion
54
33
  //#region src/runners/init/run.ts
55
34
  function cancelAndExit(message = "Operation canceled.") {
@@ -82,7 +61,9 @@ async function run({ yes, version, input: inputFlag, output: outputFlag, plugins
82
61
  return result;
83
62
  }
84
63
  try {
85
- if (!require_utils.hasPackageJson(cwd)) {
64
+ const plugins = (await require_registry.fetchRegistryIndex({ registry: require_registry.registryUrl() })).filter((entry) => entry.kind === "plugin" && !require_registry.incompatibility(entry.manifest));
65
+ const byId = new Map(plugins.map((entry) => [entry.id, entry]));
66
+ if (!node_fs.default.existsSync(node_path.default.join(cwd, "package.json"))) {
86
67
  if (!yes) {
87
68
  const shouldInit = await _clack_prompts.confirm({
88
69
  message: "No package.json found. Would you like to create one?",
@@ -97,7 +78,7 @@ async function run({ yes, version, input: inputFlag, output: outputFlag, plugins
97
78
  spinner.stop(`Created package.json with ${packageManager.name}`);
98
79
  }
99
80
  const packageManager = require_utils.detectPackageManager(cwd);
100
- if (require_utils.hasPackageJson(cwd)) require_output.logInfo(`Detected package manager: ${(0, node_util.styleText)("cyan", packageManager.name)}`);
81
+ require_output.logInfo(`Detected package manager: ${(0, node_util.styleText)("cyan", packageManager.name)}`);
101
82
  const inputPath = await resolveOrPrompt(inputFlag, require_constants.initDefaults.inputPath, "Using input path", () => _clack_prompts.text({
102
83
  message: "Where is your OpenAPI specification located?",
103
84
  placeholder: require_constants.initDefaults.inputPath,
@@ -114,17 +95,16 @@ async function run({ yes, version, input: inputFlag, output: outputFlag, plugins
114
95
  if (!value) return "Output path is required";
115
96
  }
116
97
  }));
117
- const defaultPlugins = require_constants.availablePlugins.filter((p) => require_constants.initDefaults.plugins.includes(p.value));
118
- const pluginLabel = (plugins) => (0, node_util.styleText)("cyan", plugins.map((p) => p.label).join(", "));
98
+ const defaultPlugins = require_constants.initDefaults.plugins.flatMap((slug) => byId.get(require_registry.toRegistryId(slug)) ?? []);
99
+ const pluginLabel = (entries) => (0, node_util.styleText)("cyan", entries.map((entry) => entry.manifest.displayName).join(", "));
119
100
  const selectedPlugins = await (async () => {
120
101
  if (pluginsFlag) {
121
- const plugins = resolvePlugins(pluginsFlag);
122
- if (plugins.length === 0) {
123
- require_output.logWarn(`No valid plugins found in --plugins value; falling back to default: ${pluginLabel(defaultPlugins)}`);
124
- return defaultPlugins;
125
- }
126
- require_output.logInfo(`Using plugins: ${pluginLabel(plugins)}`);
127
- return plugins;
102
+ const ids = pluginsFlag.split(",").map((id) => id.trim()).filter(Boolean);
103
+ const unknown = ids.filter((id) => !byId.has(require_registry.toRegistryId(id)));
104
+ if (unknown.length) throw new Error(`Not in the Kubb registry: ${unknown.join(", ")}. Browse the plugins at https://kubb.dev/extensions.`);
105
+ const entries = ids.map((id) => byId.get(require_registry.toRegistryId(id)));
106
+ require_output.logInfo(`Using plugins: ${pluginLabel(entries)}`);
107
+ return entries;
128
108
  }
129
109
  if (yes) {
130
110
  require_output.logInfo(`Using plugins: ${pluginLabel(defaultPlugins)}`);
@@ -132,21 +112,23 @@ async function run({ yes, version, input: inputFlag, output: outputFlag, plugins
132
112
  }
133
113
  const values = await _clack_prompts.multiselect({
134
114
  message: "Select plugins to use:",
135
- options: require_constants.availablePlugins.map(({ value, label, hint }) => ({
136
- value,
137
- label,
138
- hint
115
+ options: plugins.map(({ id, manifest }) => ({
116
+ value: id,
117
+ label: manifest.displayName,
118
+ hint: manifest.category
139
119
  })),
140
- initialValues: [...require_constants.initDefaults.plugins],
120
+ initialValues: defaultPlugins.map((entry) => entry.id),
141
121
  required: true
142
122
  });
143
123
  if (_clack_prompts.isCancel(values)) cancelAndExit();
144
- return require_constants.availablePlugins.filter((p) => values.includes(p.value));
124
+ return plugins.filter((entry) => values.includes(entry.id));
145
125
  })();
146
- const packagesToInstall = resolveInstallVersions({
147
- packages: [require_constants.KUBB_PACKAGE_NAME, ...selectedPlugins.map((p) => p.packageName)],
148
- version
126
+ const missing = require_utils.missingPluginDependencies({
127
+ selected: selectedPlugins.map((entry) => entry.manifest.name),
128
+ manifests: selectedPlugins.map((entry) => entry.manifest)
149
129
  });
130
+ if (missing.length) throw new Error(`${missing.join("\n")}\nAdd the missing plugins and run kubb init again.`);
131
+ const packagesToInstall = [`${require_constants.KUBB_PACKAGE_NAME}@${version}`, ...selectedPlugins.map((entry) => require_registry.installSpec(entry.artifact))];
150
132
  const spinner = require_output.createSpinner();
151
133
  spinner.start(`Installing ${packagesToInstall.length} packages with ${packageManager.name}`);
152
134
  try {
@@ -159,7 +141,7 @@ async function run({ yes, version, input: inputFlag, output: outputFlag, plugins
159
141
  const configSpinner = require_output.createSpinner();
160
142
  configSpinner.start(`Creating ${require_constants.KUBB_CONFIG_FILENAME}`);
161
143
  const configContent = generateConfigFile({
162
- selectedPlugins,
144
+ selectedPlugins: [],
163
145
  inputPath,
164
146
  outputPath
165
147
  });
@@ -176,6 +158,16 @@ async function run({ yes, version, input: inputFlag, output: outputFlag, plugins
176
158
  configSpinner.start(`Overwriting ${require_constants.KUBB_CONFIG_FILENAME}`);
177
159
  }
178
160
  await dryRun.run(() => node_fs.default.promises.writeFile(configPath, configContent, "utf-8"), { message: `write ${require_constants.KUBB_CONFIG_FILENAME}` });
161
+ for (const entry of selectedPlugins) {
162
+ const reason = await dryRun.run(() => require_run.addToConfig({
163
+ detail: entry,
164
+ configFile: configPath
165
+ }), {
166
+ message: `add ${entry.manifest.export}() to ${require_constants.KUBB_CONFIG_FILENAME}`,
167
+ resolve: () => void 0
168
+ });
169
+ if (reason) throw new Error(`Could not add ${entry.manifest.export}() to ${require_constants.KUBB_CONFIG_FILENAME}: ${reason}`);
170
+ }
179
171
  configSpinner.stop(`Created ${require_constants.KUBB_CONFIG_FILENAME}`);
180
172
  require_output.logOutro((0, node_util.styleText)("green", "✓ All set!") + "\n\n" + (0, node_util.styleText)("dim", "Next steps:") + "\n" + (0, node_util.styleText)("cyan", ` 1. Make sure your OpenAPI spec is at: ${inputPath}`) + "\n" + (0, node_util.styleText)("cyan", " 2. Generate code with: npx kubb generate") + "\n" + (0, node_util.styleText)("cyan", ` 3. Find generated files in: ${outputPath}`) + "\n\n" + (0, node_util.styleText)("dim", `Using ${packageManager.name} • Kubb v${version}`));
181
173
  } catch (error) {
@@ -187,4 +179,4 @@ async function run({ yes, version, input: inputFlag, output: outputFlag, plugins
187
179
  //#endregion
188
180
  exports.run = run;
189
181
 
190
- //# sourceMappingURL=run-E11sqsk0.cjs.map
182
+ //# sourceMappingURL=run-DL2wLwBZ.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-DL2wLwBZ.cjs","names":["process","styleText","clack","fetchRegistryIndex","registryUrl","incompatibility","fs","path","detectPackageManager","createSpinner","initPackageJson","initDefaults","toRegistryId","missingPluginDependencies","KUBB_PACKAGE_NAME","installSpec","installPackages","KUBB_CONFIG_FILENAME","addToConfig"],"sources":["../../../internals/shared/src/init.ts","../src/runners/init/run.ts"],"sourcesContent":["import { availablePlugins, type PluginOption } from './constants.ts'\n\n/**\n * Resolves a comma-separated plugin flag (e.g. `--plugins plugin-ts,plugin-zod`) into the\n * matching known plugin options. Unrecognized names are dropped, and a missing flag yields\n * an empty list.\n */\nexport function resolvePlugins(pluginsFlag: string | undefined): Array<PluginOption> {\n if (!pluginsFlag) {\n return []\n }\n const requested = pluginsFlag\n .split(',')\n .map((value) => value.trim())\n .filter(Boolean)\n return availablePlugins.filter((plugin) => requested.includes(plugin.value))\n}\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 = [\n `import { defineConfig } from 'kubb/config'`,\n ...selectedPlugins.map((plugin) => `import { ${plugin.importName} } from '${plugin.packageName}'`),\n ].join('\\n')\n\n const pluginConfigs = selectedPlugins.map((plugin) => ` ${plugin.importName}(),`).join('\\n')\n\n return `${imports}\n\nexport default defineConfig({\n input: '${inputPath}',\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 { styleText } from 'node:util'\nimport * as clack from '@clack/prompts'\nimport type { DryRunExtension } from '@gunshi/plugin-dryrun'\nimport { generateConfigFile, initDefaults, KUBB_CONFIG_FILENAME, KUBB_PACKAGE_NAME } from '@internals/shared'\nimport type { RegistryEntry } from '@kubb/core'\nimport { createSpinner, logError, logInfo, logIntro, logOutro } from '../../loggers/output.ts'\nimport { addToConfig } from '../add/run.ts'\nimport { fetchRegistryIndex, incompatibility, installSpec, registryUrl, toRegistryId } from '../../utils/registry.ts'\nimport { detectPackageManager, initPackageJson, installPackages, missingPluginDependencies } 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 closing outro.\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 * Dry-run extension from `@gunshi/plugin-dryrun`. When enabled, package installation and the\n * config file write are skipped.\n */\n dryRun: DryRunExtension\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, dryRun }: InitOptions): Promise<void> {\n const cwd = process.cwd()\n\n logIntro({ title: 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<NoInfer<T> | symbol>): Promise<T> {\n if (flag !== undefined) {\n logInfo(`${logLabel}: ${styleText('cyan', String(flag))}`)\n return flag\n }\n if (yes) {\n logInfo(`${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 // The plugins come from the Kubb registry, like `kubb add`, so read it before changing anything\n const plugins = (await fetchRegistryIndex({ registry: registryUrl() })).filter((entry) => entry.kind === 'plugin' && !incompatibility(entry.manifest))\n const byId = new Map(plugins.map((entry) => [entry.id, entry]))\n\n // Check/create package.json, detect package manager once after the block\n if (!fs.existsSync(path.join(cwd, 'package.json'))) {\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 = createSpinner()\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 logInfo(`Detected package manager: ${styleText('cyan', packageManager.name)}`)\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 = initDefaults.plugins.flatMap((slug) => byId.get(toRegistryId(slug)) ?? [])\n const pluginLabel = (entries: Array<RegistryEntry>) => styleText('cyan', entries.map((entry) => entry.manifest.displayName).join(', '))\n\n const selectedPlugins: Array<RegistryEntry> = await (async () => {\n if (pluginsFlag) {\n const ids = pluginsFlag\n .split(',')\n .map((id) => id.trim())\n .filter(Boolean)\n const unknown = ids.filter((id) => !byId.has(toRegistryId(id)))\n if (unknown.length) throw new Error(`Not in the Kubb registry: ${unknown.join(', ')}. Browse the plugins at https://kubb.dev/extensions.`)\n const entries = ids.map((id) => byId.get(toRegistryId(id))!)\n logInfo(`Using plugins: ${pluginLabel(entries)}`)\n return entries\n }\n if (yes) {\n logInfo(`Using plugins: ${pluginLabel(defaultPlugins)}`)\n return defaultPlugins\n }\n const values = await clack.multiselect({\n message: 'Select plugins to use:',\n options: plugins.map(({ id, manifest }) => ({ value: id, label: manifest.displayName, hint: manifest.category })),\n initialValues: defaultPlugins.map((entry) => entry.id),\n required: true,\n })\n if (clack.isCancel(values)) cancelAndExit()\n return plugins.filter((entry) => (values as Array<string>).includes(entry.id))\n })()\n\n // Check the selection against the plugins' manifests before installing anything\n const missing = missingPluginDependencies({\n selected: selectedPlugins.map((entry) => entry.manifest.name),\n manifests: selectedPlugins.map((entry) => entry.manifest),\n })\n if (missing.length) {\n throw new Error(`${missing.join('\\n')}\\nAdd the missing plugins and run kubb init again.`)\n }\n\n // Install `kubb` at the running CLI's version and each plugin at the version the registry pins\n const packagesToInstall = [`${KUBB_PACKAGE_NAME}@${version}`, ...selectedPlugins.map((entry) => installSpec(entry.artifact))]\n\n const spinner = createSpinner()\n spinner.start(`Installing ${packagesToInstall.length} packages with ${packageManager.name}`)\n\n try {\n await dryRun.run(() => installPackages(packagesToInstall, packageManager, cwd), {\n message: `install ${packagesToInstall.length} packages with ${packageManager.name}`,\n })\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 = createSpinner()\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 dryRun.run(() => fs.promises.writeFile(configPath, configContent, 'utf-8'), { message: `write ${KUBB_CONFIG_FILENAME}` })\n\n // Add each plugin the way `kubb add` does\n for (const entry of selectedPlugins) {\n const reason = await dryRun.run(() => addToConfig({ detail: entry, configFile: configPath }), {\n message: `add ${entry.manifest.export}() to ${KUBB_CONFIG_FILENAME}`,\n resolve: () => undefined,\n })\n if (reason) throw new Error(`Could not add ${entry.manifest.export}() to ${KUBB_CONFIG_FILENAME}: ${reason}`)\n }\n\n configSpinner.stop(`Created ${KUBB_CONFIG_FILENAME}`)\n\n logOutro(\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 logError(styleText('red', 'An error occurred during initialization'))\n if (error instanceof Error) {\n logError(error.message)\n }\n process.exit(1)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAkBA,SAAgB,mBAAmB,EACjC,iBACA,WACA,cAKS;CAQT,OAAO,GAPS,CACd,8CACA,GAAG,gBAAgB,KAAK,WAAW,YAAY,OAAO,WAAW,WAAW,OAAO,YAAY,EAAE,CACnG,CAAC,CAAC,KAAK,IAIS,EAAE;;;YAGR,UAAU;;aAET,WAAW;;;;EAPA,gBAAgB,KAAK,WAAW,OAAO,OAAO,WAAW,IAAI,CAAC,CAAC,KAAK,IAW9E,EAAE;;;;AAIhB;;;AClCA,SAAS,cAAc,UAAU,uBAA8B;CAC7D,eAAM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AC7B,UAAA,GACAA,UAAAA,UAAAA,CAAU,OAAO,aAAa,IAC9B,QAAA,GACAA,UAAAA,UAAAA,CAAU,QAAQ,2CAA2C,WAAW,IACxE,QAAA,GACAA,UAAAA,UAAAA,CAAU,QAAQ,4CAA4C,IAC9D,QAAA,GACAA,UAAAA,UAAAA,CAAU,QAAQ,iCAAiC,YAAY,IAC/D,UAAA,GACAA,UAAAA,UAAAA,CAAU,OAAO,SAAS,eAAe,KAAK,WAAW,SAAS,CACtE;CACF,SAAS,OAAO;EACd,eAAA,UAAA,GAASA,UAAAA,UAAAA,CAAU,OAAO,yCAAyC,CAAC;EACpE,IAAI,iBAAiB,OACnB,eAAA,SAAS,MAAM,OAAO;EAExB,aAAA,QAAQ,KAAK,CAAC;CAChB;AACF"}
@@ -1,8 +1,8 @@
1
1
  import "./rolldown-runtime-CRm0XQPb.js";
2
2
  import { t as getErrorMessage } from "./errors-DmC83ALX.js";
3
- import { a as logInfo, d as logWarn, i as logError, l as logStep, o as logIntro, r as logBlock, s as logOutro } from "./output-B9Yw7vL0.js";
3
+ import { a as logInfo, d as logWarn, i as logError, l as logStep, o as logIntro, r as logBlock, s as logOutro } from "./output-qFt4vV7K.js";
4
4
  import { a as isOutdated, i as installSpec, n as fetchRegistryIndex, o as registryUrl, r as incompatibility, s as toRegistryId } from "./registry-B7BvdrGE.js";
5
- import { i as installPackages, t as detectPackageManager } from "./utils-Dhx5PMpD.js";
5
+ import { r as installPackages, t as detectPackageManager } from "./utils-BHW8kA8P.js";
6
6
  import { styleText } from "node:util";
7
7
  import process from "node:process";
8
8
  import { readInstalledPackages } from "@kubb/core";
@@ -62,4 +62,4 @@ async function run({ ids, check, yes }) {
62
62
  //#endregion
63
63
  export { run };
64
64
 
65
- //# sourceMappingURL=run-DRR30f0e.js.map
65
+ //# sourceMappingURL=run-Dej-hm91.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"run-DRR30f0e.js","names":[],"sources":["../src/runners/update/run.ts"],"sourcesContent":["import process from 'node:process'\nimport { styleText } from 'node:util'\nimport * as clack from '@clack/prompts'\nimport { getErrorMessage } from '@internals/utils'\nimport { readInstalledPackages } from '@kubb/core'\nimport { logBlock, logError, logInfo, logIntro, logOutro, logStep, logWarn } from '../../loggers/output.ts'\nimport { fetchRegistryIndex, incompatibility, installSpec, isOutdated, registryUrl, toRegistryId } from '../../utils/registry.ts'\nimport { detectPackageManager, installPackages } from '../init/utils.ts'\n\nexport type UpdateOptions = {\n /**\n * Registry ids to update. Empty updates every installed extension the registry lists.\n */\n ids: Array<string>\n check: boolean\n yes: boolean\n}\n\n/**\n * Moves installed extensions to the version the registry pins. Lists the proposals, asks, then\n * installs them. With `check`, only lists them.\n */\nexport async function run({ ids, check, yes }: UpdateOptions): Promise<void> {\n const cwd = process.cwd()\n logIntro({ title: styleText('bgCyan', styleText('black', ' Kubb Update ')) })\n\n try {\n const wanted = new Set(ids.map(toRegistryId))\n const [entries, installed] = await Promise.all([fetchRegistryIndex({ registry: registryUrl() }), readInstalledPackages({ root: cwd })])\n const versions = new Map(installed.map((item) => [item.package, item.version]))\n\n const tracked = entries.filter((entry) => versions.has(entry.artifact.package) && (!wanted.size || wanted.has(entry.id)))\n for (const id of wanted) {\n if (!tracked.some((entry) => entry.id === id)) logWarn(`${id} is not installed, or not in the registry.`)\n }\n\n const proposals = tracked.filter((entry) => {\n if (!isOutdated({ installed: versions.get(entry.artifact.package), latest: entry.artifact.version })) return false\n const problem = incompatibility(entry.manifest)\n if (problem) logWarn(`Skipped ${entry.id}: ${problem}`)\n return !problem\n })\n\n if (!proposals.length) {\n logOutro(ids.length ? `No updates for ${ids.join(', ')}.` : 'Every installed extension is up to date.')\n return\n }\n\n const plural = proposals.length === 1 ? '' : 's'\n logBlock(\n proposals.map(({ artifact }) => `${artifact.package} ${versions.get(artifact.package) ?? 'not installed'} -> ${styleText('green', artifact.version)}`),\n )\n\n if (check) {\n logOutro(`${proposals.length} update${plural} available. Run \\`kubb update\\` to install.`)\n return\n }\n\n const confirmed = yes || (await clack.confirm({ message: `Install ${proposals.length} update${plural}?`, initialValue: true }))\n if (clack.isCancel(confirmed) || !confirmed) {\n clack.cancel('Operation canceled.')\n return\n }\n\n const packageManager = detectPackageManager(cwd)\n const specs = proposals.map(({ artifact }) => installSpec(artifact))\n logStep(`Installing ${specs.join(', ')} with ${packageManager.name}`)\n await installPackages(specs, packageManager, cwd)\n\n logInfo(`Updated ${specs.length} extension${plural}`)\n logOutro(styleText('green', 'Done'))\n } catch (error) {\n logError(getErrorMessage(error))\n process.exitCode = 1\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAsBA,eAAsB,IAAI,EAAE,KAAK,OAAO,OAAqC;CAC3E,MAAM,MAAM,QAAQ,IAAI;CACxB,SAAS,EAAE,OAAO,UAAU,UAAU,UAAU,SAAS,eAAe,CAAC,EAAE,CAAC;CAE5E,IAAI;EACF,MAAM,SAAS,IAAI,IAAI,IAAI,IAAI,YAAY,CAAC;EAC5C,MAAM,CAAC,SAAS,aAAa,MAAM,QAAQ,IAAI,CAAC,mBAAmB,EAAE,UAAU,YAAY,EAAE,CAAC,GAAG,sBAAsB,EAAE,MAAM,IAAI,CAAC,CAAC,CAAC;EACtI,MAAM,WAAW,IAAI,IAAI,UAAU,KAAK,SAAS,CAAC,KAAK,SAAS,KAAK,OAAO,CAAC,CAAC;EAE9E,MAAM,UAAU,QAAQ,QAAQ,UAAU,SAAS,IAAI,MAAM,SAAS,OAAO,MAAM,CAAC,OAAO,QAAQ,OAAO,IAAI,MAAM,EAAE,EAAE;EACxH,KAAK,MAAM,MAAM,QACf,IAAI,CAAC,QAAQ,MAAM,UAAU,MAAM,OAAO,EAAE,GAAG,QAAQ,GAAG,GAAG,2CAA2C;EAG1G,MAAM,YAAY,QAAQ,QAAQ,UAAU;GAC1C,IAAI,CAAC,WAAW;IAAE,WAAW,SAAS,IAAI,MAAM,SAAS,OAAO;IAAG,QAAQ,MAAM,SAAS;GAAQ,CAAC,GAAG,OAAO;GAC7G,MAAM,UAAU,gBAAgB,MAAM,QAAQ;GAC9C,IAAI,SAAS,QAAQ,WAAW,MAAM,GAAG,IAAI,SAAS;GACtD,OAAO,CAAC;EACV,CAAC;EAED,IAAI,CAAC,UAAU,QAAQ;GACrB,SAAS,IAAI,SAAS,kBAAkB,IAAI,KAAK,IAAI,EAAE,KAAK,0CAA0C;GACtG;EACF;EAEA,MAAM,SAAS,UAAU,WAAW,IAAI,KAAK;EAC7C,SACE,UAAU,KAAK,EAAE,eAAe,GAAG,SAAS,QAAQ,IAAI,SAAS,IAAI,SAAS,OAAO,KAAK,gBAAgB,MAAM,UAAU,SAAS,SAAS,OAAO,GAAG,CACxJ;EAEA,IAAI,OAAO;GACT,SAAS,GAAG,UAAU,OAAO,SAAS,OAAO,4CAA4C;GACzF;EACF;EAEA,MAAM,YAAY,OAAQ,MAAM,MAAM,QAAQ;GAAE,SAAS,WAAW,UAAU,OAAO,SAAS,OAAO;GAAI,cAAc;EAAK,CAAC;EAC7H,IAAI,MAAM,SAAS,SAAS,KAAK,CAAC,WAAW;GAC3C,MAAM,OAAO,qBAAqB;GAClC;EACF;EAEA,MAAM,iBAAiB,qBAAqB,GAAG;EAC/C,MAAM,QAAQ,UAAU,KAAK,EAAE,eAAe,YAAY,QAAQ,CAAC;EACnE,QAAQ,cAAc,MAAM,KAAK,IAAI,EAAE,QAAQ,eAAe,MAAM;EACpE,MAAM,gBAAgB,OAAO,gBAAgB,GAAG;EAEhD,QAAQ,WAAW,MAAM,OAAO,YAAY,QAAQ;EACpD,SAAS,UAAU,SAAS,MAAM,CAAC;CACrC,SAAS,OAAO;EACd,SAAS,gBAAgB,KAAK,CAAC;EAC/B,QAAQ,WAAW;CACrB;AACF"}
1
+ {"version":3,"file":"run-Dej-hm91.js","names":[],"sources":["../src/runners/update/run.ts"],"sourcesContent":["import process from 'node:process'\nimport { styleText } from 'node:util'\nimport * as clack from '@clack/prompts'\nimport { getErrorMessage } from '@internals/utils'\nimport { readInstalledPackages } from '@kubb/core'\nimport { logBlock, logError, logInfo, logIntro, logOutro, logStep, logWarn } from '../../loggers/output.ts'\nimport { fetchRegistryIndex, incompatibility, installSpec, isOutdated, registryUrl, toRegistryId } from '../../utils/registry.ts'\nimport { detectPackageManager, installPackages } from '../init/utils.ts'\n\nexport type UpdateOptions = {\n /**\n * Registry ids to update. Empty updates every installed extension the registry lists.\n */\n ids: Array<string>\n check: boolean\n yes: boolean\n}\n\n/**\n * Moves installed extensions to the version the registry pins. Lists the proposals, asks, then\n * installs them. With `check`, only lists them.\n */\nexport async function run({ ids, check, yes }: UpdateOptions): Promise<void> {\n const cwd = process.cwd()\n logIntro({ title: styleText('bgCyan', styleText('black', ' Kubb Update ')) })\n\n try {\n const wanted = new Set(ids.map(toRegistryId))\n const [entries, installed] = await Promise.all([fetchRegistryIndex({ registry: registryUrl() }), readInstalledPackages({ root: cwd })])\n const versions = new Map(installed.map((item) => [item.package, item.version]))\n\n const tracked = entries.filter((entry) => versions.has(entry.artifact.package) && (!wanted.size || wanted.has(entry.id)))\n for (const id of wanted) {\n if (!tracked.some((entry) => entry.id === id)) logWarn(`${id} is not installed, or not in the registry.`)\n }\n\n const proposals = tracked.filter((entry) => {\n if (!isOutdated({ installed: versions.get(entry.artifact.package), latest: entry.artifact.version })) return false\n const problem = incompatibility(entry.manifest)\n if (problem) logWarn(`Skipped ${entry.id}: ${problem}`)\n return !problem\n })\n\n if (!proposals.length) {\n logOutro(ids.length ? `No updates for ${ids.join(', ')}.` : 'Every installed extension is up to date.')\n return\n }\n\n const plural = proposals.length === 1 ? '' : 's'\n logBlock(\n proposals.map(({ artifact }) => `${artifact.package} ${versions.get(artifact.package) ?? 'not installed'} -> ${styleText('green', artifact.version)}`),\n )\n\n if (check) {\n logOutro(`${proposals.length} update${plural} available. Run \\`kubb update\\` to install.`)\n return\n }\n\n const confirmed = yes || (await clack.confirm({ message: `Install ${proposals.length} update${plural}?`, initialValue: true }))\n if (clack.isCancel(confirmed) || !confirmed) {\n clack.cancel('Operation canceled.')\n return\n }\n\n const packageManager = detectPackageManager(cwd)\n const specs = proposals.map(({ artifact }) => installSpec(artifact))\n logStep(`Installing ${specs.join(', ')} with ${packageManager.name}`)\n await installPackages(specs, packageManager, cwd)\n\n logInfo(`Updated ${specs.length} extension${plural}`)\n logOutro(styleText('green', 'Done'))\n } catch (error) {\n logError(getErrorMessage(error))\n process.exitCode = 1\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAsBA,eAAsB,IAAI,EAAE,KAAK,OAAO,OAAqC;CAC3E,MAAM,MAAM,QAAQ,IAAI;CACxB,SAAS,EAAE,OAAO,UAAU,UAAU,UAAU,SAAS,eAAe,CAAC,EAAE,CAAC;CAE5E,IAAI;EACF,MAAM,SAAS,IAAI,IAAI,IAAI,IAAI,YAAY,CAAC;EAC5C,MAAM,CAAC,SAAS,aAAa,MAAM,QAAQ,IAAI,CAAC,mBAAmB,EAAE,UAAU,YAAY,EAAE,CAAC,GAAG,sBAAsB,EAAE,MAAM,IAAI,CAAC,CAAC,CAAC;EACtI,MAAM,WAAW,IAAI,IAAI,UAAU,KAAK,SAAS,CAAC,KAAK,SAAS,KAAK,OAAO,CAAC,CAAC;EAE9E,MAAM,UAAU,QAAQ,QAAQ,UAAU,SAAS,IAAI,MAAM,SAAS,OAAO,MAAM,CAAC,OAAO,QAAQ,OAAO,IAAI,MAAM,EAAE,EAAE;EACxH,KAAK,MAAM,MAAM,QACf,IAAI,CAAC,QAAQ,MAAM,UAAU,MAAM,OAAO,EAAE,GAAG,QAAQ,GAAG,GAAG,2CAA2C;EAG1G,MAAM,YAAY,QAAQ,QAAQ,UAAU;GAC1C,IAAI,CAAC,WAAW;IAAE,WAAW,SAAS,IAAI,MAAM,SAAS,OAAO;IAAG,QAAQ,MAAM,SAAS;GAAQ,CAAC,GAAG,OAAO;GAC7G,MAAM,UAAU,gBAAgB,MAAM,QAAQ;GAC9C,IAAI,SAAS,QAAQ,WAAW,MAAM,GAAG,IAAI,SAAS;GACtD,OAAO,CAAC;EACV,CAAC;EAED,IAAI,CAAC,UAAU,QAAQ;GACrB,SAAS,IAAI,SAAS,kBAAkB,IAAI,KAAK,IAAI,EAAE,KAAK,0CAA0C;GACtG;EACF;EAEA,MAAM,SAAS,UAAU,WAAW,IAAI,KAAK;EAC7C,SACE,UAAU,KAAK,EAAE,eAAe,GAAG,SAAS,QAAQ,IAAI,SAAS,IAAI,SAAS,OAAO,KAAK,gBAAgB,MAAM,UAAU,SAAS,SAAS,OAAO,GAAG,CACxJ;EAEA,IAAI,OAAO;GACT,SAAS,GAAG,UAAU,OAAO,SAAS,OAAO,4CAA4C;GACzF;EACF;EAEA,MAAM,YAAY,OAAQ,MAAM,MAAM,QAAQ;GAAE,SAAS,WAAW,UAAU,OAAO,SAAS,OAAO;GAAI,cAAc;EAAK,CAAC;EAC7H,IAAI,MAAM,SAAS,SAAS,KAAK,CAAC,WAAW;GAC3C,MAAM,OAAO,qBAAqB;GAClC;EACF;EAEA,MAAM,iBAAiB,qBAAqB,GAAG;EAC/C,MAAM,QAAQ,UAAU,KAAK,EAAE,eAAe,YAAY,QAAQ,CAAC;EACnE,QAAQ,cAAc,MAAM,KAAK,IAAI,EAAE,QAAQ,eAAe,MAAM;EACpE,MAAM,gBAAgB,OAAO,gBAAgB,GAAG;EAEhD,QAAQ,WAAW,MAAM,OAAO,YAAY,QAAQ;EACpD,SAAS,UAAU,SAAS,MAAM,CAAC;CACrC,SAAS,OAAO;EACd,SAAS,gBAAgB,KAAK,CAAC;EAC/B,QAAQ,WAAW;CACrB;AACF"}
@@ -1,6 +1,6 @@
1
1
  const require_agent = require("./agent-DElUuYuy.cjs");
2
2
  const require_errors = require("./errors-BdA8M78q.cjs");
3
- const require_output = require("./output-CWupdozw.cjs");
3
+ const require_output = require("./output-BnK0scpX.cjs");
4
4
  const require_registry = require("./registry-DER9aRyg.cjs");
5
5
  let node_util = require("node:util");
6
6
  let node_process = require("node:process");
@@ -69,4 +69,4 @@ async function run() {
69
69
  //#endregion
70
70
  exports.run = run;
71
71
 
72
- //# sourceMappingURL=run-CnBJroZW.cjs.map
72
+ //# sourceMappingURL=run-DpAMfkm5.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"run-CnBJroZW.cjs","names":["readInstalledPackages","fetchRegistryIndex","getErrorMessage","isOutdated","process","registryUrl","styleText"],"sources":["../src/runners/list/run.ts"],"sourcesContent":["import process from 'node:process'\nimport { styleText } from 'node:util'\nimport { getErrorMessage } from '@internals/utils'\nimport { readInstalledPackages, type RegistryEntry } from '@kubb/core'\nimport { logBlock, logError, logOutro, logWarn } from '../../loggers/output.ts'\nimport { fetchRegistryIndex, isOutdated, registryUrl } from '../../utils/registry.ts'\n\nexport type ListRow = {\n id?: string\n package: string\n installed?: string\n registry?: string\n update: boolean\n}\n\n/**\n * The installed packages that ship a `kubb-extension.json` or have a registry entry, with the\n * version the registry pins.\n */\nexport async function listExtensions({ cwd, registry }: { cwd: string; registry: string }): Promise<Array<ListRow>> {\n const [installed, entries] = await Promise.all([\n readInstalledPackages({ root: cwd }),\n fetchRegistryIndex({ registry }).catch((error: unknown): Array<RegistryEntry> => {\n logWarn(`Showing installed extensions only: ${getErrorMessage(error)}`)\n return []\n }),\n ])\n const byPackage = new Map(entries.map((entry) => [entry.artifact.package, entry]))\n\n return installed.flatMap(({ package: name, version, manifest }): Array<ListRow> => {\n const entry = byPackage.get(name)\n if (!entry && !manifest) return []\n const latest = entry?.artifact.version\n return [{ id: entry?.id, package: name, installed: version, registry: latest, update: !!latest && isOutdated({ installed: version, latest }) }]\n })\n}\n\n/** Prints the installed extensions as a table. */\nexport async function run(): Promise<void> {\n try {\n const rows = await listExtensions({ cwd: process.cwd(), registry: registryUrl() })\n if (!rows.length) {\n logOutro('No installed extensions found.')\n return\n }\n\n const header = ['ID', 'PACKAGE', 'INSTALLED', 'REGISTRY', 'UPDATE']\n const cells = rows.map((row) => [row.id ?? '-', row.package, row.installed ?? '-', row.registry ?? '-', row.update ? 'yes' : 'no'])\n const widths = header.map((title, index) => Math.max(title.length, ...cells.map((cell) => cell[index]!.length)))\n const line = (cell: Array<string>) =>\n cell\n .map((value, index) => value.padEnd(widths[index]!))\n .join(' ')\n .trimEnd()\n\n logBlock([styleText('dim', line(header)), ...cells.map(line)])\n } catch (error) {\n logError(getErrorMessage(error))\n process.exitCode = 1\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAmBA,eAAsB,eAAe,EAAE,KAAK,YAAwE;CAClH,MAAM,CAAC,WAAW,WAAW,MAAM,QAAQ,IAAI,EAAA,GAC7CA,WAAAA,sBAAAA,CAAsB,EAAE,MAAM,IAAI,CAAC,GACnCC,iBAAAA,mBAAmB,EAAE,SAAS,CAAC,CAAC,CAAC,OAAO,UAAyC;EAC/E,eAAA,QAAQ,sCAAsCC,eAAAA,gBAAgB,KAAK,GAAG;EACtE,OAAO,CAAC;CACV,CAAC,CACH,CAAC;CACD,MAAM,YAAY,IAAI,IAAI,QAAQ,KAAK,UAAU,CAAC,MAAM,SAAS,SAAS,KAAK,CAAC,CAAC;CAEjF,OAAO,UAAU,SAAS,EAAE,SAAS,MAAM,SAAS,eAA+B;EACjF,MAAM,QAAQ,UAAU,IAAI,IAAI;EAChC,IAAI,CAAC,SAAS,CAAC,UAAU,OAAO,CAAC;EACjC,MAAM,SAAS,OAAO,SAAS;EAC/B,OAAO,CAAC;GAAE,IAAI,OAAO;GAAI,SAAS;GAAM,WAAW;GAAS,UAAU;GAAQ,QAAQ,CAAC,CAAC,UAAUC,iBAAAA,WAAW;IAAE,WAAW;IAAS;GAAO,CAAC;EAAE,CAAC;CAChJ,CAAC;AACH;;AAGA,eAAsB,MAAqB;CACzC,IAAI;EACF,MAAM,OAAO,MAAM,eAAe;GAAE,KAAKC,aAAAA,QAAQ,IAAI;GAAG,UAAUC,iBAAAA,YAAY;EAAE,CAAC;EACjF,IAAI,CAAC,KAAK,QAAQ;GAChB,eAAA,SAAS,gCAAgC;GACzC;EACF;EAEA,MAAM,SAAS;GAAC;GAAM;GAAW;GAAa;GAAY;EAAQ;EAClE,MAAM,QAAQ,KAAK,KAAK,QAAQ;GAAC,IAAI,MAAM;GAAK,IAAI;GAAS,IAAI,aAAa;GAAK,IAAI,YAAY;GAAK,IAAI,SAAS,QAAQ;EAAI,CAAC;EAClI,MAAM,SAAS,OAAO,KAAK,OAAO,UAAU,KAAK,IAAI,MAAM,QAAQ,GAAG,MAAM,KAAK,SAAS,KAAK,MAAM,CAAE,MAAM,CAAC,CAAC;EAC/G,MAAM,QAAQ,SACZ,KACG,KAAK,OAAO,UAAU,MAAM,OAAO,OAAO,MAAO,CAAC,CAAC,CACnD,KAAK,IAAI,CAAC,CACV,QAAQ;EAEb,eAAA,SAAS,EAAA,GAACC,UAAAA,UAAAA,CAAU,OAAO,KAAK,MAAM,CAAC,GAAG,GAAG,MAAM,IAAI,IAAI,CAAC,CAAC;CAC/D,SAAS,OAAO;EACd,eAAA,SAASJ,eAAAA,gBAAgB,KAAK,CAAC;EAC/B,aAAA,QAAA,WAAmB;CACrB;AACF"}
1
+ {"version":3,"file":"run-DpAMfkm5.cjs","names":["readInstalledPackages","fetchRegistryIndex","getErrorMessage","isOutdated","process","registryUrl","styleText"],"sources":["../src/runners/list/run.ts"],"sourcesContent":["import process from 'node:process'\nimport { styleText } from 'node:util'\nimport { getErrorMessage } from '@internals/utils'\nimport { readInstalledPackages, type RegistryEntry } from '@kubb/core'\nimport { logBlock, logError, logOutro, logWarn } from '../../loggers/output.ts'\nimport { fetchRegistryIndex, isOutdated, registryUrl } from '../../utils/registry.ts'\n\nexport type ListRow = {\n id?: string\n package: string\n installed?: string\n registry?: string\n update: boolean\n}\n\n/**\n * The installed packages that ship a `kubb-extension.json` or have a registry entry, with the\n * version the registry pins.\n */\nexport async function listExtensions({ cwd, registry }: { cwd: string; registry: string }): Promise<Array<ListRow>> {\n const [installed, entries] = await Promise.all([\n readInstalledPackages({ root: cwd }),\n fetchRegistryIndex({ registry }).catch((error: unknown): Array<RegistryEntry> => {\n logWarn(`Showing installed extensions only: ${getErrorMessage(error)}`)\n return []\n }),\n ])\n const byPackage = new Map(entries.map((entry) => [entry.artifact.package, entry]))\n\n return installed.flatMap(({ package: name, version, manifest }): Array<ListRow> => {\n const entry = byPackage.get(name)\n if (!entry && !manifest) return []\n const latest = entry?.artifact.version\n return [{ id: entry?.id, package: name, installed: version, registry: latest, update: !!latest && isOutdated({ installed: version, latest }) }]\n })\n}\n\n/** Prints the installed extensions as a table. */\nexport async function run(): Promise<void> {\n try {\n const rows = await listExtensions({ cwd: process.cwd(), registry: registryUrl() })\n if (!rows.length) {\n logOutro('No installed extensions found.')\n return\n }\n\n const header = ['ID', 'PACKAGE', 'INSTALLED', 'REGISTRY', 'UPDATE']\n const cells = rows.map((row) => [row.id ?? '-', row.package, row.installed ?? '-', row.registry ?? '-', row.update ? 'yes' : 'no'])\n const widths = header.map((title, index) => Math.max(title.length, ...cells.map((cell) => cell[index]!.length)))\n const line = (cell: Array<string>) =>\n cell\n .map((value, index) => value.padEnd(widths[index]!))\n .join(' ')\n .trimEnd()\n\n logBlock([styleText('dim', line(header)), ...cells.map(line)])\n } catch (error) {\n logError(getErrorMessage(error))\n process.exitCode = 1\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAmBA,eAAsB,eAAe,EAAE,KAAK,YAAwE;CAClH,MAAM,CAAC,WAAW,WAAW,MAAM,QAAQ,IAAI,EAAA,GAC7CA,WAAAA,sBAAAA,CAAsB,EAAE,MAAM,IAAI,CAAC,GACnCC,iBAAAA,mBAAmB,EAAE,SAAS,CAAC,CAAC,CAAC,OAAO,UAAyC;EAC/E,eAAA,QAAQ,sCAAsCC,eAAAA,gBAAgB,KAAK,GAAG;EACtE,OAAO,CAAC;CACV,CAAC,CACH,CAAC;CACD,MAAM,YAAY,IAAI,IAAI,QAAQ,KAAK,UAAU,CAAC,MAAM,SAAS,SAAS,KAAK,CAAC,CAAC;CAEjF,OAAO,UAAU,SAAS,EAAE,SAAS,MAAM,SAAS,eAA+B;EACjF,MAAM,QAAQ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ALX.js";
3
- import { n as trackRun } from "./Telemetry-BivZAaw9.js";
3
+ import { n as trackRun } from "./Telemetry-DER8LIO5.js";
4
4
  import { styleText } from "node:util";
5
5
  import process from "node:process";
6
6
  //#region src/runners/mcp/run.ts
@@ -27,4 +27,4 @@ async function run() {
27
27
  //#endregion
28
28
  export { run };
29
29
 
30
- //# sourceMappingURL=run-ajUuT3vK.js.map
30
+ //# sourceMappingURL=run-KLPSFEv-.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"run-ajUuT3vK.js","names":[],"sources":["../src/runners/mcp/run.ts"],"sourcesContent":["import process from 'node:process'\nimport { styleText } from 'node:util'\nimport { toError } from '@internals/utils'\nimport type * as McpModule from '@kubb/mcp'\nimport { trackRun } from '../../Telemetry.ts'\n\n/**\n * Starts the `@kubb/mcp` server over stdio and reports the outcome to telemetry.\n */\nexport async function run(): Promise<void> {\n const { run: startMcpServer } = (await import('@kubb/mcp')) as typeof McpModule\n\n const report = trackRun({ command: 'mcp', hrStart: process.hrtime() })\n\n try {\n // The MCP stdio transport owns stdout: anything else written there corrupts the JSON-RPC stream.\n console.error(styleText('cyan', '⏳ Starting MCP server...'))\n console.warn(styleText('yellow', 'This feature is still under development, use with caution'))\n await startMcpServer()\n await report({ status: 'success' })\n } catch (error) {\n await report({ status: 'failed' })\n console.error(toError(error).message)\n process.exitCode = 1\n }\n}\n"],"mappings":";;;;;;;;;AASA,eAAsB,MAAqB;CACzC,MAAM,EAAE,KAAK,mBAAoB,MAAM,OAAO;CAE9C,MAAM,SAAS,SAAS;EAAE,SAAS;EAAO,SAAS,QAAQ,OAAO;CAAE,CAAC;CAErE,IAAI;EAEF,QAAQ,MAAM,UAAU,QAAQ,0BAA0B,CAAC;EAC3D,QAAQ,KAAK,UAAU,UAAU,2DAA2D,CAAC;EAC7F,MAAM,eAAe;EACrB,MAAM,OAAO,EAAE,QAAQ,UAAU,CAAC;CACpC,SAAS,OAAO;EACd,MAAM,OAAO,EAAE,QAAQ,SAAS,CAAC;EACjC,QAAQ,MAAM,QAAQ,KAAK,CAAC,CAAC,OAAO;EACpC,QAAQ,WAAW;CACrB;AACF"}
1
+ {"version":3,"file":"run-KLPSFEv-.js","names":[],"sources":["../src/runners/mcp/run.ts"],"sourcesContent":["import process from 'node:process'\nimport { styleText } from 'node:util'\nimport { toError } from '@internals/utils'\nimport type * as McpModule from '@kubb/mcp'\nimport { trackRun } from '../../Telemetry.ts'\n\n/**\n * Starts the `@kubb/mcp` server over stdio and reports the outcome to telemetry.\n */\nexport async function run(): Promise<void> {\n const { run: startMcpServer } = (await import('@kubb/mcp')) as typeof McpModule\n\n const report = trackRun({ command: 'mcp', hrStart: process.hrtime() })\n\n try {\n // The MCP stdio transport owns stdout: anything else written there corrupts the JSON-RPC stream.\n console.error(styleText('cyan', '⏳ Starting MCP server...'))\n console.warn(styleText('yellow', 'This feature is still under development, use with caution'))\n await startMcpServer()\n await report({ status: 'success' })\n } catch (error) {\n await report({ status: 'failed' })\n console.error(toError(error).message)\n process.exitCode = 1\n }\n}\n"],"mappings":";;;;;;;;;AASA,eAAsB,MAAqB;CACzC,MAAM,EAAE,KAAK,mBAAoB,MAAM,OAAO;CAE9C,MAAM,SAAS,SAAS;EAAE,SAAS;EAAO,SAAS,QAAQ,OAAO;CAAE,CAAC;CAErE,IAAI;EAEF,QAAQ,MAAM,UAAU,QAAQ,0BAA0B,CAAC;EAC3D,QAAQ,KAAK,UAAU,UAAU,2DAA2D,CAAC;EAC7F,MAAM,eAAe;EACrB,MAAM,OAAO,EAAE,QAAQ,UAAU,CAAC;CACpC,SAAS,OAAO;EACd,MAAM,OAAO,EAAE,QAAQ,SAAS,CAAC;EACjC,QAAQ,MAAM,QAAQ,KAAK,CAAC,CAAC,OAAO;EACpC,QAAQ,WAAW;CACrB;AACF"}
@@ -1,6 +1,6 @@
1
1
  const require_agent = require("./agent-DElUuYuy.cjs");
2
2
  const require_errors = require("./errors-BdA8M78q.cjs");
3
- const require_Telemetry = require("./Telemetry-D1jiXfo2.cjs");
3
+ const require_Telemetry = require("./Telemetry-B_C4MVJd.cjs");
4
4
  let node_util = require("node:util");
5
5
  let node_process = require("node:process");
6
6
  node_process = require_agent.__toESM(node_process, 1);
@@ -16,9 +16,7 @@ async function run({ input }) {
16
16
  });
17
17
  try {
18
18
  const { adapterOas } = await import("@kubb/adapter-oas");
19
- const adapter = adapterOas();
20
- if (!adapter.validate) throw new Error("The loaded adapter does not support validation.");
21
- await adapter.validate(input, { throwOnError: true });
19
+ await adapterOas().validate(input, { throwOnError: true });
22
20
  await report({ status: "success" });
23
21
  console.log("✅ Validation success");
24
22
  } catch (error) {
@@ -40,4 +38,4 @@ async function run({ input }) {
40
38
  //#endregion
41
39
  exports.run = run;
42
40
 
43
- //# sourceMappingURL=run-DfkvTomI.cjs.map
41
+ //# sourceMappingURL=run-e8gMz1M_.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-e8gMz1M_.cjs","names":["trackRun","process","styleText","toError"],"sources":["../src/runners/validate/run.ts"],"sourcesContent":["import process from 'node:process'\nimport { styleText } from 'node:util'\nimport { toError } from '@internals/utils'\nimport { trackRun } from '../../Telemetry.ts'\n\ntype ValidateOptions = {\n /**\n * Path or URL to the OpenAPI/Swagger file to validate.\n */\n input: string\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 }: ValidateOptions): Promise<void> {\n const report = trackRun({ command: 'validate', hrStart: process.hrtime() })\n\n try {\n const { adapterOas } = await import('@kubb/adapter-oas')\n\n await adapterOas().validate(input, { throwOnError: true })\n await report({ status: 'success' })\n\n console.log('✅ Validation success')\n } catch (error) {\n await report({ status: '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(toError(error).message)\n\n process.exit(1)\n }\n}\n"],"mappings":";;;;;;;;;;;AAgBA,eAAsB,IAAI,EAAE,SAAyC;CACnE,MAAM,SAASA,kBAAAA,SAAS;EAAE,SAAS;EAAY,SAASC,aAAAA,QAAQ,OAAO;CAAE,CAAC;CAE1E,IAAI;EACF,MAAM,EAAE,eAAe,MAAM,OAAO;EAEpC,MAAM,WAAW,CAAC,CAAC,SAAS,OAAO,EAAE,cAAc,KAAK,CAAC;EACzD,MAAM,OAAO,EAAE,QAAQ,UAAU,CAAC;EAElC,QAAQ,IAAI,sBAAsB;CACpC,SAAS,OAAO;EACd,MAAM,OAAO,EAAE,QAAQ,SAAS,CAAC;EACjC,IAAI,iBAAiB,SAAS,qBAAqB,KAAK,MAAM,OAAO,GAAG;GACtE,QAAQ,OAAA,GAAMC,UAAAA,UAAAA,CAAU,OAAO,iDAAiD,CAAC;GACjF,QAAQ,MAAM,EAAE;GAChB,QAAQ,MAAM,kBAAkB;GAChC,QAAQ,OAAA,GAAMA,UAAAA,UAAAA,CAAU,QAAQ,iCAAiC,CAAC;GAClE,QAAQ,OAAA,GAAMA,UAAAA,UAAAA,CAAU,QAAQ,QAAQ,CAAC;GACzC,QAAQ,OAAA,GAAMA,UAAAA,UAAAA,CAAU,QAAQ,kCAAkC,CAAC;GACnE,QAAQ,MAAM,EAAE;EAClB;EACA,QAAQ,MAAM,qBAAqB;EACnC,QAAQ,MAAMC,eAAAA,QAAQ,KAAK,CAAC,CAAC,OAAO;EAEpC,aAAA,QAAQ,KAAK,CAAC;CAChB;AACF"}
@@ -1,16 +1,16 @@
1
1
  const require_agent = require("./agent-DElUuYuy.cjs");
2
2
  const require_errors = require("./errors-BdA8M78q.cjs");
3
- const require_Telemetry = require("./Telemetry-D1jiXfo2.cjs");
4
- const require_config = require("./config-CRBZcWwg.cjs");
5
- const require_output = require("./output-CWupdozw.cjs");
6
- const require_reporters = require("./reporters-C5HAypFq.cjs");
3
+ const require_Telemetry = require("./Telemetry-B_C4MVJd.cjs");
4
+ const require_config = require("./config-Bo9ro7vg.cjs");
5
+ const require_output = require("./output-BnK0scpX.cjs");
6
+ const require_registry = require("./registry-DER9aRyg.cjs");
7
+ const require_reporters = require("./reporters-B4rZOlo8.cjs");
7
8
  let node_util = require("node:util");
8
9
  let node_process = require("node:process");
9
10
  node_process = require_agent.__toESM(node_process, 1);
10
11
  let node_path = require("node:path");
11
12
  node_path = require_agent.__toESM(node_path, 1);
12
13
  let _kubb_core = require("@kubb/core");
13
- let verkit = require("verkit");
14
14
  //#region src/runners/generate/utils.ts
15
15
  /** Glob pattern for paths the file watcher ignores. */
16
16
  const WATCHER_IGNORED_PATHS = "**/{.git,node_modules}/**";
@@ -24,21 +24,6 @@ const URL_WATCHER_INTERVAL_MS = 2e3;
24
24
  /** Upper bound in milliseconds for one URL watcher request, headers and body read, so a hung server never stalls polling. */
25
25
  const URL_WATCHER_TIMEOUT_MS = 1e4;
26
26
  /**
27
- * Returns `true` when `latest` is a newer semver version than `current`. Compares each numeric
28
- * part, so `5.10.0` beats `5.9.0` where a plain string comparison would not. Prerelease
29
- * suffixes are ignored, and a malformed version never reports an update.
30
- *
31
- * @example Double-digit minor
32
- * `isNewerVersion('5.9.0', '5.10.0') // true`
33
- *
34
- * @example String comparison would get this wrong the other way
35
- * `isNewerVersion('5.10.0', '5.9.0') // false`
36
- */
37
- function isNewerVersion(current, latest) {
38
- if (!(0, verkit.isValid)(current) || !(0, verkit.isValid)(latest)) return false;
39
- return (0, verkit.isGreaterThan)((0, verkit.truncate)(latest, "patch"), (0, verkit.truncate)(current, "patch"));
40
- }
41
- /**
42
27
  * Wraps `run` so invocations never overlap: a trigger that lands while a run is in flight
43
28
  * marks it dirty and runs once more after it finishes, no matter how many triggers arrived.
44
29
  * Useful for event-driven reruns (a file watcher, a queue drain) where bursts should
@@ -230,7 +215,10 @@ async function generate(options) {
230
215
  async function checkForUpdate(hooks) {
231
216
  try {
232
217
  const data = await (await fetch(KUBB_NPM_PACKAGE_URL, { signal: AbortSignal.timeout(UPDATE_CHECK_TIMEOUT_MS) })).json();
233
- if (data.version && isNewerVersion(require_Telemetry.version, data.version)) await _kubb_core.Diagnostics.emit(hooks, _kubb_core.Diagnostics.update({
218
+ if (data.version && require_registry.isOutdated({
219
+ installed: require_Telemetry.version,
220
+ latest: data.version
221
+ })) await _kubb_core.Diagnostics.emit(hooks, _kubb_core.Diagnostics.update({
234
222
  currentVersion: require_Telemetry.version,
235
223
  latestVersion: data.version
236
224
  }));
@@ -350,4 +338,4 @@ async function run({ input, configPath, logLevel: logLevelKey, watch, reporters:
350
338
  //#endregion
351
339
  exports.run = run;
352
340
 
353
- //# sourceMappingURL=run-CNXBX4kr.cjs.map
341
+ //# sourceMappingURL=run-fg0ycsS_.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-fg0ycsS_.cjs","names":["toError","styleText","trackRun","process","memoryStorage","createKubb","isOutdated","version","Diagnostics","logLevelMap","Hookable","createSpinner","getConfigs","styleText","path","cliReporter","toError","jsonReporter","fileReporter","htmlReporter","selectReporters","pluralize","getInputKind","logInfo","logError"],"sources":["../src/runners/generate/utils.ts","../src/runners/generate/run.ts"],"sourcesContent":["import process from 'node:process'\nimport { styleText } from 'node:util'\nimport { toError } from '@internals/utils'\n\n/** Glob pattern for paths the file watcher ignores. */\nconst WATCHER_IGNORED_PATHS = '**/{.git,node_modules}/**' as const\n\n/**\n * Quiet window in milliseconds that collapses a burst of watcher events (an editor save emits several) into one rebuild.\n * It outlasts chokidar's 100 ms atomic-save window, which holds back the event of a write-then-rename save.\n */\nconst WATCHER_DEBOUNCE_MS = 250\n\n/** Interval in milliseconds between polls of a remote `input` URL in watch mode, which emits no filesystem events. */\nconst URL_WATCHER_INTERVAL_MS = 2_000\n\n/** Upper bound in milliseconds for one URL watcher request, headers and body read, so a hung server never stalls polling. */\nconst URL_WATCHER_TIMEOUT_MS = 10_000\n\ntype SerialRunnerOptions = {\n /**\n * The async work to serialize.\n */\n run(): Promise<void>\n /**\n * Receives errors thrown by `run`, so a failure never rejects the returned trigger.\n */\n onError(error: Error): void\n}\n\n/**\n * Wraps `run` so invocations never overlap: a trigger that lands while a run is in flight\n * marks it dirty and runs once more after it finishes, no matter how many triggers arrived.\n * Useful for event-driven reruns (a file watcher, a queue drain) where bursts should\n * coalesce into a single trailing run.\n *\n * @example\n * ```ts\n * const rebuild = createSerialRunner({\n * run: () => build(),\n * onError: (error) => log.error(error.message),\n * })\n * watcher.on('change', () => void rebuild())\n * ```\n */\nexport function createSerialRunner({ run, onError }: SerialRunnerOptions): () => Promise<void> {\n let running = false\n let dirty = false\n\n return async (): Promise<void> => {\n if (running) {\n dirty = true\n return\n }\n running = true\n do {\n dirty = false\n try {\n await run()\n } catch (error) {\n onError(toError(error))\n }\n } while (dirty)\n running = false\n }\n}\n\ntype WatcherLog = {\n info: (message: string) => void\n error: (message: string) => void\n}\n\n/**\n * Starts a file watcher on the given paths and calls `cb` on any change.\n * Ignores `.git` and `node_modules` directories. Event bursts (an editor save emits several)\n * are debounced into one build, and builds never overlap: changes during a build queue exactly\n * one rebuild. Resolves to a function that stops watching.\n */\nexport async function startWatcher(\n path: Array<string>,\n cb: (path: Array<string>) => Promise<void>,\n log: WatcherLog = { info: console.log, error: console.log },\n): Promise<() => Promise<void>> {\n const { watch } = await import('chokidar')\n // `ignoreInitial` skips the `add` events chokidar fires for existing files at startup, which\n // would otherwise rebuild right after the initial run.\n const watcher = watch(path, { ignorePermissionErrors: true, ignored: WATCHER_IGNORED_PATHS, ignoreInitial: true })\n\n process.once('SIGINT', () => {\n watcher.close()\n })\n process.once('SIGTERM', () => {\n watcher.close()\n })\n\n // Bursts never overlap builds on the shared hooks emitter: a change during a build\n // queues exactly one rerun.\n const runBuild = createSerialRunner({\n run: () => cb(path),\n onError: () => log.error(styleText('red', 'Watcher failed')),\n })\n let debounceTimer: ReturnType<typeof setTimeout> | null = null\n\n watcher.on('all', (type, file) => {\n log.info(styleText('yellow', styleText('bold', `Change detected: ${type} ${file}`)))\n if (debounceTimer) clearTimeout(debounceTimer)\n debounceTimer = setTimeout(() => {\n debounceTimer = null\n void runBuild()\n }, WATCHER_DEBOUNCE_MS)\n })\n\n return async () => {\n if (debounceTimer) clearTimeout(debounceTimer)\n await watcher.close()\n }\n}\n\n/**\n * Fetches the body of a remote spec URL, `undefined` when the server does not answer with a\n * readable 2xx body before `signal` aborts. The caller seeds `startUrlWatcher` with the result, so\n * the watcher compares polls against the content the initial build ran on.\n */\nexport async function fetchUrlBody(url: string, signal: AbortSignal = AbortSignal.timeout(URL_WATCHER_TIMEOUT_MS)): Promise<string | undefined> {\n try {\n const response = await fetch(url, { signal })\n if (!response.ok) return undefined\n return await response.text()\n } catch {\n return undefined\n }\n}\n\ntype UrlWatcherOptions = {\n /**\n * Sink for watcher messages, `console.log` by default.\n */\n log?: WatcherLog\n /**\n * Time in milliseconds between polls.\n */\n intervalMs?: number\n /**\n * Upper bound in milliseconds for one poll request, covering headers and body read.\n */\n timeoutMs?: number\n /**\n * Body the initial build ran against, the baseline for change detection. When omitted (the\n * server was unreachable at startup), the first successful poll rebuilds so the output catches\n * up as soon as the server responds.\n */\n initialBody?: string\n}\n\n/**\n * Polls a remote spec URL and calls `cb` whenever the response body changes. A remote document\n * emits no filesystem events, so this is the URL counterpart of `startWatcher`.\n *\n * `initialBody` seeds the change detection, so an edit landing between the initial build and the\n * first poll still rebuilds. An unreachable server (the API restarting between saves) is reported\n * once per outage and polling continues; after it recovers, a rebuild happens only when the body\n * actually differs from the last one seen, so a plain restart with an unchanged spec stays quiet.\n * Each request is aborted after `timeoutMs`, so a hung response delays at most one poll.\n *\n * Returns a function that stops polling and aborts the in-flight request, so callers (and tests)\n * can shut the watcher down without signaling the process.\n */\nexport function startUrlWatcher(url: string, cb: (path: Array<string>) => Promise<void>, options: UrlWatcherOptions = {}): () => void {\n const { log = { info: console.log, error: console.log }, intervalMs = URL_WATCHER_INTERVAL_MS, timeoutMs = URL_WATCHER_TIMEOUT_MS, initialBody } = options\n\n let lastBody = initialBody\n let offline = false\n let timer: ReturnType<typeof setTimeout> | null = null\n let controller: AbortController | null = null\n let stopped = false\n\n const stop = () => {\n stopped = true\n if (timer) clearTimeout(timer)\n controller?.abort()\n }\n process.once('SIGINT', stop)\n process.once('SIGTERM', stop)\n\n // Builds never overlap on the shared hooks emitter: a change during a build queues exactly\n // one rerun.\n const runBuild = createSerialRunner({\n run: () => cb([url]),\n onError: () => log.error(styleText('red', 'Watcher failed')),\n })\n\n const schedule = () => {\n if (!stopped) {\n timer = setTimeout(() => void poll(), intervalMs)\n }\n }\n\n const poll = async (): Promise<void> => {\n controller = new AbortController()\n // The signal also aborts the body read, so a response that stalls mid-stream still times out.\n const body = await fetchUrlBody(url, AbortSignal.any([controller.signal, AbortSignal.timeout(timeoutMs)]))\n\n if (body === undefined) {\n // `lastBody` survives the outage so recovery rebuilds only on real content changes.\n if (!offline && !stopped) {\n offline = true\n log.error(styleText('red', `Cannot reach ${url}, polling until it responds again`))\n }\n schedule()\n return\n }\n\n if (offline) {\n offline = false\n log.info(styleText('yellow', `${url} is reachable again`))\n }\n const changed = lastBody !== undefined && body !== lastBody\n if (changed) {\n log.info(styleText('yellow', styleText('bold', `Change detected: ${url}`)))\n }\n if (changed || lastBody === undefined) {\n void runBuild()\n }\n lastBody = body\n schedule()\n }\n\n void poll()\n\n return stop\n}\n","import path from 'node:path'\nimport process from 'node:process'\nimport { styleText } from 'node:util'\nimport { formatters, linters, toError } from '@internals/utils'\nimport {\n Hookable,\n type CLIOptions,\n cliReporter,\n type Config,\n createKubb,\n Diagnostics,\n fileReporter,\n getInputKind,\n htmlReporter,\n jsonReporter,\n type KubbHooks,\n logLevel as logLevelMap,\n memoryStorage,\n type ReporterName,\n} from '@kubb/core'\nimport { version } from '../../../package.json'\nimport { trackRun } from '../../Telemetry.ts'\nimport { pluralize } from '../../loggers/createLogger.ts'\nimport setupReporters, { selectReporters } from '../../loggers/reporters.ts'\nimport { createSpinner, logBanner, logError, logInfo, logIntro, logOutro, logSpacer, logStep, logTip } from '../../loggers/output.ts'\nimport { getConfigs } from '../../config.ts'\nimport { isOutdated } from '../../utils/registry.ts'\nimport { fetchUrlBody, startUrlWatcher, startWatcher } from './utils.ts'\n\n/** NPM registry endpoint used to check for @kubb/cli updates. */\nconst KUBB_NPM_PACKAGE_URL = 'https://registry.npmjs.org/@kubb/cli/latest' as const\n\n/** Upper bound in milliseconds for the npm update check, so a slow registry never stalls a run. */\nconst UPDATE_CHECK_TIMEOUT_MS = 3_000\n\n/** The formatter names from `Config['output'].format`, without `'auto'` (detection, not a tool) and `false` (skip). */\ntype FormatterName = Exclude<NonNullable<Config['output']['format']>, 'auto' | false>\ntype LinterName = Exclude<NonNullable<Config['output']['lint']>, 'auto' | false>\n\n// Pinned here, not in `@internals/utils` (which must not import `@kubb/core`): a tool added to the union without a descriptor fails to compile.\nformatters satisfies Record<FormatterName, unknown>\nlinters satisfies Record<LinterName, unknown>\n\ntype GenerateProps = {\n input?: string\n config: Config\n hooks: Hookable<KubbHooks>\n /**\n * When `true`, generates in memory instead of writing to disk, and skips formatting, linting,\n * and post-generate commands.\n */\n dryRun?: boolean\n}\n\nasync function generate(options: GenerateProps): Promise<boolean> {\n const { input, hooks, dryRun = false } = options\n\n const report = trackRun({ command: 'generate', hrStart: process.hrtime() })\n\n const config: Config = {\n ...options.config,\n input: input ?? options.config.input,\n // Dry-run never touches disk, regardless of the config's own storage driver.\n storage: dryRun ? memoryStorage() : options.config.storage,\n // Also keeps core's `hasOutputPasses` false, so dry-run skips the output manifest write too.\n output: dryRun ? { ...options.config.output, format: false, lint: false, postGenerate: [] } : options.config.output,\n }\n\n // Core formats, lints and runs `output.postGenerate` after an error-free build, and reports\n // their failures as coded diagnostics that reach the summary, the json report and the exit code.\n const kubb = createKubb(config, { hooks })\n const result = await kubb.generate()\n\n if (dryRun) {\n await hooks.callHook('kubb:info', { message: 'Dry run: no files were written', info: `${result.files.length} file(s) would be generated` })\n }\n\n await report({\n plugins: Array.from(kubb.driver.plugins.values(), (p) => ({ name: p.name, options: p.options as Record<string, unknown> })),\n filesCreated: result.files.length,\n status: result.success ? 'success' : 'failed',\n })\n\n return result.success\n}\n\ntype GenerateCommandOptions = {\n input?: string\n configPath?: string\n logLevel: string\n watch: boolean\n reporters?: Array<ReporterName>\n dryRun?: boolean\n}\n\nasync function checkForUpdate(hooks: Hookable<KubbHooks>): Promise<void> {\n try {\n const res = await fetch(KUBB_NPM_PACKAGE_URL, { signal: AbortSignal.timeout(UPDATE_CHECK_TIMEOUT_MS) })\n const data = (await res.json()) as { version: string }\n if (data.version && isOutdated({ installed: version, latest: data.version })) {\n await Diagnostics.emit(hooks, Diagnostics.update({ currentVersion: version, latestVersion: data.version }))\n }\n } catch {\n // Ignore network errors\n }\n}\n\n/**\n * Runs the full Kubb generation lifecycle for the given CLI options.\n * Loads configs, sets up the reporters (CLI `--reporter` picks which of `config.reporters` to trigger),\n * checks for a newer version, and calls `generate` for each config entry.\n */\nexport async function run({ input, configPath, logLevel: logLevelKey, watch, reporters: cliReporters, dryRun }: GenerateCommandOptions): Promise<void> {\n const logLevel = logLevelMap[logLevelKey as keyof typeof logLevelMap] ?? logLevelMap.info\n const hooks = new Hookable<KubbHooks>()\n\n // CLI `--reporter` selects which reporters to trigger by name, defaulting to `cli`. `defineConfig`\n // registers the built-in reporters on the config; a config exported without it falls back to them below.\n const requestedNames: Array<ReporterName> = cliReporters?.length ? cliReporters : ['cli']\n\n // The `json` reporter owns stdout, so the command writes nothing of its own around it.\n const quiet = logLevel <= logLevelMap.silent || requestedNames.includes('json')\n\n if (!quiet) {\n logBanner(version)\n logIntro({ title: 'Configuration' })\n }\n\n // Load the config first so `config.reporters` can pick the reporters. A failure here has no\n // reporter installed yet, so fall back to the default `cli` reporter to surface it.\n const configSpinner = createSpinner()\n let configs: Array<Config>\n let resolvedConfigPath: string\n try {\n if (!quiet) configSpinner.start('Loading config')\n\n const loaded = await getConfigs({\n configPath,\n input,\n watch,\n logLevel: logLevelKey as CLIOptions['logLevel'],\n })\n configs = loaded.configs\n resolvedConfigPath = loaded.configPath\n\n if (!quiet) configSpinner.stop(`Loaded ${styleText('dim', path.relative(process.cwd(), resolvedConfigPath))}`)\n } catch (error) {\n if (!quiet) configSpinner.error('Config failed loading')\n\n setupReporters(hooks, { logLevel, reporters: [cliReporter] })\n // A diagnostic thrown while the config file runs, such as invalid extension options, sits in the cause chain.\n const diagnostic = Diagnostics.from(error)\n await (diagnostic.code === Diagnostics.code.unknown ? hooks.callHook('kubb:error', { error: toError(error) }) : Diagnostics.emit(hooks, diagnostic))\n\n if (!quiet) logOutro(styleText('red', '✗ Configuration failed'))\n process.exit(1)\n }\n\n // Without a reporter nothing is printed, not even an error, so a config written without\n // `defineConfig` gets the same built-ins it would have registered.\n const available = configs[0]?.reporters?.length ? configs[0].reporters : [cliReporter, jsonReporter, fileReporter, htmlReporter]\n const reporters = selectReporters(available, requestedNames)\n setupReporters(hooks, { logLevel, reporters })\n\n await hooks.callHook('kubb:lifecycle:start', { version })\n\n // Inside the bootstrap group, so an update notice reads as part of the setup rather than as part\n // of the first config's generation.\n await checkForUpdate(hooks)\n\n if (!quiet) logOutro(`${pluralize(configs.length, 'config')} ready`)\n\n try {\n let anyFailed = false\n for (const config of configs) {\n const effectiveInput = input ?? config.input\n const inputKind = typeof effectiveInput === 'string' ? getInputKind(effectiveInput) : undefined\n const watchPath = inputKind === 'file' || inputKind === 'url' ? (effectiveInput as string) : undefined\n if (watchPath && watch) {\n const watchedPaths = [watchPath]\n // Don't removeAll() between builds, that would also drop logger and lifecycle\n // listeners. Plugin listeners are already disposed by safeBuild's dispose()\n // in its finally block, so re-running generate() on the same hooks emitter is safe.\n const build = async (paths: Array<string>) => {\n const succeeded = await generate({ input, config, hooks, dryRun })\n logStep(styleText('yellow', `Watching for changes in ${paths.join(' and ')}`))\n if (succeeded) {\n logSpacer()\n logTip()\n }\n }\n\n // For a URL input, capture the document before the build: it becomes the watcher's\n // change-detection baseline, so an edit landing before the first poll still rebuilds.\n // When the server is down the baseline stays undefined and the watcher rebuilds on its\n // first successful poll, so recovery with an unchanged document still generates output.\n const initialBody = inputKind === 'url' ? await fetchUrlBody(watchPath) : undefined\n\n // The watchers ignore their startup state, so run the first build here; a failing one keeps watching so the user can fix the input.\n try {\n await build(watchedPaths)\n } catch (buildError) {\n await hooks.callHook('kubb:error', { error: toError(buildError) })\n }\n\n if (inputKind === 'url') {\n startUrlWatcher(watchPath, build, { log: { info: logInfo, error: logError }, initialBody })\n } else {\n await startWatcher(watchedPaths, build, { info: logInfo, error: logError })\n }\n } else {\n try {\n const succeeded = await generate({ input, config, hooks, dryRun })\n if (!succeeded) anyFailed = true\n } catch (configError) {\n await hooks.callHook('kubb:error', { error: toError(configError) })\n anyFailed = true\n }\n }\n }\n\n await hooks.callHook('kubb:lifecycle:end')\n\n // Watch mode prints a tip after each successful build. Regular generate commands need to\n // print one explicitly after the lifecycle group has closed so it stays outside the group.\n if (!quiet && !watch && !anyFailed) {\n logTip()\n }\n\n if (anyFailed) {\n process.exit(1)\n }\n } catch (error) {\n await hooks.callHook('kubb:error', { error: toError(error) })\n process.exit(1)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAKA,MAAM,wBAAwB;;;;;AAM9B,MAAM,sBAAsB;;AAG5B,MAAM,0BAA0B;;AAGhC,MAAM,yBAAyB;;;;;;;;;;;;;;;;AA4B/B,SAAgB,mBAAmB,EAAE,KAAK,WAAqD;CAC7F,IAAI,UAAU;CACd,IAAI,QAAQ;CAEZ,OAAO,YAA2B;EAChC,IAAI,SAAS;GACX,QAAQ;GACR;EACF;EACA,UAAU;EACV,GAAG;GACD,QAAQ;GACR,IAAI;IACF,MAAM,IAAI;GACZ,SAAS,OAAO;IACd,QAAQA,eAAAA,QAAQ,KAAK,CAAC;GACxB;EACF,SAAS;EACT,UAAU;CACZ;AAC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,UAAU,EAAE,CAAC;IACnE;IAEA,IAAI,cAAc,OAChB,gBAAgB,WAAW,OAAO;KAAE,KAAK;MAAE,MAAMO,eAAAA;MAAS,OAAOC,eAAAA;KAAS;KAAG;IAAY,CAAC;SAE1F,MAAM,aAAa,cAAc,OAAO;KAAE,MAAMD,eAAAA;KAAS,OAAOC,eAAAA;IAAS,CAAC;GAE9E,OACE,IAAI;IAEF,IAAI,CAAC,MADmB,SAAS;KAAE;KAAO;KAAQ;KAAO;IAAO,CAAC,GACjD,YAAY;GAC9B,SAAS,aAAa;IACpB,MAAM,MAAM,SAAS,cAAc,EAAE,OAAOR,eAAAA,QAAQ,WAAW,EAAE,CAAC;IAClE,YAAY;GACd;EAEJ;EAEA,MAAM,MAAM,SAAS,oBAAoB;EAIzC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,WACvB,eAAA,OAAO;EAGT,IAAI,WACF,aAAA,QAAQ,KAAK,CAAC;CAElB,SAAS,OAAO;EACd,MAAM,MAAM,SAAS,cAAc,EAAE,OAAOA,eAAAA,QAAQ,KAAK,EAAE,CAAC;EAC5D,aAAA,QAAQ,KAAK,CAAC;CAChB;AACF"}
@@ -1,8 +1,8 @@
1
1
  const require_agent = require("./agent-DElUuYuy.cjs");
2
- const require_run = require("./run-DSeEZTnT.cjs");
3
- const require_Telemetry = require("./Telemetry-D1jiXfo2.cjs");
4
- const require_output = require("./output-CWupdozw.cjs");
5
- const require_reporters = require("./reporters-C5HAypFq.cjs");
2
+ const require_run = require("./run-C8dyBAPb.cjs");
3
+ const require_Telemetry = require("./Telemetry-B_C4MVJd.cjs");
4
+ const require_output = require("./output-BnK0scpX.cjs");
5
+ const require_reporters = require("./reporters-B4rZOlo8.cjs");
6
6
  let node_util = require("node:util");
7
7
  let node_process = require("node:process");
8
8
  node_process = require_agent.__toESM(node_process, 1);
@@ -257,4 +257,4 @@ const runner = async ({ values }) => {
257
257
  //#endregion
258
258
  exports.runner = runner;
259
259
 
260
- //# sourceMappingURL=snapshot-D5OaRDf9.cjs.map
260
+ //# sourceMappingURL=snapshot-B45A4RfA.cjs.map