@kubb/core 5.0.0-beta.96 → 5.0.0-beta.98
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/index.cjs +38 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +38 -21
- 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-DQlIpfWN.d.ts → types-CK6CfipY.d.ts} +10 -1
- package/dist/{usingCtx-BriKju-v.js → usingCtx-BNggxUEL.js} +24 -4
- package/dist/usingCtx-BNggxUEL.js.map +1 -0
- package/dist/{usingCtx-eyNeehd2.cjs → usingCtx-CZyLSqds.cjs} +28 -2
- package/dist/usingCtx-CZyLSqds.cjs.map +1 -0
- package/package.json +2 -2
- package/dist/usingCtx-BriKju-v.js.map +0 -1
- package/dist/usingCtx-eyNeehd2.cjs.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
|
|
2
|
-
import { $ as definePlugin, A as Generator, At as DiagnosticSeverity, B as Include, Bt as AdapterSource, C as KubbWarnContext, Ct as UserReporter, D as CreateKubbOptions, Dt as DiagnosticDoc, E as UserConfig, Et as Diagnostic, F as Parser, Ft as SerializedDiagnostic, G as Output, H as KubbPluginSetupContext, I as defineParser, It as UpdateDiagnostic, J as Override, K as OutputMode, L as Exclude, Lt as Hookable, M as defineGenerator, Mt as PerformanceDiagnostic, N as KubbDriver, Nt as ProblemCode, O as Kubb, Ot as DiagnosticKind, P as FileManagerHooks, Pt as ProblemDiagnostic, Q as ResolvePluginOptions, R as Filter, Rt as Adapter, S as KubbSuccessContext, St as ReporterName, T as PostGenerateCommand, Tt as logLevel, U as KubbPluginStartContext, V as KubbPluginEndContext, Vt as createAdapter, W as NormalizedPlugin, X as PluginFactoryOptions, Y as Plugin, Z as PluginName, _ as KubbHookStartContext, _t as Storage, a as KubbBuildEndContext, at as ResolveOptionsContext, b as KubbLifecycleStartContext, bt as Reporter, c as KubbErrorContext, ct as ResolverDefault, d as KubbFilesProcessingStartContext, dt as ResolverFilePathParams, et as BannerMeta, f as KubbFilesProcessingUpdateContext, ft as ResolverPatch, g as KubbHookLineContext, gt as createRenderer, h as KubbHookEndContext, ht as RendererFactory, i as Input, it as ResolveImportsOptions, j as GeneratorContext, jt as Diagnostics, k as createKubb, kt as DiagnosticLocation, l as KubbFileProcessingUpdate, lt as ResolverFile, m as KubbGenerationStartContext, mt as Renderer, n as CLIOptions, nt as ResolveBannerFile, o as KubbBuildStartContext, ot as ResolvePathOptions, p as KubbGenerationEndContext, pt as ResolverPathParams, q as OutputOptions, r as Config, rt as ResolveFileOptions, s as KubbDiagnosticContext, st as Resolver, t as BuildOutput, tt as ResolveBannerContext, u as KubbFilesProcessingEndContext, ut as ResolverFileParams, v as KubbHooks, vt as createStorage, w as PossibleConfig, wt as createReporter, x as KubbPluginsEndContext, xt as ReporterContext, y as KubbInfoContext, yt as GenerationResult, z as Group, zt as AdapterFactoryOptions } from "./types-
|
|
2
|
+
import { $ as definePlugin, A as Generator, At as DiagnosticSeverity, B as Include, Bt as AdapterSource, C as KubbWarnContext, Ct as UserReporter, D as CreateKubbOptions, Dt as DiagnosticDoc, E as UserConfig, Et as Diagnostic, F as Parser, Ft as SerializedDiagnostic, G as Output, H as KubbPluginSetupContext, I as defineParser, It as UpdateDiagnostic, J as Override, K as OutputMode, L as Exclude, Lt as Hookable, M as defineGenerator, Mt as PerformanceDiagnostic, N as KubbDriver, Nt as ProblemCode, O as Kubb, Ot as DiagnosticKind, P as FileManagerHooks, Pt as ProblemDiagnostic, Q as ResolvePluginOptions, R as Filter, Rt as Adapter, S as KubbSuccessContext, St as ReporterName, T as PostGenerateCommand, Tt as logLevel, U as KubbPluginStartContext, V as KubbPluginEndContext, Vt as createAdapter, W as NormalizedPlugin, X as PluginFactoryOptions, Y as Plugin, Z as PluginName, _ as KubbHookStartContext, _t as Storage, a as KubbBuildEndContext, at as ResolveOptionsContext, b as KubbLifecycleStartContext, bt as Reporter, c as KubbErrorContext, ct as ResolverDefault, d as KubbFilesProcessingStartContext, dt as ResolverFilePathParams, et as BannerMeta, f as KubbFilesProcessingUpdateContext, ft as ResolverPatch, g as KubbHookLineContext, gt as createRenderer, h as KubbHookEndContext, ht as RendererFactory, i as Input, it as ResolveImportsOptions, j as GeneratorContext, jt as Diagnostics, k as createKubb, kt as DiagnosticLocation, l as KubbFileProcessingUpdate, lt as ResolverFile, m as KubbGenerationStartContext, mt as Renderer, n as CLIOptions, nt as ResolveBannerFile, o as KubbBuildStartContext, ot as ResolvePathOptions, p as KubbGenerationEndContext, pt as ResolverPathParams, q as OutputOptions, r as Config, rt as ResolveFileOptions, s as KubbDiagnosticContext, st as Resolver, t as BuildOutput, tt as ResolveBannerContext, u as KubbFilesProcessingEndContext, ut as ResolverFileParams, v as KubbHooks, vt as createStorage, w as PossibleConfig, wt as createReporter, x as KubbPluginsEndContext, xt as ReporterContext, y as KubbInfoContext, yt as GenerationResult, z as Group, zt as AdapterFactoryOptions } from "./types-CK6CfipY.js";
|
|
3
3
|
//#region src/applyConfigDefaults.d.ts
|
|
4
4
|
type ApplyConfigDefaultsOptions<TOutput> = {
|
|
5
5
|
defaultAdapter: Adapter;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./rolldown-runtime-C0LytTxp.js";
|
|
2
|
-
import { a as
|
|
2
|
+
import { a as isPathInside, c as write, d as toError, f as camelCase, i as clean, l as BuildError, n as FileManager, o as toFilePath, r as Hookable, s as toPosixPath, t as _usingCtx, u as getErrorMessage } from "./usingCtx-BNggxUEL.js";
|
|
3
3
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
4
4
|
import { stripVTControlCharacters, styleText } from "node:util";
|
|
5
5
|
import { hash } from "node:crypto";
|
|
@@ -189,7 +189,7 @@ function memoize(store, factory) {
|
|
|
189
189
|
}
|
|
190
190
|
//#endregion
|
|
191
191
|
//#region package.json
|
|
192
|
-
var version = "5.0.0-beta.
|
|
192
|
+
var version = "5.0.0-beta.98";
|
|
193
193
|
//#endregion
|
|
194
194
|
//#region src/constants.ts
|
|
195
195
|
/**
|
|
@@ -267,6 +267,11 @@ const diagnosticCode = {
|
|
|
267
267
|
*/
|
|
268
268
|
pathTraversal: "KUBB_PATH_TRAVERSAL",
|
|
269
269
|
/**
|
|
270
|
+
* `output.clean` is enabled but `output.path` resolves to the project root or a parent of it,
|
|
271
|
+
* so cleaning would delete kubb.config and every source file.
|
|
272
|
+
*/
|
|
273
|
+
cleanRoot: "KUBB_CLEAN_ROOT",
|
|
274
|
+
/**
|
|
270
275
|
* A plugin's options are invalid, for example `output.mode: 'file'` paired with a `group` option.
|
|
271
276
|
*/
|
|
272
277
|
invalidPluginOptions: "KUBB_INVALID_PLUGIN_OPTIONS",
|
|
@@ -414,6 +419,11 @@ const diagnosticCatalog = {
|
|
|
414
419
|
cause: "A resolved output path escaped the output directory, which can stem from a path traversal in the spec or a misconfigured `group.name`.",
|
|
415
420
|
fix: "Keep generated paths within the output directory. Review the `group.name` function and the names coming from the spec."
|
|
416
421
|
},
|
|
422
|
+
[diagnosticCode.cleanRoot]: {
|
|
423
|
+
title: "Clean targets the project root",
|
|
424
|
+
cause: "`output.clean` is enabled and `output.path` resolves to the project root or a parent of it, so cleaning would delete `kubb.config` and every source file.",
|
|
425
|
+
fix: "Point `output.path` at a subdirectory such as `./src/gen` so clean only removes generated code, or disable `output.clean`."
|
|
426
|
+
},
|
|
417
427
|
[diagnosticCode.invalidPluginOptions]: {
|
|
418
428
|
title: "Invalid plugin options",
|
|
419
429
|
cause: "A plugin was configured with options that cannot be honored, for example `output.mode: 'file'` paired with a `group` option.",
|
|
@@ -1498,27 +1508,24 @@ var KubbDriver = class {
|
|
|
1498
1508
|
async run() {
|
|
1499
1509
|
const { hooks, config, fileManager } = this;
|
|
1500
1510
|
const diagnostics = [];
|
|
1511
|
+
const updateBuffer = [];
|
|
1501
1512
|
const parsersMap = /* @__PURE__ */ new Map();
|
|
1502
1513
|
for (const parser of config.parsers) if (parser.extNames) for (const ext of parser.extNames) parsersMap.set(ext, parser);
|
|
1503
|
-
const onWriteStart = async (files) => {
|
|
1504
|
-
await hooks.callHook("kubb:files:processing:start", { files });
|
|
1505
|
-
};
|
|
1506
|
-
const updateBuffer = [];
|
|
1507
|
-
const onWriteUpdate = (item) => {
|
|
1508
|
-
updateBuffer.push(item);
|
|
1509
|
-
};
|
|
1510
|
-
const onWriteEnd = async (files) => {
|
|
1511
|
-
await hooks.callHook("kubb:files:processing:update", { files: updateBuffer.map((item) => ({
|
|
1512
|
-
...item,
|
|
1513
|
-
config
|
|
1514
|
-
})) });
|
|
1515
|
-
updateBuffer.length = 0;
|
|
1516
|
-
await hooks.callHook("kubb:files:processing:end", { files });
|
|
1517
|
-
};
|
|
1518
1514
|
const unhookWrites = fileManager.hooks.addHooks({
|
|
1519
|
-
start:
|
|
1520
|
-
|
|
1521
|
-
|
|
1515
|
+
start: async (files) => {
|
|
1516
|
+
await hooks.callHook("kubb:files:processing:start", { files });
|
|
1517
|
+
},
|
|
1518
|
+
update: (item) => {
|
|
1519
|
+
updateBuffer.push(item);
|
|
1520
|
+
},
|
|
1521
|
+
end: async (files) => {
|
|
1522
|
+
await hooks.callHook("kubb:files:processing:update", { files: updateBuffer.map((item) => ({
|
|
1523
|
+
...item,
|
|
1524
|
+
config
|
|
1525
|
+
})) });
|
|
1526
|
+
updateBuffer.length = 0;
|
|
1527
|
+
await hooks.callHook("kubb:files:processing:end", { files });
|
|
1528
|
+
}
|
|
1522
1529
|
});
|
|
1523
1530
|
return Diagnostics.scope((diagnostic) => diagnostics.push(diagnostic), async () => {
|
|
1524
1531
|
try {
|
|
@@ -2092,7 +2099,17 @@ var Kubb = class {
|
|
|
2092
2099
|
const config = this.config;
|
|
2093
2100
|
const driver = new KubbDriver(config, { hooks: this.hooks });
|
|
2094
2101
|
this.hooks.setMaxListeners(Math.max(10, config.plugins.length * 4));
|
|
2095
|
-
if (config.output.clean)
|
|
2102
|
+
if (config.output.clean) {
|
|
2103
|
+
const cleanPath = resolve(config.root, config.output.path);
|
|
2104
|
+
if (isPathInside(config.root, cleanPath)) throw new Diagnostics.Error({
|
|
2105
|
+
code: Diagnostics.code.cleanRoot,
|
|
2106
|
+
severity: "error",
|
|
2107
|
+
message: `output.clean cannot delete "${cleanPath}" because it is the project root or a parent of it.`,
|
|
2108
|
+
help: "Point `output.path` at a subdirectory such as `./src/gen` so clean only removes generated code.",
|
|
2109
|
+
location: { kind: "config" }
|
|
2110
|
+
});
|
|
2111
|
+
await config.storage.clear(cleanPath);
|
|
2112
|
+
}
|
|
2096
2113
|
await driver.setup();
|
|
2097
2114
|
this.#driver = driver;
|
|
2098
2115
|
this.#storage = config.storage;
|