@kubb/cli 5.0.0-alpha.8 → 5.0.0-beta.1

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 (139) hide show
  1. package/README.md +4 -2
  2. package/bin/kubb.js +6 -0
  3. package/dist/agent-B_pirbeB.cjs +116 -0
  4. package/dist/agent-B_pirbeB.cjs.map +1 -0
  5. package/dist/{agent-B116NMCE.cjs → agent-CUmEyiqY.cjs} +5 -5
  6. package/dist/agent-CUmEyiqY.cjs.map +1 -0
  7. package/dist/agent-Ev5hU5hH.js +112 -0
  8. package/dist/agent-Ev5hU5hH.js.map +1 -0
  9. package/dist/{agent-CFRroclh.js → agent-v_2S-bnN.js} +5 -5
  10. package/dist/agent-v_2S-bnN.js.map +1 -0
  11. package/dist/{constants-BTUap0zs.cjs → constants-CnDXa1R6.cjs} +60 -20
  12. package/dist/constants-CnDXa1R6.cjs.map +1 -0
  13. package/dist/constants-aL3CP_Wq.js +95 -0
  14. package/dist/constants-aL3CP_Wq.js.map +1 -0
  15. package/dist/define-Bdn8j5VM.cjs +54 -0
  16. package/dist/define-Bdn8j5VM.cjs.map +1 -0
  17. package/dist/define-Ctii4bel.js +43 -0
  18. package/dist/define-Ctii4bel.js.map +1 -0
  19. package/dist/{errors-DBW0N9w4.cjs → errors-CLCjoSg0.cjs} +22 -6
  20. package/dist/errors-CLCjoSg0.cjs.map +1 -0
  21. package/dist/errors-CjPmyZHy.js +43 -0
  22. package/dist/errors-CjPmyZHy.js.map +1 -0
  23. package/dist/{generate-B8tpu0Dc.js → generate-BaJRhbCS.js} +3 -3
  24. package/dist/generate-BaJRhbCS.js.map +1 -0
  25. package/dist/{generate-BblrHXQC.js → generate-CuxArvEk.js} +556 -262
  26. package/dist/generate-CuxArvEk.js.map +1 -0
  27. package/dist/{generate-D58EaZny.cjs → generate-TL8zY_IT.cjs} +3 -3
  28. package/dist/generate-TL8zY_IT.cjs.map +1 -0
  29. package/dist/{generate-D_pi7lhe.cjs → generate-UCP0qpDp.cjs} +563 -269
  30. package/dist/generate-UCP0qpDp.cjs.map +1 -0
  31. package/dist/index.cjs +48 -21
  32. package/dist/index.cjs.map +1 -1
  33. package/dist/index.d.ts +1 -1
  34. package/dist/index.js +48 -21
  35. package/dist/index.js.map +1 -1
  36. package/dist/{init-hmolV6B4.cjs → init-CZ5Xq2Hd.cjs} +45 -58
  37. package/dist/init-CZ5Xq2Hd.cjs.map +1 -0
  38. package/dist/{init-B56F3Qon.cjs → init-DRR_YWIq.cjs} +4 -4
  39. package/dist/init-DRR_YWIq.cjs.map +1 -0
  40. package/dist/{init-v0GeyJkz.js → init-DSnRd1RJ.js} +4 -4
  41. package/dist/init-DSnRd1RJ.js.map +1 -0
  42. package/dist/{init-C-InrmSY.js → init-eNRlotJK.js} +41 -54
  43. package/dist/init-eNRlotJK.js.map +1 -0
  44. package/dist/{mcp-ChHFPRzD.cjs → mcp-CLcDV4Jm.cjs} +5 -6
  45. package/dist/mcp-CLcDV4Jm.cjs.map +1 -0
  46. package/dist/{mcp-D2SHEg_d.js → mcp-D7EIR9fR.js} +4 -5
  47. package/dist/mcp-D7EIR9fR.js.map +1 -0
  48. package/dist/{mcp-0AmU5JUD.js → mcp-Dakxi9CL.js} +4 -4
  49. package/dist/{mcp-0AmU5JUD.js.map → mcp-Dakxi9CL.js.map} +1 -1
  50. package/dist/{mcp-B0Jz5z2r.cjs → mcp-Dr_RY-hd.cjs} +4 -4
  51. package/dist/{mcp-B0Jz5z2r.cjs.map → mcp-Dr_RY-hd.cjs.map} +1 -1
  52. package/dist/{package-CbrJTkI2.cjs → package-Cdo6lNjF.cjs} +2 -2
  53. package/dist/package-Cdo6lNjF.cjs.map +1 -0
  54. package/dist/package-DPooAj2l.js +6 -0
  55. package/dist/package-DPooAj2l.js.map +1 -0
  56. package/dist/{shell-7HPrTCJ5.cjs → shell-475fQKaX.cjs} +8 -3
  57. package/dist/shell-475fQKaX.cjs.map +1 -0
  58. package/dist/{shell-DqqWsHCD.js → shell-DLzN4fRo.js} +8 -3
  59. package/dist/shell-DLzN4fRo.js.map +1 -0
  60. package/dist/{telemetry-Cn9X1I5B.cjs → telemetry-DN95_2pF.cjs} +50 -8
  61. package/dist/telemetry-DN95_2pF.cjs.map +1 -0
  62. package/dist/{telemetry-DxiR7clS.js → telemetry-LgT_sdPe.js} +48 -6
  63. package/dist/telemetry-LgT_sdPe.js.map +1 -0
  64. package/dist/{validate-D5CuvkLl.js → validate-B1o-rY9o.js} +4 -4
  65. package/dist/validate-B1o-rY9o.js.map +1 -0
  66. package/dist/{validate-D8Zb-dns.cjs → validate-CXFY-mHL.cjs} +4 -4
  67. package/dist/validate-CXFY-mHL.cjs.map +1 -0
  68. package/dist/{validate-l8vLmwKA.js → validate-kLJoT_hi.js} +5 -13
  69. package/dist/validate-kLJoT_hi.js.map +1 -0
  70. package/dist/{validate-Bbrn3Q-A.cjs → validate-yKKzqEZ5.cjs} +6 -14
  71. package/dist/validate-yKKzqEZ5.cjs.map +1 -0
  72. package/package.json +47 -46
  73. package/src/commands/agent/start.ts +20 -4
  74. package/src/commands/generate.ts +35 -6
  75. package/src/commands/init.ts +6 -1
  76. package/src/commands/validate.ts +6 -1
  77. package/src/constants.ts +50 -22
  78. package/src/index.ts +10 -12
  79. package/src/loggers/clackLogger.ts +57 -50
  80. package/src/loggers/fileSystemLogger.ts +17 -18
  81. package/src/loggers/githubActionsLogger.ts +25 -26
  82. package/src/loggers/plainLogger.ts +24 -25
  83. package/src/runners/agent.ts +81 -34
  84. package/src/runners/generate.ts +90 -100
  85. package/src/runners/init.ts +24 -51
  86. package/src/runners/mcp.ts +17 -4
  87. package/src/runners/validate.ts +19 -15
  88. package/src/types.ts +11 -0
  89. package/src/utils/executeHooks.ts +15 -15
  90. package/src/utils/flags.ts +9 -0
  91. package/src/utils/getConfig.ts +10 -0
  92. package/src/utils/getCosmiConfig.ts +21 -12
  93. package/src/utils/getSummary.ts +1 -1
  94. package/src/utils/runHook.ts +29 -13
  95. package/src/utils/telemetry.ts +16 -3
  96. package/bin/kubb.cjs +0 -18
  97. package/dist/agent-B116NMCE.cjs.map +0 -1
  98. package/dist/agent-C6o_6GSJ.cjs +0 -92
  99. package/dist/agent-C6o_6GSJ.cjs.map +0 -1
  100. package/dist/agent-CFRroclh.js.map +0 -1
  101. package/dist/agent-L50VNhXv.js +0 -88
  102. package/dist/agent-L50VNhXv.js.map +0 -1
  103. package/dist/constants-BTUap0zs.cjs.map +0 -1
  104. package/dist/constants-CM3dJzjK.js +0 -67
  105. package/dist/constants-CM3dJzjK.js.map +0 -1
  106. package/dist/define--M_JMcDC.js +0 -25
  107. package/dist/define--M_JMcDC.js.map +0 -1
  108. package/dist/define-D6Kfm7-Z.cjs +0 -36
  109. package/dist/define-D6Kfm7-Z.cjs.map +0 -1
  110. package/dist/errors-6mF_WKxg.js +0 -27
  111. package/dist/errors-6mF_WKxg.js.map +0 -1
  112. package/dist/errors-DBW0N9w4.cjs.map +0 -1
  113. package/dist/generate-B8tpu0Dc.js.map +0 -1
  114. package/dist/generate-BblrHXQC.js.map +0 -1
  115. package/dist/generate-D58EaZny.cjs.map +0 -1
  116. package/dist/generate-D_pi7lhe.cjs.map +0 -1
  117. package/dist/init-B56F3Qon.cjs.map +0 -1
  118. package/dist/init-C-InrmSY.js.map +0 -1
  119. package/dist/init-hmolV6B4.cjs.map +0 -1
  120. package/dist/init-v0GeyJkz.js.map +0 -1
  121. package/dist/jiti-Cd3S0xwr.cjs +0 -16
  122. package/dist/jiti-Cd3S0xwr.cjs.map +0 -1
  123. package/dist/jiti-e08mD2Ph.js +0 -11
  124. package/dist/jiti-e08mD2Ph.js.map +0 -1
  125. package/dist/mcp-ChHFPRzD.cjs.map +0 -1
  126. package/dist/mcp-D2SHEg_d.js.map +0 -1
  127. package/dist/package-BAVK5o-U.js +0 -6
  128. package/dist/package-BAVK5o-U.js.map +0 -1
  129. package/dist/package-CbrJTkI2.cjs.map +0 -1
  130. package/dist/shell-7HPrTCJ5.cjs.map +0 -1
  131. package/dist/shell-DqqWsHCD.js.map +0 -1
  132. package/dist/telemetry-Cn9X1I5B.cjs.map +0 -1
  133. package/dist/telemetry-DxiR7clS.js.map +0 -1
  134. package/dist/validate-Bbrn3Q-A.cjs.map +0 -1
  135. package/dist/validate-D5CuvkLl.js.map +0 -1
  136. package/dist/validate-D8Zb-dns.cjs.map +0 -1
  137. package/dist/validate-l8vLmwKA.js.map +0 -1
  138. package/src/utils/getIntro.ts +0 -1
  139. package/src/utils/jiti.ts +0 -9
