@kubb/cli 5.18.7 → 5.18.8
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-CBzCK4kO.cjs} +2 -2
- package/dist/{Telemetry-Cbt_dJE6.cjs.map → Telemetry-CBzCK4kO.cjs.map} +1 -1
- package/dist/{Telemetry-Bf16psPO.js → Telemetry-DUl_hxVn.js} +2 -2
- package/dist/{Telemetry-Bf16psPO.js.map → Telemetry-DUl_hxVn.js.map} +1 -1
- package/dist/{background-Cvoxk_DQ.js → background-CA9lRKAK.js} +2 -2
- package/dist/{background-Cvoxk_DQ.js.map → background-CA9lRKAK.js.map} +1 -1
- package/dist/{background-JyYJdws1.js → background-DK3HLyNk.js} +1 -1
- package/dist/{background-3TB5Cgkv.cjs → background-fhpYDuSs.cjs} +2 -2
- package/dist/{background-3TB5Cgkv.cjs.map → background-fhpYDuSs.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-BQ-Pp7i_.cjs} +3 -3
- package/dist/{configFile-C_7uzuGV.cjs.map → configFile-BQ-Pp7i_.cjs.map} +1 -1
- package/dist/{configFile-B2EIouxg.js → configFile-CPXDgTC2.js} +3 -3
- package/dist/{configFile-B2EIouxg.js.map → configFile-CPXDgTC2.js.map} +1 -1
- package/dist/{fs-j84Tqpbx.js → fs-CmODfKN-.js} +25 -6
- package/dist/fs-CmODfKN-.js.map +1 -0
- package/dist/index.cjs +12 -12
- package/dist/index.js +12 -12
- package/dist/{installWithSpinner-YEtb8cNf.cjs → installWithSpinner-DZDlVp1J.cjs} +3 -3
- package/dist/{installWithSpinner-YEtb8cNf.cjs.map → installWithSpinner-DZDlVp1J.cjs.map} +1 -1
- package/dist/{installWithSpinner-C4gKZ7r5.js → installWithSpinner-gv_OWgww.js} +2 -2
- package/dist/{installWithSpinner-C4gKZ7r5.js.map → installWithSpinner-gv_OWgww.js.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-CIMQ8g_J.cjs → mcp-BBD4kdKF.cjs} +2 -2
- package/dist/{mcp-CIMQ8g_J.cjs.map → mcp-BBD4kdKF.cjs.map} +1 -1
- package/dist/{mcp-DFPXRd6M.js → mcp-CQXp9pcW.js} +2 -2
- package/dist/{mcp-DFPXRd6M.js.map → mcp-CQXp9pcW.js.map} +1 -1
- package/dist/package-CdMFA8OG.js +5 -0
- package/dist/package-CdMFA8OG.js.map +1 -0
- package/dist/{package-C482iN7Y.cjs → package-DXNoJQYa.cjs} +2 -2
- package/dist/package-DXNoJQYa.cjs.map +1 -0
- package/dist/{reporters-yVmLpEoU.cjs → reporters-CaJ8brYA.cjs} +253 -101
- package/dist/reporters-CaJ8brYA.cjs.map +1 -0
- package/dist/{reporters-DJPMb1-j.js → reporters-CzxaQ_bD.js} +1 -1
- package/dist/{reporters-De3ynr5a.js → reporters-DeruUk9K.js} +255 -103
- package/dist/reporters-DeruUk9K.js.map +1 -0
- package/dist/{run-jGpJxxmr.js → run-96_svbr3.js} +5 -5
- package/dist/{run-jGpJxxmr.js.map → run-96_svbr3.js.map} +1 -1
- package/dist/{run-BGkdpZwR.cjs → run-BIgV2zvB.cjs} +2 -2
- package/dist/{run-BGkdpZwR.cjs.map → run-BIgV2zvB.cjs.map} +1 -1
- package/dist/{run-hqWFyi0N.cjs → run-BSA2x4iE.cjs} +8 -8
- package/dist/{run-hqWFyi0N.cjs.map → run-BSA2x4iE.cjs.map} +1 -1
- package/dist/{run-DYr--XFw.js → run-Bi8hhAzv.js} +1 -1
- package/dist/{run-D-3F2mhJ.cjs → run-Bxqg0GuI.cjs} +4 -4
- package/dist/{run-D-3F2mhJ.cjs.map → run-Bxqg0GuI.cjs.map} +1 -1
- package/dist/{run-DD1VdcpX.cjs → run-CIEKCdM-.cjs} +8 -8
- package/dist/{run-DD1VdcpX.cjs.map → run-CIEKCdM-.cjs.map} +1 -1
- package/dist/{run-BVz9vmbt.js → run-CYdKWpyH.js} +6 -6
- package/dist/{run-BVz9vmbt.js.map → run-CYdKWpyH.js.map} +1 -1
- package/dist/{run-B-PAQSVx.js → run-CmHjIMpd.js} +7 -7
- package/dist/{run-B-PAQSVx.js.map → run-CmHjIMpd.js.map} +1 -1
- package/dist/{run-nSTiS72Z.js → run-CpyFU0RM.js} +8 -8
- package/dist/{run-nSTiS72Z.js.map → run-CpyFU0RM.js.map} +1 -1
- package/dist/{run-DwPkySke.cjs → run-DLRu4z5Z.cjs} +5 -5
- package/dist/{run-DwPkySke.cjs.map → run-DLRu4z5Z.cjs.map} +1 -1
- package/dist/{run-DVbHd7qm.js → run-Df4PGOFX.js} +74 -23
- package/dist/run-Df4PGOFX.js.map +1 -0
- package/dist/{run-D7AQwBWZ.cjs → run-GdctJlXN.cjs} +6 -6
- package/dist/{run-D7AQwBWZ.cjs.map → run-GdctJlXN.cjs.map} +1 -1
- package/dist/{run-BjWqOCAj.js → run-ORjkOWFp.js} +2 -2
- package/dist/{run-BjWqOCAj.js.map → run-ORjkOWFp.js.map} +1 -1
- package/dist/{run-w0kr76jl.cjs → run-OqiJknWr.cjs} +9 -9
- package/dist/{run-w0kr76jl.cjs.map → run-OqiJknWr.cjs.map} +1 -1
- package/dist/{run-Bc34cwzh.js → run-U2Ze_QP4.js} +8 -8
- package/dist/{run-Bc34cwzh.js.map → run-U2Ze_QP4.js.map} +1 -1
- package/dist/{run-D1hHaTDJ.js → run-ixh050Ip.js} +4 -4
- package/dist/{run-D1hHaTDJ.js.map → run-ixh050Ip.js.map} +1 -1
- package/dist/{run-puNdxNuf.cjs → run-k-LqKkgU.cjs} +74 -23
- package/dist/run-k-LqKkgU.cjs.map +1 -0
- package/dist/{snapshot-DRyGykFq.cjs → snapshot-C-ge8g3_.cjs} +5 -5
- package/dist/{snapshot-DRyGykFq.cjs.map → snapshot-C-ge8g3_.cjs.map} +1 -1
- package/dist/{snapshot-eO0_VdUy.js → snapshot-CSacL1qI.js} +5 -5
- package/dist/{snapshot-eO0_VdUy.js.map → snapshot-CSacL1qI.js.map} +1 -1
- package/dist/{spinner-CdX9Noe9.cjs → spinner-D584jFAz.cjs} +24 -6
- package/dist/spinner-D584jFAz.cjs.map +1 -0
- package/dist/{status-NqYVjTY8.js → status-Bq-Bjo2n.js} +3 -3
- package/dist/{status-NqYVjTY8.js.map → status-Bq-Bjo2n.js.map} +1 -1
- package/dist/{status-DICY3TJQ.cjs → status-D-Osmkhr.cjs} +3 -3
- package/dist/{status-DICY3TJQ.cjs.map → status-D-Osmkhr.cjs.map} +1 -1
- package/dist/{studio-gu56JqH0.js → studio-BBXKjMN-.js} +12 -12
- package/dist/{studio-gu56JqH0.js.map → studio-BBXKjMN-.js.map} +1 -1
- package/dist/{studio-BfR2KY0b.cjs → studio-BZ53idqa.cjs} +12 -12
- package/dist/{studio-BfR2KY0b.cjs.map → studio-BZ53idqa.cjs.map} +1 -1
- package/dist/studioWorker.js +2 -2
- package/dist/{utils-DGopc0Bo.js → utils-BVccq6W0.js} +3 -3
- package/dist/{utils-DGopc0Bo.js.map → utils-BVccq6W0.js.map} +1 -1
- package/dist/{utils-D19HX-lE.cjs → utils-C9fYoqP2.cjs} +4 -4
- package/dist/{utils-D19HX-lE.cjs.map → utils-C9fYoqP2.cjs.map} +1 -1
- package/dist/{validate-DoSQad-i.js → validate-BuStuH_z.js} +2 -2
- package/dist/{validate-DoSQad-i.js.map → validate-BuStuH_z.js.map} +1 -1
- package/dist/{validate-BXSS6BSO.cjs → validate-rr0LpFhN.cjs} +2 -2
- package/dist/{validate-BXSS6BSO.cjs.map → validate-rr0LpFhN.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/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
|
@@ -1,16 +1,53 @@
|
|
|
1
1
|
import "./rolldown-runtime-BowF1xt-.js";
|
|
2
|
-
import { i as read, n as isPathInside, r as matchesStored } from "./fs-
|
|
2
|
+
import { i as read, n as isPathInside, r as matchesStored } from "./fs-CmODfKN-.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
14
|
// ../../internals/utils/src/promise.ts
|
|
13
15
|
/**
|
|
16
|
+
* Returns the value cached under `key` in `store`, computing and storing it on the first call.
|
|
17
|
+
* Pass a `WeakMap` for object keys, so an entry goes away with its key, or a `Map` for primitive
|
|
18
|
+
* keys. A cached `null` or `undefined` counts as a hit, so `compute` runs once per key.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* `const refs = memo(refCache, node, () => collectRefs(node))`
|
|
22
|
+
*/
|
|
23
|
+
function memo(store, key, compute) {
|
|
24
|
+
const cached = store.get(key);
|
|
25
|
+
if (cached !== void 0 || store.has(key)) return cached;
|
|
26
|
+
const value = compute();
|
|
27
|
+
store.set(key, value);
|
|
28
|
+
return value;
|
|
29
|
+
}
|
|
30
|
+
function createStore({ type }) {
|
|
31
|
+
if (type === "weak") return /* @__PURE__ */ new WeakMap();
|
|
32
|
+
const entry = /* @__PURE__ */ new Map();
|
|
33
|
+
if (type === "map") return entry;
|
|
34
|
+
const set = (key, value) => {
|
|
35
|
+
entry.clear();
|
|
36
|
+
entry.set(key, value);
|
|
37
|
+
};
|
|
38
|
+
const touch = (key) => {
|
|
39
|
+
if (!entry.has(key)) return false;
|
|
40
|
+
set(key, entry.get(key));
|
|
41
|
+
return true;
|
|
42
|
+
};
|
|
43
|
+
return {
|
|
44
|
+
has: touch,
|
|
45
|
+
get: (key) => touch(key) ? entry.get(key) : void 0,
|
|
46
|
+
set
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
memo.create = createStore;
|
|
50
|
+
/**
|
|
14
51
|
* Runs `run` over every item with at most `limit` in flight. Workers share one iterator, so each
|
|
15
52
|
* takes the next item the moment it frees up instead of waiting for a batch to drain.
|
|
16
53
|
*
|
|
@@ -812,24 +849,35 @@ function diffBuilds(previous, next) {
|
|
|
812
849
|
operations: diffNames(previous.operations, next.operations)
|
|
813
850
|
};
|
|
814
851
|
}
|
|
815
|
-
function
|
|
852
|
+
function splitLines(text) {
|
|
853
|
+
return text ? text.split("\n") : [];
|
|
854
|
+
}
|
|
855
|
+
function hashLine(line) {
|
|
856
|
+
let hash = 2166136261;
|
|
857
|
+
for (const char of line) hash = Math.imul(hash ^ char.codePointAt(0), 16777619);
|
|
858
|
+
return hash;
|
|
859
|
+
}
|
|
860
|
+
function hashLines(text) {
|
|
861
|
+
return Int32Array.from(splitLines(text), hashLine);
|
|
862
|
+
}
|
|
863
|
+
function countLineChanges({ before, after }) {
|
|
816
864
|
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);
|
|
865
|
+
for (const line of before) remaining.set(line, (remaining.get(line) ?? 0) + 1);
|
|
825
866
|
return {
|
|
826
|
-
added
|
|
827
|
-
|
|
867
|
+
added: [...after].filter((line) => {
|
|
868
|
+
const count = remaining.get(line) ?? 0;
|
|
869
|
+
if (count === 0) return true;
|
|
870
|
+
remaining.set(line, count - 1);
|
|
871
|
+
return false;
|
|
872
|
+
}).length,
|
|
873
|
+
removed: [...remaining.values()].reduce((sum, count) => sum + count, 0)
|
|
828
874
|
};
|
|
829
875
|
}
|
|
830
876
|
/**
|
|
831
877
|
* Reads the output before generation, so cleaning the directory cannot erase the diff baseline.
|
|
832
|
-
* A missing directory or an unreadable file is skipped.
|
|
878
|
+
* A missing directory or an unreadable file is skipped. This keeps every file's text for the whole
|
|
879
|
+
* run, so only a dry run and a run with output passes use it: they compare against the output read
|
|
880
|
+
* back at the end.
|
|
833
881
|
*/
|
|
834
882
|
async function readOutputFiles(outputPath) {
|
|
835
883
|
const entries = await readdir(outputPath, {
|
|
@@ -847,61 +895,134 @@ async function readOutputFiles(outputPath) {
|
|
|
847
895
|
});
|
|
848
896
|
return files;
|
|
849
897
|
}
|
|
898
|
+
function fingerprintFile(text) {
|
|
899
|
+
const body = text.trimEnd();
|
|
900
|
+
const trimmed = body.trimStart();
|
|
901
|
+
const leading = body.slice(0, body.length - trimmed.length).split("\n").length - 1;
|
|
902
|
+
const lines = hashLines(trimmed);
|
|
903
|
+
return {
|
|
904
|
+
length: trimmed.length,
|
|
905
|
+
digest: hash("sha1", trimmed),
|
|
906
|
+
lines,
|
|
907
|
+
deletedLines: body ? lines.length + leading : 0
|
|
908
|
+
};
|
|
909
|
+
}
|
|
910
|
+
/**
|
|
911
|
+
* Fingerprints every file under the output folder right before `output.clean` empties it, one file at a time, so the
|
|
912
|
+
* old tree is never held in memory. A missing directory or an unreadable file is skipped.
|
|
913
|
+
*/
|
|
914
|
+
async function readOutputFingerprints(outputPath) {
|
|
915
|
+
const entries = await readdir(outputPath, {
|
|
916
|
+
recursive: true,
|
|
917
|
+
withFileTypes: true
|
|
918
|
+
}).catch(() => []);
|
|
919
|
+
const fingerprints = /* @__PURE__ */ new Map();
|
|
920
|
+
for (const entry of entries) {
|
|
921
|
+
if (!entry.isFile()) continue;
|
|
922
|
+
const filePath = join(entry.parentPath, entry.name);
|
|
923
|
+
try {
|
|
924
|
+
fingerprints.set(filePath, fingerprintFile(readFileSync(filePath, "utf8")));
|
|
925
|
+
} catch {}
|
|
926
|
+
}
|
|
927
|
+
return fingerprints;
|
|
928
|
+
}
|
|
850
929
|
/**
|
|
851
930
|
* 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
|
-
*
|
|
931
|
+
* same output, otherwise the change with its line counts. `previous` is the stored text, the
|
|
932
|
+
* {@link FileFingerprint} of a file `output.clean` deleted, or `null` for a new file. The manifest
|
|
933
|
+
* recognizes output a formatter rewrote.
|
|
854
934
|
*/
|
|
855
935
|
function diffFile({ path, next, previous, manifest }) {
|
|
856
|
-
if (previous
|
|
936
|
+
if (previous === null) return {
|
|
937
|
+
status: "A",
|
|
938
|
+
path,
|
|
939
|
+
added: splitLines(next.trimEnd()).length,
|
|
940
|
+
removed: 0
|
|
941
|
+
};
|
|
942
|
+
if (typeof previous !== "string") {
|
|
943
|
+
const trimmed = next.trim();
|
|
944
|
+
if (trimmed.length === previous.length && hash("sha1", trimmed) === previous.digest) return void 0;
|
|
945
|
+
return {
|
|
946
|
+
status: "M",
|
|
947
|
+
path,
|
|
948
|
+
...countLineChanges({
|
|
949
|
+
before: previous.lines,
|
|
950
|
+
after: hashLines(trimmed)
|
|
951
|
+
})
|
|
952
|
+
};
|
|
953
|
+
}
|
|
954
|
+
if (matchesStored({
|
|
857
955
|
stored: previous,
|
|
858
956
|
source: next
|
|
859
957
|
}) || manifest?.isUpToDate({
|
|
860
958
|
key: path,
|
|
861
959
|
source: next,
|
|
862
960
|
disk: previous
|
|
863
|
-
}))
|
|
961
|
+
})) return void 0;
|
|
864
962
|
return {
|
|
865
|
-
status:
|
|
963
|
+
status: "M",
|
|
866
964
|
path,
|
|
867
|
-
...countLineChanges(
|
|
965
|
+
...countLineChanges({
|
|
966
|
+
before: splitLines(previous.trim()),
|
|
967
|
+
after: splitLines(next.trim())
|
|
968
|
+
})
|
|
969
|
+
};
|
|
970
|
+
}
|
|
971
|
+
const statusKeys = {
|
|
972
|
+
A: "added",
|
|
973
|
+
M: "modified",
|
|
974
|
+
D: "deleted"
|
|
975
|
+
};
|
|
976
|
+
/**
|
|
977
|
+
* Adds one file's outcome to the totals: a {@link FileChange}, or `undefined` for an unchanged file.
|
|
978
|
+
*/
|
|
979
|
+
function tallyChange({ tally, change }) {
|
|
980
|
+
if (!change) {
|
|
981
|
+
tally.unchanged++;
|
|
982
|
+
return;
|
|
983
|
+
}
|
|
984
|
+
tally[statusKeys[change.status]]++;
|
|
985
|
+
tally.linesAdded += change.added ?? 0;
|
|
986
|
+
tally.linesRemoved += change.removed ?? 0;
|
|
987
|
+
}
|
|
988
|
+
function createChangeTally() {
|
|
989
|
+
return {
|
|
990
|
+
added: 0,
|
|
991
|
+
modified: 0,
|
|
992
|
+
deleted: 0,
|
|
993
|
+
linesAdded: 0,
|
|
994
|
+
linesRemoved: 0,
|
|
995
|
+
unchanged: 0
|
|
868
996
|
};
|
|
869
997
|
}
|
|
870
998
|
/**
|
|
871
999
|
* 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.
|
|
1000
|
+
* output rewritten by a formatter, and `clean` includes files the run would delete.
|
|
874
1001
|
*/
|
|
875
|
-
async function diffOutput({ storage, paths, clean, manifest, previousFiles
|
|
876
|
-
const
|
|
877
|
-
const changes = [];
|
|
878
|
-
let unchanged = 0;
|
|
1002
|
+
async function diffOutput({ storage, paths, clean, manifest, previousFiles }) {
|
|
1003
|
+
const results = [];
|
|
879
1004
|
await inParallel({
|
|
880
|
-
items: paths,
|
|
1005
|
+
items: [...paths],
|
|
881
1006
|
limit: 50,
|
|
882
1007
|
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++;
|
|
1008
|
+
const next = await storage.readItem(filePath);
|
|
1009
|
+
if (next === null) return;
|
|
1010
|
+
results[index] = diffFile({
|
|
1011
|
+
path: filePath,
|
|
1012
|
+
next,
|
|
1013
|
+
previous: previousFiles.get(filePath) ?? null,
|
|
1014
|
+
manifest
|
|
1015
|
+
}) ?? null;
|
|
897
1016
|
}
|
|
898
1017
|
});
|
|
899
|
-
const files =
|
|
1018
|
+
const files = results.filter((result) => result !== null);
|
|
1019
|
+
const unchanged = results.filter((result) => result === null).length;
|
|
900
1020
|
if (clean) {
|
|
901
|
-
for (const [filePath, source] of previousFiles) if (!
|
|
1021
|
+
for (const [filePath, source] of previousFiles) if (!paths.has(filePath)) files.push({
|
|
902
1022
|
status: "D",
|
|
903
1023
|
path: filePath,
|
|
904
|
-
|
|
1024
|
+
added: 0,
|
|
1025
|
+
removed: splitLines(source.trimEnd()).length
|
|
905
1026
|
});
|
|
906
1027
|
}
|
|
907
1028
|
return {
|
|
@@ -963,90 +1084,121 @@ function setupReporters(context, { logLevel: logLevel$1, reporters, writer: writ
|
|
|
963
1084
|
pluginFiles.set(plugin.name, paths);
|
|
964
1085
|
}
|
|
965
1086
|
});
|
|
966
|
-
let
|
|
967
|
-
let previous;
|
|
968
|
-
let reading;
|
|
969
|
-
let counted;
|
|
970
|
-
let paths = [];
|
|
971
|
-
let outputPath = "";
|
|
1087
|
+
let run;
|
|
972
1088
|
const trackChanges = (fileChanges || selected.some((reporter) => reporter.name === "cli")) && logLevel$1 > logLevel.silent;
|
|
973
1089
|
context.hook("kubb:generation:start", ({ config }) => {
|
|
974
1090
|
pluginFiles?.clear();
|
|
975
1091
|
seen.clear();
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
1092
|
+
const outputPath = resolve(config.root, config.output.path);
|
|
1093
|
+
const tracked = trackChanges && (dryRun || config.storage?.name === "fs");
|
|
1094
|
+
const live = (() => {
|
|
1095
|
+
if (!tracked || dryRun || hasOutputPasses(config)) return void 0;
|
|
1096
|
+
return {
|
|
1097
|
+
tally: createChangeTally(),
|
|
1098
|
+
fingerprints: /* @__PURE__ */ new Map(),
|
|
1099
|
+
processed: /* @__PURE__ */ new Set()
|
|
1100
|
+
};
|
|
1101
|
+
})();
|
|
1102
|
+
run = {
|
|
1103
|
+
outputPath,
|
|
1104
|
+
filesUnchanged: 0,
|
|
1105
|
+
paths: /* @__PURE__ */ new Set(),
|
|
1106
|
+
live,
|
|
1107
|
+
reading: tracked && !live ? readOutputFiles(outputPath) : void 0
|
|
1108
|
+
};
|
|
982
1109
|
});
|
|
983
|
-
context.hook("kubb:plugins:end", async () => {
|
|
984
|
-
if (
|
|
1110
|
+
context.hook("kubb:plugins:end", async ({ config }) => {
|
|
1111
|
+
if (!run) return;
|
|
1112
|
+
if (run.reading) run.previous = await run.reading;
|
|
1113
|
+
if (run.live && config.output.clean) run.live.fingerprints = await readOutputFingerprints(run.outputPath);
|
|
985
1114
|
});
|
|
986
1115
|
context.hook("kubb:files:processing:start", async ({ files }) => {
|
|
987
|
-
if (!previous) return;
|
|
1116
|
+
if (!run?.previous) return;
|
|
1117
|
+
const { previous, outputPath } = run;
|
|
988
1118
|
for (const file of files) {
|
|
989
1119
|
if (previous.has(file.path) || isPathInside(outputPath, file.path)) continue;
|
|
990
|
-
const source = await readFile(file.path, "utf8").catch(() => null);
|
|
1120
|
+
const source = await readFile$1(file.path, "utf8").catch(() => null);
|
|
991
1121
|
if (source !== null) previous.set(file.path, source);
|
|
992
1122
|
}
|
|
993
1123
|
});
|
|
994
|
-
context.hook("kubb:file:processed", ({ file, source }) => {
|
|
995
|
-
|
|
1124
|
+
context.hook("kubb:file:processed", ({ file, source, stored = null }) => {
|
|
1125
|
+
const live = run?.live;
|
|
1126
|
+
if (!live) return;
|
|
996
1127
|
const next = source.trim();
|
|
997
|
-
if (next)
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1128
|
+
if (!next) return;
|
|
1129
|
+
live.processed.add(file.path);
|
|
1130
|
+
tallyChange({
|
|
1131
|
+
tally: live.tally,
|
|
1132
|
+
change: diffFile({
|
|
1133
|
+
path: file.path,
|
|
1134
|
+
next,
|
|
1135
|
+
previous: stored ?? live.fingerprints.get(file.path) ?? null
|
|
1136
|
+
})
|
|
1137
|
+
});
|
|
1002
1138
|
});
|
|
1003
1139
|
context.hook("kubb:files:processing:end", ({ files, unchanged }) => {
|
|
1004
|
-
|
|
1005
|
-
|
|
1140
|
+
if (!run) return;
|
|
1141
|
+
run.filesUnchanged = unchanged.length;
|
|
1142
|
+
run.paths = new Set(files.map((file) => file.path));
|
|
1006
1143
|
});
|
|
1144
|
+
/** The run's totals: counted while writing, or worked out by reading the output back. */
|
|
1145
|
+
async function countChanges({ config, storage, current }) {
|
|
1146
|
+
const { live, paths, previous } = current;
|
|
1147
|
+
if (live) {
|
|
1148
|
+
const { tally, fingerprints, processed } = live;
|
|
1149
|
+
for (const [filePath, fingerprint] of fingerprints) if (!paths.has(filePath)) tallyChange({
|
|
1150
|
+
tally,
|
|
1151
|
+
change: {
|
|
1152
|
+
status: "D",
|
|
1153
|
+
path: filePath,
|
|
1154
|
+
removed: fingerprint.deletedLines
|
|
1155
|
+
}
|
|
1156
|
+
});
|
|
1157
|
+
for (const filePath of paths.difference(processed)) if (await storage.readItem(filePath) !== null) tally.unchanged++;
|
|
1158
|
+
return tally;
|
|
1159
|
+
}
|
|
1160
|
+
if (!previous) return void 0;
|
|
1161
|
+
const manifest = dryRun ? await createOutputManifest({
|
|
1162
|
+
storage,
|
|
1163
|
+
cache: cacheStorage({ root: config.root })
|
|
1164
|
+
}) : void 0;
|
|
1165
|
+
const diff = await diffOutput({
|
|
1166
|
+
storage,
|
|
1167
|
+
paths,
|
|
1168
|
+
clean: Boolean(config.output.clean),
|
|
1169
|
+
manifest,
|
|
1170
|
+
previousFiles: previous
|
|
1171
|
+
});
|
|
1172
|
+
const changes = createChangeTally();
|
|
1173
|
+
changes.unchanged = diff.unchanged;
|
|
1174
|
+
for (const file of diff.files) tallyChange({
|
|
1175
|
+
tally: changes,
|
|
1176
|
+
change: file
|
|
1177
|
+
});
|
|
1178
|
+
return changes;
|
|
1179
|
+
}
|
|
1007
1180
|
context.hook("kubb:generation:end", async ({ config, storage, diagnostics = [], filesCreated = 0, status = "success", hrStart = process.hrtime() }) => {
|
|
1181
|
+
const current = run;
|
|
1182
|
+
run = void 0;
|
|
1008
1183
|
const result = {
|
|
1009
1184
|
config,
|
|
1010
1185
|
diagnostics,
|
|
1011
1186
|
filesCreated,
|
|
1012
|
-
filesUnchanged,
|
|
1187
|
+
filesUnchanged: current?.filesUnchanged ?? 0,
|
|
1013
1188
|
dryRun,
|
|
1014
1189
|
status,
|
|
1015
1190
|
hrStart
|
|
1016
1191
|
};
|
|
1017
1192
|
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;
|
|
1193
|
+
const counted = current && status !== "failed" ? await countChanges({
|
|
1194
|
+
config,
|
|
1195
|
+
storage,
|
|
1196
|
+
current
|
|
1197
|
+
}) : void 0;
|
|
1198
|
+
if (counted) {
|
|
1199
|
+
const { unchanged, ...changes } = counted;
|
|
1200
|
+
cliResult.filesCreated = changes.added + changes.modified + unchanged;
|
|
1201
|
+
cliResult.filesUnchanged = unchanged;
|
|
1050
1202
|
cliResult.fileChanges = changes;
|
|
1051
1203
|
}
|
|
1052
1204
|
for (const reporter of selected) {
|
|
@@ -1070,4 +1222,4 @@ function selectReporters(reporters, names) {
|
|
|
1070
1222
|
}
|
|
1071
1223
|
export { startWatcher as a, listenForKeys as i, setupReporters as n, trackBuild as o, diffBuilds as r, selectReporters as t };
|
|
1072
1224
|
|
|
1073
|
-
//# sourceMappingURL=reporters-
|
|
1225
|
+
//# sourceMappingURL=reporters-DeruUk9K.js.map
|