@kubb/cli 5.18.7 → 5.19.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/{Telemetry-Cbt_dJE6.cjs → Telemetry-B2TeLVo4.cjs} +2 -2
- package/dist/{Telemetry-Cbt_dJE6.cjs.map → Telemetry-B2TeLVo4.cjs.map} +1 -1
- package/dist/{Telemetry-Bf16psPO.js → Telemetry-Ctyp_EFO.js} +2 -2
- package/dist/{Telemetry-Bf16psPO.js.map → Telemetry-Ctyp_EFO.js.map} +1 -1
- package/dist/{background-Cvoxk_DQ.js → background-CByahHYn.js} +2 -2
- package/dist/{background-Cvoxk_DQ.js.map → background-CByahHYn.js.map} +1 -1
- package/dist/{background-JyYJdws1.js → background-D60rO2Lz.js} +1 -1
- package/dist/{background-3TB5Cgkv.cjs → background-D6dQxXt6.cjs} +2 -2
- package/dist/{background-3TB5Cgkv.cjs.map → background-D6dQxXt6.cjs.map} +1 -1
- package/dist/config-BKi_vTvh.js +1 -0
- package/dist/{config-DJtqFNG2.cjs → config-BU9xeaGq.cjs} +2 -2
- package/dist/{config-DJtqFNG2.cjs.map → config-BU9xeaGq.cjs.map} +1 -1
- package/dist/{config-BL4UlCHs.js → config-CGcQTdZV.js} +2 -2
- package/dist/{config-BL4UlCHs.js.map → config-CGcQTdZV.js.map} +1 -1
- package/dist/{config-BIv45u1Z.cjs → config-CkTrJD0E.cjs} +2 -2
- package/dist/{config-BIv45u1Z.cjs.map → config-CkTrJD0E.cjs.map} +1 -1
- package/dist/{config-BqDpLCPu.js → config-re864UnO.js} +4 -4
- package/dist/config-re864UnO.js.map +1 -0
- package/dist/{configFile-C_7uzuGV.cjs → configFile-B_xrd2yx.cjs} +5 -5
- package/dist/configFile-B_xrd2yx.cjs.map +1 -0
- package/dist/{configFile-B2EIouxg.js → configFile-Bh_5k4pf.js} +5 -5
- package/dist/configFile-Bh_5k4pf.js.map +1 -0
- package/dist/{fs-j84Tqpbx.js → fs-CWRKTIst.js} +83 -7
- package/dist/fs-CWRKTIst.js.map +1 -0
- package/dist/index.cjs +12 -12
- package/dist/index.js +12 -12
- package/dist/{installWithSpinner-C4gKZ7r5.js → installWithSpinner-RJhWCsgh.js} +2 -2
- package/dist/{installWithSpinner-C4gKZ7r5.js.map → installWithSpinner-RJhWCsgh.js.map} +1 -1
- package/dist/{installWithSpinner-YEtb8cNf.cjs → installWithSpinner-qjIqjyiW.cjs} +3 -3
- package/dist/{installWithSpinner-YEtb8cNf.cjs.map → installWithSpinner-qjIqjyiW.cjs.map} +1 -1
- package/dist/{mascot-ZEiXQ_LT.cjs → mascot-CLw0Qmln.cjs} +10 -6
- package/dist/{mascot-ZEiXQ_LT.cjs.map → mascot-CLw0Qmln.cjs.map} +1 -1
- package/dist/{mascot-kx6WDntR.js → mascot-b4yXsKwl.js} +10 -6
- package/dist/mascot-b4yXsKwl.js.map +1 -0
- package/dist/{mcp-DFPXRd6M.js → mcp-BrB7TJZU.js} +2 -2
- package/dist/{mcp-DFPXRd6M.js.map → mcp-BrB7TJZU.js.map} +1 -1
- package/dist/{mcp-CIMQ8g_J.cjs → mcp-D2gcpCcx.cjs} +2 -2
- package/dist/{mcp-CIMQ8g_J.cjs.map → mcp-D2gcpCcx.cjs.map} +1 -1
- package/dist/package-CcsdQpSf.js +5 -0
- package/dist/package-CcsdQpSf.js.map +1 -0
- package/dist/{package-C482iN7Y.cjs → package-DM5mr0Yc.cjs} +2 -2
- package/dist/package-DM5mr0Yc.cjs.map +1 -0
- package/dist/{reporters-De3ynr5a.js → reporters-B6p0n7s3.js} +226 -132
- package/dist/reporters-B6p0n7s3.js.map +1 -0
- package/dist/{reporters-DJPMb1-j.js → reporters-BDzKLpyo.js} +1 -1
- package/dist/{reporters-yVmLpEoU.cjs → reporters-DLK4D0js.cjs} +226 -132
- package/dist/reporters-DLK4D0js.cjs.map +1 -0
- package/dist/{run-D7AQwBWZ.cjs → run-3OxB7Zxn.cjs} +6 -6
- package/dist/{run-D7AQwBWZ.cjs.map → run-3OxB7Zxn.cjs.map} +1 -1
- package/dist/{run-D-3F2mhJ.cjs → run-4MUhIiPj.cjs} +4 -4
- package/dist/{run-D-3F2mhJ.cjs.map → run-4MUhIiPj.cjs.map} +1 -1
- package/dist/{run-w0kr76jl.cjs → run-6qjg9Twy.cjs} +9 -9
- package/dist/{run-w0kr76jl.cjs.map → run-6qjg9Twy.cjs.map} +1 -1
- package/dist/{run-BVz9vmbt.js → run-B3TuKUr4.js} +6 -6
- package/dist/{run-BVz9vmbt.js.map → run-B3TuKUr4.js.map} +1 -1
- package/dist/{run-DYr--XFw.js → run-BJiP4ib3.js} +1 -1
- package/dist/{run-B-PAQSVx.js → run-BSsTBfse.js} +7 -7
- package/dist/{run-B-PAQSVx.js.map → run-BSsTBfse.js.map} +1 -1
- package/dist/{run-puNdxNuf.cjs → run-C2lQXYrF.cjs} +74 -23
- package/dist/run-C2lQXYrF.cjs.map +1 -0
- package/dist/{run-DD1VdcpX.cjs → run-C6tE9zTS.cjs} +8 -8
- package/dist/{run-DD1VdcpX.cjs.map → run-C6tE9zTS.cjs.map} +1 -1
- package/dist/{run-jGpJxxmr.js → run-CC9TBCph.js} +5 -5
- package/dist/{run-jGpJxxmr.js.map → run-CC9TBCph.js.map} +1 -1
- package/dist/{run-D1hHaTDJ.js → run-CcWmws1R.js} +4 -4
- package/dist/{run-D1hHaTDJ.js.map → run-CcWmws1R.js.map} +1 -1
- package/dist/{run-DVbHd7qm.js → run-Cxfs1SLQ.js} +74 -23
- package/dist/run-Cxfs1SLQ.js.map +1 -0
- package/dist/{run-DwPkySke.cjs → run-D0HO6_Yr.cjs} +5 -5
- package/dist/{run-DwPkySke.cjs.map → run-D0HO6_Yr.cjs.map} +1 -1
- package/dist/{run-BjWqOCAj.js → run-D2tJP_b8.js} +2 -2
- package/dist/{run-BjWqOCAj.js.map → run-D2tJP_b8.js.map} +1 -1
- package/dist/{run-Bc34cwzh.js → run-DFOjQVMO.js} +8 -8
- package/dist/{run-Bc34cwzh.js.map → run-DFOjQVMO.js.map} +1 -1
- package/dist/{run-nSTiS72Z.js → run-Dyzva1xB.js} +8 -8
- package/dist/{run-nSTiS72Z.js.map → run-Dyzva1xB.js.map} +1 -1
- package/dist/{run-BGkdpZwR.cjs → run-ejmyJI37.cjs} +2 -2
- package/dist/{run-BGkdpZwR.cjs.map → run-ejmyJI37.cjs.map} +1 -1
- package/dist/{run-hqWFyi0N.cjs → run-lH8k2FY7.cjs} +8 -8
- package/dist/{run-hqWFyi0N.cjs.map → run-lH8k2FY7.cjs.map} +1 -1
- package/dist/{snapshot-DRyGykFq.cjs → snapshot-DdRni_x5.cjs} +5 -5
- package/dist/{snapshot-DRyGykFq.cjs.map → snapshot-DdRni_x5.cjs.map} +1 -1
- package/dist/{snapshot-eO0_VdUy.js → snapshot-DnqAAzKE.js} +5 -5
- package/dist/{snapshot-eO0_VdUy.js.map → snapshot-DnqAAzKE.js.map} +1 -1
- package/dist/{spinner-CdX9Noe9.cjs → spinner-BQgUoe7F.cjs} +93 -6
- package/dist/spinner-BQgUoe7F.cjs.map +1 -0
- package/dist/{status-NqYVjTY8.js → status-X9BNNp9F.js} +3 -3
- package/dist/{status-NqYVjTY8.js.map → status-X9BNNp9F.js.map} +1 -1
- package/dist/{status-DICY3TJQ.cjs → status-wHJjD3Fs.cjs} +3 -3
- package/dist/{status-DICY3TJQ.cjs.map → status-wHJjD3Fs.cjs.map} +1 -1
- package/dist/{studio-BfR2KY0b.cjs → studio-j4As00N6.cjs} +12 -12
- package/dist/{studio-BfR2KY0b.cjs.map → studio-j4As00N6.cjs.map} +1 -1
- package/dist/{studio-gu56JqH0.js → studio-rRSg33RE.js} +12 -12
- package/dist/{studio-gu56JqH0.js.map → studio-rRSg33RE.js.map} +1 -1
- package/dist/studioWorker.js +2 -2
- package/dist/{utils-DGopc0Bo.js → utils-DnmjcKb0.js} +5 -11
- package/dist/utils-DnmjcKb0.js.map +1 -0
- package/dist/{utils-D19HX-lE.cjs → utils-_hY0r-7x.cjs} +6 -12
- package/dist/utils-_hY0r-7x.cjs.map +1 -0
- package/dist/{validate-DoSQad-i.js → validate-CSbYneXo.js} +2 -2
- package/dist/{validate-DoSQad-i.js.map → validate-CSbYneXo.js.map} +1 -1
- package/dist/{validate-BXSS6BSO.cjs → validate-CyxoAzEK.cjs} +2 -2
- package/dist/{validate-BXSS6BSO.cjs.map → validate-CyxoAzEK.cjs.map} +1 -1
- package/package.json +7 -7
- package/dist/config-BqDpLCPu.js.map +0 -1
- package/dist/config-CGpzjjPV.js +0 -1
- package/dist/configFile-B2EIouxg.js.map +0 -1
- package/dist/configFile-C_7uzuGV.cjs.map +0 -1
- package/dist/fs-j84Tqpbx.js.map +0 -1
- package/dist/mascot-kx6WDntR.js.map +0 -1
- package/dist/package-C482iN7Y.cjs.map +0 -1
- package/dist/package-DqSfSjr4.js +0 -5
- package/dist/package-DqSfSjr4.js.map +0 -1
- package/dist/reporters-De3ynr5a.js.map +0 -1
- package/dist/reporters-yVmLpEoU.cjs.map +0 -1
- package/dist/run-DVbHd7qm.js.map +0 -1
- package/dist/run-puNdxNuf.cjs.map +0 -1
- package/dist/spinner-CdX9Noe9.cjs.map +0 -1
- package/dist/utils-D19HX-lE.cjs.map +0 -1
- package/dist/utils-DGopc0Bo.js.map +0 -1
|
@@ -1,31 +1,16 @@
|
|
|
1
1
|
import "./rolldown-runtime-BowF1xt-.js";
|
|
2
|
-
import { i as read, n as isPathInside, r as matchesStored } from "./fs-
|
|
2
|
+
import { c as inParallel, i as read, l as memo, n as isPathInside, r as matchesStored } from "./fs-CWRKTIst.js";
|
|
3
3
|
import { o as writer } from "./log-B_uVM704.js";
|
|
4
4
|
import { n as getElapsedMs, t as formatMs } from "./time-D7ONPPZf.js";
|
|
5
5
|
import { n as formatMsWithColor, t as formatBar } from "./banner-BMIxunVW.js";
|
|
6
6
|
import { n as pluralize, r as toPermissionFlag } from "./text-HYWAcipy.js";
|
|
7
7
|
import { styleText } from "node:util";
|
|
8
|
+
import { hash } from "node:crypto";
|
|
8
9
|
import process from "node:process";
|
|
9
|
-
import {
|
|
10
|
+
import { readFileSync } from "node:fs";
|
|
11
|
+
import { readFile as readFile$1, readdir } from "node:fs/promises";
|
|
10
12
|
import { join, relative, resolve } from "node:path";
|
|
11
13
|
import { Diagnostics, cacheStorage, createCliReporter, createOutputManifest, getInputKind, hasOutputPasses, logLevel } from "@kubb/core";
|
|
12
|
-
// ../../internals/utils/src/promise.ts
|
|
13
|
-
/**
|
|
14
|
-
* Runs `run` over every item with at most `limit` in flight. Workers share one iterator, so each
|
|
15
|
-
* takes the next item the moment it frees up instead of waiting for a batch to drain.
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* ```ts
|
|
19
|
-
* await inParallel({ items: files, limit: 50, run: (file) => storage.writeItem(file.path, file.source) })
|
|
20
|
-
* ```
|
|
21
|
-
*/
|
|
22
|
-
async function inParallel({ items, limit, run }) {
|
|
23
|
-
const queue = items.entries();
|
|
24
|
-
const worker = async () => {
|
|
25
|
-
for (const [index, item] of queue) await run(item, index);
|
|
26
|
-
};
|
|
27
|
-
await Promise.all(Array.from({ length: Math.min(limit, items.length) }, () => worker()));
|
|
28
|
-
}
|
|
29
14
|
// src/loggers/features/context.ts
|
|
30
15
|
function createLoggerContext({ hooks, writer, logLevel: logLevel$6 }) {
|
|
31
16
|
const text = (message) => logLevel$6 >= logLevel.verbose ? `${styleText("dim", `[${clock()}]`)} ${message}` : message;
|
|
@@ -271,17 +256,13 @@ function createPhases({ writer, silent, logLevel: logLevel$5, text, line, onRun
|
|
|
271
256
|
};
|
|
272
257
|
}
|
|
273
258
|
// src/loggers/specFrame.ts
|
|
274
|
-
|
|
259
|
+
const startsBySource = memo.create({ max: 1 });
|
|
275
260
|
function lineStarts(source) {
|
|
276
|
-
|
|
261
|
+
return memo(startsBySource, source, () => {
|
|
277
262
|
const starts = [0];
|
|
278
263
|
for (const match of source.matchAll(/\n/g)) starts.push(match.index + 1);
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
starts
|
|
282
|
-
};
|
|
283
|
-
}
|
|
284
|
-
return cached.starts;
|
|
264
|
+
return starts;
|
|
265
|
+
});
|
|
285
266
|
}
|
|
286
267
|
/** The index of the last line start at or before `offset`, found by binary search. */
|
|
287
268
|
function lineIndex(starts, offset, low = 0, high = starts.length - 1) {
|
|
@@ -812,24 +793,35 @@ function diffBuilds(previous, next) {
|
|
|
812
793
|
operations: diffNames(previous.operations, next.operations)
|
|
813
794
|
};
|
|
814
795
|
}
|
|
815
|
-
function
|
|
796
|
+
function splitLines(text) {
|
|
797
|
+
return text ? text.split("\n") : [];
|
|
798
|
+
}
|
|
799
|
+
function hashLine(line) {
|
|
800
|
+
let hash = 2166136261;
|
|
801
|
+
for (const char of line) hash = Math.imul(hash ^ char.codePointAt(0), 16777619);
|
|
802
|
+
return hash;
|
|
803
|
+
}
|
|
804
|
+
function hashLines(text) {
|
|
805
|
+
return Int32Array.from(splitLines(text), hashLine);
|
|
806
|
+
}
|
|
807
|
+
function countLineChanges({ before, after }) {
|
|
816
808
|
const remaining = /* @__PURE__ */ new Map();
|
|
817
|
-
for (const line of before
|
|
818
|
-
let added = 0;
|
|
819
|
-
for (const line of after ? after.split("\n") : []) {
|
|
820
|
-
const count = remaining.get(line) ?? 0;
|
|
821
|
-
if (count > 0) remaining.set(line, count - 1);
|
|
822
|
-
else added++;
|
|
823
|
-
}
|
|
824
|
-
const removed = [...remaining.values()].reduce((sum, count) => sum + count, 0);
|
|
809
|
+
for (const line of before) remaining.set(line, (remaining.get(line) ?? 0) + 1);
|
|
825
810
|
return {
|
|
826
|
-
added
|
|
827
|
-
|
|
811
|
+
added: [...after].filter((line) => {
|
|
812
|
+
const count = remaining.get(line) ?? 0;
|
|
813
|
+
if (count === 0) return true;
|
|
814
|
+
remaining.set(line, count - 1);
|
|
815
|
+
return false;
|
|
816
|
+
}).length,
|
|
817
|
+
removed: [...remaining.values()].reduce((sum, count) => sum + count, 0)
|
|
828
818
|
};
|
|
829
819
|
}
|
|
830
820
|
/**
|
|
831
821
|
* Reads the output before generation, so cleaning the directory cannot erase the diff baseline.
|
|
832
|
-
* A missing directory or an unreadable file is skipped.
|
|
822
|
+
* A missing directory or an unreadable file is skipped. This keeps every file's text for the whole
|
|
823
|
+
* run, so only a dry run and a run with output passes use it: they compare against the output read
|
|
824
|
+
* back at the end.
|
|
833
825
|
*/
|
|
834
826
|
async function readOutputFiles(outputPath) {
|
|
835
827
|
const entries = await readdir(outputPath, {
|
|
@@ -847,61 +839,134 @@ async function readOutputFiles(outputPath) {
|
|
|
847
839
|
});
|
|
848
840
|
return files;
|
|
849
841
|
}
|
|
842
|
+
function fingerprintFile(text) {
|
|
843
|
+
const body = text.trimEnd();
|
|
844
|
+
const trimmed = body.trimStart();
|
|
845
|
+
const leading = body.slice(0, body.length - trimmed.length).split("\n").length - 1;
|
|
846
|
+
const lines = hashLines(trimmed);
|
|
847
|
+
return {
|
|
848
|
+
length: trimmed.length,
|
|
849
|
+
digest: hash("sha1", trimmed),
|
|
850
|
+
lines,
|
|
851
|
+
deletedLines: body ? lines.length + leading : 0
|
|
852
|
+
};
|
|
853
|
+
}
|
|
854
|
+
/**
|
|
855
|
+
* Fingerprints every file under the output folder right before `output.clean` empties it, one file at a time, so the
|
|
856
|
+
* old tree is never held in memory. A missing directory or an unreadable file is skipped.
|
|
857
|
+
*/
|
|
858
|
+
async function readOutputFingerprints(outputPath) {
|
|
859
|
+
const entries = await readdir(outputPath, {
|
|
860
|
+
recursive: true,
|
|
861
|
+
withFileTypes: true
|
|
862
|
+
}).catch(() => []);
|
|
863
|
+
const fingerprints = /* @__PURE__ */ new Map();
|
|
864
|
+
for (const entry of entries) {
|
|
865
|
+
if (!entry.isFile()) continue;
|
|
866
|
+
const filePath = join(entry.parentPath, entry.name);
|
|
867
|
+
try {
|
|
868
|
+
fingerprints.set(filePath, fingerprintFile(readFileSync(filePath, "utf8")));
|
|
869
|
+
} catch {}
|
|
870
|
+
}
|
|
871
|
+
return fingerprints;
|
|
872
|
+
}
|
|
850
873
|
/**
|
|
851
874
|
* How one generated file differs from its copy before generation: `undefined` when both hold the
|
|
852
|
-
* same output, otherwise the change with its line counts.
|
|
853
|
-
*
|
|
875
|
+
* same output, otherwise the change with its line counts. `previous` is the stored text, the
|
|
876
|
+
* {@link FileFingerprint} of a file `output.clean` deleted, or `null` for a new file. The manifest
|
|
877
|
+
* recognizes output a formatter rewrote.
|
|
854
878
|
*/
|
|
855
879
|
function diffFile({ path, next, previous, manifest }) {
|
|
856
|
-
if (previous
|
|
880
|
+
if (previous === null) return {
|
|
881
|
+
status: "A",
|
|
882
|
+
path,
|
|
883
|
+
added: splitLines(next.trimEnd()).length,
|
|
884
|
+
removed: 0
|
|
885
|
+
};
|
|
886
|
+
if (typeof previous !== "string") {
|
|
887
|
+
const trimmed = next.trim();
|
|
888
|
+
if (trimmed.length === previous.length && hash("sha1", trimmed) === previous.digest) return void 0;
|
|
889
|
+
return {
|
|
890
|
+
status: "M",
|
|
891
|
+
path,
|
|
892
|
+
...countLineChanges({
|
|
893
|
+
before: previous.lines,
|
|
894
|
+
after: hashLines(trimmed)
|
|
895
|
+
})
|
|
896
|
+
};
|
|
897
|
+
}
|
|
898
|
+
if (matchesStored({
|
|
857
899
|
stored: previous,
|
|
858
900
|
source: next
|
|
859
901
|
}) || manifest?.isUpToDate({
|
|
860
902
|
key: path,
|
|
861
903
|
source: next,
|
|
862
904
|
disk: previous
|
|
863
|
-
}))
|
|
905
|
+
})) return void 0;
|
|
864
906
|
return {
|
|
865
|
-
status:
|
|
907
|
+
status: "M",
|
|
866
908
|
path,
|
|
867
|
-
...countLineChanges(
|
|
909
|
+
...countLineChanges({
|
|
910
|
+
before: splitLines(previous.trim()),
|
|
911
|
+
after: splitLines(next.trim())
|
|
912
|
+
})
|
|
913
|
+
};
|
|
914
|
+
}
|
|
915
|
+
const statusKeys = {
|
|
916
|
+
A: "added",
|
|
917
|
+
M: "modified",
|
|
918
|
+
D: "deleted"
|
|
919
|
+
};
|
|
920
|
+
/**
|
|
921
|
+
* Adds one file's outcome to the totals: a {@link FileChange}, or `undefined` for an unchanged file.
|
|
922
|
+
*/
|
|
923
|
+
function tallyChange({ tally, change }) {
|
|
924
|
+
if (!change) {
|
|
925
|
+
tally.unchanged++;
|
|
926
|
+
return;
|
|
927
|
+
}
|
|
928
|
+
tally[statusKeys[change.status]]++;
|
|
929
|
+
tally.linesAdded += change.added ?? 0;
|
|
930
|
+
tally.linesRemoved += change.removed ?? 0;
|
|
931
|
+
}
|
|
932
|
+
function createChangeTally() {
|
|
933
|
+
return {
|
|
934
|
+
added: 0,
|
|
935
|
+
modified: 0,
|
|
936
|
+
deleted: 0,
|
|
937
|
+
linesAdded: 0,
|
|
938
|
+
linesRemoved: 0,
|
|
939
|
+
unchanged: 0
|
|
868
940
|
};
|
|
869
941
|
}
|
|
870
942
|
/**
|
|
871
943
|
* Compares generated output with the files captured before generation. The manifest recognizes
|
|
872
|
-
* output rewritten by a formatter, and `clean` includes files the run would delete.
|
|
873
|
-
* changes already worked out while the files were written; any other path is read back.
|
|
944
|
+
* output rewritten by a formatter, and `clean` includes files the run would delete.
|
|
874
945
|
*/
|
|
875
|
-
async function diffOutput({ storage, paths, clean, manifest, previousFiles
|
|
876
|
-
const
|
|
877
|
-
const changes = [];
|
|
878
|
-
let unchanged = 0;
|
|
946
|
+
async function diffOutput({ storage, paths, clean, manifest, previousFiles }) {
|
|
947
|
+
const results = [];
|
|
879
948
|
await inParallel({
|
|
880
|
-
items: paths,
|
|
949
|
+
items: [...paths],
|
|
881
950
|
limit: 50,
|
|
882
951
|
run: async (filePath, index) => {
|
|
883
|
-
|
|
884
|
-
if (
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
previous: previousFiles.get(filePath) ?? null,
|
|
892
|
-
manifest
|
|
893
|
-
});
|
|
894
|
-
}
|
|
895
|
-
if (change) changes[index] = change;
|
|
896
|
-
else unchanged++;
|
|
952
|
+
const next = await storage.readItem(filePath);
|
|
953
|
+
if (next === null) return;
|
|
954
|
+
results[index] = diffFile({
|
|
955
|
+
path: filePath,
|
|
956
|
+
next,
|
|
957
|
+
previous: previousFiles.get(filePath) ?? null,
|
|
958
|
+
manifest
|
|
959
|
+
}) ?? null;
|
|
897
960
|
}
|
|
898
961
|
});
|
|
899
|
-
const files =
|
|
962
|
+
const files = results.filter((result) => result !== null);
|
|
963
|
+
const unchanged = results.filter((result) => result === null).length;
|
|
900
964
|
if (clean) {
|
|
901
|
-
for (const [filePath, source] of previousFiles) if (!
|
|
965
|
+
for (const [filePath, source] of previousFiles) if (!paths.has(filePath)) files.push({
|
|
902
966
|
status: "D",
|
|
903
967
|
path: filePath,
|
|
904
|
-
|
|
968
|
+
added: 0,
|
|
969
|
+
removed: splitLines(source.trimEnd()).length
|
|
905
970
|
});
|
|
906
971
|
}
|
|
907
972
|
return {
|
|
@@ -952,101 +1017,130 @@ function setupReporters(context, { logLevel: logLevel$1, reporters, writer: writ
|
|
|
952
1017
|
}).renderSummary })];
|
|
953
1018
|
});
|
|
954
1019
|
const ctx = { logLevel: logLevel$1 };
|
|
955
|
-
const pluginFiles = selected.some((reporter) => reporter.needsPluginFiles) ?
|
|
1020
|
+
const pluginFiles = selected.some((reporter) => reporter.needsPluginFiles) ? memo.create() : void 0;
|
|
956
1021
|
const seen = /* @__PURE__ */ new Set();
|
|
957
1022
|
if (pluginFiles) context.hook("kubb:plugin:end", ({ plugin, files }) => {
|
|
958
1023
|
for (const file of files) {
|
|
959
1024
|
if (seen.has(file.path)) continue;
|
|
960
1025
|
seen.add(file.path);
|
|
961
|
-
|
|
962
|
-
paths.push(file.path);
|
|
963
|
-
pluginFiles.set(plugin.name, paths);
|
|
1026
|
+
memo(pluginFiles, plugin.name, () => []).push(file.path);
|
|
964
1027
|
}
|
|
965
1028
|
});
|
|
966
|
-
let
|
|
967
|
-
let previous;
|
|
968
|
-
let reading;
|
|
969
|
-
let counted;
|
|
970
|
-
let paths = [];
|
|
971
|
-
let outputPath = "";
|
|
1029
|
+
let run;
|
|
972
1030
|
const trackChanges = (fileChanges || selected.some((reporter) => reporter.name === "cli")) && logLevel$1 > logLevel.silent;
|
|
973
1031
|
context.hook("kubb:generation:start", ({ config }) => {
|
|
974
1032
|
pluginFiles?.clear();
|
|
975
1033
|
seen.clear();
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
1034
|
+
const outputPath = resolve(config.root, config.output.path);
|
|
1035
|
+
const tracked = trackChanges && (dryRun || config.storage?.name === "fs");
|
|
1036
|
+
const live = (() => {
|
|
1037
|
+
if (!tracked || dryRun || hasOutputPasses(config)) return void 0;
|
|
1038
|
+
return {
|
|
1039
|
+
tally: createChangeTally(),
|
|
1040
|
+
fingerprints: /* @__PURE__ */ new Map(),
|
|
1041
|
+
processed: /* @__PURE__ */ new Set()
|
|
1042
|
+
};
|
|
1043
|
+
})();
|
|
1044
|
+
run = {
|
|
1045
|
+
outputPath,
|
|
1046
|
+
filesUnchanged: 0,
|
|
1047
|
+
paths: /* @__PURE__ */ new Set(),
|
|
1048
|
+
live,
|
|
1049
|
+
reading: tracked && !live ? readOutputFiles(outputPath) : void 0
|
|
1050
|
+
};
|
|
982
1051
|
});
|
|
983
|
-
context.hook("kubb:plugins:end", async () => {
|
|
984
|
-
if (
|
|
1052
|
+
context.hook("kubb:plugins:end", async ({ config }) => {
|
|
1053
|
+
if (!run) return;
|
|
1054
|
+
if (run.reading) run.previous = await run.reading;
|
|
1055
|
+
if (run.live && config.output.clean) run.live.fingerprints = await readOutputFingerprints(run.outputPath);
|
|
985
1056
|
});
|
|
986
1057
|
context.hook("kubb:files:processing:start", async ({ files }) => {
|
|
987
|
-
if (!previous) return;
|
|
1058
|
+
if (!run?.previous) return;
|
|
1059
|
+
const { previous, outputPath } = run;
|
|
988
1060
|
for (const file of files) {
|
|
989
1061
|
if (previous.has(file.path) || isPathInside(outputPath, file.path)) continue;
|
|
990
|
-
const source = await readFile(file.path, "utf8").catch(() => null);
|
|
1062
|
+
const source = await readFile$1(file.path, "utf8").catch(() => null);
|
|
991
1063
|
if (source !== null) previous.set(file.path, source);
|
|
992
1064
|
}
|
|
993
1065
|
});
|
|
994
|
-
context.hook("kubb:file:processed", ({ file, source }) => {
|
|
995
|
-
|
|
1066
|
+
context.hook("kubb:file:processed", ({ file, source, stored = null }) => {
|
|
1067
|
+
const live = run?.live;
|
|
1068
|
+
if (!live) return;
|
|
996
1069
|
const next = source.trim();
|
|
997
|
-
if (next)
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1070
|
+
if (!next) return;
|
|
1071
|
+
live.processed.add(file.path);
|
|
1072
|
+
tallyChange({
|
|
1073
|
+
tally: live.tally,
|
|
1074
|
+
change: diffFile({
|
|
1075
|
+
path: file.path,
|
|
1076
|
+
next,
|
|
1077
|
+
previous: stored ?? live.fingerprints.get(file.path) ?? null
|
|
1078
|
+
})
|
|
1079
|
+
});
|
|
1002
1080
|
});
|
|
1003
1081
|
context.hook("kubb:files:processing:end", ({ files, unchanged }) => {
|
|
1004
|
-
|
|
1005
|
-
|
|
1082
|
+
if (!run) return;
|
|
1083
|
+
run.filesUnchanged = unchanged.length;
|
|
1084
|
+
run.paths = new Set(files.map((file) => file.path));
|
|
1006
1085
|
});
|
|
1086
|
+
/** The run's totals: counted while writing, or worked out by reading the output back. */
|
|
1087
|
+
async function countChanges({ config, storage, current }) {
|
|
1088
|
+
const { live, paths, previous } = current;
|
|
1089
|
+
if (live) {
|
|
1090
|
+
const { tally, fingerprints, processed } = live;
|
|
1091
|
+
for (const [filePath, fingerprint] of fingerprints) if (!paths.has(filePath)) tallyChange({
|
|
1092
|
+
tally,
|
|
1093
|
+
change: {
|
|
1094
|
+
status: "D",
|
|
1095
|
+
path: filePath,
|
|
1096
|
+
removed: fingerprint.deletedLines
|
|
1097
|
+
}
|
|
1098
|
+
});
|
|
1099
|
+
for (const filePath of paths.difference(processed)) if (await storage.readItem(filePath) !== null) tally.unchanged++;
|
|
1100
|
+
return tally;
|
|
1101
|
+
}
|
|
1102
|
+
if (!previous) return void 0;
|
|
1103
|
+
const manifest = dryRun ? await createOutputManifest({
|
|
1104
|
+
storage,
|
|
1105
|
+
cache: cacheStorage({ root: config.root })
|
|
1106
|
+
}) : void 0;
|
|
1107
|
+
const diff = await diffOutput({
|
|
1108
|
+
storage,
|
|
1109
|
+
paths,
|
|
1110
|
+
clean: Boolean(config.output.clean),
|
|
1111
|
+
manifest,
|
|
1112
|
+
previousFiles: previous
|
|
1113
|
+
});
|
|
1114
|
+
const changes = createChangeTally();
|
|
1115
|
+
changes.unchanged = diff.unchanged;
|
|
1116
|
+
for (const file of diff.files) tallyChange({
|
|
1117
|
+
tally: changes,
|
|
1118
|
+
change: file
|
|
1119
|
+
});
|
|
1120
|
+
return changes;
|
|
1121
|
+
}
|
|
1007
1122
|
context.hook("kubb:generation:end", async ({ config, storage, diagnostics = [], filesCreated = 0, status = "success", hrStart = process.hrtime() }) => {
|
|
1123
|
+
const current = run;
|
|
1124
|
+
run = void 0;
|
|
1008
1125
|
const result = {
|
|
1009
1126
|
config,
|
|
1010
1127
|
diagnostics,
|
|
1011
1128
|
filesCreated,
|
|
1012
|
-
filesUnchanged,
|
|
1129
|
+
filesUnchanged: current?.filesUnchanged ?? 0,
|
|
1013
1130
|
dryRun,
|
|
1014
1131
|
status,
|
|
1015
1132
|
hrStart
|
|
1016
1133
|
};
|
|
1017
1134
|
const cliResult = { ...result };
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
manifest,
|
|
1028
|
-
previousFiles: previous,
|
|
1029
|
-
counted
|
|
1030
|
-
});
|
|
1031
|
-
const changes = {
|
|
1032
|
-
added: 0,
|
|
1033
|
-
modified: 0,
|
|
1034
|
-
deleted: 0,
|
|
1035
|
-
linesAdded: 0,
|
|
1036
|
-
linesRemoved: 0
|
|
1037
|
-
};
|
|
1038
|
-
const counts = {
|
|
1039
|
-
A: "added",
|
|
1040
|
-
M: "modified",
|
|
1041
|
-
D: "deleted"
|
|
1042
|
-
};
|
|
1043
|
-
for (const file of diff.files) {
|
|
1044
|
-
changes[counts[file.status]]++;
|
|
1045
|
-
changes.linesAdded += file.added ?? 0;
|
|
1046
|
-
changes.linesRemoved += file.removed ?? 0;
|
|
1047
|
-
}
|
|
1048
|
-
cliResult.filesCreated = changes.added + changes.modified + diff.unchanged;
|
|
1049
|
-
cliResult.filesUnchanged = diff.unchanged;
|
|
1135
|
+
const counted = current && status !== "failed" ? await countChanges({
|
|
1136
|
+
config,
|
|
1137
|
+
storage,
|
|
1138
|
+
current
|
|
1139
|
+
}) : void 0;
|
|
1140
|
+
if (counted) {
|
|
1141
|
+
const { unchanged, ...changes } = counted;
|
|
1142
|
+
cliResult.filesCreated = changes.added + changes.modified + unchanged;
|
|
1143
|
+
cliResult.filesUnchanged = unchanged;
|
|
1050
1144
|
cliResult.fileChanges = changes;
|
|
1051
1145
|
}
|
|
1052
1146
|
for (const reporter of selected) {
|
|
@@ -1070,4 +1164,4 @@ function selectReporters(reporters, names) {
|
|
|
1070
1164
|
}
|
|
1071
1165
|
export { startWatcher as a, listenForKeys as i, setupReporters as n, trackBuild as o, diffBuilds as r, selectReporters as t };
|
|
1072
1166
|
|
|
1073
|
-
//# sourceMappingURL=reporters-
|
|
1167
|
+
//# sourceMappingURL=reporters-B6p0n7s3.js.map
|