@ref0/workspace 0.12.0 → 0.13.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/README.md +25 -0
- package/dist/review-record/review-record.mjs +112 -20
- package/dist/review-record/settings.d.mts +11 -0
- package/dist/review-record/settings.mjs +6 -2
- package/dist/types/cache.mjs +2 -2
- package/dist/types/inputs.mjs +23 -16
- package/package.json +6 -2
- package/tsconfig/base.json +20 -0
- package/tsconfig/bundler.json +8 -0
- package/tsconfig/node-next.json +8 -0
package/README.md
CHANGED
|
@@ -131,6 +131,29 @@ WSL2. `taskSources({ root, packages, apps })` gives `builtFrom(import.meta.url,
|
|
|
131
131
|
the config's package and every workspace package it depends on, and `readsAll(command)`, keyed by
|
|
132
132
|
every file. Each puts `env REF0_SOURCES=<hash>` before each command `&&` joins.
|
|
133
133
|
|
|
134
|
+
## TypeScript
|
|
135
|
+
|
|
136
|
+
A repo's base `tsconfig` extends one preset, so an option the team adopts reaches every repo in the
|
|
137
|
+
release that adds it:
|
|
138
|
+
|
|
139
|
+
| Preset | What it holds |
|
|
140
|
+
| ----------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
141
|
+
| `@ref0/workspace/tsconfig/base.json` | The strict options: `strict`, `exactOptionalPropertyTypes`, `noUncheckedIndexedAccess`, `verbatimModuleSyntax`, `isolatedModules`, the unused, fallthrough, return and override checks, and ES2023 |
|
|
142
|
+
| `@ref0/workspace/tsconfig/bundler.json` | The base, with `module: ESNext` and `moduleResolution: Bundler`, for code a bundler builds |
|
|
143
|
+
| `@ref0/workspace/tsconfig/node-next.json` | The base, with `module` and `moduleResolution` `NodeNext`, for code Node runs as it is |
|
|
144
|
+
|
|
145
|
+
```jsonc
|
|
146
|
+
{
|
|
147
|
+
"extends": "@ref0/workspace/tsconfig/bundler.json",
|
|
148
|
+
"compilerOptions": {
|
|
149
|
+
"customConditions": ["@ref0/source"],
|
|
150
|
+
"plugins": [{ "name": "@effect/language-service" }],
|
|
151
|
+
},
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
The repo keeps what's its own: `lib`, `types`, `paths`, `customConditions`, `noEmit`, its includes and references, and the Effect language service's options, since a config's `plugins` replaces the one it extends.
|
|
156
|
+
|
|
134
157
|
## Checks
|
|
135
158
|
|
|
136
159
|
`ref0-workspace <check>`, from anywhere in the repo's checkout:
|
|
@@ -259,6 +282,8 @@ began with, and the file holds no other:
|
|
|
259
282
|
| `testHelpers` | Shared test helpers, test code too whether `testCode` names them or not, whose change puts a pull request at medium (`*/testing/*`) |
|
|
260
283
|
| `benchedPaths` | The bench list's path, whose `<case> <glob>` lines tie source to the bench cases that time it (none: no bench) |
|
|
261
284
|
| `benchRuns` | Files under a `testing/` folder that a bench case runs all the same (none) |
|
|
285
|
+
| `sizeUncounted` | Generated files, as globs, whose lines the size floor leaves out, though the always-review list and the test code rules still read them; a list replaces the default, so name the lock in it too (`pnpm-lock.yaml`) |
|
|
286
|
+
| `botBranches` | Head branches, as globs, from which a bot's pull request in the repo itself, never a fork's, counts as from someone who may push, as a release's from `release/next` does, so a low one needs no session (none) |
|
|
262
287
|
|
|
263
288
|
```json
|
|
264
289
|
{ "benchedPaths": "bench/benched-paths.txt", "lowTierLines": 200 }
|
|
@@ -47,8 +47,9 @@ import { env } from "node:process";
|
|
|
47
47
|
*
|
|
48
48
|
* A bot's comment doesn't count, and a session counts only from someone who may push to the repo,
|
|
49
49
|
* since anyone may comment once it's public. A pull request whose author may not push needs a
|
|
50
|
-
* session at any tier, as review.md says
|
|
51
|
-
* `
|
|
50
|
+
* session at any tier, as review.md says, unless it's a bot's from a branch the base's `botBranches`
|
|
51
|
+
* names in the repo itself. It reads GitHub with `gh`, and the head's history with `git` from the
|
|
52
|
+
* checkout that holds it, whole.
|
|
52
53
|
*/
|
|
53
54
|
/** Net lines of production source from which a change is large and needs a code quality reviewer. */
|
|
54
55
|
const largeChange = 1e3;
|
|
@@ -233,10 +234,11 @@ const testChangesOf = (changes, settings) => {
|
|
|
233
234
|
lines: files.reduce((sum, file) => sum + file.lines, 0)
|
|
234
235
|
};
|
|
235
236
|
};
|
|
236
|
-
/**
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
237
|
+
/**
|
|
238
|
+
* A pull request's changed lines, additions plus deletions, as the tier limits count them, without
|
|
239
|
+
* the generated files the settings' `sizeUncounted` names.
|
|
240
|
+
*/
|
|
241
|
+
const changedLines = (changes, settings = defaults) => changes.filter((change) => !matchesAny(settings.sizeUncounted)(change.filename)).reduce((sum, change) => sum + change.additions + change.deletions, 0);
|
|
240
242
|
/** A patch's hunks, from its first `@@` line, past any header a git diff prints. */
|
|
241
243
|
const hunksOf = (patch) => {
|
|
242
244
|
const hunks = [];
|
|
@@ -348,8 +350,8 @@ const floorOf = (changes, list, net = 0, settings = defaults) => {
|
|
|
348
350
|
const { lowTierLines, highTierLines } = settings;
|
|
349
351
|
const isProduction = (path) => isProductionSource(path, settings);
|
|
350
352
|
const tierAt = list === void 0 ? (path) => isProduction(path) ? "high" : void 0 : tierOf(list);
|
|
351
|
-
const lines = changedLines(changes);
|
|
352
|
-
const counted = changes.flatMap((change) =>
|
|
353
|
+
const lines = changedLines(changes, settings);
|
|
354
|
+
const counted = changes.flatMap((change) => matchesAny(settings.sizeUncounted)(change.filename) ? [] : [change.filename]);
|
|
353
355
|
const reasons = [];
|
|
354
356
|
if (net >= 1e3) reasons.push({
|
|
355
357
|
tier: "high",
|
|
@@ -440,6 +442,70 @@ const linkOf = (token) => {
|
|
|
440
442
|
*/
|
|
441
443
|
const holdsReading = (line) => /\blocal\b/i.test(line) || line.split(/[\s|]+/).some((token) => runLink.test(linkOf(token)));
|
|
442
444
|
/**
|
|
445
|
+
* A batch line's ending, after its case's name: the Coordinator's rule that a case with no local
|
|
446
|
+
* form goes unbenched on a pull request and is read in ci-bench's batch run on main.
|
|
447
|
+
*/
|
|
448
|
+
const batchSkip = ": not run, read in the batch run on main (Coordinator)";
|
|
449
|
+
/** A batch line, whole: a case's name, in backticks or not, as a list item or not, then `batchSkip`. */
|
|
450
|
+
const batchLine = new RegExp(`^(?:[-*+] )?(\`?)([\\w.-]+)\\1${batchSkip.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}$`);
|
|
451
|
+
/** The case a line leaves to the batch run on main, as `batchLine` reads it, or `undefined`. */
|
|
452
|
+
const batchCaseOf = (line) => batchLine.exec(line.trim())?.[2];
|
|
453
|
+
/** The columns a line is indented by, a tab to the next stop of 4, as CommonMark counts them. */
|
|
454
|
+
const indentOf = (line) => {
|
|
455
|
+
let column = 0;
|
|
456
|
+
for (const char of line) if (char === " ") column += 1;
|
|
457
|
+
else if (char === " ") column += 4 - column % 4;
|
|
458
|
+
else break;
|
|
459
|
+
return column;
|
|
460
|
+
};
|
|
461
|
+
/** A list item's marker, and the spaces after it: its length from the line's indent is its content's. */
|
|
462
|
+
const listMarker = /^(?:[-*+]|\d{1,9}[.)])(?: +|$)/;
|
|
463
|
+
/** Text with its HTML comments and fenced code blocks taken out, as GitHub shows neither as prose. */
|
|
464
|
+
const withoutHidden = (text) => {
|
|
465
|
+
const shown = [];
|
|
466
|
+
let from = 0;
|
|
467
|
+
let at = 0;
|
|
468
|
+
while (at < text.length) {
|
|
469
|
+
fenceOpen.lastIndex = at;
|
|
470
|
+
const fence = at === 0 || text[at - 1] === "\n" ? fenceOpen.exec(text) : null;
|
|
471
|
+
const hidden = fence !== null ? pastFence(text, fenceOpen.lastIndex, fence[1] ?? "```") : text.startsWith("<!--", at) ? text.indexOf("-->", at + 4) : void 0;
|
|
472
|
+
if (hidden === void 0) {
|
|
473
|
+
at += 1;
|
|
474
|
+
continue;
|
|
475
|
+
}
|
|
476
|
+
shown.push(text.slice(from, at));
|
|
477
|
+
if (hidden === -1) return shown.join("");
|
|
478
|
+
at = fence !== null ? hidden : hidden + 3;
|
|
479
|
+
from = at;
|
|
480
|
+
}
|
|
481
|
+
shown.push(text.slice(from));
|
|
482
|
+
return shown.join("");
|
|
483
|
+
};
|
|
484
|
+
/**
|
|
485
|
+
* The lines of a body's fold that GitHub shows as prose: none inside an HTML comment or a code
|
|
486
|
+
* block, fenced or indented, so an example of a line never reads as the line itself. An indented
|
|
487
|
+
* block is 4 columns past the list item it's in, or past the margin outside any, after a blank line
|
|
488
|
+
* or another of its lines: a list item's own paragraphs, at 2, are prose.
|
|
489
|
+
*/
|
|
490
|
+
const shownLines = (fold) => {
|
|
491
|
+
let content = 0;
|
|
492
|
+
let blank = true;
|
|
493
|
+
let code = false;
|
|
494
|
+
return withoutHidden(fold).split("\n").filter((line) => {
|
|
495
|
+
if (line.trim() === "") {
|
|
496
|
+
blank = true;
|
|
497
|
+
return false;
|
|
498
|
+
}
|
|
499
|
+
const indent = indentOf(line);
|
|
500
|
+
code = indent >= content + 4 && (blank || code);
|
|
501
|
+
const marker = code ? null : listMarker.exec(line.trimStart());
|
|
502
|
+
if (marker !== null) content = indent + marker[0].length;
|
|
503
|
+
else if (!code && blank && indent < content) content = 0;
|
|
504
|
+
blank = false;
|
|
505
|
+
return !code;
|
|
506
|
+
});
|
|
507
|
+
};
|
|
508
|
+
/**
|
|
443
509
|
* Where the body's "Bench and cost" fold opens: a `<details>` tag whose summary reads so, in bold
|
|
444
510
|
* or not. A tag's name ends at `>` or HTML's own whitespace, so `<details-fake>` or a non-breaking
|
|
445
511
|
* space opens no fold.
|
|
@@ -561,20 +627,24 @@ const provenUnchanged = (line, record, lookup) => {
|
|
|
561
627
|
/**
|
|
562
628
|
* The bench cases the base's `benched-paths.txt` ties the changes to, and why the body's "Bench and
|
|
563
629
|
* cost" fold doesn't hold a reading for each: a line there that names the case whole and holds a
|
|
564
|
-
* run's link or the word local,
|
|
565
|
-
*
|
|
630
|
+
* run's link or the word local, a "bundle unchanged" line a run proves, `provenUnchanged`, or the
|
|
631
|
+
* case's batch line, `batchCaseOf`, each of the fold's lines GitHub shows as prose, `shownLines`.
|
|
632
|
+
* `batched` names the cases a batch line carries and no reading does, so the batch run can be
|
|
633
|
+
* checked against what pull requests left to it. A base with no list ties none.
|
|
566
634
|
*/
|
|
567
635
|
const benchReadings = (body, record, settings) => {
|
|
568
636
|
if (record.benched === void 0) return {
|
|
569
637
|
cases: [],
|
|
638
|
+
batched: [],
|
|
570
639
|
errors: []
|
|
571
640
|
};
|
|
572
641
|
const { cases, files } = benchedCases(record.benched, record.changes, settings);
|
|
573
|
-
const lines = benchFold(body)
|
|
642
|
+
const lines = shownLines(benchFold(body));
|
|
574
643
|
const claims = lines.filter((line) => unchangedClaim.test(line));
|
|
575
644
|
const linked = new Set(claims.flatMap(runsOf));
|
|
576
645
|
if (linked.size > 30) return {
|
|
577
646
|
cases,
|
|
647
|
+
batched: [],
|
|
578
648
|
errors: [`Its body's "bundle unchanged" lines link ${linked.size} runs, and review-record reads at most 30: link the one run that benched the set, ci-bench's \`pr\` dispatch.`]
|
|
579
649
|
};
|
|
580
650
|
const runs = /* @__PURE__ */ new Map();
|
|
@@ -584,10 +654,14 @@ const benchReadings = (body, record, settings) => {
|
|
|
584
654
|
};
|
|
585
655
|
const unproven = claims.filter((line) => !provenUnchanged(line, record, lookup));
|
|
586
656
|
const readings = lines.filter((line) => (unchangedClaim.test(line) || holdsReading(line)) && !unproven.includes(line));
|
|
587
|
-
const
|
|
657
|
+
const carried = new Set(lines.flatMap((line) => batchCaseOf(line) ?? []));
|
|
658
|
+
const read = (name) => readings.some((line) => names(line, name));
|
|
659
|
+
const batched = cases.filter((name) => carried.has(name) && !read(name));
|
|
660
|
+
const missing = cases.filter((name) => !carried.has(name) && !read(name));
|
|
588
661
|
return {
|
|
589
662
|
cases,
|
|
590
|
-
|
|
663
|
+
batched,
|
|
664
|
+
errors: [...unproven.map((line) => `Its body's "${line.trim()}" says a bundle is unchanged, and no run it links is ci-bench's on main with a passed "${unchangedJob(unchangedClaim.exec(line)?.[1] ?? "", record.pull ?? 0, record.head)}" job: link the ci-bench run of this pull request that wrote it, \`pr\`'s.`), ...missing.length === 0 ? [] : [`It changes benched paths, ${some(files)}, so its body's "Bench and cost" fold holds a reading for each case ${settings.benchedPaths ?? "the bench list"} ties them to, and holds none for ${some(missing, 5)}. Add a line for each that names the case with its ci-bench run's link, labelled local for a local pass, or as \`<case>${batchSkip}\`, as .agents/repo/review.md says.`]]
|
|
591
665
|
};
|
|
592
666
|
};
|
|
593
667
|
/**
|
|
@@ -732,7 +806,8 @@ const verdict = (record) => {
|
|
|
732
806
|
const { files: tests } = testChangesOf(record.changes, settings);
|
|
733
807
|
const missingBreaks = unbroken(body, record.changes, settings);
|
|
734
808
|
const bench = benchReadings(body, record, settings);
|
|
735
|
-
const
|
|
809
|
+
const batched = bench.batched.length > 0 ? `; batch: ${bench.batched.length} cases, ${some(bench.batched, 10)}` : "";
|
|
810
|
+
const benched = bench.cases.length > 0 ? `, with a bench reading for each of ${bench.cases.length} cases${batched}` : "";
|
|
736
811
|
const lowBreaks = missingBreaks.length > 0 ? [`This low-tier pull request changes test code with no break on record for ${some(missingBreaks)}. Add a "Break:" line to the body for each, naming its file, what you broke in the code and that the test failed, as test-audit's authoring gate asks.`] : [];
|
|
737
812
|
if (tier === "low" && record.outsider !== true) {
|
|
738
813
|
const errors = [...lowBreaks, ...bench.errors];
|
|
@@ -1162,6 +1237,14 @@ const countedComments = (github, repo, pull) => {
|
|
|
1162
1237
|
};
|
|
1163
1238
|
/** The reason a session comment from someone who may not push doesn't count, when there is one. */
|
|
1164
1239
|
const uncountedNote = (record) => record.uncounted === void 0 || record.uncounted.length === 0 ? "" : `: the sessions from ${record.uncounted.join(", ")} don't count, since they may not push to the repo`;
|
|
1240
|
+
/** The jq filter that reads the rest of a pull request's `PullAuthor`, beside its login. */
|
|
1241
|
+
const headFilter = "{type: .user.type, branch: .head.ref, from: (.head.repo.full_name // \"\")} | tojson";
|
|
1242
|
+
/**
|
|
1243
|
+
* Whether a pull request is a bot's from a branch the settings' `botBranches` names, in `repo`
|
|
1244
|
+
* itself and never a fork: only the repo's own workflows open one there, as a release's does, so its
|
|
1245
|
+
* author counts as one who may push. A bot's on any other branch is an outsider's.
|
|
1246
|
+
*/
|
|
1247
|
+
const fromBotBranch = (author, repo, settings) => author.type === "Bot" && author.from.toLowerCase() === repo.toLowerCase() && matchesAny(settings.botBranches)(author.branch);
|
|
1165
1248
|
/** A file at a commit, through GitHub's contents API, or `undefined` when the commit has none. */
|
|
1166
1249
|
const contentsAt = (github, repo, path, ref) => github([
|
|
1167
1250
|
"-H",
|
|
@@ -1177,6 +1260,19 @@ const contentsAt = (github, repo, path, ref) => github([
|
|
|
1177
1260
|
const recordOf = (github, git, repo, pull, base, head) => {
|
|
1178
1261
|
const settings = settingsFrom(contentsAt(github, repo, settingsPath, base));
|
|
1179
1262
|
const isTest = (path) => isTestCode(path, settings);
|
|
1263
|
+
const login = found(github, [
|
|
1264
|
+
`repos/${repo}/pulls/${pull}`,
|
|
1265
|
+
"--jq",
|
|
1266
|
+
".user.login"
|
|
1267
|
+
]).trim();
|
|
1268
|
+
const fromBot = () => settings.botBranches.length > 0 && fromBotBranch({
|
|
1269
|
+
login,
|
|
1270
|
+
...JSON.parse(found(github, [
|
|
1271
|
+
`repos/${repo}/pulls/${pull}`,
|
|
1272
|
+
"--jq",
|
|
1273
|
+
headFilter
|
|
1274
|
+
]))
|
|
1275
|
+
}, repo, settings);
|
|
1180
1276
|
return {
|
|
1181
1277
|
settings,
|
|
1182
1278
|
changedFiles: Number(found(github, [
|
|
@@ -1185,11 +1281,7 @@ const recordOf = (github, git, repo, pull, base, head) => {
|
|
|
1185
1281
|
".changed_files"
|
|
1186
1282
|
])),
|
|
1187
1283
|
...countedComments(github, repo, pull),
|
|
1188
|
-
outsider: !mayPush(github, repo,
|
|
1189
|
-
`repos/${repo}/pulls/${pull}`,
|
|
1190
|
-
"--jq",
|
|
1191
|
-
".user.login"
|
|
1192
|
-
]).trim()),
|
|
1284
|
+
outsider: !mayPush(github, repo, login) && !fromBot(),
|
|
1193
1285
|
body: found(github, [
|
|
1194
1286
|
`repos/${repo}/pulls/${pull}`,
|
|
1195
1287
|
"--jq",
|
|
@@ -1253,4 +1345,4 @@ const branchRecordOf = (git, comments = [], body = "") => {
|
|
|
1253
1345
|
lines: (path) => linesAt(git, head, path)
|
|
1254
1346
|
};
|
|
1255
1347
|
};
|
|
1256
|
-
export { benchRunOf, benchWorkflow, benchedCases, branchRecordOf, changedLines, changesOf, countedComments, coveredBy, floorOf, gh, gitIn, githubFileCap, historyOf, isProductionSource, isTestCode, largeChange, netProductionLines, pullChangesOf, readSession, recordFloor, recordOf, testChangesOf, testRisks, testsOnly, tierOf, tiers, unchangedJob, verdict };
|
|
1348
|
+
export { benchRunOf, benchWorkflow, benchedCases, branchRecordOf, changedLines, changesOf, countedComments, coveredBy, floorOf, fromBotBranch, gh, gitIn, githubFileCap, historyOf, isProductionSource, isTestCode, largeChange, netProductionLines, pullChangesOf, readSession, recordFloor, recordOf, testChangesOf, testRisks, testsOnly, tierOf, tiers, unchangedJob, verdict };
|
|
@@ -35,6 +35,17 @@ export interface Settings {
|
|
|
35
35
|
readonly benchedPaths: string | undefined;
|
|
36
36
|
/** Files under a `testing/` folder that a bench case runs all the same, so a change to one owes its readings. */
|
|
37
37
|
readonly benchRuns: ReadonlyArray<string>;
|
|
38
|
+
/**
|
|
39
|
+
* Generated files, as globs, whose lines a pull request's size leaves out, though the
|
|
40
|
+
* always-review list and the test code rules still read them.
|
|
41
|
+
*/
|
|
42
|
+
readonly sizeUncounted: ReadonlyArray<string>;
|
|
43
|
+
/**
|
|
44
|
+
* Head branches, as globs, from which a bot's pull request in the repo itself, never a fork's,
|
|
45
|
+
* counts as one from someone who may push: only the repo's own workflows open one there, as a
|
|
46
|
+
* release's does.
|
|
47
|
+
*/
|
|
48
|
+
readonly botBranches: ReadonlyArray<string>;
|
|
38
49
|
}
|
|
39
50
|
/** `settingsOf`'s settings, which throws on a problem, as the gate does on anything it can't read. */
|
|
40
51
|
export declare const settingsFrom: (text: string | undefined) => Settings;
|
|
@@ -26,7 +26,9 @@ const File = Schema.Struct({
|
|
|
26
26
|
testCode: Schema.optionalKey(Globs),
|
|
27
27
|
testHelpers: Schema.optionalKey(Globs),
|
|
28
28
|
benchedPaths: Schema.optionalKey(Schema.String),
|
|
29
|
-
benchRuns: Schema.optionalKey(Schema.Array(Schema.String))
|
|
29
|
+
benchRuns: Schema.optionalKey(Schema.Array(Schema.String)),
|
|
30
|
+
sizeUncounted: Schema.optionalKey(Globs),
|
|
31
|
+
botBranches: Schema.optionalKey(Globs)
|
|
30
32
|
});
|
|
31
33
|
/** Each setting's value when the file leaves it out: ref-0/git's, where the gate began. */
|
|
32
34
|
const defaults = {
|
|
@@ -74,7 +76,9 @@ const defaults = {
|
|
|
74
76
|
],
|
|
75
77
|
testHelpers: ["*/testing/*"],
|
|
76
78
|
benchedPaths: void 0,
|
|
77
|
-
benchRuns: []
|
|
79
|
+
benchRuns: [],
|
|
80
|
+
sizeUncounted: ["pnpm-lock.yaml"],
|
|
81
|
+
botBranches: []
|
|
78
82
|
};
|
|
79
83
|
const decodeFile = Schema.decodeUnknownResult(Schema.fromJsonString(File), { onExcessProperty: "error" });
|
|
80
84
|
/**
|
package/dist/types/cache.mjs
CHANGED
|
@@ -15,8 +15,8 @@ import { mkdir, readFile, readdir, rename, stat, unlink, utimes, writeFile } fro
|
|
|
15
15
|
* A project's key hashes the contents of every file its program read, as tsrs's `--listFiles`
|
|
16
16
|
* named them, except the packages under `node_modules/.pnpm/`, which the lockfile pins. It also
|
|
17
17
|
* hashes what decides which files a program reads and how: the lockfile, `pnpm-workspace.yaml`,
|
|
18
|
-
* every `package.json` and `tsconfig*.json` in the workspace and each file a config's
|
|
19
|
-
*
|
|
18
|
+
* every `package.json` and `tsconfig*.json` in the workspace and each file a config's chain of
|
|
19
|
+
* `extends` reaches, the path of every file a project includes, and tsrs's arguments. So an edit to any file
|
|
20
20
|
* a program read moves that project's key, and adding, removing or renaming a project's file moves
|
|
21
21
|
* every key. Contents are hashed rather than dated, since each worktree is a fresh checkout, and
|
|
22
22
|
* every path is from the worktree's root, so two worktrees at the same contents share a key. A
|
package/dist/types/inputs.mjs
CHANGED
|
@@ -37,30 +37,37 @@ const workspaceFiles = (root) => {
|
|
|
37
37
|
return walk("");
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
|
+
/** The workspace files `file`'s `extends` names, from the root: those outside it, as a package's, aren't. */
|
|
41
|
+
const extendedBy = (root, file) => {
|
|
42
|
+
const text = (() => {
|
|
43
|
+
try {
|
|
44
|
+
return readFileSync(join(root, file), "utf8");
|
|
45
|
+
} catch {
|
|
46
|
+
return "";
|
|
47
|
+
}
|
|
48
|
+
})();
|
|
49
|
+
return [...(/"extends"\s*:\s*(\[[^\]]*\]|"[^"]*")/.exec(text)?.[1] ?? "").matchAll(/"(\.[^"]*)"/g)].flatMap(([, target = ""]) => {
|
|
50
|
+
const path = relative(root, resolve(root, dirname(file), target));
|
|
51
|
+
return path.startsWith("..") ? [] : [path];
|
|
52
|
+
});
|
|
53
|
+
};
|
|
40
54
|
/**
|
|
41
55
|
* The lockfile, the workspace's settings, every `package.json` and `tsconfig*.json` in `files`,
|
|
42
|
-
* and each workspace file a config's `extends`
|
|
43
|
-
* files a resolver reads and how it reads them.
|
|
56
|
+
* and each workspace file a config's chain of `extends` reaches, from the root, sorted: what
|
|
57
|
+
* decides which files a resolver reads and how it reads them.
|
|
44
58
|
*/
|
|
45
59
|
const manifestInputs = (root, files) => {
|
|
46
60
|
const manifests = files.filter((file) => {
|
|
47
61
|
const name = basename(file);
|
|
48
62
|
return name === "package.json" || /^tsconfig.*\.json$/.test(name);
|
|
49
63
|
});
|
|
50
|
-
const extended =
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
})();
|
|
59
|
-
return [...(/"extends"\s*:\s*(\[[^\]]*\]|"[^"]*")/.exec(text)?.[1] ?? "").matchAll(/"(\.[^"]*)"/g)].flatMap(([, target = ""]) => {
|
|
60
|
-
const path = relative(root, resolve(root, dirname(file), target));
|
|
61
|
-
return path.startsWith("..") ? [] : [path];
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
+
const extended = /* @__PURE__ */ new Set();
|
|
65
|
+
const toRead = manifests.filter((file) => basename(file) !== "package.json");
|
|
66
|
+
for (let file = toRead.pop(); file !== void 0; file = toRead.pop()) for (const target of extendedBy(root, file)) {
|
|
67
|
+
if (extended.has(target)) continue;
|
|
68
|
+
extended.add(target);
|
|
69
|
+
toRead.push(target);
|
|
70
|
+
}
|
|
64
71
|
return [.../* @__PURE__ */ new Set([
|
|
65
72
|
"pnpm-lock.yaml",
|
|
66
73
|
"pnpm-workspace.yaml",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ref0/workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "The lint and workspace checks every ref-0 repo shares",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"dist",
|
|
16
16
|
"!dist/**/*.test.*",
|
|
17
17
|
"!dist/**/fixtures",
|
|
18
|
+
"tsconfig",
|
|
18
19
|
"README.md",
|
|
19
20
|
"LICENSE"
|
|
20
21
|
],
|
|
@@ -40,7 +41,10 @@
|
|
|
40
41
|
"./review-record": {
|
|
41
42
|
"types": "./dist/review-record/index.d.mts",
|
|
42
43
|
"import": "./dist/review-record/index.mjs"
|
|
43
|
-
}
|
|
44
|
+
},
|
|
45
|
+
"./tsconfig/base.json": "./tsconfig/base.json",
|
|
46
|
+
"./tsconfig/bundler.json": "./tsconfig/bundler.json",
|
|
47
|
+
"./tsconfig/node-next.json": "./tsconfig/node-next.json"
|
|
44
48
|
},
|
|
45
49
|
"publishConfig": {
|
|
46
50
|
"access": "public"
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"allowUnreachableCode": false,
|
|
5
|
+
"allowUnusedLabels": false,
|
|
6
|
+
"exactOptionalPropertyTypes": true,
|
|
7
|
+
"isolatedModules": true,
|
|
8
|
+
"moduleDetection": "force",
|
|
9
|
+
"noFallthroughCasesInSwitch": true,
|
|
10
|
+
"noImplicitOverride": true,
|
|
11
|
+
"noImplicitReturns": true,
|
|
12
|
+
"noUncheckedIndexedAccess": true,
|
|
13
|
+
"noUnusedLocals": true,
|
|
14
|
+
"noUnusedParameters": true,
|
|
15
|
+
"skipLibCheck": true,
|
|
16
|
+
"strict": true,
|
|
17
|
+
"target": "ES2023",
|
|
18
|
+
"verbatimModuleSyntax": true
|
|
19
|
+
}
|
|
20
|
+
}
|