@kubb/cli 4.22.3 → 4.24.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/agent-Buz_5Op4.cjs +22 -0
- package/dist/agent-Buz_5Op4.cjs.map +1 -0
- package/dist/agent-C9MWOHKX.js +22 -0
- package/dist/agent-C9MWOHKX.js.map +1 -0
- package/dist/{chunk-jHaXqnEa.js → chunk-EyRqdYP6.js} +4 -1
- package/dist/{generate-pe0DCVnp.cjs → generate-BYLZgOxz.cjs} +440 -13
- package/dist/generate-BYLZgOxz.cjs.map +1 -0
- package/dist/{generate-DmkY-UC3.js → generate-DoM5hz_l.js} +435 -8
- package/dist/generate-DoM5hz_l.js.map +1 -0
- package/dist/index.cjs +8 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +10 -10
- package/dist/index.js.map +1 -1
- package/dist/{init-UKOqSOvQ.js → init-CGHonZd1.js} +4 -4
- package/dist/{init-UKOqSOvQ.js.map → init-CGHonZd1.js.map} +1 -1
- package/dist/{init-CK9rTBuD.cjs → init-CIr2otlG.cjs} +3 -3
- package/dist/{init-CK9rTBuD.cjs.map → init-CIr2otlG.cjs.map} +1 -1
- package/dist/{mcp-BdwwUv36.js → mcp-85caBdzd.js} +2 -2
- package/dist/{mcp-BdwwUv36.js.map → mcp-85caBdzd.js.map} +1 -1
- package/dist/{mcp-Hy_PYnFp.cjs → mcp-DGyip5BX.cjs} +1 -1
- package/dist/{mcp-Hy_PYnFp.cjs.map → mcp-DGyip5BX.cjs.map} +1 -1
- package/dist/package-DbleONiT.js +6 -0
- package/dist/package-DbleONiT.js.map +1 -0
- package/dist/{package-C1c2K_S0.cjs → package-JlnkYQn6.cjs} +2 -2
- package/dist/package-JlnkYQn6.cjs.map +1 -0
- package/dist/start-DdvHHe8S.js +76 -0
- package/dist/start-DdvHHe8S.js.map +1 -0
- package/dist/start-Vf8kCm8g.cjs +80 -0
- package/dist/start-Vf8kCm8g.cjs.map +1 -0
- package/dist/{validate-YI4YkVTl.js → validate-DaGKH-63.js} +2 -2
- package/dist/{validate-YI4YkVTl.js.map → validate-DaGKH-63.js.map} +1 -1
- package/package.json +6 -5
- package/src/commands/agent/start.ts +85 -0
- package/src/commands/agent.ts +27 -0
- package/src/index.ts +2 -2
- package/dist/generate-DmkY-UC3.js.map +0 -1
- package/dist/generate-pe0DCVnp.cjs.map +0 -1
- package/dist/getCosmiConfig-Co29x0Wv.cjs +0 -458
- package/dist/getCosmiConfig-Co29x0Wv.cjs.map +0 -1
- package/dist/getCosmiConfig-y2n_oW_y.js +0 -438
- package/dist/getCosmiConfig-y2n_oW_y.js.map +0 -1
- package/dist/package-C1c2K_S0.cjs.map +0 -1
- package/dist/package-_aADOcaI.js +0 -6
- package/dist/package-_aADOcaI.js.map +0 -1
- package/dist/start-CiV9kRep.js +0 -125
- package/dist/start-CiV9kRep.js.map +0 -1
- package/dist/start-DUh4jdqh.cjs +0 -128
- package/dist/start-DUh4jdqh.cjs.map +0 -1
- package/src/commands/start.ts +0 -149
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-C1_xRkKa.cjs');
|
|
2
|
+
let citty = require("citty");
|
|
3
|
+
|
|
4
|
+
//#region src/commands/agent.ts
|
|
5
|
+
const command = (0, citty.defineCommand)({
|
|
6
|
+
args: { help: {
|
|
7
|
+
type: "boolean",
|
|
8
|
+
description: "Show help",
|
|
9
|
+
alias: "h",
|
|
10
|
+
default: false
|
|
11
|
+
} },
|
|
12
|
+
subCommands: { start: () => Promise.resolve().then(() => require("./start-Vf8kCm8g.cjs")).then((m) => m.default) },
|
|
13
|
+
async run(commandContext) {
|
|
14
|
+
const { args } = commandContext;
|
|
15
|
+
if (args.help) return (0, citty.showUsage)(command);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
var agent_default = command;
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
exports.default = agent_default;
|
|
22
|
+
//# sourceMappingURL=agent-Buz_5Op4.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-Buz_5Op4.cjs","names":[],"sources":["../src/commands/agent.ts"],"sourcesContent":["import type { ArgsDef } from 'citty'\nimport { defineCommand, showUsage } from 'citty'\n\nconst args = {\n help: {\n type: 'boolean',\n description: 'Show help',\n alias: 'h',\n default: false,\n },\n} as const satisfies ArgsDef\n\nconst command = defineCommand({\n args,\n subCommands: {\n start: () => import('./agent/start.ts').then((m) => m.default),\n },\n async run(commandContext) {\n const { args } = commandContext\n\n if (args.help) {\n return showUsage(command)\n }\n },\n})\n\nexport default command\n"],"mappings":";;;;AAYA,MAAM,mCAAwB;CAC5B,MAVW,EACX,MAAM;EACJ,MAAM;EACN,aAAa;EACb,OAAO;EACP,SAAS;EACV,EACF;CAIC,aAAa,EACX,kDAAa,yBAA2B,MAAM,MAAM,EAAE,QAAQ,EAC/D;CACD,MAAM,IAAI,gBAAgB;EACxB,MAAM,EAAE,SAAS;AAEjB,MAAI,KAAK,KACP,6BAAiB,QAAQ;;CAG9B,CAAC;AAEF,oBAAe"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { t as __name } from "./chunk-EyRqdYP6.js";
|
|
2
|
+
import { defineCommand, showUsage } from "citty";
|
|
3
|
+
|
|
4
|
+
//#region src/commands/agent.ts
|
|
5
|
+
const command = defineCommand({
|
|
6
|
+
args: { help: {
|
|
7
|
+
type: "boolean",
|
|
8
|
+
description: "Show help",
|
|
9
|
+
alias: "h",
|
|
10
|
+
default: false
|
|
11
|
+
} },
|
|
12
|
+
subCommands: { start: () => import("./start-DdvHHe8S.js").then((m) => m.default) },
|
|
13
|
+
async run(commandContext) {
|
|
14
|
+
const { args } = commandContext;
|
|
15
|
+
if (args.help) return showUsage(command);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
var agent_default = command;
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
export { agent_default as default };
|
|
22
|
+
//# sourceMappingURL=agent-C9MWOHKX.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-C9MWOHKX.js","names":[],"sources":["../src/commands/agent.ts"],"sourcesContent":["import type { ArgsDef } from 'citty'\nimport { defineCommand, showUsage } from 'citty'\n\nconst args = {\n help: {\n type: 'boolean',\n description: 'Show help',\n alias: 'h',\n default: false,\n },\n} as const satisfies ArgsDef\n\nconst command = defineCommand({\n args,\n subCommands: {\n start: () => import('./agent/start.ts').then((m) => m.default),\n },\n async run(commandContext) {\n const { args } = commandContext\n\n if (args.help) {\n return showUsage(command)\n }\n },\n})\n\nexport default command\n"],"mappings":";;;;AAYA,MAAM,UAAU,cAAc;CAC5B,MAVW,EACX,MAAM;EACJ,MAAM;EACN,aAAa;EACb,OAAO;EACP,SAAS;EACV,EACF;CAIC,aAAa,EACX,aAAa,OAAO,uBAAoB,MAAM,MAAM,EAAE,QAAQ,EAC/D;CACD,MAAM,IAAI,gBAAgB;EACxB,MAAM,EAAE,SAAS;AAEjB,MAAI,KAAK,KACP,QAAO,UAAU,QAAQ;;CAG9B,CAAC;AAEF,oBAAe"}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
|
|
1
3
|
//#region rolldown:runtime
|
|
2
4
|
var __defProp = Object.defineProperty;
|
|
3
5
|
var __name = (target, value) => __defProp(target, "name", {
|
|
4
6
|
value,
|
|
5
7
|
configurable: true
|
|
6
8
|
});
|
|
9
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
7
10
|
|
|
8
11
|
//#endregion
|
|
9
|
-
export { __name as t };
|
|
12
|
+
export { __require as n, __name as t };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-C1_xRkKa.cjs');
|
|
2
|
-
const require_package = require('./package-
|
|
3
|
-
const require_getCosmiConfig = require('./getCosmiConfig-Co29x0Wv.cjs');
|
|
2
|
+
const require_package = require('./package-JlnkYQn6.cjs');
|
|
4
3
|
let citty = require("citty");
|
|
5
4
|
let node_path = require("node:path");
|
|
6
5
|
node_path = require_chunk.__toESM(node_path);
|
|
@@ -8,20 +7,24 @@ let node_process = require("node:process");
|
|
|
8
7
|
node_process = require_chunk.__toESM(node_process);
|
|
9
8
|
let _clack_prompts = require("@clack/prompts");
|
|
10
9
|
_clack_prompts = require_chunk.__toESM(_clack_prompts);
|
|
10
|
+
let execa = require("execa");
|
|
11
|
+
let picocolors = require("picocolors");
|
|
12
|
+
picocolors = require_chunk.__toESM(picocolors);
|
|
11
13
|
let _kubb_core = require("@kubb/core");
|
|
12
14
|
let _kubb_core_utils = require("@kubb/core/utils");
|
|
13
15
|
let latest_version = require("latest-version");
|
|
14
16
|
latest_version = require_chunk.__toESM(latest_version);
|
|
15
|
-
let picocolors = require("picocolors");
|
|
16
|
-
picocolors = require_chunk.__toESM(picocolors);
|
|
17
17
|
let semver = require("semver");
|
|
18
|
-
let execa = require("execa");
|
|
19
18
|
let gradient_string = require("gradient-string");
|
|
20
19
|
gradient_string = require_chunk.__toESM(gradient_string);
|
|
21
20
|
let seedrandom = require("seedrandom");
|
|
22
21
|
seedrandom = require_chunk.__toESM(seedrandom);
|
|
23
22
|
let node_stream = require("node:stream");
|
|
24
23
|
let _kubb_core_fs = require("@kubb/core/fs");
|
|
24
|
+
let node_crypto = require("node:crypto");
|
|
25
|
+
let string_argv = require("string-argv");
|
|
26
|
+
let cosmiconfig = require("cosmiconfig");
|
|
27
|
+
let jiti = require("jiti");
|
|
25
28
|
|
|
26
29
|
//#region src/utils/formatMsWithColor.ts
|
|
27
30
|
/**
|
|
@@ -1148,17 +1151,441 @@ async function setupLogger(context, { logLevel }) {
|
|
|
1148
1151
|
return cleanup;
|
|
1149
1152
|
}
|
|
1150
1153
|
|
|
1154
|
+
//#endregion
|
|
1155
|
+
//#region src/utils/detectFormatter.ts
|
|
1156
|
+
/**
|
|
1157
|
+
* Check if a formatter command is available in the system.
|
|
1158
|
+
*
|
|
1159
|
+
* @param formatter - The formatter to check ('biome', 'prettier', or 'oxfmt')
|
|
1160
|
+
* @returns Promise that resolves to true if the formatter is available, false otherwise
|
|
1161
|
+
*
|
|
1162
|
+
* @remarks
|
|
1163
|
+
* This function checks availability by running `<formatter> --version` command.
|
|
1164
|
+
* All supported formatters (biome, prettier, oxfmt) implement the --version flag.
|
|
1165
|
+
*/
|
|
1166
|
+
async function isFormatterAvailable(formatter) {
|
|
1167
|
+
try {
|
|
1168
|
+
await (0, execa.execaCommand)(`${formatter} --version`, { stdio: "ignore" });
|
|
1169
|
+
return true;
|
|
1170
|
+
} catch {
|
|
1171
|
+
return false;
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
/**
|
|
1175
|
+
* Detect which formatter is available in the system.
|
|
1176
|
+
*
|
|
1177
|
+
* @returns Promise that resolves to the first available formatter or undefined if none are found
|
|
1178
|
+
*
|
|
1179
|
+
* @remarks
|
|
1180
|
+
* Checks in order of preference: biome, oxfmt, prettier.
|
|
1181
|
+
* Uses the `--version` flag to detect if each formatter command is available.
|
|
1182
|
+
* This is a reliable method as all supported formatters implement this flag.
|
|
1183
|
+
*
|
|
1184
|
+
* @example
|
|
1185
|
+
* ```typescript
|
|
1186
|
+
* const formatter = await detectFormatter()
|
|
1187
|
+
* if (formatter) {
|
|
1188
|
+
* console.log(`Using ${formatter} for formatting`)
|
|
1189
|
+
* } else {
|
|
1190
|
+
* console.log('No formatter found')
|
|
1191
|
+
* }
|
|
1192
|
+
* ```
|
|
1193
|
+
*/
|
|
1194
|
+
async function detectFormatter() {
|
|
1195
|
+
for (const formatter of [
|
|
1196
|
+
"biome",
|
|
1197
|
+
"oxfmt",
|
|
1198
|
+
"prettier"
|
|
1199
|
+
]) if (await isFormatterAvailable(formatter)) return formatter;
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
//#endregion
|
|
1203
|
+
//#region src/utils/detectLinter.ts
|
|
1204
|
+
/**
|
|
1205
|
+
* Check if a linter command is available in the system.
|
|
1206
|
+
*
|
|
1207
|
+
* @param linter - The linter to check ('biome', 'oxlint', or 'eslint')
|
|
1208
|
+
* @returns Promise that resolves to true if the linter is available, false otherwise
|
|
1209
|
+
*
|
|
1210
|
+
* @remarks
|
|
1211
|
+
* This function checks availability by running `<linter> --version` command.
|
|
1212
|
+
* All supported linters (biome, oxlint, eslint) implement the --version flag.
|
|
1213
|
+
*/
|
|
1214
|
+
async function isLinterAvailable(linter) {
|
|
1215
|
+
try {
|
|
1216
|
+
await (0, execa.execaCommand)(`${linter} --version`, { stdio: "ignore" });
|
|
1217
|
+
return true;
|
|
1218
|
+
} catch {
|
|
1219
|
+
return false;
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
/**
|
|
1223
|
+
* Detect which linter is available in the system.
|
|
1224
|
+
*
|
|
1225
|
+
* @returns Promise that resolves to the first available linter or undefined if none are found
|
|
1226
|
+
*
|
|
1227
|
+
* @remarks
|
|
1228
|
+
* Checks in order of preference: biome, oxlint, eslint.
|
|
1229
|
+
* Uses the `--version` flag to detect if each linter command is available.
|
|
1230
|
+
* This is a reliable method as all supported linters implement this flag.
|
|
1231
|
+
*
|
|
1232
|
+
* @example
|
|
1233
|
+
* ```typescript
|
|
1234
|
+
* const linter = await detectLinter()
|
|
1235
|
+
* if (linter) {
|
|
1236
|
+
* console.log(`Using ${linter} for linting`)
|
|
1237
|
+
* } else {
|
|
1238
|
+
* console.log('No linter found')
|
|
1239
|
+
* }
|
|
1240
|
+
* ```
|
|
1241
|
+
*/
|
|
1242
|
+
async function detectLinter() {
|
|
1243
|
+
for (const linter of [
|
|
1244
|
+
"biome",
|
|
1245
|
+
"oxlint",
|
|
1246
|
+
"eslint"
|
|
1247
|
+
]) if (await isLinterAvailable(linter)) return linter;
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
//#endregion
|
|
1251
|
+
//#region src/utils/executeHooks.ts
|
|
1252
|
+
async function executeHooks({ hooks, events }) {
|
|
1253
|
+
const commands = Array.isArray(hooks.done) ? hooks.done : [hooks.done].filter(Boolean);
|
|
1254
|
+
for (const command$1 of commands) {
|
|
1255
|
+
const [cmd, ...args] = [...(0, string_argv.parseArgsStringToArgv)(command$1)];
|
|
1256
|
+
if (!cmd) continue;
|
|
1257
|
+
const hookId = (0, node_crypto.createHash)("sha256").update(command$1).digest("hex");
|
|
1258
|
+
await events.emit("hook:start", {
|
|
1259
|
+
id: hookId,
|
|
1260
|
+
command: cmd,
|
|
1261
|
+
args
|
|
1262
|
+
});
|
|
1263
|
+
await events.onOnce("hook:end", async ({ success, error }) => {
|
|
1264
|
+
if (!success) throw error;
|
|
1265
|
+
await events.emit("success", `${picocolors.default.dim(command$1)} successfully executed`);
|
|
1266
|
+
});
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
//#endregion
|
|
1271
|
+
//#region src/utils/formatters.ts
|
|
1272
|
+
const formatters = {
|
|
1273
|
+
prettier: {
|
|
1274
|
+
command: "prettier",
|
|
1275
|
+
args: (outputPath) => [
|
|
1276
|
+
"--ignore-unknown",
|
|
1277
|
+
"--write",
|
|
1278
|
+
outputPath
|
|
1279
|
+
],
|
|
1280
|
+
errorMessage: "Prettier not found"
|
|
1281
|
+
},
|
|
1282
|
+
biome: {
|
|
1283
|
+
command: "biome",
|
|
1284
|
+
args: (outputPath) => [
|
|
1285
|
+
"format",
|
|
1286
|
+
"--write",
|
|
1287
|
+
outputPath
|
|
1288
|
+
],
|
|
1289
|
+
errorMessage: "Biome not found"
|
|
1290
|
+
},
|
|
1291
|
+
oxfmt: {
|
|
1292
|
+
command: "oxfmt",
|
|
1293
|
+
args: (outputPath) => [outputPath],
|
|
1294
|
+
errorMessage: "Oxfmt not found"
|
|
1295
|
+
}
|
|
1296
|
+
};
|
|
1297
|
+
|
|
1298
|
+
//#endregion
|
|
1299
|
+
//#region src/runners/generate.ts
|
|
1300
|
+
async function generate({ input, config: userConfig, events, logLevel }) {
|
|
1301
|
+
const inputPath = input ?? ("path" in userConfig.input ? userConfig.input.path : void 0);
|
|
1302
|
+
const hrStart = node_process.default.hrtime();
|
|
1303
|
+
const config = {
|
|
1304
|
+
...userConfig,
|
|
1305
|
+
root: userConfig.root || node_process.default.cwd(),
|
|
1306
|
+
input: inputPath ? {
|
|
1307
|
+
...userConfig.input,
|
|
1308
|
+
path: inputPath
|
|
1309
|
+
} : userConfig.input,
|
|
1310
|
+
output: {
|
|
1311
|
+
write: true,
|
|
1312
|
+
barrelType: "named",
|
|
1313
|
+
extension: { ".ts": ".ts" },
|
|
1314
|
+
format: "prettier",
|
|
1315
|
+
...userConfig.output
|
|
1316
|
+
}
|
|
1317
|
+
};
|
|
1318
|
+
await events.emit("generation:start", config);
|
|
1319
|
+
await events.emit("info", config.name ? `Setup generation ${picocolors.default.bold(config.name)}` : "Setup generation", inputPath);
|
|
1320
|
+
const { sources, fabric, pluginManager } = await (0, _kubb_core.setup)({
|
|
1321
|
+
config,
|
|
1322
|
+
events
|
|
1323
|
+
});
|
|
1324
|
+
await events.emit("info", config.name ? `Build generation ${picocolors.default.bold(config.name)}` : "Build generation", inputPath);
|
|
1325
|
+
const { files, failedPlugins, pluginTimings, error } = await (0, _kubb_core.safeBuild)({
|
|
1326
|
+
config,
|
|
1327
|
+
events
|
|
1328
|
+
}, {
|
|
1329
|
+
pluginManager,
|
|
1330
|
+
fabric,
|
|
1331
|
+
events,
|
|
1332
|
+
sources
|
|
1333
|
+
});
|
|
1334
|
+
await events.emit("info", "Load summary");
|
|
1335
|
+
if (failedPlugins.size > 0 || error) {
|
|
1336
|
+
[error, ...Array.from(failedPlugins).filter((it) => it.error).map((it) => it.error)].filter(Boolean).forEach((err) => {
|
|
1337
|
+
events.emit("error", err);
|
|
1338
|
+
});
|
|
1339
|
+
await events.emit("generation:end", config, files, sources);
|
|
1340
|
+
await events.emit("generation:summary", config, {
|
|
1341
|
+
failedPlugins,
|
|
1342
|
+
filesCreated: files.length,
|
|
1343
|
+
status: failedPlugins.size > 0 || error ? "failed" : "success",
|
|
1344
|
+
hrStart,
|
|
1345
|
+
pluginTimings: logLevel >= _kubb_core.LogLevel.verbose ? pluginTimings : void 0
|
|
1346
|
+
});
|
|
1347
|
+
node_process.default.exit(1);
|
|
1348
|
+
}
|
|
1349
|
+
await events.emit("success", "Generation successfully", inputPath);
|
|
1350
|
+
await events.emit("generation:end", config, files, sources);
|
|
1351
|
+
if (config.output.format) {
|
|
1352
|
+
await events.emit("format:start");
|
|
1353
|
+
let formatter = config.output.format;
|
|
1354
|
+
if (formatter === "auto") {
|
|
1355
|
+
const detectedFormatter = await detectFormatter();
|
|
1356
|
+
if (!detectedFormatter) await events.emit("warn", "No formatter found (biome, prettier, or oxfmt). Skipping formatting.");
|
|
1357
|
+
else {
|
|
1358
|
+
formatter = detectedFormatter;
|
|
1359
|
+
await events.emit("info", `Auto-detected formatter: ${picocolors.default.dim(formatter)}`);
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
if (formatter && formatter !== "auto" && formatter in formatters) {
|
|
1363
|
+
const formatterConfig = formatters[formatter];
|
|
1364
|
+
const outputPath = node_path.default.resolve(config.root, config.output.path);
|
|
1365
|
+
try {
|
|
1366
|
+
const hookId = (0, node_crypto.createHash)("sha256").update([config.name, formatter].filter(Boolean).join("-")).digest("hex");
|
|
1367
|
+
await events.emit("hook:start", {
|
|
1368
|
+
id: hookId,
|
|
1369
|
+
command: formatterConfig.command,
|
|
1370
|
+
args: formatterConfig.args(outputPath)
|
|
1371
|
+
});
|
|
1372
|
+
await events.onOnce("hook:end", async ({ success, error: error$1 }) => {
|
|
1373
|
+
if (!success) throw error$1;
|
|
1374
|
+
await events.emit("success", [
|
|
1375
|
+
`Formatting with ${picocolors.default.dim(formatter)}`,
|
|
1376
|
+
logLevel >= _kubb_core.LogLevel.info ? `on ${picocolors.default.dim(outputPath)}` : void 0,
|
|
1377
|
+
"successfully"
|
|
1378
|
+
].filter(Boolean).join(" "));
|
|
1379
|
+
});
|
|
1380
|
+
} catch (caughtError) {
|
|
1381
|
+
const error$1 = new Error(formatterConfig.errorMessage);
|
|
1382
|
+
error$1.cause = caughtError;
|
|
1383
|
+
await events.emit("error", error$1);
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1386
|
+
await events.emit("format:end");
|
|
1387
|
+
}
|
|
1388
|
+
if (config.output.lint) {
|
|
1389
|
+
await events.emit("lint:start");
|
|
1390
|
+
let linter = config.output.lint;
|
|
1391
|
+
if (linter === "auto") {
|
|
1392
|
+
const detectedLinter = await detectLinter();
|
|
1393
|
+
if (!detectedLinter) await events.emit("warn", "No linter found (biome, oxlint, or eslint). Skipping linting.");
|
|
1394
|
+
else {
|
|
1395
|
+
linter = detectedLinter;
|
|
1396
|
+
await events.emit("info", `Auto-detected linter: ${picocolors.default.dim(linter)}`);
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
1399
|
+
if (linter && linter !== "auto") {
|
|
1400
|
+
await events.emit("info", [`Linting with ${picocolors.default.dim(linter)}`, logLevel >= _kubb_core.LogLevel.info ? `on ${picocolors.default.dim(node_path.default.resolve(config.root, config.output.path))}` : void 0].filter(Boolean).join(" "));
|
|
1401
|
+
if (linter === "eslint") try {
|
|
1402
|
+
const hookId = (0, node_crypto.createHash)("sha256").update([config.name, linter].filter(Boolean).join("-")).digest("hex");
|
|
1403
|
+
await events.emit("hook:start", {
|
|
1404
|
+
id: hookId,
|
|
1405
|
+
command: "eslint",
|
|
1406
|
+
args: [node_path.default.resolve(config.root, config.output.path), "--fix"]
|
|
1407
|
+
});
|
|
1408
|
+
await events.onOnce("hook:end", async ({ success, error: error$1 }) => {
|
|
1409
|
+
if (!success) throw error$1;
|
|
1410
|
+
await events.emit("success", [
|
|
1411
|
+
`Linted with ${picocolors.default.dim(linter)}`,
|
|
1412
|
+
logLevel >= _kubb_core.LogLevel.info ? `on ${picocolors.default.dim(node_path.default.resolve(config.root, config.output.path))}` : void 0,
|
|
1413
|
+
"successfully"
|
|
1414
|
+
].filter(Boolean).join(" "));
|
|
1415
|
+
});
|
|
1416
|
+
} catch (caughtError) {
|
|
1417
|
+
const error$1 = /* @__PURE__ */ new Error("Eslint not found");
|
|
1418
|
+
error$1.cause = caughtError;
|
|
1419
|
+
await events.emit("error", error$1);
|
|
1420
|
+
}
|
|
1421
|
+
if (linter === "biome") try {
|
|
1422
|
+
const hookId = (0, node_crypto.createHash)("sha256").update([config.name, linter].filter(Boolean).join("-")).digest("hex");
|
|
1423
|
+
await events.emit("hook:start", {
|
|
1424
|
+
id: hookId,
|
|
1425
|
+
command: "biome",
|
|
1426
|
+
args: [
|
|
1427
|
+
"lint",
|
|
1428
|
+
"--fix",
|
|
1429
|
+
node_path.default.resolve(config.root, config.output.path)
|
|
1430
|
+
]
|
|
1431
|
+
});
|
|
1432
|
+
await events.onOnce("hook:end", async ({ success, error: error$1 }) => {
|
|
1433
|
+
if (!success) throw error$1;
|
|
1434
|
+
await events.emit("success", [
|
|
1435
|
+
`Linted with ${picocolors.default.dim(linter)}`,
|
|
1436
|
+
logLevel >= _kubb_core.LogLevel.info ? `on ${picocolors.default.dim(node_path.default.resolve(config.root, config.output.path))}` : void 0,
|
|
1437
|
+
"successfully"
|
|
1438
|
+
].filter(Boolean).join(" "));
|
|
1439
|
+
});
|
|
1440
|
+
} catch (caughtError) {
|
|
1441
|
+
const error$1 = /* @__PURE__ */ new Error("Biome not found");
|
|
1442
|
+
error$1.cause = caughtError;
|
|
1443
|
+
await events.emit("error", error$1);
|
|
1444
|
+
}
|
|
1445
|
+
if (linter === "oxlint") try {
|
|
1446
|
+
const hookId = (0, node_crypto.createHash)("sha256").update([config.name, linter].filter(Boolean).join("-")).digest("hex");
|
|
1447
|
+
await events.emit("hook:start", {
|
|
1448
|
+
id: hookId,
|
|
1449
|
+
command: "oxlint",
|
|
1450
|
+
args: ["--fix", node_path.default.resolve(config.root, config.output.path)]
|
|
1451
|
+
});
|
|
1452
|
+
await events.onOnce("hook:end", async ({ success, error: error$1 }) => {
|
|
1453
|
+
if (!success) throw error$1;
|
|
1454
|
+
await events.emit("success", [
|
|
1455
|
+
`Linted with ${picocolors.default.dim(linter)}`,
|
|
1456
|
+
logLevel >= _kubb_core.LogLevel.info ? `on ${picocolors.default.dim(node_path.default.resolve(config.root, config.output.path))}` : void 0,
|
|
1457
|
+
"successfully"
|
|
1458
|
+
].filter(Boolean).join(" "));
|
|
1459
|
+
});
|
|
1460
|
+
} catch (caughtError) {
|
|
1461
|
+
const error$1 = /* @__PURE__ */ new Error("Oxlint not found");
|
|
1462
|
+
error$1.cause = caughtError;
|
|
1463
|
+
await events.emit("error", error$1);
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
1466
|
+
await events.emit("lint:end");
|
|
1467
|
+
}
|
|
1468
|
+
if (config.hooks) {
|
|
1469
|
+
await events.emit("hooks:start");
|
|
1470
|
+
await executeHooks({
|
|
1471
|
+
hooks: config.hooks,
|
|
1472
|
+
events
|
|
1473
|
+
});
|
|
1474
|
+
await events.emit("hooks:end");
|
|
1475
|
+
}
|
|
1476
|
+
await events.emit("generation:summary", config, {
|
|
1477
|
+
failedPlugins,
|
|
1478
|
+
filesCreated: files.length,
|
|
1479
|
+
status: failedPlugins.size > 0 || error ? "failed" : "success",
|
|
1480
|
+
hrStart,
|
|
1481
|
+
pluginTimings
|
|
1482
|
+
});
|
|
1483
|
+
}
|
|
1484
|
+
|
|
1485
|
+
//#endregion
|
|
1486
|
+
//#region src/utils/getPlugins.ts
|
|
1487
|
+
function isJSONPlugins(plugins) {
|
|
1488
|
+
return !!plugins?.some((plugin) => {
|
|
1489
|
+
return Array.isArray(plugin) && typeof plugin?.at(0) === "string";
|
|
1490
|
+
});
|
|
1491
|
+
}
|
|
1492
|
+
function isObjectPlugins(plugins) {
|
|
1493
|
+
return plugins instanceof Object && !Array.isArray(plugins);
|
|
1494
|
+
}
|
|
1495
|
+
function getPlugins(plugins) {
|
|
1496
|
+
if (isObjectPlugins(plugins)) throw new Error("Object plugins are not supported anymore, best to use http://kubb.dev/getting-started/configure#json");
|
|
1497
|
+
if (isJSONPlugins(plugins)) throw new Error("JSON plugins are not supported anymore, best to use http://kubb.dev/getting-started/configure#json");
|
|
1498
|
+
return Promise.resolve(plugins);
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1501
|
+
//#endregion
|
|
1502
|
+
//#region src/utils/getConfigs.ts
|
|
1503
|
+
/**
|
|
1504
|
+
* Converting UserConfig to Config Array without a change in the object beside the JSON convert.
|
|
1505
|
+
*/
|
|
1506
|
+
async function getConfigs(result, args) {
|
|
1507
|
+
const config = result?.config;
|
|
1508
|
+
let kubbUserConfig = Promise.resolve(config);
|
|
1509
|
+
if (typeof config === "function") {
|
|
1510
|
+
const possiblePromise = config(args);
|
|
1511
|
+
if ((0, _kubb_core_utils.isPromise)(possiblePromise)) kubbUserConfig = possiblePromise;
|
|
1512
|
+
kubbUserConfig = Promise.resolve(possiblePromise);
|
|
1513
|
+
}
|
|
1514
|
+
let JSONConfig = await kubbUserConfig;
|
|
1515
|
+
if (!Array.isArray(JSONConfig)) JSONConfig = [JSONConfig];
|
|
1516
|
+
const results = [];
|
|
1517
|
+
for (const item of JSONConfig) {
|
|
1518
|
+
const plugins = item.plugins ? await getPlugins(item.plugins) : void 0;
|
|
1519
|
+
results.push({
|
|
1520
|
+
...item,
|
|
1521
|
+
plugins
|
|
1522
|
+
});
|
|
1523
|
+
}
|
|
1524
|
+
return results;
|
|
1525
|
+
}
|
|
1526
|
+
|
|
1527
|
+
//#endregion
|
|
1528
|
+
//#region src/utils/getCosmiConfig.ts
|
|
1529
|
+
const tsLoader = async (configFile) => {
|
|
1530
|
+
return await (0, jiti.createJiti)(configFile, {
|
|
1531
|
+
jsx: {
|
|
1532
|
+
runtime: "automatic",
|
|
1533
|
+
importSource: "@kubb/react-fabric"
|
|
1534
|
+
},
|
|
1535
|
+
sourceMaps: true,
|
|
1536
|
+
interopDefault: true
|
|
1537
|
+
}).import(configFile, { default: true });
|
|
1538
|
+
};
|
|
1539
|
+
async function getCosmiConfig(moduleName, config) {
|
|
1540
|
+
let result;
|
|
1541
|
+
const searchPlaces = [
|
|
1542
|
+
"package.json",
|
|
1543
|
+
`.${moduleName}rc`,
|
|
1544
|
+
`.${moduleName}rc.json`,
|
|
1545
|
+
`.${moduleName}rc.yaml`,
|
|
1546
|
+
`.${moduleName}rc.yml`,
|
|
1547
|
+
`.${moduleName}rc.ts`,
|
|
1548
|
+
`.${moduleName}rc.js`,
|
|
1549
|
+
`.${moduleName}rc.mjs`,
|
|
1550
|
+
`.${moduleName}rc.cjs`,
|
|
1551
|
+
`${moduleName}.config.ts`,
|
|
1552
|
+
`${moduleName}.config.js`,
|
|
1553
|
+
`${moduleName}.config.mjs`,
|
|
1554
|
+
`${moduleName}.config.cjs`
|
|
1555
|
+
];
|
|
1556
|
+
const explorer = (0, cosmiconfig.cosmiconfig)(moduleName, {
|
|
1557
|
+
cache: false,
|
|
1558
|
+
searchPlaces: [
|
|
1559
|
+
...searchPlaces.map((searchPlace) => {
|
|
1560
|
+
return `.config/${searchPlace}`;
|
|
1561
|
+
}),
|
|
1562
|
+
...searchPlaces.map((searchPlace) => {
|
|
1563
|
+
return `configs/${searchPlace}`;
|
|
1564
|
+
}),
|
|
1565
|
+
...searchPlaces
|
|
1566
|
+
],
|
|
1567
|
+
loaders: { ".ts": tsLoader }
|
|
1568
|
+
});
|
|
1569
|
+
try {
|
|
1570
|
+
result = config ? await explorer.load(config) : await explorer.search();
|
|
1571
|
+
} catch (error) {
|
|
1572
|
+
throw new Error("Config failed loading", { cause: error });
|
|
1573
|
+
}
|
|
1574
|
+
if (result?.isEmpty || !result || !result.config) throw new Error("Config not defined, create a kubb.config.js or pass through your config with the option --config");
|
|
1575
|
+
return result;
|
|
1576
|
+
}
|
|
1577
|
+
|
|
1151
1578
|
//#endregion
|
|
1152
1579
|
//#region src/utils/watcher.ts
|
|
1153
|
-
async function startWatcher(path$
|
|
1580
|
+
async function startWatcher(path$3, cb) {
|
|
1154
1581
|
const { watch } = await import("chokidar");
|
|
1155
|
-
watch(path$
|
|
1582
|
+
watch(path$3, {
|
|
1156
1583
|
ignorePermissionErrors: true,
|
|
1157
1584
|
ignored: "**/{.git,node_modules}/**"
|
|
1158
1585
|
}).on("all", async (type, file) => {
|
|
1159
1586
|
console.log(picocolors.default.yellow(picocolors.default.bold(`Change detected: ${type} ${file}`)));
|
|
1160
1587
|
try {
|
|
1161
|
-
await cb(path$
|
|
1588
|
+
await cb(path$3);
|
|
1162
1589
|
} catch (_e) {
|
|
1163
1590
|
console.log(picocolors.default.red("Watcher failed"));
|
|
1164
1591
|
}
|
|
@@ -1232,8 +1659,8 @@ const command = (0, citty.defineCommand)({
|
|
|
1232
1659
|
if ((0, semver.lt)(require_package.version, latestVersion)) await events.emit("version:new", require_package.version, latestVersion);
|
|
1233
1660
|
});
|
|
1234
1661
|
try {
|
|
1235
|
-
const result = await
|
|
1236
|
-
const configs = await
|
|
1662
|
+
const result = await getCosmiConfig("kubb", args.config);
|
|
1663
|
+
const configs = await getConfigs(result, args);
|
|
1237
1664
|
await events.emit("config:start");
|
|
1238
1665
|
await events.emit("info", "Config loaded", node_path.default.relative(node_process.cwd(), result.filepath));
|
|
1239
1666
|
await events.emit("success", "Config loaded successfully", node_path.default.relative(node_process.cwd(), result.filepath));
|
|
@@ -1243,7 +1670,7 @@ const command = (0, citty.defineCommand)({
|
|
|
1243
1670
|
return async () => {
|
|
1244
1671
|
if ((0, _kubb_core.isInputPath)(config) && args.watch) {
|
|
1245
1672
|
await startWatcher([input || config.input.path], async (paths) => {
|
|
1246
|
-
await
|
|
1673
|
+
await generate({
|
|
1247
1674
|
input,
|
|
1248
1675
|
config,
|
|
1249
1676
|
logLevel,
|
|
@@ -1253,7 +1680,7 @@ const command = (0, citty.defineCommand)({
|
|
|
1253
1680
|
});
|
|
1254
1681
|
return;
|
|
1255
1682
|
}
|
|
1256
|
-
await
|
|
1683
|
+
await generate({
|
|
1257
1684
|
input,
|
|
1258
1685
|
config,
|
|
1259
1686
|
logLevel,
|
|
@@ -1273,4 +1700,4 @@ var generate_default = command;
|
|
|
1273
1700
|
|
|
1274
1701
|
//#endregion
|
|
1275
1702
|
exports.default = generate_default;
|
|
1276
|
-
//# sourceMappingURL=generate-
|
|
1703
|
+
//# sourceMappingURL=generate-BYLZgOxz.cjs.map
|