@kubb/cli 5.8.0 → 5.8.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 (84) hide show
  1. package/dist/{Telemetry-C2052gYB.cjs → Telemetry-D6v6WUtX.cjs} +2 -2
  2. package/dist/{Telemetry-C2052gYB.cjs.map → Telemetry-D6v6WUtX.cjs.map} +1 -1
  3. package/dist/{Telemetry-A_TdzcbF.js → Telemetry-DMMnTu4n.js} +2 -2
  4. package/dist/{Telemetry-A_TdzcbF.js.map → Telemetry-DMMnTu4n.js.map} +1 -1
  5. package/dist/{background-DFGFUYGe.cjs → background-B-5uPpUT.cjs} +2 -2
  6. package/dist/{background-DFGFUYGe.cjs.map → background-B-5uPpUT.cjs.map} +1 -1
  7. package/dist/{background-BHIwU4gp.js → background-CV1vB9ys.js} +2 -2
  8. package/dist/{background-BHIwU4gp.js.map → background-CV1vB9ys.js.map} +1 -1
  9. package/dist/background-CuIy_K8c.js +1 -0
  10. package/dist/{commands-Uc-5l9O0.cjs → commands-CBibFu1T.cjs} +3 -3
  11. package/dist/{commands-Uc-5l9O0.cjs.map → commands-CBibFu1T.cjs.map} +1 -1
  12. package/dist/{commands-Hx6XpJx7.js → commands-DZgyEg0r.js} +3 -3
  13. package/dist/{commands-Hx6XpJx7.js.map → commands-DZgyEg0r.js.map} +1 -1
  14. package/dist/{config-DX176_YM.cjs → config-CRBZcWwg.cjs} +16 -61
  15. package/dist/config-CRBZcWwg.cjs.map +1 -0
  16. package/dist/{config-Czvfdmb6.js → config-DAdYwK_D.js} +14 -53
  17. package/dist/config-DAdYwK_D.js.map +1 -0
  18. package/dist/{errors-CMbMAwyW.cjs → errors-BdA8M78q.cjs} +19 -1
  19. package/dist/{errors-CMbMAwyW.cjs.map → errors-BdA8M78q.cjs.map} +1 -1
  20. package/dist/{errors-BQJzaUwP.js → errors-DmC83ALX.js} +14 -2
  21. package/dist/{errors-BQJzaUwP.js.map → errors-DmC83ALX.js.map} +1 -1
  22. package/dist/index.cjs +128 -40
  23. package/dist/index.cjs.map +1 -1
  24. package/dist/index.d.ts +1 -2
  25. package/dist/index.js +128 -40
  26. package/dist/index.js.map +1 -1
  27. package/dist/{output-DekB5lg3.cjs → output-CWupdozw.cjs} +31 -31
  28. package/dist/output-CWupdozw.cjs.map +1 -0
  29. package/dist/registry-CCKUL3ps.cjs +113 -0
  30. package/dist/registry-CCKUL3ps.cjs.map +1 -0
  31. package/dist/registry-DjGepXb0.js +77 -0
  32. package/dist/registry-DjGepXb0.js.map +1 -0
  33. package/dist/reporters-C5HAypFq.cjs +67 -0
  34. package/dist/reporters-C5HAypFq.cjs.map +1 -0
  35. package/dist/reporters-CNZQUlXY.js +55 -0
  36. package/dist/reporters-CNZQUlXY.js.map +1 -0
  37. package/dist/run-B9wWJSSx.js +65 -0
  38. package/dist/run-B9wWJSSx.js.map +1 -0
  39. package/dist/{run-BaErHa3l.cjs → run-BNfemif8.cjs} +3 -3
  40. package/dist/{run-BaErHa3l.cjs.map → run-BNfemif8.cjs.map} +1 -1
  41. package/dist/run-BURZ4hDs.js +106 -0
  42. package/dist/run-BURZ4hDs.js.map +1 -0
  43. package/dist/run-BaFyksnF.cjs +72 -0
  44. package/dist/run-BaFyksnF.cjs.map +1 -0
  45. package/dist/{run-BSPA8JKH.cjs → run-BbSYIW7v.cjs} +9 -8
  46. package/dist/{run-BSPA8JKH.cjs.map → run-BbSYIW7v.cjs.map} +1 -1
  47. package/dist/run-C4IHvWT_.cjs +109 -0
  48. package/dist/run-C4IHvWT_.cjs.map +1 -0
  49. package/dist/run-CDS3EWEN.js +71 -0
  50. package/dist/run-CDS3EWEN.js.map +1 -0
  51. package/dist/{run-CN5DJ5XC.js → run-CGqjX3nk.js} +3 -3
  52. package/dist/{run-CN5DJ5XC.js.map → run-CGqjX3nk.js.map} +1 -1
  53. package/dist/{run-BWjtN8Gs.cjs → run-D87cI2Vc.cjs} +3 -3
  54. package/dist/{run-BWjtN8Gs.cjs.map → run-D87cI2Vc.cjs.map} +1 -1
  55. package/dist/{run-BeptvKTj.js → run-D9QTeOsm.js} +3 -3
  56. package/dist/{run-BeptvKTj.js.map → run-D9QTeOsm.js.map} +1 -1
  57. package/dist/{run-DuD68jDf.cjs → run-DSpOqqKI.cjs} +9 -8
  58. package/dist/{run-DuD68jDf.cjs.map → run-DSpOqqKI.cjs.map} +1 -1
  59. package/dist/run-DVIqUt1x.cjs +67 -0
  60. package/dist/run-DVIqUt1x.cjs.map +1 -0
  61. package/dist/{run-s3XYpkCe.cjs → run-E11sqsk0.cjs} +9 -81
  62. package/dist/run-E11sqsk0.cjs.map +1 -0
  63. package/dist/{run-BNEll0r7.js → run-Myj1dJrW.js} +5 -4
  64. package/dist/{run-BNEll0r7.js.map → run-Myj1dJrW.js.map} +1 -1
  65. package/dist/{run-BTU318R1.js → run-USNnlQcA.js} +2 -74
  66. package/dist/run-USNnlQcA.js.map +1 -0
  67. package/dist/{run-CIVIeuAh.js → run-W-tLF6Qs.js} +6 -5
  68. package/dist/{run-CIVIeuAh.js.map → run-W-tLF6Qs.js.map} +1 -1
  69. package/dist/{snapshot-GiKqhTTe.cjs → snapshot-9BhLfZLz.cjs} +7 -7
  70. package/dist/{snapshot-GiKqhTTe.cjs.map → snapshot-9BhLfZLz.cjs.map} +1 -1
  71. package/dist/{snapshot-B0piE_yD.js → snapshot-BdP6LpUP.js} +4 -4
  72. package/dist/{snapshot-B0piE_yD.js.map → snapshot-BdP6LpUP.js.map} +1 -1
  73. package/dist/studioWorker.js +2 -2
  74. package/dist/utils-Dhx5PMpD.js +80 -0
  75. package/dist/utils-Dhx5PMpD.js.map +1 -0
  76. package/dist/utils-ZcCFqERz.cjs +106 -0
  77. package/dist/utils-ZcCFqERz.cjs.map +1 -0
  78. package/package.json +7 -7
  79. package/dist/background-BpMcA026.js +0 -1
  80. package/dist/config-Czvfdmb6.js.map +0 -1
  81. package/dist/config-DX176_YM.cjs.map +0 -1
  82. package/dist/output-DekB5lg3.cjs.map +0 -1
  83. package/dist/run-BTU318R1.js.map +0 -1
  84. package/dist/run-s3XYpkCe.cjs.map +0 -1
