@kubb/cli 5.0.0-alpha.2 → 5.0.0-alpha.21

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/dist/{agent-L50VNhXv.js → agent-DTyw-mt7.js} +4 -4
  2. package/dist/{agent-L50VNhXv.js.map → agent-DTyw-mt7.js.map} +1 -1
  3. package/dist/{agent-B2TK-4x7.cjs → agent-Dd7uQlD3.cjs} +5 -5
  4. package/dist/{agent-B2TK-4x7.cjs.map → agent-Dd7uQlD3.cjs.map} +1 -1
  5. package/dist/{agent-C6o_6GSJ.cjs → agent-DpzeyN1s.cjs} +4 -4
  6. package/dist/{agent-C6o_6GSJ.cjs.map → agent-DpzeyN1s.cjs.map} +1 -1
  7. package/dist/{agent-CxaBPZgN.js → agent-TvIyrWHH.js} +5 -5
  8. package/dist/{agent-CxaBPZgN.js.map → agent-TvIyrWHH.js.map} +1 -1
  9. package/dist/{constants-BTUap0zs.cjs → constants-D0XHAHeZ.cjs} +78 -8
  10. package/dist/constants-D0XHAHeZ.cjs.map +1 -0
  11. package/dist/{constants-CM3dJzjK.js → constants-DJM9zCXm.js} +73 -9
  12. package/dist/constants-DJM9zCXm.js.map +1 -0
  13. package/dist/define-Bdn8j5VM.cjs +54 -0
  14. package/dist/define-Bdn8j5VM.cjs.map +1 -0
  15. package/dist/define-Ctii4bel.js +43 -0
  16. package/dist/define-Ctii4bel.js.map +1 -0
  17. package/dist/{errors-DBW0N9w4.cjs → errors-CLCjoSg0.cjs} +22 -6
  18. package/dist/errors-CLCjoSg0.cjs.map +1 -0
  19. package/dist/errors-CjPmyZHy.js +43 -0
  20. package/dist/errors-CjPmyZHy.js.map +1 -0
  21. package/dist/{generate-C52-Gwzu.cjs → generate-8gBYPkBI.cjs} +3 -3
  22. package/dist/{generate-C52-Gwzu.cjs.map → generate-8gBYPkBI.cjs.map} +1 -1
  23. package/dist/{generate-8xxZmvqZ.js → generate-BjYMvMXy.js} +178 -77
  24. package/dist/generate-BjYMvMXy.js.map +1 -0
  25. package/dist/{generate-D8p6X0le.cjs → generate-C1x42EUt.cjs} +177 -76
  26. package/dist/generate-C1x42EUt.cjs.map +1 -0
  27. package/dist/{generate-DYZYA7O1.js → generate-CCKyB7yS.js} +3 -3
  28. package/dist/{generate-DYZYA7O1.js.map → generate-CCKyB7yS.js.map} +1 -1
  29. package/dist/index.cjs +49 -19
  30. package/dist/index.cjs.map +1 -1
  31. package/dist/index.d.ts +1 -1
  32. package/dist/index.js +49 -19
  33. package/dist/index.js.map +1 -1
  34. package/dist/{init-hmolV6B4.cjs → init-BlriFVH6.cjs} +19 -4
  35. package/dist/init-BlriFVH6.cjs.map +1 -0
  36. package/dist/{init-BH6q17OX.js → init-C71oxvYR.js} +4 -4
  37. package/dist/{init-BH6q17OX.js.map → init-C71oxvYR.js.map} +1 -1
  38. package/dist/{init-BiutNzDD.cjs → init-DnUVdLjN.cjs} +4 -4
  39. package/dist/{init-BiutNzDD.cjs.map → init-DnUVdLjN.cjs.map} +1 -1
  40. package/dist/{init-C-InrmSY.js → init-Y1TNCdzh.js} +19 -4
  41. package/dist/init-Y1TNCdzh.js.map +1 -0
  42. package/dist/{mcp-Bc7xyp4a.js → mcp-9R8F1uQc.js} +4 -4
  43. package/dist/{mcp-Bc7xyp4a.js.map → mcp-9R8F1uQc.js.map} +1 -1
  44. package/dist/{mcp-D2SHEg_d.js → mcp-CxuctqmK.js} +3 -3
  45. package/dist/{mcp-D2SHEg_d.js.map → mcp-CxuctqmK.js.map} +1 -1
  46. package/dist/{mcp-B9iqBWaU.cjs → mcp-DDX2VL5b.cjs} +4 -4
  47. package/dist/{mcp-B9iqBWaU.cjs.map → mcp-DDX2VL5b.cjs.map} +1 -1
  48. package/dist/{mcp-ChHFPRzD.cjs → mcp-jMZ56bqT.cjs} +3 -3
  49. package/dist/{mcp-ChHFPRzD.cjs.map → mcp-jMZ56bqT.cjs.map} +1 -1
  50. package/dist/{package-lo3R7SUU.cjs → package-CH6AW-ko.cjs} +2 -2
  51. package/dist/package-CH6AW-ko.cjs.map +1 -0
  52. package/dist/package-DTEuw2ZR.js +6 -0
  53. package/dist/package-DTEuw2ZR.js.map +1 -0
  54. package/dist/{shell-7HPrTCJ5.cjs → shell-475fQKaX.cjs} +8 -3
  55. package/dist/shell-475fQKaX.cjs.map +1 -0
  56. package/dist/{shell-DqqWsHCD.js → shell-DLzN4fRo.js} +8 -3
  57. package/dist/shell-DLzN4fRo.js.map +1 -0
  58. package/dist/{telemetry-DxiR7clS.js → telemetry-CBISr5w4.js} +48 -6
  59. package/dist/telemetry-CBISr5w4.js.map +1 -0
  60. package/dist/{telemetry-Cn9X1I5B.cjs → telemetry-YO-uwAbf.cjs} +48 -6
  61. package/dist/telemetry-YO-uwAbf.cjs.map +1 -0
  62. package/dist/{validate-Bbrn3Q-A.cjs → validate-B-LfVNlS.cjs} +3 -3
  63. package/dist/{validate-Bbrn3Q-A.cjs.map → validate-B-LfVNlS.cjs.map} +1 -1
  64. package/dist/{validate-l8vLmwKA.js → validate-CIS8nJdd.js} +3 -3
  65. package/dist/{validate-l8vLmwKA.js.map → validate-CIS8nJdd.js.map} +1 -1
  66. package/dist/{validate-DCeW2b2k.js → validate-CT9EjxW0.js} +4 -4
  67. package/dist/{validate-DCeW2b2k.js.map → validate-CT9EjxW0.js.map} +1 -1
  68. package/dist/{validate-B_O2agAB.cjs → validate-D-Jv1vcb.cjs} +4 -4
  69. package/dist/{validate-B_O2agAB.cjs.map → validate-D-Jv1vcb.cjs.map} +1 -1
  70. package/package.json +5 -5
  71. package/src/constants.ts +57 -10
  72. package/src/index.ts +5 -4
  73. package/src/loggers/clackLogger.ts +30 -22
  74. package/src/runners/generate.ts +22 -23
  75. package/src/types.ts +11 -0
  76. package/src/utils/flags.ts +10 -0
  77. package/src/utils/getCosmiConfig.ts +6 -0
  78. package/dist/constants-BTUap0zs.cjs.map +0 -1
  79. package/dist/constants-CM3dJzjK.js.map +0 -1
  80. package/dist/define--M_JMcDC.js +0 -25
  81. package/dist/define--M_JMcDC.js.map +0 -1
  82. package/dist/define-D6Kfm7-Z.cjs +0 -36
  83. package/dist/define-D6Kfm7-Z.cjs.map +0 -1
  84. package/dist/errors-6mF_WKxg.js +0 -27
  85. package/dist/errors-6mF_WKxg.js.map +0 -1
  86. package/dist/errors-DBW0N9w4.cjs.map +0 -1
  87. package/dist/generate-8xxZmvqZ.js.map +0 -1
  88. package/dist/generate-D8p6X0le.cjs.map +0 -1
  89. package/dist/init-C-InrmSY.js.map +0 -1
  90. package/dist/init-hmolV6B4.cjs.map +0 -1
  91. package/dist/package-B4LgzOaR.js +0 -6
  92. package/dist/package-B4LgzOaR.js.map +0 -1
  93. package/dist/package-lo3R7SUU.cjs.map +0 -1
  94. package/dist/shell-7HPrTCJ5.cjs.map +0 -1
  95. package/dist/shell-DqqWsHCD.js.map +0 -1
  96. package/dist/telemetry-Cn9X1I5B.cjs.map +0 -1
  97. package/dist/telemetry-DxiR7clS.js.map +0 -1
  98. package/src/utils/getIntro.ts +0 -1
