@kubb/cli 4.11.1 → 4.11.2
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-mP1U-zi4.js → generate-CYBFB3tU.js} +11 -4
- package/dist/generate-CYBFB3tU.js.map +1 -0
- package/dist/{generate-BGADYMY6.js → generate-CpBJ2Y-n.js} +109 -57
- package/dist/generate-CpBJ2Y-n.js.map +1 -0
- package/dist/{generate-LbioowO-.cjs → generate-DpHvARzf.cjs} +109 -57
- package/dist/generate-DpHvARzf.cjs.map +1 -0
- package/dist/{generate-CVRHD5GD.cjs → generate-KUqCSnZp.cjs} +11 -4
- package/dist/generate-KUqCSnZp.cjs.map +1 -0
- 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 +4 -4
- package/src/commands/generate.ts +12 -2
- package/src/runners/generate.ts +88 -49
- package/src/utils/getSummary.ts +52 -8
- package/dist/generate-BGADYMY6.js.map +0 -1
- package/dist/generate-CVRHD5GD.cjs.map +0 -1
- package/dist/generate-LbioowO-.cjs.map +0 -1
- package/dist/generate-mP1U-zi4.js.map +0 -1
- package/src/utils/getErrorCauses.ts +0 -14
|
@@ -133,10 +133,10 @@ const command = defineCommand({
|
|
|
133
133
|
},
|
|
134
134
|
logLevel: {
|
|
135
135
|
type: "string",
|
|
136
|
-
description: "Info, silent or debug",
|
|
136
|
+
description: "Info, silent, verbose or debug",
|
|
137
137
|
alias: "l",
|
|
138
138
|
default: "info",
|
|
139
|
-
valueHint: "silent|info|debug"
|
|
139
|
+
valueHint: "silent|info|verbose|debug"
|
|
140
140
|
},
|
|
141
141
|
watch: {
|
|
142
142
|
type: "boolean",
|
|
@@ -150,6 +150,12 @@ const command = defineCommand({
|
|
|
150
150
|
alias: "d",
|
|
151
151
|
default: false
|
|
152
152
|
},
|
|
153
|
+
verbose: {
|
|
154
|
+
type: "boolean",
|
|
155
|
+
description: "Override logLevel to verbose",
|
|
156
|
+
alias: "v",
|
|
157
|
+
default: false
|
|
158
|
+
},
|
|
153
159
|
help: {
|
|
154
160
|
type: "boolean",
|
|
155
161
|
description: "Show help",
|
|
@@ -163,8 +169,9 @@ const command = defineCommand({
|
|
|
163
169
|
const input = args._[0];
|
|
164
170
|
if (args.help) return showUsage(command);
|
|
165
171
|
if (args.debug) args.logLevel = "debug";
|
|
172
|
+
if (args.verbose) args.logLevel = "verbose";
|
|
166
173
|
const logger = createLogger({ logLevel: LogMapper[args.logLevel] || 3 });
|
|
167
|
-
const { generate } = await import("./generate-
|
|
174
|
+
const { generate } = await import("./generate-CpBJ2Y-n.js");
|
|
168
175
|
logger.emit("start", "Loading config");
|
|
169
176
|
const result = await getCosmiConfig("kubb", args.config);
|
|
170
177
|
logger.emit("success", `Config loaded(${pc.dim(path.relative(process$1.cwd(), result.filepath))})`);
|
|
@@ -211,4 +218,4 @@ var generate_default = command;
|
|
|
211
218
|
|
|
212
219
|
//#endregion
|
|
213
220
|
export { generate_default as default };
|
|
214
|
-
//# sourceMappingURL=generate-
|
|
221
|
+
//# sourceMappingURL=generate-CYBFB3tU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-CYBFB3tU.js","names":["results: Array<Config>","path","process"],"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 type { CLIOptions, Config, UserConfig } from '@kubb/core'\nimport { isPromise } from '@kubb/core/utils'\nimport type { Args } from '../commands/generate.ts'\nimport type { CosmiconfigResult } from './getCosmiConfig.ts'\nimport { getPlugins } from './getPlugins.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 as CLIOptions)\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-fabric',\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 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, verbose or debug',\n alias: 'l',\n default: 'info',\n valueHint: 'silent|info|verbose|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 verbose: {\n type: 'boolean',\n description: 'Override logLevel to verbose',\n alias: 'v',\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 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 if (args.verbose) {\n args.logLevel = 'verbose'\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 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.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,OAAO,IAAI,OAAO,QAAQ,GAAG,EAAE,KAAK;GACzD;;AAGJ,SAAS,gBAAgB,SAAgD;AACvE,QAAO,mBAAmB,UAAU,CAAC,MAAM,QAAQ,QAAQ;;AAG7D,SAAgB,WAAW,SAAgE;AACzF,KAAI,gBAAgB,QAAQ,CAC1B,OAAM,IAAI,MAAM,uGAAuG;AAGzH,KAAI,cAAc,QAAQ,CACxB,OAAM,IAAI,MAAM,qGAAqG;AAGvH,QAAO,QAAQ,QAAQ,QAAQ;;;;;;;;ACZjC,eAAsB,UAAU,QAA2B,MAA6C;CACtG,MAAM,SAAS,QAAQ;CACvB,IAAI,iBAAiB,QAAQ,QAAQ,OAAO;AAG5C,KAAI,OAAO,WAAW,YAAY;EAChC,MAAM,kBAAkB,OAAO,KAAmB;AAClD,MAAI,UAAU,gBAAgB,CAC5B,kBAAiB;AAEnB,mBAAiB,QAAQ,QAAQ,gBAAgB;;CAGnD,IAAI,aAAa,MAAM;AAEvB,KAAI,MAAM,QAAQ,WAAW,EAAE;EAC7B,MAAMA,UAAyB,EAAE;AAEjC,OAAK,MAAM,QAAQ,YAAY;GAC7B,MAAM,UAAU,KAAK,UAAU,MAAM,WAAW,KAAK,QAAQ,GAAG;AAEhE,WAAQ,KAAK;IACX,GAAG;IACH;IACD,CAAW;;AAGd,SAAO;;AAGT,cAAa;EACX,GAAG;E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OAAO;AAErB,YAAO,SAAS;MACd;MACA,QAAQ;MACR;MACA;MACD,CAAC;MACF;AAEF,UAAM,eAAe,IAAI,OAAO,SAAS;AACzC;;AAGF,iBAAc,OAAO;AAErB,SAAM,SAAS;IACb;IACA;IACA;IACA;IACD,CAAC;;AAKJ,MAAI,KAAK,OAAO;AACd,OAAI,MAAM,QAAQ,OAAO,CACvB,OAAM,IAAI,MAAM,kDAAkD;AAGpE,OAAI,YAAY,OAAO,CACrB,QAAO,aAAa,CAAC,SAAS,OAAO,MAAM,KAAK,EAAE,OAAO,UAAU;AACjE,UAAM,OAAO;AACb,WAAO,KAAK,SAAS,GAAG,OAAO,GAAG,KAAK,2BAA2B,MAAM,KAAK,QAAQ,GAAG,CAAC,CAAC;KAC1F;;AAIN,QAAM,OAAO;AAEb,MAAI,WAAW,kBAMb,KALmB,MAAM,OAAO,SAAS,OAAO,oDAAoD;GAClG,MAAM;GACN,SAAS;GACV,CAAC,CAGA,OAAM,OAAO;MAEb,WAAQ,KAAK,EAAE;;CAItB,CAAC;AAEF,uBAAe"}
|
|
@@ -43,20 +43,6 @@ async function executeHooks({ hooks, logger }) {
|
|
|
43
43
|
logger?.emit("success", "Executed hooks");
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
//#endregion
|
|
47
|
-
//#region src/utils/getErrorCauses.ts
|
|
48
|
-
function getErrorCauses(errors) {
|
|
49
|
-
return errors.reduce((prev, error) => {
|
|
50
|
-
const causedError = error?.cause;
|
|
51
|
-
if (causedError) {
|
|
52
|
-
prev = [...prev, ...getErrorCauses([causedError])];
|
|
53
|
-
return prev;
|
|
54
|
-
}
|
|
55
|
-
prev = [...prev, error];
|
|
56
|
-
return prev;
|
|
57
|
-
}, []).filter(Boolean);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
46
|
//#endregion
|
|
61
47
|
//#region src/utils/parseHrtimeToSeconds.ts
|
|
62
48
|
function parseHrtimeToSeconds(hrtime) {
|
|
@@ -65,24 +51,50 @@ function parseHrtimeToSeconds(hrtime) {
|
|
|
65
51
|
|
|
66
52
|
//#endregion
|
|
67
53
|
//#region src/utils/getSummary.ts
|
|
68
|
-
function getSummary({ failedPlugins, filesCreated, status, hrStart, config }) {
|
|
54
|
+
function getSummary({ failedPlugins, filesCreated, status, hrStart, config, pluginTimings }) {
|
|
69
55
|
const logs = /* @__PURE__ */ new Set();
|
|
70
56
|
const elapsedSeconds = parseHrtimeToSeconds(process.hrtime(hrStart));
|
|
71
57
|
const pluginsCount = config.plugins?.length || 0;
|
|
72
58
|
const successCount = pluginsCount - failedPlugins.size;
|
|
73
59
|
const meta = {
|
|
74
|
-
plugins: status === "success" ? `${pc.green(`${successCount} successful`)}, ${pluginsCount} total` : `${pc.red(`${failedPlugins.size
|
|
60
|
+
plugins: status === "success" ? `${pc.green(`${successCount} successful`)}, ${pluginsCount} total` : `${pc.green(`${successCount} successful`)}, ${pc.red(`${failedPlugins.size} failed`)}, ${pluginsCount} total`,
|
|
75
61
|
pluginsFailed: status === "failed" ? [...failedPlugins]?.map(({ plugin }) => randomCliColour(plugin.name))?.join(", ") : void 0,
|
|
76
62
|
filesCreated,
|
|
77
63
|
time: `${pc.yellow(`${elapsedSeconds}s`)}`,
|
|
78
64
|
output: path.isAbsolute(config.root) ? path.resolve(config.root, config.output.path) : config.root
|
|
79
65
|
};
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
66
|
+
const labels = {
|
|
67
|
+
plugins: "Plugins:",
|
|
68
|
+
failed: "Failed:",
|
|
69
|
+
generated: "Generated:",
|
|
70
|
+
output: "Output:"
|
|
71
|
+
};
|
|
72
|
+
const maxLabelLength = Math.max(...Object.values(labels).map((l) => l.length));
|
|
73
|
+
const summaryLines = [
|
|
74
|
+
[`${pc.bold(labels.plugins.padEnd(maxLabelLength))} ${meta.plugins}`, true],
|
|
75
|
+
[`${pc.dim(labels.failed.padEnd(maxLabelLength))} ${meta.pluginsFailed || "none"}`, !!meta.pluginsFailed],
|
|
76
|
+
[`${pc.bold(labels.generated.padEnd(maxLabelLength))} ${meta.filesCreated} files in ${meta.time}`, true]
|
|
77
|
+
];
|
|
78
|
+
if (pluginTimings && pluginTimings.size > 0) {
|
|
79
|
+
const MAX_TOP_PLUGINS = 5;
|
|
80
|
+
const TIME_SCALE_DIVISOR = 100;
|
|
81
|
+
const MAX_BAR_LENGTH = 20;
|
|
82
|
+
const sortedTimings = Array.from(pluginTimings.entries()).sort((a, b) => b[1] - a[1]).slice(0, MAX_TOP_PLUGINS);
|
|
83
|
+
if (sortedTimings.length > 0) {
|
|
84
|
+
summaryLines.push(["Plugin Timings:", true]);
|
|
85
|
+
const maxNameLength = Math.max(...sortedTimings.map(([name]) => name.length));
|
|
86
|
+
const indent = " ".repeat(maxLabelLength + 1);
|
|
87
|
+
sortedTimings.forEach(([name, time]) => {
|
|
88
|
+
const timeStr = time >= 1e3 ? `${(time / 1e3).toFixed(2)}s` : `${Math.round(time)}ms`;
|
|
89
|
+
const barLength = Math.min(Math.ceil(time / TIME_SCALE_DIVISOR), MAX_BAR_LENGTH);
|
|
90
|
+
const bar = "█".repeat(barLength);
|
|
91
|
+
const paddedName = name.padStart(maxNameLength, " ");
|
|
92
|
+
summaryLines.push([`${indent}${randomCliColour(paddedName)} ${pc.dim(bar)} ${pc.yellow(timeStr)}`, true]);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
summaryLines.push([`${pc.bold(labels.output.padEnd(maxLabelLength))} ${meta.output}`, true]);
|
|
97
|
+
logs.add(summaryLines.map((item) => {
|
|
86
98
|
if (item.at(1)) return item.at(0);
|
|
87
99
|
}).filter(Boolean).join("\n"));
|
|
88
100
|
return [...logs];
|
|
@@ -148,50 +160,35 @@ async function generate({ input, config, progressCache, args }) {
|
|
|
148
160
|
logger
|
|
149
161
|
});
|
|
150
162
|
logger.emit("start", `Building ${logger.logLevel !== LogMapper.silent ? pc.dim(inputPath) : ""}`);
|
|
151
|
-
const { files, failedPlugins, error } = await safeBuild({
|
|
163
|
+
const { files, failedPlugins, pluginTimings, error } = await safeBuild({
|
|
152
164
|
config: definedConfig,
|
|
153
165
|
logger
|
|
154
166
|
}, {
|
|
155
167
|
pluginManager,
|
|
156
|
-
fabric
|
|
168
|
+
fabric,
|
|
169
|
+
logger
|
|
157
170
|
});
|
|
158
|
-
if (logger.logLevel
|
|
171
|
+
if (logger.logLevel >= LogMapper.debug) {
|
|
159
172
|
logger.consola?.start("Writing logs");
|
|
160
|
-
|
|
161
|
-
logger.consola?.success(
|
|
173
|
+
await logger.writeLogs();
|
|
174
|
+
logger.consola?.success("Written logs");
|
|
162
175
|
}
|
|
163
176
|
const summary = getSummary({
|
|
164
177
|
failedPlugins,
|
|
165
178
|
filesCreated: files.length,
|
|
166
179
|
config: definedConfig,
|
|
167
180
|
status: failedPlugins.size > 0 || error ? "failed" : "success",
|
|
168
|
-
hrStart
|
|
181
|
+
hrStart,
|
|
182
|
+
pluginTimings: logger.logLevel >= LogMapper.verbose ? pluginTimings : void 0
|
|
169
183
|
});
|
|
170
|
-
if (failedPlugins.size && logger.consola) {
|
|
184
|
+
if ((failedPlugins.size > 0 || error) && logger.consola) {
|
|
171
185
|
logger.consola?.resumeLogs();
|
|
172
|
-
logger.consola
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
message: summary.join(""),
|
|
176
|
-
style: {
|
|
177
|
-
padding: 2,
|
|
178
|
-
borderColor: "red",
|
|
179
|
-
borderStyle: "rounded"
|
|
180
|
-
}
|
|
181
|
-
});
|
|
182
|
-
const errors = getErrorCauses([...failedPlugins].filter((it) => it.error).map((it) => it.error));
|
|
183
|
-
if (logger.consola && errors.length && logger.logLevel === LogMapper.debug) errors.forEach((err) => {
|
|
186
|
+
logger.consola?.log(`✗ Build failed ${logger.logLevel !== LogMapper.silent ? pc.dim(inputPath) : ""}`);
|
|
187
|
+
[error, ...Array.from(failedPlugins).filter((it) => it.error).map((it) => it.error)].filter(Boolean).forEach((err) => {
|
|
188
|
+
if (logger.logLevel >= LogMapper.debug && err.cause) logger.consola?.error(err.cause);
|
|
184
189
|
logger.consola?.error(err);
|
|
185
190
|
});
|
|
186
|
-
|
|
187
|
-
logger.consola?.error(it.error);
|
|
188
|
-
});
|
|
189
|
-
process$1.exit(1);
|
|
190
|
-
}
|
|
191
|
-
if (error && logger.consola) {
|
|
192
|
-
logger.consola?.resumeLogs();
|
|
193
|
-
logger.consola.error(`Build failed ${logger.logLevel !== LogMapper.silent ? pc.dim(inputPath) : ""}`);
|
|
194
|
-
logger.consola.box({
|
|
191
|
+
logger.consola?.box({
|
|
195
192
|
title: `${config.name || ""}`,
|
|
196
193
|
message: summary.join(""),
|
|
197
194
|
style: {
|
|
@@ -200,72 +197,127 @@ async function generate({ input, config, progressCache, args }) {
|
|
|
200
197
|
borderStyle: "rounded"
|
|
201
198
|
}
|
|
202
199
|
});
|
|
203
|
-
const errors = getErrorCauses([error]);
|
|
204
|
-
if (logger.consola && errors.length && logger.logLevel === LogMapper.debug) errors.forEach((err) => {
|
|
205
|
-
logger.consola?.error(err);
|
|
206
|
-
});
|
|
207
|
-
logger.consola?.error(error);
|
|
208
200
|
process$1.exit(1);
|
|
209
201
|
}
|
|
210
202
|
if (config.output.format === "prettier") {
|
|
211
203
|
logger?.emit("start", `Formatting with ${config.output.format}`);
|
|
204
|
+
logger?.emit("debug", {
|
|
205
|
+
date: /* @__PURE__ */ new Date(),
|
|
206
|
+
logs: [`Running prettier on ${path.resolve(definedConfig.root, definedConfig.output.path)}`]
|
|
207
|
+
});
|
|
212
208
|
try {
|
|
213
209
|
await execa("prettier", [
|
|
214
210
|
"--ignore-unknown",
|
|
215
211
|
"--write",
|
|
216
212
|
path.resolve(definedConfig.root, definedConfig.output.path)
|
|
217
213
|
]);
|
|
214
|
+
logger?.emit("debug", {
|
|
215
|
+
date: /* @__PURE__ */ new Date(),
|
|
216
|
+
logs: ["Prettier formatting completed successfully"]
|
|
217
|
+
});
|
|
218
218
|
} catch (e) {
|
|
219
219
|
logger.consola?.warn("Prettier not found");
|
|
220
220
|
logger.consola?.error(e);
|
|
221
|
+
logger?.emit("debug", {
|
|
222
|
+
date: /* @__PURE__ */ new Date(),
|
|
223
|
+
logs: [`Prettier formatting failed: ${e.message}`]
|
|
224
|
+
});
|
|
221
225
|
}
|
|
222
226
|
logger?.emit("success", `Formatted with ${config.output.format}`);
|
|
223
227
|
}
|
|
224
228
|
if (config.output.format === "biome") {
|
|
225
229
|
logger?.emit("start", `Formatting with ${config.output.format}`);
|
|
230
|
+
logger?.emit("debug", {
|
|
231
|
+
date: /* @__PURE__ */ new Date(),
|
|
232
|
+
logs: [`Running biome format on ${path.resolve(definedConfig.root, definedConfig.output.path)}`]
|
|
233
|
+
});
|
|
226
234
|
try {
|
|
227
235
|
await execa("biome", [
|
|
228
236
|
"format",
|
|
229
237
|
"--write",
|
|
230
238
|
path.resolve(definedConfig.root, definedConfig.output.path)
|
|
231
239
|
]);
|
|
240
|
+
logger?.emit("debug", {
|
|
241
|
+
date: /* @__PURE__ */ new Date(),
|
|
242
|
+
logs: ["Biome formatting completed successfully"]
|
|
243
|
+
});
|
|
232
244
|
} catch (e) {
|
|
233
245
|
logger.consola?.warn("Biome not found");
|
|
234
246
|
logger.consola?.error(e);
|
|
247
|
+
logger?.emit("debug", {
|
|
248
|
+
date: /* @__PURE__ */ new Date(),
|
|
249
|
+
logs: [`Biome formatting failed: ${e.message}`]
|
|
250
|
+
});
|
|
235
251
|
}
|
|
236
252
|
logger?.emit("success", `Formatted with ${config.output.format}`);
|
|
237
253
|
}
|
|
238
254
|
if (config.output.lint === "eslint") {
|
|
239
255
|
logger?.emit("start", `Linting with ${config.output.lint}`);
|
|
256
|
+
logger?.emit("debug", {
|
|
257
|
+
date: /* @__PURE__ */ new Date(),
|
|
258
|
+
logs: [`Running eslint on ${path.resolve(definedConfig.root, definedConfig.output.path)}`]
|
|
259
|
+
});
|
|
240
260
|
try {
|
|
241
261
|
await execa("eslint", [path.resolve(definedConfig.root, definedConfig.output.path), "--fix"]);
|
|
262
|
+
logger?.emit("debug", {
|
|
263
|
+
date: /* @__PURE__ */ new Date(),
|
|
264
|
+
logs: ["ESLint linting completed successfully"]
|
|
265
|
+
});
|
|
242
266
|
} catch (e) {
|
|
243
267
|
logger.consola?.warn("Eslint not found");
|
|
244
268
|
logger.consola?.error(e);
|
|
269
|
+
logger?.emit("debug", {
|
|
270
|
+
date: /* @__PURE__ */ new Date(),
|
|
271
|
+
logs: [`ESLint linting failed: ${e.message}`]
|
|
272
|
+
});
|
|
245
273
|
}
|
|
246
274
|
logger?.emit("success", `Linted with ${config.output.lint}`);
|
|
247
275
|
}
|
|
248
276
|
if (config.output.lint === "biome") {
|
|
249
277
|
logger?.emit("start", `Linting with ${config.output.lint}`);
|
|
278
|
+
logger?.emit("debug", {
|
|
279
|
+
date: /* @__PURE__ */ new Date(),
|
|
280
|
+
logs: [`Running biome lint on ${path.resolve(definedConfig.root, definedConfig.output.path)}`]
|
|
281
|
+
});
|
|
250
282
|
try {
|
|
251
283
|
await execa("biome", [
|
|
252
284
|
"lint",
|
|
253
285
|
"--fix",
|
|
254
286
|
path.resolve(definedConfig.root, definedConfig.output.path)
|
|
255
287
|
]);
|
|
288
|
+
logger?.emit("debug", {
|
|
289
|
+
date: /* @__PURE__ */ new Date(),
|
|
290
|
+
logs: ["Biome linting completed successfully"]
|
|
291
|
+
});
|
|
256
292
|
} catch (e) {
|
|
257
293
|
logger.consola?.warn("Biome not found");
|
|
258
294
|
logger.consola?.error(e);
|
|
295
|
+
logger?.emit("debug", {
|
|
296
|
+
date: /* @__PURE__ */ new Date(),
|
|
297
|
+
logs: [`✗ Biome linting failed: ${e.message}`]
|
|
298
|
+
});
|
|
259
299
|
}
|
|
260
300
|
logger?.emit("success", `Linted with ${config.output.lint}`);
|
|
261
301
|
}
|
|
262
302
|
if (config.output.lint === "oxlint") {
|
|
263
303
|
logger?.emit("start", `Linting with ${config.output.lint}`);
|
|
304
|
+
logger?.emit("debug", {
|
|
305
|
+
date: /* @__PURE__ */ new Date(),
|
|
306
|
+
logs: [`Running oxlint on ${path.resolve(definedConfig.root, definedConfig.output.path)}`]
|
|
307
|
+
});
|
|
264
308
|
try {
|
|
265
309
|
await execa("oxlint", ["--fix", path.resolve(definedConfig.root, definedConfig.output.path)]);
|
|
310
|
+
logger?.emit("debug", {
|
|
311
|
+
date: /* @__PURE__ */ new Date(),
|
|
312
|
+
logs: ["Oxlint linting completed successfully"]
|
|
313
|
+
});
|
|
266
314
|
} catch (e) {
|
|
267
315
|
logger.consola?.warn("Oxlint not found");
|
|
268
316
|
logger.consola?.error(e);
|
|
317
|
+
logger?.emit("debug", {
|
|
318
|
+
date: /* @__PURE__ */ new Date(),
|
|
319
|
+
logs: [`✗ Oxlint linting failed: ${e.message}`]
|
|
320
|
+
});
|
|
269
321
|
}
|
|
270
322
|
logger?.emit("success", `Linted with ${config.output.lint}`);
|
|
271
323
|
}
|
|
@@ -273,7 +325,7 @@ async function generate({ input, config, progressCache, args }) {
|
|
|
273
325
|
hooks: config.hooks,
|
|
274
326
|
logger
|
|
275
327
|
});
|
|
276
|
-
logger.consola?.log(`⚡Build completed ${logger.logLevel !== LogMapper.silent ? pc.dim(inputPath) : ""}`);
|
|
328
|
+
logger.consola?.log(`⚡ Build completed ${logger.logLevel !== LogMapper.silent ? pc.dim(inputPath) : ""}`);
|
|
277
329
|
logger.consola?.box({
|
|
278
330
|
title: `${config.name || ""}`,
|
|
279
331
|
message: summary.join(""),
|
|
@@ -287,4 +339,4 @@ async function generate({ input, config, progressCache, args }) {
|
|
|
287
339
|
|
|
288
340
|
//#endregion
|
|
289
341
|
export { generate };
|
|
290
|
-
//# sourceMappingURL=generate-
|
|
342
|
+
//# sourceMappingURL=generate-CpBJ2Y-n.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-CpBJ2Y-n.js","names":["summaryLines: Array<[string, boolean]>","process","definedConfig: Config"],"sources":["../src/utils/Writables.ts","../src/utils/executeHooks.ts","../src/utils/parseHrtimeToSeconds.ts","../src/utils/getSummary.ts","../src/runners/generate.ts"],"sourcesContent":["import * as process from 'node:process'\nimport type { WritableOptions } from 'node:stream'\nimport { Writable } from 'node:stream'\nimport type { ConsolaInstance } from 'consola'\nimport pc from 'picocolors'\n\nexport class ConsolaWritable extends Writable {\n consola: ConsolaInstance | undefined\n command: string\n constructor(consola: ConsolaInstance | undefined, command: string, opts?: WritableOptions) {\n super(opts)\n\n this.command = command\n this.consola = consola\n }\n _write(chunk: any, _encoding: BufferEncoding, callback: (error?: Error | null) => void): void {\n process.stdout.write(`${pc.dim(chunk?.toString())}`)\n\n callback()\n }\n}\n","import type { Config } from '@kubb/core'\nimport type { Logger } from '@kubb/core/logger'\nimport { LogMapper } from '@kubb/core/logger'\nimport { execa } from 'execa'\nimport pc from 'picocolors'\nimport { parseArgsStringToArgv } from 'string-argv'\nimport { ConsolaWritable } from './Writables.ts'\n\ntype ExecutingHooksProps = {\n hooks: NonNullable<Config['hooks']>\n logger: Logger\n}\n\nexport async function executeHooks({ hooks, logger }: ExecutingHooksProps): Promise<void> {\n const commands = Array.isArray(hooks.done) ? hooks.done : [hooks.done].filter(Boolean)\n\n for (const command of commands) {\n const consolaWritable = new ConsolaWritable(logger.consola!, command)\n const [cmd, ..._args] = [...parseArgsStringToArgv(command)]\n\n if (!cmd) {\n continue\n }\n\n logger?.emit('start', `Executing hook ${logger.logLevel !== LogMapper.silent ? pc.dim(command) : ''}`)\n\n await execa(cmd, _args, {\n detached: true,\n stdout: logger?.logLevel === LogMapper.silent ? undefined : ['pipe', consolaWritable],\n stripFinalNewline: true,\n })\n\n logger?.emit('success', `Executed hook ${logger.logLevel !== LogMapper.silent ? pc.dim(command) : ''}`)\n }\n\n logger?.emit('success', 'Executed hooks')\n}\n","export function parseHrtimeToSeconds(hrtime: [number, number]): string {\n const seconds = (hrtime[0] + hrtime[1] / 1e9).toFixed(3)\n return seconds\n}\n","import path from 'node:path'\nimport type { Config, Plugin } from '@kubb/core'\nimport { randomCliColour } from '@kubb/core/logger'\nimport pc from 'picocolors'\nimport { parseHrtimeToSeconds } from './parseHrtimeToSeconds.ts'\n\ntype SummaryProps = {\n failedPlugins: Set<{ plugin: Plugin; error: Error }>\n status: 'success' | 'failed'\n hrStart: [number, number]\n filesCreated: number\n config: Config\n pluginTimings?: Map<string, number>\n}\n\nexport function getSummary({ failedPlugins, filesCreated, status, hrStart, config, pluginTimings }: SummaryProps): string[] {\n const logs = new Set<string>()\n const elapsedSeconds = parseHrtimeToSeconds(process.hrtime(hrStart))\n\n const pluginsCount = config.plugins?.length || 0\n const successCount = pluginsCount - failedPlugins.size\n\n const meta = {\n plugins:\n status === 'success'\n ? `${pc.green(`${successCount} successful`)}, ${pluginsCount} total`\n : `${pc.green(`${successCount} successful`)}, ${pc.red(`${failedPlugins.size} failed`)}, ${pluginsCount} total`,\n pluginsFailed: status === 'failed' ? [...failedPlugins]?.map(({ plugin }) => randomCliColour(plugin.name))?.join(', ') : undefined,\n filesCreated: filesCreated,\n time: `${pc.yellow(`${elapsedSeconds}s`)}`,\n output: path.isAbsolute(config.root) ? path.resolve(config.root, config.output.path) : config.root,\n } as const\n\n // Calculate label padding for perfect alignment\n const labels = {\n plugins: 'Plugins:',\n failed: 'Failed:',\n generated: 'Generated:',\n output: 'Output:',\n }\n const maxLabelLength = Math.max(...Object.values(labels).map((l) => l.length))\n\n const summaryLines: Array<[string, boolean]> = [\n [`${pc.bold(labels.plugins.padEnd(maxLabelLength))} ${meta.plugins}`, true],\n [`${pc.dim(labels.failed.padEnd(maxLabelLength))} ${meta.pluginsFailed || 'none'}`, !!meta.pluginsFailed],\n [`${pc.bold(labels.generated.padEnd(maxLabelLength))} ${meta.filesCreated} files in ${meta.time}`, true],\n ]\n\n // Add plugin timing breakdown if available\n if (pluginTimings && pluginTimings.size > 0) {\n const MAX_TOP_PLUGINS = 5\n const TIME_SCALE_DIVISOR = 100 // Each 100ms = 1 bar character\n const MAX_BAR_LENGTH = 20\n\n const sortedTimings = Array.from(pluginTimings.entries())\n .sort((a, b) => b[1] - a[1])\n .slice(0, MAX_TOP_PLUGINS)\n\n if (sortedTimings.length > 0) {\n summaryLines.push(['Plugin Timings:', true])\n\n // Find the longest plugin name for alignment\n const maxNameLength = Math.max(...sortedTimings.map(([name]) => name.length))\n\n // Indent plugin timing bars to align with summary values (e.g., \"7 successful\", \"60 files\")\n const indent = ' '.repeat(maxLabelLength + 1)\n\n sortedTimings.forEach(([name, time]) => {\n const timeStr = time >= 1000 ? `${(time / 1000).toFixed(2)}s` : `${Math.round(time)}ms`\n const barLength = Math.min(Math.ceil(time / TIME_SCALE_DIVISOR), MAX_BAR_LENGTH)\n const bar = '█'.repeat(barLength)\n\n // Right-align plugin names, left-align bars, with consistent spacing\n const paddedName = name.padStart(maxNameLength, ' ')\n summaryLines.push([`${indent}${randomCliColour(paddedName)} ${pc.dim(bar)} ${pc.yellow(timeStr)}`, true])\n })\n }\n }\n\n summaryLines.push([`${pc.bold(labels.output.padEnd(maxLabelLength))} ${meta.output}`, true])\n\n logs.add(\n summaryLines\n .map((item) => {\n if (item.at(1)) {\n return item.at(0)\n }\n return undefined\n })\n .filter(Boolean)\n .join('\\n'),\n )\n\n return [...logs]\n}\n","import path from 'node:path'\nimport process from 'node:process'\nimport { type Config, safeBuild, setup } from '@kubb/core'\nimport { createLogger, LogMapper } from '@kubb/core/logger'\nimport { Presets, SingleBar } from 'cli-progress'\nimport { execa } from 'execa'\nimport pc from 'picocolors'\nimport type { Args } from '../commands/generate.ts'\nimport { executeHooks } from '../utils/executeHooks.ts'\nimport { getSummary } from '../utils/getSummary.ts'\n\ntype GenerateProps = {\n input?: string\n config: Config\n args: Args\n progressCache: Map<string, SingleBar>\n}\n\nexport async function generate({ input, config, progressCache, args }: GenerateProps): Promise<void> {\n const hrStart = process.hrtime()\n const logLevel = LogMapper[args.logLevel as keyof typeof LogMapper] || 3\n\n const logger = createLogger({\n logLevel,\n name: config.name,\n })\n\n const { root = process.cwd(), ...userConfig } = config\n const inputPath = input ?? ('path' in userConfig.input ? userConfig.input.path : undefined)\n\n if (logger.logLevel !== LogMapper.debug) {\n logger.on('progress_start', ({ id, size, message = '' }) => {\n logger.consola?.pauseLogs()\n const payload = { id, message }\n const progressBar = new SingleBar(\n {\n format: '{percentage}% {bar} {value}/{total} | {message}',\n barsize: 30,\n clearOnComplete: true,\n emptyOnZero: true,\n },\n Presets.shades_grey,\n )\n\n if (!progressCache.has(id)) {\n progressCache.set(id, progressBar)\n progressBar.start(size, 1, payload)\n }\n })\n\n logger.on('progress_stop', ({ id }) => {\n progressCache.get(id)?.stop()\n logger.consola?.resumeLogs()\n })\n\n logger.on('progressed', ({ id, message = '' }) => {\n const payload = { id, message }\n\n progressCache.get(id)?.increment(1, payload)\n })\n }\n\n const definedConfig: Config = {\n root,\n ...userConfig,\n input: inputPath\n ? {\n ...userConfig.input,\n path: inputPath,\n }\n : userConfig.input,\n output: {\n write: true,\n barrelType: 'named',\n extension: {\n '.ts': '.ts',\n },\n format: 'prettier',\n ...userConfig.output,\n },\n }\n\n const { fabric, pluginManager } = await setup({\n config: definedConfig,\n logger,\n })\n\n logger.emit('start', `Building ${logger.logLevel !== LogMapper.silent ? pc.dim(inputPath!) : ''}`)\n\n const { files, failedPlugins, pluginTimings, error } = await safeBuild(\n {\n config: definedConfig,\n logger,\n },\n { pluginManager, fabric, logger },\n )\n\n if (logger.logLevel >= LogMapper.debug) {\n logger.consola?.start('Writing logs')\n\n await logger.writeLogs()\n\n logger.consola?.success('Written logs')\n }\n\n const summary = getSummary({\n failedPlugins,\n filesCreated: files.length,\n config: definedConfig,\n status: failedPlugins.size > 0 || error ? 'failed' : 'success',\n hrStart,\n pluginTimings: logger.logLevel >= LogMapper.verbose ? pluginTimings : undefined,\n })\n\n // Handle build failures (either from failed plugins or general errors)\n const hasFailures = failedPlugins.size > 0 || error\n\n if (hasFailures && logger.consola) {\n logger.consola?.resumeLogs()\n logger.consola?.log(`✗ Build failed ${logger.logLevel !== LogMapper.silent ? pc.dim(inputPath!) : ''}`)\n\n // Collect all errors from failed plugins and general error\n const allErrors: Error[] = [\n error,\n ...Array.from(failedPlugins)\n .filter((it) => it.error)\n .map((it) => it.error),\n ].filter(Boolean)\n\n allErrors.forEach((err) => {\n // Display error causes in debug mode\n if (logger.logLevel >= LogMapper.debug && err.cause) {\n logger.consola?.error(err.cause)\n }\n\n logger.consola?.error(err)\n })\n\n logger.consola?.box({\n title: `${config.name || ''}`,\n message: summary.join(''),\n style: {\n padding: 2,\n borderColor: 'red',\n borderStyle: 'rounded',\n },\n })\n\n process.exit(1)\n }\n\n // formatting\n if (config.output.format === 'prettier') {\n logger?.emit('start', `Formatting with ${config.output.format}`)\n logger?.emit('debug', {\n date: new Date(),\n logs: [`Running prettier on ${path.resolve(definedConfig.root, definedConfig.output.path)}`],\n })\n\n try {\n await execa('prettier', ['--ignore-unknown', '--write', path.resolve(definedConfig.root, definedConfig.output.path)])\n logger?.emit('debug', {\n date: new Date(),\n logs: ['Prettier formatting completed successfully'],\n })\n } catch (e) {\n logger.consola?.warn('Prettier not found')\n logger.consola?.error(e)\n logger?.emit('debug', {\n date: new Date(),\n logs: [`Prettier formatting failed: ${(e as Error).message}`],\n })\n }\n\n logger?.emit('success', `Formatted with ${config.output.format}`)\n }\n\n if (config.output.format === 'biome') {\n logger?.emit('start', `Formatting with ${config.output.format}`)\n logger?.emit('debug', {\n date: new Date(),\n logs: [`Running biome format on ${path.resolve(definedConfig.root, definedConfig.output.path)}`],\n })\n\n try {\n await execa('biome', ['format', '--write', path.resolve(definedConfig.root, definedConfig.output.path)])\n logger?.emit('debug', {\n date: new Date(),\n logs: ['Biome formatting completed successfully'],\n })\n } catch (e) {\n logger.consola?.warn('Biome not found')\n logger.consola?.error(e)\n logger?.emit('debug', {\n date: new Date(),\n logs: [`Biome formatting failed: ${(e as Error).message}`],\n })\n }\n\n logger?.emit('success', `Formatted with ${config.output.format}`)\n }\n\n // linting\n if (config.output.lint === 'eslint') {\n logger?.emit('start', `Linting with ${config.output.lint}`)\n logger?.emit('debug', {\n date: new Date(),\n logs: [`Running eslint on ${path.resolve(definedConfig.root, definedConfig.output.path)}`],\n })\n\n try {\n await execa('eslint', [path.resolve(definedConfig.root, definedConfig.output.path), '--fix'])\n logger?.emit('debug', {\n date: new Date(),\n logs: ['ESLint linting completed successfully'],\n })\n } catch (e) {\n logger.consola?.warn('Eslint not found')\n logger.consola?.error(e)\n logger?.emit('debug', {\n date: new Date(),\n logs: [`ESLint linting failed: ${(e as Error).message}`],\n })\n }\n\n logger?.emit('success', `Linted with ${config.output.lint}`)\n }\n\n if (config.output.lint === 'biome') {\n logger?.emit('start', `Linting with ${config.output.lint}`)\n logger?.emit('debug', {\n date: new Date(),\n logs: [`Running biome lint on ${path.resolve(definedConfig.root, definedConfig.output.path)}`],\n })\n\n try {\n await execa('biome', ['lint', '--fix', path.resolve(definedConfig.root, definedConfig.output.path)])\n logger?.emit('debug', {\n date: new Date(),\n logs: ['Biome linting completed successfully'],\n })\n } catch (e) {\n logger.consola?.warn('Biome not found')\n logger.consola?.error(e)\n logger?.emit('debug', {\n date: new Date(),\n logs: [`✗ Biome linting failed: ${(e as Error).message}`],\n })\n }\n\n logger?.emit('success', `Linted with ${config.output.lint}`)\n }\n\n if (config.output.lint === 'oxlint') {\n logger?.emit('start', `Linting with ${config.output.lint}`)\n logger?.emit('debug', {\n date: new Date(),\n logs: [`Running oxlint on ${path.resolve(definedConfig.root, definedConfig.output.path)}`],\n })\n\n try {\n await execa('oxlint', ['--fix', path.resolve(definedConfig.root, definedConfig.output.path)])\n logger?.emit('debug', {\n date: new Date(),\n logs: ['Oxlint linting completed successfully'],\n })\n } catch (e) {\n logger.consola?.warn('Oxlint not found')\n logger.consola?.error(e)\n logger?.emit('debug', {\n date: new Date(),\n logs: [`✗ Oxlint linting failed: ${(e as Error).message}`],\n })\n }\n\n logger?.emit('success', `Linted with ${config.output.lint}`)\n }\n\n if (config.hooks) {\n await executeHooks({ hooks: config.hooks, logger })\n }\n\n logger.consola?.log(`⚡ Build completed ${logger.logLevel !== LogMapper.silent ? pc.dim(inputPath!) : ''}`)\n logger.consola?.box({\n title: `${config.name || ''}`,\n message: summary.join(''),\n style: {\n padding: 2,\n borderColor: 'green',\n borderStyle: 'rounded',\n },\n })\n}\n"],"mappings":";;;;;;;;;;;;AAMA,IAAa,kBAAb,cAAqC,SAAS;CAC5C;CACA;CACA,YAAY,SAAsC,SAAiB,MAAwB;AACzF,QAAM,KAAK;AAEX,OAAK,UAAU;AACf,OAAK,UAAU;;CAEjB,OAAO,OAAY,WAA2B,UAAgD;AAC5F,YAAQ,OAAO,MAAM,GAAG,GAAG,IAAI,OAAO,UAAU,CAAC,GAAG;AAEpD,YAAU;;;;;;ACLd,eAAsB,aAAa,EAAE,OAAO,UAA8C;CACxF,MAAM,WAAW,MAAM,QAAQ,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,MAAM,KAAK,CAAC,OAAO,QAAQ;AAEtF,MAAK,MAAM,WAAW,UAAU;EAC9B,MAAM,kBAAkB,IAAI,gBAAgB,OAAO,SAAU,QAAQ;EACrE,MAAM,CAAC,KAAK,GAAG,SAAS,CAAC,GAAG,sBAAsB,QAAQ,CAAC;AAE3D,MAAI,CAAC,IACH;AAGF,UAAQ,KAAK,SAAS,kBAAkB,OAAO,aAAa,UAAU,SAAS,GAAG,IAAI,QAAQ,GAAG,KAAK;AAEtG,QAAM,MAAM,KAAK,OAAO;GACtB,UAAU;GACV,QAAQ,QAAQ,aAAa,UAAU,SAAS,SAAY,CAAC,QAAQ,gBAAgB;GACrF,mBAAmB;GACpB,CAAC;AAEF,UAAQ,KAAK,WAAW,iBAAiB,OAAO,aAAa,UAAU,SAAS,GAAG,IAAI,QAAQ,GAAG,KAAK;;AAGzG,SAAQ,KAAK,WAAW,iBAAiB;;;;;ACnC3C,SAAgB,qBAAqB,QAAkC;AAErE,SADiB,OAAO,KAAK,OAAO,KAAK,KAAK,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