@visulima/task-runner 1.0.0-alpha.2 → 1.0.0-alpha.20

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 (102) hide show
  1. package/CHANGELOG.md +310 -0
  2. package/README.md +198 -52
  3. package/dist/index.d.ts +3795 -34
  4. package/dist/index.js +1 -20
  5. package/dist/packem_chunks/index.js +31 -0
  6. package/dist/packem_shared/Cache-C8FfeXpg.js +2 -0
  7. package/dist/packem_shared/CompositeLifeCycle-C6aee9GK.js +1 -0
  8. package/dist/packem_shared/FileAccessTracker-DBz_w4wl.js +50 -0
  9. package/dist/packem_shared/FingerprintManager-CYW2EwLc.js +2 -0
  10. package/dist/packem_shared/HttpRemoteCache-CpPl6lzE.js +1 -0
  11. package/dist/packem_shared/INPUT_URI_SCHEMES-Csrd0tlg.js +1 -0
  12. package/dist/packem_shared/IncrementalFileHasher-B-V3i2x-.js +1 -0
  13. package/dist/packem_shared/LogReporter-3R3oWj-Q.js +13 -0
  14. package/dist/packem_shared/ReapiRemoteCache-BXJip5wH.js +251 -0
  15. package/dist/packem_shared/TaskOrchestrator-CYj5MLwz.js +6 -0
  16. package/dist/packem_shared/TerminalBuffer-BtZy7TpT.js +3 -0
  17. package/dist/packem_shared/TrackedTaskExecutor-CtYLL3vS.js +1 -0
  18. package/dist/packem_shared/V2_ROOT-injxWBrl.js +1 -0
  19. package/dist/packem_shared/actionDigestForTaskHash-BOL4fZ9v.js +1 -0
  20. package/dist/packem_shared/archive-CDfGy5Lm.js +1 -0
  21. package/dist/packem_shared/buildForwardDependencyMap-DudUDFze.js +3 -0
  22. package/dist/packem_shared/collectFiles-W4bnBRpb.js +1 -0
  23. package/dist/packem_shared/collectNodeModulesBinDirs-CD-eDrtO.js +1 -0
  24. package/dist/packem_shared/computeTaskHash-CaPdG1BA.js +1 -0
  25. package/dist/packem_shared/containsBlob-DAU8R7GH.js +1 -0
  26. package/dist/packem_shared/createInputHandler-CkDCpPYy.js +1 -0
  27. package/dist/packem_shared/createTaskGraph-D8Jn_Dn9.js +1 -0
  28. package/dist/packem_shared/defaultTaskRunner-DMHpavzm.js +2 -0
  29. package/dist/packem_shared/detectFrameworks-WVZJOPgN.js +1 -0
  30. package/dist/packem_shared/detectScriptShell-CaTDk5cW.js +1 -0
  31. package/dist/packem_shared/digestBuffer-g11aCaDx.js +1 -0
  32. package/dist/packem_shared/enforceProjectConstraints-dNc1SwRi.js +1 -0
  33. package/dist/packem_shared/expandArguments-D7qvc6Rp.js +1 -0
  34. package/dist/packem_shared/expandShortcut-BErNHNXZ.js +1 -0
  35. package/dist/packem_shared/expandTokensInString-DVSFEdWu.js +1 -0
  36. package/dist/packem_shared/expandWildcard-DE0dOOZF.js +1 -0
  37. package/dist/packem_shared/extractPackageName-BeL6Gc3a.js +1 -0
  38. package/dist/packem_shared/findCycle-BY8-jmzB.js +1 -0
  39. package/dist/packem_shared/formatTimingTable-CP3rsDwf.js +7 -0
  40. package/dist/packem_shared/generateRunSummary-L9Z2NfWn.js +1 -0
  41. package/dist/packem_shared/getCurrentBranch-D-qoZByx.js +1 -0
  42. package/dist/packem_shared/getMainWorktreeRoot-DB9P2wDL.js +1 -0
  43. package/dist/packem_shared/isNativeAvailable-CkTjxb7P.js +1 -0
  44. package/dist/packem_shared/parseCommands-BHsXoUCd.js +1 -0
  45. package/dist/packem_shared/parsePartition-Bt1jBjZH.js +1 -0
  46. package/dist/packem_shared/projectGraphToDot-FN6oHDGH.js +250 -0
  47. package/dist/packem_shared/resolveCacheMode--4y60ODd.js +1 -0
  48. package/dist/packem_shared/resolveOutputs-CzGGEbcP.js +1 -0
  49. package/dist/packem_shared/runConcurrentFallback-BhJCT2LA.js +3 -0
  50. package/dist/packem_shared/runConcurrently-D1Ytsjaj.js +1 -0
  51. package/dist/packem_shared/runTeardown-DAn1xFWJ.js +1 -0
  52. package/dist/packem_shared/shell-quote-BhmqDUL1.js +1 -0
  53. package/dist/packem_shared/stripQuotes-jkZb0CL9.js +1 -0
  54. package/dist/packem_shared/toChromeTrace-DxN5NQIU.js +1 -0
  55. package/dist/packem_shared/tracked-executor-B90U4Um3.js +3 -0
  56. package/dist/packem_shared/utils-BH2W5Wml.js +1 -0
  57. package/dist/packem_shared/withRestart-DKtEGsQA.js +1 -0
  58. package/index.js +603 -0
  59. package/package.json +31 -19
  60. package/binding.js +0 -204
  61. package/dist/affected.d.ts +0 -48
  62. package/dist/cache.d.ts +0 -103
  63. package/dist/default-task-runner.d.ts +0 -44
  64. package/dist/file-access-tracker.d.ts +0 -53
  65. package/dist/fingerprint.d.ts +0 -45
  66. package/dist/framework-inference.d.ts +0 -35
  67. package/dist/graph-visualizer.d.ts +0 -74
  68. package/dist/incremental-hasher.d.ts +0 -58
  69. package/dist/life-cycle.d.ts +0 -36
  70. package/dist/lockfile-hasher.d.ts +0 -73
  71. package/dist/native-binding.d.ts +0 -64
  72. package/dist/packem_shared/Cache-IYpTYVUC.js +0 -298
  73. package/dist/packem_shared/CompositeLifeCycle-7AtYw1dv.js +0 -112
  74. package/dist/packem_shared/FileAccessTracker-CrtBAt5D.js +0 -239
  75. package/dist/packem_shared/FingerprintManager-D6Y0erg-.js +0 -227
  76. package/dist/packem_shared/IncrementalFileHasher-Ds3J6dgb.js +0 -151
  77. package/dist/packem_shared/RemoteCache-BDqrnDEi.js +0 -179
  78. package/dist/packem_shared/TaskOrchestrator-BvYs3ONw.js +0 -342
  79. package/dist/packem_shared/TaskScheduler-CJilHDta.js +0 -111
  80. package/dist/packem_shared/TrackedTaskExecutor-BGUKFE-7.js +0 -164
  81. package/dist/packem_shared/collectFiles-ClXHnHhg.js +0 -22
  82. package/dist/packem_shared/computeTaskHash-BoCnnvIJ.js +0 -356
  83. package/dist/packem_shared/createTaskGraph-CcsFaSrz.js +0 -164
  84. package/dist/packem_shared/defaultTaskRunner-CrW4v5Ye.js +0 -79
  85. package/dist/packem_shared/detectFrameworks-CeFzKE6J.js +0 -101
  86. package/dist/packem_shared/extractPackageName-CbVNW-dr.js +0 -189
  87. package/dist/packem_shared/filterAffectedTasks-I-18zPg6.js +0 -135
  88. package/dist/packem_shared/findCycle-DF4_BRdO.js +0 -212
  89. package/dist/packem_shared/generateRunSummary-qn-_jKwt.js +0 -134
  90. package/dist/packem_shared/isNativeAvailable-BWhnZ4ES.js +0 -19
  91. package/dist/packem_shared/projectGraphToDot-VdTjHcVp.js +0 -202
  92. package/dist/packem_shared/utils-zO0ZRgtf.js +0 -390
  93. package/dist/remote-cache.d.ts +0 -55
  94. package/dist/run-summary.d.ts +0 -89
  95. package/dist/task-graph-utils.d.ts +0 -39
  96. package/dist/task-graph.d.ts +0 -22
  97. package/dist/task-hasher.d.ts +0 -67
  98. package/dist/task-orchestrator.d.ts +0 -38
  99. package/dist/task-scheduler.d.ts +0 -18
  100. package/dist/tracked-executor.d.ts +0 -46
  101. package/dist/types.d.ts +0 -385
  102. package/dist/utils.d.ts +0 -39
