@kubb/cli 5.18.6 → 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.
Files changed (193) hide show
  1. package/dist/{Telemetry-CZJ2Noi6.cjs → Telemetry-CBzCK4kO.cjs} +5 -5
  2. package/dist/{Telemetry-CZJ2Noi6.cjs.map → Telemetry-CBzCK4kO.cjs.map} +1 -1
  3. package/dist/{Telemetry-DQG_EpcV.js → Telemetry-DUl_hxVn.js} +5 -5
  4. package/dist/{Telemetry-DQG_EpcV.js.map → Telemetry-DUl_hxVn.js.map} +1 -1
  5. package/dist/{background-Z23KW1yA.js → background-CA9lRKAK.js} +4 -4
  6. package/dist/{background-Z23KW1yA.js.map → background-CA9lRKAK.js.map} +1 -1
  7. package/dist/{background-Dsy12RvL.js → background-DK3HLyNk.js} +1 -1
  8. package/dist/{background-DIVc60mm.cjs → background-fhpYDuSs.cjs} +4 -4
  9. package/dist/{background-DIVc60mm.cjs.map → background-fhpYDuSs.cjs.map} +1 -1
  10. package/dist/{banner-BdTTDFkG.js → banner-BMIxunVW.js} +3 -3
  11. package/dist/{banner-BdTTDFkG.js.map → banner-BMIxunVW.js.map} +1 -1
  12. package/dist/{banner-wJFk-L-c.cjs → banner-GwQ2NFNI.cjs} +3 -3
  13. package/dist/{banner-wJFk-L-c.cjs.map → banner-GwQ2NFNI.cjs.map} +1 -1
  14. package/dist/config-BKi_vTvh.js +1 -0
  15. package/dist/{config-CRrmj88c.cjs → config-BU9xeaGq.cjs} +3 -3
  16. package/dist/{config-CRrmj88c.cjs.map → config-BU9xeaGq.cjs.map} +1 -1
  17. package/dist/{config-Uk3rbZfb.js → config-CGcQTdZV.js} +7 -6
  18. package/dist/config-CGcQTdZV.js.map +1 -0
  19. package/dist/{config-BWj9jBVj.cjs → config-CkTrJD0E.cjs} +7 -6
  20. package/dist/config-CkTrJD0E.cjs.map +1 -0
  21. package/dist/{config-CQTxXvIG.js → config-re864UnO.js} +5 -5
  22. package/dist/config-re864UnO.js.map +1 -0
  23. package/dist/{configFile-BPHxtrEM.cjs → configFile-BQ-Pp7i_.cjs} +5 -5
  24. package/dist/{configFile-BPHxtrEM.cjs.map → configFile-BQ-Pp7i_.cjs.map} +1 -1
  25. package/dist/{configFile-L5i7gGUc.js → configFile-CPXDgTC2.js} +5 -5
  26. package/dist/{configFile-L5i7gGUc.js.map → configFile-CPXDgTC2.js.map} +1 -1
  27. package/dist/{credentials-DEsGwcGD.cjs → credentials-Cl3eOa8G.cjs} +3 -7
  28. package/dist/{credentials-DEsGwcGD.cjs.map → credentials-Cl3eOa8G.cjs.map} +1 -1
  29. package/dist/{credentials-B77iJx9H.js → credentials-DznluKkp.js} +1 -1
  30. package/dist/{credentials-osgjujE_.js → credentials-LPHovWZe.js} +2 -2
  31. package/dist/{credentials-osgjujE_.js.map → credentials-LPHovWZe.js.map} +1 -1
  32. package/dist/{env-rv-VgSGN.js → env-BYZIPHqz.js} +3 -3
  33. package/dist/{env-rv-VgSGN.js.map → env-BYZIPHqz.js.map} +1 -1
  34. package/dist/env-BgVegN_u.js +1 -0
  35. package/dist/{env-eu3XyKqJ.cjs → env-Bi4GXVdd.cjs} +4 -7
  36. package/dist/{env-eu3XyKqJ.cjs.map → env-Bi4GXVdd.cjs.map} +1 -1
  37. package/dist/{errors-BponpdjN.cjs → errors-Bewwe8mY.cjs} +2 -2
  38. package/dist/{errors-BponpdjN.cjs.map → errors-Bewwe8mY.cjs.map} +1 -1
  39. package/dist/{errors-wzqmMpMo.js → errors-CEzFbRvL.js} +2 -2
  40. package/dist/{errors-wzqmMpMo.js.map → errors-CEzFbRvL.js.map} +1 -1
  41. package/dist/{fs-Cf1FSRh9.js → fs-CmODfKN-.js} +27 -8
  42. package/dist/fs-CmODfKN-.js.map +1 -0
  43. package/dist/index.cjs +15 -15
  44. package/dist/index.d.cts +1 -2
  45. package/dist/index.d.ts +1 -2
  46. package/dist/index.js +15 -15
  47. package/dist/{installWithSpinner-CnE4dIza.cjs → installWithSpinner-DZDlVp1J.cjs} +6 -6
  48. package/dist/{installWithSpinner-CnE4dIza.cjs.map → installWithSpinner-DZDlVp1J.cjs.map} +1 -1
  49. package/dist/{installWithSpinner-CNDzLZw-.js → installWithSpinner-gv_OWgww.js} +6 -6
  50. package/dist/{installWithSpinner-CNDzLZw-.js.map → installWithSpinner-gv_OWgww.js.map} +1 -1
  51. package/dist/{intro-DRl-pwVs.js → intro-Dun8Eqod.js} +4 -4
  52. package/dist/{intro-DRl-pwVs.js.map → intro-Dun8Eqod.js.map} +1 -1
  53. package/dist/{intro-DuyzJ3Rb.cjs → intro-PFXmY9bD.cjs} +4 -4
  54. package/dist/{intro-DuyzJ3Rb.cjs.map → intro-PFXmY9bD.cjs.map} +1 -1
  55. package/dist/{isCIEnvironment-D6xtAAZ2.js → isCIEnvironment-DAMZSlP2.js} +2 -2
  56. package/dist/{isCIEnvironment-D6xtAAZ2.js.map → isCIEnvironment-DAMZSlP2.js.map} +1 -1
  57. package/dist/{isCIEnvironment-DiVOMI5Q.cjs → isCIEnvironment-jzKqdVwJ.cjs} +2 -2
  58. package/dist/{isCIEnvironment-DiVOMI5Q.cjs.map → isCIEnvironment-jzKqdVwJ.cjs.map} +1 -1
  59. package/dist/{log-B-1vLxF1.js → log-B_uVM704.js} +3 -3
  60. package/dist/{log-B-1vLxF1.js.map → log-B_uVM704.js.map} +1 -1
  61. package/dist/{log-wv1OxLiq.cjs → log-BzmBldY6.cjs} +3 -3
  62. package/dist/{log-wv1OxLiq.cjs.map → log-BzmBldY6.cjs.map} +1 -1
  63. package/dist/{mascot-CC-D4ON2.cjs → mascot-CLw0Qmln.cjs} +14 -10
  64. package/dist/{mascot-CC-D4ON2.cjs.map → mascot-CLw0Qmln.cjs.map} +1 -1
  65. package/dist/{mascot-CmUUHLlx.js → mascot-b4yXsKwl.js} +14 -10
  66. package/dist/mascot-b4yXsKwl.js.map +1 -0
  67. package/dist/{mcp-D60W6v_6.cjs → mcp-BBD4kdKF.cjs} +3 -3
  68. package/dist/{mcp-D60W6v_6.cjs.map → mcp-BBD4kdKF.cjs.map} +1 -1
  69. package/dist/{mcp-D63ugfbT.js → mcp-CQXp9pcW.js} +3 -3
  70. package/dist/{mcp-D63ugfbT.js.map → mcp-CQXp9pcW.js.map} +1 -1
  71. package/dist/package-CdMFA8OG.js +5 -0
  72. package/dist/package-CdMFA8OG.js.map +1 -0
  73. package/dist/{package-B8KmMINL.cjs → package-DXNoJQYa.cjs} +2 -2
  74. package/dist/package-DXNoJQYa.cjs.map +1 -0
  75. package/dist/{registry-Cy48PGdh.js → registry-BBJpMlM9.js} +4 -4
  76. package/dist/{registry-Cy48PGdh.js.map → registry-BBJpMlM9.js.map} +1 -1
  77. package/dist/{registry-Q77p5TZp.cjs → registry-CTVAqQFn.cjs} +4 -4
  78. package/dist/{registry-Q77p5TZp.cjs.map → registry-CTVAqQFn.cjs.map} +1 -1
  79. package/dist/{reporters-DyjE3BzZ.cjs → reporters-CaJ8brYA.cjs} +258 -106
  80. package/dist/reporters-CaJ8brYA.cjs.map +1 -0
  81. package/dist/{reporters-9MqdcKPp.js → reporters-CzxaQ_bD.js} +1 -1
  82. package/dist/{reporters-B_USHwD6.js → reporters-DeruUk9K.js} +260 -108
  83. package/dist/reporters-DeruUk9K.js.map +1 -0
  84. package/dist/{rolldown-runtime-C3-Zg-KD.cjs → rolldown-runtime-BV8xUvPy.cjs} +4 -4
  85. package/dist/{rolldown-runtime-xo6NMXYd.js → rolldown-runtime-BowF1xt-.js} +0 -1
  86. package/dist/{run-Dx8QpT_k.js → run-96_svbr3.js} +31 -21
  87. package/dist/run-96_svbr3.js.map +1 -0
  88. package/dist/{run-DMvX80Mi.cjs → run-BIgV2zvB.cjs} +4 -4
  89. package/dist/{run-DMvX80Mi.cjs.map → run-BIgV2zvB.cjs.map} +1 -1
  90. package/dist/{run-BA5vGtx3.cjs → run-BSA2x4iE.cjs} +14 -14
  91. package/dist/{run-BA5vGtx3.cjs.map → run-BSA2x4iE.cjs.map} +1 -1
  92. package/dist/{run-D_tbKvAc.js → run-Bi8hhAzv.js} +1 -1
  93. package/dist/{run-83Aaa6qM.cjs → run-Bxqg0GuI.cjs} +8 -8
  94. package/dist/{run-83Aaa6qM.cjs.map → run-Bxqg0GuI.cjs.map} +1 -1
  95. package/dist/{run-Ch7Uuu-u.js → run-C4fd98gp.js} +7 -7
  96. package/dist/{run-Ch7Uuu-u.js.map → run-C4fd98gp.js.map} +1 -1
  97. package/dist/{run-9mcw0FWy.cjs → run-CIEKCdM-.cjs} +19 -19
  98. package/dist/run-CIEKCdM-.cjs.map +1 -0
  99. package/dist/{run-5u7cHD85.js → run-CYdKWpyH.js} +43 -23
  100. package/dist/run-CYdKWpyH.js.map +1 -0
  101. package/dist/{run-DHdlUkYt.js → run-CmHjIMpd.js} +19 -19
  102. package/dist/run-CmHjIMpd.js.map +1 -0
  103. package/dist/{run-CgXrvsL9.js → run-CpyFU0RM.js} +16 -16
  104. package/dist/{run-CgXrvsL9.js.map → run-CpyFU0RM.js.map} +1 -1
  105. package/dist/{run-CfumUZCl.cjs → run-D15oxCOd.cjs} +7 -7
  106. package/dist/{run-CfumUZCl.cjs.map → run-D15oxCOd.cjs.map} +1 -1
  107. package/dist/{run-BxNbFsmc.cjs → run-DLRu4z5Z.cjs} +30 -19
  108. package/dist/run-DLRu4z5Z.cjs.map +1 -0
  109. package/dist/run-Df4PGOFX.js +291 -0
  110. package/dist/run-Df4PGOFX.js.map +1 -0
  111. package/dist/{run-D-FHx4uQ.cjs → run-GdctJlXN.cjs} +42 -21
  112. package/dist/run-GdctJlXN.cjs.map +1 -0
  113. package/dist/{run-Do24e475.js → run-ORjkOWFp.js} +4 -4
  114. package/dist/{run-Do24e475.js.map → run-ORjkOWFp.js.map} +1 -1
  115. package/dist/{run-DhlC3it5.cjs → run-OqiJknWr.cjs} +17 -17
  116. package/dist/{run-DhlC3it5.cjs.map → run-OqiJknWr.cjs.map} +1 -1
  117. package/dist/{run-BD6A0HGa.js → run-U2Ze_QP4.js} +17 -17
  118. package/dist/{run-BD6A0HGa.js.map → run-U2Ze_QP4.js.map} +1 -1
  119. package/dist/{run-DKqUfsTv.js → run-ixh050Ip.js} +8 -8
  120. package/dist/{run-DKqUfsTv.js.map → run-ixh050Ip.js.map} +1 -1
  121. package/dist/run-k-LqKkgU.cjs +294 -0
  122. package/dist/run-k-LqKkgU.cjs.map +1 -0
  123. package/dist/{shared-KKRMm1xX.cjs → shared-DoD3p_X8.cjs} +2 -2
  124. package/dist/{shared-KKRMm1xX.cjs.map → shared-DoD3p_X8.cjs.map} +1 -1
  125. package/dist/{shared-DcDHRtZx.js → shared-SrKde4x4.js} +2 -2
  126. package/dist/{shared-DcDHRtZx.js.map → shared-SrKde4x4.js.map} +1 -1
  127. package/dist/{snapshot-C_11eUdT.cjs → snapshot-C-ge8g3_.cjs} +12 -12
  128. package/dist/snapshot-C-ge8g3_.cjs.map +1 -0
  129. package/dist/{snapshot-CbajkXfi.js → snapshot-CSacL1qI.js} +12 -12
  130. package/dist/snapshot-CSacL1qI.js.map +1 -0
  131. package/dist/{spinner-RfMb7fd6.cjs → spinner-D584jFAz.cjs} +27 -9
  132. package/dist/spinner-D584jFAz.cjs.map +1 -0
  133. package/dist/{spinner-DxsAllRI.js → spinner-D5DgYSS5.js} +3 -3
  134. package/dist/{spinner-DxsAllRI.js.map → spinner-D5DgYSS5.js.map} +1 -1
  135. package/dist/{status-CaEQY12V.js → status-Bq-Bjo2n.js} +4 -4
  136. package/dist/{status-CaEQY12V.js.map → status-Bq-Bjo2n.js.map} +1 -1
  137. package/dist/{status-CgVRLP9A.cjs → status-D-Osmkhr.cjs} +4 -4
  138. package/dist/{status-CgVRLP9A.cjs.map → status-D-Osmkhr.cjs.map} +1 -1
  139. package/dist/{studio-1Otb3b_g.js → studio-BBXKjMN-.js} +18 -18
  140. package/dist/{studio-1Otb3b_g.js.map → studio-BBXKjMN-.js.map} +1 -1
  141. package/dist/{studio-CENejJka.cjs → studio-BZ53idqa.cjs} +18 -18
  142. package/dist/{studio-CENejJka.cjs.map → studio-BZ53idqa.cjs.map} +1 -1
  143. package/dist/studioWorker.js +3 -3
  144. package/dist/{summary-BQWHL_Ca.js → summary-BS-iWuye.js} +4 -4
  145. package/dist/{summary-BQWHL_Ca.js.map → summary-BS-iWuye.js.map} +1 -1
  146. package/dist/{summary-B2Apv5KO.cjs → summary-n4osDoch.cjs} +4 -4
  147. package/dist/{summary-B2Apv5KO.cjs.map → summary-n4osDoch.cjs.map} +1 -1
  148. package/dist/{table-CR7iZJGo.js → table-BKkctGHD.js} +2 -2
  149. package/dist/{table-CR7iZJGo.js.map → table-BKkctGHD.js.map} +1 -1
  150. package/dist/{table-BlRe9YTZ.cjs → table-_fOF5WNI.cjs} +2 -2
  151. package/dist/{table-BlRe9YTZ.cjs.map → table-_fOF5WNI.cjs.map} +1 -1
  152. package/dist/{text-DMiX2dcG.cjs → text-CkCtm5VP.cjs} +2 -2
  153. package/dist/{text-DMiX2dcG.cjs.map → text-CkCtm5VP.cjs.map} +1 -1
  154. package/dist/{text-EoYn04SX.js → text-HYWAcipy.js} +2 -2
  155. package/dist/{text-EoYn04SX.js.map → text-HYWAcipy.js.map} +1 -1
  156. package/dist/{time-3BKoci3G.cjs → time-D4xUq6tx.cjs} +2 -2
  157. package/dist/{time-3BKoci3G.cjs.map → time-D4xUq6tx.cjs.map} +1 -1
  158. package/dist/{time-C-wU7VhC.js → time-D7ONPPZf.js} +2 -2
  159. package/dist/{time-C-wU7VhC.js.map → time-D7ONPPZf.js.map} +1 -1
  160. package/dist/{utils-f1C7RiEI.js → utils-BVccq6W0.js} +4 -4
  161. package/dist/{utils-f1C7RiEI.js.map → utils-BVccq6W0.js.map} +1 -1
  162. package/dist/{utils-DeXBGzGJ.cjs → utils-C9fYoqP2.cjs} +5 -5
  163. package/dist/{utils-DeXBGzGJ.cjs.map → utils-C9fYoqP2.cjs.map} +1 -1
  164. package/dist/{validate-cBMe2ndk.js → validate-BuStuH_z.js} +4 -4
  165. package/dist/{validate-cBMe2ndk.js.map → validate-BuStuH_z.js.map} +1 -1
  166. package/dist/{validate-BPYNc8h8.cjs → validate-rr0LpFhN.cjs} +4 -4
  167. package/dist/{validate-BPYNc8h8.cjs.map → validate-rr0LpFhN.cjs.map} +1 -1
  168. package/package.json +8 -8
  169. package/dist/config-BL3HnFhb.js +0 -1
  170. package/dist/config-BWj9jBVj.cjs.map +0 -1
  171. package/dist/config-CQTxXvIG.js.map +0 -1
  172. package/dist/config-Uk3rbZfb.js.map +0 -1
  173. package/dist/env-C3xHRMez.js +0 -1
  174. package/dist/fs-Cf1FSRh9.js.map +0 -1
  175. package/dist/mascot-CmUUHLlx.js.map +0 -1
  176. package/dist/package-B8KmMINL.cjs.map +0 -1
  177. package/dist/package-Cjh6pjp9.js +0 -5
  178. package/dist/package-Cjh6pjp9.js.map +0 -1
  179. package/dist/reporters-B_USHwD6.js.map +0 -1
  180. package/dist/reporters-DyjE3BzZ.cjs.map +0 -1
  181. package/dist/run-5u7cHD85.js.map +0 -1
  182. package/dist/run-9mcw0FWy.cjs.map +0 -1
  183. package/dist/run-BxNbFsmc.cjs.map +0 -1
  184. package/dist/run-CXYwjh9u.cjs +0 -229
  185. package/dist/run-CXYwjh9u.cjs.map +0 -1
  186. package/dist/run-D-FHx4uQ.cjs.map +0 -1
  187. package/dist/run-DHdlUkYt.js.map +0 -1
  188. package/dist/run-Dx8QpT_k.js.map +0 -1
  189. package/dist/run-m5ZAeYLj.js +0 -226
  190. package/dist/run-m5ZAeYLj.js.map +0 -1
  191. package/dist/snapshot-C_11eUdT.cjs.map +0 -1
  192. package/dist/snapshot-CbajkXfi.js.map +0 -1
  193. package/dist/spinner-RfMb7fd6.cjs.map +0 -1