@@ -1,9 +1,8 @@
1
1
  import "./rolldown-runtime-CRm0XQPb.js";
2
- import { f as clackLogger, g as plainLogger, m as isRichOutput } from "./output-B9Yw7vL0.js";
3
2
  import process from "node:process";
4
3
  import { readFile } from "node:fs/promises";
5
- import { basename, dirname, resolve } from "node:path";
6
- import { createCliReporter } from "@kubb/core";
4
+ import { basename, dirname, join, resolve } from "node:path";
5
+ import { existsSync } from "node:fs";
7
6
  import { createJiti } from "jiti";
8
7
  import { loadConfig } from "unconfig";
9
8
  //#region ../../internals/shared/src/loader.ts
@@ -47,54 +46,6 @@ function createModuleLoader() {
47
46
  } };
48
47
  }
49
48
  //#endregion
50
- //#region src/loggers/reporters.ts
51
- /** Bridges a {@link Reporter} onto the hook emitter: calls `report` with each config's {@link GenerationResult} on `kubb:generation:end`. */
52
- function installReporter(context, reporter, ctx) {
53
- const pluginFiles = reporter.needsPluginFiles ? /* @__PURE__ */ new Map() : void 0;
54
- if (pluginFiles) context.hook("kubb:plugin:end", ({ config, plugin, files }) => {
55
- const filesByPlugin = pluginFiles.get(config) ?? /* @__PURE__ */ new Map();
56
- const seen = new Set([...filesByPlugin.values()].flatMap((paths) => [...paths]));
57
- const added = files.filter((file) => !seen.has(file.path)).map((file) => file.path);
58
- if (added.length) filesByPlugin.set(plugin.name, /* @__PURE__ */ new Set([...filesByPlugin.get(plugin.name) ?? [], ...added]));
59
- pluginFiles.set(config, filesByPlugin);
60
- });
61
- context.hook("kubb:generation:end", async ({ config, diagnostics = [], filesCreated = 0, status = "success", hrStart = process.hrtime() }) => {
62
- const files = pluginFiles?.get(config);
63
- const grouped = files && [...files].map(([plugin, paths]) => ({
64
- plugin,
65
- files: [...paths]
66
- }));
67
- await reporter.report({
68
- config,
69
- diagnostics,
70
- filesCreated,
71
- status,
72
- hrStart,
73
- pluginFiles: grouped
74
- }, ctx);
75
- pluginFiles?.delete(config);
76
- });
77
- if (reporter.drain) context.hook("kubb:lifecycle:end", () => reporter.drain?.(ctx));
78
- }
79
- /** Installs the live logger and wires the selected reporters. `cli` renders its summary through the logger, and is skipped when `json` owns stdout. */
80
- function setupReporters(context, { logLevel, reporters, logger: forcedLogger }) {
81
- const hasJson = reporters.some((reporter) => reporter.name === "json");
82
- const ctx = { logLevel };
83
- for (const reporter of reporters) {
84
- if (reporter.name !== "cli") {
85
- installReporter(context, reporter, ctx);
86
- continue;
87
- }
88
- if (hasJson) continue;
89
- const handle = (forcedLogger ?? (isRichOutput() ? clackLogger : plainLogger))(context, { logLevel });
90
- installReporter(context, createCliReporter({ render: handle?.renderSummary }), ctx);
91
- }
92
- }
93
- /** Picks the reporters whose `name` is in `names`, in the given order (the CLI maps `--reporter` to this); duplicates and unknown names are skipped. */
94
- function selectReporters(reporters, names) {
95
- return [...new Set(names)].flatMap((name) => reporters.find((reporter) => reporter.name === name) ?? []);
96
- }
97
- //#endregion
98
49
  //#region src/config.ts
99
50
  const loader = createModuleLoader();
100
51
  const tsLoader = (configFile) => loader.load(configFile, { default: true });
@@ -112,6 +63,16 @@ const SEARCH_EXTENSIONS = [
112
63
  "mjs",
113
64
  "cjs"
114
65
  ];
