@modootoday/pmcp 0.24.0 → 0.25.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/.agents/plugins/marketplace.json +1 -1
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.mcp.json +1 -1
- package/dist/{affected-D6FRJPPI.js → affected-IPFJM2KD.js} +484 -140
- package/dist/{apply-6JVJ7FDZ.js → apply-6XLLYLJT.js} +15 -14
- package/dist/{broadcast-VKZY7WSD.js → broadcast-34CEG2NQ.js} +5 -2
- package/dist/{chunk-B3OZ4GGO.js → chunk-23PE3HZB.js} +16 -1
- package/dist/{chunk-42SO7KYX.js → chunk-2GD7PQ7J.js} +2 -2
- package/dist/{chunk-7A6QIROT.js → chunk-2TXVOHRS.js} +3 -3
- package/dist/{chunk-QR4GXET7.js → chunk-3P6Y2BAO.js} +3 -3
- package/dist/{chunk-5QBOGEVE.js → chunk-5MUD7FHP.js} +2 -2
- package/dist/{chunk-2GZKA33O.js → chunk-A4P3IIPE.js} +2 -2
- package/dist/{chunk-UFWW4H6V.js → chunk-BG6TONJO.js} +2 -2
- package/dist/{chunk-HES44LTA.js → chunk-C3KRMTIZ.js} +28 -4
- package/dist/{chunk-QY2P54Z2.js → chunk-DITIXBFB.js} +61 -8
- package/dist/{chunk-6UGHVU5B.js → chunk-DWHM5BAY.js} +2 -2
- package/dist/{chunk-TIH7JFPJ.js → chunk-EC5QLEZD.js} +2 -2
- package/dist/{chunk-RZYZILU4.js → chunk-EWYLWBKS.js} +2 -2
- package/dist/{chunk-LI3BII4F.js → chunk-ISWR2XIU.js} +2 -2
- package/dist/{chunk-WNP2BXR7.js → chunk-LZVHFPN6.js} +5 -5
- package/dist/{chunk-K6ATERWS.js → chunk-MBHI2TKQ.js} +4 -4
- package/dist/{chunk-43MXRTKH.js → chunk-NAHAESFV.js} +9 -4
- package/dist/chunk-NQCAKDRY.js +156 -0
- package/dist/chunk-OIKT4SYO.js +42 -0
- package/dist/{chunk-D2MHB5EF.js → chunk-PECS47OL.js} +3 -3
- package/dist/{chunk-62BC3K4Z.js → chunk-PGZZI42O.js} +2 -2
- package/dist/{chunk-S6G7YWNE.js → chunk-QYHM6554.js} +2 -2
- package/dist/{chunk-2W2F5BWF.js → chunk-RF6RDJYH.js} +16 -16
- package/dist/{chunk-SUDG7B6S.js → chunk-SDFJJJB5.js} +2 -2
- package/dist/chunk-SMBU3QLE.js +7 -0
- package/dist/{chunk-644GNYMB.js → chunk-SRSKCFFS.js} +3 -3
- package/dist/{chunk-LB2WXBPA.js → chunk-SSQ6EWNA.js} +5 -5
- package/dist/{chunk-56VBB3H7.js → chunk-TJW4DP26.js} +2 -2
- package/dist/{chunk-25M2YWBH.js → chunk-TOR6SKRB.js} +146 -63
- package/dist/{chunk-ISGHJHVH.js → chunk-UQHJUTDW.js} +2 -2
- package/dist/{chunk-M6X6HVQK.js → chunk-VQBXWMLT.js} +2 -2
- package/dist/{chunk-UYBWUOLR.js → chunk-VYQJPT27.js} +4 -4
- package/dist/{cli-GFDT4YXM.js → cli-5G2OYTIL.js} +9 -9
- package/dist/{cli-WWNTQJPV.js → cli-QDQYUHAP.js} +9 -9
- package/dist/cli.js +38 -5
- package/dist/{completion-I63UIDZ7.js → completion-3GVNPLZY.js} +4 -4
- package/dist/{diagnostics-RUJZBPNZ.js → diagnostics-2W7QDQNG.js} +6 -6
- package/dist/{doctor-CLUFTEFO.js → doctor-3TDO5LJ5.js} +17 -16
- package/dist/{entry-QSJCFI5Z.js → entry-E62DZQJF.js} +10 -10
- package/dist/{exec-mcp-AFPUJTN7.js → exec-mcp-4N7FLY52.js} +13 -12
- package/dist/{harness-PPM32AI5.js → harness-E2AUZDLV.js} +3 -3
- package/dist/harness-launch-gate.js +4 -4
- package/dist/harness-worker.js +6 -6
- package/dist/{heavy-TEHP5PHT.js → heavy-HZQVFI6P.js} +182 -52
- package/dist/hook-body.js +116 -45
- package/dist/{hooks-L4PXVEGR.js → hooks-VAEAK2FY.js} +4 -4
- package/dist/{host-MU2GRH57.js → host-4GJDGTLW.js} +7 -7
- package/dist/{host-LBTL47X7.js → host-I2EMQ7UE.js} +18 -65
- package/dist/{host-run-IRSAQA5Z.js → host-run-DDMKD3BU.js} +5 -5
- package/dist/http.js +1 -1
- package/dist/{import-mcp-QVPW6A2Q.js → import-mcp-TNSAMJXI.js} +12 -11
- package/dist/index.d.ts +1 -1
- package/dist/index.js +16 -15
- package/dist/{init-46STH6FP.js → init-UA7MDNTZ.js} +2 -2
- package/dist/{invoke-I6C6UT6Q.js → invoke-HW7NBPGP.js} +8 -8
- package/dist/{list-HXG6EB7V.js → list-A7VQJXE5.js} +14 -13
- package/dist/{logout-SSUXJ6SE.js → logout-HNPLUKJY.js} +13 -12
- package/dist/{mailbox-5FVFMQ2J.js → mailbox-MR6TPD3P.js} +20 -6
- package/dist/{mainline-4XP6ZORU.js → mainline-MSLW3UFD.js} +14 -8
- package/dist/{mcp-L6X45IOS.js → mcp-6C23GX2E.js} +2 -2
- package/dist/{modes-SEINLLMK.js → modes-7OY7R73T.js} +3 -3
- package/dist/{pause-CMZOIHTJ.js → pause-H6ZYZF7C.js} +5 -2
- package/dist/{project-4JPKU2D7.js → project-BX6NCGKB.js} +4 -4
- package/dist/{report-UB7MXAUB.js → report-43SFNNCF.js} +2 -2
- package/dist/{resume-PAKIT4TT.js → resume-2BWGSTCN.js} +5 -2
- package/dist/{run-PMASXIGY.js → run-2UVAWBAF.js} +12 -11
- package/dist/{run-OW7436TY.js → run-7TRWZFEZ.js} +4 -4
- package/dist/{serve-P3HJN6AF.js → serve-4XZ5SKJJ.js} +3 -3
- package/dist/{setup-6AQUOWOH.js → setup-GRWLDBVB.js} +4 -4
- package/dist/{start-login-P7YDRTA3.js → start-login-AR7ITWNV.js} +13 -12
- package/dist/{status-4PYPTYUB.js → status-2GDYLIR3.js} +6 -3
- package/dist/{status-DAXQKT35.js → status-VQCMJFVE.js} +31 -28
- package/dist/{status-DLGZDYEP.js → status-ZY6LDQSF.js} +13 -12
- package/dist/stdio.js +2 -2
- package/dist/{sweep-VURZU6DI.js → sweep-76BUOGEI.js} +5 -2
- package/dist/{test-H243OTSK.js → test-VWGNFSH5.js} +15 -13
- package/dist/{tui-P6XTSTQO.js → tui-TUMOQBE7.js} +4 -4
- package/dist/{unbroadcast-7AMLURCG.js → unbroadcast-HJHYUHZL.js} +5 -2
- package/dist/{worker-5YJLIGTU.js → worker-NEEPJRVV.js} +8 -8
- package/dist/{worktree-create-FTSLMZWS.js → worktree-create-ZQRN5JBD.js} +2 -2
- package/dist/{worktree-list-WH6OX6U7.js → worktree-list-WZC75NLF.js} +11 -12
- package/dist/{worktree-sync-DGNHSQ64.js → worktree-sync-MUVKK2CV.js} +5 -5
- package/docs/commands.md +9 -7
- package/docs/git-workflow.md +7 -1
- package/docs/glossary.md +1 -1
- package/docs/hooks.md +20 -16
- package/docs/project-configuration.md +76 -37
- package/docs/sessions.md +9 -2
- package/docs/upgrading.md +58 -0
- package/gemini-extension.json +2 -2
- package/mcp.json +1 -1
- package/package.json +5 -5
- package/plugin.json +1 -1
- package/plugins/pmcp/.claude-plugin/plugin.json +1 -1
- package/plugins/pmcp/.mcp.json +1 -1
- package/plugins/pmcp/gemini-extension.json +2 -2
- package/plugins/pmcp/mcp.json +1 -1
- package/plugins/pmcp/plugin.json +1 -1
- package/dist/chunk-LTMHE5VL.js +0 -7
|
@@ -3,8 +3,9 @@ import {
|
|
|
3
3
|
} from "./chunk-UKR64U7J.js";
|
|
4
4
|
import {
|
|
5
5
|
git,
|
|
6
|
+
gitBytes,
|
|
6
7
|
gitText
|
|
7
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-23PE3HZB.js";
|
|
8
9
|
import {
|
|
9
10
|
ArgumentError,
|
|
10
11
|
one
|
|
@@ -22,7 +23,7 @@ import {
|
|
|
22
23
|
import "./chunk-PMJG2CXF.js";
|
|
23
24
|
|
|
24
25
|
// src/git/cli/affected.ts
|
|
25
|
-
import { resolve } from "path";
|
|
26
|
+
import { resolve as resolve2 } from "path";
|
|
26
27
|
|
|
27
28
|
// src/git/affected/config.ts
|
|
28
29
|
var DERIVE = ["tsconfig", "vitest"];
|
|
@@ -113,7 +114,7 @@ function readAffectedConfig(config) {
|
|
|
113
114
|
}
|
|
114
115
|
|
|
115
116
|
// src/git/affected/select.ts
|
|
116
|
-
import { posix as
|
|
117
|
+
import { posix as posix6 } from "path";
|
|
117
118
|
|
|
118
119
|
// src/git/affected/delta.ts
|
|
119
120
|
function commitOf(root, ref) {
|
|
@@ -158,12 +159,10 @@ function showFile(root, rev, path) {
|
|
|
158
159
|
}
|
|
159
160
|
|
|
160
161
|
// src/git/affected/derive.ts
|
|
161
|
-
import {
|
|
162
|
-
import { join as join2, posix as posix2 } from "path";
|
|
162
|
+
import { posix as posix2 } from "path";
|
|
163
163
|
|
|
164
164
|
// src/git/affected/tsconfig.ts
|
|
165
|
-
import {
|
|
166
|
-
import { join, posix } from "path";
|
|
165
|
+
import { posix } from "path";
|
|
167
166
|
function parseJsonc(text) {
|
|
168
167
|
for (const attempt of [
|
|
169
168
|
text,
|
|
@@ -178,12 +177,9 @@ function parseJsonc(text) {
|
|
|
178
177
|
}
|
|
179
178
|
return null;
|
|
180
179
|
}
|
|
181
|
-
function readTsconfig(
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
} catch {
|
|
185
|
-
return null;
|
|
186
|
-
}
|
|
180
|
+
function readTsconfig(tree, file) {
|
|
181
|
+
const text = tree.text(file);
|
|
182
|
+
return text === null ? null : parseJsonc(text);
|
|
187
183
|
}
|
|
188
184
|
function extendsSpecs(parsed) {
|
|
189
185
|
const raw = parsed?.["extends"];
|
|
@@ -195,7 +191,7 @@ function packageSplit(spec) {
|
|
|
195
191
|
const size = spec.startsWith("@") ? 2 : 1;
|
|
196
192
|
return [parts.slice(0, size).join("/"), parts.slice(size).join("/")];
|
|
197
193
|
}
|
|
198
|
-
function packageTarget(
|
|
194
|
+
function packageTarget(tree, spec, byName) {
|
|
199
195
|
const [name, sub] = packageSplit(spec);
|
|
200
196
|
const member = byName.get(name);
|
|
201
197
|
if (member === void 0) return null;
|
|
@@ -209,27 +205,27 @@ function packageTarget(root, spec, byName) {
|
|
|
209
205
|
for (const candidate of candidates) {
|
|
210
206
|
if (candidate === void 0) continue;
|
|
211
207
|
const file = posix.normalize(posix.join(member.dir, candidate));
|
|
212
|
-
if (
|
|
208
|
+
if (tree.has(file)) return file;
|
|
213
209
|
}
|
|
214
210
|
return null;
|
|
215
211
|
}
|
|
216
|
-
function extendsChain(
|
|
212
|
+
function extendsChain(tree, file, byName, seen = /* @__PURE__ */ new Set()) {
|
|
217
213
|
const out = [];
|
|
218
|
-
for (const spec of extendsSpecs(readTsconfig(
|
|
214
|
+
for (const spec of extendsSpecs(readTsconfig(tree, file))) {
|
|
219
215
|
let target;
|
|
220
216
|
let owner;
|
|
221
217
|
if (spec.startsWith(".")) {
|
|
222
218
|
target = posix.normalize(posix.join(posix.dirname(file), spec));
|
|
223
219
|
if (!target.endsWith(".json")) target = `${target}.json`;
|
|
224
220
|
} else {
|
|
225
|
-
target = packageTarget(
|
|
221
|
+
target = packageTarget(tree, spec, byName);
|
|
226
222
|
owner = byName.get(packageSplit(spec)[0])?.dir;
|
|
227
223
|
}
|
|
228
224
|
if (target === null || target.startsWith("..") || seen.has(target))
|
|
229
225
|
continue;
|
|
230
226
|
seen.add(target);
|
|
231
227
|
out.push({ file: target, ...owner ? { owner } : {} });
|
|
232
|
-
out.push(...extendsChain(
|
|
228
|
+
out.push(...extendsChain(tree, target, byName, seen));
|
|
233
229
|
}
|
|
234
230
|
return out;
|
|
235
231
|
}
|
|
@@ -237,13 +233,9 @@ function extendsChain(root, file, byName, seen = /* @__PURE__ */ new Set()) {
|
|
|
237
233
|
// src/git/affected/derive.ts
|
|
238
234
|
var VITEST = /^vitest\.config\.(?:ts|mts|cts|js|mjs|cjs)$/u;
|
|
239
235
|
var TSCONFIG = /^tsconfig.*\.json$/u;
|
|
240
|
-
function vitestImports(
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
text = readFileSync2(join2(root, file), "utf8");
|
|
244
|
-
} catch {
|
|
245
|
-
return [];
|
|
246
|
-
}
|
|
236
|
+
function vitestImports(tree, file) {
|
|
237
|
+
const text = tree.text(file);
|
|
238
|
+
if (text === null) return [];
|
|
247
239
|
const out = [];
|
|
248
240
|
const specs = /(?:from\s+|import\s*\(\s*)["'](\.{1,2}\/[^"']+)["']/gu;
|
|
249
241
|
for (const match of text.matchAll(specs)) {
|
|
@@ -255,12 +247,14 @@ function vitestImports(root, file) {
|
|
|
255
247
|
return out;
|
|
256
248
|
}
|
|
257
249
|
function inside(path, dirs) {
|
|
258
|
-
|
|
250
|
+
for (let dir = path; dir !== "." && dir !== "/"; dir = posix2.dirname(dir))
|
|
251
|
+
if (dirs.has(dir)) return true;
|
|
252
|
+
return false;
|
|
259
253
|
}
|
|
260
|
-
function deriveReaders(
|
|
254
|
+
function deriveReaders(tree, members, adapters) {
|
|
261
255
|
const readers2 = /* @__PURE__ */ new Map();
|
|
262
256
|
if (adapters.length === 0) return readers2;
|
|
263
|
-
const dirs = members.map((member) => member.dir);
|
|
257
|
+
const dirs = new Set(members.map((member) => member.dir));
|
|
264
258
|
const byName = new Map(
|
|
265
259
|
members.flatMap(
|
|
266
260
|
(member) => member.name === void 0 ? [] : [[member.name, member]]
|
|
@@ -271,28 +265,107 @@ function deriveReaders(root, members, adapters) {
|
|
|
271
265
|
if (!readers2.has(target)) readers2.set(target, /* @__PURE__ */ new Set());
|
|
272
266
|
readers2.get(target).add(member);
|
|
273
267
|
};
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
const file
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
add(step.file, dir);
|
|
286
|
-
if (adapters.includes("vitest") && VITEST.test(entry))
|
|
287
|
-
for (const target of vitestImports(root, file)) add(target, dir);
|
|
288
|
-
}
|
|
268
|
+
const configs = members.flatMap(
|
|
269
|
+
({ dir }) => tree.children(dir).filter(
|
|
270
|
+
(entry) => adapters.includes("tsconfig") && TSCONFIG.test(entry) || adapters.includes("vitest") && VITEST.test(entry)
|
|
271
|
+
).map((entry) => ({ dir, entry, file: `${dir}/${entry}` }))
|
|
272
|
+
);
|
|
273
|
+
tree.prefetch(configs.map(({ file }) => file));
|
|
274
|
+
for (const { dir, entry, file } of configs) {
|
|
275
|
+
if (adapters.includes("tsconfig") && TSCONFIG.test(entry))
|
|
276
|
+
for (const step of extendsChain(tree, file, byName)) add(step.file, dir);
|
|
277
|
+
if (adapters.includes("vitest") && VITEST.test(entry))
|
|
278
|
+
for (const target of vitestImports(tree, file)) add(target, dir);
|
|
289
279
|
}
|
|
290
280
|
return readers2;
|
|
291
281
|
}
|
|
292
282
|
|
|
293
283
|
// src/git/affected/graph.ts
|
|
294
|
-
import {
|
|
295
|
-
|
|
284
|
+
import { posix as posix3 } from "path";
|
|
285
|
+
|
|
286
|
+
// src/git/affected/source-facts.ts
|
|
287
|
+
import { mkdirSync, readFileSync, renameSync, writeFileSync } from "fs";
|
|
288
|
+
import { homedir } from "os";
|
|
289
|
+
import { dirname, join } from "path";
|
|
290
|
+
var VERSION = 1;
|
|
291
|
+
var LIMIT = 1e5;
|
|
292
|
+
var HEAD_CHARS = 256;
|
|
293
|
+
var PARENT = /from\s+["'](\.\.\/[^"']*)["']/gu;
|
|
294
|
+
var OPENER = /(?:from|import)\s*\(?\s*["']/gu;
|
|
295
|
+
function factsOf(text) {
|
|
296
|
+
const parents = [...text.matchAll(PARENT)].map((match) => match[1]);
|
|
297
|
+
const heads = [];
|
|
298
|
+
for (const match of text.matchAll(OPENER)) {
|
|
299
|
+
const start = match.index + match[0].length;
|
|
300
|
+
const rest = text.slice(start, start + HEAD_CHARS);
|
|
301
|
+
const quote = rest.search(/["']/u);
|
|
302
|
+
const head = quote < 0 ? rest : rest.slice(0, quote);
|
|
303
|
+
if (!head.startsWith("./") && !head.startsWith("../")) heads.push(head);
|
|
304
|
+
}
|
|
305
|
+
return { parents, heads: [...new Set(heads)] };
|
|
306
|
+
}
|
|
307
|
+
function importsName(facts, name) {
|
|
308
|
+
return facts.heads.some(
|
|
309
|
+
(head) => head === name || head.startsWith(`${name}/`)
|
|
310
|
+
);
|
|
311
|
+
}
|
|
312
|
+
function cacheFile() {
|
|
313
|
+
const base = process.env["XDG_CACHE_HOME"] || join(homedir(), ".cache");
|
|
314
|
+
return join(base, "pmcp", "affected-sources.json");
|
|
315
|
+
}
|
|
316
|
+
function load(file) {
|
|
317
|
+
try {
|
|
318
|
+
const value = JSON.parse(readFileSync(file, "utf8"));
|
|
319
|
+
return value.version === VERSION && value.entries ? value.entries : {};
|
|
320
|
+
} catch {
|
|
321
|
+
return {};
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
function save(file, entries) {
|
|
325
|
+
try {
|
|
326
|
+
mkdirSync(dirname(file), { recursive: true });
|
|
327
|
+
const temporary = `${file}.${process.pid}.tmp`;
|
|
328
|
+
writeFileSync(temporary, JSON.stringify({ version: VERSION, entries }));
|
|
329
|
+
renameSync(temporary, file);
|
|
330
|
+
} catch {
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
function readFacts(tree, paths) {
|
|
334
|
+
const file = cacheFile();
|
|
335
|
+
const stored = load(file);
|
|
336
|
+
const used = {};
|
|
337
|
+
const missing = [];
|
|
338
|
+
const ids = /* @__PURE__ */ new Map();
|
|
339
|
+
for (const path of paths) {
|
|
340
|
+
const id = tree.blobId(path);
|
|
341
|
+
if (id === null) continue;
|
|
342
|
+
ids.set(path, id);
|
|
343
|
+
const hit = stored[id];
|
|
344
|
+
if (hit) used[id] = hit;
|
|
345
|
+
else missing.push(path);
|
|
346
|
+
}
|
|
347
|
+
tree.prefetch(missing);
|
|
348
|
+
for (const path of missing) {
|
|
349
|
+
const text = tree.text(path);
|
|
350
|
+
if (text === null) continue;
|
|
351
|
+
const facts = factsOf(text);
|
|
352
|
+
used[ids.get(path)] = [facts.parents, facts.heads];
|
|
353
|
+
}
|
|
354
|
+
const out = /* @__PURE__ */ new Map();
|
|
355
|
+
for (const [path, id] of ids) {
|
|
356
|
+
const entry = used[id];
|
|
357
|
+
if (entry) out.set(path, { parents: entry[0], heads: entry[1] });
|
|
358
|
+
}
|
|
359
|
+
if (missing.length > 0) {
|
|
360
|
+
const kept = Object.entries(stored).filter(([id]) => !(id in used));
|
|
361
|
+
const room = LIMIT - Object.keys(used).length;
|
|
362
|
+
const older = room > 0 ? kept.slice(-room) : [];
|
|
363
|
+
save(file, { ...Object.fromEntries(older), ...used });
|
|
364
|
+
}
|
|
365
|
+
return out;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
// src/git/affected/graph.ts
|
|
296
369
|
var SOURCE = /\.(?:ts|tsx|mts|cts|js|jsx|mjs|cjs)$/u;
|
|
297
370
|
var TEST = /\.(?:test|spec)\./u;
|
|
298
371
|
function keys(manifest, field) {
|
|
@@ -305,50 +378,44 @@ function typechecksTests(tsconfig) {
|
|
|
305
378
|
const text = JSON.stringify(exclude);
|
|
306
379
|
return !text.includes("test") && !text.includes("spec");
|
|
307
380
|
}
|
|
308
|
-
function
|
|
381
|
+
function sourceFiles(tree, dirs) {
|
|
309
382
|
const out = /* @__PURE__ */ new Map();
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
);
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
out.set(file, readFileSync3(join3(root, dir, "src", file), "utf8"));
|
|
322
|
-
} catch {
|
|
383
|
+
const related = (link) => [...dirs].some(
|
|
384
|
+
(dir) => dir === link || dir.startsWith(`${link}/`) || link.startsWith(`${dir}/`)
|
|
385
|
+
);
|
|
386
|
+
for (const path of tree.files("", related)) {
|
|
387
|
+
if (!SOURCE.test(path)) continue;
|
|
388
|
+
for (let at = path.indexOf("/src/"); at >= 0; at = path.indexOf("/src/", at + 1)) {
|
|
389
|
+
const dir = path.slice(0, at);
|
|
390
|
+
if (!dirs.has(dir) || TEST.test(path.slice(at + 5))) continue;
|
|
391
|
+
const list = out.get(dir) ?? [];
|
|
392
|
+
list.push(path);
|
|
393
|
+
out.set(dir, list);
|
|
323
394
|
}
|
|
324
395
|
}
|
|
325
396
|
return out;
|
|
326
397
|
}
|
|
327
|
-
function imports(text, name) {
|
|
328
|
-
const escaped = name.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
|
|
329
|
-
return new RegExp(
|
|
330
|
-
`(?:from|import)\\s*\\(?\\s*["']${escaped}(/|["'])`,
|
|
331
|
-
"u"
|
|
332
|
-
).test(text);
|
|
333
|
-
}
|
|
334
398
|
function ownerOf(path, dirs) {
|
|
335
399
|
for (let cur = path; cur && cur !== "."; cur = posix3.dirname(cur))
|
|
336
400
|
if (dirs.has(cur)) return cur;
|
|
337
401
|
return void 0;
|
|
338
402
|
}
|
|
339
|
-
function dependencyEdges(
|
|
403
|
+
function dependencyEdges(tree, members) {
|
|
340
404
|
const byName = new Map(
|
|
341
405
|
members.flatMap((m) => m.name ? [[m.name, m.dir]] : [])
|
|
342
406
|
);
|
|
343
407
|
const dirs = new Set(members.map((m) => m.dir));
|
|
344
408
|
const deps = /* @__PURE__ */ new Map();
|
|
409
|
+
const sources = sourceFiles(tree, dirs);
|
|
410
|
+
const facts = readFacts(tree, [...sources.values()].flat());
|
|
411
|
+
tree.prefetch(members.map((m) => `${m.dir}/tsconfig.json`));
|
|
345
412
|
for (const member of members) {
|
|
346
413
|
const out = /* @__PURE__ */ new Set();
|
|
347
414
|
const add = (name) => {
|
|
348
415
|
const dir = byName.get(name);
|
|
349
416
|
if (dir !== void 0 && dir !== member.dir) out.add(dir);
|
|
350
417
|
};
|
|
351
|
-
const tsconfig = readTsconfig(
|
|
418
|
+
const tsconfig = readTsconfig(tree, `${member.dir}/tsconfig.json`);
|
|
352
419
|
for (const field of [
|
|
353
420
|
"dependencies",
|
|
354
421
|
"peerDependencies",
|
|
@@ -358,21 +425,21 @@ function dependencyEdges(root, members) {
|
|
|
358
425
|
const dev = keys(member.manifest, "devDependencies").filter(
|
|
359
426
|
(name) => byName.has(name)
|
|
360
427
|
);
|
|
361
|
-
const
|
|
428
|
+
const files = (sources.get(member.dir) ?? []).flatMap((path) => {
|
|
429
|
+
const found = facts.get(path);
|
|
430
|
+
return found === void 0 ? [] : [[path, found]];
|
|
431
|
+
});
|
|
362
432
|
if (typechecksTests(tsconfig)) dev.forEach(add);
|
|
363
433
|
else
|
|
364
434
|
for (const name of dev)
|
|
365
|
-
if (
|
|
366
|
-
add(name);
|
|
435
|
+
if (files.some(([, found]) => importsName(found, name))) add(name);
|
|
367
436
|
for (const spec of extendsSpecs(tsconfig)) {
|
|
368
437
|
const parts = spec.split("/");
|
|
369
438
|
add(spec.startsWith("@") ? parts.slice(0, 2).join("/") : parts[0]);
|
|
370
439
|
}
|
|
371
|
-
for (const [file,
|
|
372
|
-
for (const
|
|
373
|
-
const target = posix3.normalize(
|
|
374
|
-
posix3.join(member.dir, "src", posix3.dirname(file), match[1])
|
|
375
|
-
);
|
|
440
|
+
for (const [file, found] of files)
|
|
441
|
+
for (const spec of found.parents) {
|
|
442
|
+
const target = posix3.normalize(posix3.join(posix3.dirname(file), spec));
|
|
376
443
|
const owner = ownerOf(target, dirs);
|
|
377
444
|
if (owner !== void 0 && owner !== member.dir) out.add(owner);
|
|
378
445
|
}
|
|
@@ -380,12 +447,13 @@ function dependencyEdges(root, members) {
|
|
|
380
447
|
}
|
|
381
448
|
return deps;
|
|
382
449
|
}
|
|
383
|
-
function withConsumers(
|
|
450
|
+
function withConsumers(tree, members, selected) {
|
|
451
|
+
const seen = new Set(selected);
|
|
452
|
+
if (seen.size === 0) return [];
|
|
384
453
|
const consumers = /* @__PURE__ */ new Map();
|
|
385
|
-
for (const [dir, deps] of dependencyEdges(
|
|
454
|
+
for (const [dir, deps] of dependencyEdges(tree, members))
|
|
386
455
|
for (const dep of deps)
|
|
387
456
|
consumers.set(dep, [...consumers.get(dep) ?? [], dir]);
|
|
388
|
-
const seen = new Set(selected);
|
|
389
457
|
const queue = [...seen];
|
|
390
458
|
while (queue.length > 0)
|
|
391
459
|
for (const next of consumers.get(queue.pop()) ?? [])
|
|
@@ -412,29 +480,33 @@ var DEP_FIELDS = [
|
|
|
412
480
|
];
|
|
413
481
|
var GRAPH_FIELDS = /* @__PURE__ */ new Set(["workspaces", "packages"]);
|
|
414
482
|
function parseBunLock(text) {
|
|
415
|
-
|
|
416
|
-
|
|
483
|
+
const out = [];
|
|
484
|
+
const special = /["/,]/gu;
|
|
485
|
+
let copied = 0;
|
|
486
|
+
for (let match = special.exec(text); match; match = special.exec(text)) {
|
|
487
|
+
let i = match.index;
|
|
417
488
|
const c = text[i];
|
|
418
489
|
if (c === '"') {
|
|
419
|
-
const start = i;
|
|
420
490
|
for (i += 1; i < text.length && text[i] !== '"'; i += 1)
|
|
421
491
|
if (text[i] === "\\") i += 1;
|
|
422
|
-
|
|
492
|
+
special.lastIndex = i + 1;
|
|
423
493
|
continue;
|
|
424
494
|
}
|
|
425
495
|
if (c === "/" && text[i + 1] === "/") {
|
|
496
|
+
out.push(text.slice(copied, i));
|
|
426
497
|
while (i < text.length && text[i] !== "\n") i += 1;
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
}
|
|
430
|
-
if (c === ",") {
|
|
498
|
+
copied = i;
|
|
499
|
+
} else if (c === ",") {
|
|
431
500
|
let j = i + 1;
|
|
432
501
|
while (j < text.length && /\s/u.test(text.charAt(j))) j += 1;
|
|
433
|
-
if (text[j]
|
|
502
|
+
if (text[j] !== "}" && text[j] !== "]") continue;
|
|
503
|
+
out.push(text.slice(copied, i));
|
|
504
|
+
copied = i + 1;
|
|
434
505
|
}
|
|
435
|
-
|
|
506
|
+
special.lastIndex = Math.max(copied, i + 1);
|
|
436
507
|
}
|
|
437
|
-
|
|
508
|
+
out.push(text.slice(copied));
|
|
509
|
+
const parsed = JSON.parse(out.join(""));
|
|
438
510
|
if (parsed === null || typeof parsed !== "object")
|
|
439
511
|
throw new Error("lockfile is not an object");
|
|
440
512
|
for (const field of GRAPH_FIELDS)
|
|
@@ -560,6 +632,7 @@ function lockDelta(input) {
|
|
|
560
632
|
if (moved !== null) direct.add(moved);
|
|
561
633
|
seeds.add(key);
|
|
562
634
|
}
|
|
635
|
+
if (seeds.size === 0) return { all: null, direct: [...direct].sort() };
|
|
563
636
|
const reverse = /* @__PURE__ */ new Map();
|
|
564
637
|
addReverseEdges(base, reverse);
|
|
565
638
|
addReverseEdges(head, reverse);
|
|
@@ -588,29 +661,9 @@ var bunLockfile = {
|
|
|
588
661
|
};
|
|
589
662
|
|
|
590
663
|
// src/git/affected/members.ts
|
|
591
|
-
import {
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
return name.startsWith(".") || name === "node_modules";
|
|
595
|
-
}
|
|
596
|
-
function manifestDirs(root) {
|
|
597
|
-
const out = [];
|
|
598
|
-
const queue = [""];
|
|
599
|
-
while (queue.length > 0) {
|
|
600
|
-
const dir = queue.pop();
|
|
601
|
-
let entries;
|
|
602
|
-
try {
|
|
603
|
-
entries = readdirSync3(join4(root, dir), { withFileTypes: true });
|
|
604
|
-
} catch {
|
|
605
|
-
continue;
|
|
606
|
-
}
|
|
607
|
-
for (const entry of entries) {
|
|
608
|
-
const rel = dir === "" ? entry.name : `${dir}/${entry.name}`;
|
|
609
|
-
if (entry.isDirectory() && !skipped(entry.name)) queue.push(rel);
|
|
610
|
-
else if (entry.name === "package.json" && dir !== "") out.push(dir);
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
return out;
|
|
664
|
+
import { posix as posix4 } from "path";
|
|
665
|
+
function skipped(dir) {
|
|
666
|
+
return dir.split("/").some((name) => name.startsWith(".") || name === "node_modules");
|
|
614
667
|
}
|
|
615
668
|
function workspacePatterns(manifest) {
|
|
616
669
|
const declared = manifest["workspaces"];
|
|
@@ -630,30 +683,306 @@ function memberMatcher(patterns) {
|
|
|
630
683
|
return included;
|
|
631
684
|
};
|
|
632
685
|
}
|
|
633
|
-
function
|
|
686
|
+
function mayHold(patterns, dir) {
|
|
687
|
+
const parts = dir.split("/");
|
|
688
|
+
return patterns.some((pattern) => {
|
|
689
|
+
if (pattern.startsWith("!")) return false;
|
|
690
|
+
const segments = pattern.replace(/\/+$/u, "").split("/");
|
|
691
|
+
for (let at = 0; at < parts.length; at += 1) {
|
|
692
|
+
const segment = segments[at];
|
|
693
|
+
if (segment === void 0) return false;
|
|
694
|
+
if (segment.includes("**")) return true;
|
|
695
|
+
if (!globPattern(segment, false).test(parts[at])) return false;
|
|
696
|
+
}
|
|
697
|
+
return true;
|
|
698
|
+
});
|
|
699
|
+
}
|
|
700
|
+
function parseJson(text) {
|
|
701
|
+
if (text === null) return null;
|
|
634
702
|
try {
|
|
635
|
-
const value = JSON.parse(
|
|
703
|
+
const value = JSON.parse(text);
|
|
636
704
|
return value !== null && typeof value === "object" ? value : null;
|
|
637
705
|
} catch {
|
|
638
706
|
return null;
|
|
639
707
|
}
|
|
640
708
|
}
|
|
641
|
-
function workspaceMembers(
|
|
642
|
-
const rootManifest =
|
|
709
|
+
function workspaceMembers(tree) {
|
|
710
|
+
const rootManifest = parseJson(tree.text("package.json"));
|
|
643
711
|
if (rootManifest === null) throw new Error("root package.json is unreadable");
|
|
644
|
-
const
|
|
645
|
-
const
|
|
646
|
-
|
|
647
|
-
|
|
712
|
+
const patterns = workspacePatterns(rootManifest);
|
|
713
|
+
const matches = memberMatcher(patterns);
|
|
714
|
+
const dirs = tree.files("", (link) => !skipped(link) && mayHold(patterns, link)).filter((path) => posix4.basename(path) === "package.json").map((path) => posix4.dirname(path)).filter((dir) => dir !== "." && !skipped(dir) && matches(dir)).sort();
|
|
715
|
+
tree.prefetch(dirs.map((dir) => `${dir}/package.json`));
|
|
716
|
+
return dirs.map((dir) => {
|
|
717
|
+
const manifest = parseJson(tree.text(`${dir}/package.json`)) ?? {};
|
|
648
718
|
const name = manifest["name"];
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
719
|
+
return { dir, manifest, ...typeof name === "string" ? { name } : {} };
|
|
720
|
+
});
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
// src/git/affected/tree.ts
|
|
724
|
+
import { existsSync } from "fs";
|
|
725
|
+
import { join as join2, posix as posix5, resolve } from "path";
|
|
726
|
+
|
|
727
|
+
// src/git/affected/objects.ts
|
|
728
|
+
var LINK_MODE = "120000";
|
|
729
|
+
var GITLINK_MODE = "160000";
|
|
730
|
+
function isLink(entry) {
|
|
731
|
+
return entry.mode === LINK_MODE;
|
|
732
|
+
}
|
|
733
|
+
var RepoTree = class _RepoTree {
|
|
734
|
+
constructor(gitDir) {
|
|
735
|
+
this.gitDir = gitDir;
|
|
736
|
+
}
|
|
737
|
+
gitDir;
|
|
738
|
+
files = /* @__PURE__ */ new Map();
|
|
739
|
+
gitlinks = /* @__PURE__ */ new Map();
|
|
740
|
+
dirIndex;
|
|
741
|
+
static read(gitDir, commit) {
|
|
742
|
+
const run = gitBytes(gitDir, [
|
|
743
|
+
`--git-dir=${gitDir}`,
|
|
744
|
+
"ls-tree",
|
|
745
|
+
"-r",
|
|
746
|
+
"-z",
|
|
747
|
+
"--full-tree",
|
|
748
|
+
commit
|
|
749
|
+
]);
|
|
750
|
+
if (run.status !== 0)
|
|
751
|
+
throw new Error(`cannot list ${commit}: ${run.stderr.trim()}`);
|
|
752
|
+
const tree = new _RepoTree(gitDir);
|
|
753
|
+
for (const record of run.stdout.toString("utf8").split("\0")) {
|
|
754
|
+
const tab = record.indexOf(" ");
|
|
755
|
+
if (tab < 0) continue;
|
|
756
|
+
const [mode, , oid] = record.slice(0, tab).split(" ");
|
|
757
|
+
const path = record.slice(tab + 1);
|
|
758
|
+
if (mode === GITLINK_MODE) tree.gitlinks.set(path, oid);
|
|
759
|
+
else tree.files.set(path, { mode, oid });
|
|
760
|
+
}
|
|
761
|
+
return tree;
|
|
762
|
+
}
|
|
763
|
+
// File names directly inside dir ("" for the top).
|
|
764
|
+
children(dir) {
|
|
765
|
+
if (this.dirIndex === void 0) {
|
|
766
|
+
this.dirIndex = /* @__PURE__ */ new Map();
|
|
767
|
+
for (const path of this.files.keys()) {
|
|
768
|
+
const slash = path.lastIndexOf("/");
|
|
769
|
+
const parent = slash < 0 ? "" : path.slice(0, slash);
|
|
770
|
+
const list = this.dirIndex.get(parent) ?? [];
|
|
771
|
+
list.push(path.slice(slash + 1));
|
|
772
|
+
this.dirIndex.set(parent, list);
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
return this.dirIndex.get(dir) ?? [];
|
|
776
|
+
}
|
|
777
|
+
// Blob texts by object id in one cat-file process; a missing object is left out.
|
|
778
|
+
blobs(oids) {
|
|
779
|
+
const out = /* @__PURE__ */ new Map();
|
|
780
|
+
const wanted = [...new Set(oids)];
|
|
781
|
+
if (wanted.length === 0) return out;
|
|
782
|
+
const run = gitBytes(
|
|
783
|
+
this.gitDir,
|
|
784
|
+
[`--git-dir=${this.gitDir}`, "cat-file", "--batch"],
|
|
785
|
+
wanted.join("\n") + "\n"
|
|
786
|
+
);
|
|
787
|
+
if (run.status !== 0)
|
|
788
|
+
throw new Error(`cannot read objects: ${run.stderr.trim()}`);
|
|
789
|
+
const bytes = run.stdout;
|
|
790
|
+
let at = 0;
|
|
791
|
+
while (at < bytes.length) {
|
|
792
|
+
const eol = bytes.indexOf(10, at);
|
|
793
|
+
if (eol < 0) break;
|
|
794
|
+
const [oid, type, size] = bytes.toString("utf8", at, eol).split(" ");
|
|
795
|
+
at = eol + 1;
|
|
796
|
+
if (type === "missing" || size === void 0) continue;
|
|
797
|
+
const end = at + Number(size);
|
|
798
|
+
if (type === "blob") out.set(oid, bytes.toString("utf8", at, end));
|
|
799
|
+
at = end + 1;
|
|
800
|
+
}
|
|
801
|
+
return out;
|
|
654
802
|
}
|
|
655
|
-
|
|
803
|
+
};
|
|
804
|
+
|
|
805
|
+
// src/git/affected/tree.ts
|
|
806
|
+
function submoduleNames(text) {
|
|
807
|
+
const names = /* @__PURE__ */ new Map();
|
|
808
|
+
let name;
|
|
809
|
+
for (const line of (text ?? "").split("\n")) {
|
|
810
|
+
const header = /^\s*\[submodule\s+"(.+)"\]\s*$/u.exec(line);
|
|
811
|
+
if (header) name = header[1];
|
|
812
|
+
const path = /^\s*path\s*=\s*(.+?)\s*$/u.exec(line);
|
|
813
|
+
if (path && name !== void 0) names.set(path[1], name);
|
|
814
|
+
}
|
|
815
|
+
return names;
|
|
656
816
|
}
|
|
817
|
+
var HeadTree = class _HeadTree {
|
|
818
|
+
constructor(root, top) {
|
|
819
|
+
this.root = root;
|
|
820
|
+
this.mounts.set("", top);
|
|
821
|
+
}
|
|
822
|
+
root;
|
|
823
|
+
mounts = /* @__PURE__ */ new Map();
|
|
824
|
+
texts = /* @__PURE__ */ new Map();
|
|
825
|
+
static open(root, rev) {
|
|
826
|
+
const [gitDir, common] = gitText(root, [
|
|
827
|
+
"rev-parse",
|
|
828
|
+
"--absolute-git-dir",
|
|
829
|
+
"--git-common-dir"
|
|
830
|
+
]).split("\n");
|
|
831
|
+
if (!gitDir || !common) throw new Error(`${root} has no git directory`);
|
|
832
|
+
const stores = [gitDir, resolve(root, common)];
|
|
833
|
+
return new _HeadTree(root, {
|
|
834
|
+
prefix: "",
|
|
835
|
+
repo: RepoTree.read(gitDir, rev),
|
|
836
|
+
stores
|
|
837
|
+
});
|
|
838
|
+
}
|
|
839
|
+
// The checkout's own pointer is asked last, as a store a moved checkout may still name.
|
|
840
|
+
*stores(parent, rel) {
|
|
841
|
+
const name = submoduleNames(this.read(parent, ".gitmodules")).get(rel);
|
|
842
|
+
const seen = /* @__PURE__ */ new Set();
|
|
843
|
+
for (const store of parent.stores) {
|
|
844
|
+
const dir = join2(store, "modules", name ?? rel);
|
|
845
|
+
if (!seen.has(dir) && existsSync(dir)) yield dir;
|
|
846
|
+
seen.add(dir);
|
|
847
|
+
}
|
|
848
|
+
const pointer = gitText(join2(this.root, parent.prefix, rel), [
|
|
849
|
+
"rev-parse",
|
|
850
|
+
"--absolute-git-dir"
|
|
851
|
+
]);
|
|
852
|
+
if (pointer && !seen.has(pointer) && !parent.stores.includes(pointer))
|
|
853
|
+
yield pointer;
|
|
854
|
+
}
|
|
855
|
+
// A submodule no store holds reads as empty, as an uninitialized one does; a store that
|
|
856
|
+
// lacks the pinned commit fails, since the answer would be for another revision.
|
|
857
|
+
mount(parent, rel) {
|
|
858
|
+
const prefix = `${parent.prefix}${rel}/`;
|
|
859
|
+
const known = this.mounts.get(prefix);
|
|
860
|
+
if (known !== void 0) return known;
|
|
861
|
+
const commit = parent.repo.gitlinks.get(rel);
|
|
862
|
+
let failure;
|
|
863
|
+
let mount = null;
|
|
864
|
+
for (const store of this.stores(parent, rel)) {
|
|
865
|
+
try {
|
|
866
|
+
mount = { prefix, repo: RepoTree.read(store, commit), stores: [store] };
|
|
867
|
+
break;
|
|
868
|
+
} catch (error) {
|
|
869
|
+
failure = error instanceof Error ? error : new Error(String(error));
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
if (mount === null && failure !== void 0)
|
|
873
|
+
throw new Error(`submodule ${prefix.slice(0, -1)}: ${failure.message}`);
|
|
874
|
+
this.mounts.set(prefix, mount);
|
|
875
|
+
return mount;
|
|
876
|
+
}
|
|
877
|
+
// The repository holding path, descending through the gitlinks above it.
|
|
878
|
+
find(path) {
|
|
879
|
+
let mount = this.mounts.get("");
|
|
880
|
+
let rel = path;
|
|
881
|
+
for (; ; ) {
|
|
882
|
+
if (mount.repo.gitlinks.has(rel)) return { mount, rel };
|
|
883
|
+
let link;
|
|
884
|
+
for (let dir = posix5.dirname(rel); dir !== "." && dir !== "/" && link === void 0; dir = posix5.dirname(dir))
|
|
885
|
+
if (mount.repo.gitlinks.has(dir)) link = dir;
|
|
886
|
+
if (link === void 0) return { mount, rel };
|
|
887
|
+
const inner = this.mount(mount, link);
|
|
888
|
+
if (inner === null) return null;
|
|
889
|
+
mount = inner;
|
|
890
|
+
rel = rel.slice(link.length + 1);
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
entry(path) {
|
|
894
|
+
const found = this.find(path);
|
|
895
|
+
const entry = found?.mount.repo.files.get(found.rel);
|
|
896
|
+
return found && entry ? { ...found, entry } : null;
|
|
897
|
+
}
|
|
898
|
+
read(mount, rel) {
|
|
899
|
+
const path = mount.prefix + rel;
|
|
900
|
+
if (!this.texts.has(path)) this.prefetch([path]);
|
|
901
|
+
return this.texts.get(path) ?? null;
|
|
902
|
+
}
|
|
903
|
+
// A symbolic link resolves inside the tree, as the checkout would follow it.
|
|
904
|
+
linkTarget(path) {
|
|
905
|
+
if (!this.texts.has(path)) this.prefetch([path]);
|
|
906
|
+
const text = this.texts.get(path) ?? null;
|
|
907
|
+
if (text === null) return null;
|
|
908
|
+
const next = posix5.normalize(posix5.join(posix5.dirname(path), text));
|
|
909
|
+
return next.startsWith("..") || posix5.isAbsolute(next) ? null : next;
|
|
910
|
+
}
|
|
911
|
+
has(path, hops = 8) {
|
|
912
|
+
const found = this.entry(path);
|
|
913
|
+
if (found === null) return false;
|
|
914
|
+
if (!isLink(found.entry)) return true;
|
|
915
|
+
const next = hops > 0 ? this.linkTarget(path) : null;
|
|
916
|
+
return next !== null && this.has(next, hops - 1);
|
|
917
|
+
}
|
|
918
|
+
// The object id of the file a path names, after its links; content keys a cache safely.
|
|
919
|
+
blobId(path, hops = 8) {
|
|
920
|
+
const found = this.entry(path);
|
|
921
|
+
if (found === null) return null;
|
|
922
|
+
if (!isLink(found.entry)) return found.entry.oid;
|
|
923
|
+
const next = hops > 0 ? this.linkTarget(path) : null;
|
|
924
|
+
return next === null ? null : this.blobId(next, hops - 1);
|
|
925
|
+
}
|
|
926
|
+
text(path, hops = 8) {
|
|
927
|
+
const found = this.entry(path);
|
|
928
|
+
if (found === null) return null;
|
|
929
|
+
if (isLink(found.entry)) {
|
|
930
|
+
const next = hops > 0 ? this.linkTarget(path) : null;
|
|
931
|
+
return next === null ? null : this.text(next, hops - 1);
|
|
932
|
+
}
|
|
933
|
+
if (!this.texts.has(path)) this.prefetch([path]);
|
|
934
|
+
return this.texts.get(path) ?? null;
|
|
935
|
+
}
|
|
936
|
+
// Reads every named file in one object-store pass per repository.
|
|
937
|
+
prefetch(paths) {
|
|
938
|
+
const byRepo = /* @__PURE__ */ new Map();
|
|
939
|
+
for (const path of paths) {
|
|
940
|
+
if (this.texts.has(path)) continue;
|
|
941
|
+
const found = this.entry(path);
|
|
942
|
+
if (found === null) {
|
|
943
|
+
this.texts.set(path, null);
|
|
944
|
+
continue;
|
|
945
|
+
}
|
|
946
|
+
const oids = byRepo.get(found.mount.repo) ?? /* @__PURE__ */ new Map();
|
|
947
|
+
oids.set(found.entry.oid, [...oids.get(found.entry.oid) ?? [], path]);
|
|
948
|
+
byRepo.set(found.mount.repo, oids);
|
|
949
|
+
}
|
|
950
|
+
for (const [repo, oids] of byRepo) {
|
|
951
|
+
const blobs = repo.blobs(oids.keys());
|
|
952
|
+
for (const [oid, list] of oids)
|
|
953
|
+
for (const path of list) this.texts.set(path, blobs.get(oid) ?? null);
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
// File names directly inside dir.
|
|
957
|
+
children(dir) {
|
|
958
|
+
const found = this.find(dir);
|
|
959
|
+
if (found === null) return [];
|
|
960
|
+
if (found.mount.repo.gitlinks.has(found.rel)) {
|
|
961
|
+
const inner = this.mount(found.mount, found.rel);
|
|
962
|
+
return inner === null ? [] : inner.repo.children("");
|
|
963
|
+
}
|
|
964
|
+
return found.mount.repo.children(found.rel);
|
|
965
|
+
}
|
|
966
|
+
// Every file below prefix ("" for all), entering a submodule only when descend allows it.
|
|
967
|
+
files(prefix, descend = () => true) {
|
|
968
|
+
const out = [];
|
|
969
|
+
const visit = (mount) => {
|
|
970
|
+
for (const rel of mount.repo.files.keys()) {
|
|
971
|
+
const path = mount.prefix + rel;
|
|
972
|
+
if (path.startsWith(prefix)) out.push(path);
|
|
973
|
+
}
|
|
974
|
+
for (const rel of mount.repo.gitlinks.keys()) {
|
|
975
|
+
const path = mount.prefix + rel;
|
|
976
|
+
const related = path.startsWith(prefix) || prefix.startsWith(`${path}/`);
|
|
977
|
+
if (!related || !descend(path)) continue;
|
|
978
|
+
const inner = this.mount(mount, rel);
|
|
979
|
+
if (inner !== null) visit(inner);
|
|
980
|
+
}
|
|
981
|
+
};
|
|
982
|
+
visit(this.mounts.get(""));
|
|
983
|
+
return out;
|
|
984
|
+
}
|
|
985
|
+
};
|
|
657
986
|
|
|
658
987
|
// src/git/affected/select.ts
|
|
659
988
|
var ALL = (reason, extra = {}) => ({
|
|
@@ -680,7 +1009,7 @@ function ordered(globs) {
|
|
|
680
1009
|
};
|
|
681
1010
|
}
|
|
682
1011
|
function ownerWalk(path, dirs) {
|
|
683
|
-
for (let dir =
|
|
1012
|
+
for (let dir = posix6.dirname(path); dir !== "." && dir !== "/"; dir = posix6.dirname(dir))
|
|
684
1013
|
if (dirs.has(dir)) return dir;
|
|
685
1014
|
return void 0;
|
|
686
1015
|
}
|
|
@@ -696,13 +1025,19 @@ function lockfileMembers(root, config, changes, base, head) {
|
|
|
696
1025
|
config: config.lockfile
|
|
697
1026
|
});
|
|
698
1027
|
}
|
|
699
|
-
function membersOf(root) {
|
|
1028
|
+
function membersOf(root, head) {
|
|
700
1029
|
try {
|
|
701
|
-
|
|
1030
|
+
const tree = HeadTree.open(root, head);
|
|
1031
|
+
return { tree, members: workspaceMembers(tree) };
|
|
702
1032
|
} catch (error) {
|
|
703
1033
|
return error instanceof Error ? error : new Error(String(error));
|
|
704
1034
|
}
|
|
705
1035
|
}
|
|
1036
|
+
function outsideMembers(changes, dirs) {
|
|
1037
|
+
return changes.some(
|
|
1038
|
+
({ path }) => !dirs.has(path) && ownerWalk(path, dirs) === void 0
|
|
1039
|
+
);
|
|
1040
|
+
}
|
|
706
1041
|
function selectAffected(root, config, baseRef, headRef, testsOnly = false) {
|
|
707
1042
|
const delta = readDelta(root, baseRef, headRef);
|
|
708
1043
|
if (!delta.ok) return ALL(delta.reason);
|
|
@@ -711,16 +1046,25 @@ function selectAffected(root, config, baseRef, headRef, testsOnly = false) {
|
|
|
711
1046
|
const shared = matcher(config.sharedInputs);
|
|
712
1047
|
const hit = changes.find((change) => shared(change.path));
|
|
713
1048
|
if (hit) return ALL(`shared input ${hit.path} changed`, at);
|
|
714
|
-
const
|
|
715
|
-
if (
|
|
716
|
-
return ALL(`members unreadable: ${
|
|
1049
|
+
const read = membersOf(root, head);
|
|
1050
|
+
if (read instanceof Error)
|
|
1051
|
+
return ALL(`members unreadable: ${read.message}`, at);
|
|
1052
|
+
try {
|
|
1053
|
+
return mapChanges(root, config, delta, read, testsOnly);
|
|
1054
|
+
} catch (error) {
|
|
1055
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
1056
|
+
return ALL(`head unreadable: ${reason}`, at);
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
function mapChanges(root, config, { base, head, changes }, { tree, members }, testsOnly) {
|
|
1060
|
+
const at = { base, head };
|
|
717
1061
|
const dirs = new Set(members.map((member) => member.dir));
|
|
718
1062
|
const lock = lockfileMembers(root, config, changes, base, head);
|
|
719
1063
|
if (lock.all !== null) return ALL(lock.all, at);
|
|
720
1064
|
const changed = /* @__PURE__ */ new Set();
|
|
721
1065
|
const direct = lock.direct.filter((dir) => dirs.has(dir));
|
|
722
1066
|
if (direct.length > 0)
|
|
723
|
-
for (const dir of withConsumers(
|
|
1067
|
+
for (const dir of withConsumers(tree, members, direct)) changed.add(dir);
|
|
724
1068
|
const ignored = matcher(config.ignore);
|
|
725
1069
|
const included = ordered(config.include);
|
|
726
1070
|
const deletedIncluded = ordered(config.includeDeleted);
|
|
@@ -732,9 +1076,9 @@ function selectAffected(root, config, baseRef, headRef, testsOnly = false) {
|
|
|
732
1076
|
test: matcher([glob]),
|
|
733
1077
|
list: list2
|
|
734
1078
|
}));
|
|
735
|
-
const derived = deriveReaders(
|
|
1079
|
+
const derived = outsideMembers(changes, dirs) ? deriveReaders(tree, members, config.derive) : /* @__PURE__ */ new Map();
|
|
736
1080
|
const memberChange = changes.some(
|
|
737
|
-
(change) => (change.status === "A" || change.status === "D") &&
|
|
1081
|
+
(change) => (change.status === "A" || change.status === "D") && posix6.basename(change.path) === "package.json" && change.path !== "package.json" && included(change.path) && !ignored(change.path)
|
|
738
1082
|
);
|
|
739
1083
|
if (memberChange) for (const dir of config.onMemberChange) changed.add(dir);
|
|
740
1084
|
const unmapped = [];
|
|
@@ -760,7 +1104,7 @@ function selectAffected(root, config, baseRef, headRef, testsOnly = false) {
|
|
|
760
1104
|
const list = [...changed].filter((dir) => dirs.has(dir)).sort();
|
|
761
1105
|
if (unmapped.length > 0 && config.unmapped === "all")
|
|
762
1106
|
return ALL(`unmapped ${unmapped[0]}`, { ...at, unmapped });
|
|
763
|
-
const wide = config.consumers && !testsOnly ? withConsumers(
|
|
1107
|
+
const wide = config.consumers && !testsOnly ? withConsumers(tree, members, list) : list;
|
|
764
1108
|
return { all: false, ...at, changed: list, members: wide, unmapped };
|
|
765
1109
|
}
|
|
766
1110
|
|
|
@@ -777,7 +1121,7 @@ function select(context, base) {
|
|
|
777
1121
|
unmapped: []
|
|
778
1122
|
};
|
|
779
1123
|
const configPath = one(context.args, "config");
|
|
780
|
-
const path = configPath === void 0 ? findConfig(context.cwd) :
|
|
1124
|
+
const path = configPath === void 0 ? findConfig(context.cwd) : resolve2(context.cwd, configPath);
|
|
781
1125
|
let config;
|
|
782
1126
|
try {
|
|
783
1127
|
config = path === null ? null : readAffectedConfig(readConfig(path));
|
|
@@ -833,4 +1177,4 @@ export {
|
|
|
833
1177
|
AFFECTED_SCHEMA,
|
|
834
1178
|
gitAffected
|
|
835
1179
|
};
|
|
836
|
-
//# sourceMappingURL=affected-
|
|
1180
|
+
//# sourceMappingURL=affected-IPFJM2KD.js.map
|