@@ -1,16 +1,53 @@
1
- import "./rolldown-runtime-xo6NMXYd.js";
2
- import { n as getElapsedMs, t as formatMs } from "./time-C-wU7VhC.js";
3
- import { i as read, n as isPathInside, r as matchesStored } from "./fs-Cf1FSRh9.js";
4
- import { n as formatMsWithColor, t as formatBar } from "./banner-BdTTDFkG.js";
5
- import { o as writer } from "./log-B-1vLxF1.js";
6
- import { n as pluralize, r as toPermissionFlag } from "./text-EoYn04SX.js";
1
+ import "./rolldown-runtime-BowF1xt-.js";
2
+ import { i as read, n as isPathInside, r as matchesStored } from "./fs-CmODfKN-.js";
3
+ import { o as writer } from "./log-B_uVM704.js";
4
+ import { n as getElapsedMs, t as formatMs } from "./time-D7ONPPZf.js";
5
+ import { n as formatMsWithColor, t as formatBar } from "./banner-BMIxunVW.js";
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 { readFile, readdir } from "node:fs/promises";
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 countLineChanges(before, after) {
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 ? before.split("\n") : []) remaining.set(line, (remaining.get(line) ?? 0) + 1);
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
- removed
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. The manifest recognizes output a
853
- * formatter rewrote.
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 !== null && (matchesStored({
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
- }))) return;
961
+ })) return void 0;
864
962
  return {
865
- status: previous === null ? "A" : "M",
963
+ status: "M",
866
964
  path,
867
- ...countLineChanges(previous?.trim() ?? "", previous === null ? next.trimEnd() : next.trim())
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. `counted` holds
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, counted }) {
876
- const generated = new Set(paths);
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
- let change;
884
- if (counted?.has(filePath)) change = counted.get(filePath);
885
- else {
886
- const next = await storage.readItem(filePath);
887
- if (next === null) return;
888
- change = diffFile({
889
- path: filePath,
890
- next,
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 = changes.filter((file) => file !== void 0);
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 (!generated.has(filePath)) files.push({
1021
+ for (const [filePath, source] of previousFiles) if (!paths.has(filePath)) files.push({
902
1022
  status: "D",
903
1023
  path: filePath,
904
- ...countLineChanges(source.trimEnd(), "")
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 filesUnchanged = 0;
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
- filesUnchanged = 0;
977
- paths = [];
978
- outputPath = resolve(config.root, config.output.path);
979
- previous = void 0;
980
- reading = trackChanges && (dryRun || config.storage?.name === "fs") ? readOutputFiles(outputPath) : void 0;
981
- counted = reading && !dryRun && !hasOutputPasses(config) ? /* @__PURE__ */ new Map() : void 0;
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 (reading) previous = await reading;
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
- if (!counted || !previous) return;
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) counted.set(file.path, diffFile({
998
- path: file.path,
999
- next,
1000
- previous: previous.get(file.path) ?? null
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
- filesUnchanged = unchanged.length;
1005
- paths = files.map((file) => file.path);
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
- if (previous && status !== "failed") {
1019
- const manifest = dryRun ? await createOutputManifest({
1020
- storage,
1021
- cache: cacheStorage({ root: config.root })
1022
- }) : void 0;
1023
- const diff = await diffOutput({
1024
- storage,
1025
- paths,
1026
- clean: Boolean(config.output.clean),
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-B_USHwD6.js.map
1225
+ //# sourceMappingURL=reporters-DeruUk9K.js.map