@@ -0,0 +1,43 @@
1
+ import "./chunk--u3MIqq1.js";
2
+ //#region ../../internals/utils/src/errors.ts
3
+ /**
4
+ * Coerces an unknown thrown value to an `Error` instance.
5
+ * Returns the value as-is when it is already an `Error`; otherwise wraps it with `String(value)`.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * try { ... } catch(err) {
10
+ * throw new BuildError('Build failed', { cause: toError(err), errors: [] })
11
+ * }
12
+ * ```
13
+ */
14
+ function toError(value) {
15
+ return value instanceof Error ? value : new Error(String(value));
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
+ }
29
+ /**
30
+ * Extracts the `.cause` of an `Error` as an `Error`, or `undefined` when absent or not an `Error`.
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * const cause = toCause(buildError) // Error | undefined
35
+ * ```
36
+ */
37
+ function toCause(error) {
38
+ return error.cause instanceof Error ? error.cause : void 0;
39
+ }
40
+ //#endregion
41
+ export { toCause as n, toError as r, getErrorMessage as t };
42
+
43
+ //# sourceMappingURL=errors-CjPmyZHy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors-CjPmyZHy.js","names":[],"sources":["../../../internals/utils/src/errors.ts"],"sourcesContent":["/** Thrown when a plugin's configuration or input fails validation.\n *\n * @example\n * ```ts\n * throw new ValidationPluginError('Invalid config: \"output.path\" is required')\n * ```\n */\nexport class ValidationPluginError extends Error {}\n\n/**\n * Thrown when one or more errors occur during a Kubb build.\n * Carries the full list of underlying errors on `errors`.\n *\n * @example\n * ```ts\n * throw new BuildError('Build failed', { errors: [err1, err2] })\n * ```\n */\nexport class BuildError extends Error {\n errors: Array<Error>\n\n constructor(message: string, options: { cause?: Error; errors: Array<Error> }) {\n super(message, { cause: options.cause })\n this.name = 'BuildError'\n this.errors = options.errors\n }\n}\n\n/**\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 BuildError('Build failed', { cause: toError(err), errors: [] })\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\n/**\n * Extracts the `.cause` of an `Error` as an `Error`, or `undefined` when absent or not an `Error`.\n *\n * @example\n * ```ts\n * const cause = toCause(buildError) // Error | undefined\n * ```\n */\nexport function toCause(error: Error): Error | undefined {\n return error.cause instanceof Error ? error.cause : undefined\n}\n"],"mappings":";;;;;;;;;;;;;AAuCA,SAAgB,QAAQ,OAAuB;AAC7C,QAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,MAAM,CAAC;;;;;;;;;;;AAYlE,SAAgB,gBAAgB,OAAwB;AACtD,QAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;;;;;;;;;;AAW/D,SAAgB,QAAQ,OAAiC;AACvD,QAAO,MAAM,iBAAiB,QAAQ,MAAM,QAAQ,KAAA"}
@@ -1,6 +1,6 @@
1
1
  require("./chunk-ByKO4r7w.cjs");
