@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.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_usingCtx = require("./usingCtx-
|
|
2
|
+
const require_usingCtx = require("./usingCtx-CZyLSqds.cjs");
|
|
3
3
|
let node_async_hooks = require("node:async_hooks");
|
|
4
4
|
let node_util = require("node:util");
|
|
5
5
|
let node_crypto = require("node:crypto");
|
|
@@ -191,7 +191,7 @@ function memoize(store, factory) {
|
|
|
191
191
|
}
|
|
192
192
|
//#endregion
|
|
193
193
|
//#region package.json
|
|
194
|
-
var version = "5.0.0-beta.
|
|
194
|
+
var version = "5.0.0-beta.98";
|
|
195
195
|
//#endregion
|
|
196
196
|
//#region src/constants.ts
|
|
197
197
|
/**
|
|
@@ -269,6 +269,11 @@ const diagnosticCode = {
|
|
|
269
269
|
*/
|
|
270
270
|
pathTraversal: "KUBB_PATH_TRAVERSAL",
|
|
271
271
|
/**
|
|
272
|
+
* `output.clean` is enabled but `output.path` resolves to the project root or a parent of it,
|
|
273
|
+
* so cleaning would delete kubb.config and every source file.
|
|
274
|
+
*/
|
|
275
|
+
cleanRoot: "KUBB_CLEAN_ROOT",
|
|
276
|
+
/**
|
|
272
277
|
* A plugin's options are invalid, for example `output.mode: 'file'` paired with a `group` option.
|
|
273
278
|
*/
|
|
274
279
|
invalidPluginOptions: "KUBB_INVALID_PLUGIN_OPTIONS",
|
|
@@ -416,6 +421,11 @@ const diagnosticCatalog = {
|
|
|
416
421
|
cause: "A resolved output path escaped the output directory, which can stem from a path traversal in the spec or a misconfigured `group.name`.",
|
|
417
422
|
fix: "Keep generated paths within the output directory. Review the `group.name` function and the names coming from the spec."
|
|
418
423
|
},
|
|
424
|
+
[diagnosticCode.cleanRoot]: {
|
|
425
|
+
title: "Clean targets the project root",
|
|
426
|
+
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.",
|
|
427
|
+
fix: "Point `output.path` at a subdirectory such as `./src/gen` so clean only removes generated code, or disable `output.clean`."
|
|
428
|
+
},
|
|
419
429
|
[diagnosticCode.invalidPluginOptions]: {
|
|
420
430
|
title: "Invalid plugin options",
|
|
421
431
|
cause: "A plugin was configured with options that cannot be honored, for example `output.mode: 'file'` paired with a `group` option.",
|
|
@@ -1500,27 +1510,24 @@ var KubbDriver = class {
|
|
|
1500
1510
|
async run() {
|
|
1501
1511
|
const { hooks, config, fileManager } = this;
|
|
1502
1512
|
const diagnostics = [];
|
|
1513
|
+
const updateBuffer = [];
|
|
1503
1514
|
const parsersMap = /* @__PURE__ */ new Map();
|
|
1504
1515
|
for (const parser of config.parsers) if (parser.extNames) for (const ext of parser.extNames) parsersMap.set(ext, parser);
|
|
1505
|
-
const onWriteStart = async (files) => {
|
|
1506
|
-
await hooks.callHook("kubb:files:processing:start", { files });
|
|
1507
|
-
};
|
|
1508
|
-
const updateBuffer = [];
|
|
1509
|
-
const onWriteUpdate = (item) => {
|
|
1510
|
-
updateBuffer.push(item);
|
|
1511
|
-
};
|
|
1512
|
-
const onWriteEnd = async (files) => {
|
|
1513
|
-
await hooks.callHook("kubb:files:processing:update", { files: updateBuffer.map((item) => ({
|
|
1514
|
-
...item,
|
|
1515
|
-
config
|
|
1516
|
-
})) });
|
|
1517
|
-
updateBuffer.length = 0;
|
|
1518
|
-
await hooks.callHook("kubb:files:processing:end", { files });
|
|
1519
|
-
};
|
|
1520
1516
|
const unhookWrites = fileManager.hooks.addHooks({
|
|
1521
|
-
start:
|
|
1522
|
-
|
|
1523
|
-
|
|
1517
|
+
start: async (files) => {
|
|
1518
|
+
await hooks.callHook("kubb:files:processing:start", { files });
|
|
1519
|
+
},
|
|
1520
|
+
update: (item) => {
|
|
1521
|
+
updateBuffer.push(item);
|
|
1522
|
+
},
|
|
1523
|
+
end: async (files) => {
|
|
1524
|
+
await hooks.callHook("kubb:files:processing:update", { files: updateBuffer.map((item) => ({
|
|
1525
|
+
...item,
|
|
1526
|
+
config
|
|
1527
|
+
})) });
|
|
1528
|
+
updateBuffer.length = 0;
|
|
1529
|
+
await hooks.callHook("kubb:files:processing:end", { files });
|
|
1530
|
+
}
|
|
1524
1531
|
});
|
|
1525
1532
|
return Diagnostics.scope((diagnostic) => diagnostics.push(diagnostic), async () => {
|
|
1526
1533
|
try {
|
|
@@ -2094,7 +2101,17 @@ var Kubb = class {
|
|
|
2094
2101
|
const config = this.config;
|
|
2095
2102
|
const driver = new KubbDriver(config, { hooks: this.hooks });
|
|
2096
2103
|
this.hooks.setMaxListeners(Math.max(10, config.plugins.length * 4));
|
|
2097
|
-
if (config.output.clean)
|
|
2104
|
+
if (config.output.clean) {
|
|
2105
|
+
const cleanPath = (0, node_path.resolve)(config.root, config.output.path);
|
|
2106
|
+
if (require_usingCtx.isPathInside(config.root, cleanPath)) throw new Diagnostics.Error({
|
|
2107
|
+
code: Diagnostics.code.cleanRoot,
|
|
2108
|
+
severity: "error",
|
|
2109
|
+
message: `output.clean cannot delete "${cleanPath}" because it is the project root or a parent of it.`,
|
|
2110
|
+
help: "Point `output.path` at a subdirectory such as `./src/gen` so clean only removes generated code.",
|
|
2111
|
+
location: { kind: "config" }
|
|
2112
|
+
});
|
|
2113
|
+
await config.storage.clear(cleanPath);
|
|
2114
|
+
}
|
|
2098
2115
|
await driver.setup();
|
|
2099
2116
|
this.#driver = driver;
|
|
2100
2117
|
this.#storage = config.storage;
|