66
+ /**
67
+ * The first Kubb config file in `cwd` or the nearest parent folder that has one, searched in the same
68
+ * order as {@link getConfigs}, without loading it.
69
+ */
70
+ function findConfigFile(cwd = process.cwd()) {
71
+ for (let dir = resolve(cwd);; dir = dirname(dir)) {
72
+ const found = SEARCH_FILES.flatMap((file) => SEARCH_EXTENSIONS.map((extension) => join(dir, `${file}.${extension}`))).find((file) => existsSync(file));
73
+ if (found || dirname(dir) === dir) return found;
74
+ }
75
+ }
115
76
  /** Discovers the Kubb config and resolves it into normalized configs, each guaranteed to have a `plugins` array. */
116
77
  async function getConfigs({ configPath, input, watch, logLevel }) {
117
78
  const abs = configPath ? resolve(configPath) : void 0;
@@ -154,6 +115,6 @@ async function getConfigs({ configPath, input, watch, logLevel }) {
154
115
  };
155
116
  }
156
117
  //#endregion
157
- export { selectReporters as n, setupReporters as r, getConfigs as t };
118
+ export { getConfigs as n, findConfigFile as t };
158
119
 
159
- //# sourceMappingURL=config-Czvfdmb6.js.map
120
+ //# sourceMappingURL=config-DAdYwK_D.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-DAdYwK_D.js","names":[],"sources":["../../../internals/shared/src/loader.ts","../src/config.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises'\nimport { createJiti } from 'jiti'\n\n/**\n * jiti options for loading Kubb config modules: the automatic JSX runtime pointed at\n * `@kubb/renderer-jsx`, and `moduleCache` off so a re-load re-evaluates the file.\n */\nconst JITI_OPTIONS = {\n jsx: { runtime: 'automatic', importSource: '@kubb/renderer-jsx' },\n moduleCache: false,\n} satisfies Parameters<typeof createJiti>[1]\n\n/**\n * Plain JavaScript files. jiti hands these to Node's native `import()`, whose module cache never\n * lets go of a file, so `moduleCache: false` alone would keep returning the first version of it.\n */\nconst JAVASCRIPT_EXTENSION = /\\.[cm]?jsx?$/\n\n/**\n * Per-call options for {@link ModuleLoader.load}.\n */\ntype LoadModuleOptions = {\n /**\n * Return the module's default export instead of the full namespace.\n */\n default?: boolean\n}\n\n/**\n * Loads `.ts`/`.js` modules via jiti.\n */\ntype ModuleLoader = {\n load<T = unknown>(filePath: string, options?: LoadModuleOptions): Promise<T>\n}\n\n/**\n * Creates a jiti-based loader for Kubb's TypeScript and JavaScript config modules.\n *\n * jiti transpiles TypeScript and the `@kubb/renderer-jsx` JSX runtime on the fly. Every load\n * re-evaluates the file, so a config edited on disk is picked up by the next load.\n *\n * @example\n * ```ts\n * const config = await createModuleLoader().load('/abs/kubb.config.ts', { default: true })\n * ```\n */\nexport function createModuleLoader(): ModuleLoader {\n const jiti = createJiti(import.meta.url, JITI_OPTIONS)\n\n return {\n async load<T>(filePath: string, options?: LoadModuleOptions) {\n if (!JAVASCRIPT_EXTENSION.test(filePath)) {\n return (options?.default ? jiti.import(filePath, { default: true }) : jiti.import(filePath)) as Promise<T>\n }\n\n // Transpiled through jiti instead, so every load re-evaluates the file as it is on disk now.\n // A TypeScript file it imports reloads too. A plain JavaScript file it imports still goes\n // through Node's `import()` and stays cached until the process restarts.\n const mod = (await jiti.evalModule(await readFile(filePath, 'utf8'), { filename: filePath, async: true, forceTranspile: true })) as\n | { default?: unknown }\n | undefined\n return (options?.default ? (mod?.default ?? mod) : mod) as T\n },\n }\n}\n","import { existsSync } from 'node:fs'\nimport { basename, dirname, join, resolve } from 'node:path'\nimport process from 'node:process'\nimport { createModuleLoader } from '@internals/shared'\nimport type { CLIOptions, Config, PossibleConfig } from '@kubb/core'\nimport { type LoadConfigResult, type LoadConfigSource, loadConfig } from 'unconfig'\n\nconst loader = createModuleLoader()\n\n// Kubb configs are JS/TS modules (they call `defineConfig`/`pluginX()`), so YAML and JSON are not\n// supported. The jiti loader handles every module format and the JSX runtime, returning the default export.\nconst tsLoader = (configFile: string) => loader.load(configFile, { default: true })\n\nconst MODULE_NAME = 'kubb'\n\nconst SEARCH_FILES = ['', '.config/', 'configs/'].flatMap((prefix) => [`${prefix}.${MODULE_NAME}rc`, `${prefix}${MODULE_NAME}.config`])\nconst SEARCH_EXTENSIONS = ['ts', 'mts', 'cts', 'js', 'mjs', 'cjs']\n\n/**\n * The first Kubb config file in `cwd` or the nearest parent folder that has one, searched in the same\n * order as {@link getConfigs}, without loading it.\n */\nexport function findConfigFile(cwd: string = process.cwd()): string | undefined {\n for (let dir = resolve(cwd); ; dir = dirname(dir)) {\n const found = SEARCH_FILES.flatMap((file) => SEARCH_EXTENSIONS.map((extension) => join(dir, `${file}.${extension}`))).find((file) => existsSync(file))\n if (found || dirname(dir) === dir) return found\n }\n}\n\ntype GetConfigsOptions = {\n /** Explicit path to the Kubb config file. When omitted, the loader searches up from `process.cwd()`. */\n configPath?: string\n /** OpenAPI input path or URL that overrides `config.input` for this run. */\n input?: string\n /** Watch flag forwarded to the user's `defineConfig` function. */\n watch?: boolean\n /** Log level forwarded to the user's `defineConfig` function. */\n logLevel?: CLIOptions['logLevel']\n}\n\ntype GetConfigsResult = {\n /** Absolute path to the resolved config file. */\n configPath: string\n /** Resolved and normalized Kubb configs, each guaranteed to have a `plugins` array. */\n configs: Array<Config>\n}\n\n/** Discovers the Kubb config and resolves it into normalized configs, each guaranteed to have a `plugins` array. */\nexport async function getConfigs({ configPath, input, watch, logLevel }: GetConfigsOptions): Promise<GetConfigsResult> {\n const abs = configPath ? resolve(configPath) : undefined\n const sources: Array<LoadConfigSource<unknown>> = abs\n ? [{ files: [basename(abs)], extensions: [], parser: tsLoader }]\n : [{ files: SEARCH_FILES, extensions: SEARCH_EXTENSIONS, parser: tsLoader }]\n\n let result: LoadConfigResult<unknown>\n try {\n result = await loadConfig<unknown>({ cwd: abs ? dirname(abs) : process.cwd(), sources, merge: false })\n } catch (error) {\n throw new Error('Config failed loading', { cause: error })\n }\n\n const [filepath] = result.sources\n if (!result.config || !filepath) {\n throw new Error('Config not defined, create a kubb.config.js or pass through your config with the option --config')\n }\n\n const config = result.config as PossibleConfig<CLIOptions>\n const cli: CLIOptions = { config: configPath, input, watch, logLevel }\n const resolved = await (typeof config === 'function' ? config(cli) : config)\n const userConfigs = Array.isArray(resolved) ? resolved : [resolved]\n\n return {\n configPath: filepath,\n configs: userConfigs.map((item) => {\n const config: Config = { ...item, plugins: item.plugins ?? [] }\n return config\n }),\n }\n}\n"],"mappings":";;;;;;;;;;;;AAOA,MAAM,eAAe;CACnB,KAAK;EAAE,SAAS;EAAa,cAAc;CAAqB;CAChE,aAAa;AACf;;;;;AAMA,MAAM,uBAAuB;;;;;;;;;;;;AA8B7B,SAAgB,qBAAmC;CACjD,MAAM,OAAO,WAAW,YAAY,KAAK,YAAY;CAErD,OAAO,EACL,MAAM,KAAQ,UAAkB,SAA6B;EAC3D,IAAI,CAAC,qBAAqB,KAAK,QAAQ,GACrC,OAAQ,SAAS,UAAU,KAAK,OAAO,UAAU,EAAE,SAAS,KAAK,CAAC,IAAI,KAAK,OAAO,QAAQ;EAM5F,MAAM,MAAO,MAAM,KAAK,WAAW,MAAM,SAAS,UAAU,MAAM,GAAG;GAAE,UAAU;GAAU,OAAO;GAAM,gBAAgB;EAAK,CAAC;EAG9H,OAAQ,SAAS,UAAW,KAAK,WAAW,MAAO;CACrD,EACF;AACF;;;ACzDA,MAAM,SAAS,mBAAmB;AAIlC,MAAM,YAAY,eAAuB,OAAO,KAAK,YAAY,EAAE,SAAS,KAAK,CAAC;AAElF,MAAM,cAAc;AAEpB,MAAM,eAAe;CAAC;CAAI;CAAY;AAAU,CAAC,CAAC,SAAS,WAAW,CAAC,GAAG,OAAO,GAAG,YAAY,KAAK,GAAG,SAAS,YAAY,QAAQ,CAAC;AACtI,MAAM,oBAAoB;CAAC;CAAM;CAAO;CAAO;CAAM;CAAO;AAAK;;;;;AAMjE,SAAgB,eAAe,MAAc,QAAQ,IAAI,GAAuB;CAC9E,KAAK,IAAI,MAAM,QAAQ,GAAG,IAAK,MAAM,QAAQ,GAAG,GAAG;EACjD,MAAM,QAAQ,aAAa,SAAS,SAAS,kBAAkB,KAAK,cAAc,KAAK,KAAK,GAAG,KAAK,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,MAAM,SAAS,WAAW,IAAI,CAAC;EACrJ,IAAI,SAAS,QAAQ,GAAG,MAAM,KAAK,OAAO;CAC5C;AACF;;AAqBA,eAAsB,WAAW,EAAE,YAAY,OAAO,OAAO,YAA0D;CACrH,MAAM,MAAM,aAAa,QAAQ,UAAU,IAAI,KAAA;CAC/C,MAAM,UAA4C,MAC9C,CAAC;EAAE,OAAO,CAAC,SAAS,GAAG,CAAC;EAAG,YAAY,CAAC;EAAG,QAAQ;CAAS,CAAC,IAC7D,CAAC;EAAE,OAAO;EAAc,YAAY;EAAmB,QAAQ;CAAS,CAAC;CAE7E,IAAI;CACJ,IAAI;EACF,SAAS,MAAM,WAAoB;GAAE,KAAK,MAAM,QAAQ,GAAG,IAAI,QAAQ,IAAI;GAAG;GAAS,OAAO;EAAM,CAAC;CACvG,SAAS,OAAO;EACd,MAAM,IAAI,MAAM,yBAAyB,EAAE,OAAO,MAAM,CAAC;CAC3D;CAEA,MAAM,CAAC,YAAY,OAAO;CAC1B,IAAI,CAAC,OAAO,UAAU,CAAC,UACrB,MAAM,IAAI,MAAM,kGAAkG;CAGpH,MAAM,SAAS,OAAO;CAEtB,MAAM,WAAW,OAAO,OAAO,WAAW,aAAa,OAAO;EADpC,QAAQ;EAAY;EAAO;EAAO;CACI,CAAC,IAAI;CAGrE,OAAO;EACL,YAAY;EACZ,UAJkB,MAAM,QAAQ,QAAQ,IAAI,WAAW,CAAC,QAAQ,EAAA,CAI3C,KAAK,SAAS;GAEjC,OAAO;IADkB,GAAG;IAAM,SAAS,KAAK,WAAW,CAAC;GAChD;EACd,CAAC;CACH;AACF"}
@@ -14,7 +14,25 @@ require("./agent-DElUuYuy.cjs");
14
14
  function toError(value) {
15
15
  return value instanceof Error ? value : new Error(String(value));
16
16
  }
