@kubb/core 4.36.1 → 5.0.0-alpha.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/hooks.d.ts +1 -1
- package/dist/index.cjs +24 -37
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +24 -37
- package/dist/index.js.map +1 -1
- package/dist/{types-D30QAz2y.d.ts → types-B7eZvqwD.d.ts} +14 -24
- package/package.json +3 -3
- package/src/PluginManager.ts +21 -45
- package/src/build.ts +5 -5
- package/src/types.ts +3 -14
- package/src/utils/getBarrelFiles.ts +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
|
-
import { A as
|
|
2
|
+
import { A as UserPluginWithLifeCycle, B as URLPath, C as PrinterFactoryOptions, D as UserConfig, E as UnknownUserPlugin, F as defineStorage, I as formatters, L as linters, M as PluginManager, N as getMode, O as UserLogger, P as DefineStorage, R as logLevel, S as Printer, T as ResolvePathParams, _ as PluginFactoryOptions, a as Config, b as PluginParameter, c as Group, d as Logger, f as LoggerContext, g as PluginContext, h as Plugin, i as BarrelType, j as KubbEvents, k as UserPlugin, l as InputData, m as Output, n as AdapterFactoryOptions, o as DevtoolsOptions, p as LoggerOptions, r as AdapterSource, s as GetPluginFactoryOptions, t as Adapter, u as InputPath, v as PluginLifecycle, w as ResolveNameParams, x as PluginWithLifeCycle, y as PluginLifecycleHooks, z as AsyncEventEmitter } from "./types-B7eZvqwD.js";
|
|
3
3
|
import { definePrinter } from "@kubb/ast";
|
|
4
4
|
import { Fabric } from "@kubb/react-fabric";
|
|
5
5
|
import { KubbFile } from "@kubb/fabric-core/types";
|
|
@@ -274,7 +274,7 @@ declare function detectFormatter(): Promise<Formatter | undefined>;
|
|
|
274
274
|
//#endregion
|
|
275
275
|
//#region src/utils/getBarrelFiles.d.ts
|
|
276
276
|
type FileMetaBase = {
|
|
277
|
-
|
|
277
|
+
pluginName?: string;
|
|
278
278
|
};
|
|
279
279
|
type AddIndexesProps = {
|
|
280
280
|
type: BarrelType | false | undefined;
|
|
@@ -311,5 +311,5 @@ declare function getConfigs(config: ConfigInput | UserConfig, args: CLIOptions):
|
|
|
311
311
|
type Linter = keyof typeof linters;
|
|
312
312
|
declare function detectLinter(): Promise<Linter | undefined>;
|
|
313
313
|
//#endregion
|
|
314
|
-
export { Adapter, AdapterFactoryOptions, AdapterSource, AsyncEventEmitter, BarrelType, type CLIOptions, Config, type ConfigInput, DefineStorage, DevtoolsOptions, type FileMetaBase, FunctionParams, type FunctionParamsAST, GetPluginFactoryOptions, Group, InputData, InputPath, KubbEvents, Logger, LoggerContext, LoggerOptions, Output, PackageManager, Plugin, PluginContext, PluginFactoryOptions,
|
|
314
|
+
export { Adapter, AdapterFactoryOptions, AdapterSource, AsyncEventEmitter, BarrelType, type CLIOptions, Config, type ConfigInput, DefineStorage, DevtoolsOptions, type FileMetaBase, FunctionParams, type FunctionParamsAST, GetPluginFactoryOptions, Group, InputData, InputPath, KubbEvents, Logger, LoggerContext, LoggerOptions, Output, PackageManager, Plugin, PluginContext, PluginFactoryOptions, PluginLifecycle, PluginLifecycleHooks, PluginManager, PluginParameter, PluginWithLifeCycle, Printer, PrinterFactoryOptions, PromiseManager, ResolveNameParams, ResolvePathParams, URLPath, UnknownUserPlugin, UserConfig, UserLogger, UserPlugin, UserPluginWithLifeCycle, build, build as default, defineAdapter, defineConfig, defineLogger, definePlugin, definePrinter, defineStorage, detectFormatter, detectLinter, formatters, fsStorage, getBarrelFiles, getConfigs, getMode, isInputPath, linters, logLevel, memoryStorage, safeBuild, setup };
|
|
315
315
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1018,19 +1018,19 @@ var PluginManager = class {
|
|
|
1018
1018
|
get plugins() {
|
|
1019
1019
|
return this.#getSortedPlugins();
|
|
1020
1020
|
}
|
|
1021
|
-
getFile({ name, mode, extname,
|
|
1021
|
+
getFile({ name, mode, extname, pluginName, options }) {
|
|
1022
1022
|
const baseName = `${name}${extname}`;
|
|
1023
1023
|
const path = this.resolvePath({
|
|
1024
1024
|
baseName,
|
|
1025
1025
|
mode,
|
|
1026
|
-
|
|
1026
|
+
pluginName,
|
|
1027
1027
|
options
|
|
1028
1028
|
});
|
|
1029
|
-
if (!path) throw new Error(`Filepath should be defined for resolvedName "${name}" and
|
|
1029
|
+
if (!path) throw new Error(`Filepath should be defined for resolvedName "${name}" and pluginName "${pluginName}"`);
|
|
1030
1030
|
return {
|
|
1031
1031
|
path,
|
|
1032
1032
|
baseName,
|
|
1033
|
-
meta: {
|
|
1033
|
+
meta: { pluginName },
|
|
1034
1034
|
sources: [],
|
|
1035
1035
|
imports: [],
|
|
1036
1036
|
exports: []
|
|
@@ -1039,8 +1039,8 @@ var PluginManager = class {
|
|
|
1039
1039
|
resolvePath = (params) => {
|
|
1040
1040
|
const root = path.resolve(this.config.root, this.config.output.path);
|
|
1041
1041
|
const defaultPath = path.resolve(root, params.baseName);
|
|
1042
|
-
if (params.
|
|
1043
|
-
|
|
1042
|
+
if (params.pluginName) return this.hookForPluginSync({
|
|
1043
|
+
pluginName: params.pluginName,
|
|
1044
1044
|
hookName: "resolvePath",
|
|
1045
1045
|
parameters: [
|
|
1046
1046
|
params.baseName,
|
|
@@ -1058,9 +1058,9 @@ var PluginManager = class {
|
|
|
1058
1058
|
})?.result || defaultPath;
|
|
1059
1059
|
};
|
|
1060
1060
|
resolveName = (params) => {
|
|
1061
|
-
if (params.
|
|
1061
|
+
if (params.pluginName) {
|
|
1062
1062
|
const names = this.hookForPluginSync({
|
|
1063
|
-
|
|
1063
|
+
pluginName: params.pluginName,
|
|
1064
1064
|
hookName: "resolveName",
|
|
1065
1065
|
parameters: [params.name.trim(), params.type]
|
|
1066
1066
|
});
|
|
@@ -1075,8 +1075,8 @@ var PluginManager = class {
|
|
|
1075
1075
|
/**
|
|
1076
1076
|
* Run a specific hookName for plugin x.
|
|
1077
1077
|
*/
|
|
1078
|
-
async hookForPlugin({
|
|
1079
|
-
const plugins = this.
|
|
1078
|
+
async hookForPlugin({ pluginName, hookName, parameters }) {
|
|
1079
|
+
const plugins = this.getPluginsByName(hookName, pluginName);
|
|
1080
1080
|
this.events.emit("plugins:hook:progress:start", {
|
|
1081
1081
|
hookName,
|
|
1082
1082
|
plugins
|
|
@@ -1097,8 +1097,8 @@ var PluginManager = class {
|
|
|
1097
1097
|
/**
|
|
1098
1098
|
* Run a specific hookName for plugin x.
|
|
1099
1099
|
*/
|
|
1100
|
-
hookForPluginSync({
|
|
1101
|
-
return this.
|
|
1100
|
+
hookForPluginSync({ pluginName, hookName, parameters }) {
|
|
1101
|
+
return this.getPluginsByName(hookName, pluginName).map((plugin) => {
|
|
1102
1102
|
return this.#executeSync({
|
|
1103
1103
|
strategy: "hookFirst",
|
|
1104
1104
|
hookName,
|
|
@@ -1236,24 +1236,12 @@ var PluginManager = class {
|
|
|
1236
1236
|
return 0;
|
|
1237
1237
|
});
|
|
1238
1238
|
}
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
const [searchPluginName] = pluginKey;
|
|
1242
|
-
return plugins.find((item) => {
|
|
1243
|
-
const [name] = item.key;
|
|
1244
|
-
return name === searchPluginName;
|
|
1245
|
-
});
|
|
1239
|
+
getPluginByName(pluginName) {
|
|
1240
|
+
return [...this.#plugins].find((item) => item.name === pluginName);
|
|
1246
1241
|
}
|
|
1247
|
-
|
|
1242
|
+
getPluginsByName(hookName, pluginName) {
|
|
1248
1243
|
const plugins = [...this.plugins];
|
|
1249
|
-
const
|
|
1250
|
-
const pluginByPluginName = plugins.filter((plugin) => hookName in plugin).filter((item) => {
|
|
1251
|
-
const [name, identifier] = item.key;
|
|
1252
|
-
const identifierCheck = identifier?.toString() === searchIdentifier?.toString();
|
|
1253
|
-
const nameCheck = name === searchPluginName;
|
|
1254
|
-
if (searchIdentifier) return identifierCheck && nameCheck;
|
|
1255
|
-
return nameCheck;
|
|
1256
|
-
});
|
|
1244
|
+
const pluginByPluginName = plugins.filter((plugin) => hookName in plugin).filter((item) => item.name === pluginName);
|
|
1257
1245
|
if (!pluginByPluginName?.length) {
|
|
1258
1246
|
const corePlugin = plugins.find((plugin) => plugin.name === "core" && hookName in plugin);
|
|
1259
1247
|
return corePlugin ? [corePlugin] : [];
|
|
@@ -1350,11 +1338,10 @@ var PluginManager = class {
|
|
|
1350
1338
|
const usedPluginNames = this.#usedPluginNames;
|
|
1351
1339
|
setUniqueName(plugin.name, usedPluginNames);
|
|
1352
1340
|
const usageCount = usedPluginNames[plugin.name];
|
|
1353
|
-
if (usageCount && usageCount > 1)
|
|
1341
|
+
if (usageCount && usageCount > 1) throw new ValidationPluginError(`Duplicate plugin "${plugin.name}" detected. Each plugin can only be used once. Use a different configuration instead of adding multiple instances of the same plugin.`);
|
|
1354
1342
|
return {
|
|
1355
1343
|
install() {},
|
|
1356
|
-
...plugin
|
|
1357
|
-
key: [plugin.name, usedPluginNames[plugin.name]].filter(Boolean)
|
|
1344
|
+
...plugin
|
|
1358
1345
|
};
|
|
1359
1346
|
}
|
|
1360
1347
|
};
|
|
@@ -1461,7 +1448,7 @@ const fsStorage = defineStorage(() => ({
|
|
|
1461
1448
|
}));
|
|
1462
1449
|
//#endregion
|
|
1463
1450
|
//#region package.json
|
|
1464
|
-
var version$1 = "
|
|
1451
|
+
var version$1 = "5.0.0-alpha.2";
|
|
1465
1452
|
//#endregion
|
|
1466
1453
|
//#region src/utils/diagnostics.ts
|
|
1467
1454
|
/**
|
|
@@ -1635,7 +1622,7 @@ async function safeBuild(options, overrides) {
|
|
|
1635
1622
|
await events.emit("plugin:start", plugin);
|
|
1636
1623
|
await events.emit("debug", {
|
|
1637
1624
|
date: timestamp,
|
|
1638
|
-
logs: ["Installing plugin...", ` • Plugin
|
|
1625
|
+
logs: ["Installing plugin...", ` • Plugin Name: ${plugin.name}`]
|
|
1639
1626
|
});
|
|
1640
1627
|
await installer(context);
|
|
1641
1628
|
const duration = getElapsedMs(hrStart);
|
|
@@ -1661,7 +1648,7 @@ async function safeBuild(options, overrides) {
|
|
|
1661
1648
|
date: errorTimestamp,
|
|
1662
1649
|
logs: [
|
|
1663
1650
|
"✗ Plugin installation failed",
|
|
1664
|
-
` • Plugin
|
|
1651
|
+
` • Plugin Name: ${plugin.name}`,
|
|
1665
1652
|
` • Error: ${error.constructor.name} - ${error.message}`,
|
|
1666
1653
|
" • Stack Trace:",
|
|
1667
1654
|
error.stack || "No stack trace available"
|
|
@@ -1735,14 +1722,14 @@ async function safeBuild(options, overrides) {
|
|
|
1735
1722
|
}
|
|
1736
1723
|
}
|
|
1737
1724
|
function buildBarrelExports({ barrelFiles, rootDir, existingExports, config, pluginManager }) {
|
|
1738
|
-
const
|
|
1739
|
-
for (const plugin of pluginManager.plugins)
|
|
1725
|
+
const pluginNameMap = /* @__PURE__ */ new Map();
|
|
1726
|
+
for (const plugin of pluginManager.plugins) pluginNameMap.set(plugin.name, plugin);
|
|
1740
1727
|
return barrelFiles.flatMap((file) => {
|
|
1741
1728
|
const containsOnlyTypes = file.sources?.every((source) => source.isTypeOnly);
|
|
1742
1729
|
return (file.sources ?? []).flatMap((source) => {
|
|
1743
1730
|
if (!file.path || !source.isIndexable) return [];
|
|
1744
1731
|
const meta = file.meta;
|
|
1745
|
-
const pluginOptions = (meta?.
|
|
1732
|
+
const pluginOptions = (meta?.pluginName ? pluginNameMap.get(meta.pluginName) : void 0)?.options;
|
|
1746
1733
|
if (!pluginOptions || pluginOptions.output?.barrelType === false) return [];
|
|
1747
1734
|
const exportName = config.output.barrelType === "all" ? void 0 : source.name ? [source.name] : void 0;
|
|
1748
1735
|
if (exportName?.some((n) => existingExports.has(n))) return [];
|