@@ -1,390 +0,0 @@
1
- import { createRequire as __cjs_createRequire } from "node:module";
2
-
3
- const __cjs_require = __cjs_createRequire(import.meta.url);
4
-
5
- const __cjs_getProcess = typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined" ? globalThis.process : process;
6
-
7
- const __cjs_getBuiltinModule = (module) => {
8
- // Check if we're in Node.js and version supports getBuiltinModule
9
- if (typeof __cjs_getProcess !== "undefined" && __cjs_getProcess.versions && __cjs_getProcess.versions.node) {
10
- const [major, minor] = __cjs_getProcess.versions.node.split(".").map(Number);
11
- // Node.js 20.16.0+ and 22.3.0+
12
- if (major > 22 || (major === 22 && minor >= 3) || (major === 20 && minor >= 16)) {
13
- return __cjs_getProcess.getBuiltinModule(module);
14
- }
15
- }
16
- // Fallback to createRequire
17
- return __cjs_require(module);
18
- };
19
-
20
- const {
21
- stat,
22
- realpath,
23
- readdir,
24
- readFile
25
- } = __cjs_getBuiltinModule("node:fs/promises");
26
- import { join } from '@visulima/path';
27
-
28
- const MASK_128 = (1n << 128n) - 1n;
29
- const MASK_64 = (1n << 64n) - 1n;
30
- const MASK_32 = (1n << 32n) - 1n;
31
- const PRIME32_1 = 0x9E3779B1n;
32
- const PRIME32_2 = 0x85EBCA77n;
33
- const PRIME32_3 = 0xC2B2AE3Dn;
34
- const PRIME64_1 = 0x9E3779B185EBCA87n;
35
- const PRIME64_2 = 0xC2B2AE3D27D4EB4Fn;
36
- const PRIME64_3 = 0x165667B19E3779F9n;
37
- const PRIME64_4 = 0x85EBCA77C2B2AE63n;
38
- const PRIME64_5 = 0x27D4EB2F165667C5n;
39
- const PRIME_MX1 = 0x165667919E3779F9n;
40
- const PRIME_MX2 = 0x9FB21C651E98DF25n;
41
- const STRIPE_LEN = 64;
42
- const ACC_NB = STRIPE_LEN / 8;
43
- const U64 = 8;
44
- const KKEY = Buffer.from(
45
- "b8fe6c3923a44bbe7c01812cf721ad1cded46de9839097db7240a4a4b7b3671fcb79e64eccc0e578825ad07dccff7221b8084674f743248ee03590e6813a264c3c2852bb91c300cb88d0658b1b532ea371644897a20df94e3819ef46a9deacd8a8fa763fe39c343ff9dcbbc7c70b4f1d8a51e04bcdb45931c89f7ec9d9787364eac5ac8334d3ebc3c581a0fffa1363eb170ddd51b7f0da49d316552629d4689e2b16be587d47a1fc8ff8b8d17ad031ce45cb3a8f95160428afd7fbcabb4b407e",
46
- "hex"
47
- );
48
- const getView = (buf, offset = 0) => Buffer.from(buf.buffer, buf.byteOffset + offset, buf.length - offset);
49
- const bswap64 = (a) => {
50
- const scratch = Buffer.allocUnsafe(8);
51
- scratch.writeBigUInt64LE(a);
52
- return scratch.readBigUInt64BE();
53
- };
54
- const bswap32 = (a) => {
55
- let v = a;
56
- v = (v & 0x0000FFFFn) << 16n | (v & 0xFFFF0000n) >> 16n;
57
- v = (v & 0x00FF00FFn) << 8n | (v & 0xFF00FF00n) >> 8n;
58
- return v;
59
- };
60
- const multU32ToU64 = (a, b) => (a & MASK_32) * (b & MASK_32) & MASK_64;
61
- const rotl32 = (a, b) => (a << b | a >> 32n - b) & MASK_32;
62
- const xorshift64 = (b, shift) => b ^ b >> shift;
63
- const inv64 = (x) => ~x + 1n & MASK_64;
64
- const mul128Fold64 = (a, b) => {
65
- const lll = a * b & MASK_128;
66
- return lll & MASK_64 ^ lll >> 64n;
67
- };
68
- const avalanche = (h) => {
69
- let v = h;
70
- v ^= v >> 37n;
71
- v = v * PRIME_MX1 & MASK_64;
72
- v ^= v >> 32n;
73
- return v;
74
- };
75
- const avalanche64 = (h) => {
76
- let v = h;
77
- v ^= v >> 33n;
78
- v = v * PRIME64_2 & MASK_64;
79
- v ^= v >> 29n;
80
- v = v * PRIME64_3 & MASK_64;
81
- v ^= v >> 32n;
82
- return v;
83
- };
84
- const accumulate512 = (acc, data, key) => {
85
- for (let i = 0; i < ACC_NB; i++) {
86
- const dataVal = data.readBigUInt64LE(i * 8);
87
- const dataKey = dataVal ^ key.readBigUInt64LE(i * 8);
88
- acc[i ^ 1] += dataVal;
89
- acc[i] += multU32ToU64(dataKey, dataKey >> 32n);
90
- }
91
- return acc;
92
- };
93
- const accumulate = (acc, data, key, nbStripes) => {
94
- for (let i = 0; i < nbStripes; i++) {
95
- accumulate512(acc, getView(data, i * STRIPE_LEN), getView(key, i * 8));
96
- }
97
- return acc;
98
- };
99
- const scrambleAcc = (acc, key) => {
100
- for (let i = 0; i < ACC_NB; i++) {
101
- const key64 = key.readBigUInt64LE(i * 8);
102
- let acc64 = acc[i];
103
- acc64 = xorshift64(acc64, 47n);
104
- acc64 ^= key64;
105
- acc64 *= PRIME32_1;
106
- acc[i] = acc64 & MASK_64;
107
- }
108
- return acc;
109
- };
110
- const mix2Accs = (acc, key) => (
111
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
112
- mul128Fold64(acc[0] ^ key.readBigUInt64LE(0), acc[1] ^ key.readBigUInt64LE(U64))
113
- );
114
- const mergeAccs = (acc, key, start) => {
115
- let result64 = start;
116
- result64 += mix2Accs(acc.slice(0), getView(key, 0));
117
- result64 += mix2Accs(acc.slice(2), getView(key, 16));
118
- result64 += mix2Accs(acc.slice(4), getView(key, 32));
119
- result64 += mix2Accs(acc.slice(6), getView(key, 48));
120
- return avalanche(result64 & MASK_64);
121
- };
122
- const hashLong = (acc, data, secret) => {
123
- const nbStripesPerBlock = Math.floor((secret.byteLength - STRIPE_LEN) / 8);
124
- const blockLen = STRIPE_LEN * nbStripesPerBlock;
125
- const nbBlocks = Math.floor((data.byteLength - 1) / blockLen);
126
- for (let i = 0; i < nbBlocks; i++) {
127
- accumulate(acc, getView(data, i * blockLen), secret, nbStripesPerBlock);
128
- scrambleAcc(acc, getView(secret, secret.byteLength - STRIPE_LEN));
129
- }
130
- const nbStripes = Math.floor((data.byteLength - 1 - blockLen * nbBlocks) / STRIPE_LEN);
131
- accumulate(acc, getView(data, nbBlocks * blockLen), secret, nbStripes);
132
- accumulate512(acc, getView(data, data.byteLength - STRIPE_LEN), getView(secret, secret.byteLength - STRIPE_LEN - 7));
133
- return acc;
134
- };
135
- const hashLong128b = (data, secret) => {
136
- const acc = new BigUint64Array([PRIME32_3, PRIME64_1, PRIME64_2, PRIME64_3, PRIME64_4, PRIME32_2, PRIME64_5, PRIME32_1]);
137
- hashLong(acc, data, secret);
138
- const low64 = mergeAccs(acc, getView(secret, 11), BigInt(data.byteLength) * PRIME64_1 & MASK_64);
139
- const high64 = mergeAccs(
140
- acc,
141
- getView(secret, secret.byteLength - STRIPE_LEN - 11),
142
- ~(BigInt(data.byteLength) * PRIME64_2) & MASK_64
143
- );
144
- return high64 << 64n | low64;
145
- };
146
- const mix16B = (data, key, seed) => mul128Fold64(
147
- (data.readBigUInt64LE(0) ^ key.readBigUInt64LE(0) + seed) & MASK_64,
148
- (data.readBigUInt64LE(8) ^ key.readBigUInt64LE(8) - seed) & MASK_64
149
- );
150
- const mix32B = (acc, data1, data2, key, seed) => {
151
- let accl = acc & MASK_64;
152
- let acch = acc >> 64n & MASK_64;
153
- accl += mix16B(data1, key, seed);
154
- accl ^= data2.readBigUInt64LE(0) + data2.readBigUInt64LE(8);
155
- accl &= MASK_64;
156
- acch += mix16B(data2, getView(key, 16), seed);
157
- acch ^= data1.readBigUInt64LE(0) + data1.readBigUInt64LE(8);
158
- acch &= MASK_64;
159
- return acch << 64n | accl;
160
- };
161
- const len1to3_128b = (data, key32, seed) => {
162
- const len = data.byteLength;
163
- const combined = BigInt(data.readUInt8(len - 1)) | BigInt(len << 8) | BigInt(data.readUInt8(0) << 16) | BigInt(data.readUInt8(len >> 1) << 24);
164
- const blow = (BigInt(key32.readUInt32LE(0)) ^ BigInt(key32.readUInt32LE(4))) + seed;
165
- const low = (combined ^ blow) & MASK_64;
166
- const bhigh = (BigInt(key32.readUInt32LE(8)) ^ BigInt(key32.readUInt32LE(12))) - seed;
167
- const high = (rotl32(bswap32(combined), 13n) ^ bhigh) & MASK_64;
168
- return (avalanche64(high) & MASK_64) << 64n | avalanche64(low);
169
- };
170
- const len4to8_128b = (data, key32, seed) => {
171
- const len = data.byteLength;
172
- const l1 = data.readUInt32LE(0);
173
- const l2 = data.readUInt32LE(len - 4);
174
- const l64 = BigInt(l1) | BigInt(l2) << 32n;
175
- const bitflip = (key32.readBigUInt64LE(16) ^ key32.readBigUInt64LE(24)) + seed & MASK_64;
176
- const keyed = l64 ^ bitflip;
177
- let m128 = keyed * (PRIME64_1 + (BigInt(len) << 2n)) & MASK_128;
178
- m128 += (m128 & MASK_64) << 65n;
179
- m128 &= MASK_128;
180
- m128 ^= m128 >> 67n;
181
- return xorshift64(xorshift64(m128 & MASK_64, 35n) * PRIME_MX2 & MASK_64, 28n) | avalanche(m128 >> 64n) << 64n;
182
- };
183
- const len9to16_128b = (data, key64, seed) => {
184
- const len = data.byteLength;
185
- const bitflipl = (key64.readBigUInt64LE(32) ^ key64.readBigUInt64LE(40)) + seed & MASK_64;
186
- const bitfliph = (key64.readBigUInt64LE(48) ^ key64.readBigUInt64LE(56)) - seed & MASK_64;
187
- const ll1 = data.readBigUInt64LE();
188
- let ll2 = data.readBigUInt64LE(len - 8);
189
- let m128 = (ll1 ^ ll2 ^ bitflipl) * PRIME64_1;
190
- const m128l = (m128 & MASK_64) + (BigInt(len - 1) << 54n);
191
- m128 = m128 & (MASK_128 ^ MASK_64) | m128l;
192
- ll2 ^= bitfliph;
193
- m128 += ll2 + (ll2 & MASK_32) * (PRIME32_2 - 1n) << 64n;
194
- m128 &= MASK_128;
195
- m128 ^= bswap64(m128 >> 64n);
196
- let h128 = (m128 & MASK_64) * PRIME64_2;
197
- h128 += (m128 >> 64n) * PRIME64_2 << 64n;
198
- h128 &= MASK_128;
199
- return avalanche(h128 & MASK_64) | avalanche(h128 >> 64n) << 64n;
200
- };
201
- const len0to16_128b = (data, seed) => {
202
- const len = data.byteLength;
203
- if (len > 8) {
204
- return len9to16_128b(data, KKEY, seed);
205
- }
206
- if (len >= 4) {
207
- return len4to8_128b(data, KKEY, seed);
208
- }
209
- if (len > 0) {
210
- return len1to3_128b(data, KKEY, seed);
211
- }
212
- return avalanche64(seed ^ KKEY.readBigUInt64LE(64) ^ KKEY.readBigUInt64LE(72)) | avalanche64(seed ^ KKEY.readBigUInt64LE(80) ^ KKEY.readBigUInt64LE(88)) << 64n;
213
- };
214
- const len17to128_128b = (data, secret, seed) => {
215
- let acc = BigInt(data.byteLength) * PRIME64_1 & MASK_64;
216
- let i = BigInt(data.byteLength - 1) / 32n;
217
- while (i >= 0n) {
218
- const ni = Number(i);
219
- acc = mix32B(acc, getView(data, 16 * ni), getView(data, data.byteLength - 16 * (ni + 1)), getView(secret, 32 * ni), seed);
220
- i--;
221
- }
222
- let h128l = acc + (acc >> 64n) & MASK_64;
223
- h128l = avalanche(h128l);
224
- let h128h = (acc & MASK_64) * PRIME64_1 + (acc >> 64n) * PRIME64_4 + (BigInt(data.byteLength) - seed & MASK_64) * PRIME64_2;
225
- h128h &= MASK_64;
226
- h128h = inv64(avalanche(h128h));
227
- return h128l | h128h << 64n;
228
- };
229
- const len129to240_128b = (data, secret, seed) => {
230
- let acc = BigInt(data.byteLength) * PRIME64_1 & MASK_64;
231
- for (let i = 32; i < 160; i += 32) {
232
- acc = mix32B(acc, getView(data, i - 32), getView(data, i - 16), getView(secret, i - 32), seed);
233
- }
234
- acc = avalanche(acc & MASK_64) | avalanche(acc >> 64n) << 64n;
235
- for (let i = 160; i <= data.byteLength; i += 32) {
236
- acc = mix32B(acc, getView(data, i - 32), getView(data, i - 16), getView(secret, 3 + i - 160), seed);
237
- }
238
- acc = mix32B(acc, getView(data, data.byteLength - 16), getView(data, data.byteLength - 32), getView(secret, 136 - 17 - 16), inv64(seed));
239
- let h128l = acc + (acc >> 64n) & MASK_64;
240
- h128l = avalanche(h128l);
241
- let h128h = (acc & MASK_64) * PRIME64_1 + (acc >> 64n) * PRIME64_4 + (BigInt(data.byteLength) - seed & MASK_64) * PRIME64_2;
242
- h128h &= MASK_64;
243
- h128h = inv64(avalanche(h128h));
244
- return h128l | h128h << 64n;
245
- };
246
- const xxh3_128 = (data, seed = 0n) => {
247
- const len = data.byteLength;
248
- if (len <= 16) {
249
- return len0to16_128b(data, seed);
250
- }
251
- if (len <= 128) {
252
- return len17to128_128b(data, KKEY, seed);
253
- }
254
- if (len <= 240) {
255
- return len129to240_128b(data, KKEY, seed);
256
- }
257
- return hashLong128b(data, KKEY);
258
- };
259
- const bigintToHex = (value) => {
260
- const hi = value >> 64n & MASK_64;
261
- const lo = value & MASK_64;
262
- return hi.toString(16).padStart(16, "0") + lo.toString(16).padStart(16, "0");
263
- };
264
- const xxh3Hash = (data) => bigintToHex(xxh3_128(data));
265
- class Xxh3Hasher {
266
- #chunks = [];
267
- update(data) {
268
- if (typeof data === "string") {
269
- this.#chunks.push(Buffer.from(data));
270
- } else {
271
- this.#chunks.push(data);
272
- }
273
- return this;
274
- }
275
- digest() {
276
- return xxh3Hash(Buffer.concat(this.#chunks));
277
- }
278
- }
279
- const createXxh3Hasher = () => new Xxh3Hasher();
280
-
281
- const hashFile = async (filePath) => {
282
- try {
283
- const content = await readFile(filePath);
284
- return xxh3Hash(content);
285
- } catch {
286
- return void 0;
287
- }
288
- };
289
- const hashStrings = (...values) => {
290
- const hash = createXxh3Hasher();
291
- for (const v of values) {
292
- hash.update(v);
293
- hash.update("\0");
294
- }
295
- return hash.digest();
296
- };
297
- const sortObjectKeys = (object) => {
298
- const sorted = {};
299
- for (const key of Object.keys(object).toSorted()) {
300
- const value = object[key];
301
- sorted[key] = value !== void 0 && value !== null && typeof value === "object" && !Array.isArray(value) ? sortObjectKeys(value) : value;
302
- }
303
- return sorted;
304
- };
305
- const collectFiles = async (directory, ignoredDirectories, visitedRealPaths) => {
306
- const visited = visitedRealPaths ?? /* @__PURE__ */ new Set();
307
- const results = [];
308
- try {
309
- const directoryStat = await stat(directory);
310
- if (directoryStat.isFile()) {
311
- return [directory];
312
- }
313
- const resolvedPath = await realpath(directory);
314
- if (visited.has(resolvedPath)) {
315
- return [];
316
- }
317
- visited.add(resolvedPath);
318
- const entries = await readdir(directory, { withFileTypes: true });
319
- const promises = entries.map(async (entry) => {
320
- if (ignoredDirectories.has(entry.name)) {
321
- return [];
322
- }
323
- const fullPath = join(directory, entry.name);
324
- if (entry.isDirectory()) {
325
- return collectFiles(fullPath, ignoredDirectories, visited);
326
- }
327
- if (entry.isFile()) {
328
- return [fullPath];
329
- }
330
- if (entry.isSymbolicLink()) {
331
- try {
332
- const linkStat = await stat(fullPath);
333
- if (linkStat.isFile()) {
334
- return [fullPath];
335
- }
336
- if (linkStat.isDirectory()) {
337
- return collectFiles(fullPath, ignoredDirectories, visited);
338
- }
339
- } catch {
340
- }
341
- }
342
- return [];
343
- });
344
- const nested = await Promise.all(promises);
345
- for (const files of nested) {
346
- results.push(...files);
347
- }
348
- } catch {
349
- }
350
- return results;
351
- };
352
- const resolveTaskCwd = (workspaceRoot, task) => task.projectRoot ? join(workspaceRoot, task.projectRoot) : workspaceRoot;
353
- const createFailureResult = (task, error, startTime) => {
354
- return {
355
- code: 1,
356
- endTime: Date.now(),
357
- startTime,
358
- status: "failure",
359
- task,
360
- terminalOutput: error instanceof Error ? error.message : String(error)
361
- };
362
- };
363
- const READ_PACKAGE_DEPS_DEFAULTS = { optional: true, peer: true };
364
- const readPackageDeps = async (packageJsonPath, options = READ_PACKAGE_DEPS_DEFAULTS) => {
365
- try {
366
- const content = await readFile(packageJsonPath, "utf8");
367
- const pkg = JSON.parse(content);
368
- const deps = /* @__PURE__ */ new Set();
369
- const maps = [pkg.dependencies, pkg.devDependencies];
370
- if (options.peer !== false) {
371
- maps.push(pkg.peerDependencies);
372
- }
373
- if (options.optional !== false) {
374
- maps.push(pkg.optionalDependencies);
375
- }
376
- for (const depMap of maps) {
377
- if (depMap) {
378
- for (const name of Object.keys(depMap)) {
379
- deps.add(name);
380
- }
381
- }
382
- }
383
- return deps;
384
- } catch {
385
- return void 0;
386
- }
387
- };
388
- const uniqueId = () => `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
389
-
390
- export { createFailureResult as a, hashStrings as b, collectFiles as c, resolveTaskCwd as d, createXxh3Hasher as e, hashFile as h, readPackageDeps as r, sortObjectKeys as s, uniqueId as u, xxh3Hash as x };
@@ -1,55 +0,0 @@
1
- /**
2
- * Options for the remote cache.
3
- */
4
- interface RemoteCacheOptions {
5
- /**
6
- * Called when a fire-and-forget upload fails.
7
- * Since uploads are non-blocking, errors are silently swallowed by default.
8
- * Provide this callback to log or report upload failures.
9
- */
10
- onUploadError?: (hash: string, error: unknown) => void;
11
- /** Whether to enable remote cache reads */
12
- read?: boolean;
13
- /** Team ID or namespace for cache isolation */
14
- teamId?: string;
15
- /** Request timeout in milliseconds (default: 30000) */
16
- timeout?: number;
17
- /** Authentication token for the remote cache */
18
- token?: string;
19
- /** Remote cache server URL (e.g., "https://cache.example.com") */
20
- url: string;
21
- /** Whether to enable remote cache writes */
22
- write?: boolean;
23
- }
24
- /**
25
- * HTTP-based remote cache compatible with the Turborepo remote cache protocol.
26
- *
27
- * Protocol:
28
- * - GET /v8/artifacts/{hash}?teamId={team} -> retrieve cached artifact (gzipped tar)
29
- * - PUT /v8/artifacts/{hash}?teamId={team} -> store artifact
30
- * - POST /v8/artifacts/events -> analytics (optional)
31
- *
32
- * Authentication via `Authorization: Bearer {token}` header.
33
- *
34
- * The cache entry is a gzipped tarball containing the cache directory contents
35
- * (code, terminalOutput, fingerprint.json, outputs/, .commit).
36
- */
37
- declare class RemoteCache {
38
- #private;
39
- constructor(options: RemoteCacheOptions);
40
- /**
41
- * Retrieves a cached artifact from the remote cache.
42
- * Returns the local path to the extracted cache entry, or undefined if not found.
43
- */
44
- retrieve(hash: string, localCacheDirectory: string): Promise<boolean>;
45
- /**
46
- * Stores a cache entry in the remote cache.
47
- */
48
- store(hash: string, localCacheDirectory: string): Promise<boolean>;
49
- /**
50
- * Checks if an artifact exists in the remote cache without downloading it.
51
- */
52
- exists(hash: string): Promise<boolean>;
53
- }
54
- export type { RemoteCacheOptions };
55
- export { RemoteCache };
@@ -1,89 +0,0 @@
1
- import type { TaskGraph, TaskHashDetails, TaskResults } from "./types.d.ts";
2
- /**
3
- * Summary of a single task execution.
4
- */
5
- interface TaskSummary {
6
- /** Whether the task was cacheable */
7
- cacheable: boolean;
8
- /** Cache status */
9
- cacheStatus: "HIT" | "MISS" | "REMOTE_HIT" | "SKIPPED";
10
- /** Dependencies on other tasks */
11
- dependencies: string[];
12
- /** Duration in milliseconds */
13
- duration: number | undefined;
14
- /** End time (ISO 8601) */
15
- endTime: string | undefined;
16
- /** Exit code */
17
- exitCode: number | undefined;
18
- /** The computed cache hash */
19
- hash: string | undefined;
20
- /** Detailed hash information */
21
- hashDetails: TaskHashDetails | undefined;
22
- /** The task's declared outputs */
23
- outputs: string[];
24
- /** Start time (ISO 8601) */
25
- startTime: string | undefined;
26
- /** The task target */
27
- target: {
28
- configuration?: string;
29
- project: string;
30
- target: string;
31
- };
32
- /** The task ID (e.g., "app:build") */
33
- taskId: string;
34
- }
35
- /**
36
- * Complete summary of a task runner execution.
37
- */
38
- interface RunSummary {
39
- /** Total duration in milliseconds */
40
- duration: number;
41
- /** Run end time (ISO 8601) */
42
- endTime: string;
43
- /** Environment info */
44
- environment: {
45
- /** Architecture */
46
- arch: string;
47
- /** Node.js version */
48
- nodeVersion: string;
49
- /** Platform */
50
- platform: string;
51
- };
52
- /** Unique run ID */
53
- id: string;
54
- /** Run start time (ISO 8601) */
55
- startTime: string;
56
- /** Overall execution statistics */
57
- stats: {
58
- /** Number of cached tasks (local + remote) */
59
- cached: number;
60
- /** Number of failed tasks */
61
- failed: number;
62
- /** Number of skipped tasks */
63
- skipped: number;
64
- /** Number of successful tasks */
65
- succeeded: number;
66
- /** Total number of tasks */
67
- total: number;
68
- };
69
- /** The task graph used for this run */
70
- taskGraph: {
71
- dependencies: Record<string, string[]>;
72
- roots: string[];
73
- };
74
- /** Summary of each task */
75
- tasks: TaskSummary[];
76
- }
77
- /**
78
- * Generates a run summary from task results.
79
- */
80
- declare const generateRunSummary: (results: TaskResults, taskGraph: TaskGraph, startTime: number) => RunSummary;
81
- /**
82
- * Writes the run summary to a JSON file in the `.task-runner/runs/` directory.
83
- * @param summary The run summary to write
84
- * @param workspaceRoot The workspace root directory
85
- * @returns The path to the written summary file
86
- */
87
- declare const writeRunSummary: (summary: RunSummary, workspaceRoot: string) => Promise<string>;
88
- export type { RunSummary, TaskSummary };
89
- export { generateRunSummary, writeRunSummary };
@@ -1,39 +0,0 @@
1
- import type { TaskGraph } from "./types.d.ts";
2
- /**
3
- * Finds a single cycle in the task graph, if one exists.
4
- * Returns the cycle as an array of task IDs, or null if no cycle exists.
5
- */
6
- export declare const findCycle: (taskGraph: TaskGraph) => string[] | undefined;
7
- /**
8
- * Finds all cycles in the task graph.
9
- */
10
- export declare const findCycles: (taskGraph: TaskGraph) => string[][];
11
- /**
12
- * Walks the task graph in topological order (dependencies before dependents),
13
- * calling the callback for each task.
14
- *
15
- * Note: If the graph contains cycles, tasks involved in cycles will not be visited.
16
- * Use `findCycle` to detect cycles before walking if complete traversal is required.
17
- */
18
- export declare const walkTaskGraph: (taskGraph: TaskGraph, callback: (taskId: string) => void) => void;
19
- /**
20
- * Returns a reversed copy of the task graph (edges point in the opposite direction).
21
- */
22
- export declare const reverseTaskGraph: (taskGraph: TaskGraph) => TaskGraph;
23
- /**
24
- * Returns the leaf tasks (tasks with no dependencies of their own).
25
- */
26
- export declare const getLeafTasks: (taskGraph: TaskGraph) => string[];
27
- /**
28
- * Removes edges that form cycles, making the graph acyclic.
29
- * Returns a new task graph without the cycle-forming edges.
30
- */
31
- export declare const makeAcyclic: (taskGraph: TaskGraph) => TaskGraph;
32
- /**
33
- * Gets all tasks that depend on the given task (directly or transitively).
34
- */
35
- export declare const getDependentTasks: (taskGraph: TaskGraph, taskId: string) => string[];
36
- /**
37
- * Gets all tasks that the given task depends on (directly or transitively).
38
- */
39
- export declare const getTransitiveDependencies: (taskGraph: TaskGraph, taskId: string) => string[];
@@ -1,22 +0,0 @@
1
- import type { ProjectGraph, TargetConfiguration, Task, TaskGraph, TaskTarget, WorkspaceConfiguration } from "./types.d.ts";
2
- interface CreateTaskGraphOptions {
3
- /** The project graph */
4
- projectGraph: ProjectGraph;
5
- /** Target default configurations */
6
- targetDefaults?: Record<string, Partial<TargetConfiguration>>;
7
- /** The workspace configuration */
8
- workspace: WorkspaceConfiguration;
9
- }
10
- /**
11
- * Creates a unique task ID from a target.
12
- */
13
- declare const getTaskId: (target: TaskTarget) => string;
14
- /**
15
- * Parses a task ID into its component parts.
16
- */
17
- declare const parseTaskId: (taskId: string) => TaskTarget;
18
- /**
19
- * Creates a task graph from a list of tasks, resolving all dependencies.
20
- */
21
- declare const createTaskGraph: (initialTasks: Task[], options: CreateTaskGraphOptions) => TaskGraph;
22
- export { createTaskGraph, getTaskId, parseTaskId };
@@ -1,67 +0,0 @@
1
- import type { NamedInputs, ProjectConfiguration, TargetConfiguration, Task, TaskHashDetails } from "./types.d.ts";
2
- /**
3
- * Interface for task hashers.
4
- */
5
- interface TaskHasher {
6
- hashTask: (task: Task) => Promise<TaskHashDetails>;
7
- }
8
- /**
9
- * Options for creating an InProcessTaskHasher.
10
- */
11
- interface TaskHasherOptions {
12
- /** Additional environment variables to include in hash */
13
- envVars?: string[];
14
- /**
15
- * Enable framework environment variable inference.
16
- * When true, auto-detects frameworks and includes their public
17
- * env var prefixes in the task hash.
18
- * @default false
19
- */
20
- frameworkInference?: boolean;
21
- /**
22
- * Global environment variables that invalidate all task hashes.
23
- */
24
- globalEnv?: string[];
25
- /**
26
- * Global input files that invalidate all task hashes when changed.
27
- * These are workspace-root-relative paths (e.g., "pnpm-lock.yaml").
28
- */
29
- globalInputs?: string[];
30
- /** Named input definitions */
31
- namedInputs?: NamedInputs;
32
- /** Project configurations keyed by project name */
33
- projects: Record<string, ProjectConfiguration>;
34
- /**
35
- * Enable smart lockfile hashing.
36
- * When true, instead of hashing the entire lockfile, only the resolved
37
- * versions of a package's actual dependencies are hashed.
38
- * This means changing the lockfile only busts cache for affected packages.
39
- *
40
- * Matches Turborepo's smart lockfile hashing behavior.
41
- * @default false
42
- */
43
- smartLockfileHashing?: boolean;
44
- /** Target default configurations */
45
- targetDefaults?: Record<string, Partial<TargetConfiguration>>;
46
- /** The workspace root directory */
47
- workspaceRoot: string;
48
- }
49
- /**
50
- * Computes hashes for tasks based on their inputs.
51
- * Used to determine if a cached result can be reused.
52
- */
53
- declare class InProcessTaskHasher implements TaskHasher {
54
- #private;
55
- constructor(options: TaskHasherOptions);
56
- hashTask(task: Task): Promise<TaskHashDetails>;
57
- clearCache(): void;
58
- }
59
- /**
60
- * Computes the final hash for a task from its hash details.
61
- * Uses native Rust xxh3-128 when available, otherwise pure TS xxh3-ts.
62
- * Both produce identical xxh3-128 hashes, ensuring cache compatibility
63
- * regardless of whether the native addon is loaded.
64
- */
65
- declare const computeTaskHash: (hashDetails: TaskHashDetails) => string;
66
- export { computeTaskHash, InProcessTaskHasher };
67
- export type { TaskHasher, TaskHasherOptions };