@kubb/core 5.6.3 → 5.7.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/{KubbDriver-CVFm4dwb.cjs → KubbDriver-BcoHguLM.cjs} +365 -59
- package/dist/KubbDriver-BcoHguLM.cjs.map +1 -0
- package/dist/{KubbDriver-BZBnKODj.js → KubbDriver-DRobnIcp.js} +282 -60
- package/dist/KubbDriver-DRobnIcp.js.map +1 -0
- package/dist/index.cjs +35 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +58 -3
- package/dist/index.js +23 -31
- package/dist/index.js.map +1 -1
- package/dist/mocks.cjs +1 -1
- package/dist/mocks.d.ts +1 -1
- package/dist/mocks.js +1 -1
- package/dist/{types-BjZ8hdyZ.d.ts → types-Cd91JYuu.d.ts} +178 -59
- package/package.json +4 -3
- package/dist/KubbDriver-BZBnKODj.js.map +0 -1
- package/dist/KubbDriver-CVFm4dwb.cjs.map +0 -1
|
@@ -30,6 +30,7 @@ let node_fs_promises = require("node:fs/promises");
|
|
|
30
30
|
let node_path = require("node:path");
|
|
31
31
|
node_path = __toESM(node_path, 1);
|
|
32
32
|
let _kubb_ast = require("@kubb/ast");
|
|
33
|
+
let verkit = require("verkit");
|
|
33
34
|
let node_events = require("node:events");
|
|
34
35
|
//#region ../../internals/utils/src/casing.ts
|
|
35
36
|
/**
|
|
@@ -355,7 +356,7 @@ function formatMs(ms) {
|
|
|
355
356
|
}
|
|
356
357
|
//#endregion
|
|
357
358
|
//#region package.json
|
|
358
|
-
var version = "5.
|
|
359
|
+
var version = "5.7.0";
|
|
359
360
|
//#endregion
|
|
360
361
|
//#region src/constants.ts
|
|
361
362
|
/**
|
|
@@ -411,6 +412,18 @@ const diagnosticCode = {
|
|
|
411
412
|
*/
|
|
412
413
|
pluginNotFound: "KUBB_PLUGIN_NOT_FOUND",
|
|
413
414
|
/**
|
|
415
|
+
* The running Kubb or Node.js version is outside a plugin's `meta.compatibility`.
|
|
416
|
+
*/
|
|
417
|
+
incompatibleExtension: "KUBB_INCOMPATIBLE_EXTENSION",
|
|
418
|
+
/**
|
|
419
|
+
* A required entry in a plugin's `dependencies` record is missing from the config.
|
|
420
|
+
*/
|
|
421
|
+
missingDependency: "KUBB_MISSING_DEPENDENCY",
|
|
422
|
+
/**
|
|
423
|
+
* A dependency's `meta.version` is outside the range a plugin's `dependencies` record declares.
|
|
424
|
+
*/
|
|
425
|
+
incompatibleDependency: "KUBB_INCOMPATIBLE_DEPENDENCY",
|
|
426
|
+
/**
|
|
414
427
|
* A plugin threw while generating.
|
|
415
428
|
*/
|
|
416
429
|
pluginFailed: "KUBB_PLUGIN_FAILED",
|
|
@@ -423,6 +436,10 @@ const diagnosticCode = {
|
|
|
423
436
|
*/
|
|
424
437
|
pluginInfo: "KUBB_PLUGIN_INFO",
|
|
425
438
|
/**
|
|
439
|
+
* A `kubb/kit` composable was called outside a plugin's `setup` and `kubb:plugin:setup`.
|
|
440
|
+
*/
|
|
441
|
+
noContext: "KUBB_NO_CONTEXT",
|
|
442
|
+
/**
|
|
426
443
|
* A schema uses a `format` Kubb does not map to a specific type. Reserved for
|
|
427
444
|
* adapters to emit as a `warning`.
|
|
428
445
|
*/
|
|
@@ -594,6 +611,21 @@ const diagnosticCatalog = {
|
|
|
594
611
|
cause: "A plugin that another plugin depends on is missing from the config.",
|
|
595
612
|
fix: "Add the required plugin to the `plugins` array in kubb.config.ts, or remove the dependency on it."
|
|
596
613
|
},
|
|
614
|
+
[diagnosticCode.incompatibleExtension]: {
|
|
615
|
+
title: "Incompatible extension",
|
|
616
|
+
cause: "A plugin sets `meta.compatibility.kubb` or `meta.compatibility.node` to a range the running Kubb or Node.js version does not satisfy.",
|
|
617
|
+
fix: "Upgrade Kubb or Node.js to a version in the range, or install a version of the plugin that supports your current Kubb and Node.js."
|
|
618
|
+
},
|
|
619
|
+
[diagnosticCode.missingDependency]: {
|
|
620
|
+
title: "Missing dependency",
|
|
621
|
+
cause: "A plugin lists another plugin in its `dependencies` record without `optional: true`, and the config does not include it.",
|
|
622
|
+
fix: "Add the missing plugin to the `plugins` array in kubb.config.ts."
|
|
623
|
+
},
|
|
624
|
+
[diagnosticCode.incompatibleDependency]: {
|
|
625
|
+
title: "Incompatible dependency",
|
|
626
|
+
cause: "A plugin's `dependencies` record sets a `version` range, and the configured plugin's `meta.version` falls outside it.",
|
|
627
|
+
fix: "Install a version of the dependency inside the range, or a version of the dependent plugin that supports the installed dependency."
|
|
628
|
+
},
|
|
597
629
|
[diagnosticCode.pluginFailed]: {
|
|
598
630
|
title: "Plugin failed",
|
|
599
631
|
cause: "A plugin threw while generating, or reported an error through `ctx.error`.",
|
|
@@ -609,6 +641,11 @@ const diagnosticCatalog = {
|
|
|
609
641
|
cause: "A plugin reported an informational message through `ctx.info`.",
|
|
610
642
|
fix: "Informational only. No action is required."
|
|
611
643
|
},
|
|
644
|
+
[diagnosticCode.noContext]: {
|
|
645
|
+
title: "No plugin context",
|
|
646
|
+
cause: "A `kubb/kit` composable such as `useKubb()` or `addGenerator()` ran outside the `setup` and `kubb:plugin:setup` of a plugin, so there is no plugin to apply it to.",
|
|
647
|
+
fix: "Call the composable inside `setup` or `kubb:plugin:setup`, including in code that setup awaits."
|
|
648
|
+
},
|
|
612
649
|
[diagnosticCode.unsupportedFormat]: {
|
|
613
650
|
title: "Unsupported format",
|
|
614
651
|
cause: "A schema uses a `format` Kubb does not map to a specific type, so it falls back to the base type.",
|
|
@@ -912,6 +949,172 @@ var Diagnostics = class Diagnostics {
|
|
|
912
949
|
}
|
|
913
950
|
};
|
|
914
951
|
//#endregion
|
|
952
|
+
//#region src/composables.ts
|
|
953
|
+
/**
|
|
954
|
+
* Holds the setup context of the plugin whose `setup` or `kubb:plugin:setup` is running. `KubbDriver` sets it for each plugin.
|
|
955
|
+
*/
|
|
956
|
+
const kubbContext = new node_async_hooks.AsyncLocalStorage();
|
|
957
|
+
function requireContext(caller) {
|
|
958
|
+
const ctx = kubbContext.getStore();
|
|
959
|
+
if (ctx) return ctx;
|
|
960
|
+
throw new Diagnostics.Error({
|
|
961
|
+
code: Diagnostics.code.noContext,
|
|
962
|
+
severity: "error",
|
|
963
|
+
message: `\`${caller}()\` was called outside a plugin setup.`,
|
|
964
|
+
help: `Call \`${caller}()\` inside \`setup\` or \`kubb:plugin:setup\`, including in code that setup awaits.`
|
|
965
|
+
});
|
|
966
|
+
}
|
|
967
|
+
/**
|
|
968
|
+
* Returns the context of the plugin whose `kubb:plugin:setup` is running. It stays available after an `await`.
|
|
969
|
+
* Throws `KUBB_NO_CONTEXT` outside setup.
|
|
970
|
+
*/
|
|
971
|
+
function useKubb() {
|
|
972
|
+
return requireContext("useKubb");
|
|
973
|
+
}
|
|
974
|
+
/**
|
|
975
|
+
* Returns the same context as {@link useKubb}, or `undefined` outside `setup` and `kubb:plugin:setup`.
|
|
976
|
+
*/
|
|
977
|
+
function tryUseKubb() {
|
|
978
|
+
return kubbContext.getStore();
|
|
979
|
+
}
|
|
980
|
+
/**
|
|
981
|
+
* Registers generators on the plugin being set up, like `ctx.addGenerator`.
|
|
982
|
+
*
|
|
983
|
+
* @example
|
|
984
|
+
* `addGenerator(typeGenerator, enumGenerator)`
|
|
985
|
+
*/
|
|
986
|
+
function addGenerator(...generators) {
|
|
987
|
+
requireContext("addGenerator").addGenerator(...generators);
|
|
988
|
+
}
|
|
989
|
+
/**
|
|
990
|
+
* Sets the resolver of the plugin being set up, like `ctx.setResolver`.
|
|
991
|
+
*/
|
|
992
|
+
function setResolver(resolver) {
|
|
993
|
+
requireContext("setResolver").setResolver(resolver);
|
|
994
|
+
}
|
|
995
|
+
/**
|
|
996
|
+
* Adds a macro to the plugin being set up, like `ctx.addMacro`.
|
|
997
|
+
*/
|
|
998
|
+
function addMacro(macro) {
|
|
999
|
+
requireContext("addMacro").addMacro(macro);
|
|
1000
|
+
}
|
|
1001
|
+
/**
|
|
1002
|
+
* Replaces the macros of the plugin being set up, like `ctx.setMacros`.
|
|
1003
|
+
*/
|
|
1004
|
+
function setMacros(macros) {
|
|
1005
|
+
requireContext("setMacros").setMacros(macros);
|
|
1006
|
+
}
|
|
1007
|
+
/**
|
|
1008
|
+
* Adds a raw file to the build output, like `ctx.injectFile`.
|
|
1009
|
+
*/
|
|
1010
|
+
function injectFile(file) {
|
|
1011
|
+
requireContext("injectFile").injectFile(file);
|
|
1012
|
+
}
|
|
1013
|
+
/**
|
|
1014
|
+
* Returns the options the user passed to the plugin being set up, like `ctx.options`.
|
|
1015
|
+
*/
|
|
1016
|
+
function useOptions() {
|
|
1017
|
+
return requireContext("useOptions").options;
|
|
1018
|
+
}
|
|
1019
|
+
/**
|
|
1020
|
+
* Sets the resolved options of the plugin being set up, like `ctx.setOptions`.
|
|
1021
|
+
*/
|
|
1022
|
+
function setOptions(options) {
|
|
1023
|
+
requireContext("setOptions").setOptions(options);
|
|
1024
|
+
}
|
|
1025
|
+
/**
|
|
1026
|
+
* Returns the resolved build configuration, like `ctx.config`.
|
|
1027
|
+
*/
|
|
1028
|
+
function useConfig() {
|
|
1029
|
+
return requireContext("useConfig").config;
|
|
1030
|
+
}
|
|
1031
|
+
/**
|
|
1032
|
+
* Returns another plugin from the config, typed through `Kubb.PluginRegistry`, like `ctx.requirePlugin`.
|
|
1033
|
+
*/
|
|
1034
|
+
function requirePlugin(name) {
|
|
1035
|
+
return requireContext("requirePlugin").requirePlugin(name);
|
|
1036
|
+
}
|
|
1037
|
+
//#endregion
|
|
1038
|
+
//#region src/defineExtension.ts
|
|
1039
|
+
/**
|
|
1040
|
+
* Returns `meta`, or `{ name }` for an extension that only sets the deprecated `name`. Throws `KUBB_INVALID_PLUGIN_OPTIONS` when it has neither.
|
|
1041
|
+
*/
|
|
1042
|
+
function resolveMeta({ name, meta }) {
|
|
1043
|
+
if (meta) return meta;
|
|
1044
|
+
if (name) return { name };
|
|
1045
|
+
throw new Diagnostics.Error({
|
|
1046
|
+
code: Diagnostics.code.invalidPluginOptions,
|
|
1047
|
+
severity: "error",
|
|
1048
|
+
message: "An extension has neither `meta.name` nor `name`.",
|
|
1049
|
+
help: "Set `meta: { name }` on the plugin or parser.",
|
|
1050
|
+
location: { kind: "config" }
|
|
1051
|
+
});
|
|
1052
|
+
}
|
|
1053
|
+
/**
|
|
1054
|
+
* Throws `KUBB_INCOMPATIBLE_EXTENSION` when the running Kubb or Node.js version is outside `meta.compatibility`.
|
|
1055
|
+
*/
|
|
1056
|
+
function checkCompatibility(meta) {
|
|
1057
|
+
const checks = [{
|
|
1058
|
+
target: "Kubb",
|
|
1059
|
+
range: meta.compatibility?.kubb,
|
|
1060
|
+
version
|
|
1061
|
+
}, {
|
|
1062
|
+
target: "Node.js",
|
|
1063
|
+
range: meta.compatibility?.node,
|
|
1064
|
+
version: process.versions.node
|
|
1065
|
+
}];
|
|
1066
|
+
for (const { target, range, version } of checks) {
|
|
1067
|
+
if (!range || (0, verkit.satisfies)(version, range, { includePrerelease: true })) continue;
|
|
1068
|
+
throw new Diagnostics.Error({
|
|
1069
|
+
code: Diagnostics.code.incompatibleExtension,
|
|
1070
|
+
severity: "error",
|
|
1071
|
+
message: `"${meta.name}" requires ${target} ${range}, but ${version} is running.`,
|
|
1072
|
+
help: `Use a ${target} version that satisfies ${range}, or a version of "${meta.name}" that supports ${target} ${version}.`,
|
|
1073
|
+
location: { kind: "config" },
|
|
1074
|
+
plugin: meta.name
|
|
1075
|
+
});
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
/**
|
|
1079
|
+
* Throws `KUBB_MISSING_DEPENDENCY` for a missing required entry in a `dependencies` record, and
|
|
1080
|
+
* `KUBB_INCOMPATIBLE_DEPENDENCY` when an entry's `meta.version` is out of range. Arrays are not checked.
|
|
1081
|
+
*/
|
|
1082
|
+
function checkDependencies({ name, dependencies, plugins }) {
|
|
1083
|
+
if (!dependencies || Array.isArray(dependencies)) return;
|
|
1084
|
+
for (const [dependencyName, dependency] of Object.entries(dependencies)) {
|
|
1085
|
+
const target = plugins.get(dependencyName);
|
|
1086
|
+
if (!target) {
|
|
1087
|
+
if (dependency?.optional) continue;
|
|
1088
|
+
throw new Diagnostics.Error({
|
|
1089
|
+
code: Diagnostics.code.missingDependency,
|
|
1090
|
+
severity: "error",
|
|
1091
|
+
message: `Plugin "${dependencyName}" is required by "${name}" but not found.`,
|
|
1092
|
+
help: `Add "${dependencyName}" to the \`plugins\` array in kubb.config.ts.`,
|
|
1093
|
+
location: { kind: "config" },
|
|
1094
|
+
plugin: name
|
|
1095
|
+
});
|
|
1096
|
+
}
|
|
1097
|
+
const range = dependency?.version;
|
|
1098
|
+
const version = target.meta?.version;
|
|
1099
|
+
if (!range || !version || (0, verkit.satisfies)(version, range, { includePrerelease: true })) continue;
|
|
1100
|
+
throw new Diagnostics.Error({
|
|
1101
|
+
code: Diagnostics.code.incompatibleDependency,
|
|
1102
|
+
severity: "error",
|
|
1103
|
+
message: `"${name}" requires "${dependencyName}" ${range}, but ${version} is configured.`,
|
|
1104
|
+
help: `Install a version of "${dependencyName}" that satisfies ${range}.`,
|
|
1105
|
+
location: { kind: "config" },
|
|
1106
|
+
plugin: name
|
|
1107
|
+
});
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
function defineExtension({ kind, meta, build }) {
|
|
1111
|
+
const factory = (options) => build(options ?? {});
|
|
1112
|
+
return Object.assign(factory, meta ? {
|
|
1113
|
+
kind,
|
|
1114
|
+
meta
|
|
1115
|
+
} : { kind });
|
|
1116
|
+
}
|
|
1117
|
+
//#endregion
|
|
915
1118
|
//#region src/definePlugin.ts
|
|
916
1119
|
/**
|
|
917
1120
|
* Merges the `output.mode` default into the output config and validates the combination.
|
|
@@ -951,30 +1154,31 @@ function assertPluginOption({ plugin, option, value, allowed }) {
|
|
|
951
1154
|
plugin
|
|
952
1155
|
});
|
|
953
1156
|
}
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
1157
|
+
function definePlugin(input) {
|
|
1158
|
+
if (typeof input === "function") return defineExtension({
|
|
1159
|
+
kind: "plugin",
|
|
1160
|
+
build: (options) => {
|
|
1161
|
+
const plugin = input(options);
|
|
1162
|
+
return {
|
|
1163
|
+
...plugin,
|
|
1164
|
+
meta: resolveMeta(plugin)
|
|
1165
|
+
};
|
|
1166
|
+
}
|
|
1167
|
+
});
|
|
1168
|
+
const { meta, dependencies, enforce, hooks = {}, setup } = input;
|
|
1169
|
+
return defineExtension({
|
|
1170
|
+
kind: "plugin",
|
|
1171
|
+
meta,
|
|
1172
|
+
build: (options) => ({
|
|
1173
|
+
name: meta.name,
|
|
1174
|
+
meta,
|
|
1175
|
+
options,
|
|
1176
|
+
dependencies,
|
|
1177
|
+
enforce,
|
|
1178
|
+
hooks,
|
|
1179
|
+
setup
|
|
1180
|
+
})
|
|
1181
|
+
});
|
|
978
1182
|
}
|
|
979
1183
|
//#endregion
|
|
980
1184
|
//#region src/input.ts
|
|
@@ -2011,23 +2215,34 @@ var KubbDriver = class {
|
|
|
2011
2215
|
this.adapter = config.adapter ?? null;
|
|
2012
2216
|
}
|
|
2013
2217
|
/**
|
|
2014
|
-
* Normalizes every configured plugin, orders them, and registers their lifecycle handlers.
|
|
2218
|
+
* Normalizes and checks every configured plugin, orders them, and registers their lifecycle handlers.
|
|
2015
2219
|
* A plugin that another lists as a dependency runs first, then `enforce: 'pre'` before
|
|
2016
2220
|
* `'post'`. When the config has an adapter, the adapter source is resolved from the input
|
|
2017
2221
|
* so `run` can parse it later.
|
|
2018
2222
|
*/
|
|
2019
2223
|
async setup() {
|
|
2020
2224
|
this.options.signal?.throwIfAborted();
|
|
2225
|
+
for (const parser of this.config.parsers) if (parser.meta) checkCompatibility(parser.meta);
|
|
2021
2226
|
const normalized = this.#sortPlugins(this.config.plugins.map((rawPlugin) => {
|
|
2227
|
+
if (rawPlugin.meta) checkCompatibility(rawPlugin.meta);
|
|
2228
|
+
const meta = resolveMeta(rawPlugin);
|
|
2022
2229
|
return {
|
|
2023
|
-
name:
|
|
2024
|
-
|
|
2230
|
+
name: meta.name,
|
|
2231
|
+
meta,
|
|
2232
|
+
dependencies: typeof rawPlugin.dependencies === "function" ? rawPlugin.dependencies(rawPlugin.options ?? {}, { config: this.config }) : rawPlugin.dependencies,
|
|
2025
2233
|
enforce: rawPlugin.enforce,
|
|
2026
2234
|
hooks: rawPlugin.hooks,
|
|
2235
|
+
setup: rawPlugin.setup,
|
|
2027
2236
|
options: rawPlugin.options ?? defaultPluginOptions(),
|
|
2028
|
-
resolver: createResolver({ pluginName:
|
|
2237
|
+
resolver: createResolver({ pluginName: meta.name })
|
|
2029
2238
|
};
|
|
2030
2239
|
}));
|
|
2240
|
+
const byName = new Map(normalized.map((plugin) => [plugin.name, plugin]));
|
|
2241
|
+
for (const plugin of normalized) checkDependencies({
|
|
2242
|
+
name: plugin.name,
|
|
2243
|
+
dependencies: plugin.dependencies,
|
|
2244
|
+
plugins: byName
|
|
2245
|
+
});
|
|
2031
2246
|
for (const plugin of normalized) {
|
|
2032
2247
|
this.#registerPlugin(plugin);
|
|
2033
2248
|
this.plugins.set(plugin.name, plugin);
|
|
@@ -2045,7 +2260,10 @@ var KubbDriver = class {
|
|
|
2045
2260
|
#sortPlugins(plugins) {
|
|
2046
2261
|
const queue = [...plugins].sort((a, b) => enforceWeight(a) - enforceWeight(b));
|
|
2047
2262
|
const names = new Set(queue.map((plugin) => plugin.name));
|
|
2048
|
-
const blockedBy = new Map(queue.map((plugin) =>
|
|
2263
|
+
const blockedBy = new Map(queue.map((plugin) => {
|
|
2264
|
+
const dependencies = Array.isArray(plugin.dependencies) ? plugin.dependencies : Object.keys(plugin.dependencies ?? {});
|
|
2265
|
+
return [plugin.name, new Set(dependencies.filter((name) => names.has(name) && name !== plugin.name))];
|
|
2266
|
+
}));
|
|
2049
2267
|
const sorted = [];
|
|
2050
2268
|
for (const _ of plugins) {
|
|
2051
2269
|
const index = queue.findIndex((plugin) => blockedBy.get(plugin.name)?.size === 0);
|
|
@@ -2090,41 +2308,45 @@ var KubbDriver = class {
|
|
|
2090
2308
|
this.#unhooks.push(this.hooks.addHooks(configHooks));
|
|
2091
2309
|
}
|
|
2092
2310
|
/**
|
|
2093
|
-
* Runs each plugin's `kubb:plugin:setup` handler, in plugin order, with a context scoped to that
|
|
2311
|
+
* Runs each plugin's `setup` and `kubb:plugin:setup` handler, in plugin order, with a context scoped to that
|
|
2094
2312
|
* plugin so `addGenerator`, `setResolver`, `addMacro`, `setMacros`, and `setOptions` target its
|
|
2095
2313
|
* `NormalizedPlugin` entry. Called once from `run` before the plugin execution loop begins, so
|
|
2096
2314
|
* plugins can configure generators, resolvers, macros, and options before `buildStart`.
|
|
2097
2315
|
*/
|
|
2098
2316
|
async setupHooks() {
|
|
2099
2317
|
for (const plugin of this.plugins.values()) {
|
|
2100
|
-
const
|
|
2101
|
-
if (!setup) continue;
|
|
2318
|
+
const setupHook = plugin.hooks?.["kubb:plugin:setup"];
|
|
2319
|
+
if (!plugin.setup && !setupHook) continue;
|
|
2320
|
+
const ctx = {
|
|
2321
|
+
config: this.config,
|
|
2322
|
+
options: plugin.options ?? {},
|
|
2323
|
+
addGenerator: (...generators) => {
|
|
2324
|
+
plugin.generators = [...plugin.generators ?? [], ...generators];
|
|
2325
|
+
},
|
|
2326
|
+
setResolver: (resolver) => {
|
|
2327
|
+
plugin.resolver = Resolver.merge(createResolver({ pluginName: plugin.name }), resolver);
|
|
2328
|
+
},
|
|
2329
|
+
addMacro: (macro) => {
|
|
2330
|
+
this.#transforms.add(plugin.name, macro);
|
|
2331
|
+
},
|
|
2332
|
+
setMacros: (macros) => {
|
|
2333
|
+
this.#transforms.set(plugin.name, macros);
|
|
2334
|
+
},
|
|
2335
|
+
setOptions: (opts) => {
|
|
2336
|
+
plugin.options = normalizePluginOptions({
|
|
2337
|
+
...plugin.options,
|
|
2338
|
+
...opts
|
|
2339
|
+
}, plugin.name);
|
|
2340
|
+
},
|
|
2341
|
+
injectFile: (userFileNode) => {
|
|
2342
|
+
this.fileManager.add(_kubb_ast.ast.factory.createFile(userFileNode));
|
|
2343
|
+
},
|
|
2344
|
+
requirePlugin: ((name) => this.requirePlugin(name, { requiredBy: plugin.name }))
|
|
2345
|
+
};
|
|
2102
2346
|
try {
|
|
2103
|
-
await
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
addGenerator: (...generators) => {
|
|
2107
|
-
plugin.generators = [...plugin.generators ?? [], ...generators];
|
|
2108
|
-
},
|
|
2109
|
-
setResolver: (resolver) => {
|
|
2110
|
-
plugin.resolver = Resolver.merge(createResolver({ pluginName: plugin.name }), resolver);
|
|
2111
|
-
},
|
|
2112
|
-
addMacro: (macro) => {
|
|
2113
|
-
this.#transforms.add(plugin.name, macro);
|
|
2114
|
-
},
|
|
2115
|
-
setMacros: (macros) => {
|
|
2116
|
-
this.#transforms.set(plugin.name, macros);
|
|
2117
|
-
},
|
|
2118
|
-
setOptions: (opts) => {
|
|
2119
|
-
plugin.options = normalizePluginOptions({
|
|
2120
|
-
...plugin.options,
|
|
2121
|
-
...opts
|
|
2122
|
-
}, plugin.name);
|
|
2123
|
-
},
|
|
2124
|
-
injectFile: (userFileNode) => {
|
|
2125
|
-
this.fileManager.add(_kubb_ast.ast.factory.createFile(userFileNode));
|
|
2126
|
-
},
|
|
2127
|
-
requirePlugin: ((name) => this.requirePlugin(name, { requiredBy: plugin.name }))
|
|
2347
|
+
await kubbContext.run(ctx, async () => {
|
|
2348
|
+
if (plugin.setup) plugin.options = normalizePluginOptions(await plugin.setup(ctx.options, ctx), plugin.name);
|
|
2349
|
+
await setupHook?.(ctx);
|
|
2128
2350
|
});
|
|
2129
2351
|
} catch (caughtError) {
|
|
2130
2352
|
const diagnostic = Diagnostics.from(caughtError);
|
|
@@ -2631,6 +2853,18 @@ Object.defineProperty(exports, "_usingCtx", {
|
|
|
2631
2853
|
return _usingCtx;
|
|
2632
2854
|
}
|
|
2633
2855
|
});
|
|
2856
|
+
Object.defineProperty(exports, "addGenerator", {
|
|
2857
|
+
enumerable: true,
|
|
2858
|
+
get: function() {
|
|
2859
|
+
return addGenerator;
|
|
2860
|
+
}
|
|
2861
|
+
});
|
|
2862
|
+
Object.defineProperty(exports, "addMacro", {
|
|
2863
|
+
enumerable: true,
|
|
2864
|
+
get: function() {
|
|
2865
|
+
return addMacro;
|
|
2866
|
+
}
|
|
2867
|
+
});
|
|
2634
2868
|
Object.defineProperty(exports, "assertPluginOption", {
|
|
2635
2869
|
enumerable: true,
|
|
2636
2870
|
get: function() {
|
|
@@ -2661,6 +2895,12 @@ Object.defineProperty(exports, "createResolver", {
|
|
|
2661
2895
|
return createResolver;
|
|
2662
2896
|
}
|
|
2663
2897
|
});
|
|
2898
|
+
Object.defineProperty(exports, "defineExtension", {
|
|
2899
|
+
enumerable: true,
|
|
2900
|
+
get: function() {
|
|
2901
|
+
return defineExtension;
|
|
2902
|
+
}
|
|
2903
|
+
});
|
|
2664
2904
|
Object.defineProperty(exports, "definePlugin", {
|
|
2665
2905
|
enumerable: true,
|
|
2666
2906
|
get: function() {
|
|
@@ -2697,12 +2937,24 @@ Object.defineProperty(exports, "inParallel", {
|
|
|
2697
2937
|
return inParallel;
|
|
2698
2938
|
}
|
|
2699
2939
|
});
|
|
2940
|
+
Object.defineProperty(exports, "injectFile", {
|
|
2941
|
+
enumerable: true,
|
|
2942
|
+
get: function() {
|
|
2943
|
+
return injectFile;
|
|
2944
|
+
}
|
|
2945
|
+
});
|
|
2700
2946
|
Object.defineProperty(exports, "isPathInside", {
|
|
2701
2947
|
enumerable: true,
|
|
2702
2948
|
get: function() {
|
|
2703
2949
|
return isPathInside;
|
|
2704
2950
|
}
|
|
2705
2951
|
});
|
|
2952
|
+
Object.defineProperty(exports, "kubbContext", {
|
|
2953
|
+
enumerable: true,
|
|
2954
|
+
get: function() {
|
|
2955
|
+
return kubbContext;
|
|
2956
|
+
}
|
|
2957
|
+
});
|
|
2706
2958
|
Object.defineProperty(exports, "pluginNotFoundError", {
|
|
2707
2959
|
enumerable: true,
|
|
2708
2960
|
get: function() {
|
|
@@ -2715,6 +2967,36 @@ Object.defineProperty(exports, "read", {
|
|
|
2715
2967
|
return read;
|
|
2716
2968
|
}
|
|
2717
2969
|
});
|
|
2970
|
+
Object.defineProperty(exports, "requirePlugin", {
|
|
2971
|
+
enumerable: true,
|
|
2972
|
+
get: function() {
|
|
2973
|
+
return requirePlugin;
|
|
2974
|
+
}
|
|
2975
|
+
});
|
|
2976
|
+
Object.defineProperty(exports, "resolveMeta", {
|
|
2977
|
+
enumerable: true,
|
|
2978
|
+
get: function() {
|
|
2979
|
+
return resolveMeta;
|
|
2980
|
+
}
|
|
2981
|
+
});
|
|
2982
|
+
Object.defineProperty(exports, "setMacros", {
|
|
2983
|
+
enumerable: true,
|
|
2984
|
+
get: function() {
|
|
2985
|
+
return setMacros;
|
|
2986
|
+
}
|
|
2987
|
+
});
|
|
2988
|
+
Object.defineProperty(exports, "setOptions", {
|
|
2989
|
+
enumerable: true,
|
|
2990
|
+
get: function() {
|
|
2991
|
+
return setOptions;
|
|
2992
|
+
}
|
|
2993
|
+
});
|
|
2994
|
+
Object.defineProperty(exports, "setResolver", {
|
|
2995
|
+
enumerable: true,
|
|
2996
|
+
get: function() {
|
|
2997
|
+
return setResolver;
|
|
2998
|
+
}
|
|
2999
|
+
});
|
|
2718
3000
|
Object.defineProperty(exports, "toError", {
|
|
2719
3001
|
enumerable: true,
|
|
2720
3002
|
get: function() {
|
|
@@ -2727,6 +3009,30 @@ Object.defineProperty(exports, "toPosixPath", {
|
|
|
2727
3009
|
return toPosixPath;
|
|
2728
3010
|
}
|
|
2729
3011
|
});
|
|
3012
|
+
Object.defineProperty(exports, "tryUseKubb", {
|
|
3013
|
+
enumerable: true,
|
|
3014
|
+
get: function() {
|
|
3015
|
+
return tryUseKubb;
|
|
3016
|
+
}
|
|
3017
|
+
});
|
|
3018
|
+
Object.defineProperty(exports, "useConfig", {
|
|
3019
|
+
enumerable: true,
|
|
3020
|
+
get: function() {
|
|
3021
|
+
return useConfig;
|
|
3022
|
+
}
|
|
3023
|
+
});
|
|
3024
|
+
Object.defineProperty(exports, "useKubb", {
|
|
3025
|
+
enumerable: true,
|
|
3026
|
+
get: function() {
|
|
3027
|
+
return useKubb;
|
|
3028
|
+
}
|
|
3029
|
+
});
|
|
3030
|
+
Object.defineProperty(exports, "useOptions", {
|
|
3031
|
+
enumerable: true,
|
|
3032
|
+
get: function() {
|
|
3033
|
+
return useOptions;
|
|
3034
|
+
}
|
|
3035
|
+
});
|
|
2730
3036
|
Object.defineProperty(exports, "write", {
|
|
2731
3037
|
enumerable: true,
|
|
2732
3038
|
get: function() {
|
|
@@ -2734,4 +3040,4 @@ Object.defineProperty(exports, "write", {
|
|
|
2734
3040
|
}
|
|
2735
3041
|
});
|
|
2736
3042
|
|
|
2737
|
-
//# sourceMappingURL=KubbDriver-
|
|
3043
|
+
//# sourceMappingURL=KubbDriver-BcoHguLM.cjs.map
|