@kubb/cli 5.0.0-alpha.9 → 5.0.0-beta.75

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 (135) hide show
  1. package/README.md +4 -2
  2. package/bin/kubb.js +6 -0
  3. package/dist/{agent-BKphjOIF.cjs → agent-BEgI2HXH.cjs} +5 -5
  4. package/dist/agent-BEgI2HXH.cjs.map +1 -0
  5. package/dist/agent-B_pirbeB.cjs +116 -0
  6. package/dist/agent-B_pirbeB.cjs.map +1 -0
  7. package/dist/{agent-5mmp7QzF.js → agent-CTdJEHEs.js} +5 -5
  8. package/dist/agent-CTdJEHEs.js.map +1 -0
  9. package/dist/agent-Ev5hU5hH.js +112 -0
  10. package/dist/agent-Ev5hU5hH.js.map +1 -0
  11. package/dist/{constants-D0XHAHeZ.cjs → constants-CnDXa1R6.cjs} +30 -60
  12. package/dist/constants-CnDXa1R6.cjs.map +1 -0
  13. package/dist/{constants-DJM9zCXm.js → constants-aL3CP_Wq.js} +23 -59
  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-BHNyeQXl.js → generate-Cg8yufrw.js} +552 -258
  24. package/dist/generate-Cg8yufrw.js.map +1 -0
  25. package/dist/{generate-DU5zzc54.cjs → generate-DDCwNQNo.cjs} +3 -3
  26. package/dist/generate-DDCwNQNo.cjs.map +1 -0
  27. package/dist/{generate-Cq5RDTBL.cjs → generate-K8MJ9aQF.cjs} +559 -265
  28. package/dist/generate-K8MJ9aQF.cjs.map +1 -0
  29. package/dist/{generate-Rly1EXBN.js → generate-YPtfjsg4.js} +3 -3
  30. package/dist/generate-YPtfjsg4.js.map +1 -0
  31. package/dist/index.cjs +40 -18
  32. package/dist/index.cjs.map +1 -1
  33. package/dist/index.js +40 -18
  34. package/dist/index.js.map +1 -1
  35. package/dist/{init-CN1JFyGX.cjs → init-Bu95ML_u.cjs} +4 -4
  36. package/dist/init-Bu95ML_u.cjs.map +1 -0
  37. package/dist/{init-BK6inBTR.cjs → init-CZ5Xq2Hd.cjs} +45 -58
  38. package/dist/init-CZ5Xq2Hd.cjs.map +1 -0
  39. package/dist/{init-BQ6zfsnw.js → init-eNRlotJK.js} +41 -54
  40. package/dist/init-eNRlotJK.js.map +1 -0
  41. package/dist/{init-iN7e1XwI.js → init-ooJeOBGt.js} +4 -4
  42. package/dist/init-ooJeOBGt.js.map +1 -0
  43. package/dist/{mcp-eP1S40LZ.js → mcp-C-d5N1wZ.js} +4 -4
  44. package/dist/{mcp-eP1S40LZ.js.map → mcp-C-d5N1wZ.js.map} +1 -1
  45. package/dist/{mcp-CONmm_xT.cjs → mcp-CLcDV4Jm.cjs} +5 -6
  46. package/dist/mcp-CLcDV4Jm.cjs.map +1 -0
  47. package/dist/{mcp-BiGUvbWP.js → mcp-D7EIR9fR.js} +4 -5
  48. package/dist/mcp-D7EIR9fR.js.map +1 -0
  49. package/dist/{mcp-T7Q4nWbT.cjs → mcp-Dpu8vzzj.cjs} +4 -4
  50. package/dist/{mcp-T7Q4nWbT.cjs.map → mcp-Dpu8vzzj.cjs.map} +1 -1
  51. package/dist/{package-BJ6ionm6.cjs → package-D5arPDnh.cjs} +2 -2
  52. package/dist/package-D5arPDnh.cjs.map +1 -0
  53. package/dist/package-DqZsMLZ9.js +6 -0
  54. package/dist/package-DqZsMLZ9.js.map +1 -0
  55. package/dist/{shell-7HPrTCJ5.cjs → shell-475fQKaX.cjs} +8 -3
  56. package/dist/shell-475fQKaX.cjs.map +1 -0
  57. package/dist/{shell-DqqWsHCD.js → shell-DLzN4fRo.js} +8 -3
  58. package/dist/shell-DLzN4fRo.js.map +1 -0
  59. package/dist/{telemetry-DZ7IrLAU.cjs → telemetry-DN95_2pF.cjs} +50 -8
  60. package/dist/telemetry-DN95_2pF.cjs.map +1 -0
  61. package/dist/{telemetry-BF3SMlH6.js → telemetry-LgT_sdPe.js} +48 -6
  62. package/dist/telemetry-LgT_sdPe.js.map +1 -0
  63. package/dist/{validate-DAZdX_0i.js → validate-CIR3_lZI.js} +4 -4
  64. package/dist/validate-CIR3_lZI.js.map +1 -0
  65. package/dist/{validate-DucFMytl.cjs → validate-DcqUb4DM.cjs} +4 -4
  66. package/dist/validate-DcqUb4DM.cjs.map +1 -0
  67. package/dist/{validate-BImbbx1t.js → validate-kLJoT_hi.js} +5 -13
  68. package/dist/validate-kLJoT_hi.js.map +1 -0
  69. package/dist/{validate-ujLCYSWU.cjs → validate-yKKzqEZ5.cjs} +6 -14
  70. package/dist/validate-yKKzqEZ5.cjs.map +1 -0
  71. package/package.json +47 -46
  72. package/src/commands/agent/start.ts +20 -4
  73. package/src/commands/generate.ts +35 -6
  74. package/src/commands/init.ts +6 -1
  75. package/src/commands/validate.ts +6 -1
  76. package/src/constants.ts +19 -38
  77. package/src/index.ts +7 -10
  78. package/src/loggers/clackLogger.ts +54 -46
  79. package/src/loggers/fileSystemLogger.ts +15 -16
  80. package/src/loggers/githubActionsLogger.ts +23 -24
  81. package/src/loggers/plainLogger.ts +22 -23
  82. package/src/runners/agent.ts +81 -34
  83. package/src/runners/generate.ts +90 -100
  84. package/src/runners/init.ts +24 -51
  85. package/src/runners/mcp.ts +17 -4
  86. package/src/runners/validate.ts +19 -15
  87. package/src/utils/executeHooks.ts +15 -15
  88. package/src/utils/flags.ts +1 -2
  89. package/src/utils/getConfig.ts +10 -0
  90. package/src/utils/getCosmiConfig.ts +21 -12
  91. package/src/utils/getSummary.ts +1 -1
  92. package/src/utils/runHook.ts +29 -13
  93. package/src/utils/telemetry.ts +16 -3
  94. package/bin/kubb.cjs +0 -18
  95. package/dist/agent-5mmp7QzF.js.map +0 -1
  96. package/dist/agent-BKphjOIF.cjs.map +0 -1
  97. package/dist/agent-BapvKB4r.cjs +0 -92
  98. package/dist/agent-BapvKB4r.cjs.map +0 -1
  99. package/dist/agent-CBrpIMMU.js +0 -88
  100. package/dist/agent-CBrpIMMU.js.map +0 -1
  101. package/dist/constants-D0XHAHeZ.cjs.map +0 -1
  102. package/dist/constants-DJM9zCXm.js.map +0 -1
  103. package/dist/define--M_JMcDC.js +0 -25
  104. package/dist/define--M_JMcDC.js.map +0 -1
  105. package/dist/define-D6Kfm7-Z.cjs +0 -36
  106. package/dist/define-D6Kfm7-Z.cjs.map +0 -1
  107. package/dist/errors-6mF_WKxg.js +0 -27
  108. package/dist/errors-6mF_WKxg.js.map +0 -1
  109. package/dist/errors-DBW0N9w4.cjs.map +0 -1
  110. package/dist/generate-BHNyeQXl.js.map +0 -1
  111. package/dist/generate-Cq5RDTBL.cjs.map +0 -1
  112. package/dist/generate-DU5zzc54.cjs.map +0 -1
  113. package/dist/generate-Rly1EXBN.js.map +0 -1
  114. package/dist/init-BK6inBTR.cjs.map +0 -1
  115. package/dist/init-BQ6zfsnw.js.map +0 -1
  116. package/dist/init-CN1JFyGX.cjs.map +0 -1
  117. package/dist/init-iN7e1XwI.js.map +0 -1
  118. package/dist/jiti-Cd3S0xwr.cjs +0 -16
  119. package/dist/jiti-Cd3S0xwr.cjs.map +0 -1
  120. package/dist/jiti-e08mD2Ph.js +0 -11
  121. package/dist/jiti-e08mD2Ph.js.map +0 -1
  122. package/dist/mcp-BiGUvbWP.js.map +0 -1
  123. package/dist/mcp-CONmm_xT.cjs.map +0 -1
  124. package/dist/package-BJ6ionm6.cjs.map +0 -1
  125. package/dist/package-BKZ0H3Zf.js +0 -6
  126. package/dist/package-BKZ0H3Zf.js.map +0 -1
  127. package/dist/shell-7HPrTCJ5.cjs.map +0 -1
  128. package/dist/shell-DqqWsHCD.js.map +0 -1
  129. package/dist/telemetry-BF3SMlH6.js.map +0 -1
  130. package/dist/telemetry-DZ7IrLAU.cjs.map +0 -1
  131. package/dist/validate-BImbbx1t.js.map +0 -1
  132. package/dist/validate-DAZdX_0i.js.map +0 -1
  133. package/dist/validate-DucFMytl.cjs.map +0 -1
  134. package/dist/validate-ujLCYSWU.cjs.map +0 -1
  135. package/src/utils/jiti.ts +0 -9
