@kubb/cli 3.17.0 → 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.
- package/dist/{generate-DAJRIO7l.js → generate-BqEOROw2.js} +95 -1
- package/dist/generate-BqEOROw2.js.map +1 -0
- package/dist/{generate-AG4UwoYw.cjs → generate-DZp-7WcR.cjs} +2 -2
- package/dist/{generate-AG4UwoYw.cjs.map → generate-DZp-7WcR.cjs.map} +1 -1
- package/dist/{generate-TqAvum5c.cjs → generate-DbZb8mNG.cjs} +127 -33
- package/dist/generate-DbZb8mNG.cjs.map +1 -0
- package/dist/{generate-6jcPLg_V.js → generate-p_ZFPEjK.js} +2 -2
- package/dist/{generate-6jcPLg_V.js.map → generate-p_ZFPEjK.js.map} +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
- package/src/runners/generate.ts +109 -0
- package/dist/generate-DAJRIO7l.js.map +0 -1
- package/dist/generate-TqAvum5c.cjs.map +0 -1
|
@@ -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-
|
|
182
|
+
const { generate } = await Promise.resolve().then(() => require("./generate-DbZb8mNG.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-
|
|
254
|
+
//# sourceMappingURL=generate-DZp-7WcR.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-AG4UwoYw.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 { cosmiconfig } from 'cosmiconfig'\nimport { createJiti } from 'jiti'\n\nimport type { UserConfig, defineConfig } from '@kubb/core'\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,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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"}
|
|
1
|
+
{"version":3,"file":"generate-DZp-7WcR.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 { cosmiconfig } from 'cosmiconfig'\nimport { createJiti } from 'jiti'\n\nimport type { UserConfig, defineConfig } from '@kubb/core'\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,OAAK,MAAM,QAAQ,YAAY;GAC7B,MAAM,UAAU,KAAK,UAAU,MAAM,WAAW,KAAK,WAAW;AAEhE,WAAQ,KAAK;IACX,GAAG;IACH;IACD;EACF;A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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"}
|
|
@@ -4,6 +4,7 @@ const node_process = require_chunk.__toESM(require("node:process"));
|
|
|
4
4
|
const __kubb_core = require_chunk.__toESM(require("@kubb/core"));
|
|
5
5
|
const __kubb_core_logger = require_chunk.__toESM(require("@kubb/core/logger"));
|
|
6
6
|
const picocolors = require_chunk.__toESM(require("picocolors"));
|
|
7
|
+
const __kubb_core_fs = require_chunk.__toESM(require("@kubb/core/fs"));
|
|
7
8
|
const cli_progress = require_chunk.__toESM(require("cli-progress"));
|
|
8
9
|
const node_url = require_chunk.__toESM(require("node:url"));
|
|
9
10
|
const node_child_process = require_chunk.__toESM(require("node:child_process"));
|
|
@@ -823,28 +824,28 @@ var require_windows = /* @__PURE__ */ require_chunk.__commonJS({ "../../node_mod
|
|
|
823
824
|
module.exports = isexe$3;
|
|
824
825
|
isexe$3.sync = sync$2;
|
|
825
826
|
var fs$2 = require("fs");
|
|
826
|
-
function checkPathExt(path$
|
|
827
|
+
function checkPathExt(path$10, options) {
|
|
827
828
|
var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
|
|
828
829
|
if (!pathext) return true;
|
|
829
830
|
pathext = pathext.split(";");
|
|
830
831
|
if (pathext.indexOf("") !== -1) return true;
|
|
831
832
|
for (var i$1 = 0; i$1 < pathext.length; i$1++) {
|
|
832
833
|
var p = pathext[i$1].toLowerCase();
|
|
833
|
-
if (p && path$
|
|
834
|
+
if (p && path$10.substr(-p.length).toLowerCase() === p) return true;
|
|
834
835
|
}
|
|
835
836
|
return false;
|
|
836
837
|
}
|
|
837
|
-
function checkStat$1(stat, path$
|
|
838
|
+
function checkStat$1(stat, path$10, options) {
|
|
838
839
|
if (!stat.isSymbolicLink() && !stat.isFile()) return false;
|
|
839
|
-
return checkPathExt(path$
|
|
840
|
+
return checkPathExt(path$10, options);
|
|
840
841
|
}
|
|
841
|
-
function isexe$3(path$
|
|
842
|
-
fs$2.stat(path$
|
|
843
|
-
cb(er, er ? false : checkStat$1(stat, path$
|
|
842
|
+
function isexe$3(path$10, options, cb) {
|
|
843
|
+
fs$2.stat(path$10, function(er, stat) {
|
|
844
|
+
cb(er, er ? false : checkStat$1(stat, path$10, options));
|
|
844
845
|
});
|
|
845
846
|
}
|
|
846
|
-
function sync$2(path$
|
|
847
|
-
return checkStat$1(fs$2.statSync(path$
|
|
847
|
+
function sync$2(path$10, options) {
|
|
848
|
+
return checkStat$1(fs$2.statSync(path$10), path$10, options);
|
|
848
849
|
}
|
|
849
850
|
}) });
|
|
850
851
|
|
|
@@ -854,13 +855,13 @@ var require_mode = /* @__PURE__ */ require_chunk.__commonJS({ "../../node_module
|
|
|
854
855
|
module.exports = isexe$2;
|
|
855
856
|
isexe$2.sync = sync$1;
|
|
856
857
|
var fs$1 = require("fs");
|
|
857
|
-
function isexe$2(path$
|
|
858
|
-
fs$1.stat(path$
|
|
858
|
+
function isexe$2(path$10, options, cb) {
|
|
859
|
+
fs$1.stat(path$10, function(er, stat) {
|
|
859
860
|
cb(er, er ? false : checkStat(stat, options));
|
|
860
861
|
});
|
|
861
862
|
}
|
|
862
|
-
function sync$1(path$
|
|
863
|
-
return checkStat(fs$1.statSync(path$
|
|
863
|
+
function sync$1(path$10, options) {
|
|
864
|
+
return checkStat(fs$1.statSync(path$10), options);
|
|
864
865
|
}
|
|
865
866
|
function checkStat(stat, options) {
|
|
866
867
|
return stat.isFile() && checkMode(stat, options);
|
|
@@ -889,7 +890,7 @@ var require_isexe = /* @__PURE__ */ require_chunk.__commonJS({ "../../node_modul
|
|
|
889
890
|
else core = require_mode();
|
|
890
891
|
module.exports = isexe$1;
|
|
891
892
|
isexe$1.sync = sync;
|
|
892
|
-
function isexe$1(path$
|
|
893
|
+
function isexe$1(path$10, options, cb) {
|
|
893
894
|
if (typeof options === "function") {
|
|
894
895
|
cb = options;
|
|
895
896
|
options = {};
|
|
@@ -897,13 +898,13 @@ var require_isexe = /* @__PURE__ */ require_chunk.__commonJS({ "../../node_modul
|
|
|
897
898
|
if (!cb) {
|
|
898
899
|
if (typeof Promise !== "function") throw new TypeError("callback not provided");
|
|
899
900
|
return new Promise(function(resolve, reject) {
|
|
900
|
-
isexe$1(path$
|
|
901
|
+
isexe$1(path$10, options || {}, function(er, is) {
|
|
901
902
|
if (er) reject(er);
|
|
902
903
|
else resolve(is);
|
|
903
904
|
});
|
|
904
905
|
});
|
|
905
906
|
}
|
|
906
|
-
core(path$
|
|
907
|
+
core(path$10, options || {}, function(er, is) {
|
|
907
908
|
if (er) {
|
|
908
909
|
if (er.code === "EACCES" || options && options.ignoreErrors) {
|
|
909
910
|
er = null;
|
|
@@ -913,9 +914,9 @@ var require_isexe = /* @__PURE__ */ require_chunk.__commonJS({ "../../node_modul
|
|
|
913
914
|
cb(er, is);
|
|
914
915
|
});
|
|
915
916
|
}
|
|
916
|
-
function sync(path$
|
|
917
|
+
function sync(path$10, options) {
|
|
917
918
|
try {
|
|
918
|
-
return core.sync(path$
|
|
919
|
+
return core.sync(path$10, options || {});
|
|
919
920
|
} catch (er) {
|
|
920
921
|
if (options && options.ignoreErrors || er.code === "EACCES") return false;
|
|
921
922
|
else throw er;
|
|
@@ -927,7 +928,7 @@ var require_isexe = /* @__PURE__ */ require_chunk.__commonJS({ "../../node_modul
|
|
|
927
928
|
//#region ../../node_modules/.pnpm/which@2.0.2/node_modules/which/which.js
|
|
928
929
|
var require_which = /* @__PURE__ */ require_chunk.__commonJS({ "../../node_modules/.pnpm/which@2.0.2/node_modules/which/which.js": ((exports, module) => {
|
|
929
930
|
const isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
|
|
930
|
-
const path$
|
|
931
|
+
const path$9 = require("path");
|
|
931
932
|
const COLON = isWindows ? ";" : ":";
|
|
932
933
|
const isexe = require_isexe();
|
|
933
934
|
const getNotFoundError = (cmd) => Object.assign(/* @__PURE__ */ new Error(`not found: ${cmd}`), { code: "ENOENT" });
|
|
@@ -957,7 +958,7 @@ var require_which = /* @__PURE__ */ require_chunk.__commonJS({ "../../node_modul
|
|
|
957
958
|
if (i$1 === pathEnv.length) return opt.all && found.length ? resolve(found) : reject(getNotFoundError(cmd));
|
|
958
959
|
const ppRaw = pathEnv[i$1];
|
|
959
960
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
960
|
-
const pCmd = path$
|
|
961
|
+
const pCmd = path$9.join(pathPart, cmd);
|
|
961
962
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
962
963
|
resolve(subStep(p, i$1, 0));
|
|
963
964
|
});
|
|
@@ -979,7 +980,7 @@ var require_which = /* @__PURE__ */ require_chunk.__commonJS({ "../../node_modul
|
|
|
979
980
|
for (let i$1 = 0; i$1 < pathEnv.length; i$1++) {
|
|
980
981
|
const ppRaw = pathEnv[i$1];
|
|
981
982
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
982
|
-
const pCmd = path$
|
|
983
|
+
const pCmd = path$9.join(pathPart, cmd);
|
|
983
984
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
984
985
|
for (let j = 0; j < pathExt.length; j++) {
|
|
985
986
|
const cur = p + pathExt[j];
|
|
@@ -1014,7 +1015,7 @@ var require_path_key = /* @__PURE__ */ require_chunk.__commonJS({ "../../node_mo
|
|
|
1014
1015
|
//#endregion
|
|
1015
1016
|
//#region ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js
|
|
1016
1017
|
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$
|
|
1018
|
+
const path$8 = require("path");
|
|
1018
1019
|
const which = require_which();
|
|
1019
1020
|
const getPathKey = require_path_key();
|
|
1020
1021
|
function resolveCommandAttempt(parsed, withoutPathExt) {
|
|
@@ -1029,12 +1030,12 @@ var require_resolveCommand = /* @__PURE__ */ require_chunk.__commonJS({ "../../n
|
|
|
1029
1030
|
try {
|
|
1030
1031
|
resolved = which.sync(parsed.command, {
|
|
1031
1032
|
path: env[getPathKey({ env })],
|
|
1032
|
-
pathExt: withoutPathExt ? path$
|
|
1033
|
+
pathExt: withoutPathExt ? path$8.delimiter : void 0
|
|
1033
1034
|
});
|
|
1034
1035
|
} catch (e) {} finally {
|
|
1035
1036
|
if (shouldSwitchCwd) process.chdir(cwd);
|
|
1036
1037
|
}
|
|
1037
|
-
if (resolved) resolved = path$
|
|
1038
|
+
if (resolved) resolved = path$8.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
|
|
1038
1039
|
return resolved;
|
|
1039
1040
|
}
|
|
1040
1041
|
function resolveCommand$1(parsed) {
|
|
@@ -1077,8 +1078,8 @@ var require_shebang_command = /* @__PURE__ */ require_chunk.__commonJS({ "../../
|
|
|
1077
1078
|
module.exports = (string = "") => {
|
|
1078
1079
|
const match = string.match(shebangRegex);
|
|
1079
1080
|
if (!match) return null;
|
|
1080
|
-
const [path$
|
|
1081
|
-
const binary = path$
|
|
1081
|
+
const [path$10, argument] = match[0].replace(/#! ?/, "").split(" ");
|
|
1082
|
+
const binary = path$10.split("/").pop();
|
|
1082
1083
|
if (binary === "env") return argument;
|
|
1083
1084
|
return argument ? `${binary} ${argument}` : binary;
|
|
1084
1085
|
};
|
|
@@ -1106,7 +1107,7 @@ var require_readShebang = /* @__PURE__ */ require_chunk.__commonJS({ "../../node
|
|
|
1106
1107
|
//#endregion
|
|
1107
1108
|
//#region ../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js
|
|
1108
1109
|
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$
|
|
1110
|
+
const path$7 = require("path");
|
|
1110
1111
|
const resolveCommand = require_resolveCommand();
|
|
1111
1112
|
const escape = require_escape();
|
|
1112
1113
|
const readShebang = require_readShebang();
|
|
@@ -1129,7 +1130,7 @@ var require_parse = /* @__PURE__ */ require_chunk.__commonJS({ "../../node_modul
|
|
|
1129
1130
|
const needsShell = !isExecutableRegExp.test(commandFile);
|
|
1130
1131
|
if (parsed.options.forceShell || needsShell) {
|
|
1131
1132
|
const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
|
|
1132
|
-
parsed.command = path$
|
|
1133
|
+
parsed.command = path$7.normalize(parsed.command);
|
|
1133
1134
|
parsed.command = escape.command(parsed.command);
|
|
1134
1135
|
parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars));
|
|
1135
1136
|
const shellCommand = [parsed.command].concat(parsed.args).join(" ");
|
|
@@ -4272,12 +4273,12 @@ const logOutputSync = ({ serializedResult, fdNumber, state, verboseInfo, encodin
|
|
|
4272
4273
|
}
|
|
4273
4274
|
};
|
|
4274
4275
|
const writeToFiles = (serializedResult, stdioItems, outputFiles) => {
|
|
4275
|
-
for (const { path: path$
|
|
4276
|
-
const pathString = typeof path$
|
|
4277
|
-
if (append || outputFiles.has(pathString)) (0, node_fs.appendFileSync)(path$
|
|
4276
|
+
for (const { path: path$10, append } of stdioItems.filter(({ type }) => FILE_TYPES.has(type))) {
|
|
4277
|
+
const pathString = typeof path$10 === "string" ? path$10 : path$10.toString();
|
|
4278
|
+
if (append || outputFiles.has(pathString)) (0, node_fs.appendFileSync)(path$10, serializedResult);
|
|
4278
4279
|
else {
|
|
4279
4280
|
outputFiles.add(pathString);
|
|
4280
|
-
(0, node_fs.writeFileSync)(path$
|
|
4281
|
+
(0, node_fs.writeFileSync)(path$10, serializedResult);
|
|
4281
4282
|
}
|
|
4282
4283
|
}
|
|
4283
4284
|
};
|
|
@@ -6575,6 +6576,7 @@ async function generate({ input, config, progressCache, args }) {
|
|
|
6575
6576
|
write: true,
|
|
6576
6577
|
barrelType: "named",
|
|
6577
6578
|
extension: { ".ts": ".ts" },
|
|
6579
|
+
format: "prettier",
|
|
6578
6580
|
...userConfig.output
|
|
6579
6581
|
}
|
|
6580
6582
|
};
|
|
@@ -6619,6 +6621,98 @@ async function generate({ input, config, progressCache, args }) {
|
|
|
6619
6621
|
logger.consola?.error(error);
|
|
6620
6622
|
node_process.default.exit(1);
|
|
6621
6623
|
}
|
|
6624
|
+
if (userConfig.output.format === void 0) {
|
|
6625
|
+
const config$1 = {
|
|
6626
|
+
tabWidth: 2,
|
|
6627
|
+
printWidth: 160,
|
|
6628
|
+
singleQuote: true,
|
|
6629
|
+
semi: false,
|
|
6630
|
+
bracketSameLine: false,
|
|
6631
|
+
endOfLine: "auto",
|
|
6632
|
+
plugins: ["prettier/plugins/typescript"]
|
|
6633
|
+
};
|
|
6634
|
+
try {
|
|
6635
|
+
logger?.emit("start", "Applying default Formatting");
|
|
6636
|
+
const configPath = node_path.default.resolve(definedConfig.root, ".prettierrc.temp.json");
|
|
6637
|
+
await (0, __kubb_core_fs.write)(configPath, JSON.stringify(config$1));
|
|
6638
|
+
await execa("npx", [
|
|
6639
|
+
"--yes",
|
|
6640
|
+
"prettier",
|
|
6641
|
+
"--ignore-unknown",
|
|
6642
|
+
"--config",
|
|
6643
|
+
configPath,
|
|
6644
|
+
"--write",
|
|
6645
|
+
node_path.default.resolve(definedConfig.root, definedConfig.output.path)
|
|
6646
|
+
]);
|
|
6647
|
+
await (0, __kubb_core_fs.unlink)(configPath);
|
|
6648
|
+
} catch (e) {
|
|
6649
|
+
logger.consola?.warn("Prettier not found");
|
|
6650
|
+
logger.consola?.error(e);
|
|
6651
|
+
}
|
|
6652
|
+
logger?.emit("success", "Applied default Formatting");
|
|
6653
|
+
}
|
|
6654
|
+
if (config.output.format === "prettier") {
|
|
6655
|
+
logger?.emit("start", `Formatting with ${config.output.format}`);
|
|
6656
|
+
try {
|
|
6657
|
+
await execa("prettier", [
|
|
6658
|
+
"--ignore-unknown",
|
|
6659
|
+
"--write",
|
|
6660
|
+
node_path.default.resolve(definedConfig.root, definedConfig.output.path)
|
|
6661
|
+
]);
|
|
6662
|
+
} catch (e) {
|
|
6663
|
+
logger.consola?.warn("Prettier not found");
|
|
6664
|
+
logger.consola?.error(e);
|
|
6665
|
+
}
|
|
6666
|
+
logger?.emit("success", `Formatted with ${config.output.format}`);
|
|
6667
|
+
}
|
|
6668
|
+
if (config.output.format === "biome") {
|
|
6669
|
+
logger?.emit("start", `Formatting with ${config.output.format}`);
|
|
6670
|
+
try {
|
|
6671
|
+
await execa("biome", [
|
|
6672
|
+
"format",
|
|
6673
|
+
"--write",
|
|
6674
|
+
node_path.default.resolve(definedConfig.root, definedConfig.output.path)
|
|
6675
|
+
]);
|
|
6676
|
+
} catch (e) {
|
|
6677
|
+
logger.consola?.warn("Biome not found");
|
|
6678
|
+
logger.consola?.error(e);
|
|
6679
|
+
}
|
|
6680
|
+
logger?.emit("success", `Formatted with ${config.output.format}`);
|
|
6681
|
+
}
|
|
6682
|
+
if (config.output.lint === "eslint") {
|
|
6683
|
+
logger?.emit("start", `Linting with ${config.output.format}`);
|
|
6684
|
+
try {
|
|
6685
|
+
await execa("eslint", [node_path.default.resolve(definedConfig.root, definedConfig.output.path), "--fix"]);
|
|
6686
|
+
} catch (e) {
|
|
6687
|
+
logger.consola?.warn("Eslint not found");
|
|
6688
|
+
logger.consola?.error(e);
|
|
6689
|
+
}
|
|
6690
|
+
logger?.emit("success", `Linted with ${config.output.format}`);
|
|
6691
|
+
}
|
|
6692
|
+
if (config.output.lint === "biome") {
|
|
6693
|
+
logger?.emit("start", `Linting with ${config.output.format}`);
|
|
6694
|
+
try {
|
|
6695
|
+
await execa("biome", [
|
|
6696
|
+
"lint",
|
|
6697
|
+
"--fix",
|
|
6698
|
+
node_path.default.resolve(definedConfig.root, definedConfig.output.path)
|
|
6699
|
+
]);
|
|
6700
|
+
} catch (e) {
|
|
6701
|
+
logger.consola?.warn("Biome not found");
|
|
6702
|
+
logger.consola?.error(e);
|
|
6703
|
+
}
|
|
6704
|
+
logger?.emit("success", `Linted with ${config.output.format}`);
|
|
6705
|
+
}
|
|
6706
|
+
if (config.output.lint === "oxlint") {
|
|
6707
|
+
logger?.emit("start", `Linting with ${config.output.format}`);
|
|
6708
|
+
try {
|
|
6709
|
+
await execa("oxlint", ["--fix", node_path.default.resolve(definedConfig.root, definedConfig.output.path)]);
|
|
6710
|
+
} catch (e) {
|
|
6711
|
+
logger.consola?.warn("Oxlint not found");
|
|
6712
|
+
logger.consola?.error(e);
|
|
6713
|
+
}
|
|
6714
|
+
logger?.emit("success", `Linted with ${config.output.format}`);
|
|
6715
|
+
}
|
|
6622
6716
|
if (config.hooks) await executeHooks({
|
|
6623
6717
|
hooks: config.hooks,
|
|
6624
6718
|
logger
|
|
@@ -6637,4 +6731,4 @@ async function generate({ input, config, progressCache, args }) {
|
|
|
6637
6731
|
|
|
6638
6732
|
//#endregion
|
|
6639
6733
|
exports.generate = generate;
|
|
6640
|
-
//# sourceMappingURL=generate-
|
|
6734
|
+
//# sourceMappingURL=generate-DbZb8mNG.cjs.map
|