@kubb/cli 5.0.0-alpha.36 → 5.0.0-alpha.38

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 (42) hide show
  1. package/bin/kubb.js +6 -0
  2. package/dist/{agent-D1I8zBrQ.js → agent-DNZm3zOe.js} +2 -2
  3. package/dist/{agent-D1I8zBrQ.js.map → agent-DNZm3zOe.js.map} +1 -1
  4. package/dist/{agent-yOLMZKYB.cjs → agent-DqLV_BrR.cjs} +2 -2
  5. package/dist/{agent-yOLMZKYB.cjs.map → agent-DqLV_BrR.cjs.map} +1 -1
  6. package/dist/errors-CLCjoSg0.cjs.map +1 -1
  7. package/dist/errors-CjPmyZHy.js.map +1 -1
  8. package/dist/{generate-Cf1qSeSJ.cjs → generate-BrhbbkZi.cjs} +131 -6
  9. package/dist/generate-BrhbbkZi.cjs.map +1 -0
  10. package/dist/{generate-BqY9Y4hu.js → generate-Cpvlmmdd.js} +2 -2
  11. package/dist/{generate-BqY9Y4hu.js.map → generate-Cpvlmmdd.js.map} +1 -1
  12. package/dist/{generate-DLF8yBO-.cjs → generate-DL0JO-12.cjs} +2 -2
  13. package/dist/{generate-DLF8yBO-.cjs.map → generate-DL0JO-12.cjs.map} +1 -1
  14. package/dist/{generate-tDgmJWNE.js → generate-DYtIPCkP.js} +128 -3
  15. package/dist/{generate-tDgmJWNE.js.map → generate-DYtIPCkP.js.map} +1 -1
  16. package/dist/index.cjs +6 -6
  17. package/dist/index.js +6 -6
  18. package/dist/{init-COClpOHO.cjs → init-B7Cxlo4Z.cjs} +2 -2
  19. package/dist/{init-COClpOHO.cjs.map → init-B7Cxlo4Z.cjs.map} +1 -1
  20. package/dist/{init-DsJPxNVQ.js → init-CDTmO4nP.js} +2 -2
  21. package/dist/{init-DsJPxNVQ.js.map → init-CDTmO4nP.js.map} +1 -1
  22. package/dist/init-cAbMOLut.cjs.map +1 -1
  23. package/dist/init-hcm7zvPn.js.map +1 -1
  24. package/dist/{mcp-SALpMGkp.cjs → mcp-B-W6VZnj.cjs} +2 -2
  25. package/dist/{mcp-SALpMGkp.cjs.map → mcp-B-W6VZnj.cjs.map} +1 -1
  26. package/dist/{mcp-BCpQsb0N.js → mcp-BNtcPdx0.js} +2 -2
  27. package/dist/{mcp-BCpQsb0N.js.map → mcp-BNtcPdx0.js.map} +1 -1
  28. package/dist/{package-_aRwmOp5.cjs → package-Di-_0gXB.cjs} +2 -2
  29. package/dist/package-Di-_0gXB.cjs.map +1 -0
  30. package/dist/package-rp8ltIsX.js +6 -0
  31. package/dist/package-rp8ltIsX.js.map +1 -0
  32. package/dist/{validate-DPTV1XRk.cjs → validate-BzuJANpV.cjs} +2 -2
  33. package/dist/{validate-DPTV1XRk.cjs.map → validate-BzuJANpV.cjs.map} +1 -1
  34. package/dist/{validate-BLlD33VV.js → validate-hNVTMue-.js} +2 -2
  35. package/dist/{validate-BLlD33VV.js.map → validate-hNVTMue-.js.map} +1 -1
  36. package/package.json +6 -7
  37. package/src/runners/generate.ts +1 -5
  38. package/bin/kubb.cjs +0 -18
  39. package/dist/generate-Cf1qSeSJ.cjs.map +0 -1
  40. package/dist/package-Cx_eJU6W.js +0 -6
  41. package/dist/package-Cx_eJU6W.js.map +0 -1
  42. package/dist/package-_aRwmOp5.cjs.map +0 -1
@@ -2,17 +2,18 @@ import "./chunk--u3MIqq1.js";
2
2
  import { n as toCause, r as toError } from "./errors-CjPmyZHy.js";
3
3
  import { a as canUseTTY, i as executeIfOnline, o as isGitHubActions, r as sendTelemetry, t as buildTelemetryEvent } from "./telemetry-CBISr5w4.js";
4
4
  import { n as tokenize } from "./shell-DLzN4fRo.js";
5
- import { t as version } from "./package-Cx_eJU6W.js";
5
+ import { t as version } from "./package-rp8ltIsX.js";
6
6
  import { a as WATCHER_IGNORED_PATHS, i as SUMMARY_SEPARATOR, t as KUBB_NPM_PACKAGE_URL } from "./constants-DJM9zCXm.js";
7
7
  import { styleText } from "node:util";
8
8
  import { EventEmitter } from "node:events";
9
+ import { spawn } from "node:child_process";
9
10
  import { createHash } from "node:crypto";
10
11
  import "node:fs";
11
12
  import { mkdir, readFile, writeFile } from "node:fs/promises";
12
13
  import path, { dirname, relative, resolve } from "node:path";
13
14
  import process$1 from "node:process";
14
15
  import * as clack from "@clack/prompts";