@@ -0,0 +1,54 @@
1
+ require("./chunk-ByKO4r7w.cjs");
2
+ //#region ../../internals/utils/src/cli/define.ts
3
+ /**
4
+ * Returns a `CLIAdapter` as-is with full type inference. Pass a custom adapter to `createCLI` to swap the CLI engine.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * const adapter = defineCLIAdapter({ run: myRun, renderHelp: myHelp })
9
+ * createCLI({ adapter }).run(commands, argv, opts)
10
+ * ```
11
+ */
12
+ function defineCLIAdapter(adapter) {
13
+ return adapter;
14
+ }
15
+ /**
16
+ * Returns a `CommandDefinition` with typed `values` in `run()`.
17
+ * The callback receives `values` inferred from the declared options — no casts needed.
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * const generate = defineCommand({
22
+ * name: 'generate',
23
+ * description: 'Generate client code',
24
+ * options: { config: { type: 'string', description: 'Config path' } },
25
+ * async run({ values }) { console.log(values.config) },
26
+ * })
27
+ * ```
28
+ */
29
+ function defineCommand(def) {
30
+ const { run, ...rest } = def;
31
+ if (!run) return rest;
32
+ return {
33
+ ...rest,
34
+ run: (args) => run({
35
+ values: args.values,
36
+ positionals: args.positionals
37
+ })
38
+ };
39
+ }
40
+ //#endregion
41
+ Object.defineProperty(exports, "defineCLIAdapter", {
42
+ enumerable: true,
43
+ get: function() {
44
+ return defineCLIAdapter;
45
+ }
46
+ });
47
+ Object.defineProperty(exports, "defineCommand", {
48
+ enumerable: true,
49
+ get: function() {
50
+ return defineCommand;
51
+ }
52
+ });
53
+
54
+ //# sourceMappingURL=define-Bdn8j5VM.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define-Bdn8j5VM.cjs","names":[],"sources":["../../../internals/utils/src/cli/define.ts"],"sourcesContent":["import type { CLIAdapter, CommandDefinition, OptionDefinition } from './types.ts'\n\ntype OptionTypeMap = { string: string; boolean: boolean }\n\ntype IsRequired<O extends OptionDefinition> = O['default'] extends string | boolean ? true : O['required'] extends true ? true : false\n\n/**\n * Infers typed values from an options record. Options with a `default` or `required: true` are always defined.\n */\ntype InferValues<O extends Record<string, OptionDefinition>> = {\n [K in keyof O as IsRequired<O[K]> extends true ? K : never]: OptionTypeMap[O[K]['type']]\n} & {\n [K in keyof O as IsRequired<O[K]> extends true ? never : K]?: OptionTypeMap[O[K]['type']]\n}\n\n/**\n * Returns a `CLIAdapter` as-is with full type inference. Pass a custom adapter to `createCLI` to swap the CLI engine.\n *\n * @example\n * ```ts\n * const adapter = defineCLIAdapter({ run: myRun, renderHelp: myHelp })\n * createCLI({ adapter }).run(commands, argv, opts)\n * ```\n */\nexport function defineCLIAdapter(adapter: CLIAdapter): CLIAdapter {\n return adapter\n}\n\n/**\n * Returns a `CommandDefinition` with typed `values` in `run()`.\n * The callback receives `values` inferred from the declared options — no casts needed.\n *\n * @example\n * ```ts\n * const generate = defineCommand({\n * name: 'generate',\n * description: 'Generate client code',\n * options: { config: { type: 'string', description: 'Config path' } },\n * async run({ values }) { console.log(values.config) },\n * })\n * ```\n */\nexport function defineCommand<O extends Record<string, OptionDefinition>>(def: {\n name: string\n description: string\n arguments?: string[]\n options?: O\n subCommands?: CommandDefinition[]\n run?: (args: { values: InferValues<O>; positionals: string[] }) => Promise<void>\n}): CommandDefinition {\n const { run, ...rest } = def\n if (!run) return rest\n return {\n ...rest,\n run: (args) =>\n run({\n values: args.values as InferValues<O>,\n positionals: args.positionals,\n }),\n }\n}\n"],"mappings":";;;;;;;;;;;AAwBA,SAAgB,iBAAiB,SAAiC;AAChE,QAAO;;;;;;;;;;;;;;;;AAiBT,SAAgB,cAA0D,KAOpD;CACpB,MAAM,EAAE,KAAK,GAAG,SAAS;AACzB,KAAI,CAAC,IAAK,QAAO;AACjB,QAAO;EACL,GAAG;EACH,MAAM,SACJ,IAAI;GACF,QAAQ,KAAK;GACb,aAAa,KAAK;GACnB,CAAC;EACL"}
@@ -0,0 +1,43 @@
1
+ import "./chunk--u3MIqq1.js";
2
+ //#region ../../internals/utils/src/cli/define.ts
3
+ /**
4
+ * Returns a `CLIAdapter` as-is with full type inference. Pass a custom adapter to `createCLI` to swap the CLI engine.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * const adapter = defineCLIAdapter({ run: myRun, renderHelp: myHelp })
9
+ * createCLI({ adapter }).run(commands, argv, opts)
10
+ * ```
11
+ */
12
+ function defineCLIAdapter(adapter) {
13
+ return adapter;
14
+ }
15
+ /**
16
+ * Returns a `CommandDefinition` with typed `values` in `run()`.
17
+ * The callback receives `values` inferred from the declared options — no casts needed.
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * const generate = defineCommand({
22
+ * name: 'generate',
23
+ * description: 'Generate client code',
24
+ * options: { config: { type: 'string', description: 'Config path' } },
25
+ * async run({ values }) { console.log(values.config) },
26
+ * })
27
+ * ```
28
+ */
29
+ function defineCommand(def) {
30
+ const { run, ...rest } = def;
31
+ if (!run) return rest;
32
+ return {
33
+ ...rest,
34
+ run: (args) => run({
35
+ values: args.values,
36
+ positionals: args.positionals
37
+ })
38
+ };
39
+ }
40
+ //#endregion
41
+ export { defineCommand as n, defineCLIAdapter as t };
42
+
43
+ //# sourceMappingURL=define-Ctii4bel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define-Ctii4bel.js","names":[],"sources":["../../../internals/utils/src/cli/define.ts"],"sourcesContent":["import type { CLIAdapter, CommandDefinition, OptionDefinition } from './types.ts'\n\ntype OptionTypeMap = { string: string; boolean: boolean }\n\ntype IsRequired<O extends OptionDefinition> = O['default'] extends string | boolean ? true : O['required'] extends true ? true : false\n\n/**\n * Infers typed values from an options record. Options with a `default` or `required: true` are always defined.\n */\ntype InferValues<O extends Record<string, OptionDefinition>> = {\n [K in keyof O as IsRequired<O[K]> extends true ? K : never]: OptionTypeMap[O[K]['type']]\n} & {\n [K in keyof O as IsRequired<O[K]> extends true ? never : K]?: OptionTypeMap[O[K]['type']]\n}\n\n/**\n * Returns a `CLIAdapter` as-is with full type inference. Pass a custom adapter to `createCLI` to swap the CLI engine.\n *\n * @example\n * ```ts\n * const adapter = defineCLIAdapter({ run: myRun, renderHelp: myHelp })\n * createCLI({ adapter }).run(commands, argv, opts)\n * ```\n */\nexport function defineCLIAdapter(adapter: CLIAdapter): CLIAdapter {\n return adapter\n}\n\n/**\n * Returns a `CommandDefinition` with typed `values` in `run()`.\n * The callback receives `values` inferred from the declared options — no casts needed.\n *\n * @example\n * ```ts\n * const generate = defineCommand({\n * name: 'generate',\n * description: 'Generate client code',\n * options: { config: { type: 'string', description: 'Config path' } },\n * async run({ values }) { console.log(values.config) },\n * })\n * ```\n */\nexport function defineCommand<O extends Record<string, OptionDefinition>>(def: {\n name: string\n description: string\n arguments?: string[]\n options?: O\n subCommands?: CommandDefinition[]\n run?: (args: { values: InferValues<O>; positionals: string[] }) => Promise<void>\n}): CommandDefinition {\n const { run, ...rest } = def\n if (!run) return rest\n return {\n ...rest,\n run: (args) =>\n run({\n values: args.values as InferValues<O>,\n positionals: args.positionals,\n }),\n }\n}\n"],"mappings":";;;;;;;;;;;AAwBA,SAAgB,iBAAiB,SAAiC;AAChE,QAAO;;;;;;;;;;;;;;;;AAiBT,SAAgB,cAA0D,KAOpD;CACpB,MAAM,EAAE,KAAK,GAAG,SAAS;AACzB,KAAI,CAAC,IAAK,QAAO;AACjB,QAAO;EACL,GAAG;EACH,MAAM,SACJ,IAAI;GACF,QAAQ,KAAK;GACb,aAAa,KAAK;GACnB,CAAC;EACL"}
@@ -2,21 +2,37 @@ require("./chunk-ByKO4r7w.cjs");
2
2
  //#region ../../internals/utils/src/errors.ts
