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

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 (97) hide show
  1. package/dist/{agent-B2TK-4x7.cjs → agent-BSYWyJsT.cjs} +5 -5
  2. package/dist/{agent-B2TK-4x7.cjs.map → agent-BSYWyJsT.cjs.map} +1 -1
  3. package/dist/{agent-L50VNhXv.js → agent-DTyw-mt7.js} +4 -4
  4. package/dist/{agent-L50VNhXv.js.map → agent-DTyw-mt7.js.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-twir_VZR.js} +5 -5
  8. package/dist/{agent-CxaBPZgN.js.map → agent-twir_VZR.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-DYZYA7O1.js → generate-Bem8MuCe.js} +3 -3
  22. package/dist/{generate-DYZYA7O1.js.map → generate-Bem8MuCe.js.map} +1 -1
  23. package/dist/{generate-C52-Gwzu.cjs → generate-D0kZqfuL.cjs} +3 -3
  24. package/dist/{generate-C52-Gwzu.cjs.map → generate-D0kZqfuL.cjs.map} +1 -1
  25. package/dist/{generate-D8p6X0le.cjs → generate-Rcp3a_oB.cjs} +165 -75
  26. package/dist/generate-Rcp3a_oB.cjs.map +1 -0
  27. package/dist/{generate-8xxZmvqZ.js → generate-aphAGUgm.js} +166 -76
  28. package/dist/generate-aphAGUgm.js.map +1 -0
  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-BH6q17OX.js → init-8SDh_pb0.js} +4 -4
  35. package/dist/{init-BH6q17OX.js.map → init-8SDh_pb0.js.map} +1 -1
  36. package/dist/{init-hmolV6B4.cjs → init-BlriFVH6.cjs} +19 -4
  37. package/dist/init-BlriFVH6.cjs.map +1 -0
  38. package/dist/{init-C-InrmSY.js → init-Y1TNCdzh.js} +19 -4
  39. package/dist/init-Y1TNCdzh.js.map +1 -0
  40. package/dist/{init-BiutNzDD.cjs → init-e8WVahrG.cjs} +4 -4
  41. package/dist/{init-BiutNzDD.cjs.map → init-e8WVahrG.cjs.map} +1 -1
  42. package/dist/{mcp-B9iqBWaU.cjs → mcp-CX15K09_.cjs} +4 -4
  43. package/dist/{mcp-B9iqBWaU.cjs.map → mcp-CX15K09_.cjs.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-Bc7xyp4a.js → mcp-DVfEukVB.js} +4 -4
  47. package/dist/{mcp-Bc7xyp4a.js.map → mcp-DVfEukVB.js.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-Bu9RKng0.js +6 -0
  51. package/dist/package-Bu9RKng0.js.map +1 -0
  52. package/dist/{package-lo3R7SUU.cjs → package-DcCkJTYU.cjs} +2 -2
  53. package/dist/package-DcCkJTYU.cjs.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-DneGZznw.js} +4 -4
  67. package/dist/{validate-DCeW2b2k.js.map → validate-DneGZznw.js.map} +1 -1
  68. package/dist/{validate-B_O2agAB.cjs → validate-SXu2oA86.cjs} +4 -4
  69. package/dist/{validate-B_O2agAB.cjs.map → validate-SXu2oA86.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 +15 -23
  75. package/src/types.ts +11 -0
  76. package/src/utils/flags.ts +10 -0
  77. package/dist/constants-BTUap0zs.cjs.map +0 -1
  78. package/dist/constants-CM3dJzjK.js.map +0 -1
  79. package/dist/define--M_JMcDC.js +0 -25
  80. package/dist/define--M_JMcDC.js.map +0 -1
  81. package/dist/define-D6Kfm7-Z.cjs +0 -36
  82. package/dist/define-D6Kfm7-Z.cjs.map +0 -1
  83. package/dist/errors-6mF_WKxg.js +0 -27
  84. package/dist/errors-6mF_WKxg.js.map +0 -1
  85. package/dist/errors-DBW0N9w4.cjs.map +0 -1
  86. package/dist/generate-8xxZmvqZ.js.map +0 -1
  87. package/dist/generate-D8p6X0le.cjs.map +0 -1
  88. package/dist/init-C-InrmSY.js.map +0 -1
  89. package/dist/init-hmolV6B4.cjs.map +0 -1
  90. package/dist/package-B4LgzOaR.js +0 -6
  91. package/dist/package-B4LgzOaR.js.map +0 -1
  92. package/dist/package-lo3R7SUU.cjs.map +0 -1
  93. package/dist/shell-7HPrTCJ5.cjs.map +0 -1
  94. package/dist/shell-DqqWsHCD.js.map +0 -1
  95. package/dist/telemetry-Cn9X1I5B.cjs.map +0 -1
  96. package/dist/telemetry-DxiR7clS.js.map +0 -1
  97. 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,5 +1,5 @@
1
1
  import "./chunk--u3MIqq1.js";
2
- import { n as defineCommand } from "./define--M_JMcDC.js";
2
+ import { n as defineCommand } from "./define-Ctii4bel.js";
3
3
  //#region src/commands/generate.ts
4
4
  const command = defineCommand({
5
5
  name: "generate",
@@ -51,7 +51,7 @@ const command = defineCommand({
51
51
  },
52
52
  async run({ values, positionals }) {
53
53
  const logLevel = values.debug ? "debug" : values.verbose ? "verbose" : values.silent ? "silent" : values.logLevel;
54
- const { runGenerateCommand } = await import("./generate-8xxZmvqZ.js");
54
+ const { runGenerateCommand } = await import("./generate-aphAGUgm.js");
55
55
  await runGenerateCommand({
56
56
  input: positionals[0],
57
57
  configPath: values.config,
@@ -63,4 +63,4 @@ const command = defineCommand({
63
63
  //#endregion
64
64
  export { command };
65
65
 
66
- //# sourceMappingURL=generate-DYZYA7O1.js.map
66
+ //# sourceMappingURL=generate-Bem8MuCe.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate-DYZYA7O1.js","names":[],"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,UAAU,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,MAAM,OAAO;AAE5C,QAAM,mBAAmB;GAAE,OAAO,YAAY;GAAI,YAAY,OAAO;GAAQ;GAAU,OAAO,OAAO;GAAO,CAAC;;CAEhH,CAAC"}
1
+ {"version":3,"file":"generate-Bem8MuCe.js","names":[],"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,UAAU,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,MAAM,OAAO;AAE5C,QAAM,mBAAmB;GAAE,OAAO,YAAY;GAAI,YAAY,OAAO;GAAQ;GAAU,OAAO,OAAO;GAAO,CAAC;;CAEhH,CAAC"}
@@ -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-Rcp3a_oB.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-D0kZqfuL.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-D0kZqfuL.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
  const require_chunk = require("./chunk-ByKO4r7w.cjs");
2
- const require_errors = require("./errors-DBW0N9w4.cjs");
3
- const require_telemetry = require("./telemetry-Cn9X1I5B.cjs");
4
- const require_shell = require("./shell-7HPrTCJ5.cjs");
5
- const require_package = require("./package-lo3R7SUU.cjs");
6
- const require_constants = require("./constants-BTUap0zs.cjs");
2
+ const require_errors = require("./errors-CLCjoSg0.cjs");
3
+ const require_telemetry = require("./telemetry-YO-uwAbf.cjs");
4
+ const require_shell = require("./shell-475fQKaX.cjs");
5
+ const require_package = require("./package-DcCkJTYU.cjs");
6
+ const require_constants = require("./constants-D0XHAHeZ.cjs");
7
7
  let node_util = require("node:util");
8
8
  let node_events = require("node:events");
9
9
  let node_crypto = require("node:crypto");
@@ -22,12 +22,19 @@ let cosmiconfig = require("cosmiconfig");
22
22
  let jiti = require("jiti");
23
23
  //#region ../../internals/utils/src/asyncEventEmitter.ts
24
24
  /**
25
- * A typed EventEmitter that awaits all async listeners before resolving.
25
+ * Typed `EventEmitter` that awaits all async listeners before resolving.
26
26
  * Wraps Node's `EventEmitter` with full TypeScript event-map inference.
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * const emitter = new AsyncEventEmitter<{ build: [name: string] }>()
31
+ * emitter.on('build', async (name) => { console.log(name) })
32
+ * await emitter.emit('build', 'petstore') // all listeners awaited
33
+ * ```
27
34
  */
28
35
  var AsyncEventEmitter = class {
29
36
  /**
30
- * `maxListener` controls the maximum number of listeners per event before Node emits a memory-leak warning.
37
+ * Maximum number of listeners per event before Node emits a memory-leak warning.
31
38
  * @default 10
32
39
  */
33
40
  constructor(maxListener = 10) {
@@ -35,8 +42,13 @@ var AsyncEventEmitter = class {
35
42
  }
36
43
  #emitter = new node_events.EventEmitter();
37
44
  /**
38
- * Emits an event and awaits all registered listeners in parallel.
45
+ * Emits `eventName` and awaits all registered listeners in parallel.
39
46
  * Throws if any listener rejects, wrapping the cause with the event name and serialized arguments.
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * await emitter.emit('build', 'petstore')
51
+ * ```
40
52
  */
41
53
  async emit(eventName, ...eventArgs) {
42
54
  const listeners = this.#emitter.listeners(eventName);
@@ -55,11 +67,25 @@ var AsyncEventEmitter = class {
55
67
  }
56
68
  }));
57
69
  }
58
- /** Registers a persistent listener for the given event. */
70
+ /**
71
+ * Registers a persistent listener for `eventName`.
72
+ *
73
+ * @example
74
+ * ```ts
75
+ * emitter.on('build', async (name) => { console.log(name) })
76
+ * ```
77
+ */
59
78
  on(eventName, handler) {
60
79
  this.#emitter.on(eventName, handler);
61
80
  }
62
- /** Registers a one-shot listener that removes itself after the first invocation. */
81
+ /**
82
+ * Registers a one-shot listener that removes itself after the first invocation.
83
+ *
84
+ * @example
85
+ * ```ts
86
+ * emitter.onOnce('build', async (name) => { console.log(name) })
87
+ * ```
88
+ */
63
89
  onOnce(eventName, handler) {
64
90
  const wrapper = (...args) => {
65
91
  this.off(eventName, wrapper);
@@ -67,11 +93,25 @@ var AsyncEventEmitter = class {
67
93
  };
68
94
  this.on(eventName, wrapper);
69
95
  }
70
- /** Removes a previously registered listener. */
96
+ /**
97
+ * Removes a previously registered listener.
98
+ *
99
+ * @example
100
+ * ```ts
101
+ * emitter.off('build', handler)
102
+ * ```
103
+ */
71
104
  off(eventName, handler) {
72
105
  this.#emitter.off(eventName, handler);
73
106
  }
74
- /** Removes all listeners from every event channel. */
107
+ /**
108
+ * Removes all listeners from every event channel.
109
+ *
110
+ * @example
111
+ * ```ts
112
+ * emitter.removeAll()
113
+ * ```
114
+ */
75
115
  removeAll() {
76
116
  this.#emitter.removeAllListeners();
77
117
  }
@@ -79,8 +119,15 @@ var AsyncEventEmitter = class {
79
119
  //#endregion
80
120
  //#region ../../internals/utils/src/time.ts
81
121
  /**
82
- * Calculates elapsed time in milliseconds from a high-resolution start time.
83
- * Rounds to 2 decimal places to provide sub-millisecond precision without noise.
122
+ * Calculates elapsed time in milliseconds from a high-resolution `process.hrtime` start time.
123
+ * Rounds to 2 decimal places for sub-millisecond precision without noise.
124
+ *
125
+ * @example
126
+ * ```ts
127
+ * const start = process.hrtime()
128
+ * doWork()
129
+ * getElapsedMs(start) // 42.35
130
+ * ```
84
131
  */
85
132
  function getElapsedMs(hrStart) {
86
133
  const [seconds, nanoseconds] = process.hrtime(hrStart);
@@ -88,8 +135,14 @@ function getElapsedMs(hrStart) {
88
135
  return Math.round(ms * 100) / 100;
89
136
  }
90
137
  /**
91
- * Converts a millisecond duration into a human-readable string.
92
- * Adjusts units (ms, s, m s) based on the magnitude of the duration.
138
+ * Converts a millisecond duration into a human-readable string (`ms`, `s`, or `m s`).
139
+ *
140
+ * @example
141
+ * ```ts
142
+ * formatMs(250) // '250ms'
143
+ * formatMs(1500) // '1.50s'
144
+ * formatMs(90000) // '1m 30.0s'
145
+ * ```
93
146
  */
94
147
  function formatMs(ms) {
95
148
  if (ms >= 6e4) return `${Math.floor(ms / 6e4)}m ${(ms % 6e4 / 1e3).toFixed(1)}s`;
@@ -97,7 +150,14 @@ function formatMs(ms) {
97
150
  return `${Math.round(ms)}ms`;
98
151
  }
99
152
  /**
100
- * Convenience helper: formats the elapsed time since `hrStart` in one step.
153
+ * Formats the elapsed time since `hrStart` as a human-readable string.
154
+ *
155
+ * @example
156
+ * ```ts
157
+ * const start = process.hrtime()
158
+ * doWork()
159
+ * formatHrtime(start) // '1.50s'
160
+ * ```
101
161
  */
102
162
  function formatHrtime(hrStart) {
103
163
  return formatMs(getElapsedMs(hrStart));
@@ -139,7 +199,9 @@ function gradient(colorStops, text) {
139
199
  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`;
140
200
  }).join("");
141
201
  }
142
- /** ANSI color functions for each part of the Kubb mascot illustration. */
202
+ /**
203
+ * ANSI color functions for each part of the Kubb mascot illustration.
204
+ */
143
205
  const palette = {
144
206
  lid: hex("#F55A17"),
145
207
  woodTop: hex("#F5A217"),
@@ -150,7 +212,12 @@ const palette = {
150
212
  blush: hex("#FDA4AF")
151
213
  };
152
214
  /**
153
- * Generates the Kubb mascot welcome banner.
215
+ * Generates the Kubb mascot welcome banner as an ANSI-colored string.
216
+ *
217
+ * @example
218
+ * ```ts
219
+ * console.log(getIntro({ title: 'kubb.config.ts', description: 'generating…', version: '5.0.0', areEyesOpen: true }))
220
+ * ```
154
221
  */
155
222
  function getIntro({ title, description, version, areEyesOpen }) {
156
223
  const kubbVersion = gradient([
@@ -168,7 +235,13 @@ function getIntro({ title, description, version, areEyesOpen }) {
168
235
  ${palette.woodBase("▀▀▀▀▀▀▀▀▀▀▀▀▀")}
169
236
  `;
170
237
  }
171
- /** ANSI color names available for terminal output. */
238
+ /** ANSI color names available for deterministic terminal coloring.
239
+ *
240
+ * @example
241
+ * ```ts
242
+ * const color = randomColors[2] // 'green'
243
+ * ```
244
+ */
172
245
  const randomColors = [
173
246
  "black",
174
247
  "red",
@@ -181,15 +254,27 @@ const randomColors = [
181
254
  "gray"
182
255
  ];
183
256
  /**
184
- * Returns the text wrapped in a deterministic ANSI color derived from the text's SHA-256 hash.
257
+ * Wraps `text` in a deterministic ANSI color derived from the text's SHA-256 hash.
258
+ *
259
+ * @example
260
+ * ```ts
261
+ * randomCliColor('petstore') // '\x1b[33mpetstore\x1b[39m' (always the same color for 'petstore')
262
+ * ```
185
263
  */
186
264
  function randomCliColor(text) {
187
265
  if (!text) return "";
188
266
  return (0, node_util.styleText)(randomColors[(0, node_crypto.createHash)("sha256").update(text).digest().readUInt32BE(0) % randomColors.length] ?? "white", text);
189
267
  }
190
268
  /**
191
- * Formats a millisecond duration with an ANSI color based on thresholds:
192
- * green 500 ms · yellow 1 000 ms · red > 1 000 ms
269
+ * Formats a millisecond duration with a threshold-based ANSI color.
270
+ * `≤ 500 ms` → green · `≤ 1 000 ms` → yellow · `> 1 000 ms` → red.
271
+ *
272
+ * @example
273
+ * ```ts
274
+ * formatMsWithColor(200) // '\x1b[32m200ms\x1b[39m'
275
+ * formatMsWithColor(800) // '\x1b[33m800ms\x1b[39m'
276
+ * formatMsWithColor(1500) // '\x1b[31m1.50s\x1b[39m'
277
+ * ```
193
278
  */
194
279
  function formatMsWithColor(ms) {
195
280
  const formatted = formatMs(ms);
@@ -201,24 +286,29 @@ function formatMsWithColor(ms) {
201
286
  //#region ../../internals/utils/src/fs.ts
202
287
  /**
203
288
  * Writes `data` to `path`, trimming leading/trailing whitespace before saving.
204
- * Skips the write and returns `undefined` when the trimmed content is empty or
205
- * identical to what is already on disk.
289
+ * Skips the write when the trimmed content is empty or identical to what is already on disk.
206
290
  * Creates any missing parent directories automatically.
207
- * When `sanity` is `true`, re-reads the file after writing and throws if the
208
- * content does not match.
291
+ * When `sanity` is `true`, re-reads the file after writing and throws if the content does not match.
292
+ *
293
+ * @example
294
+ * ```ts
295
+ * await write('./src/Pet.ts', source) // writes and returns trimmed content
296
+ * await write('./src/Pet.ts', source) // null — file unchanged
297
+ * await write('./src/Pet.ts', ' ') // null — empty content skipped
298
+ * ```
209
299
  */
210
300
  async function write(path, data, options = {}) {
211
301
  const trimmed = data.trim();
212
- if (trimmed === "") return void 0;
302
+ if (trimmed === "") return null;
213
303
  const resolved = (0, node_path.resolve)(path);
214
304
  if (typeof Bun !== "undefined") {
215
305
  const file = Bun.file(resolved);
216
- if ((await file.exists() ? await file.text() : null) === trimmed) return void 0;
306
+ if ((await file.exists() ? await file.text() : null) === trimmed) return null;
217
307
  await Bun.write(resolved, trimmed);
218
308
  return trimmed;
219
309
  }
220
310
  try {
221
- if (await (0, node_fs_promises.readFile)(resolved, { encoding: "utf-8" }) === trimmed) return void 0;
311
+ if (await (0, node_fs_promises.readFile)(resolved, { encoding: "utf-8" }) === trimmed) return null;
222
312
  } catch {}
223
313
  await (0, node_fs_promises.mkdir)((0, node_path.dirname)(resolved), { recursive: true });
224
314
  await (0, node_fs_promises.writeFile)(resolved, trimmed, { encoding: "utf-8" });
@@ -435,15 +525,20 @@ const clackLogger = (0, _kubb_core.defineLogger)({
435
525
  });
436
526
  context.on("version:new", (version, latestVersion) => {
437
527
  if (logLevel <= _kubb_core.logLevel.silent) return;
438
- _clack_prompts.box(`\`v${version}\` → \`v${latestVersion}\`
528
+ try {
529
+ _clack_prompts.box(`\`v${version}\` → \`v${latestVersion}\`
439
530
  Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
440
- width: "auto",
441
- formatBorder: (s) => (0, node_util.styleText)("yellow", s),
442
- rounded: true,
443
- withGuide: false,
444
- contentAlign: "center",
445
- titleAlign: "center"
446
- });
531
+ width: "auto",
532
+ formatBorder: (s) => (0, node_util.styleText)("yellow", s),
533
+ rounded: true,
534
+ withGuide: false,
535
+ contentAlign: "center",
536
+ titleAlign: "center"
537
+ });
538
+ } catch {
539
+ console.log(`Update available for Kubb: v${version} → v${latestVersion}`);
540
+ console.log("Run `npm install -g @kubb/cli` to update");
541
+ }
447
542
  });
448
543
  context.on("lifecycle:start", async (version) => {
449
544
  console.log(`\n${getIntro({
@@ -613,14 +708,18 @@ Run \`npm install -g @kubb/cli\` to update`, "Update available for `Kubb`", {
613
708
  summary.unshift("\n");
614
709
  summary.push("\n");
615
710
  const borderColor = status === "success" ? "green" : "red";
616
- _clack_prompts.box(summary.join("\n"), getMessage(title), {
617
- width: "auto",
618
- formatBorder: (s) => (0, node_util.styleText)(borderColor, s),
619
- rounded: true,
620
- withGuide: false,
621
- contentAlign: "left",
622
- titleAlign: "center"
623
- });
711
+ try {
712
+ _clack_prompts.box(summary.join("\n"), getMessage(title), {
713
+ width: "auto",
714
+ formatBorder: (s) => (0, node_util.styleText)(borderColor, s),
715
+ rounded: true,
716
+ withGuide: false,
717
+ contentAlign: "left",
718
+ titleAlign: "center"
719
+ });
720
+ } catch {
721
+ console.log(summary.join("\n"));
722
+ }
624
723
  });
625
724
  context.on("lifecycle:end", () => {
626
725
  reset();
@@ -1319,7 +1418,7 @@ async function generate({ input, config: userConfig, events, logLevel }) {
1319
1418
  };
1320
1419
  await events.emit("generation:start", config);
1321
1420
  await events.emit("info", config.name ? `Setup generation ${(0, node_util.styleText)("bold", config.name)}` : "Setup generation", inputPath);
1322
- const { sources, fabric, pluginManager } = await (0, _kubb_core.setup)({
1421
+ const { sources, fabric, driver } = await (0, _kubb_core.setup)({
1323
1422
  config,
1324
1423
  events
1325
1424
  });
@@ -1328,7 +1427,7 @@ async function generate({ input, config: userConfig, events, logLevel }) {
1328
1427
  config,
1329
1428
  events
1330
1429
  }, {
1331
- pluginManager,
1430
+ driver,
1332
1431
  fabric,
1333
1432
  events,
1334
1433
  sources
@@ -1348,7 +1447,7 @@ async function generate({ input, config: userConfig, events, logLevel }) {
1348
1447
  await require_telemetry.sendTelemetry(require_telemetry.buildTelemetryEvent({
1349
1448
  command: "generate",
1350
1449
  kubbVersion: require_package.version,
1351
- plugins: pluginManager.plugins.map((p) => ({
1450
+ plugins: driver.plugins.map((p) => ({
1352
1451
  name: p.name,
1353
1452
  options: p.options
1354
1453
  })),
@@ -1407,7 +1506,7 @@ async function generate({ input, config: userConfig, events, logLevel }) {
1407
1506
  await require_telemetry.sendTelemetry(require_telemetry.buildTelemetryEvent({
1408
1507
  command: "generate",
1409
1508
  kubbVersion: require_package.version,
1410
- plugins: pluginManager.plugins.map((p) => ({
1509
+ plugins: driver.plugins.map((p) => ({
1411
1510
  name: p.name,
1412
1511
  options: p.options
1413
1512
  })),
@@ -1419,7 +1518,6 @@ async function generate({ input, config: userConfig, events, logLevel }) {
1419
1518
  async function runGenerateCommand({ input, configPath, logLevel: logLevelKey, watch }) {
1420
1519
  const logLevel = _kubb_core.logLevel[logLevelKey] ?? _kubb_core.logLevel.info;
1421
1520
  const events = new AsyncEventEmitter();
1422
- const promiseManager = new _kubb_core.PromiseManager();
1423
1521
  await setupLogger(events, { logLevel });
1424
1522
  await require_telemetry.executeIfOnline(async () => {
1425
1523
  try {
@@ -1435,30 +1533,22 @@ async function runGenerateCommand({ input, configPath, logLevel: logLevelKey, wa
1435
1533
  await events.emit("success", "Config loaded successfully", node_path.default.relative(node_process.default.cwd(), result.filepath));
1436
1534
  await events.emit("config:end", configs);
1437
1535
  await events.emit("lifecycle:start", require_package.version);
1438
- const promises = configs.map((config) => {
1439
- return async () => {
1440
- if ((0, _kubb_core.isInputPath)(config) && watch) {
1441
- await startWatcher([input || config.input.path], async (paths) => {
1442
- events.removeAll();
1443
- await generate({
1444
- input,
1445
- config,
1446
- logLevel,
1447
- events
1448
- });
1449
- _clack_prompts.log.step((0, node_util.styleText)("yellow", `Watching for changes in ${paths.join(" and ")}`));
1450
- });
1451
- return;
1452
- }
1453
- await generate({
1454
- input,
1455
- config,
1456
- logLevel,
1457
- events
1458
- });
1459
- };
1536
+ for (const config of configs) if ((0, _kubb_core.isInputPath)(config) && watch) await startWatcher([input || config.input.path], async (paths) => {
1537
+ events.removeAll();
1538
+ await generate({
1539
+ input,
1540
+ config,
1541
+ logLevel,
1542
+ events
1543
+ });
1544
+ _clack_prompts.log.step((0, node_util.styleText)("yellow", `Watching for changes in ${paths.join(" and ")}`));
1545
+ });
1546
+ else await generate({
1547
+ input,
1548
+ config,
1549
+ logLevel,
1550
+ events
1460
1551
  });
1461
- await promiseManager.run("seq", promises);
1462
1552
  await events.emit("lifecycle:end");
1463
1553
  } catch (error) {
1464
1554
  await events.emit("error", require_errors.toError(error));
@@ -1468,4 +1558,4 @@ async function runGenerateCommand({ input, configPath, logLevel: logLevelKey, wa
1468
1558
  //#endregion
1469
1559
  exports.runGenerateCommand = runGenerateCommand;
1470
1560
 
1471
- //# sourceMappingURL=generate-D8p6X0le.cjs.map
1561
+ //# sourceMappingURL=generate-Rcp3a_oB.cjs.map