@@ -1,5 +1,11 @@
1
1
  //#region src/constants.ts
2
2
  /**
3
+ * Default filename for the Kubb configuration file.
4
+ *
5
+ * Used by the `init` command when scaffolding new projects and by the `agent` default config.
6
+ */
7
+ const KUBB_CONFIG_FILENAME = "kubb.config.ts";
8
+ /**
3
9
  * NPM registry endpoint used to check for @kubb/cli updates.
4
10
  */
5
11
  const KUBB_NPM_PACKAGE_URL = "https://registry.npmjs.org/@kubb/cli/latest";
@@ -18,62 +24,21 @@ const WATCHER_IGNORED_PATHS = "**/{.git,node_modules}/**";
18
24
  /**
19
25
  * Flags that short-circuit execution (help/version) — no telemetry notice is shown.
20
26
  */
21
- const QUITE_FLAGS = new Set([
27
+ const QUIET_FLAGS = new Set([
22
28
  "--help",
23
29
  "-h",
24
30
  "--version",
25
31
  "-v"
26
32
  ]);
27
- /**
28
- * Flags accepted by the `generate` command.
29
- */
30
- const GENERATE_FLAGS = new Set([
31
- "--config",
32
- "-c",
33
- "--log-level",
34
- "-l",
35
- "--watch",
36
- "-w",
37
- "--debug",
38
- "-d",
39
- "--verbose",
40
- "-v",
41
- "--silent",
42
- "-s"
43
- ]);
44
- /**
45
- * Flags accepted by the `validate` command.
46
- */
47
- const VALIDATE_FLAGS = new Set(["--input", "-i"]);
48
- /**
49
- * Flags accepted by the `init` command.
50
- */
51
- const INIT_FLAGS = new Set(["--yes", "-y"]);
52
- /**
53
- * Flags accepted by the `agent start` command.
54
- */
55
- const AGENT_START_FLAGS = new Set([
56
- "--config",
57
- "-c",
58
- "--port",
59
- "-p",
60
- "--host",
61
- "--allow-write",
62
- "--allow-all"
63
- ]);
64
- new Set([
65
- ...QUITE_FLAGS,
66
- ...GENERATE_FLAGS,
67
- ...VALIDATE_FLAGS,
68
- ...INIT_FLAGS,
69
- ...AGENT_START_FLAGS
70
- ]);
71
33
  const agentDefaults = {
72
34
  port: "3000",
73
35
  host: "localhost",
74
- configFile: "kubb.config.ts",
36
+ configFile: KUBB_CONFIG_FILENAME,
75
37
  retryTimeout: "30000",
76
38
  studioUrl: "https://studio.kubb.dev",
39
+ /**
40
+ * Relative path from the @kubb/agent package root to the server entry.
41
+ */
77
42
  serverEntryPath: ".output/server/index.mjs"
78
43
  };
79
44
  /**
@@ -82,7 +47,7 @@ const agentDefaults = {
82
47
  const initDefaults = {
83
48
  inputPath: "./openapi.yaml",
84
49
  outputPath: "./src/gen",
85
- plugins: ["plugin-oas", "plugin-ts"]
50
+ plugins: ["plugin-ts"]
86
51
  };
87
52
  /**
88
53
  * Maps each plugin value to the default config snippet inserted by `init`.
@@ -90,7 +55,6 @@ const initDefaults = {
90
55
  * `as const` keeps the object deeply immutable.
91
56
  */
92
57
  const pluginDefaultConfigs = {
93
- "plugin-oas": "pluginOas()",
94
58
  "plugin-ts": `pluginTs({
95
59
  output: { path: 'models' },
96
60
  })`,
@@ -99,18 +63,9 @@ const pluginDefaultConfigs = {
99
63
  })`,
100
64
  "plugin-react-query": `pluginReactQuery({
101
65
  output: { path: 'hooks' },
102
- })`,
103
- "plugin-solid-query": `pluginSolidQuery({
104
- output: { path: 'hooks' },
105
- })`,
106
- "plugin-svelte-query": `pluginSvelteQuery({
107
- output: { path: 'hooks' },
108
66
  })`,
109
67
  "plugin-vue-query": `pluginVueQuery({
110
68
  output: { path: 'hooks' },
111
- })`,
112
- "plugin-swr": `pluginSwr({
113
- output: { path: 'hooks' },
114
69
  })`,
115
70
  "plugin-zod": `pluginZod({
116
71
  output: { path: 'zod' },
@@ -120,12 +75,21 @@ const pluginDefaultConfigs = {
120
75
  })`,
121
76
  "plugin-msw": `pluginMsw({
122
77
  output: { path: 'msw' },
78
+ })`,
79
+ "plugin-cypress": `pluginCypress({
80
+ output: { path: 'cypress' },
81
+ })`,
82
+ "plugin-mcp": `pluginMcp({
83
+ output: { path: 'mcp' },
84
+ })`,
85
+ "plugin-redoc": `pluginRedoc({
86
+ output: { path: 'redoc' },
123
87
  })`
124
88
  };
125
89
  /**
126
90
  * Color palette used by randomCliColor() for deterministic plugin name coloring.
127
91
  */
128
92
  //#endregion
129
- export { WATCHER_IGNORED_PATHS as a, pluginDefaultConfigs as c, SUMMARY_SEPARATOR as i, OTLP_ENDPOINT as n, agentDefaults as o, QUITE_FLAGS as r, initDefaults as s, KUBB_NPM_PACKAGE_URL as t };
93
+ export { SUMMARY_SEPARATOR as a, initDefaults as c, QUIET_FLAGS as i, pluginDefaultConfigs as l, KUBB_NPM_PACKAGE_URL as n, WATCHER_IGNORED_PATHS as o, OTLP_ENDPOINT as r, agentDefaults as s, KUBB_CONFIG_FILENAME as t };
130
94
 
131
- //# sourceMappingURL=constants-DJM9zCXm.js.map
95
+ //# sourceMappingURL=constants-aL3CP_Wq.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants-aL3CP_Wq.js","names":[],"sources":["../src/constants.ts"],"sourcesContent":["/**\n * Default filename for the Kubb configuration file.\n *\n * Used by the `init` command when scaffolding new projects and by the `agent` default config.\n */\nexport const KUBB_CONFIG_FILENAME = 'kubb.config.ts' as const\n\n/**\n * NPM registry endpoint used to check for @kubb/cli updates.\n */\nexport const KUBB_NPM_PACKAGE_URL = 'https://registry.npmjs.org/@kubb/cli/latest' as const\n\n/**\n * OpenTelemetry ingestion endpoint for anonymous usage telemetry.\n */\nexport const OTLP_ENDPOINT = 'https://otlp.kubb.dev' as const\n\n/**\n * Horizontal rule rendered above/below the plain-logger generation summary.\n */\nexport const SUMMARY_SEPARATOR = '─'.repeat(27)\n\n/**\n * Maximum number of █ characters in a plugin timing bar.\n */\nexport const SUMMARY_MAX_BAR_LENGTH = 10 as const\n\n/**\n * Divides elapsed milliseconds into bar-length units (1 block per 100 ms).\n */\nexport const SUMMARY_TIME_SCALE_DIVISOR = 100 as const\n\n/**\n * Glob pattern for paths the file watcher ignores.\n */\nexport const WATCHER_IGNORED_PATHS = '**/{.git,node_modules}/**' as const\n\n/**\n * Flags that short-circuit execution (help/version) — no telemetry notice is shown.\n */\nexport const QUIET_FLAGS = new Set(['--help', '-h', '--version', '-v'] as const)\n\nexport const agentDefaults = {\n port: '3000',\n host: 'localhost',\n configFile: KUBB_CONFIG_FILENAME,\n retryTimeout: '30000',\n studioUrl: 'https://studio.kubb.dev',\n /**\n * Relative path from the @kubb/agent package root to the server entry.\n */\n serverEntryPath: '.output/server/index.mjs',\n} as const\n\n/**\n * Default values used during interactive `init` scaffolding.\n */\nexport const initDefaults = {\n inputPath: './openapi.yaml',\n outputPath: './src/gen',\n plugins: ['plugin-ts'],\n} as const\n\n/**\n * Maps each plugin value to the default config snippet inserted by `init`.\n * The `satisfies` constraint ensures all values remain plain strings while\n * `as const` keeps the object deeply immutable.\n */\nexport const pluginDefaultConfigs = {\n 'plugin-ts': `pluginTs({\n output: { path: 'models' },\n })`,\n 'plugin-client': `pluginClient({\n output: { path: 'clients' },\n })`,\n 'plugin-react-query': `pluginReactQuery({\n output: { path: 'hooks' },\n })`,\n 'plugin-vue-query': `pluginVueQuery({\n output: { path: 'hooks' },\n })`,\n 'plugin-zod': `pluginZod({\n output: { path: 'zod' },\n })`,\n 'plugin-faker': `pluginFaker({\n output: { path: 'mocks' },\n })`,\n 'plugin-msw': `pluginMsw({\n output: { path: 'msw' },\n })`,\n 'plugin-cypress': `pluginCypress({\n output: { path: 'cypress' },\n })`,\n 'plugin-mcp': `pluginMcp({\n output: { path: 'mcp' },\n })`,\n 'plugin-redoc': `pluginRedoc({\n output: { path: 'redoc' },\n })`,\n} as const satisfies Record<string, string>\n\n/**\n * Color palette used by randomCliColor() for deterministic plugin name coloring.\n */\n"],"mappings":";;;;;;AAKA,MAAa,uBAAuB;;;;AAKpC,MAAa,uBAAuB;;;;AAKpC,MAAa,gBAAgB;;;;AAK7B,MAAa,oBAAoB,IAAI,OAAO,GAAG;;;;AAe/C,MAAa,wBAAwB;;;;AAKrC,MAAa,cAAc,IAAI,IAAI;CAAC;CAAU;CAAM;CAAa;CAAK,CAAU;AAEhF,MAAa,gBAAgB;CAC3B,MAAM;CACN,MAAM;CACN,YAAY;CACZ,cAAc;CACd,WAAW;;;;CAIX,iBAAiB;CAClB;;;;AAKD,MAAa,eAAe;CAC1B,WAAW;CACX,YAAY;CACZ,SAAS,CAAC,YAAY;CACvB;;;;;;AAOD,MAAa,uBAAuB;CAClC,aAAa;;;CAGb,iBAAiB;;;CAGjB,sBAAsB;;;CAGtB,oBAAoB;;;CAGpB,cAAc;;;CAGd,gBAAgB;;;CAGhB,cAAc;;;CAGd,kBAAkB;;;CAGlB,cAAc;;;CAGd,gBAAgB;;;CAGjB"}
@@ -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"}