15
- import { createKubb, defineLogger, detectFormatter, detectLinter, formatters, isInputPath, linters, logLevel } from "@kubb/core";
16
+ import { createKubb, defineLogger, isInputPath, logLevel } from "@kubb/core";
16
17
  import { NonZeroExitError, x } from "tinyexec";
17
18
  import { Writable } from "node:stream";
18
19
  import { cosmiconfig } from "cosmiconfig";
@@ -124,6 +125,130 @@ var AsyncEventEmitter = class {
124
125
  }
125
126
  };
126
127
  //#endregion
128
+ //#region ../../internals/utils/src/formatters.ts
129
+ /**
130
+ * CLI command descriptors for each supported code formatter.
131
+ *
132
+ * Each entry contains the executable `command`, an `args` factory that maps an
133
+ * output path to the correct argument list, and an `errorMessage` shown when
134
+ * the formatter is not found.
135
+ */
136
+ const formatters = {
137
+ prettier: {
138
+ command: "prettier",
139
+ args: (outputPath) => [
140
+ "--ignore-unknown",
141
+ "--write",
142
+ outputPath
143
+ ],
144
+ errorMessage: "Prettier not found"
145
+ },
146
+ biome: {
147
+ command: "biome",
148
+ args: (outputPath) => [
149
+ "format",
150
+ "--write",
151
+ outputPath
152
+ ],
153
+ errorMessage: "Biome not found"
154
+ },
155
+ oxfmt: {
156
+ command: "oxfmt",
157
+ args: (outputPath) => [outputPath],
158
+ errorMessage: "Oxfmt not found"
159
+ }
160
+ };
161
+ async function isFormatterAvailable(formatter) {
162
+ return new Promise((resolve) => {
163
+ const child = spawn(formatter, ["--version"], { stdio: "ignore" });
164
+ child.on("close", (code) => resolve(code === 0));
165
+ child.on("error", () => resolve(false));
166
+ });
167
+ }
168
+ /**
169
+ * Detects the first available code formatter on the current system.
170
+ *
171
+ * - Checks in preference order: `biome`, `oxfmt`, `prettier`.
172
+ * - Returns `null` when none are found.
173
+ *
174
+ * @example
175
+ * ```ts
176
+ * const formatter = await detectFormatter()
177
+ * if (formatter) {
178
+ * console.log(`Using ${formatter} for formatting`)
179
+ * }
180
+ * ```
181
+ */
182
+ async function detectFormatter() {
183
+ const formatterNames = new Set([
184
+ "biome",
185
+ "oxfmt",
186
+ "prettier"
187
+ ]);
188
+ for (const formatter of formatterNames) if (await isFormatterAvailable(formatter)) return formatter;
189
+ return null;
190
+ }
191
+ //#endregion
192
+ //#region ../../internals/utils/src/linters.ts
193
+ /**
194
+ * CLI command descriptors for each supported linter.
195
+ *
196
+ * Each entry contains the executable `command`, an `args` factory that maps an
197
+ * output path to the correct argument list, and an `errorMessage` shown when
198
+ * the linter is not found.
199
+ */
200
+ const linters = {
201
+ eslint: {
202
+ command: "eslint",
203
+ args: (outputPath) => [outputPath, "--fix"],
204
+ errorMessage: "Eslint not found"
205
+ },
206
+ biome: {
207
+ command: "biome",
208
+ args: (outputPath) => [
209
+ "lint",
210
+ "--fix",
211
+ outputPath
212
+ ],
213
+ errorMessage: "Biome not found"
214
+ },
215
+ oxlint: {
216
+ command: "oxlint",
217
+ args: (outputPath) => ["--fix", outputPath],
218
+ errorMessage: "Oxlint not found"
219
+ }
220
+ };
221
+ async function isLinterAvailable(linter) {
222
+ return new Promise((resolve) => {
223
+ const child = spawn(linter, ["--version"], { stdio: "ignore" });
224
+ child.on("close", (code) => resolve(code === 0));
225
+ child.on("error", () => resolve(false));
226
+ });
227
+ }
228
+ /**
229
+ * Detects the first available linter on the current system.
230
+ *
231
+ * - Checks in preference order: `biome`, `oxlint`, `eslint`.
232
+ * - Returns `null` when none are found.
233
+ *
234
+ * @example
235
+ * ```ts
236
+ * const linter = await detectLinter()
237
+ * if (linter) {
238
+ * console.log(`Using ${linter} for linting`)
239
+ * }
240
+ * ```
241
+ */
242
+ async function detectLinter() {
243
+ const linterNames = new Set([
244
+ "biome",
245
+ "oxlint",
246
+ "eslint"
247
+ ]);
248
+ for (const linter of linterNames) if (await isLinterAvailable(linter)) return linter;
249
+ return null;
250
+ }
251
+ //#endregion
127
252
  //#region ../../internals/utils/src/time.ts
128
253
  /**
129
254
  * Calculates elapsed time in milliseconds from a high-resolution `process.hrtime` start time.
@@ -1572,4 +1697,4 @@ async function runGenerateCommand({ input, configPath, logLevel: logLevelKey, wa
1572
1697
  //#endregion
1573
1698
  export { runGenerateCommand };
1574
1699
 
1575
- //# sourceMappingURL=generate-tDgmJWNE.js.map
1700
+ //# sourceMappingURL=generate-DYtIPCkP.js.map