17
+ /**
18
+ * Extracts a human-readable message from any thrown value.
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * getErrorMessage(new Error('oops')) // 'oops'
23
+ * getErrorMessage('plain string') // 'plain string'
24
+ * ```
25
+ */
26
+ function getErrorMessage(value) {
27
+ return value instanceof Error ? value.message : String(value);
28
+ }
17
29
  //#endregion
30
+ Object.defineProperty(exports, "getErrorMessage", {
31
+ enumerable: true,
32
+ get: function() {
33
+ return getErrorMessage;
34
+ }
35
+ });
18
36
  Object.defineProperty(exports, "toError", {
19
37
  enumerable: true,
20
38
  get: function() {
@@ -22,4 +40,4 @@ Object.defineProperty(exports, "toError", {
22
40
  }
23
41
  });
24
42
 
25
- //# sourceMappingURL=errors-CMbMAwyW.cjs.map
43
+ //# sourceMappingURL=errors-BdA8M78q.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors-CMbMAwyW.cjs","names":[],"sources":["../../../internals/utils/src/errors.ts"],"sourcesContent":["/**\n * Coerces an unknown thrown value to an `Error` instance.\n * Returns the value as-is when it is already an `Error`; otherwise wraps it with `String(value)`.\n *\n * @example\n * ```ts\n * try { ... } catch(err) {\n * throw new Error('Build failed', { cause: toError(err) })\n * }\n * ```\n */\nexport function toError(value: unknown): Error {\n return value instanceof Error ? value : new Error(String(value))\n}\n\n/**\n * Extracts a human-readable message from any thrown value.\n *\n * @example\n * ```ts\n * getErrorMessage(new Error('oops')) // 'oops'\n * getErrorMessage('plain string') // 'plain string'\n * ```\n */\nexport function getErrorMessage(value: unknown): string {\n return value instanceof Error ? value.message : String(value)\n}\n"],"mappings":";;;;;;;;;;;;;AAWA,SAAgB,QAAQ,OAAuB;CAC7C,OAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC;AACjE"}
1
+ {"version":3,"file":"errors-BdA8M78q.cjs","names":[],"sources":["../../../internals/utils/src/errors.ts"],"sourcesContent":["/**\n * Coerces an unknown thrown value to an `Error` instance.\n * Returns the value as-is when it is already an `Error`; otherwise wraps it with `String(value)`.\n *\n * @example\n * ```ts\n * try { ... } catch(err) {\n * throw new Error('Build failed', { cause: toError(err) })\n * }\n * ```\n */\nexport function toError(value: unknown): Error {\n return value instanceof Error ? value : new Error(String(value))\n}\n\n/**\n * Extracts a human-readable message from any thrown value.\n *\n * @example\n * ```ts\n * getErrorMessage(new Error('oops')) // 'oops'\n * getErrorMessage('plain string') // 'plain string'\n * ```\n */\nexport function getErrorMessage(value: unknown): string {\n return value instanceof Error ? value.message : String(value)\n}\n"],"mappings":";;;;;;;;;;;;;AAWA,SAAgB,QAAQ,OAAuB;CAC7C,OAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC;AACjE;;;;;;;;;;AAWA,SAAgB,gBAAgB,OAAwB;CACtD,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAC9D"}
@@ -14,7 +14,19 @@ import "./rolldown-runtime-CRm0XQPb.js";
14
14
  function toError(value) {
15
15
  return value instanceof Error ? value : new Error(String(value));
16
16
  }
17
+ /**
18
+ * Extracts a human-readable message from any thrown value.
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * getErrorMessage(new Error('oops')) // 'oops'
23
+ * getErrorMessage('plain string') // 'plain string'
24
+ * ```
25
+ */
26
+ function getErrorMessage(value) {
27
+ return value instanceof Error ? value.message : String(value);
28
+ }
17
29
  //#endregion
18
- export { toError as t };
30
+ export { toError as n, getErrorMessage as t };
19
31
 
20
- //# sourceMappingURL=errors-BQJzaUwP.js.map
32
+ //# sourceMappingURL=errors-DmC83ALX.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors-BQJzaUwP.js","names":[],"sources":["../../../internals/utils/src/errors.ts"],"sourcesContent":["/**\n * Coerces an unknown thrown value to an `Error` instance.\n * Returns the value as-is when it is already an `Error`; otherwise wraps it with `String(value)`.\n *\n * @example\n * ```ts\n * try { ... } catch(err) {\n * throw new Error('Build failed', { cause: toError(err) })\n * }\n * ```\n */\nexport function toError(value: unknown): Error {\n return value instanceof Error ? value : new Error(String(value))\n}\n\n/**\n * Extracts a human-readable message from any thrown value.\n *\n * @example\n * ```ts\n * getErrorMessage(new Error('oops')) // 'oops'\n * getErrorMessage('plain string') // 'plain string'\n * ```\n */\nexport function getErrorMessage(value: unknown): string {\n return value instanceof Error ? value.message : String(value)\n}\n"],"mappings":";;;;;;;;;;;;;AAWA,SAAgB,QAAQ,OAAuB;CAC7C,OAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC;AACjE"}
1
+ {"version":3,"file":"errors-DmC83ALX.js","names":[],"sources":["../../../internals/utils/src/errors.ts"],"sourcesContent":["/**\n * Coerces an unknown thrown value to an `Error` instance.\n * Returns the value as-is when it is already an `Error`; otherwise wraps it with `String(value)`.\n *\n * @example\n * ```ts\n * try { ... } catch(err) {\n * throw new Error('Build failed', { cause: toError(err) })\n * }\n * ```\n */\nexport function toError(value: unknown): Error {\n return value instanceof Error ? value : new Error(String(value))\n}\n\n/**\n * Extracts a human-readable message from any thrown value.\n *\n * @example\n * ```ts\n * getErrorMessage(new Error('oops')) // 'oops'\n * getErrorMessage('plain string') // 'plain string'\n * ```\n */\nexport function getErrorMessage(value: unknown): string {\n return value instanceof Error ? value.message : String(value)\n}\n"],"mappings":";;;;;;;;;;;;;AAWA,SAAgB,QAAQ,OAAuB;CAC7C,OAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC;AACjE;;;;;;;;;;AAWA,SAAgB,gBAAgB,OAAwB;CACtD,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAC9D"}
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_agent = require("./agent-DElUuYuy.cjs");
3
- const require_Telemetry = require("./Telemetry-C2052gYB.cjs");
3
+ const require_Telemetry = require("./Telemetry-D6v6WUtX.cjs");
4
4
  let node_util = require("node:util");
5
5
  let _gunshi_plugin_dryrun = require("@gunshi/plugin-dryrun");
6
6
  _gunshi_plugin_dryrun = require_agent.__toESM(_gunshi_plugin_dryrun, 1);
@@ -11,6 +11,12 @@ const configArg = { config: {
11
11
  description: "Path to the Kubb config",
12
12
  short: "c"
13
13
  } };
14
+ const yesArg = { yes: {
15
+ type: "boolean",
16
+ description: "Skip the confirmation",
17
+ short: "y",
18
+ default: false
19
+ } };
14
20
  const logLevelArg = { logLevel: {
15
21
  type: "enum",
16
22
  choices: [
@@ -60,6 +66,43 @@ const studioPermissionArgs = {
60
66
  }
61
67
  };
62
68
  //#endregion
69
+ //#region src/commands/add.ts
70
+ const command$13 = (0, gunshi.define)({
71
+ name: "add",
72
+ description: "Install a plugin, adapter, or parser from the Kubb registry at its reviewed version. A plugin is added to kubb.config.ts, an adapter or parser prints the code to add. Reads KUBB_REGISTRY to use another registry.",
73
+ examples: [
74
+ "kubb add plugin-zod",
75
+ "kubb add kubb-labs/plugin-react-query",
76
+ "kubb add acme/plugin-x --yes",
77
+ "kubb add plugin-zod --no-install"
78
+ ].join("\n"),
79
+ toKebab: true,
80
+ args: {
81
+ id: {
82
+ type: "positional",
83
+ description: "Registry id: owner/slug, or a slug for an official extension",
84
+ required: true
85
+ },
86
+ ...configArg,
87
+ ...yesArg,
88
+ install: {
89
+ type: "boolean",
90
+ description: "Install the package. Pass --no-install to only edit the config",
91
+ negatable: true,
92
+ default: true
93
+ }
94
+ },
95
+ async run({ values }) {
96
+ const { run } = await Promise.resolve().then(() => require("./run-C4IHvWT_.cjs"));
97
+ await run({
98
+ id: values.id,
99
+ configPath: values.config,
100
+ yes: values.yes,
101
+ install: values.install
102
+ });
103
+ }
104
+ });
105
+ //#endregion
63
106
  //#region src/commands/generate.ts
64
107
  const REPORTER_NAMES = [
65
108
  "cli",
@@ -83,7 +126,7 @@ function resolveLogLevel({ verbose, silent, logLevel }) {
83
126
  if (silent) return "silent";
84
127
  return logLevel;
85
128
  }
86
- const command$10 = (0, gunshi.defineWithTypes)()({
129
+ const command$12 = (0, gunshi.defineWithTypes)()({
87
130
  name: "generate",
88
131
  description: "Generate TypeScript types, API clients, React Query hooks, Zod schemas, and more from an OpenAPI specification. Reads kubb.config.ts by default. Pass an OpenAPI file path as the first argument to override the input without editing the config.",
89
132
  examples: [
@@ -133,7 +176,7 @@ const command$10 = (0, gunshi.defineWithTypes)()({
133
176
  async run(ctx) {
134
177
  const { values } = ctx;
135
178
  const logLevel = resolveLogLevel(values);
136
- const { run } = await Promise.resolve().then(() => require("./run-DuD68jDf.cjs"));
179
+ const { run } = await Promise.resolve().then(() => require("./run-DSpOqqKI.cjs"));
137
180
  await run({
138
181
  input: values.input,
139
182
  configPath: values.config,
@@ -146,7 +189,7 @@ const command$10 = (0, gunshi.defineWithTypes)()({
146
189
  });
147
190
  //#endregion
148
191
  //#region src/commands/init.ts
149
- const command$9 = (0, gunshi.defineWithTypes)()({
192
+ const command$11 = (0, gunshi.defineWithTypes)()({
150
193
  name: "init",
151
194
  description: "Scaffold a kubb.config.ts and install plugins for code generation from an OpenAPI spec. Run without flags for interactive setup, or pass --input, --output, and --plugins to skip the prompts.",
152
195
  examples: [
@@ -184,7 +227,7 @@ const command$9 = (0, gunshi.defineWithTypes)()({
184
227
  },
185
228
  async run(ctx) {
186
229
  const { values } = ctx;
187
- const { run } = await Promise.resolve().then(() => require("./run-s3XYpkCe.cjs"));
230
+ const { run } = await Promise.resolve().then(() => require("./run-E11sqsk0.cjs"));
188
231
  await run({
189
232
  yes: values.yes,
190
233
  version: require_Telemetry.version,
@@ -196,9 +239,20 @@ const command$9 = (0, gunshi.defineWithTypes)()({
196
239
  }
197
240
  });
198
241
  //#endregion
242
+ //#region src/commands/list.ts
243
+ const command$10 = (0, gunshi.define)({
244
+ name: "list",
245
+ description: "List the installed Kubb extensions: their registry id, package, installed version, the version the Kubb registry pins, and whether an update exists.",
246
+ examples: "kubb list",
247
+ async run() {
248
+ const { run } = await Promise.resolve().then(() => require("./run-BaFyksnF.cjs"));
249
+ await run();
250
+ }
251
+ });
252
+ //#endregion
199
253
  //#region src/commands/mcp.ts
200
254
  /** The runner is imported when the command runs, so listing `kubb --help` never loads `@kubb/mcp`. */
201
- const command$8 = (0, gunshi.define)({
255
+ const command$9 = (0, gunshi.define)({
202
256
  name: "mcp",
203
257
  description: "Start a Model Context Protocol (MCP) server that exposes Kubb code generation as tools for AI assistants. Once running, configure your AI client (Claude, Cursor, Windsurf, etc.) to connect to it — the assistant can then call kubb generate directly without leaving the chat.",
204
258
  examples: [
@@ -207,13 +261,13 @@ const command$8 = (0, gunshi.define)({
207
261
  "# { \"mcpServers\": { \"kubb\": { \"command\": \"npx\", \"args\": [\"kubb\", \"mcp\"] } } }"
208
262
  ].join("\n"),
209
263
  async run() {
210
- const { run } = await Promise.resolve().then(() => require("./run-BWjtN8Gs.cjs"));
264
+ const { run } = await Promise.resolve().then(() => require("./run-D87cI2Vc.cjs"));
211
265
  await run();
212
266
  }
213
267
  });
214
268
  //#endregion
215
269
  //#region src/commands/studio/connect.ts
216
- const command$7 = (0, gunshi.define)({
270
+ const command$8 = (0, gunshi.define)({
217
271
  name: "connect",
218
272
  description: "Connect this project to Kubb Studio and generate from the browser.",
219
273
  examples: [
@@ -236,26 +290,26 @@ const command$7 = (0, gunshi.define)({
236
290
  ...logLevelArg
237
291
  },
238
292
  async run(ctx) {
239
- const { connectRunner } = await Promise.resolve().then(() => require("./commands-Uc-5l9O0.cjs"));
293
+ const { connectRunner } = await Promise.resolve().then(() => require("./commands-CBibFu1T.cjs"));
240
294
  await connectRunner(ctx);
241
295
  }
242
296
  });
243
297
  //#endregion
244
298
  //#region src/commands/studio/login.ts
245
- const command$6 = (0, gunshi.define)({
299
+ const command$7 = (0, gunshi.define)({
246
300
  name: "login",
247
301
  description: "Pair this machine with Kubb Studio without connecting.",
248
302
  examples: ["kubb studio login", "kubb studio login --url http://localhost:3000"].join("\n"),
249
303
  toKebab: true,
250
- args: command$7.args,
304
+ args: command$8.args,
251
305
  async run(ctx) {
252
- const { loginRunner } = await Promise.resolve().then(() => require("./commands-Uc-5l9O0.cjs"));
306
+ const { loginRunner } = await Promise.resolve().then(() => require("./commands-CBibFu1T.cjs"));
253
307
  await loginRunner(ctx);
254
308
  }
255
309
  });
256
310
  //#endregion
257
311
  //#region src/commands/studio/logout.ts
258
- const command$5 = (0, gunshi.define)({
312
+ const command$6 = (0, gunshi.define)({
259
313
  name: "logout",
260
314
  description: "Forget the stored Kubb Studio token.",
261
315
  examples: ["kubb studio logout"].join("\n"),
@@ -267,13 +321,13 @@ const command$5 = (0, gunshi.define)({
267
321
  ...logLevelArg
268
322
  },
269
323
  async run(ctx) {
270
- const { logoutRunner } = await Promise.resolve().then(() => require("./commands-Uc-5l9O0.cjs"));
324
+ const { logoutRunner } = await Promise.resolve().then(() => require("./commands-CBibFu1T.cjs"));
271
325
  await logoutRunner(ctx);
272
326
  }
273
327
  });
274
328
  //#endregion
275
329
  //#region src/commands/studio/snapshot.ts
276
- const command$4 = (0, gunshi.define)({
330
+ const command$5 = (0, gunshi.define)({
277
331
  name: "snapshot",
278
332
  description: "Generate and publish a Kubb Studio snapshot from CI.",
279
333
  examples: ["kubb studio snapshot", "kubb studio snapshot --json"].join("\n"),
@@ -307,19 +361,19 @@ const command$4 = (0, gunshi.define)({
307
361
  ...logLevelArg
308
362
  },
309
363
  async run(ctx) {
310
- const { runner } = await Promise.resolve().then(() => require("./snapshot-GiKqhTTe.cjs"));
364
+ const { runner } = await Promise.resolve().then(() => require("./snapshot-9BhLfZLz.cjs"));
311
365
  await runner(ctx);
312
366
  }
313
367
  });
314
368
  //#endregion
315
369
  //#region src/commands/studio/background.ts
316
- const command$3 = (0, gunshi.define)({
370
+ const command$4 = (0, gunshi.define)({
317
371
  name: "start",
318
372
  description: "Keep this project connected to Kubb Studio in the background.",
319
373
  toKebab: true,
320
- args: command$7.args,
374
+ args: command$8.args,
321
375
  async run(ctx) {
322
- const { startRunner } = await Promise.resolve().then(() => require("./commands-Uc-5l9O0.cjs"));
376
+ const { startRunner } = await Promise.resolve().then(() => require("./commands-CBibFu1T.cjs"));
323
377
  await startRunner(ctx);
324
378
  }
325
379
  });
@@ -327,13 +381,13 @@ const stopCommand = (0, gunshi.define)({
327
381
  name: "stop",
328
382
  description: "Stop this project's background connection and keep its pairing.",
329
383
  async run() {
330
- const { stopRunner } = await Promise.resolve().then(() => require("./commands-Uc-5l9O0.cjs"));
384
+ const { stopRunner } = await Promise.resolve().then(() => require("./commands-CBibFu1T.cjs"));
331
385
  await stopRunner();
332
386
  }
333
387
  });
334
388
  //#endregion
335
389
  //#region src/commands/studio/status.ts
336
- const command$2 = (0, gunshi.define)({
390
+ const command$3 = (0, gunshi.define)({
337
391
  name: "status",
338
392
  description: "Show the project worker, Kubb Studio pairing, and saved permissions.",
339
393
  examples: ["kubb studio status"].join("\n"),
@@ -345,13 +399,13 @@ const command$2 = (0, gunshi.define)({
345
399
  ...logLevelArg
346
400
  },
347
401
  async run(ctx) {
348
- const { statusRunner } = await Promise.resolve().then(() => require("./commands-Uc-5l9O0.cjs"));
402
+ const { statusRunner } = await Promise.resolve().then(() => require("./commands-CBibFu1T.cjs"));
349
403
  await statusRunner(ctx);
350
404
  }
351
405
  });
352
406
  //#endregion
353
407
  //#region src/commands/studio/index.ts
354
- const command$1 = (0, gunshi.define)({
408
+ const command$2 = (0, gunshi.define)({
355
409
  name: "studio",
356
410
  description: "Connect this project to Kubb Studio, or manage its pairing and snapshots.",
357
411
  examples: [
@@ -363,19 +417,19 @@ const command$1 = (0, gunshi.define)({
363
417
  "kubb studio snapshot"
364
418
  ].join("\n"),
365
419
  toKebab: true,
366
- args: command$7.args,
420
+ args: command$8.args,
367
421
  async run(ctx) {
368
- const { connectRunner } = await Promise.resolve().then(() => require("./commands-Uc-5l9O0.cjs"));
422
+ const { connectRunner } = await Promise.resolve().then(() => require("./commands-CBibFu1T.cjs"));
369
423
  await connectRunner(ctx);
370
424
  },
371
425
  subCommands: {
372
- start: command$3,
426
+ start: command$4,
373
427
  stop: stopCommand,
374
- connect: command$7,
375
- login: command$6,
376
- logout: command$5,
377
- status: command$2,
378
- snapshot: command$4
428
+ connect: command$8,
429
+ login: command$7,
430
+ logout: command$6,
431
+ status: command$3,
432
+ snapshot: command$5
379
433
  }
380
434
  });
381
435
  /**
@@ -392,6 +446,38 @@ function routeStudioFlags(args) {
392
446
  ];
393
447
  }
394
448
  //#endregion
449
+ //#region src/commands/update.ts
450
+ const command$1 = (0, gunshi.define)({
451
+ name: "update",
452
+ description: "Update installed extensions to the version the Kubb registry pins. Pass ids to update only those, or --check to list the updates without installing.",
453
+ examples: [
454
+ "kubb update",
455
+ "kubb update --check",
456
+ "kubb update plugin-zod plugin-ts --yes"
457
+ ].join("\n"),
458
+ args: {
459
+ ids: {
460
+ type: "positional",
461
+ description: "Registry ids to update, all installed extensions when omitted",
462
+ multiple: true
463
+ },
464
+ check: {
465
+ type: "boolean",
466
+ description: "List the available updates without installing them",
467
+ default: false
468
+ },
469
+ ...yesArg
470
+ },
471
+ async run({ values }) {
472
+ const { run } = await Promise.resolve().then(() => require("./run-DVIqUt1x.cjs"));
473
+ await run({
474
+ ids: values.ids ?? [],
475
+ check: values.check,
476
+ yes: values.yes
477
+ });
478
+ }
479
+ });
480
+ //#endregion
395
481
  //#region src/commands/validate.ts
396
482
  /** The runner is imported when the command runs, so listing `kubb --help` never loads `@kubb/adapter-oas`. */
397
483
  const command = (0, gunshi.define)({
@@ -404,7 +490,7 @@ const command = (0, gunshi.define)({
404
490
  required: true
405
491
  } },
406
492
  async run({ values }) {
407
- const { run } = await Promise.resolve().then(() => require("./run-BaErHa3l.cjs"));
493
+ const { run } = await Promise.resolve().then(() => require("./run-BNfemif8.cjs"));
408
494
  await run({ input: values.input });
409
495
  }
410
496
  });
@@ -459,23 +545,25 @@ function stripExecArgs(argv) {
459
545
  }
460
546
  /**
461
547
  * Entry point for the `kubb` CLI. Prints the telemetry notice unless telemetry is disabled or a
462
- * quiet flag is passed, then runs the generate, validate, mcp, studio, and init commands. Defaults to
463
- * `generate` when no command is given.
548
+ * quiet flag is passed, then runs the given command, or `generate` when none is given.
464
549
  */
465
550
  async function run(argv = process.argv) {
466
551
  const args = routeStudioFlags(resolveDeprecatedFlags(stripExecArgs(argv)));
467
552
  const isQuietFlag = args.some((arg) => QUIET_FLAGS.has(arg));
468
553
  if (!require_Telemetry.isDisabled() && !isQuietFlag) console.error(`${(0, node_util.styleText)("yellow", "Notice:")} Kubb collects anonymous telemetry data to help improve the tool. No personal data or file contents are collected. \nTo disable, set ${(0, node_util.styleText)("cyan", "KUBB_DISABLE_TELEMETRY=1")}.\n`);
469
- await (0, gunshi.cli)(args, command$10, {
554
+ await (0, gunshi.cli)(args, command$12, {
470
555
  name: "kubb",
471
556
  version: require_Telemetry.version,
472
- description: "Generate code from an OpenAPI specification, or connect the project to Kubb Studio.",
557
+ description: "Generate code from an OpenAPI specification, manage Kubb extensions, or connect the project to Kubb Studio.",
473
558
  subCommands: {
474
- generate: command$10,
475
- init: command$9,
559
+ generate: command$12,
560
+ init: command$11,
476
561
  validate: command,
477
- mcp: command$8,
478
- studio: command$1
562
+ mcp: command$9,
563
+ studio: command$2,
564
+ add: command$13,
565
+ update: command$1,
566
+ list: command$10
479
567
  },
480
568
  fallbackToEntry: true,
481
569
  strict: true,