@diffci.com/diffci 0.3.37 → 0.3.39
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/README.md +3 -3
- package/dist-client/src/client/agent-setup.d.ts +1 -1
- package/dist-client/src/client/agent-setup.js +1 -1
- package/dist-client/src/client/check-plan-junit.js +12 -3
- package/dist-client/src/client/command-batches.d.ts +6 -0
- package/dist-client/src/client/command-batches.js +7 -1
- package/dist-client/src/client/node-bin-launch.d.ts +10 -0
- package/dist-client/src/client/node-bin-launch.js +71 -0
- package/dist-client/src/client/verify-savings.js +18 -11
- package/node_modules/@diffci.com/core/README.md +15 -4
- package/node_modules/@diffci.com/core/dist/cache/economics-context.d.ts +4 -1
- package/node_modules/@diffci.com/core/dist/cache/economics-context.js +7 -3
- package/node_modules/@diffci.com/core/dist/cache/economics-context.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/cache/graph-cache.d.ts +1 -1
- package/node_modules/@diffci.com/core/dist/cache/graph-cache.js +5 -1
- package/node_modules/@diffci.com/core/dist/cache/graph-cache.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/ci-inference/evidence.js +1 -1
- package/node_modules/@diffci.com/core/dist/ci-inference/evidence.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/git/git-diff.d.ts +2 -0
- package/node_modules/@diffci.com/core/dist/git/git-diff.js +7 -6
- package/node_modules/@diffci.com/core/dist/git/git-diff.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/adapters/go.js +24 -7
- package/node_modules/@diffci.com/core/dist/repo/adapters/go.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/analyzer.js +16 -1
- package/node_modules/@diffci.com/core/dist/repo/analyzer.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/export-reach.d.ts +16 -0
- package/node_modules/@diffci.com/core/dist/repo/export-reach.js +113 -0
- package/node_modules/@diffci.com/core/dist/repo/export-reach.js.map +1 -0
- package/node_modules/@diffci.com/core/dist/repo/file-references.js +2 -1
- package/node_modules/@diffci.com/core/dist/repo/file-references.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/graph.js +429 -39
- package/node_modules/@diffci.com/core/dist/repo/graph.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/impact-types.d.ts +1 -1
- package/node_modules/@diffci.com/core/dist/repo/impact.d.ts +51 -0
- package/node_modules/@diffci.com/core/dist/repo/impact.js +296 -9
- package/node_modules/@diffci.com/core/dist/repo/impact.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/lockfiles.d.ts +5 -0
- package/node_modules/@diffci.com/core/dist/repo/lockfiles.js +12 -0
- package/node_modules/@diffci.com/core/dist/repo/lockfiles.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/repo-config.d.ts +5 -0
- package/node_modules/@diffci.com/core/dist/repo/repo-config.js +3 -1
- package/node_modules/@diffci.com/core/dist/repo/repo-config.js.map +1 -1
- package/node_modules/@diffci.com/core/dist/repo/types.d.ts +35 -1
- package/node_modules/@diffci.com/core/dist/repo/workspace-sources.d.ts +35 -0
- package/node_modules/@diffci.com/core/dist/repo/workspace-sources.js +292 -0
- package/node_modules/@diffci.com/core/dist/repo/workspace-sources.js.map +1 -0
- package/node_modules/@diffci.com/core/package.json +1 -1
- package/node_modules/@diffci.com/core/src/cache/economics-context.ts +7 -3
- package/node_modules/@diffci.com/core/src/cache/graph-cache.ts +5 -1
- package/node_modules/@diffci.com/core/src/ci-inference/evidence.ts +1 -1
- package/node_modules/@diffci.com/core/src/git/git-diff.ts +7 -6
- package/node_modules/@diffci.com/core/src/repo/adapters/go.ts +23 -7
- package/node_modules/@diffci.com/core/src/repo/analyzer.ts +15 -1
- package/node_modules/@diffci.com/core/src/repo/export-reach.ts +92 -0
- package/node_modules/@diffci.com/core/src/repo/file-references.ts +2 -1
- package/node_modules/@diffci.com/core/src/repo/graph.ts +365 -35
- package/node_modules/@diffci.com/core/src/repo/impact-types.ts +2 -0
- package/node_modules/@diffci.com/core/src/repo/impact.ts +267 -9
- package/node_modules/@diffci.com/core/src/repo/lockfiles.ts +13 -0
- package/node_modules/@diffci.com/core/src/repo/repo-config.ts +8 -1
- package/node_modules/@diffci.com/core/src/repo/types.ts +32 -1
- package/node_modules/@diffci.com/core/src/repo/workspace-sources.ts +273 -0
- package/package.json +3 -3
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
/**
|
|
3
|
+
* Maps an import of a declared workspace package to that package's source files.
|
|
4
|
+
*
|
|
5
|
+
* Workspace packages commonly point `types`, `main` and `exports` at build output (2026-11-09, Sentry's
|
|
6
|
+
* JavaScript SDK: `@sentry/server-utils` exports `./build/types/index.d.ts`). Before a build those files
|
|
7
|
+
* do not exist and the import resolves nowhere; after `build:types` it resolves to a generated declaration
|
|
8
|
+
* file that no source change ever touches. Either way the edge into the package's `src/` is lost, and a
|
|
9
|
+
* selective plan would skip every downstream package.
|
|
10
|
+
*
|
|
11
|
+
* The mapping is exact or absent. A declaration entry maps to source only through a tsconfig in the
|
|
12
|
+
* package root that states both an output directory (`declarationDir` or `outDir`) containing the entry and
|
|
13
|
+
* a `rootDir`; `outDir/x.d.ts` becomes `rootDir/x.ts` (or `.tsx`, `.mts`, `.cts`, `.js`, `.jsx`) when that file
|
|
14
|
+
* exists. An entry that is itself a TypeScript source file is used as is. Anything else is unmapped, and the
|
|
15
|
+
* caller must fall back rather than guess.
|
|
16
|
+
*/
|
|
17
|
+
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
|
18
|
+
import { join, posix } from "node:path";
|
|
19
|
+
import ts from "typescript";
|
|
20
|
+
const DECLARATION = /\.d\.([mc]?)ts$/;
|
|
21
|
+
const SOURCE = /\.([mc]?tsx?|[mc]?jsx?)$/;
|
|
22
|
+
const EMITTED = /\.([mc]?)jsx?$/;
|
|
23
|
+
function toPosix(path) {
|
|
24
|
+
return path.replace(/\\/g, "/");
|
|
25
|
+
}
|
|
26
|
+
export class WorkspaceSources {
|
|
27
|
+
repoPath;
|
|
28
|
+
packages = new Map();
|
|
29
|
+
manifests = new Map();
|
|
30
|
+
outputs = new Map();
|
|
31
|
+
constructor(repoPath, workspaceRoots) {
|
|
32
|
+
this.repoPath = repoPath;
|
|
33
|
+
for (const root of workspaceRoots) {
|
|
34
|
+
if (!root)
|
|
35
|
+
continue;
|
|
36
|
+
const name = this.manifest(root)?.name;
|
|
37
|
+
if (typeof name === "string" && name && !this.packages.has(name))
|
|
38
|
+
this.packages.set(name, { name, root });
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
get size() {
|
|
42
|
+
return this.packages.size;
|
|
43
|
+
}
|
|
44
|
+
/** The workspace package whose directory holds a repository-relative path (the deepest one). */
|
|
45
|
+
packageContaining(path) {
|
|
46
|
+
let found;
|
|
47
|
+
for (const pkg of this.packages.values()) {
|
|
48
|
+
if (path.startsWith(`${pkg.root}/`) && (!found || pkg.root.length > found.root.length))
|
|
49
|
+
found = pkg;
|
|
50
|
+
}
|
|
51
|
+
return found;
|
|
52
|
+
}
|
|
53
|
+
/** The workspace package a bare specifier names, and the export subpath (`.` or `./x`). */
|
|
54
|
+
packageFor(specifier) {
|
|
55
|
+
const parts = specifier.split("/");
|
|
56
|
+
const nameParts = specifier.startsWith("@") ? 2 : 1;
|
|
57
|
+
if (parts.length < nameParts || parts.slice(0, nameParts).some((part) => !part))
|
|
58
|
+
return undefined;
|
|
59
|
+
const pkg = this.packages.get(parts.slice(0, nameParts).join("/"));
|
|
60
|
+
if (!pkg)
|
|
61
|
+
return undefined;
|
|
62
|
+
const rest = parts.slice(nameParts).join("/");
|
|
63
|
+
return { pkg, subpath: rest ? `./${rest}` : "." };
|
|
64
|
+
}
|
|
65
|
+
/** Repository-relative source file for an import of `subpath`, from the package manifest. */
|
|
66
|
+
sourceForSubpath(pkg, subpath) {
|
|
67
|
+
const manifest = this.manifest(pkg.root);
|
|
68
|
+
if (!manifest)
|
|
69
|
+
return undefined;
|
|
70
|
+
const entry = entryTarget(manifest, subpath);
|
|
71
|
+
if (entry === undefined && subpath !== ".") {
|
|
72
|
+
// A deep import of a file path the manifest does not export, such as Sentry's
|
|
73
|
+
// `@sentry/node/build/types/types` in a type import: map that file itself.
|
|
74
|
+
const file = posix.normalize(posix.join(pkg.root, subpath));
|
|
75
|
+
if (!file.startsWith(`${pkg.root}/`))
|
|
76
|
+
return undefined;
|
|
77
|
+
for (const candidate of [file, `${file}.d.ts`, `${file}/index.d.ts`, `${file}.ts`, `${file}/index.ts`]) {
|
|
78
|
+
const source = this.toSource(pkg, candidate);
|
|
79
|
+
if (source)
|
|
80
|
+
return source;
|
|
81
|
+
}
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
84
|
+
if (!entry || entry.startsWith("/") || /^[A-Za-z]:/.test(entry))
|
|
85
|
+
return undefined;
|
|
86
|
+
const target = posix.normalize(posix.join(pkg.root, entry));
|
|
87
|
+
if (target !== pkg.root && !target.startsWith(`${pkg.root}/`))
|
|
88
|
+
return undefined;
|
|
89
|
+
return this.toSource(pkg, target);
|
|
90
|
+
}
|
|
91
|
+
/** Repository-relative non-code file (a stylesheet, JSON, an image) an `exports` entry names for `subpath`,
|
|
92
|
+
* such as payloadcms/payload's `"./css/app.css": "./src/css/app.css"` in `@payloadcms/ui`. */
|
|
93
|
+
assetForSubpath(pkg, subpath) {
|
|
94
|
+
const manifest = this.manifest(pkg.root);
|
|
95
|
+
const node = manifest?.exports === undefined ? undefined : exportNode(manifest.exports, subpath);
|
|
96
|
+
if (!node)
|
|
97
|
+
return undefined;
|
|
98
|
+
for (const leaf of exportLeaves(node.entry, node.star)) {
|
|
99
|
+
if (leaf.startsWith("/") || /^[A-Za-z]:/.test(leaf) || SOURCE.test(leaf) || DECLARATION.test(leaf))
|
|
100
|
+
continue;
|
|
101
|
+
const target = posix.normalize(posix.join(pkg.root, leaf));
|
|
102
|
+
if (target.startsWith(`${pkg.root}/`) && existsSync(join(this.repoPath, target)))
|
|
103
|
+
return target;
|
|
104
|
+
}
|
|
105
|
+
return undefined;
|
|
106
|
+
}
|
|
107
|
+
/** Whether an import of `subpath` names anything: a manifest entry, or a file in the package. An import
|
|
108
|
+
* that names nothing fails whether the package is installed or not. */
|
|
109
|
+
names(pkg, subpath) {
|
|
110
|
+
const manifest = this.manifest(pkg.root);
|
|
111
|
+
if (!manifest)
|
|
112
|
+
return true;
|
|
113
|
+
if (manifest.exports === undefined ? subpath === "." : exportNode(manifest.exports, subpath))
|
|
114
|
+
return true;
|
|
115
|
+
if (subpath === ".")
|
|
116
|
+
return true;
|
|
117
|
+
const file = posix.normalize(posix.join(pkg.root, subpath));
|
|
118
|
+
return [file, `${file}.d.ts`, `${file}.ts`, `${file}.tsx`, `${file}.js`, `${file}/index.d.ts`, `${file}/index.ts`, `${file}/index.js`]
|
|
119
|
+
.some((candidate) => existsSync(join(this.repoPath, candidate)));
|
|
120
|
+
}
|
|
121
|
+
/** Repository-relative source file for a file inside the package that TypeScript resolved to. */
|
|
122
|
+
sourceForFile(pkg, fileRel) {
|
|
123
|
+
return this.toSource(pkg, fileRel);
|
|
124
|
+
}
|
|
125
|
+
toSource(pkg, targetRel) {
|
|
126
|
+
const declaration = DECLARATION.exec(targetRel);
|
|
127
|
+
const script = declaration ? null : EMITTED.exec(targetRel);
|
|
128
|
+
const outputs = this.outputDirectories(pkg);
|
|
129
|
+
for (const { declarationDir, outDir, rootDir } of outputs) {
|
|
130
|
+
// Declarations live in declarationDir (or outDir); emitted JavaScript only in outDir.
|
|
131
|
+
const directory = declaration ? declarationDir : script ? outDir : undefined;
|
|
132
|
+
if (!directory || !targetRel.startsWith(`${directory}/`))
|
|
133
|
+
continue;
|
|
134
|
+
const flavor = (declaration ?? script)[1];
|
|
135
|
+
const stem = targetRel.slice(directory.length + 1).replace(declaration ? DECLARATION : EMITTED, "");
|
|
136
|
+
const extensions = flavor ? [`.${flavor}ts`, `.${flavor}js`] : [".ts", ".tsx", ".js", ".jsx"];
|
|
137
|
+
for (const extension of extensions) {
|
|
138
|
+
const candidate = posix.join(rootDir, stem + extension);
|
|
139
|
+
if (existsSync(join(this.repoPath, candidate)))
|
|
140
|
+
return candidate;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
if (declaration)
|
|
144
|
+
return undefined;
|
|
145
|
+
// Build output is never source, even when it exists on disk.
|
|
146
|
+
if (outputs.some(({ declarationDir, outDir }) => [declarationDir, outDir].some((dir) => dir && targetRel.startsWith(`${dir}/`))))
|
|
147
|
+
return undefined;
|
|
148
|
+
if (!SOURCE.test(targetRel))
|
|
149
|
+
return undefined;
|
|
150
|
+
if (existsSync(join(this.repoPath, targetRel)))
|
|
151
|
+
return targetRel;
|
|
152
|
+
// A `.js` specifier naming a TypeScript source beside it, as TypeScript resolves it (2026-11-10:
|
|
153
|
+
// payloadcms/payload exports `"types": "./src/exports/build-config.js"`, which exists only as `.ts`).
|
|
154
|
+
if (script) {
|
|
155
|
+
const stem = targetRel.slice(0, -script[0].length);
|
|
156
|
+
const flavor = script[1];
|
|
157
|
+
for (const extension of flavor ? [`.${flavor}ts`] : [".ts", ".tsx"]) {
|
|
158
|
+
if (existsSync(join(this.repoPath, stem + extension)))
|
|
159
|
+
return stem + extension;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return undefined;
|
|
163
|
+
}
|
|
164
|
+
/** Output directories stated by tsconfig*.json files in the package root, with their rootDir. */
|
|
165
|
+
outputDirectories(pkg) {
|
|
166
|
+
let found = this.outputs.get(pkg.root);
|
|
167
|
+
if (found)
|
|
168
|
+
return found;
|
|
169
|
+
found = [];
|
|
170
|
+
const directory = join(this.repoPath, pkg.root);
|
|
171
|
+
let names = [];
|
|
172
|
+
try {
|
|
173
|
+
names = readdirSync(directory).filter((name) => /^tsconfig(\..+)?\.json$/.test(name)).sort();
|
|
174
|
+
}
|
|
175
|
+
catch { /* an unreadable package states no outputs */ }
|
|
176
|
+
for (const name of names) {
|
|
177
|
+
const file = toPosix(join(directory, name));
|
|
178
|
+
const read = ts.readConfigFile(file, ts.sys.readFile);
|
|
179
|
+
if (read.error)
|
|
180
|
+
continue;
|
|
181
|
+
const options = ts.parseJsonConfigFileContent(read.config, ts.sys, toPosix(directory), undefined, file).options;
|
|
182
|
+
const rootDir = this.relative(options.rootDir);
|
|
183
|
+
// Every directory must stay inside the package; a rootDir elsewhere would map onto another package's files.
|
|
184
|
+
const within = (path) => path !== undefined && (path === pkg.root || path.startsWith(`${pkg.root}/`));
|
|
185
|
+
if (!within(rootDir))
|
|
186
|
+
continue;
|
|
187
|
+
const usable = (path) => (within(path) && path !== rootDir ? path : undefined);
|
|
188
|
+
const outDir = usable(this.relative(options.outDir));
|
|
189
|
+
const declarationDir = usable(this.relative(options.declarationDir ?? options.outDir));
|
|
190
|
+
if (outDir || declarationDir)
|
|
191
|
+
found.push({ declarationDir, outDir, rootDir });
|
|
192
|
+
}
|
|
193
|
+
this.outputs.set(pkg.root, found);
|
|
194
|
+
return found;
|
|
195
|
+
}
|
|
196
|
+
relative(path) {
|
|
197
|
+
if (!path)
|
|
198
|
+
return undefined;
|
|
199
|
+
const root = toPosix(this.repoPath).replace(/\/$/, "");
|
|
200
|
+
const value = posix.normalize(toPosix(path));
|
|
201
|
+
if (value.toLowerCase() === root.toLowerCase())
|
|
202
|
+
return "";
|
|
203
|
+
return value.toLowerCase().startsWith(`${root.toLowerCase()}/`) ? value.slice(root.length + 1) : undefined;
|
|
204
|
+
}
|
|
205
|
+
manifest(root) {
|
|
206
|
+
if (this.manifests.has(root))
|
|
207
|
+
return this.manifests.get(root);
|
|
208
|
+
let manifest;
|
|
209
|
+
try {
|
|
210
|
+
const parsed = JSON.parse(readFileSync(join(this.repoPath, root, "package.json"), "utf8"));
|
|
211
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed))
|
|
212
|
+
manifest = parsed;
|
|
213
|
+
}
|
|
214
|
+
catch { /* an unreadable manifest names no package */ }
|
|
215
|
+
this.manifests.set(root, manifest);
|
|
216
|
+
return manifest;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
/** The entry the manifest gives for `subpath`: the `types` target of its export (or a TypeScript source
|
|
220
|
+
* target when it has none), else the top-level `types`/`typings` for the package root. */
|
|
221
|
+
function entryTarget(manifest, subpath) {
|
|
222
|
+
const exports = manifest.exports;
|
|
223
|
+
if (exports === undefined) {
|
|
224
|
+
if (subpath !== ".")
|
|
225
|
+
return undefined;
|
|
226
|
+
const types = manifest.types ?? manifest.typings;
|
|
227
|
+
return typeof types === "string" ? types : undefined;
|
|
228
|
+
}
|
|
229
|
+
const node = exportNode(exports, subpath);
|
|
230
|
+
return node ? pickEntry(node.entry, node.star) : undefined;
|
|
231
|
+
}
|
|
232
|
+
/** The `exports` entry for `subpath` and the text its `*` stands for, or undefined when none matches. */
|
|
233
|
+
function exportNode(exports, subpath) {
|
|
234
|
+
const isMap = exports !== null && typeof exports === "object" && !Array.isArray(exports);
|
|
235
|
+
const keyed = isMap && Object.keys(exports).some((key) => key.startsWith("."));
|
|
236
|
+
if (!keyed)
|
|
237
|
+
return subpath === "." ? { entry: exports, star: undefined } : undefined;
|
|
238
|
+
const map = exports;
|
|
239
|
+
if (subpath in map)
|
|
240
|
+
return { entry: map[subpath], star: undefined };
|
|
241
|
+
// Subpath patterns: the longest matching prefix wins, as in Node.
|
|
242
|
+
let best;
|
|
243
|
+
for (const key of Object.keys(map)) {
|
|
244
|
+
const star = key.indexOf("*");
|
|
245
|
+
if (star < 0 || key.indexOf("*", star + 1) >= 0)
|
|
246
|
+
continue;
|
|
247
|
+
const prefix = key.slice(0, star);
|
|
248
|
+
const suffix = key.slice(star + 1);
|
|
249
|
+
if (subpath.length < prefix.length + suffix.length || !subpath.startsWith(prefix) || !subpath.endsWith(suffix))
|
|
250
|
+
continue;
|
|
251
|
+
if (!best || prefix.length > best.key.indexOf("*"))
|
|
252
|
+
best = { key, star: subpath.slice(prefix.length, subpath.length - suffix.length) };
|
|
253
|
+
}
|
|
254
|
+
return best ? { entry: map[best.key], star: best.star } : undefined;
|
|
255
|
+
}
|
|
256
|
+
/** Every string target of an `exports` entry, with `*` filled in. */
|
|
257
|
+
function exportLeaves(entry, star) {
|
|
258
|
+
const leaves = [];
|
|
259
|
+
const walk = (node) => {
|
|
260
|
+
if (typeof node === "string")
|
|
261
|
+
leaves.push(star === undefined ? node : node.split("*").join(star));
|
|
262
|
+
else if (Array.isArray(node))
|
|
263
|
+
for (const item of node)
|
|
264
|
+
walk(item);
|
|
265
|
+
else if (node && typeof node === "object")
|
|
266
|
+
for (const value of Object.values(node))
|
|
267
|
+
walk(value);
|
|
268
|
+
};
|
|
269
|
+
walk(entry);
|
|
270
|
+
return leaves;
|
|
271
|
+
}
|
|
272
|
+
function pickEntry(entry, star) {
|
|
273
|
+
const fill = (value) => (star === undefined ? value : value.split("*").join(star));
|
|
274
|
+
const leaves = [];
|
|
275
|
+
const walk = (node, types) => {
|
|
276
|
+
if (typeof node === "string")
|
|
277
|
+
leaves.push({ value: fill(node), types });
|
|
278
|
+
else if (Array.isArray(node))
|
|
279
|
+
for (const item of node)
|
|
280
|
+
walk(item, types);
|
|
281
|
+
else if (node && typeof node === "object")
|
|
282
|
+
for (const [key, value] of Object.entries(node))
|
|
283
|
+
walk(value, types || key === "types");
|
|
284
|
+
};
|
|
285
|
+
walk(entry, false);
|
|
286
|
+
return leaves.find((leaf) => leaf.types)?.value
|
|
287
|
+
?? leaves.find((leaf) => DECLARATION.test(leaf.value))?.value
|
|
288
|
+
?? leaves.find((leaf) => /\.[mc]?tsx?$/.test(leaf.value))?.value
|
|
289
|
+
// JavaScript only: mapped back through a tsconfig outDir, or used as is when it is source.
|
|
290
|
+
?? leaves.find((leaf) => EMITTED.test(leaf.value))?.value;
|
|
291
|
+
}
|
|
292
|
+
//# sourceMappingURL=workspace-sources.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-sources.js","sourceRoot":"","sources":["../../src/repo/workspace-sources.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC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,MAAM,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;aACnE,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;YAAE,KAAK,MAAM,IAAI,IAAI,IAAI;gBAAE,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;aACpE,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ;YAAE,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC;gBAAE,IAAI,CAAC,KAAK,EAAE,KAAK,IAAI,GAAG,KAAK,OAAO,CAAC,CAAC;IACpI,CAAC,CAAC;IACF,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACnB,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,KAAK;WAC1C,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK;WAC1D,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK;QAChE,2FAA2F;WACxF,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC;AAC9D,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@diffci.com/core",
|
|
3
3
|
"version": "0.1.1",
|
|
4
|
-
"description": "
|
|
4
|
+
"description": "Engine behind DiffCI, verification for AI coding agents: dependency analysis, affected tests and checks, conservative fallback",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"private": true,
|
|
7
7
|
"type": "module",
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { existsSync, readFileSync } from "node:fs";
|
|
3
3
|
import { join } from "node:path";
|
|
4
|
+
import { LOCKFILE_NAMES } from "../repo/lockfiles.js";
|
|
4
5
|
import { readRepositoryConfig } from "../repo/repo-config.js";
|
|
5
6
|
|
|
6
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* Files that determine whether a cached Vue analysis still matches the checkout configuration.
|
|
9
|
+
* The declared Vue package can carry its own lockfile, so every lockfile name is hashed there too.
|
|
10
|
+
*/
|
|
7
11
|
export function economicsContext(repoPath: string): string {
|
|
8
12
|
const scope = readRepositoryConfig(repoPath).vue;
|
|
9
|
-
const paths = new Set(["diffci.json", "package.json", "tsconfig.json", "go.mod", "go.sum", "go.work", "go.work.sum",
|
|
10
|
-
if (scope) for (const path of ["package.json", "tsconfig.json", scope.testConfig]) paths.add(`${scope.packageRoot}/${path}`);
|
|
13
|
+
const paths = new Set(["diffci.json", "package.json", "tsconfig.json", "go.mod", "go.sum", "go.work", "go.work.sum", ...LOCKFILE_NAMES, ...["ts", "js", "mts", "mjs", "cts", "cjs"].map(ext => `vitest.config.${ext}`)]);
|
|
14
|
+
if (scope) for (const path of ["package.json", "tsconfig.json", scope.testConfig, ...LOCKFILE_NAMES]) paths.add(`${scope.packageRoot}/${path}`);
|
|
11
15
|
const hash = createHash("sha256").update(JSON.stringify([process.platform, process.arch, process.version]));
|
|
12
16
|
for (const path of [...paths].sort()) {
|
|
13
17
|
hash.update(JSON.stringify(path));
|
|
@@ -9,7 +9,11 @@ import type { DependencyGraphResult } from "../repo/types.js";
|
|
|
9
9
|
// 6: the profile's diffciConfig carries declared `inputs` (2026-11-05).
|
|
10
10
|
// 7: folded computed specifiers and root-absolute Vite globs have edges (2026-11-06).
|
|
11
11
|
// 8: Python projects have a graph, and the profile carries pythonSources/pythonTests (2026-11-06).
|
|
12
|
-
|
|
12
|
+
// 11: results carry export-level `bindings` (2026-11-10).
|
|
13
|
+
// 12: bindings mark computed loads that run when a module loads (2026-11-10).
|
|
14
|
+
// 13: tsd and tstyche scope type edges to their own files (typeTestGlobs) (2026-11-10).
|
|
15
|
+
// 14: path-literal edges from strings naming code files (2026-11-10).
|
|
16
|
+
export const GRAPH_CACHE_SCHEMA_VERSION = "14";
|
|
13
17
|
|
|
14
18
|
export interface GraphCacheKeyInputs {
|
|
15
19
|
commitSha: string;
|
|
@@ -62,7 +62,7 @@ export function packageFacts(repoPath: string): ObservedFact[] {
|
|
|
62
62
|
/** Which lockfile is committed. The repository's own statement about its package manager. */
|
|
63
63
|
export function lockfileFacts(repoPath: string): ObservedFact[] {
|
|
64
64
|
const facts: ObservedFact[] = [];
|
|
65
|
-
for (const name of ["pnpm-lock.yaml", "yarn.lock", "package-lock.json", "bun.lockb", "npm-shrinkwrap.json"]) {
|
|
65
|
+
for (const name of ["pnpm-lock.yaml", "yarn.lock", "package-lock.json", "bun.lock", "bun.lockb", "npm-shrinkwrap.json"]) {
|
|
66
66
|
if (existsSync(join(repoPath, name))) {
|
|
67
67
|
facts.push({ kind: "lockfile.present", value: name, evidence: { file: name, text: name } });
|
|
68
68
|
}
|
|
@@ -15,7 +15,7 @@ import { workflowMayRunTests } from "../repo/workflow-test-steps.js";
|
|
|
15
15
|
import { npmLockAffectedDependencies } from "../repo/npm-lockfile.js";
|
|
16
16
|
import { pnpmLockAffectedDependencies } from "../repo/pnpm-lockfile.js";
|
|
17
17
|
import { yarnLockAffectedDependencies } from "../repo/yarn-lockfile.js";
|
|
18
|
-
import { LOCKFILE } from "../repo/lockfiles.js";
|
|
18
|
+
import { LOCKFILE, LOCKFILE_NAMES } from "../repo/lockfiles.js";
|
|
19
19
|
import { ciConfigPredicate, gitlabLocalIncludes, isConventionalCiConfigPath } from "./ci-config-paths.js";
|
|
20
20
|
|
|
21
21
|
export const EMPTY_TREE_SHA = "4b825dc642cb6eb9a060e54bf8d69288fbee4904";
|
|
@@ -195,12 +195,12 @@ export function normalizeDirectories(paths: Iterable<string>): string[] {
|
|
|
195
195
|
return dirs;
|
|
196
196
|
}
|
|
197
197
|
|
|
198
|
-
|
|
198
|
+
/** Exported for tests only: each entry must match a real configuration file name. */
|
|
199
|
+
export const CONFIG_PATTERNS = [
|
|
199
200
|
/^next\.config\./,
|
|
200
201
|
/^tsconfig\.json$/,
|
|
201
202
|
/^jsconfig\.json$/,
|
|
202
203
|
/^eslint\.config\./,
|
|
203
|
-
/^eslint\.rc/,
|
|
204
204
|
/^\.eslint/,
|
|
205
205
|
/^postcss\.config\./,
|
|
206
206
|
/^tailwind\.config\./,
|
|
@@ -208,6 +208,9 @@ const CONFIG_PATTERNS = [
|
|
|
208
208
|
/^prettier\.config\./,
|
|
209
209
|
/^vitest\.config\./,
|
|
210
210
|
/^jest\.config\./,
|
|
211
|
+
// babel-jest transforms every test file with these; without this a .js/.ts babel.config or .babelrc.js was
|
|
212
|
+
// classified as source with no importers and selected no tests (2026-11-11, #99).
|
|
213
|
+
/^(?:babel\.config\.|\.babelrc)/,
|
|
211
214
|
/^playwright\.config\./,
|
|
212
215
|
/^webpack\.config\./,
|
|
213
216
|
/^rollup\.config\./,
|
|
@@ -225,7 +228,6 @@ const CONFIG_PATTERNS = [
|
|
|
225
228
|
/^yarn\.lock$/,
|
|
226
229
|
/^pnpm-lock\.yaml$/,
|
|
227
230
|
/^bun\.lockb$/,
|
|
228
|
-
/^(npm|pnpm|yarn)-lock\./,
|
|
229
231
|
// Python projects (2026-11-06): what pytest, the interpreter and the installed packages are.
|
|
230
232
|
/^pyproject\.toml$/,
|
|
231
233
|
/^setup\.(?:py|cfg)$/,
|
|
@@ -343,7 +345,6 @@ export function testListEdit(oldBody: string, newBody: string): { added: string[
|
|
|
343
345
|
}
|
|
344
346
|
|
|
345
347
|
const DEPENDENCY_FIELDS = new Set(["dependencies", "devDependencies", "optionalDependencies"]);
|
|
346
|
-
const PACKAGE_LOCKFILES = ["package-lock.json", "npm-shrinkwrap.json", "yarn.lock", "pnpm-lock.yaml", "bun.lock", "bun.lockb"];
|
|
347
348
|
|
|
348
349
|
/** Exact root requests for the supported Classic layout. Unlike scriptRecord, never discard an
|
|
349
350
|
* invalid dependency value: an omitted root would make the lockfile attribution incomplete. */
|
|
@@ -841,7 +842,7 @@ export async function analyzeGitDelta(
|
|
|
841
842
|
const lockfileGoverns = (path: string) => {
|
|
842
843
|
for (let dir = posix.dirname(path); ; dir = posix.dirname(dir)) {
|
|
843
844
|
const prefix = dir === "." ? "" : `${dir}/`;
|
|
844
|
-
if (
|
|
845
|
+
if (LOCKFILE_NAMES.some((name) => [baseSha, headSha].some((sha) => readFileAtSha(sha, prefix + name, repoPath) !== undefined))) return true;
|
|
845
846
|
if (dir === ".") return false;
|
|
846
847
|
}
|
|
847
848
|
};
|
|
@@ -77,7 +77,11 @@ export function analyzeGoMetadata(context: AdapterContext, output: string): Adap
|
|
|
77
77
|
// Associate inactive files with their package conservatively. They are not runnable
|
|
78
78
|
// tests, but edits (including build constraints) must still select that package and
|
|
79
79
|
// its dependents. Unaccounted files remain a global blocker below.
|
|
80
|
-
|
|
80
|
+
// A package of a locally replaced module is a dependency of the root build only: its tests belong to
|
|
81
|
+
// that module and cannot run from the root, so they are neither selectable tests nor modelled sources.
|
|
82
|
+
const replaced = Boolean(pkg.Module?.Replace?.Dir);
|
|
83
|
+
const testFiles = replaced ? [] : [...(pkg.TestGoFiles ?? []), ...(pkg.XTestGoFiles ?? [])];
|
|
84
|
+
const files = [...(pkg.GoFiles ?? []), ...(pkg.CgoFiles ?? []), ...testFiles, ...(pkg.IgnoredGoFiles ?? [])];
|
|
81
85
|
const paths = files.map((file) => internalPath(context.repoPath, resolve(pkg.Dir, file)));
|
|
82
86
|
if (paths.some((p) => p === undefined)) { result.blockers.push("Go package contains files outside the repository"); continue; }
|
|
83
87
|
const sources = paths as string[];
|
|
@@ -92,12 +96,12 @@ export function analyzeGoMetadata(context: AdapterContext, output: string): Adap
|
|
|
92
96
|
if (/^\s*\/\/go:(?:generate|linkname)\b/m.test(readFileSync(resolve(context.repoPath, file), "utf8"))) result.blockers.push(`Go ${file}: generated or linked dependencies require full validation`);
|
|
93
97
|
}
|
|
94
98
|
const dir = internalPath(context.repoPath, pkg.Dir)!;
|
|
95
|
-
for (const test of
|
|
99
|
+
for (const test of testFiles) {
|
|
96
100
|
const path = internalPath(context.repoPath, resolve(pkg.Dir, test))!;
|
|
97
101
|
result.testFiles.push(path);
|
|
98
102
|
result.testPackages[path] = dir ? `./${dir}` : ".";
|
|
99
103
|
}
|
|
100
|
-
for (const file of [...(pkg.EmbedFiles ?? []), ...(pkg.TestEmbedFiles ?? []), ...(pkg.XTestEmbedFiles ?? [])]) {
|
|
104
|
+
for (const file of [...(pkg.EmbedFiles ?? []), ...(replaced ? [] : [...(pkg.TestEmbedFiles ?? []), ...(pkg.XTestEmbedFiles ?? [])])]) {
|
|
101
105
|
const asset = internalPath(context.repoPath, resolve(pkg.Dir, file));
|
|
102
106
|
if (asset === undefined) { result.blockers.push("Go embedded file escapes repository"); continue; }
|
|
103
107
|
result.assetPaths.push(asset);
|
|
@@ -111,7 +115,8 @@ export function analyzeGoMetadata(context: AdapterContext, output: string): Adap
|
|
|
111
115
|
for (const file of members.get(pkg.ImportPath) ?? []) {
|
|
112
116
|
if (file !== anchor) result.edges.push({ from: anchor, to: file, kind: "import" }, { from: file, to: anchor, kind: "import" });
|
|
113
117
|
}
|
|
114
|
-
|
|
118
|
+
const replaced = Boolean(pkg.Module?.Replace?.Dir);
|
|
119
|
+
for (const imported of [...(pkg.Imports ?? []), ...(replaced ? [] : [...(pkg.TestImports ?? []), ...(pkg.XTestImports ?? [])])]) {
|
|
115
120
|
const target = anchors.get(imported);
|
|
116
121
|
if (target && target !== anchor) result.edges.push({ from: anchor, to: target, kind: "import" });
|
|
117
122
|
}
|
|
@@ -156,9 +161,20 @@ export const goAdapter: RepositoryAdapter = {
|
|
|
156
161
|
const scopedContext = scoped ? { ...context, files: context.files.filter(file => !excluded(file)) } : context;
|
|
157
162
|
const result = analyzeGoMetadata(scopedContext, output);
|
|
158
163
|
if (scoped) {
|
|
159
|
-
|
|
160
|
-
//
|
|
161
|
-
|
|
164
|
+
// A local replacement makes a nested module part of the root module's build. When it points at a
|
|
165
|
+
// nested module root inside the repository, go list already reports the packages the root build
|
|
166
|
+
// uses (with their Dir inside the checkout), so that module is modelled rather than excluded:
|
|
167
|
+
// changes to those packages select their importers, and its other files (its own tests, packages
|
|
168
|
+
// the root does not use, its go.mod) stay outside source metadata and fall back (#81).
|
|
169
|
+
const replaceDirs = new Set(parseGoList(output).flatMap(pkg => {
|
|
170
|
+
const dir = pkg.Module?.Replace?.Dir;
|
|
171
|
+
if (!dir) return [];
|
|
172
|
+
const internal = internalPath(context.repoPath, dir);
|
|
173
|
+
return [internal === undefined ? dir : `${internal}/`];
|
|
174
|
+
}));
|
|
175
|
+
const replacedRoots = nestedRoots.filter(root => replaceDirs.has(root));
|
|
176
|
+
context.profile.goExcludedModuleRoots = nestedRoots.filter(root => !replacedRoots.includes(root));
|
|
177
|
+
if (replaceDirs.size > replacedRoots.length) result.blockers.push("Go root-module scope with local replacements requires full validation");
|
|
162
178
|
}
|
|
163
179
|
result.executionEnv = { GOOS: buildEnv.GOOS, GOARCH: buildEnv.GOARCH, CGO_ENABLED: buildEnv.CGO_ENABLED, GOFLAGS: "" };
|
|
164
180
|
return result;
|
|
@@ -218,6 +218,14 @@ function matchesTestGlob(path: string, pattern: string): boolean {
|
|
|
218
218
|
return matchesGlob(path, pattern);
|
|
219
219
|
}
|
|
220
220
|
|
|
221
|
+
/**
|
|
222
|
+
* Build-output names skipped only where output goes: beside a package.json or at the repository root.
|
|
223
|
+
* 2026-11-10: skipping them at any depth hid payloadcms/payload's
|
|
224
|
+
* `packages/payload/src/cli/commands/build/build.spec.ts`, a source test Vitest runs, so a narrowed selection
|
|
225
|
+
* could never include it.
|
|
226
|
+
*/
|
|
227
|
+
const OUTPUT_DIR_NAMES = new Set(["dist", "build", "tmp", "temp"]);
|
|
228
|
+
|
|
221
229
|
function scanFiles(
|
|
222
230
|
dirPath: string,
|
|
223
231
|
repoPath: string,
|
|
@@ -225,9 +233,15 @@ function scanFiles(
|
|
|
225
233
|
callback: (relativePath: string, fileName: string) => void,
|
|
226
234
|
): void {
|
|
227
235
|
const entries = readdirSync(dirPath, { withFileTypes: true });
|
|
236
|
+
let outputRoot: boolean | undefined;
|
|
228
237
|
for (const entry of entries) {
|
|
229
238
|
if (entry.isDirectory()) {
|
|
230
|
-
if (
|
|
239
|
+
if (entry.name.startsWith(".")) continue;
|
|
240
|
+
if (excludeDirs.has(entry.name)) {
|
|
241
|
+
if (!OUTPUT_DIR_NAMES.has(entry.name)) continue;
|
|
242
|
+
outputRoot ??= dirPath === repoPath || existsSync(join(dirPath, "package.json"));
|
|
243
|
+
if (outputRoot) continue;
|
|
244
|
+
}
|
|
231
245
|
scanFiles(join(dirPath, entry.name), repoPath, excludeDirs, callback);
|
|
232
246
|
continue;
|
|
233
247
|
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
import type { ModuleBindings } from "./types.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Export-level reach (2026-11-10). File-level selection treats `import { x } from "pkg"` as a dependency on
|
|
6
|
+
* every file `pkg`'s barrel re-exports, which is what `vitest --changed` does too. On payloadcms/payload that
|
|
7
|
+
* selects about 230 of 520 test files for a change in one hierarchy helper. Following re-exports by name
|
|
8
|
+
* inside packages that declare `sideEffects: false` (the contract bundlers rely on to drop unused re-exports)
|
|
9
|
+
* selected 16.5% of test files on 31 code-only commits against Vitest's 23.5%.
|
|
10
|
+
*
|
|
11
|
+
* `touched` is every file whose code a test runs or whose exports were consulted to resolve one of its
|
|
12
|
+
* names, so a changed barrel or a changed `export *` source still selects. Whenever the walk cannot tell
|
|
13
|
+
* which names a module binds (no bindings, opaque exports, a package without the side-effect contract, a
|
|
14
|
+
* name it cannot find) it counts the whole module, as file-level selection does.
|
|
15
|
+
*/
|
|
16
|
+
export function exportLevelReach(
|
|
17
|
+
start: string,
|
|
18
|
+
bindings: Readonly<Record<string, ModuleBindings>>,
|
|
19
|
+
runtimeDependencies: (path: string) => readonly string[],
|
|
20
|
+
/** Tests may be type-checked as they run: a type import of a target takes the whole target. */
|
|
21
|
+
followTypes = false,
|
|
22
|
+
): Set<string> {
|
|
23
|
+
const touched = new Set<string>();
|
|
24
|
+
const ran = new Set<string>();
|
|
25
|
+
const whole = new Set<string>();
|
|
26
|
+
const seen = new Set<string>();
|
|
27
|
+
const queue: [string, string][] = [[start, "*"]];
|
|
28
|
+
|
|
29
|
+
const runBody = (file: string): void => {
|
|
30
|
+
if (ran.has(file)) return;
|
|
31
|
+
ran.add(file);
|
|
32
|
+
const own = bindings[file];
|
|
33
|
+
for (const target of runtimeDependencies(file)) {
|
|
34
|
+
const imported = own?.imports[target];
|
|
35
|
+
if (followTypes && own?.typeImports?.includes(target)) {
|
|
36
|
+
queue.push([target, "*"]);
|
|
37
|
+
} else if (imported === undefined) {
|
|
38
|
+
// A target only re-exported is evaluated but contributes nothing unless a name is asked of it.
|
|
39
|
+
if (own?.reexports[target] && bindings[target]?.sideEffectFree) continue;
|
|
40
|
+
queue.push([target, "*"]);
|
|
41
|
+
} else if (imported === "*" || !bindings[target]?.sideEffectFree) {
|
|
42
|
+
queue.push([target, "*"]);
|
|
43
|
+
} else {
|
|
44
|
+
for (const name of imported) queue.push([target, name]);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const takeWhole = (file: string): void => {
|
|
50
|
+
if (whole.has(file)) return;
|
|
51
|
+
whole.add(file);
|
|
52
|
+
runBody(file);
|
|
53
|
+
for (const target of Object.keys(bindings[file]?.reexports ?? {})) queue.push([target, "*"]);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const defines = (file: string, name: string, visiting: Set<string>): boolean => {
|
|
57
|
+
if (visiting.has(file)) return false;
|
|
58
|
+
visiting.add(file);
|
|
59
|
+
touched.add(file);
|
|
60
|
+
const own = bindings[file];
|
|
61
|
+
if (!own || own.opaque || !own.sideEffectFree) return true;
|
|
62
|
+
if (own.locals.includes(name)) return true;
|
|
63
|
+
for (const forwarded of Object.values(own.reexports)) {
|
|
64
|
+
if (forwarded.namespaces.includes(name) || forwarded.pairs.some(([exported]) => exported === name)) return true;
|
|
65
|
+
}
|
|
66
|
+
return Object.entries(own.reexports).some(([target, forwarded]) => forwarded.star && defines(target, name, visiting));
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
while (queue.length) {
|
|
70
|
+
const [file, name] = queue.pop()!;
|
|
71
|
+
const key = `${file}\0${name}`;
|
|
72
|
+
if (seen.has(key) || whole.has(file)) continue;
|
|
73
|
+
seen.add(key);
|
|
74
|
+
touched.add(file);
|
|
75
|
+
const own = bindings[file];
|
|
76
|
+
if (name === "*" || !own || own.opaque || !own.sideEffectFree) { takeWhole(file); continue; }
|
|
77
|
+
if (own.locals.includes(name)) { runBody(file); continue; }
|
|
78
|
+
let found = false;
|
|
79
|
+
for (const [target, forwarded] of Object.entries(own.reexports)) {
|
|
80
|
+
if (forwarded.namespaces.includes(name)) { queue.push([target, "*"]); found = true; }
|
|
81
|
+
for (const [exported, imported] of forwarded.pairs) if (exported === name) { queue.push([target, imported]); found = true; }
|
|
82
|
+
}
|
|
83
|
+
if (!found) {
|
|
84
|
+
for (const [target, forwarded] of Object.entries(own.reexports)) {
|
|
85
|
+
if (forwarded.star && defines(target, name, new Set())) { queue.push([target, name]); found = true; }
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (!found) takeWhole(file);
|
|
89
|
+
}
|
|
90
|
+
for (const file of ran) touched.add(file);
|
|
91
|
+
return touched;
|
|
92
|
+
}
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
import { readFileSync, statSync } from "node:fs";
|
|
35
35
|
import { join, posix } from "node:path";
|
|
36
36
|
import { matchesGlob } from "./test-discovery.js";
|
|
37
|
+
import { LOCKFILE_NAMES } from "./lockfiles.js";
|
|
37
38
|
|
|
38
39
|
const MAX_READ_BYTES = 1_048_576;
|
|
39
40
|
|
|
@@ -210,7 +211,7 @@ export interface ReferenceResolution {
|
|
|
210
211
|
|
|
211
212
|
const MAX_DEPTH = 5;
|
|
212
213
|
const MAX_TRANSITIVE_READERS = 50;
|
|
213
|
-
const LOCKFILES = new Set(
|
|
214
|
+
const LOCKFILES: ReadonlySet<string> = new Set(LOCKFILE_NAMES);
|
|
214
215
|
const TEST_LIFECYCLE = ["pretest", "test", "posttest", "prepare", "preinstall", "install", "postinstall"];
|
|
215
216
|
/** Non-code files that can run something or direct what code reads: shell and interpreter scripts,
|
|
216
217
|
* and structured manifests. Only these are followed to their own readers. */
|