3
3
  /**
4
4
  * Coerces an unknown thrown value to an `Error` instance.
5
- * When the value is already an `Error` it is returned as-is;
6
- * otherwise a new `Error` is created whose message is `String(value)`.
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
+ * ```
7
13
  */
8
14
  function toError(value) {
9
15
  return value instanceof Error ? value : new Error(String(value));
10
16
  }
11
17
  /**
12
- * Safely extracts a human-readable message from any thrown value.
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
+ * ```
13
25
  */
14
26
  function getErrorMessage(value) {
15
27
  return value instanceof Error ? value.message : String(value);
16
28
  }
17
29
  /**
18
- * Extracts the `.cause` of an `Error` as an `Error | undefined`.
19
- * Returns `undefined` when the cause is absent or is not an `Error`.
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
+ * ```
20
36
  */
21
37
  function toCause(error) {
22
38
  return error.cause instanceof Error ? error.cause : void 0;
@@ -41,4 +57,4 @@ Object.defineProperty(exports, "toError", {
41
57
  }
42
58
  });
43
59
 
44
- //# sourceMappingURL=errors-DBW0N9w4.cjs.map
60
+ //# sourceMappingURL=errors-CLCjoSg0.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors-CLCjoSg0.cjs","names":[],"sources":["../../../internals/utils/src/errors.ts"],"sourcesContent":["/**\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":";;;;;;;;;;;;;AA8BA,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"}
@@ -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":["/**\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":";;;;;;;;;;;;;AA8BA,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-BblrHXQC.js");
54
+ const { runGenerateCommand } = await import("./generate-CuxArvEk.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-B8tpu0Dc.js.map
66
+ //# sourceMappingURL=generate-BaJRhbCS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-BaJRhbCS.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: {\n type: 'string',\n description: 'Path to the Kubb config',\n short: 'c',\n },\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: {\n type: 'boolean',\n description: 'Watch mode based on the input file',\n short: 'w',\n default: false,\n },\n debug: {\n type: 'boolean',\n description: 'Override logLevel to debug',\n short: 'd',\n default: false,\n },\n verbose: {\n type: 'boolean',\n description: 'Override logLevel to verbose',\n short: 'v',\n default: false,\n },\n silent: {\n type: 'boolean',\n description: 'Override logLevel to silent',\n short: 's',\n default: false,\n },\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({\n input: positionals[0],\n configPath: values.config,\n logLevel,\n watch: values.watch,\n })\n },\n})\n"],"mappings":";;;AAEA,MAAa,UAAU,cAAc;CACnC,MAAM;CACN,aAAa;CACb,WAAW,CAAC,UAAU;CACtB,SAAS;EACP,QAAQ;GACN,MAAM;GACN,aAAa;GACb,OAAO;GACR;EACD,UAAU;GACR,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;GACT,MAAM;GACN,MAAM;IAAC;IAAU;IAAQ;IAAW;IAAQ;GAC7C;EACD,OAAO;GACL,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;GACV;EACD,OAAO;GACL,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;GACV;EACD,SAAS;GACP,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;GACV;EACD,QAAQ;GACN,MAAM;GACN,aAAa;GACb,OAAO;GACP,SAAS;GACV;EACF;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;GACvB,OAAO,YAAY;GACnB,YAAY,OAAO;GACnB;GACA,OAAO,OAAO;GACf,CAAC;;CAEL,CAAC"}