@kubb/cli 3.17.1 → 3.18.0

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.
@@ -5,6 +5,7 @@ import process$1, { execArgv, execPath, hrtime, platform } from "node:process";
5
5
  import { safeBuild, setup } from "@kubb/core";
6
6
  import { LogMapper, createLogger, randomCliColour } from "@kubb/core/logger";
7
7
  import pc from "picocolors";
8
+ import { unlink, write } from "@kubb/core/fs";
8
9
  import { Presets, SingleBar } from "cli-progress";
9
10
  import { fileURLToPath } from "node:url";
10
11
  import { ChildProcess, execFile, spawn, spawnSync } from "node:child_process";
@@ -6603,6 +6604,7 @@ async function generate({ input, config, progressCache, args }) {
6603
6604
  write: true,
6604
6605
  barrelType: "named",
6605
6606
  extension: { ".ts": ".ts" },
6607
+ format: "prettier",
6606
6608
  ...userConfig.output
6607
6609
  }
6608
6610
  };
@@ -6647,6 +6649,98 @@ async function generate({ input, config, progressCache, args }) {
6647
6649
  logger.consola?.error(error);
6648
6650
  process$1.exit(1);
6649
6651
  }
6652
+ if (userConfig.output.format === void 0) {
6653
+ const config$1 = {
6654
+ tabWidth: 2,
6655
+ printWidth: 160,
6656
+ singleQuote: true,
6657
+ semi: false,
6658
+ bracketSameLine: false,
6659
+ endOfLine: "auto",
6660
+ plugins: ["prettier/plugins/typescript"]
6661
+ };
6662
+ try {
6663
+ logger?.emit("start", "Applying default Formatting");
6664
+ const configPath = path.resolve(definedConfig.root, ".prettierrc.temp.json");
6665
+ await write(configPath, JSON.stringify(config$1));
6666
+ await execa("npx", [
6667
+ "--yes",
6668
+ "prettier",
6669
+ "--ignore-unknown",
6670
+ "--config",
6671
+ configPath,
6672
+ "--write",
6673
+ path.resolve(definedConfig.root, definedConfig.output.path)
6674
+ ]);
6675
+ await unlink(configPath);
6676
+ } catch (e) {
6677
+ logger.consola?.warn("Prettier not found");
6678
+ logger.consola?.error(e);
6679
+ }
6680
+ logger?.emit("success", "Applied default Formatting");
6681
+ }
6682
+ if (config.output.format === "prettier") {
6683
+ logger?.emit("start", `Formatting with ${config.output.format}`);
6684
+ try {
6685
+ await execa("prettier", [
6686
+ "--ignore-unknown",
6687
+ "--write",
6688
+ path.resolve(definedConfig.root, definedConfig.output.path)
6689
+ ]);
6690
+ } catch (e) {
6691
+ logger.consola?.warn("Prettier not found");
6692
+ logger.consola?.error(e);
6693
+ }
6694
+ logger?.emit("success", `Formatted with ${config.output.format}`);
6695
+ }
6696
+ if (config.output.format === "biome") {
6697
+ logger?.emit("start", `Formatting with ${config.output.format}`);
6698
+ try {
6699
+ await execa("biome", [
6700
+ "format",
6701
+ "--write",
6702
+ path.resolve(definedConfig.root, definedConfig.output.path)
6703
+ ]);
6704
+ } catch (e) {
6705
+ logger.consola?.warn("Biome not found");
6706
+ logger.consola?.error(e);
6707
+ }
6708
+ logger?.emit("success", `Formatted with ${config.output.format}`);
6709
+ }
6710
+ if (config.output.lint === "eslint") {
6711
+ logger?.emit("start", `Linting with ${config.output.format}`);
6712
+ try {
6713
+ await execa("eslint", [path.resolve(definedConfig.root, definedConfig.output.path), "--fix"]);
6714
+ } catch (e) {
6715
+ logger.consola?.warn("Eslint not found");
6716
+ logger.consola?.error(e);
6717
+ }
6718
+ logger?.emit("success", `Linted with ${config.output.format}`);
6719
+ }
6720
+ if (config.output.lint === "biome") {
6721
+ logger?.emit("start", `Linting with ${config.output.format}`);
6722
+ try {
6723
+ await execa("biome", [
6724
+ "lint",
6725
+ "--fix",
6726
+ path.resolve(definedConfig.root, definedConfig.output.path)
6727
+ ]);
6728
+ } catch (e) {
6729
+ logger.consola?.warn("Biome not found");
6730
+ logger.consola?.error(e);
6731
+ }
6732
+ logger?.emit("success", `Linted with ${config.output.format}`);
6733
+ }
6734
+ if (config.output.lint === "oxlint") {
6735
+ logger?.emit("start", `Linting with ${config.output.format}`);
6736
+ try {
6737
+ await execa("oxlint", ["--fix", path.resolve(definedConfig.root, definedConfig.output.path)]);
6738
+ } catch (e) {
6739
+ logger.consola?.warn("Oxlint not found");
6740
+ logger.consola?.error(e);
6741
+ }
6742
+ logger?.emit("success", `Linted with ${config.output.format}`);
6743
+ }
6650
6744
  if (config.hooks) await executeHooks({
6651
6745
  hooks: config.hooks,
6652
6746
  logger
@@ -6665,4 +6759,4 @@ async function generate({ input, config, progressCache, args }) {
6665
6759
 
6666
6760
  //#endregion
6667
6761
  export { generate };
6668
- //# sourceMappingURL=generate-DAJRIO7l.js.map
6762
+ //# sourceMappingURL=generate-BqEOROw2.js.map