@kubb/cli 3.17.1 → 3.18.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.
@@ -179,7 +179,7 @@ const command = (0, citty.defineCommand)({
179
179
  if (args$1.debug) args$1.logLevel = "debug";
180
180
  const logLevel = __kubb_core_logger.LogMapper[args$1.logLevel] || 3;
181
181
  const logger = (0, __kubb_core_logger.createLogger)({ logLevel });
182
- const { generate } = await Promise.resolve().then(() => require("./generate-TqAvum5c.cjs"));
182
+ const { generate } = await Promise.resolve().then(() => require("./generate-Cod5_RqJ.cjs"));
183
183
  logger.emit("start", "Loading config");
184
184
  const result = await getCosmiConfig("kubb", args$1.config);
185
185
  logger.emit("success", `Config loaded(${picocolors.default.dim(node_path.default.relative(node_process.cwd(), result.filepath))})`);
@@ -251,4 +251,4 @@ const command = (0, citty.defineCommand)({
251
251
 
252
252
  //#endregion
253
253
  exports.default = command;
254
- //# sourceMappingURL=generate-AG4UwoYw.cjs.map
254
+ //# sourceMappingURL=generate-Cj0UETd1.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-Cj0UETd1.cjs","names":["args","results: Array<Config>","jiti","path","pc","args","LogMapper","pc","path","process","PromiseManager"],"sources":["../src/utils/getPlugins.ts","../src/utils/getConfig.ts","../src/utils/getCosmiConfig.ts","../src/utils/watcher.ts","../src/commands/generate.ts"],"sourcesContent":["import type { UserConfig } from '@kubb/core'\n\nfunction isJSONPlugins(plugins: UserConfig['plugins']) {\n return !!(plugins as any)?.some((plugin: any) => {\n return Array.isArray(plugin) && typeof plugin?.at(0) === 'string'\n })\n}\n\nfunction isObjectPlugins(plugins: UserConfig['plugins']): plugins is any {\n return plugins instanceof Object && !Array.isArray(plugins)\n}\n\nexport function getPlugins(plugins: UserConfig['plugins']): Promise<UserConfig['plugins']> {\n if (isObjectPlugins(plugins)) {\n throw new Error('Object plugins are not supported anymore, best to use http://kubb.dev/getting-started/configure#json')\n }\n\n if (isJSONPlugins(plugins)) {\n throw new Error('JSON plugins are not supported anymore, best to use http://kubb.dev/getting-started/configure#json')\n }\n\n return Promise.resolve(plugins)\n}\n","import { isPromise } from '@kubb/core/utils'\n\nimport { getPlugins } from './getPlugins.ts'\n\nimport type { Config, UserConfig } from '@kubb/core'\nimport type { Args } from '../commands/generate.ts'\nimport type { CosmiconfigResult } from './getCosmiConfig.ts'\n\n/**\n * Converting UserConfig to Config without a change in the object beside the JSON convert.\n */\nexport async function getConfig(result: CosmiconfigResult, args: Args): Promise<Array<Config> | Config> {\n const config = result?.config\n let kubbUserConfig = Promise.resolve(config) as Promise<UserConfig | Array<UserConfig>>\n\n // for ts or js files\n if (typeof config === 'function') {\n const possiblePromise = config(args)\n if (isPromise(possiblePromise)) {\n kubbUserConfig = possiblePromise\n }\n kubbUserConfig = Promise.resolve(possiblePromise)\n }\n\n let JSONConfig = await kubbUserConfig\n\n if (Array.isArray(JSONConfig)) {\n const results: Array<Config> = []\n\n for (const item of JSONConfig) {\n const plugins = item.plugins ? await getPlugins(item.plugins) : undefined\n\n results.push({\n ...item,\n plugins,\n } as Config)\n }\n\n return results\n }\n\n JSONConfig = {\n ...JSONConfig,\n plugins: JSONConfig.plugins ? await getPlugins(JSONConfig.plugins) : undefined,\n }\n\n return JSONConfig as Config\n}\n","import type { defineConfig, UserConfig } from '@kubb/core'\nimport { cosmiconfig } from 'cosmiconfig'\nimport { createJiti } from 'jiti'\n\nexport type CosmiconfigResult = {\n filepath: string\n isEmpty?: boolean\n config: ReturnType<typeof defineConfig> | UserConfig\n}\n\nconst tsLoader = async (configFile: string) => {\n const jiti = createJiti(import.meta.url, {\n jsx: {\n runtime: 'automatic',\n importSource: '@kubb/react',\n },\n sourceMaps: true,\n })\n\n const mod = await jiti.import(configFile, { default: true })\n\n return mod\n}\n\nexport async function getCosmiConfig(moduleName: string, config?: string): Promise<CosmiconfigResult> {\n const searchPlaces = [\n 'package.json',\n `.${moduleName}rc`,\n `.${moduleName}rc.json`,\n `.${moduleName}rc.yaml`,\n `.${moduleName}rc.yml`,\n\n `.${moduleName}rc.ts`,\n `.${moduleName}rc.js`,\n `.${moduleName}rc.mjs`,\n `.${moduleName}rc.cjs`,\n\n `${moduleName}.config.ts`,\n `${moduleName}.config.js`,\n `${moduleName}.config.mjs`,\n `${moduleName}.config.cjs`,\n ]\n const explorer = cosmiconfig(moduleName, {\n cache: false,\n searchPlaces: [\n ...searchPlaces.map((searchPlace) => {\n return `.config/${searchPlace}`\n }),\n ...searchPlaces.map((searchPlace) => {\n return `configs/${searchPlace}`\n }),\n ...searchPlaces,\n ],\n loaders: {\n '.ts': tsLoader,\n },\n })\n\n const result = config ? await explorer.load(config) : await explorer.search()\n\n if (result?.isEmpty || !result || !result.config) {\n throw new Error('Config not defined, create a kubb.config.js or pass through your config with the option --config')\n }\n\n return result as CosmiconfigResult\n}\n","import { createLogger } from '@kubb/core/logger'\nimport pc from 'picocolors'\n\nexport async function startWatcher(path: string[], cb: (path: string[]) => Promise<void>): Promise<void> {\n const { watch } = await import('chokidar')\n const logger = createLogger()\n\n const ignored = '**/{.git,node_modules}/**'\n\n const watcher = watch(path, {\n ignorePermissionErrors: true,\n ignored,\n })\n watcher.on('all', (type, file) => {\n logger?.emit('info', pc.yellow(pc.bold(`Change detected: ${type} ${file}`)))\n\n try {\n cb(path)\n } catch (_e) {\n logger?.emit('warning', pc.red('Watcher failed'))\n }\n })\n}\n","import path from 'node:path'\nimport * as process from 'node:process'\nimport { isInputPath, PromiseManager } from '@kubb/core'\nimport { createLogger, LogMapper } from '@kubb/core/logger'\nimport type { ArgsDef, ParsedArgs } from 'citty'\nimport { defineCommand, showUsage } from 'citty'\nimport type { SingleBar } from 'cli-progress'\nimport open from 'open'\nimport pc from 'picocolors'\nimport { getConfig } from '../utils/getConfig.ts'\nimport { getCosmiConfig } from '../utils/getCosmiConfig.ts'\nimport { startWatcher } from '../utils/watcher.ts'\n\ndeclare global {\n var isDevtoolsEnabled: any\n}\n\nconst args = {\n config: {\n type: 'string',\n description: 'Path to the Kubb config',\n alias: 'c',\n },\n logLevel: {\n type: 'string',\n description: 'Info, silent or debug',\n alias: 'l',\n default: 'info',\n valueHint: 'silent|info|debug',\n },\n watch: {\n type: 'boolean',\n description: 'Watch mode based on the input file',\n alias: 'w',\n default: false,\n },\n debug: {\n type: 'boolean',\n description: 'Override logLevel to debug',\n alias: 'd',\n default: false,\n },\n ui: {\n type: 'boolean',\n description: 'Open ui',\n alias: 'u',\n default: false,\n },\n help: {\n type: 'boolean',\n description: 'Show help',\n alias: 'h',\n default: false,\n },\n} as const satisfies ArgsDef\n\nexport type Args = ParsedArgs<typeof args>\n\nconst command = defineCommand({\n meta: {\n name: 'generate',\n description: \"[input] Generate files based on a 'kubb.config.ts' file\",\n },\n args,\n async run(commandContext) {\n let name = ''\n const progressCache = new Map<string, SingleBar>()\n\n const { args } = commandContext\n\n const input = args._[0]\n\n if (args.help) {\n return showUsage(command)\n }\n\n if (args.debug) {\n args.logLevel = 'debug'\n }\n\n const logLevel = LogMapper[args.logLevel as keyof typeof LogMapper] || 3\n const logger = createLogger({\n logLevel,\n })\n const { generate } = await import('../runners/generate.ts')\n\n logger.emit('start', 'Loading config')\n\n const result = await getCosmiConfig('kubb', args.config)\n logger.emit('success', `Config loaded(${pc.dim(path.relative(process.cwd(), result.filepath))})`)\n\n const config = await getConfig(result, args)\n\n const start = async () => {\n if (Array.isArray(config)) {\n const promiseManager = new PromiseManager()\n const promises = config.map((c) => () => {\n name = c.name || ''\n progressCache.clear()\n\n return generate({\n input,\n config: c,\n args,\n progressCache,\n })\n })\n\n await promiseManager.run('seq', promises)\n return\n }\n\n progressCache.clear()\n\n await generate({\n input,\n config,\n progressCache,\n args,\n })\n\n return\n }\n\n if (args.ui) {\n const { startServer } = await import('@kubb/ui')\n\n await startServer(\n {\n stop: () => process.exit(1),\n restart: () => start(),\n getMeta: () => {\n const entries = [...progressCache.entries()]\n\n const percentages = entries.reduce(\n (acc, [key, singleBar]) => {\n acc[key] = singleBar.getProgress()\n\n return acc\n },\n {} as Record<string, number>,\n )\n\n return {\n name,\n percentages,\n }\n },\n },\n (info) => {\n const url = `${info.address}:${info.port}`.replace('::', 'http://localhost')\n logger.consola?.start(`Starting ui on ${url}`)\n\n open(url)\n },\n )\n }\n\n if (args.watch) {\n if (Array.isArray(config)) {\n throw new Error('Cannot use watcher with multiple Configs(array)')\n }\n\n if (isInputPath(config)) {\n return startWatcher([input || config.input.path], async (paths) => {\n await start()\n logger.emit('start', pc.yellow(pc.bold(`Watching for changes in ${paths.join(' and ')}`)))\n })\n }\n }\n\n await start()\n\n if (globalThis.isDevtoolsEnabled) {\n const canRestart = await logger.consola?.prompt('Restart(could be used to validate the profiler)?', {\n type: 'confirm',\n initial: false,\n })\n\n if (canRestart) {\n await start()\n } else {\n process.exit(1)\n }\n }\n },\n})\n\nexport default command\n"],"mappings":";;;;;;;;;;;;;AAEA,SAAS,cAAc,SAAgC;AACrD,QAAO,CAAC,CAAE,SAAiB,MAAM,WAAgB;AAC/C,SAAO,MAAM,QAAQ,WAAW,OAAO,QAAQ,GAAG,OAAO;CAC1D;AACF;AAED,SAAS,gBAAgB,SAAgD;AACvE,QAAO,mBAAmB,UAAU,CAAC,MAAM,QAAQ;AACpD;AAED,SAAgB,WAAW,SAAgE;AACzF,KAAI,gBAAgB,SAClB,OAAM,IAAI,MAAM;AAGlB,KAAI,cAAc,SAChB,OAAM,IAAI,MAAM;AAGlB,QAAO,QAAQ,QAAQ;AACxB;;;;;;;ACXD,eAAsB,UAAU,QAA2B,QAA6C;CACtG,MAAM,SAAS,QAAQ;CACvB,IAAI,iBAAiB,QAAQ,QAAQ;AAGrC,KAAI,OAAO,WAAW,YAAY;EAChC,MAAM,kBAAkB,OAAOA;AAC/B,uCAAc,iBACZ,kBAAiB;AAEnB,mBAAiB,QAAQ,QAAQ;CAClC;CAED,IAAI,aAAa,MAAM;AAEvB,KAAI,MAAM,QAAQ,aAAa;EAC7B,MAAMC,UAAyB,EAAE;AAEjC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,IAAIK;IAC3B,MAAM,WAAW,OAAO,KAAK,YAAY;AACvC,YAAO,EAAE,QAAQ;AACjB,mBAAc;AAEd,YAAO,SAAS;MACd;MACA,QAAQ;MACR;MACA;MACD;IACF;AAED,UAAM,eAAe,IAAI,OAAO;AAChC;GACD;AAED,iBAAc;AAEd,SAAM,SAAS;IACb;IACA;IACA;IACA;IACD;EAGF;AAED,MAAIL,OAAK,IAAI;GACX,MAAM,EAAE,aAAa,GAAG,MAAM,OAAO;AAErC,SAAM,YACJ;IACE,YAAYI,aAAQ,KAAK;IACzB,eAAe;IACf,eAAe;KACb,MAAM,UAAU,CAAC,GAAG,cAAc,UAAU;KAE5C,MAAM,cAAc,QAAQ,QACzB,KAAK,CAAC,KAAK,UAAU,KAAK;AACzB,UAAI,OAAO,UAAU;AAErB,aAAO;KACR,GACD,EAAE;AAGJ,YAAO;MACL;MACA;MACD;IACF;IACF,GACA,SAAS;IACR,MAAM,MAAM,GAAG,KAAK,QAAQ,GAAG,KAAK,OAAO,QAAQ,MAAM;AACzD,WAAO,SAAS,MAAM,kBAAkB;AAExC,sBAAK;GACN;EAEJ;AAED,MAAIJ,OAAK,OAAO;AACd,OAAI,MAAM,QAAQ,QAChB,OAAM,IAAI,MAAM;AAGlB,oCAAgB,QACd,QAAO,aAAa,CAAC,SAAS,OAAO,MAAM,KAAK,EAAE,OAAO,UAAU;AACjE,UAAM;AACN,WAAO,KAAK,SAASE,mBAAG,OAAOA,mBAAG,KAAK,2BAA2B,MAAM,KAAK;GAC9E;EAEJ;AAED,QAAM;AAEN,MAAI,WAAW,mBAAmB;GAChC,MAAM,aAAa,MAAM,OAAO,SAAS,OAAO,oDAAoD;IAClG,MAAM;IACN,SAAS;IACV;AAED,OAAI,WACF,OAAM;OAEN,cAAQ,KAAK;EAEhB;CACF;CACF"}
@@ -823,28 +823,28 @@ var require_windows = /* @__PURE__ */ require_chunk.__commonJS({ "../../node_mod
823
823
  module.exports = isexe$3;
824
824
  isexe$3.sync = sync$2;
825
825
  var fs$2 = require("fs");
826
- function checkPathExt(path$9, options) {
826
+ function checkPathExt(path$10, options) {
827
827
  var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
828
828
  if (!pathext) return true;
829
829
  pathext = pathext.split(";");
830
830
  if (pathext.indexOf("") !== -1) return true;
831
831
  for (var i$1 = 0; i$1 < pathext.length; i$1++) {
832
832
  var p = pathext[i$1].toLowerCase();
833
- if (p && path$9.substr(-p.length).toLowerCase() === p) return true;
833
+ if (p && path$10.substr(-p.length).toLowerCase() === p) return true;
834
834
  }
835
835
  return false;
836
836
  }
837
- function checkStat$1(stat, path$9, options) {
837
+ function checkStat$1(stat, path$10, options) {
838
838
  if (!stat.isSymbolicLink() && !stat.isFile()) return false;
839
- return checkPathExt(path$9, options);
839
+ return checkPathExt(path$10, options);
840
840
  }
841
- function isexe$3(path$9, options, cb) {
842
- fs$2.stat(path$9, function(er, stat) {
843
- cb(er, er ? false : checkStat$1(stat, path$9, options));
841
+ function isexe$3(path$10, options, cb) {
842
+ fs$2.stat(path$10, function(er, stat) {
843
+ cb(er, er ? false : checkStat$1(stat, path$10, options));
844
844
  });
845
845
  }
846
- function sync$2(path$9, options) {
847
- return checkStat$1(fs$2.statSync(path$9), path$9, options);
846
+ function sync$2(path$10, options) {
847
+ return checkStat$1(fs$2.statSync(path$10), path$10, options);
848
848
  }
849
849
  }) });
850
850
 
@@ -854,13 +854,13 @@ var require_mode = /* @__PURE__ */ require_chunk.__commonJS({ "../../node_module
854
854
  module.exports = isexe$2;
855
855
  isexe$2.sync = sync$1;
856
856
  var fs$1 = require("fs");
857
- function isexe$2(path$9, options, cb) {
858
- fs$1.stat(path$9, function(er, stat) {
857
+ function isexe$2(path$10, options, cb) {
858
+ fs$1.stat(path$10, function(er, stat) {
859
859
  cb(er, er ? false : checkStat(stat, options));
860
860
  });
861
861
  }
862
- function sync$1(path$9, options) {
863
- return checkStat(fs$1.statSync(path$9), options);
862
+ function sync$1(path$10, options) {
863
+ return checkStat(fs$1.statSync(path$10), options);
864
864
  }
865
865
  function checkStat(stat, options) {
866
866
  return stat.isFile() && checkMode(stat, options);
@@ -889,7 +889,7 @@ var require_isexe = /* @__PURE__ */ require_chunk.__commonJS({ "../../node_modul
889
889
  else core = require_mode();
890
890
  module.exports = isexe$1;
891
891
  isexe$1.sync = sync;
892
- function isexe$1(path$9, options, cb) {
892
+ function isexe$1(path$10, options, cb) {
893
893
  if (typeof options === "function") {
894
894
  cb = options;
895
895
  options = {};
@@ -897,13 +897,13 @@ var require_isexe = /* @__PURE__ */ require_chunk.__commonJS({ "../../node_modul
897
897
  if (!cb) {
898
898
  if (typeof Promise !== "function") throw new TypeError("callback not provided");
899
899
  return new Promise(function(resolve, reject) {
900
- isexe$1(path$9, options || {}, function(er, is) {
900
+ isexe$1(path$10, options || {}, function(er, is) {
901
901
  if (er) reject(er);
902
902
  else resolve(is);
903
903
  });
904
904
  });
905
905
  }
906
- core(path$9, options || {}, function(er, is) {
906
+ core(path$10, options || {}, function(er, is) {
907
907
  if (er) {
908
908
  if (er.code === "EACCES" || options && options.ignoreErrors) {
909
909
  er = null;
@@ -913,9 +913,9 @@ var require_isexe = /* @__PURE__ */ require_chunk.__commonJS({ "../../node_modul
913
913
  cb(er, is);
914
914
  });
915
915
  }
916
- function sync(path$9, options) {
916
+ function sync(path$10, options) {
917
917
  try {
918
- return core.sync(path$9, options || {});
918
+ return core.sync(path$10, options || {});
919
919
  } catch (er) {
920
920
  if (options && options.ignoreErrors || er.code === "EACCES") return false;
921
921
  else throw er;
@@ -927,7 +927,7 @@ var require_isexe = /* @__PURE__ */ require_chunk.__commonJS({ "../../node_modul
927
927
  //#region ../../node_modules/.pnpm/which@2.0.2/node_modules/which/which.js
928
928
  var require_which = /* @__PURE__ */ require_chunk.__commonJS({ "../../node_modules/.pnpm/which@2.0.2/node_modules/which/which.js": ((exports, module) => {
929
929
  const isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
930
- const path$8 = require("path");
930
+ const path$9 = require("path");
931
931
  const COLON = isWindows ? ";" : ":";
932
932
  const isexe = require_isexe();
933
933
  const getNotFoundError = (cmd) => Object.assign(/* @__PURE__ */ new Error(`not found: ${cmd}`), { code: "ENOENT" });
@@ -957,7 +957,7 @@ var require_which = /* @__PURE__ */ require_chunk.__commonJS({ "../../node_modul
957
957
  if (i$1 === pathEnv.length) return opt.all && found.length ? resolve(found) : reject(getNotFoundError(cmd));
958
958
  const ppRaw = pathEnv[i$1];
959
959
  const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
960
- const pCmd = path$8.join(pathPart, cmd);
960
+ const pCmd = path$9.join(pathPart, cmd);
961
961
  const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
962
962
  resolve(subStep(p, i$1, 0));
963
963
  });
@@ -979,7 +979,7 @@ var require_which = /* @__PURE__ */ require_chunk.__commonJS({ "../../node_modul
979
979
  for (let i$1 = 0; i$1 < pathEnv.length; i$1++) {
980
980
  const ppRaw = pathEnv[i$1];
981
981
  const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
982
- const pCmd = path$8.join(pathPart, cmd);
982
+ const pCmd = path$9.join(pathPart, cmd);
983
983
  const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
984
984
  for (let j = 0; j < pathExt.length; j++) {
985
985
  const cur = p + pathExt[j];
@@ -1014,7 +1014,7 @@ var require_path_key = /* @__PURE__ */ require_chunk.__commonJS({ "../../node_mo
1014
1014
  //#endregion
1015
1015
  //#region ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js
1016
1016
  var require_resolveCommand = /* @__PURE__ */ require_chunk.__commonJS({ "../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js": ((exports, module) => {
1017
- const path$7 = require("path");
1017
+ const path$8 = require("path");
1018
1018
  const which = require_which();
1019
1019
  const getPathKey = require_path_key();
1020
1020
  function resolveCommandAttempt(parsed, withoutPathExt) {
@@ -1029,12 +1029,12 @@ var require_resolveCommand = /* @__PURE__ */ require_chunk.__commonJS({ "../../n
1029
1029
  try {
1030
1030
  resolved = which.sync(parsed.command, {
1031
1031
  path: env[getPathKey({ env })],
1032
- pathExt: withoutPathExt ? path$7.delimiter : void 0
1032
+ pathExt: withoutPathExt ? path$8.delimiter : void 0
1033
1033
  });
1034
1034
  } catch (e) {} finally {
1035
1035
  if (shouldSwitchCwd) process.chdir(cwd);
1036
1036
  }
1037
- if (resolved) resolved = path$7.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
1037
+ if (resolved) resolved = path$8.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
1038
1038
  return resolved;
1039
1039
  }
1040
1040
  function resolveCommand$1(parsed) {
@@ -1077,8 +1077,8 @@ var require_shebang_command = /* @__PURE__ */ require_chunk.__commonJS({ "../../
1077
1077
  module.exports = (string = "") => {
1078
1078
  const match = string.match(shebangRegex);
1079
1079
  if (!match) return null;
1080
- const [path$9, argument] = match[0].replace(/#! ?/, "").split(" ");
1081
- const binary = path$9.split("/").pop();
1080
+ const [path$10, argument] = match[0].replace(/#! ?/, "").split(" ");
1081
+ const binary = path$10.split("/").pop();
1082
1082
  if (binary === "env") return argument;
1083
1083
  return argument ? `${binary} ${argument}` : binary;
1084
1084
  };
@@ -1106,7 +1106,7 @@ var require_readShebang = /* @__PURE__ */ require_chunk.__commonJS({ "../../node
1106
1106
  //#endregion
1107
1107
  //#region ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js
1108
1108
  var require_parse = /* @__PURE__ */ require_chunk.__commonJS({ "../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js": ((exports, module) => {
1109
- const path$6 = require("path");
1109
+ const path$7 = require("path");
1110
1110
  const resolveCommand = require_resolveCommand();
1111
1111
  const escape = require_escape();
1112
1112
  const readShebang = require_readShebang();
@@ -1129,7 +1129,7 @@ var require_parse = /* @__PURE__ */ require_chunk.__commonJS({ "../../node_modul
1129
1129
  const needsShell = !isExecutableRegExp.test(commandFile);
1130
1130
  if (parsed.options.forceShell || needsShell) {
1131
1131
  const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
1132
- parsed.command = path$6.normalize(parsed.command);
1132
+ parsed.command = path$7.normalize(parsed.command);
1133
1133
  parsed.command = escape.command(parsed.command);
1134
1134
  parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars));
1135
1135
  const shellCommand = [parsed.command].concat(parsed.args).join(" ");
@@ -4272,12 +4272,12 @@ const logOutputSync = ({ serializedResult, fdNumber, state, verboseInfo, encodin
4272
4272
  }
4273
4273
  };
4274
4274
  const writeToFiles = (serializedResult, stdioItems, outputFiles) => {
4275
- for (const { path: path$9, append } of stdioItems.filter(({ type }) => FILE_TYPES.has(type))) {
4276
- const pathString = typeof path$9 === "string" ? path$9 : path$9.toString();
4277
- if (append || outputFiles.has(pathString)) (0, node_fs.appendFileSync)(path$9, serializedResult);
4275
+ for (const { path: path$10, append } of stdioItems.filter(({ type }) => FILE_TYPES.has(type))) {
4276
+ const pathString = typeof path$10 === "string" ? path$10 : path$10.toString();
4277
+ if (append || outputFiles.has(pathString)) (0, node_fs.appendFileSync)(path$10, serializedResult);
4278
4278
  else {
4279
4279
  outputFiles.add(pathString);
4280
- (0, node_fs.writeFileSync)(path$9, serializedResult);
4280
+ (0, node_fs.writeFileSync)(path$10, serializedResult);
4281
4281
  }
4282
4282
  }
4283
4283
  };
@@ -6575,6 +6575,7 @@ async function generate({ input, config, progressCache, args }) {
6575
6575
  write: true,
6576
6576
  barrelType: "named",
6577
6577
  extension: { ".ts": ".ts" },
6578
+ format: "prettier",
6578
6579
  ...userConfig.output
6579
6580
  }
6580
6581
  };
@@ -6619,6 +6620,68 @@ async function generate({ input, config, progressCache, args }) {
6619
6620
  logger.consola?.error(error);
6620
6621
  node_process.default.exit(1);
6621
6622
  }
6623
+ if (config.output.format === "prettier") {
6624
+ logger?.emit("start", `Formatting with ${config.output.format}`);
6625
+ try {
6626
+ await execa("prettier", [
6627
+ "--ignore-unknown",
6628
+ "--write",
6629
+ node_path.default.resolve(definedConfig.root, definedConfig.output.path)
6630
+ ]);
6631
+ } catch (e) {
6632
+ logger.consola?.warn("Prettier not found");
6633
+ logger.consola?.error(e);
6634
+ }
6635
+ logger?.emit("success", `Formatted with ${config.output.format}`);
6636
+ }
6637
+ if (config.output.format === "biome") {
6638
+ logger?.emit("start", `Formatting with ${config.output.format}`);
6639
+ try {
6640
+ await execa("biome", [
6641
+ "format",
6642
+ "--write",
6643
+ node_path.default.resolve(definedConfig.root, definedConfig.output.path)
6644
+ ]);
6645
+ } catch (e) {
6646
+ logger.consola?.warn("Biome not found");
6647
+ logger.consola?.error(e);
6648
+ }
6649
+ logger?.emit("success", `Formatted with ${config.output.format}`);
6650
+ }
6651
+ if (config.output.lint === "eslint") {
6652
+ logger?.emit("start", `Linting with ${config.output.format}`);
6653
+ try {
6654
+ await execa("eslint", [node_path.default.resolve(definedConfig.root, definedConfig.output.path), "--fix"]);
6655
+ } catch (e) {
6656
+ logger.consola?.warn("Eslint not found");
6657
+ logger.consola?.error(e);
6658
+ }
6659
+ logger?.emit("success", `Linted with ${config.output.format}`);
6660
+ }
6661
+ if (config.output.lint === "biome") {
6662
+ logger?.emit("start", `Linting with ${config.output.format}`);
6663
+ try {
6664
+ await execa("biome", [
6665
+ "lint",
6666
+ "--fix",
6667
+ node_path.default.resolve(definedConfig.root, definedConfig.output.path)
6668
+ ]);
6669
+ } catch (e) {
6670
+ logger.consola?.warn("Biome not found");
6671
+ logger.consola?.error(e);
6672
+ }
6673
+ logger?.emit("success", `Linted with ${config.output.format}`);
6674
+ }
6675
+ if (config.output.lint === "oxlint") {
6676
+ logger?.emit("start", `Linting with ${config.output.format}`);
6677
+ try {
6678
+ await execa("oxlint", ["--fix", node_path.default.resolve(definedConfig.root, definedConfig.output.path)]);
6679
+ } catch (e) {
6680
+ logger.consola?.warn("Oxlint not found");
6681
+ logger.consola?.error(e);
6682
+ }
6683
+ logger?.emit("success", `Linted with ${config.output.format}`);
6684
+ }
6622
6685
  if (config.hooks) await executeHooks({
6623
6686
  hooks: config.hooks,
6624
6687
  logger
@@ -6637,4 +6700,4 @@ async function generate({ input, config, progressCache, args }) {
6637
6700
 
6638
6701
  //#endregion
6639
6702
  exports.generate = generate;
6640
- //# sourceMappingURL=generate-TqAvum5c.cjs.map
6703
+ //# sourceMappingURL=generate-Cod5_RqJ.cjs.map