vigiles 41.0.0 → 41.2.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/action.yml +78 -2
- package/dist/cli-flag-check.js +11 -1
- package/dist/cli-main.js +82 -4
- package/dist/core/changed-base.d.ts +34 -0
- package/dist/core/changed-base.js +82 -0
- package/dist/core/config-schema.d.ts +9 -0
- package/dist/core/config-schema.js +7 -0
- package/dist/core/rule-proof/kits/eslint.d.ts +30 -0
- package/dist/core/rule-proof/kits/eslint.js +130 -0
- package/dist/core/rule-proof/kits/index.d.ts +7 -0
- package/dist/core/rule-proof/kits/index.js +12 -0
- package/dist/core/rule-proof/kits/ruff.d.ts +28 -0
- package/dist/core/rule-proof/kits/ruff.js +178 -0
- package/dist/core/rule-proof/node-install.d.ts +32 -0
- package/dist/core/rule-proof/node-install.js +117 -0
- package/dist/core/rule-proof/pair.d.ts +11 -0
- package/dist/core/rule-proof/pair.js +61 -0
- package/dist/core/rule-proof/port.d.ts +77 -0
- package/dist/core/rule-proof/port.js +3 -0
- package/dist/core/rule-proof/report.d.ts +11 -0
- package/dist/core/rule-proof/report.js +36 -0
- package/dist/core/rule-proof/run.d.ts +58 -0
- package/dist/core/rule-proof/run.js +260 -0
- package/dist/core/rule-proof/types.d.ts +119 -0
- package/dist/core/rule-proof/types.js +13 -0
- package/dist/core/test-reach.d.ts +99 -0
- package/dist/core/test-reach.js +725 -0
- package/dist/core/test-selection.d.ts +86 -0
- package/dist/core/test-selection.js +176 -0
- package/dist/entries/rule-proof.d.ts +18 -0
- package/dist/entries/rule-proof.js +23 -0
- package/dist/host/changed-files.io.d.ts +23 -0
- package/dist/host/changed-files.io.js +171 -0
- package/dist/host/rule-proof.io.d.ts +4 -0
- package/dist/host/rule-proof.io.js +64 -0
- package/dist/vigilesrc.schema.json +19 -0
- package/package.json +2 -1
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProvedReading = exports.PinnedLinter = void 0;
|
|
4
|
+
exports.ruleProofWith = ruleProofWith;
|
|
5
|
+
/**
|
|
6
|
+
* `experimental_ruleProof`'s three steps, over the {@link RuleProofHost} port
|
|
7
|
+
* and a set of {@link ProofKit}s. This file names no machine and no linter: the
|
|
8
|
+
* host adapter does every effect, a kit knows its linter, and the entry root
|
|
9
|
+
* hands both in.
|
|
10
|
+
*
|
|
11
|
+
* install(linter, dir) → a PinnedLinter: the repository's own linter version
|
|
12
|
+
* prove(pinned, reading, { bad, good })
|
|
13
|
+
* → a ProvedReading only when the planted violation is
|
|
14
|
+
* flagged AND its twin is not
|
|
15
|
+
* flagged(proved) → the repository files that reading flags
|
|
16
|
+
*
|
|
17
|
+
* Each step takes a value only the step before can make. So a reading cannot be
|
|
18
|
+
* run over a repository before it passed its pair, the pair cannot be half a
|
|
19
|
+
* pair, and the pair cannot be checked at one linter version and the
|
|
20
|
+
* repository run at another: `flagged` takes the ProvedReading alone, and it
|
|
21
|
+
* carries the PinnedLinter it was proved on. The classes are nominal (a
|
|
22
|
+
* `private` member), so an object of the same shape is not one.
|
|
23
|
+
*/
|
|
24
|
+
const node_path_1 = require("node:path");
|
|
25
|
+
const pair_js_1 = require("./pair.js");
|
|
26
|
+
/** A repository's own linter at its pinned version. Only `install` makes one. */
|
|
27
|
+
class PinnedLinter {
|
|
28
|
+
linter;
|
|
29
|
+
version;
|
|
30
|
+
dir;
|
|
31
|
+
run;
|
|
32
|
+
/** @internal */
|
|
33
|
+
constructor(linter, version, dir,
|
|
34
|
+
/** @internal the kit, the argv prefix that runs the linter, the settled options */
|
|
35
|
+
run) {
|
|
36
|
+
this.linter = linter;
|
|
37
|
+
this.version = version;
|
|
38
|
+
this.dir = dir;
|
|
39
|
+
this.run = run;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.PinnedLinter = PinnedLinter;
|
|
43
|
+
/** A reading that passed its planted pair on one PinnedLinter. Only `prove` makes one. */
|
|
44
|
+
class ProvedReading {
|
|
45
|
+
pinned;
|
|
46
|
+
reading;
|
|
47
|
+
/** @internal */
|
|
48
|
+
constructor(pinned, reading) {
|
|
49
|
+
this.pinned = pinned;
|
|
50
|
+
this.reading = reading;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.ProvedReading = ProvedReading;
|
|
54
|
+
const CONFIG_LOAD = "config-load";
|
|
55
|
+
const tail = (text) => text.trim().split("\n").slice(-5).join("\n");
|
|
56
|
+
const notInstalled = (stage, reason) => ({ kind: "not-installed", stage, reason });
|
|
57
|
+
const notRun = (stage, reason) => ({
|
|
58
|
+
kind: "not-run",
|
|
59
|
+
stage,
|
|
60
|
+
reason,
|
|
61
|
+
});
|
|
62
|
+
/** An ExecResult that is not a clean exit, as why nothing was installed. */
|
|
63
|
+
function installFailure(command, r) {
|
|
64
|
+
if (r.kind === "timeout")
|
|
65
|
+
return notInstalled("timeout", `${command} ran past its time limit`);
|
|
66
|
+
if (r.kind === "spawn-error")
|
|
67
|
+
return notInstalled("install", `${command} could not start: ${r.message}`);
|
|
68
|
+
if (r.kind === "killed")
|
|
69
|
+
return notInstalled("install", `${command} was killed by ${r.signal}`);
|
|
70
|
+
return r.code === 0
|
|
71
|
+
? null
|
|
72
|
+
: notInstalled("install", `${command} exited ${String(r.code)}: ${tail(r.stderr)}`);
|
|
73
|
+
}
|
|
74
|
+
/** A lint call's stdout, or why there is no report to read. */
|
|
75
|
+
function outputOf(r, reportCodes) {
|
|
76
|
+
if (r.kind === "timeout")
|
|
77
|
+
return notRun("timeout", "the linter ran past its time limit");
|
|
78
|
+
if (r.kind === "spawn-error")
|
|
79
|
+
return notRun(CONFIG_LOAD, `the linter could not start: ${r.message}`);
|
|
80
|
+
if (r.kind === "killed")
|
|
81
|
+
return notRun(CONFIG_LOAD, `the linter was killed by ${r.signal}`);
|
|
82
|
+
if (!reportCodes.includes(r.code))
|
|
83
|
+
return notRun(CONFIG_LOAD, tail(`${r.stderr}\n${r.stdout}`));
|
|
84
|
+
return { kind: "output", stdout: r.stdout };
|
|
85
|
+
}
|
|
86
|
+
const fromParse = (parse) => parse.kind === "unreadable"
|
|
87
|
+
? notRun(CONFIG_LOAD, parse.reason)
|
|
88
|
+
: { kind: "files", files: parse.files };
|
|
89
|
+
/** Files per lint call, so a large repository never meets the argv limit. */
|
|
90
|
+
const CHUNK = 200;
|
|
91
|
+
/** `a/b/c.js` → `["a", "a/b"]`. */
|
|
92
|
+
const ancestorsOf = (path) => path
|
|
93
|
+
.split("/")
|
|
94
|
+
.slice(0, -1)
|
|
95
|
+
.map((_, i, parts) => parts.slice(0, i + 1).join("/"));
|
|
96
|
+
const settle = (o) => ({
|
|
97
|
+
installTimeoutMs: 600_000,
|
|
98
|
+
lintTimeoutMs: 150_000,
|
|
99
|
+
...o,
|
|
100
|
+
});
|
|
101
|
+
/** HOME and the shared caches under `cacheDir`, plus the kit's own tools' caches. */
|
|
102
|
+
function envFor(kit, cacheDir) {
|
|
103
|
+
return {
|
|
104
|
+
HOME: node_path_1.posix.join(cacheDir, "home"),
|
|
105
|
+
XDG_CACHE_HOME: node_path_1.posix.join(cacheDir, "xdg"),
|
|
106
|
+
CI: "1",
|
|
107
|
+
...kit.env(cacheDir),
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
function install(host, kit, dir, o) {
|
|
111
|
+
const plan = kit.plan({
|
|
112
|
+
names: host.list(dir),
|
|
113
|
+
read: (name) => host.read((0, node_path_1.join)(dir, name)),
|
|
114
|
+
});
|
|
115
|
+
if (plan.kind === "none")
|
|
116
|
+
return notInstalled(plan.stage, plan.reason);
|
|
117
|
+
const [command, ...args] = plan.install;
|
|
118
|
+
const env = envFor(kit, o.cacheDir);
|
|
119
|
+
const failed = installFailure(command, host.exec(command, args, { cwd: dir, env, timeoutMs: o.installTimeoutMs }));
|
|
120
|
+
if (failed !== null)
|
|
121
|
+
return failed;
|
|
122
|
+
const version = plan.version((path) => host.read((0, node_path_1.join)(dir, path)));
|
|
123
|
+
if (version === null)
|
|
124
|
+
return notInstalled("no-linter", plan.missing);
|
|
125
|
+
const run = { kit, command: plan.command(dir), options: o };
|
|
126
|
+
return {
|
|
127
|
+
kind: "installed",
|
|
128
|
+
linter: new PinnedLinter(kit.linter, version, dir, run),
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
/** Lint `files` (relative paths) with one reading on its pinned linter. */
|
|
132
|
+
function lint(host, pinned, reading, files) {
|
|
133
|
+
const { kit, command, options } = pinned.run;
|
|
134
|
+
const places = { dir: pinned.dir, cacheDir: options.cacheDir };
|
|
135
|
+
const call = kit.invocation(reading, files, places);
|
|
136
|
+
// A repository file at the scratch path is never overwritten, nor deleted.
|
|
137
|
+
if (host.exists(call.configPath))
|
|
138
|
+
return notRun("scratch-path-taken", `${(0, node_path_1.relative)(pinned.dir, call.configPath)} already exists in the repository`);
|
|
139
|
+
host.write(call.configPath, call.configText);
|
|
140
|
+
try {
|
|
141
|
+
const [bin = "", ...prefix] = command;
|
|
142
|
+
const result = host.exec(bin, [...prefix, ...call.args], {
|
|
143
|
+
cwd: pinned.dir,
|
|
144
|
+
env: envFor(kit, options.cacheDir),
|
|
145
|
+
timeoutMs: options.lintTimeoutMs,
|
|
146
|
+
});
|
|
147
|
+
const out = outputOf(result, kit.reportCodes);
|
|
148
|
+
if (out.kind === "not-run")
|
|
149
|
+
return out;
|
|
150
|
+
return fromParse(kit.parse(out.stdout, files, reading, pinned.dir));
|
|
151
|
+
}
|
|
152
|
+
finally {
|
|
153
|
+
host.remove(call.configPath);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/** Write a planted file; return what to remove: the topmost directory it created, or itself. */
|
|
157
|
+
function plant(host, dir, file) {
|
|
158
|
+
const missing = ancestorsOf(file.path)
|
|
159
|
+
.map((a) => (0, node_path_1.join)(dir, a))
|
|
160
|
+
.find((a) => !host.exists(a));
|
|
161
|
+
host.write((0, node_path_1.join)(dir, file.path), file.text);
|
|
162
|
+
return missing ?? (0, node_path_1.join)(dir, file.path);
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Plant the files one by one, recording each write that happened, so a write
|
|
166
|
+
* that fails part-way (a path component is a file) still leaves a list of what
|
|
167
|
+
* to remove.
|
|
168
|
+
*/
|
|
169
|
+
function plantAll(host, dir, files) {
|
|
170
|
+
return files.reduce((done, file) => {
|
|
171
|
+
if (done.failed !== null)
|
|
172
|
+
return done;
|
|
173
|
+
try {
|
|
174
|
+
return {
|
|
175
|
+
created: [...done.created, plant(host, dir, file)],
|
|
176
|
+
failed: null,
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
catch (error) {
|
|
180
|
+
return {
|
|
181
|
+
created: done.created,
|
|
182
|
+
failed: notRun("pair-path-taken", `${file.path} cannot be written: ${String(error)}`),
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
}, { created: [], failed: null });
|
|
186
|
+
}
|
|
187
|
+
/** Why a pair may not be planted at all. */
|
|
188
|
+
function blocked(host, dir, reading, pair) {
|
|
189
|
+
const planted = [pair.bad, pair.good];
|
|
190
|
+
const outside = planted.find((f) => !(0, pair_js_1.inScope)(f.path, reading.scope));
|
|
191
|
+
if (outside !== undefined)
|
|
192
|
+
return notRun("pair-outside-scope", `${outside.path} is not in the reading's scope`);
|
|
193
|
+
const taken = planted.find((f) => host.exists((0, node_path_1.join)(dir, f.path)));
|
|
194
|
+
return taken === undefined
|
|
195
|
+
? null
|
|
196
|
+
: notRun("pair-path-taken", `${taken.path} already exists in the repository`);
|
|
197
|
+
}
|
|
198
|
+
/** The pair's two reports, or which planted file the linter said nothing about. */
|
|
199
|
+
function pairReports(run, pair) {
|
|
200
|
+
if (run.kind === "not-run")
|
|
201
|
+
return run;
|
|
202
|
+
const reportOf = (f) => run.files.find((r) => r.path === f.path);
|
|
203
|
+
const nothingFor = (f) => notRun(CONFIG_LOAD, `the linter reported nothing for ${f.path}`);
|
|
204
|
+
const bad = reportOf(pair.bad);
|
|
205
|
+
if (bad === undefined)
|
|
206
|
+
return nothingFor(pair.bad);
|
|
207
|
+
const good = reportOf(pair.good);
|
|
208
|
+
return good === undefined ? nothingFor(pair.good) : [bad, good];
|
|
209
|
+
}
|
|
210
|
+
const isPair = (r) => Array.isArray(r);
|
|
211
|
+
function prove(host, pinned, reading, pair) {
|
|
212
|
+
const stop = blocked(host, pinned.dir, reading, pair);
|
|
213
|
+
if (stop !== null)
|
|
214
|
+
return stop;
|
|
215
|
+
// The proof runs on a snapshot: a caller's object changed after this call
|
|
216
|
+
// cannot change the reading that passed.
|
|
217
|
+
const frozen = structuredClone(reading);
|
|
218
|
+
const planted = plantAll(host, pinned.dir, [pair.bad, pair.good]);
|
|
219
|
+
try {
|
|
220
|
+
if (planted.failed !== null)
|
|
221
|
+
return planted.failed;
|
|
222
|
+
const paths = [pair.bad.path, pair.good.path];
|
|
223
|
+
const reports = pairReports(lint(host, pinned, frozen, paths), pair);
|
|
224
|
+
if (!isPair(reports))
|
|
225
|
+
return reports;
|
|
226
|
+
const judged = (0, pair_js_1.judgePair)(...reports);
|
|
227
|
+
return judged.kind === "proved"
|
|
228
|
+
? { kind: "proved", reading: new ProvedReading(pinned, frozen) }
|
|
229
|
+
: judged;
|
|
230
|
+
}
|
|
231
|
+
finally {
|
|
232
|
+
planted.created.forEach((p) => {
|
|
233
|
+
host.remove(p);
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
function flagged(host, proved) {
|
|
238
|
+
const { pinned, reading } = proved;
|
|
239
|
+
const files = host
|
|
240
|
+
.files(pinned.dir, reading.scope.files)
|
|
241
|
+
.filter((p) => (0, pair_js_1.inScope)(p, reading.scope))
|
|
242
|
+
.sort((a, b) => a.localeCompare(b));
|
|
243
|
+
const chunks = Array.from({ length: Math.ceil(files.length / CHUNK) }, (_, i) => files.slice(i * CHUNK, (i + 1) * CHUNK));
|
|
244
|
+
const results = chunks.map((chunk) => lint(host, pinned, reading, chunk));
|
|
245
|
+
const stopped = results.find((r) => r.kind === "not-run");
|
|
246
|
+
const reports = results.flatMap((r) => (r.kind === "files" ? r.files : []));
|
|
247
|
+
return stopped ?? { kind: "ran", ...(0, pair_js_1.summarize)(reports) };
|
|
248
|
+
}
|
|
249
|
+
/** The three steps over one host and one kit set. */
|
|
250
|
+
function ruleProofWith(host, kits) {
|
|
251
|
+
return {
|
|
252
|
+
install: (linter, dir, options) => install(host, kits[linter], dir, settle(options)),
|
|
253
|
+
prove: (pinned,
|
|
254
|
+
// The reading's type comes from the pinned linter, never the other way:
|
|
255
|
+
// a reading of another linter is a type error here.
|
|
256
|
+
reading, pair) => prove(host, pinned, reading, pair),
|
|
257
|
+
flagged: (proved) => flagged(host, proved),
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
//# sourceMappingURL=run.js.map
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The vocabulary of `experimental_ruleProof`, shared by the steps, the port and
|
|
3
|
+
* every linter kit. It names no linter: a kit adds its own reading fields on top
|
|
4
|
+
* of {@link BaseReading}.
|
|
5
|
+
*
|
|
6
|
+
* Two lessons from hand-written copies of this, kept as types rather than notes:
|
|
7
|
+
* a config that did not load printed nothing and was scored "no diagnostic", so
|
|
8
|
+
* an unreadable report is its own case and never an empty list; and a file that
|
|
9
|
+
* did not parse is not a clean file, so a per-file report has three kinds.
|
|
10
|
+
*/
|
|
11
|
+
/** Where a reading applies, as patterns relative to the repository root. */
|
|
12
|
+
export interface ReadingScope {
|
|
13
|
+
readonly files: readonly string[];
|
|
14
|
+
readonly ignores: readonly string[];
|
|
15
|
+
}
|
|
16
|
+
/** What every reading has. A kit's reading adds the linter's own options. */
|
|
17
|
+
export interface BaseReading {
|
|
18
|
+
/** The kit's name, as the kit set is keyed. */
|
|
19
|
+
readonly linter: string;
|
|
20
|
+
/** The rule as the linter spells it. */
|
|
21
|
+
readonly rule: string;
|
|
22
|
+
readonly scope: ReadingScope;
|
|
23
|
+
}
|
|
24
|
+
/** What one lint run said about one file. */
|
|
25
|
+
export type FileReport = {
|
|
26
|
+
readonly path: string;
|
|
27
|
+
readonly kind: "linted";
|
|
28
|
+
readonly hits: number;
|
|
29
|
+
} | {
|
|
30
|
+
readonly path: string;
|
|
31
|
+
readonly kind: "parse-error";
|
|
32
|
+
readonly message: string;
|
|
33
|
+
} | {
|
|
34
|
+
readonly path: string;
|
|
35
|
+
readonly kind: "ignored";
|
|
36
|
+
};
|
|
37
|
+
/** A linter's output read as per-file facts, or why it could not be. */
|
|
38
|
+
export type LintParse = {
|
|
39
|
+
readonly kind: "parsed";
|
|
40
|
+
readonly files: readonly FileReport[];
|
|
41
|
+
} | {
|
|
42
|
+
readonly kind: "unreadable";
|
|
43
|
+
readonly reason: string;
|
|
44
|
+
};
|
|
45
|
+
/** Why a reading or a run produced no verdict. */
|
|
46
|
+
export type NotRunStage = "pair-outside-scope" | "pair-path-taken" | "scratch-path-taken" | "pair-ignored" | "parse" | "config-load" | "timeout";
|
|
47
|
+
/** No verdict, and why. */
|
|
48
|
+
export interface NotRun {
|
|
49
|
+
readonly kind: "not-run";
|
|
50
|
+
readonly stage: NotRunStage;
|
|
51
|
+
readonly reason: string;
|
|
52
|
+
}
|
|
53
|
+
/** The verdict on a planted pair, before the proved reading is bound to its linter. */
|
|
54
|
+
export type PairVerdict = {
|
|
55
|
+
readonly kind: "proved";
|
|
56
|
+
} | {
|
|
57
|
+
readonly kind: "not-proved";
|
|
58
|
+
readonly badHits: number;
|
|
59
|
+
readonly goodHits: number;
|
|
60
|
+
} | NotRun;
|
|
61
|
+
/** Why there is no pinned linter. */
|
|
62
|
+
export interface NotInstalled {
|
|
63
|
+
readonly kind: "not-installed";
|
|
64
|
+
readonly stage: "no-lockfile" | "no-pin" | "install" | "timeout" | "no-linter";
|
|
65
|
+
readonly reason: string;
|
|
66
|
+
}
|
|
67
|
+
/** A file planted for the proof: a path relative to the repository and its text. */
|
|
68
|
+
export interface PlantedFile {
|
|
69
|
+
readonly path: string;
|
|
70
|
+
readonly text: string;
|
|
71
|
+
}
|
|
72
|
+
/** The violation and its twin. Both are required: one direction proves nothing. */
|
|
73
|
+
export interface PlantedPair {
|
|
74
|
+
readonly bad: PlantedFile;
|
|
75
|
+
readonly good: PlantedFile;
|
|
76
|
+
}
|
|
77
|
+
/** The repository files a proved reading flags, and the ones it could not judge. */
|
|
78
|
+
export interface Flagged {
|
|
79
|
+
/** Files the linter parsed, flagged or not. */
|
|
80
|
+
readonly linted: number;
|
|
81
|
+
readonly flagged: readonly string[];
|
|
82
|
+
readonly parseErrors: readonly string[];
|
|
83
|
+
readonly ignored: readonly string[];
|
|
84
|
+
}
|
|
85
|
+
/** What a proved reading flags in the repository. */
|
|
86
|
+
export type FlaggedRun = ({
|
|
87
|
+
readonly kind: "ran";
|
|
88
|
+
} & Flagged) | NotRun;
|
|
89
|
+
/** Where install keeps every cache, and how long each step may take. */
|
|
90
|
+
export interface InstallOptions {
|
|
91
|
+
/** A directory the caller owns; HOME and every package-manager cache go here. */
|
|
92
|
+
readonly cacheDir: string;
|
|
93
|
+
/** Default 600 s. */
|
|
94
|
+
readonly installTimeoutMs?: number;
|
|
95
|
+
/** Per lint call, default 150 s. */
|
|
96
|
+
readonly lintTimeoutMs?: number;
|
|
97
|
+
}
|
|
98
|
+
/** What a command did. A timeout and a binary that never started are not exit codes. */
|
|
99
|
+
export type ExecResult = {
|
|
100
|
+
readonly kind: "exited";
|
|
101
|
+
readonly code: number;
|
|
102
|
+
readonly stdout: string;
|
|
103
|
+
readonly stderr: string;
|
|
104
|
+
} | {
|
|
105
|
+
readonly kind: "timeout";
|
|
106
|
+
} | {
|
|
107
|
+
readonly kind: "killed";
|
|
108
|
+
readonly signal: string;
|
|
109
|
+
} | {
|
|
110
|
+
readonly kind: "spawn-error";
|
|
111
|
+
readonly message: string;
|
|
112
|
+
};
|
|
113
|
+
/** Options for one command. `env` is added to the inherited environment. */
|
|
114
|
+
export interface ExecOptions {
|
|
115
|
+
readonly cwd: string;
|
|
116
|
+
readonly env: Readonly<Record<string, string>>;
|
|
117
|
+
readonly timeoutMs: number;
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The vocabulary of `experimental_ruleProof`, shared by the steps, the port and
|
|
4
|
+
* every linter kit. It names no linter: a kit adds its own reading fields on top
|
|
5
|
+
* of {@link BaseReading}.
|
|
6
|
+
*
|
|
7
|
+
* Two lessons from hand-written copies of this, kept as types rather than notes:
|
|
8
|
+
* a config that did not load printed nothing and was scored "no diagnostic", so
|
|
9
|
+
* an unreadable report is its own case and never an empty list; and a file that
|
|
10
|
+
* did not parse is not a clean file, so a per-file report has three kinds.
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What one harness file can REACH — the files whose change can change its
|
|
3
|
+
* outcome — for `vigiles test --changed` (`./test-selection.ts` decides with it).
|
|
4
|
+
*
|
|
5
|
+
* Three edges, followed from the harness through every code file it reaches:
|
|
6
|
+
*
|
|
7
|
+
* 1. IMPORTS — relative `import`/`export … from`/`require`/literal `import()`,
|
|
8
|
+
* found by TypeScript's `preProcessFile` and resolved by `resolveModuleName`.
|
|
9
|
+
* 2. EFFECT CALLS — a call that runs, reads or copies a file: the `spawn`/`exec`
|
|
10
|
+
* family (the command and its argv array), `readFile*`/`createReadStream`,
|
|
11
|
+
* `cp*`/`copyFile*`, and `runHook(command)`. Only CALL ARGUMENTS count: a path
|
|
12
|
+
* inside an object literal (`tool_input.file_path` in a synthetic hook event)
|
|
13
|
+
* is a fixture, never a dependency. A script the call runs is followed like
|
|
14
|
+
* an import, so its own imports and calls count too.
|
|
15
|
+
* 3. BUILD OUTPUT → SOURCE — a path inside the tsconfig's `outDir` is read as its
|
|
16
|
+
* `rootDir` counterpart (`dist/x.js` → `src/x.ts`), so a harness that imports
|
|
17
|
+
* the build is reached by a change to the source behind it.
|
|
18
|
+
*
|
|
19
|
+
* An effect path is EVALUATED, not matched as text: string literals, `+` and
|
|
20
|
+
* template literals, `path.join`/`resolve`/`dirname`, `__dirname`,
|
|
21
|
+
* `import.meta.{url,dirname,filename}`, `new URL(x, import.meta.url)`,
|
|
22
|
+
* `fileURLToPath`, `process.cwd()`, and a `const` bound to any of those. A path
|
|
23
|
+
* whose start is known and whose end is not (`join(ROOT, "data", name)`) is a
|
|
24
|
+
* PREFIX: any change under `data/` reaches the harness. A path with nothing
|
|
25
|
+
* known is UNRESOLVED and reported as such; what to do with it is the
|
|
26
|
+
* selector's decision, not this module's.
|
|
27
|
+
*
|
|
28
|
+
* Pure: every read goes through {@link SourceHost}.
|
|
29
|
+
*/
|
|
30
|
+
import ts from "typescript";
|
|
31
|
+
/** The reads reach needs. Paths are absolute. */
|
|
32
|
+
export interface SourceHost {
|
|
33
|
+
/** A file's text, or null when it is absent or unreadable. */
|
|
34
|
+
readonly read: (path: string) => string | null;
|
|
35
|
+
readonly isFile: (path: string) => boolean;
|
|
36
|
+
/** tsc's own directory walk (`ts.sys.readDirectory`), for a tsconfig's inputs. */
|
|
37
|
+
readonly readDirectory: ts.ParseConfigHost["readDirectory"];
|
|
38
|
+
/** The real path behind a symlink — a workspace package linked into node_modules. */
|
|
39
|
+
readonly realpath: (path: string) => string;
|
|
40
|
+
}
|
|
41
|
+
/** What `<cwd>/tsconfig.json` says, read by TypeScript itself (`extends` included). */
|
|
42
|
+
export interface Project {
|
|
43
|
+
/** Where the build writes and the source it writes from; undefined with no `outDir`. */
|
|
44
|
+
readonly build: OutputLayout | undefined;
|
|
45
|
+
/** Its compiler options, so `paths`/`baseUrl` apply when a bare specifier is resolved. */
|
|
46
|
+
readonly options: Readonly<ts.CompilerOptions>;
|
|
47
|
+
}
|
|
48
|
+
/** Where a TypeScript build writes, and the source it writes from. Absolute. */
|
|
49
|
+
export interface OutputLayout {
|
|
50
|
+
readonly outDir: string;
|
|
51
|
+
readonly rootDir: string;
|
|
52
|
+
}
|
|
53
|
+
/** A file or folder an effect call names, cwd-relative and POSIX. */
|
|
54
|
+
export interface EffectDep {
|
|
55
|
+
readonly path: string;
|
|
56
|
+
/** True: any changed path STARTING with `path` (an unknown tail). */
|
|
57
|
+
readonly prefix: boolean;
|
|
58
|
+
readonly call: string;
|
|
59
|
+
}
|
|
60
|
+
/** An effect call whose path argument could not be evaluated at all. */
|
|
61
|
+
export interface Unresolved {
|
|
62
|
+
readonly call: string;
|
|
63
|
+
readonly file: string;
|
|
64
|
+
readonly line: number;
|
|
65
|
+
}
|
|
66
|
+
export interface Reach {
|
|
67
|
+
/** Code and data files reached by import, cwd-relative and POSIX. */
|
|
68
|
+
readonly imports: ReadonlySet<string>;
|
|
69
|
+
readonly effects: readonly EffectDep[];
|
|
70
|
+
readonly unresolved: readonly Unresolved[];
|
|
71
|
+
}
|
|
72
|
+
export type ReachHit = {
|
|
73
|
+
readonly kind: "import";
|
|
74
|
+
} | {
|
|
75
|
+
readonly kind: "reads";
|
|
76
|
+
readonly call: string;
|
|
77
|
+
};
|
|
78
|
+
/** Does a change to `changed` (cwd-relative) reach through `r`, and how? */
|
|
79
|
+
export declare function reachMatch(r: Reach, changed: string): ReachHit | undefined;
|
|
80
|
+
/**
|
|
81
|
+
* `<cwd>/tsconfig.json` as TypeScript reads it. No tsconfig → undefined. With
|
|
82
|
+
* no `outDir`, `build` is undefined and paths are taken as they are; an unset
|
|
83
|
+
* `rootDir` is tsc's own default (see {@link commonSourceDir}).
|
|
84
|
+
*/
|
|
85
|
+
export declare function readProject(cwd: string, host: SourceHost): Project | undefined;
|
|
86
|
+
/** `relative`, in POSIX separators. */
|
|
87
|
+
export declare function posixRelative(from: string, to: string): string;
|
|
88
|
+
export interface ReachSetup {
|
|
89
|
+
readonly cwd: string;
|
|
90
|
+
readonly host: SourceHost;
|
|
91
|
+
/** `readProject(cwd, host)`, read once per run. */
|
|
92
|
+
readonly project: Project | undefined;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* What each harness file reaches, for one run. The resolution cache is shared
|
|
96
|
+
* by every file the returned function is asked about.
|
|
97
|
+
*/
|
|
98
|
+
export declare function reachFor(setup: ReachSetup): (file: string) => Reach;
|
|
99
|
+
//# sourceMappingURL=test-reach.d.ts.map
|