2
2
  //#region src/commands/generate.ts
3
- const command = require("./define-D6Kfm7-Z.cjs").defineCommand({
3
+ const command = require("./define-Bdn8j5VM.cjs").defineCommand({
4
4
  name: "generate",
5
5
  description: "[input] Generate files based on a 'kubb.config.ts' file",
6
6
  arguments: ["[input]"],
@@ -50,7 +50,7 @@ const command = require("./define-D6Kfm7-Z.cjs").defineCommand({
50
50
  },
51
51
  async run({ values, positionals }) {
52
52
  const logLevel = values.debug ? "debug" : values.verbose ? "verbose" : values.silent ? "silent" : values.logLevel;
53
- const { runGenerateCommand } = await Promise.resolve().then(() => require("./generate-D8p6X0le.cjs"));
53
+ const { runGenerateCommand } = await Promise.resolve().then(() => require("./generate-C1x42EUt.cjs"));
54
54
  await runGenerateCommand({
55
55
  input: positionals[0],
56
56
  configPath: values.config,
@@ -62,4 +62,4 @@ const command = require("./define-D6Kfm7-Z.cjs").defineCommand({
62
62
  //#endregion
63
63
  exports.command = command;
64
64
 
65
- //# sourceMappingURL=generate-C52-Gwzu.cjs.map
65
+ //# sourceMappingURL=generate-8gBYPkBI.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate-C52-Gwzu.cjs","names":["defineCommand"],"sources":["../src/commands/generate.ts"],"sourcesContent":["import { defineCommand } from '@internals/utils'\n\nexport const command = defineCommand({\n name: 'generate',\n description: \"[input] Generate files based on a 'kubb.config.ts' file\",\n arguments: ['[input]'],\n options: {\n config: { type: 'string', description: 'Path to the Kubb config', short: 'c' },\n logLevel: {\n type: 'string',\n description: 'Info, silent, verbose or debug',\n short: 'l',\n default: 'info',\n hint: 'silent|info|verbose|debug',\n enum: ['silent', 'info', 'verbose', 'debug'],\n },\n watch: { type: 'boolean', description: 'Watch mode based on the input file', short: 'w', default: false },\n debug: { type: 'boolean', description: 'Override logLevel to debug', short: 'd', default: false },\n verbose: { type: 'boolean', description: 'Override logLevel to verbose', short: 'v', default: false },\n silent: { type: 'boolean', description: 'Override logLevel to silent', short: 's', default: false },\n },\n async run({ values, positionals }) {\n const logLevel = values.debug ? 'debug' : values.verbose ? 'verbose' : values.silent ? 'silent' : values.logLevel\n const { runGenerateCommand } = await import('../runners/generate.ts')\n\n await runGenerateCommand({ input: positionals[0], configPath: values.config, logLevel, watch: values.watch })\n },\n})\n"],"mappings":";;AAEA,MAAa,2CAAUA,cAAc;CACnC,MAAM;CACN,aAAa;CACb,WAAW,CAAC,UAAU;CACtB,SAAS;EACP,QAAQ;GAAE,MAAM;GAAU,aAAa;GAA2B,OAAO;GAAK;EAC9E,UAAU;GACR,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;GACT,MAAM;GACN,MAAM;IAAC;IAAU;IAAQ;IAAW;IAAQ;GAC7C;EACD,OAAO;GAAE,MAAM;GAAW,aAAa;GAAsC,OAAO;GAAK,SAAS;GAAO;EACzG,OAAO;GAAE,MAAM;GAAW,aAAa;GAA8B,OAAO;GAAK,SAAS;GAAO;EACjG,SAAS;GAAE,MAAM;GAAW,aAAa;GAAgC,OAAO;GAAK,SAAS;GAAO;EACrG,QAAQ;GAAE,MAAM;GAAW,aAAa;GAA+B,OAAO;GAAK,SAAS;GAAO;EACpG;CACD,MAAM,IAAI,EAAE,QAAQ,eAAe;EACjC,MAAM,WAAW,OAAO,QAAQ,UAAU,OAAO,UAAU,YAAY,OAAO,SAAS,WAAW,OAAO;EACzG,MAAM,EAAE,uBAAuB,MAAA,QAAA,SAAA,CAAA,WAAA,QAAM,0BAAA,CAAA;AAErC,QAAM,mBAAmB;GAAE,OAAO,YAAY;GAAI,YAAY,OAAO;GAAQ;GAAU,OAAO,OAAO;GAAO,CAAC;;CAEhH,CAAC"}
1
+ {"version":3,"file":"generate-8gBYPkBI.cjs","names":["defineCommand"],"sources":["../src/commands/generate.ts"],"sourcesContent":["import { defineCommand } from '@internals/utils'\n\nexport const command = defineCommand({\n name: 'generate',\n description: \"[input] Generate files based on a 'kubb.config.ts' file\",\n arguments: ['[input]'],\n options: {\n config: { type: 'string', description: 'Path to the Kubb config', short: 'c' },\n logLevel: {\n type: 'string',\n description: 'Info, silent, verbose or debug',\n short: 'l',\n default: 'info',\n hint: 'silent|info|verbose|debug',\n enum: ['silent', 'info', 'verbose', 'debug'],\n },\n watch: { type: 'boolean', description: 'Watch mode based on the input file', short: 'w', default: false },\n debug: { type: 'boolean', description: 'Override logLevel to debug', short: 'd', default: false },\n verbose: { type: 'boolean', description: 'Override logLevel to verbose', short: 'v', default: false },\n silent: { type: 'boolean', description: 'Override logLevel to silent', short: 's', default: false },\n },\n async run({ values, positionals }) {\n const logLevel = values.debug ? 'debug' : values.verbose ? 'verbose' : values.silent ? 'silent' : values.logLevel\n const { runGenerateCommand } = await import('../runners/generate.ts')\n\n await runGenerateCommand({ input: positionals[0], configPath: values.config, logLevel, watch: values.watch })\n },\n})\n"],"mappings":";;AAEA,MAAa,2CAAUA,cAAc;CACnC,MAAM;CACN,aAAa;CACb,WAAW,CAAC,UAAU;CACtB,SAAS;EACP,QAAQ;GAAE,MAAM;GAAU,aAAa;GAA2B,OAAO;GAAK;EAC9E,UAAU;GACR,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;GACT,MAAM;GACN,MAAM;IAAC;IAAU;IAAQ;IAAW;IAAQ;GAC7C;EACD,OAAO;GAAE,MAAM;GAAW,aAAa;GAAsC,OAAO;GAAK,SAAS;GAAO;EACzG,OAAO;GAAE,MAAM;GAAW,aAAa;GAA8B,OAAO;GAAK,SAAS;GAAO;EACjG,SAAS;GAAE,MAAM;GAAW,aAAa;GAAgC,OAAO;GAAK,SAAS;GAAO;EACrG,QAAQ;GAAE,MAAM;GAAW,aAAa;GAA+B,OAAO;GAAK,SAAS;GAAO;EACpG;CACD,MAAM,IAAI,EAAE,QAAQ,eAAe;EACjC,MAAM,WAAW,OAAO,QAAQ,UAAU,OAAO,UAAU,YAAY,OAAO,SAAS,WAAW,OAAO;EACzG,MAAM,EAAE,uBAAuB,MAAA,QAAA,SAAA,CAAA,WAAA,QAAM,0BAAA,CAAA;AAErC,QAAM,mBAAmB;GAAE,OAAO,YAAY;GAAI,YAAY,OAAO;GAAQ;GAAU,OAAO,OAAO;GAAO,CAAC;;CAEhH,CAAC"}
@@ -1,9 +1,9 @@
1
1
  import "./chunk--u3MIqq1.js";
2
- import { n as toCause, r as toError } from "./errors-6mF_WKxg.js";
3
- import { a as canUseTTY, i as executeIfOnline, o as isGitHubActions, r as sendTelemetry, t as buildTelemetryEvent } from "./telemetry-DxiR7clS.js";
4
- import { n as tokenize } from "./shell-DqqWsHCD.js";
5
- import { t as version } from "./package-B4LgzOaR.js";
6
- import { i as WATCHER_IGNORED_PATHS, r as SUMMARY_SEPARATOR, t as KUBB_NPM_PACKAGE_URL } from "./constants-CM3dJzjK.js";
2
+ import { n as toCause, r as toError } from "./errors-CjPmyZHy.js";
3
+ import { a as canUseTTY, i as executeIfOnline, o as isGitHubActions, r as sendTelemetry, t as buildTelemetryEvent } from "./telemetry-CBISr5w4.js";
4
+ import { n as tokenize } from "./shell-DLzN4fRo.js";
5
+ import { t as version } from "./package-DTEuw2ZR.js";
6
+ import { a as WATCHER_IGNORED_PATHS, i as SUMMARY_SEPARATOR, t as KUBB_NPM_PACKAGE_URL } from "./constants-DJM9zCXm.js";
7
7
  import { styleText } from "node:util";
8
8
  import { EventEmitter } from "node:events";
9
9
  import { createHash } from "node:crypto";
@@ -12,19 +12,26 @@ import { mkdir, readFile, writeFile } from "node:fs/promises";
12
12
  import path, { dirname, relative, resolve } from "node:path";
13
13
  import process$1 from "node:process";
14
14
  import * as clack from "@clack/prompts";
15
- import { PromiseManager, defineLogger, detectFormatter, detectLinter, formatters, getConfigs, isInputPath, linters, logLevel, safeBuild, setup } from "@kubb/core";
15
+ import { defineLogger, detectFormatter, detectLinter, formatters, getConfigs, isInputPath, linters, logLevel, safeBuild, setup } from "@kubb/core";
16
16
  import { NonZeroExitError, x } from "tinyexec";
17
17
  import { Writable } from "node:stream";
18
18
  import { cosmiconfig } from "cosmiconfig";
19
19
  import { createJiti } from "jiti";
20
20
  //#region ../../internals/utils/src/asyncEventEmitter.ts
21
21
  /**
22
- * A typed EventEmitter that awaits all async listeners before resolving.
22
+ * Typed `EventEmitter` that awaits all async listeners before resolving.
23
23
  * Wraps Node's `EventEmitter` with full TypeScript event-map inference.
24
+ *
25
+ * @example
26
+ * ```ts
27
+ * const emitter = new AsyncEventEmitter<{ build: [name: string] }>()
28
+ * emitter.on('build', async (name) => { console.log(name) })
29
+ * await emitter.emit('build', 'petstore') // all listeners awaited
30
+ * ```
24
31
  */
25
32
  var AsyncEventEmitter = class {
26
33
  /**
27
- * `maxListener` controls the maximum number of listeners per event before Node emits a memory-leak warning.
34
+ * Maximum number of listeners per event before Node emits a memory-leak warning.
28
35
  * @default 10
29
36
  */
30
37
  constructor(maxListener = 10) {
@@ -32,8 +39,13 @@ var AsyncEventEmitter = class {
32
39
  }
33
40
  #emitter = new EventEmitter();
34
41
  /**
35
- * Emits an event and awaits all registered listeners in parallel.
42
+ * Emits `eventName` and awaits all registered listeners in parallel.
36
43
  * Throws if any listener rejects, wrapping the cause with the event name and serialized arguments.
44
+ *
45
+ * @example
46
+ * ```ts
47
+ * await emitter.emit('build', 'petstore')
48
+ * ```
37
49
  */
38
50
  async emit(eventName, ...eventArgs) {
39
51
  const listeners = this.#emitter.listeners(eventName);
@@ -52,11 +64,25 @@ var AsyncEventEmitter = class {
52
64
  }
53
65
  }));
54
66
  }
55
- /** Registers a persistent listener for the given event. */
67
+ /**
68
+ * Registers a persistent listener for `eventName`.
69
+ *
70
+ * @example
71
+ * ```ts
72
+ * emitter.on('build', async (name) => { console.log(name) })
73
+ * ```
74
+ */
56
75
  on(eventName, handler) {
57
76
  this.#emitter.on(eventName, handler);
58
77
  }
59
- /** Registers a one-shot listener that removes itself after the first invocation. */
78
+ /**
79
+ * Registers a one-shot listener that removes itself after the first invocation.
80
+ *
81
+ * @example
82
+ * ```ts
83
+ * emitter.onOnce('build', async (name) => { console.log(name) })
84
+ * ```
85
+ */
60
86
  onOnce(eventName, handler) {
61
87
  const wrapper = (...args) => {
62
88
  this.off(eventName, wrapper);
@@ -64,11 +90,25 @@ var AsyncEventEmitter = class {
64
90
  };
65
91
  this.on(eventName, wrapper);
66
92
  }
67
- /** Removes a previously registered listener. */
93
+ /**
94
+ * Removes a previously registered listener.
95
+ *
96
+ * @example
97
+ * ```ts
98
+ * emitter.off('build', handler)
99
+ * ```
100
+ */
68
101
  off(eventName, handler) {
69
102
  this.#emitter.off(eventName, handler);
70
103
  }
71
- /** Removes all listeners from every event channel. */
104
+ /**
105
+ * Removes all listeners from every event channel.
106
+ *
107
+ * @example
108
+ * ```ts
109
+ * emitter.removeAll()
110
+ * ```
111
+ */
72
112
  removeAll() {
73
113
  this.#emitter.removeAllListeners();
74
114
  }
@@ -76,8 +116,15 @@ var AsyncEventEmitter = class {
76
116
  //#endregion
77
117
  //#region ../../internals/utils/src/time.ts
78
118
  /**
79
- * Calculates elapsed time in milliseconds from a high-resolution start time.
80
- * Rounds to 2 decimal places to provide sub-millisecond precision without noise.
119
+ * Calculates elapsed time in milliseconds from a high-resolution `process.hrtime` start time.
120
+ * Rounds to 2 decimal places for sub-millisecond precision without noise.
121
+ *
122
+ * @example
123
+ * ```ts
124
+ * const start = process.hrtime()
125
+ * doWork()
126
+ * getElapsedMs(start) // 42.35
127
+ * ```
81
128
  */
82
129
  function getElapsedMs(hrStart) {
83
130
  const [seconds, nanoseconds] = process.hrtime(hrStart);
@@ -85,8 +132,14 @@ function getElapsedMs(hrStart) {
85
132
  return Math.round(ms * 100) / 100;
86
133
  }
87
134
  /**
88
- * Converts a millisecond duration into a human-readable string.
89
- * Adjusts units (ms, s, m s) based on the magnitude of the duration.
135
+ * Converts a millisecond duration into a human-readable string (`ms`, `s`, or `m s`).
136
+ *
137
+ * @example
138
+ * ```ts
139
+ * formatMs(250) // '250ms'
140
+ * formatMs(1500) // '1.50s'
141
+ * formatMs(90000) // '1m 30.0s'
142
+ * ```
90
143
  */
91
144
  function formatMs(ms) {
92
145
  if (ms >= 6e4) return `${Math.floor(ms / 6e4)}m ${(ms % 6e4 / 1e3).toFixed(1)}s`;
@@ -94,7 +147,14 @@ function formatMs(ms) {
94
147
  return `${Math.round(ms)}ms`;
95
148
  }
96
149
  /**
97
- * Convenience helper: formats the elapsed time since `hrStart` in one step.
150
+ * Formats the elapsed time since `hrStart` as a human-readable string.
151
+ *
152
+ * @example
153
+ * ```ts
154
+ * const start = process.hrtime()
155
+ * doWork()
156
+ * formatHrtime(start) // '1.50s'
157
+ * ```
98
158
  */
99
159
  function formatHrtime(hrStart) {
100
160
  return formatMs(getElapsedMs(hrStart));
@@ -136,7 +196,9 @@ function gradient(colorStops, text) {
136
196
  return `\x1b[38;2;${Math.round(from.r + (to.r - from.r) * lt)};${Math.round(from.g + (to.g - from.g) * lt)};${Math.round(from.b + (to.b - from.b) * lt)}m${char}\x1b[0m`;
137
197
  }).join("");
138
198
  }
139
- /** ANSI color functions for each part of the Kubb mascot illustration. */
199
+ /**
200
+ * ANSI color functions for each part of the Kubb mascot illustration.
201
+ */
140
202
  const palette = {
141
203
  lid: hex("#F55A17"),
142
204
  woodTop: hex("#F5A217"),
@@ -147,7 +209,12 @@ const palette = {
147
209
  blush: hex("#FDA4AF")
148
210
  };
149
211
  /**
150
- * Generates the Kubb mascot welcome banner.
212
+ * Generates the Kubb mascot welcome banner as an ANSI-colored string.
213
+ *
214
+ * @example
215
+ * ```ts
216
+ * console.log(getIntro({ title: 'kubb.config.ts', description: 'generating…', version: '5.0.0', areEyesOpen: true }))
217
+ * ```
151
218
  */
152
219
  function getIntro({ title, description, version, areEyesOpen }) {
153
220
  const kubbVersion = gradient([
@@ -165,7 +232,13 @@ function getIntro({ title, description, version, areEyesOpen }) {
165
232
  ${palette.woodBase("▀▀▀▀▀▀▀▀▀▀▀▀▀")}
166
233
  `;
167
234
  }
168
- /** ANSI color names available for terminal output. */
235
+ /** ANSI color names available for deterministic terminal coloring.
236
+ *
237
+ * @example
238
+ * ```ts
239
+ * const color = randomColors[2] // 'green'
240
+ * ```
241
+ */
169
242
  const randomColors = [
170
243
  "black",
171
244
  "red",
@@ -178,15 +251,27 @@ const randomColors = [
178
251
  "gray"
179
252
  ];
180
253
  /**
181
- * Returns the text wrapped in a deterministic ANSI color derived from the text's SHA-256 hash.
254
+ * Wraps `text` in a deterministic ANSI color derived from the text's SHA-256 hash.
255
+ *
256
+ * @example
257
+ * ```ts
258
+ * randomCliColor('petstore') // '\x1b[33mpetstore\x1b[39m' (always the same color for 'petstore')
259
+ * ```
182
260
  */
183
261
  function randomCliColor(text) {
184
262
  if (!text) return "";
185
263
  return styleText(randomColors[createHash("sha256").update(text).digest().readUInt32BE(0) % randomColors.length] ?? "white", text);
186
264
  }
187
265
  /**
188
- * Formats a millisecond duration with an ANSI color based on thresholds:
189
- * green 500 ms · yellow 1 000 ms · red > 1 000 ms
266
+ * Formats a millisecond duration with a threshold-based ANSI color.
267
+ * `≤ 500 ms` → green · `≤ 1 000 ms` → yellow · `> 1 000 ms` → red.
268
+ *
269
+ * @example
270
+ * ```ts
271
+ * formatMsWithColor(200) // '\x1b[32m200ms\x1b[39m'
272
+ * formatMsWithColor(800) // '\x1b[33m800ms\x1b[39m'
273
+ * formatMsWithColor(1500) // '\x1b[31m1.50s\x1b[39m'
274
+ * ```
190
275
  */
191
276
  function formatMsWithColor(ms) {
192
277
  const formatted = formatMs(ms);
@@ -198,24 +283,29 @@ function formatMsWithColor(ms) {
198
283
  //#region ../../internals/utils/src/fs.ts
199
284
  /**
200
285
  * Writes `data` to `path`, trimming leading/trailing whitespace before saving.
201
- * Skips the write and returns `undefined` when the trimmed content is empty or
202
- * identical to what is already on disk.
286
+ * Skips the write when the trimmed content is empty or identical to what is already on disk.
203
287
  * Creates any missing parent directories automatically.
204
- * When `sanity` is `true`, re-reads the file after writing and throws if the
205
- * content does not match.
288
+ * When `sanity` is `true`, re-reads the file after writing and throws if the content does not match.
289
+ *
290
+ * @example
291
+ * ```ts
292
+ * await write('./src/Pet.ts', source) // writes and returns trimmed content
293
+ * await write('./src/Pet.ts', source) // null — file unchanged
294
+ * await write('./src/Pet.ts', ' ') // null — empty content skipped
295
+ * ```
206
296
  */
207
297
  async function write(path, data, options = {}) {
208
298
  const trimmed = data.trim();
209
- if (trimmed === "") return void 0;
299
+ if (trimmed === "") return null;
210
300
  const resolved = resolve(path);
211
301
  if (typeof Bun !== "undefined") {
212
302
  const file = Bun.file(resolved);
213
- if ((await file.exists() ? await file.text() : null) === trimmed) return void 0;
303
+ if ((await file.exists() ? await file.text() : null) === trimmed) return null;
214
304
  await Bun.write(resolved, trimmed);
215
305
  return trimmed;
216
306
  }
217
307
  try {
218
- if (await readFile(resolved, { encoding: "utf-8" }) === trimmed) return void 0;
308
+ if (await readFile(resolved, { encoding: "utf-8" }) === trimmed) return null;
219
309
  } catch {}
220
310
  await mkdir(dirname(resolved), { recursive: true });
221
311
  await writeFile(resolved, trimmed, { encoding: "utf-8" });
@@ -432,15 +522,20 @@ const clackLogger = defineLogger({
432
522
  });
433
523
  context.on("version:new", (version, latestVersion) => {
434
524
  if (logLevel$8 <= logLevel.silent) return;
435
- clack.box(`\`v${version}\` → \`v${latestVersion}\`
525
+ try {
526
+ clack.box(`\`v${version}\` → \`v${latestVersion}\`
436
527
  Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
437
- width: "auto",
438
- formatBorder: (s) => styleText("yellow", s),
439
- rounded: true,
440
- withGuide: false,
441
- contentAlign: "center",
442
- titleAlign: "center"
443
- });
528
+ width: "auto",
529
+ formatBorder: (s) => styleText("yellow", s),
530
+ rounded: true,
531
+ withGuide: false,
532
+ contentAlign: "center",
533
+ titleAlign: "center"
534
+ });
535
+ } catch {
536
+ console.log(`Update available for Kubb: v${version} → v${latestVersion}`);
537
+ console.log("Run `npm install -g @kubb/cli` to update");
538
+ }
444
539
  });
445
540
  context.on("lifecycle:start", async (version) => {
446
541
  console.log(`\n${getIntro({
@@ -610,14 +705,18 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
610
705
  summary.unshift("\n");
611
706
  summary.push("\n");
612
707
  const borderColor = status === "success" ? "green" : "red";
613
- clack.box(summary.join("\n"), getMessage(title), {
614
- width: "auto",
615
- formatBorder: (s) => styleText(borderColor, s),
616
- rounded: true,
617
- withGuide: false,
618
- contentAlign: "left",
619
- titleAlign: "center"
620
- });
708
+ try {
709
+ clack.box(summary.join("\n"), getMessage(title), {
710
+ width: "auto",
711
+ formatBorder: (s) => styleText(borderColor, s),
712
+ rounded: true,
713
+ withGuide: false,
714
+ contentAlign: "left",
715
+ titleAlign: "center"
716
+ });
717
+ } catch {
718
+ console.log(summary.join("\n"));
719
+ }
621
720
  });
622
721
  context.on("lifecycle:end", () => {
623
722
  reset();
@@ -1204,10 +1303,14 @@ async function getCosmiConfig(moduleName, config) {
1204
1303
  `.${moduleName}rc.yaml`,
1205
1304
  `.${moduleName}rc.yml`,
1206
1305
  `.${moduleName}rc.ts`,
1306
+ `.${moduleName}rc.mts`,
1307
+ `.${moduleName}rc.cts`,
1207
1308
  `.${moduleName}rc.js`,
1208
1309
  `.${moduleName}rc.mjs`,
1209
1310
  `.${moduleName}rc.cjs`,
1210
1311
  `${moduleName}.config.ts`,
1312
+ `${moduleName}.config.mts`,
1313
+ `${moduleName}.config.cts`,
1211
1314
  `${moduleName}.config.js`,
1212
1315
  `${moduleName}.config.mjs`,
1213
1316
  `${moduleName}.config.cjs`
@@ -1223,7 +1326,11 @@ async function getCosmiConfig(moduleName, config) {
1223
1326
  }),
1224
1327
  ...searchPlaces
1225
1328
  ],
1226
- loaders: { ".ts": tsLoader }
1329
+ loaders: {
1330
+ ".ts": tsLoader,
1331
+ ".mts": tsLoader,
1332
+ ".cts": tsLoader
1333
+ }
1227
1334
  });
1228
1335
  try {
1229
1336
  result = config ? await explorer.load(config) : await explorer.search();
@@ -1262,6 +1369,7 @@ async function runToolPass({ toolValue, detect, toolMap, toolLabel, successPrefi
1262
1369
  await events.emit("info", `Auto-detected ${toolLabel}: ${styleText("dim", resolvedTool)}`);
1263
1370
  }
1264
1371
  }
1372
+ let toolError;
1265
1373
  if (resolvedTool && resolvedTool !== "auto" && resolvedTool in toolMap) {
1266
1374
  const toolConfig = toolMap[resolvedTool];
1267
1375
  try {
@@ -1292,9 +1400,11 @@ async function runToolPass({ toolValue, detect, toolMap, toolLabel, successPrefi
1292
1400
  const err = new Error(toolConfig.errorMessage);
1293
1401
  err.cause = caughtError;
1294
1402
  await events.emit("error", err);
1403
+ toolError = err;
1295
1404
  }
1296
1405
  }
1297
1406
  await onEnd();
1407
+ if (toolError) throw toolError;
1298
1408
  }
1299
1409
  async function generate({ input, config: userConfig, events, logLevel: logLevel$2 }) {
1300
1410
  const inputPath = input ?? ("path" in userConfig.input ? userConfig.input.path : void 0);
@@ -1316,7 +1426,7 @@ async function generate({ input, config: userConfig, events, logLevel: logLevel$
1316
1426
  };
1317
1427
  await events.emit("generation:start", config);
1318
1428
  await events.emit("info", config.name ? `Setup generation ${styleText("bold", config.name)}` : "Setup generation", inputPath);
1319
- const { sources, fabric, pluginManager } = await setup({
1429
+ const { sources, fabric, driver } = await setup({
1320
1430
  config,
1321
1431
  events
1322
1432
  });
@@ -1325,7 +1435,7 @@ async function generate({ input, config: userConfig, events, logLevel: logLevel$
1325
1435
  config,
1326
1436
  events
1327
1437
  }, {
1328
- pluginManager,
1438
+ driver,
1329
1439
  fabric,
1330
1440
  events,
1331
1441
  sources
@@ -1345,7 +1455,7 @@ async function generate({ input, config: userConfig, events, logLevel: logLevel$
1345
1455
  await sendTelemetry(buildTelemetryEvent({
1346
1456
  command: "generate",
1347
1457
  kubbVersion: version,
1348
- plugins: pluginManager.plugins.map((p) => ({
1458
+ plugins: driver.plugins.map((p) => ({
1349
1459
  name: p.name,
1350
1460
  options: p.options
1351
1461
  })),
@@ -1404,7 +1514,7 @@ async function generate({ input, config: userConfig, events, logLevel: logLevel$
1404
1514
  await sendTelemetry(buildTelemetryEvent({
1405
1515
  command: "generate",
1406
1516
  kubbVersion: version,
1407
- plugins: pluginManager.plugins.map((p) => ({
1517
+ plugins: driver.plugins.map((p) => ({
1408
1518
  name: p.name,
1409
1519
  options: p.options
1410
1520
  })),
@@ -1416,7 +1526,6 @@ async function generate({ input, config: userConfig, events, logLevel: logLevel$
1416
1526
  async function runGenerateCommand({ input, configPath, logLevel: logLevelKey, watch }) {
1417
1527
  const logLevel$3 = logLevel[logLevelKey] ?? logLevel.info;
1418
1528
  const events = new AsyncEventEmitter();
1419
- const promiseManager = new PromiseManager();
1420
1529
  await setupLogger(events, { logLevel: logLevel$3 });
1421
1530
  await executeIfOnline(async () => {
1422
1531
  try {
@@ -1432,30 +1541,22 @@ async function runGenerateCommand({ input, configPath, logLevel: logLevelKey, wa
1432
1541
  await events.emit("success", "Config loaded successfully", path.relative(process$1.cwd(), result.filepath));
1433
1542
  await events.emit("config:end", configs);
1434
1543
  await events.emit("lifecycle:start", version);
1435
- const promises = configs.map((config) => {
1436
- return async () => {
1437
- if (isInputPath(config) && watch) {
1438
- await startWatcher([input || config.input.path], async (paths) => {
1439
- events.removeAll();
1440
- await generate({
1441
- input,
1442
- config,
1443
- logLevel: logLevel$3,
1444
- events
1445
- });
1446
- clack.log.step(styleText("yellow", `Watching for changes in ${paths.join(" and ")}`));
1447
- });
1448
- return;
1449
- }
1450
- await generate({
1451
- input,
1452
- config,
1453
- logLevel: logLevel$3,
1454
- events
1455
- });
1456
- };
1544
+ for (const config of configs) if (isInputPath(config) && watch) await startWatcher([input || config.input.path], async (paths) => {
1545
+ events.removeAll();
1546
+ await generate({
1547
+ input,
1548
+ config,
1549
+ logLevel: logLevel$3,
1550
+ events
1551
+ });
1552
+ clack.log.step(styleText("yellow", `Watching for changes in ${paths.join(" and ")}`));
1553
+ });
1554
+ else await generate({
1555
+ input,
1556
+ config,
1557
+ logLevel: logLevel$3,
1558
+ events
1457
1559
  });
1458
- await promiseManager.run("seq", promises);
1459
1560
  await events.emit("lifecycle:end");
1460
1561
  } catch (error) {
1461
1562
  await events.emit("error", toError(error));
@@ -1465,4 +1566,4 @@ async function runGenerateCommand({ input, configPath, logLevel: logLevelKey, wa
1465
1566
  //#endregion
1466
1567
  export { runGenerateCommand };
1467
1568
 
1468
- //# sourceMappingURL=generate-8xxZmvqZ.js.map
1569
+ //# sourceMappingURL=generate-BjYMvMXy.js.map