@cplieger/deadset-ts 7.2.0-dev.4 → 8.0.0-dev.10
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 +1 -1
- package/dist/bin/mapper-connection.js +2 -1
- package/dist/bin/node-host.js +24 -5
- package/dist/src/analysis.js +245 -309
- package/dist/src/augmentations.js +124 -18
- package/dist/src/automatic-types.js +170 -0
- package/dist/src/build-scripts.js +425 -0
- package/dist/src/component-layer.js +4 -2
- package/dist/src/components.js +9 -9
- package/dist/src/config.js +6 -81
- package/dist/src/configuration-files.js +78 -188
- package/dist/src/configured-declarations.js +15 -20
- package/dist/src/conformance-record.js +2 -2
- package/dist/src/consumers.js +3 -30
- package/dist/src/contextual-uses.js +56 -9
- package/dist/src/contract/config.generated.js +558 -0
- package/dist/src/contract/contract.generated.js +1244 -0
- package/dist/src/contract/report.generated.js +862 -0
- package/dist/src/convention-rows.js +146 -1
- package/dist/src/conventions.js +136 -70
- package/dist/src/decorator.js +21 -18
- package/dist/src/dependencies.js +280 -62
- package/dist/src/edges.js +38 -122
- package/dist/src/element-access.js +4 -6
- package/dist/src/entry-point-gaps.js +9 -18
- package/dist/src/entry-points.js +106 -21
- package/dist/src/enum-group.js +3 -10
- package/dist/src/erased-stores.js +4 -6
- package/dist/src/exempt-classes.js +1 -63
- package/dist/src/exempt.js +21 -40
- package/dist/src/failure.js +36 -0
- package/dist/src/file-facts.js +2 -25
- package/dist/src/findings/completion.js +225 -63
- package/dist/src/findings/dependencies-and-module-machinery.js +72 -27
- package/dist/src/findings/emitters.js +6 -6
- package/dist/src/findings/interfaces.js +4 -5
- package/dist/src/findings/intra-function.js +53 -19
- package/dist/src/findings/non-code-artifacts.js +71 -39
- package/dist/src/findings/reads-and-writes.js +16 -13
- package/dist/src/findings/self-check.js +10 -12
- package/dist/src/findings/unused-declarations.js +57 -28
- package/dist/src/findings/visibility-narrowing.js +40 -18
- package/dist/src/findings-pass.js +8 -15
- package/dist/src/framework-lifecycle.js +7 -7
- package/dist/src/fs/document.js +52 -0
- package/dist/src/fs/manifest.js +72 -0
- package/dist/src/fs/tree.js +88 -0
- package/dist/src/generated-file.js +18 -4
- package/dist/src/git-ignore.js +99 -0
- package/dist/src/graph.js +9 -4
- package/dist/src/html-entries.js +6 -33
- package/dist/src/import-bindings.js +97 -0
- package/dist/src/in-operands.js +2 -1
- package/dist/src/index.js +1 -1
- package/dist/src/indexed-access.js +130 -28
- package/dist/src/injection-container.js +1 -1
- package/dist/src/interface-satisfaction.js +30 -12
- package/dist/src/intra-function-parts.js +341 -69
- package/dist/src/inventory.js +54 -29
- package/dist/src/javascript-file.js +33 -0
- package/dist/src/json-document.js +198 -67
- package/dist/src/keyof-comparisons.js +4 -6
- package/dist/src/kinds.js +3 -366
- package/dist/src/load/classify.js +270 -0
- package/dist/src/load/diagnostics.js +80 -0
- package/dist/src/load/discover.js +277 -0
- package/dist/src/{emit-map.js → load/emit-map.js} +1 -1
- package/dist/src/load/expected-module.js +136 -0
- package/dist/src/load/load.js +27 -0
- package/dist/src/load/module-lookup.js +37 -0
- package/dist/src/load/plan.js +313 -0
- package/dist/src/load/specifiers.js +115 -0
- package/dist/src/load/synthesize.js +140 -0
- package/dist/src/load/test-globals.js +207 -0
- package/dist/src/load/test-joins.js +82 -0
- package/dist/src/{workspace-manifests.js → load/workspace-manifests.js} +4 -4
- package/dist/src/{workspace-programs.js → load/workspace-programs.js} +88 -61
- package/dist/src/{workspace-resolution.js → load/workspace-resolution.js} +60 -59
- package/dist/src/{workspace-run.js → load/workspace-run.js} +7 -7
- package/dist/src/{workspace.js → load/workspace.js} +62 -124
- package/dist/src/manifest.js +49 -54
- package/dist/src/matrix.js +94 -13
- package/dist/src/mdx-entries.js +174 -0
- package/dist/src/module-declarations.js +9 -13
- package/dist/src/outside-tests.js +1 -1
- package/dist/src/overrides.js +41 -10
- package/dist/src/partial.js +2 -1
- package/dist/src/paths.js +26 -15
- package/dist/src/position.js +2 -1
- package/dist/src/print.js +11 -78
- package/dist/src/product.js +13 -0
- package/dist/src/query.js +1 -0
- package/dist/src/ref.js +11 -0
- package/dist/src/references.js +52 -31
- package/dist/src/report-schema.js +51 -0
- package/dist/src/report.js +59 -41
- package/dist/src/reporters/annotations.js +15 -8
- package/dist/src/reporters/sarif.js +16 -10
- package/dist/src/reporters/template.js +4 -19
- package/dist/src/resolve.js +245 -727
- package/dist/src/roots.js +374 -116
- package/dist/src/run.js +66 -77
- package/dist/src/schema.js +320 -342
- package/dist/src/scope.js +38 -115
- package/dist/src/serialization-contract.js +649 -29
- package/dist/src/session.js +41 -29
- package/dist/src/source-files.js +40 -15
- package/dist/src/suppress-file.js +34 -29
- package/dist/src/suppress-inline.js +21 -4
- package/dist/src/suppress.js +40 -56
- package/dist/src/sweep.js +32 -17
- package/dist/src/symbol-keys.js +105 -6
- package/dist/src/template-field.js +9 -19
- package/dist/src/test-support.js +119 -18
- package/dist/src/text/compare.js +26 -0
- package/dist/src/text/glob.js +194 -0
- package/dist/src/text/named-files.js +54 -0
- package/dist/src/text/shell.js +159 -0
- package/dist/src/text/yaml.js +393 -0
- package/dist/src/type-errors.js +27 -221
- package/dist/src/type-parameter-reads.js +172 -0
- package/dist/src/unseen-loads.js +100 -0
- package/dist/src/unwrap.js +23 -0
- package/dist/src/usage.js +10 -0
- package/dist/src/verbs/analyze.js +181 -125
- package/dist/src/verbs/describe.js +9 -16
- package/dist/src/verbs/explain.js +14 -9
- package/dist/src/verbs/print-config.js +2 -1
- package/dist/src/verbs/print-projects.js +6 -4
- package/dist/src/verbs/print-retained.js +4 -2
- package/dist/src/verbs/print-roots.js +4 -2
- package/dist/src/verbs/verb.js +1 -5
- package/dist/src/verbs/version.js +14 -3
- package/dist/src/workflow-steps.js +128 -33
- package/jsr.json +1 -1
- package/package.json +5 -4
- package/src/analysis.ts +333 -457
- package/src/augmentations.ts +152 -23
- package/src/automatic-types.ts +228 -0
- package/src/build-scripts.ts +543 -0
- package/src/component-layer.ts +4 -2
- package/src/components.ts +9 -10
- package/src/config.ts +31 -299
- package/src/configuration-files.ts +100 -191
- package/src/configured-declarations.ts +18 -23
- package/src/conformance-record.ts +2 -2
- package/src/consumers.ts +6 -57
- package/src/contextual-uses.ts +64 -12
- package/src/contract/config.generated.ts +818 -0
- package/src/contract/contract.generated.ts +1308 -0
- package/src/contract/report.generated.ts +1237 -0
- package/src/convention-rows.ts +186 -1
- package/src/conventions.ts +166 -90
- package/src/decorator.ts +28 -18
- package/src/dependencies.ts +356 -78
- package/src/edges.ts +41 -140
- package/src/element-access.ts +4 -7
- package/src/entry-point-gaps.ts +11 -20
- package/src/entry-points.ts +124 -28
- package/src/enum-group.ts +2 -11
- package/src/erased-stores.ts +3 -7
- package/src/exempt-classes.ts +1 -75
- package/src/exempt.ts +36 -50
- package/src/failure.ts +63 -0
- package/src/file-facts.ts +9 -24
- package/src/finding.ts +24 -9
- package/src/findings/boundary.ts +2 -0
- package/src/findings/completion.ts +297 -77
- package/src/findings/dependencies-and-module-machinery.ts +90 -31
- package/src/findings/emitter.ts +8 -9
- package/src/findings/emitters.ts +8 -8
- package/src/findings/interfaces.ts +4 -6
- package/src/findings/intra-function.ts +64 -20
- package/src/findings/non-code-artifacts.ts +88 -50
- package/src/findings/reads-and-writes.ts +20 -16
- package/src/findings/self-check.ts +11 -17
- package/src/findings/unused-declarations.ts +65 -28
- package/src/findings/visibility-narrowing.ts +51 -19
- package/src/findings-pass.ts +10 -19
- package/src/framework-lifecycle.ts +7 -7
- package/src/fs/document.ts +70 -0
- package/src/fs/manifest.ts +92 -0
- package/src/fs/tree.ts +110 -0
- package/src/generated-file.ts +23 -4
- package/src/git-ignore.ts +122 -0
- package/src/graph.ts +11 -3
- package/src/host.ts +17 -14
- package/src/html-entries.ts +6 -33
- package/src/import-bindings.ts +128 -0
- package/src/in-operands.ts +2 -1
- package/src/index.ts +1 -1
- package/src/indexed-access.ts +152 -30
- package/src/injection-container.ts +1 -1
- package/src/interface-satisfaction.ts +33 -13
- package/src/intra-function-parts.ts +449 -85
- package/src/inventory.ts +73 -27
- package/src/javascript-file.ts +37 -0
- package/src/json-document.ts +241 -76
- package/src/keyof-comparisons.ts +3 -7
- package/src/kinds.ts +5 -413
- package/src/load/classify.ts +397 -0
- package/src/load/diagnostics.ts +144 -0
- package/src/load/discover.ts +455 -0
- package/src/{emit-map.ts → load/emit-map.ts} +1 -1
- package/src/load/expected-module.ts +188 -0
- package/src/load/load.ts +73 -0
- package/src/load/module-lookup.ts +50 -0
- package/src/load/plan.ts +504 -0
- package/src/load/specifiers.ts +168 -0
- package/src/load/synthesize.ts +211 -0
- package/src/load/test-globals.ts +251 -0
- package/src/load/test-joins.ts +98 -0
- package/src/{workspace-manifests.ts → load/workspace-manifests.ts} +5 -5
- package/src/{workspace-programs.ts → load/workspace-programs.ts} +127 -80
- package/src/{workspace-resolution.ts → load/workspace-resolution.ts} +73 -64
- package/src/{workspace-run.ts → load/workspace-run.ts} +18 -16
- package/src/{workspace.ts → load/workspace.ts} +90 -134
- package/src/manifest.ts +81 -75
- package/src/matrix.ts +154 -18
- package/src/mdx-entries.ts +218 -0
- package/src/module-declarations.ts +11 -13
- package/src/outside-tests.ts +1 -1
- package/src/overrides.ts +51 -12
- package/src/partial.ts +3 -2
- package/src/paths.ts +27 -15
- package/src/position.ts +2 -1
- package/src/print.ts +12 -91
- package/src/product.ts +18 -0
- package/src/query.ts +11 -0
- package/src/ref.ts +13 -0
- package/src/references.ts +62 -32
- package/src/report-schema.ts +68 -0
- package/src/report.ts +105 -215
- package/src/reporters/annotations.ts +22 -11
- package/src/reporters/json.ts +1 -1
- package/src/reporters/reporter.ts +2 -4
- package/src/reporters/reporters.ts +1 -1
- package/src/reporters/sarif.ts +29 -16
- package/src/reporters/template.ts +4 -20
- package/src/reporters/text.ts +3 -3
- package/src/resolve.ts +283 -1111
- package/src/roots.ts +490 -137
- package/src/run.ts +75 -91
- package/src/schema.ts +391 -387
- package/src/scope.ts +46 -138
- package/src/serialization-contract.ts +818 -26
- package/src/session.ts +77 -54
- package/src/source-files.ts +67 -17
- package/src/suppress-file.ts +36 -34
- package/src/suppress-inline.ts +20 -3
- package/src/suppress.ts +52 -63
- package/src/sweep.ts +53 -18
- package/src/symbol-keys.ts +131 -7
- package/src/template-field.ts +15 -25
- package/src/test-support.ts +155 -18
- package/src/text/compare.ts +27 -0
- package/src/text/glob.ts +210 -0
- package/src/text/named-files.inputs.json +1522 -0
- package/src/text/named-files.ts +68 -0
- package/src/text/shell.ts +161 -0
- package/src/text/yaml.ts +423 -0
- package/src/type-errors.ts +35 -273
- package/src/type-parameter-reads.ts +227 -0
- package/src/unseen-loads.ts +134 -0
- package/src/unwrap.ts +34 -0
- package/src/usage.ts +10 -0
- package/src/verbs/analyze.ts +245 -161
- package/src/verbs/describe.ts +14 -15
- package/src/verbs/explain.ts +15 -13
- package/src/verbs/print-config.ts +2 -1
- package/src/verbs/print-projects.ts +6 -4
- package/src/verbs/print-retained.ts +4 -2
- package/src/verbs/print-roots.ts +4 -2
- package/src/verbs/verb.ts +2 -8
- package/src/verbs/version.ts +15 -3
- package/src/workflow-steps.ts +149 -34
- package/dist/src/discover.js +0 -347
- package/dist/src/glob.js +0 -65
- package/dist/src/pnpm-workspace.js +0 -120
- package/dist/src/setup-failure.js +0 -23
- package/dist/src/test-joins.js +0 -101
- package/dist/src/version.js +0 -7
- package/src/discover.ts +0 -510
- package/src/glob.ts +0 -67
- package/src/pnpm-workspace.ts +0 -135
- package/src/setup-failure.ts +0 -39
- package/src/test-joins.ts +0 -120
- package/src/version.ts +0 -7
package/dist/src/discover.js
DELETED
|
@@ -1,347 +0,0 @@
|
|
|
1
|
-
import { DiagnosticCategory } from "@typescript/native/sync";
|
|
2
|
-
import { dirnamePath, joinPath, relativePath, resolvePath } from "./paths.js";
|
|
3
|
-
import { SetupError } from "./setup-failure.js";
|
|
4
|
-
/** Directory names discovery does not descend into. */
|
|
5
|
-
export const IGNORED_DIRECTORIES = new Set(["node_modules", ".git"]);
|
|
6
|
-
/** A compiler configuration file discovery recognises under a root. */
|
|
7
|
-
const CONFIG_FILE = /^tsconfig.*\.json$/u;
|
|
8
|
-
/**
|
|
9
|
-
* A run that cannot read what it was asked to analyze. It ends the run with the
|
|
10
|
-
* failure code and no finding list: a configuration file the compiler cannot read,
|
|
11
|
-
* or a project carrying an error, leaves the analysis without the type information
|
|
12
|
-
* every answer rests on, and a partial answer is never printed as a complete one.
|
|
13
|
-
*/
|
|
14
|
-
export class DiscoveryError extends Error {
|
|
15
|
-
/** The diagnostics the compiler reported, in the order it reported them. */
|
|
16
|
-
diagnostics;
|
|
17
|
-
constructor(message, diagnostics) {
|
|
18
|
-
super(message);
|
|
19
|
-
this.name = "DiscoveryError";
|
|
20
|
-
this.diagnostics = diagnostics;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
/** The category an error diagnostic carries, which the protocol sends as a number. */
|
|
24
|
-
const ERROR_CATEGORY = DiagnosticCategory.Error;
|
|
25
|
-
/** Whether one diagnostic is an error, which is what fails a run closed. */
|
|
26
|
-
function isError(diagnostic) {
|
|
27
|
-
return diagnostic.category === ERROR_CATEGORY;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* One diagnostic as a line naming its file, its line and column, its code and its
|
|
31
|
-
* message: `path:line:column: TScode: message`, the position left out where the
|
|
32
|
-
* diagnostic names none and the file where it names none. `display` spells the
|
|
33
|
-
* file's path; it answers the path itself where it is not given.
|
|
34
|
-
*/
|
|
35
|
-
export function renderDiagnostic(located, display = (path) => path) {
|
|
36
|
-
const { diagnostic, at } = located;
|
|
37
|
-
const message = `TS${String(diagnostic.code)}: ${diagnostic.text}`;
|
|
38
|
-
if (diagnostic.fileName === undefined) {
|
|
39
|
-
return message;
|
|
40
|
-
}
|
|
41
|
-
const where = display(diagnostic.fileName);
|
|
42
|
-
return at === undefined
|
|
43
|
-
? `${where}: ${message}`
|
|
44
|
-
: `${where}:${String(at.line)}:${String(at.column)}: ${message}`;
|
|
45
|
-
}
|
|
46
|
-
/** Each diagnostic with the line and column its offset falls on. */
|
|
47
|
-
function locatedIn(diagnostics, locate) {
|
|
48
|
-
return diagnostics.map((diagnostic) => ({
|
|
49
|
-
diagnostic,
|
|
50
|
-
at: diagnostic.fileName === undefined ? undefined : locate(diagnostic.fileName, diagnostic.pos),
|
|
51
|
-
}));
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Every error a project's three diagnostic sets carry, in the order the compiler
|
|
55
|
-
* reported them: a configuration whose options do not parse, a file whose syntax
|
|
56
|
-
* does not, and a program that does not type-check. A resolved configuration
|
|
57
|
-
* carries no diagnostics of its own, so a configuration written with an unreadable
|
|
58
|
-
* option resolves and is refused here, once its project is open.
|
|
59
|
-
*/
|
|
60
|
-
export function diagnosticErrors(sets) {
|
|
61
|
-
return [...sets.configParsing, ...sets.syntactic, ...sets.semantic].filter(isError);
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* The codes of a type library and a lib the configuration names that the compiler
|
|
65
|
-
* cannot find, which it reports while it gathers the program's files:
|
|
66
|
-
* https://github.com/microsoft/typescript-go/blob/89d5d5b2849a0db0957065889ca58536fa6d2e4a/internal/compiler/processingDiagnostic.go
|
|
67
|
-
*/
|
|
68
|
-
const UNFOUND_LIBRARY = new Set([2688, 2726, 2727]);
|
|
69
|
-
/** The errors one open project carries, each located in the file it names. */
|
|
70
|
-
export function projectErrors(sets) {
|
|
71
|
-
// The compiler numbers its semantic messages from 2000 and its option messages from
|
|
72
|
-
// 5000. A file-less option error, a removed option or an output layout, leaves the
|
|
73
|
-
// program whole, and the compiler checks it all the same:
|
|
74
|
-
// https://github.com/microsoft/TypeScript/wiki/Coding-guidelines#diagnostic-message-codes
|
|
75
|
-
const semantic = sets.unplaced.filter((diagnostic) => isError(diagnostic) && diagnostic.code >= 2000 && diagnostic.code < 3000);
|
|
76
|
-
const unfound = semantic.filter(({ code }) => UNFOUND_LIBRARY.has(code));
|
|
77
|
-
const load = [
|
|
78
|
-
...sets.configParsing.filter(isError),
|
|
79
|
-
...semantic.filter(({ code }) => !UNFOUND_LIBRARY.has(code)),
|
|
80
|
-
];
|
|
81
|
-
return {
|
|
82
|
-
load: locatedIn(load, sets.locate),
|
|
83
|
-
check: load.length > 0 ? [] : locatedIn(diagnosticErrors(sets), sets.locate),
|
|
84
|
-
unfound: load.length > 0 ? [] : locatedIn(unfound, sets.locate),
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* The first line of one error about the target, every mention of the target root
|
|
89
|
-
* spelled relative to it: a path below the root loses the root and its separator, and
|
|
90
|
-
* the root itself is `.`.
|
|
91
|
-
*/
|
|
92
|
-
export function targetRelative(text, targetRoot) {
|
|
93
|
-
const root = targetRoot.endsWith("/") ? targetRoot.slice(0, -1) : targetRoot;
|
|
94
|
-
const [first = ""] = text.split(/\r?\n/u);
|
|
95
|
-
const spelled = first.split(`${root}/`).join("").split(root).join(".").trim();
|
|
96
|
-
return spelled === "" ? "the configuration could not be built" : spelled;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Whether one configuration is the analyzer's own guess: discovery derived it and the
|
|
100
|
-
* scope did not name it. A guess that does not load is dropped; any other ends the run.
|
|
101
|
-
*/
|
|
102
|
-
export function isGuess(discovery, configFile) {
|
|
103
|
-
return discovery.derived && !discovery.fromScope.includes(configFile);
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* The configuration files below `root`, in ascending path order, skipping an
|
|
107
|
-
* ignored directory. A directory that cannot be read is skipped: a tree the
|
|
108
|
-
* analysis may not enter names no project.
|
|
109
|
-
*/
|
|
110
|
-
function configFilesUnder(host, root) {
|
|
111
|
-
const found = [];
|
|
112
|
-
const pending = [root];
|
|
113
|
-
while (pending.length > 0) {
|
|
114
|
-
const dir = pending.pop();
|
|
115
|
-
if (dir === undefined) {
|
|
116
|
-
break;
|
|
117
|
-
}
|
|
118
|
-
let entries;
|
|
119
|
-
try {
|
|
120
|
-
entries = host.readDirectory(dir);
|
|
121
|
-
}
|
|
122
|
-
catch {
|
|
123
|
-
continue;
|
|
124
|
-
}
|
|
125
|
-
for (const entry of [...entries].sort((a, b) => (a.name < b.name ? -1 : 1))) {
|
|
126
|
-
const path = joinPath(dir, entry.name);
|
|
127
|
-
if (entry.directory) {
|
|
128
|
-
if (!IGNORED_DIRECTORIES.has(entry.name)) {
|
|
129
|
-
pending.push(path);
|
|
130
|
-
}
|
|
131
|
-
continue;
|
|
132
|
-
}
|
|
133
|
-
if (CONFIG_FILE.test(entry.name)) {
|
|
134
|
-
found.push(path);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
return found.sort();
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* The configuration file the scope names for the target directly, where its path
|
|
142
|
-
* names one rather than a directory. A target naming a directory is reached by the
|
|
143
|
-
* walk over that directory instead. A consumer's projects are a consumer's, never the
|
|
144
|
-
* target's, so no consumer path is read here.
|
|
145
|
-
*/
|
|
146
|
-
function scopeConfigFiles(host, scope) {
|
|
147
|
-
return [scope.target.path]
|
|
148
|
-
.filter((path) => path.endsWith(".json"))
|
|
149
|
-
.map((path) => resolvePath(host.workingDirectory(), path));
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Every configuration file reached from `pending`, in the order discovery reads them:
|
|
153
|
-
* each once, each followed by the configurations it references that `follows` admits,
|
|
154
|
-
* transitively. A configuration the compiler cannot read ends the run naming it, unless
|
|
155
|
-
* `unreadable` is given, which is then told the configuration and why, and the walk
|
|
156
|
-
* goes on without it.
|
|
157
|
-
*/
|
|
158
|
-
function derivedFrom(engine, host, pending, follows, unreadable) {
|
|
159
|
-
const seen = new Set();
|
|
160
|
-
const found = [];
|
|
161
|
-
while (pending.length > 0) {
|
|
162
|
-
const configFile = pending.shift();
|
|
163
|
-
if (configFile === undefined) {
|
|
164
|
-
break;
|
|
165
|
-
}
|
|
166
|
-
const path = resolvePath(host.workingDirectory(), configFile);
|
|
167
|
-
if (seen.has(path)) {
|
|
168
|
-
continue;
|
|
169
|
-
}
|
|
170
|
-
seen.add(path);
|
|
171
|
-
const read = readConfiguration(engine, path);
|
|
172
|
-
if ("reason" in read) {
|
|
173
|
-
if (unreadable === undefined) {
|
|
174
|
-
throw new DiscoveryError(`${path} cannot be read as a compiler configuration: ${read.reason}`, []);
|
|
175
|
-
}
|
|
176
|
-
unreadable(path, read.reason);
|
|
177
|
-
continue;
|
|
178
|
-
}
|
|
179
|
-
found.push(path);
|
|
180
|
-
pending.push(...read.references.filter(follows));
|
|
181
|
-
}
|
|
182
|
-
return found;
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* The compiler configurations one consumer is loaded through: every one under its
|
|
186
|
-
* root that is not inside an ignored directory, and the configurations each of those
|
|
187
|
-
* references, transitively, in that order. A root that is absent, that is no
|
|
188
|
-
* directory, or that holds no configuration ends the run naming it, because a
|
|
189
|
-
* finding computed without a declared consumer would claim a reference set the run
|
|
190
|
-
* never read.
|
|
191
|
-
*/
|
|
192
|
-
export function consumerProjects(engine, host, root) {
|
|
193
|
-
const kind = host.kindOf(root);
|
|
194
|
-
if (kind === "absent") {
|
|
195
|
-
throw new SetupError([
|
|
196
|
-
{
|
|
197
|
-
setupClass: "missing-consumer",
|
|
198
|
-
detail: `the scope declares the consumer ${root}, and nothing is at that path: check the consumer out at ${root} and install its dependencies`,
|
|
199
|
-
},
|
|
200
|
-
]);
|
|
201
|
-
}
|
|
202
|
-
if (kind !== "directory") {
|
|
203
|
-
throw new DiscoveryError(`the consumer ${root} is not a directory`, []);
|
|
204
|
-
}
|
|
205
|
-
const found = derivedFrom(engine, host, configFilesUnder(host, root), () => true);
|
|
206
|
-
if (found.length === 0) {
|
|
207
|
-
throw new DiscoveryError(`the consumer ${root} holds no compiler configuration, so none of its references can be read`, []);
|
|
208
|
-
}
|
|
209
|
-
return found;
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* The name a derived project carries: its configuration file's path below the target
|
|
213
|
-
* root, or the absolute path of a file outside it.
|
|
214
|
-
*/
|
|
215
|
-
function derivedId(targetRoot, configFile) {
|
|
216
|
-
return relativePath(targetRoot, configFile) ?? configFile;
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* The configuration files one configuration's `references` name, or why the compiler
|
|
220
|
-
* cannot read the configuration.
|
|
221
|
-
*/
|
|
222
|
-
function readConfiguration(engine, configFile) {
|
|
223
|
-
try {
|
|
224
|
-
const parsed = engine.parseConfigFile(configFile);
|
|
225
|
-
// The parse answers a directory reference as the directory; the compiler reads a
|
|
226
|
-
// path not ending `.json` as its `tsconfig.json`:
|
|
227
|
-
// https://github.com/microsoft/typescript-go/blob/89d5d5b2849a0db0957065889ca58536fa6d2e4a/internal/core/projectreference.go#L18
|
|
228
|
-
return {
|
|
229
|
-
references: (parsed.projectReferences ?? []).map(({ path }) => path.endsWith(".json") ? path : joinPath(path, "tsconfig.json")),
|
|
230
|
-
};
|
|
231
|
-
}
|
|
232
|
-
catch (error) {
|
|
233
|
-
return { reason: error instanceof Error ? error.message : String(error) };
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
/**
|
|
237
|
-
* The references of one compiler configuration file, or ends the run naming it: a
|
|
238
|
-
* project opened from a configuration the compiler cannot read would be analyzed with
|
|
239
|
-
* no type information.
|
|
240
|
-
*/
|
|
241
|
-
function parseOrRefuse(engine, configFile, named) {
|
|
242
|
-
const read = readConfiguration(engine, configFile);
|
|
243
|
-
if ("reason" in read) {
|
|
244
|
-
throw new DiscoveryError(`${named} cannot be read as a compiler configuration: ${read.reason}`, []);
|
|
245
|
-
}
|
|
246
|
-
return read.references;
|
|
247
|
-
}
|
|
248
|
-
/**
|
|
249
|
-
* The projects a build matrix declares, in its order, each entry a file below the target
|
|
250
|
-
* root: an entry naming an absent file, a directory or a file the compiler cannot read
|
|
251
|
-
* ends the run naming it, and one naming an earlier entry's file adds nothing. A
|
|
252
|
-
* reference below the root the matrix does not name ends the run naming both, because the
|
|
253
|
-
* compiler builds a referenced project's sources into the referencing program without
|
|
254
|
-
* reporting their diagnostics. A reference outside the root is an outside project.
|
|
255
|
-
*/
|
|
256
|
-
function declaredProjects(engine, host, targetRoot, entries) {
|
|
257
|
-
const seen = new Set();
|
|
258
|
-
const projects = [];
|
|
259
|
-
const references = new Map();
|
|
260
|
-
for (const entry of entries) {
|
|
261
|
-
const configFile = joinPath(targetRoot, entry.project);
|
|
262
|
-
const named = `the project ${JSON.stringify(entry.id)} (${configFile})`;
|
|
263
|
-
const kind = host.kindOf(configFile);
|
|
264
|
-
if (kind !== "file") {
|
|
265
|
-
throw new DiscoveryError(kind === "absent"
|
|
266
|
-
? `${named} does not exist`
|
|
267
|
-
: `${named} is a directory, and a project names its compiler configuration file`, []);
|
|
268
|
-
}
|
|
269
|
-
if (seen.has(configFile)) {
|
|
270
|
-
continue;
|
|
271
|
-
}
|
|
272
|
-
seen.add(configFile);
|
|
273
|
-
references.set(configFile, parseOrRefuse(engine, configFile, named));
|
|
274
|
-
projects.push({ id: entry.id, configFile });
|
|
275
|
-
}
|
|
276
|
-
for (const project of projects) {
|
|
277
|
-
const unnamed = references
|
|
278
|
-
.get(project.configFile)
|
|
279
|
-
?.find((path) => !seen.has(path) && relativePath(targetRoot, path) !== undefined);
|
|
280
|
-
if (unnamed !== undefined) {
|
|
281
|
-
throw new DiscoveryError(`the project ${JSON.stringify(project.id)} (${project.configFile}) references ` +
|
|
282
|
-
`${unnamed}, which the build matrix does not name. A referenced project is built ` +
|
|
283
|
-
"into the program that references it, so the matrix names it too", []);
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
return {
|
|
287
|
-
projects,
|
|
288
|
-
derived: false,
|
|
289
|
-
notBuilt: [],
|
|
290
|
-
configFiles: projects.map((project) => project.configFile),
|
|
291
|
-
fromScope: [],
|
|
292
|
-
};
|
|
293
|
-
}
|
|
294
|
-
/**
|
|
295
|
-
* The projects a run derives where the matrix declares none, in discovery order: the
|
|
296
|
-
* paths the scope names, every compiler configuration under the target root outside an
|
|
297
|
-
* ignored directory, then each configuration below the root those reference,
|
|
298
|
-
* transitively, each once. A reference outside the root is an outside project, whose
|
|
299
|
-
* sources the compiler builds into the referencing program. A configuration the scope
|
|
300
|
-
* names ends the run where it cannot be read; one the walk found is dropped and named.
|
|
301
|
-
*/
|
|
302
|
-
function derivedProjects(engine, host, scope) {
|
|
303
|
-
const targetRoot = scope.target.path;
|
|
304
|
-
const fromScope = scopeConfigFiles(host, scope);
|
|
305
|
-
const notBuilt = [];
|
|
306
|
-
const rootDir = resolvePath(host.workingDirectory(), fromScope.length > 0 ? dirnamePath(targetRoot) : targetRoot);
|
|
307
|
-
const configFiles = derivedFrom(engine, host, [...fromScope, ...configFilesUnder(host, targetRoot)], (reference) => relativePath(rootDir, reference) !== undefined, (configFile, reason) => {
|
|
308
|
-
if (fromScope.includes(configFile)) {
|
|
309
|
-
throw new DiscoveryError(`${configFile} cannot be read as a compiler configuration: ${reason}`, []);
|
|
310
|
-
}
|
|
311
|
-
notBuilt.push({
|
|
312
|
-
id: derivedId(targetRoot, configFile),
|
|
313
|
-
configFile,
|
|
314
|
-
error: targetRelative(reason, resolvePath(host.workingDirectory(), targetRoot)),
|
|
315
|
-
});
|
|
316
|
-
});
|
|
317
|
-
const projects = configFiles.map((configFile) => ({
|
|
318
|
-
id: derivedId(targetRoot, configFile),
|
|
319
|
-
configFile,
|
|
320
|
-
}));
|
|
321
|
-
return { projects, derived: true, notBuilt, configFiles, fromScope };
|
|
322
|
-
}
|
|
323
|
-
/**
|
|
324
|
-
* Every project one run analyzes.
|
|
325
|
-
*
|
|
326
|
-
* The project entries of the build matrix, where it holds any, are the projects:
|
|
327
|
-
* exactly those, in the order the matrix lists them, each named by its declared
|
|
328
|
-
* identifier, as {@link declaredProjects} reads them. A matrix holding no project
|
|
329
|
-
* entry, the empty one included, leaves discovery to derive the projects from the
|
|
330
|
-
* scope and the target tree. A platform entry names a configuration of another
|
|
331
|
-
* language and plays no part here.
|
|
332
|
-
*
|
|
333
|
-
* A configuration file the compiler cannot read is never analyzed. One the matrix or
|
|
334
|
-
* the scope names ends the run with the failure code; a guess is dropped and named in
|
|
335
|
-
* {@link Discovery.notBuilt}. What a configuration's own contents say is read once its
|
|
336
|
-
* project is open, by {@link diagnosticErrors}, because a resolution carries none.
|
|
337
|
-
*
|
|
338
|
-
* Nothing reads a build output: a project is the files its configuration names, so a
|
|
339
|
-
* package whose sources ship as TypeScript is analyzed as it stands.
|
|
340
|
-
*/
|
|
341
|
-
export function discoverProjects(engine, host, scope, configurations = []) {
|
|
342
|
-
const declared = configurations.filter((entry) => entry.shape === "project");
|
|
343
|
-
if (declared.length > 0) {
|
|
344
|
-
return declaredProjects(engine, host, scope.target.path, declared);
|
|
345
|
-
}
|
|
346
|
-
return derivedProjects(engine, host, scope);
|
|
347
|
-
}
|
package/dist/src/glob.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Glob patterns over the paths of the target's own files, as the configuration
|
|
3
|
-
* writes them. Both `ts.test_files` and `ts.entry_files` name files this way, and
|
|
4
|
-
* one grammar answers for both.
|
|
5
|
-
*
|
|
6
|
-
* A configured root is not written in this grammar. It names a symbol reference
|
|
7
|
-
* rather than a path, `*` there spans the solidus and a brace list means nothing,
|
|
8
|
-
* so that rule is written where it is read.
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* One literal run of a pattern, with every character the expression syntax claims
|
|
12
|
-
* escaped.
|
|
13
|
-
*
|
|
14
|
-
* The set is the syntax characters and the solidus, and it is closed: an escape of any
|
|
15
|
-
* other character is refused outright by the expression syntax under the unicode flag,
|
|
16
|
-
* so escaping a hyphen, which needs none outside a character class, would refuse every
|
|
17
|
-
* pattern that names a hyphenated path.
|
|
18
|
-
*/
|
|
19
|
-
function quoted(text) {
|
|
20
|
-
return text.replaceAll(/[.*+?^${}()|[\]\\/]/gu, (character) => `\\${character}`);
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* The expression one glob pattern denotes. `**` spans path separators while `*` and `?`
|
|
24
|
-
* do not, a brace list is an alternation of its members, and every other character
|
|
25
|
-
* stands for itself.
|
|
26
|
-
*/
|
|
27
|
-
export function globExpression(pattern) {
|
|
28
|
-
let source = "^";
|
|
29
|
-
let at = 0;
|
|
30
|
-
while (at < pattern.length) {
|
|
31
|
-
const rest = pattern.slice(at);
|
|
32
|
-
if (rest.startsWith("**/")) {
|
|
33
|
-
source += "(?:[^/]*/)*";
|
|
34
|
-
at += 3;
|
|
35
|
-
continue;
|
|
36
|
-
}
|
|
37
|
-
if (rest.startsWith("**")) {
|
|
38
|
-
source += ".*";
|
|
39
|
-
at += 2;
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
|
-
const character = pattern[at] ?? "";
|
|
43
|
-
at += 1;
|
|
44
|
-
if (character === "*") {
|
|
45
|
-
source += "[^/]*";
|
|
46
|
-
continue;
|
|
47
|
-
}
|
|
48
|
-
if (character === "?") {
|
|
49
|
-
source += "[^/]";
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
|
-
if (character === "{") {
|
|
53
|
-
const close = pattern.indexOf("}", at);
|
|
54
|
-
if (close < 0) {
|
|
55
|
-
source += "\\{";
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
58
|
-
source += `(?:${pattern.slice(at, close).split(",").map(quoted).join("|")})`;
|
|
59
|
-
at = close + 1;
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
62
|
-
source += quoted(character);
|
|
63
|
-
}
|
|
64
|
-
return new RegExp(`${source}$`, "u");
|
|
65
|
-
}
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The `packages` list of a `pnpm-workspace.yaml`. The document is read as far as that
|
|
3
|
-
* one key needs and no further: a top-level `packages` key holding a block sequence or
|
|
4
|
-
* a one-line flow sequence of plain or quoted strings. Any other value of the key is
|
|
5
|
-
* refused rather than guessed at, because a list read wrong names the wrong packages.
|
|
6
|
-
*/
|
|
7
|
-
/** The characters a plain scalar may not start with. */
|
|
8
|
-
const INDICATORS = new Set(["[", "]", "{", "}", ",", "&", "*", "!", "|", ">", "%", "@", "`", "#"]);
|
|
9
|
-
/** One line with its comment removed, a `#` inside quotes kept. */
|
|
10
|
-
function uncommented(line) {
|
|
11
|
-
let quote;
|
|
12
|
-
for (let at = 0; at < line.length; at += 1) {
|
|
13
|
-
const character = line[at];
|
|
14
|
-
if (quote !== undefined) {
|
|
15
|
-
if (character === quote) {
|
|
16
|
-
quote = undefined;
|
|
17
|
-
}
|
|
18
|
-
continue;
|
|
19
|
-
}
|
|
20
|
-
if (character === "'" || character === '"') {
|
|
21
|
-
quote = character;
|
|
22
|
-
}
|
|
23
|
-
else if (character === "#" && (at === 0 || /\s/u.test(line[at - 1] ?? ""))) {
|
|
24
|
-
return line.slice(0, at).trimEnd();
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return line.trimEnd();
|
|
28
|
-
}
|
|
29
|
-
/** One scalar as written, or `undefined` where it is not a string this reader reads. */
|
|
30
|
-
function scalarOf(text) {
|
|
31
|
-
const value = text.trim();
|
|
32
|
-
if (value.length >= 2 && value.startsWith("'") && value.endsWith("'")) {
|
|
33
|
-
const inner = value.slice(1, -1);
|
|
34
|
-
return /'(?!')/u.test(inner.replaceAll("''", "")) ? undefined : inner.replaceAll("''", "'");
|
|
35
|
-
}
|
|
36
|
-
if (value.length >= 2 && value.startsWith('"') && value.endsWith('"')) {
|
|
37
|
-
const inner = value.slice(1, -1);
|
|
38
|
-
return inner.includes("\\") || inner.includes('"') ? undefined : inner;
|
|
39
|
-
}
|
|
40
|
-
if (value === "" ||
|
|
41
|
-
INDICATORS.has(value[0] ?? "") ||
|
|
42
|
-
value.startsWith("'") ||
|
|
43
|
-
value.startsWith('"')) {
|
|
44
|
-
return undefined;
|
|
45
|
-
}
|
|
46
|
-
if (value.startsWith("- ") || value.startsWith("? ") || /:(?:\s|$)/u.test(value)) {
|
|
47
|
-
return undefined;
|
|
48
|
-
}
|
|
49
|
-
return value;
|
|
50
|
-
}
|
|
51
|
-
/** The entries of a one-line flow sequence, or `undefined` where one does not read. */
|
|
52
|
-
function flowOf(text) {
|
|
53
|
-
const inner = text.slice(1, -1).trim();
|
|
54
|
-
if (inner === "") {
|
|
55
|
-
return [];
|
|
56
|
-
}
|
|
57
|
-
const entries = inner.split(",");
|
|
58
|
-
if (entries.length > 1 && entries.at(-1)?.trim() === "") {
|
|
59
|
-
entries.pop();
|
|
60
|
-
}
|
|
61
|
-
const found = [];
|
|
62
|
-
for (const entry of entries) {
|
|
63
|
-
const value = scalarOf(entry);
|
|
64
|
-
if (value === undefined) {
|
|
65
|
-
return undefined;
|
|
66
|
-
}
|
|
67
|
-
found.push(value);
|
|
68
|
-
}
|
|
69
|
-
return found;
|
|
70
|
-
}
|
|
71
|
-
const KEY = /^(?:packages|'packages'|"packages")\s*:(?:\s(.*))?$/u;
|
|
72
|
-
/** The `packages` list one `pnpm-workspace.yaml` text declares. */
|
|
73
|
-
export function pnpmPackages(text) {
|
|
74
|
-
const lines = text.split(/\r?\n/u).map(uncommented);
|
|
75
|
-
const keys = lines.flatMap((line, at) => (KEY.test(line) ? [at] : []));
|
|
76
|
-
const [at] = keys;
|
|
77
|
-
if (at === undefined) {
|
|
78
|
-
return { kind: "absent" };
|
|
79
|
-
}
|
|
80
|
-
if (keys.length > 1) {
|
|
81
|
-
return { kind: "refused", reason: "the packages key is declared more than once" };
|
|
82
|
-
}
|
|
83
|
-
const rest = (KEY.exec(lines[at] ?? "")?.[1] ?? "").trim();
|
|
84
|
-
if (rest !== "") {
|
|
85
|
-
const listed = rest.startsWith("[") && rest.endsWith("]") ? flowOf(rest) : undefined;
|
|
86
|
-
return listed === undefined
|
|
87
|
-
? {
|
|
88
|
-
kind: "refused",
|
|
89
|
-
reason: `packages holds ${JSON.stringify(rest)}, not a sequence of strings`,
|
|
90
|
-
}
|
|
91
|
-
: { kind: "listed", patterns: listed };
|
|
92
|
-
}
|
|
93
|
-
const patterns = [];
|
|
94
|
-
for (const line of lines.slice(at + 1)) {
|
|
95
|
-
if (line.trim() === "") {
|
|
96
|
-
continue;
|
|
97
|
-
}
|
|
98
|
-
const item = /^(\s*)-(?:\s+(.*))?$/u.exec(line);
|
|
99
|
-
if (item === null) {
|
|
100
|
-
if (/^\s/u.test(line)) {
|
|
101
|
-
return {
|
|
102
|
-
kind: "refused",
|
|
103
|
-
reason: `packages holds ${JSON.stringify(line.trim())}, not a sequence item`,
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
break;
|
|
107
|
-
}
|
|
108
|
-
const value = scalarOf(item[2] ?? "");
|
|
109
|
-
if (value === undefined) {
|
|
110
|
-
return {
|
|
111
|
-
kind: "refused",
|
|
112
|
-
reason: `the packages item ${JSON.stringify(line.trim())} is not a plain or quoted string`,
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
patterns.push(value);
|
|
116
|
-
}
|
|
117
|
-
return patterns.length === 0
|
|
118
|
-
? { kind: "refused", reason: "packages holds no sequence" }
|
|
119
|
-
: { kind: "listed", patterns };
|
|
120
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A setup failure: a file or a component the analysis needs and the project does not
|
|
3
|
-
* provide. Each one names what is missing and the fix, on one line of the error stream
|
|
4
|
-
* that starts with its class.
|
|
5
|
-
*/
|
|
6
|
-
/** The failure as the one line of the error stream that names it. */
|
|
7
|
-
export function setupLine(failure) {
|
|
8
|
-
return `setup failure: ${failure.setupClass}: ${failure.detail}`;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* A run that met a setup failure where none may be dropped: in a configuration the
|
|
12
|
-
* configuration document or the scope declares, in a declared consumer, or in every
|
|
13
|
-
* configuration discovery derived. It ends the run with the failure code and no finding
|
|
14
|
-
* list.
|
|
15
|
-
*/
|
|
16
|
-
export class SetupError extends Error {
|
|
17
|
-
failures;
|
|
18
|
-
constructor(failures) {
|
|
19
|
-
super(failures.map(setupLine).join("\n"));
|
|
20
|
-
this.name = "SetupError";
|
|
21
|
-
this.failures = failures;
|
|
22
|
-
}
|
|
23
|
-
}
|
package/dist/src/test-joins.js
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The test files a derived matrix holds although no configuration's file list names them.
|
|
3
|
-
* The test runner compiles such a file with the options of the nearest compiler
|
|
4
|
-
* configuration at or above it, so the file joins that configuration's program as a file
|
|
5
|
-
* its list names, unless a `package.json` below that configuration's directory makes the
|
|
6
|
-
* file another package's, which its own test runner compiles.
|
|
7
|
-
*/
|
|
8
|
-
import { sourcePaths } from "./file-facts.js";
|
|
9
|
-
import { dirnamePath, joinPath, relativePath } from "./paths.js";
|
|
10
|
-
import { writtenPath } from "./workspace-programs.js";
|
|
11
|
-
const PREFERRED = "/tsconfig.json";
|
|
12
|
-
/** The configurations of one directory in the order a file joins them: `tsconfig.json` first. */
|
|
13
|
-
function byPreference(a, b) {
|
|
14
|
-
const first = a.endsWith(PREFERRED) ? 0 : 1;
|
|
15
|
-
const second = b.endsWith(PREFERRED) ? 0 : 1;
|
|
16
|
-
return first - second || (a < b ? -1 : a > b ? 1 : 0);
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Per configuration of `configFiles`, the absolute paths of the test files that join it:
|
|
20
|
-
* each file below `root` a pattern of `patterns` names, that no configuration's file list
|
|
21
|
-
* holds, joins the configuration nearest at or above its directory when no `package.json`
|
|
22
|
-
* sits between them. A configuration the compiler cannot read lists nothing and is joined
|
|
23
|
-
* by nothing.
|
|
24
|
-
*/
|
|
25
|
-
export function joinedTestFiles(engine, host, root, configFiles, patterns) {
|
|
26
|
-
const listed = new Set();
|
|
27
|
-
const byDir = new Map();
|
|
28
|
-
for (const configFile of configFiles) {
|
|
29
|
-
let fileNames;
|
|
30
|
-
try {
|
|
31
|
-
fileNames = engine.parseConfigFile(configFile).fileNames;
|
|
32
|
-
}
|
|
33
|
-
catch {
|
|
34
|
-
continue;
|
|
35
|
-
}
|
|
36
|
-
fileNames.forEach((name) => listed.add(name));
|
|
37
|
-
const dir = dirnamePath(configFile);
|
|
38
|
-
byDir.set(dir, [...(byDir.get(dir) ?? []), configFile].sort(byPreference));
|
|
39
|
-
}
|
|
40
|
-
const joins = new Map();
|
|
41
|
-
for (const path of sourcePaths(host, root)) {
|
|
42
|
-
const file = joinPath(root, path);
|
|
43
|
-
if (listed.has(file) || !patterns.some((pattern) => pattern.test(path))) {
|
|
44
|
-
continue;
|
|
45
|
-
}
|
|
46
|
-
for (let dir = dirnamePath(file);; dir = dirnamePath(dir)) {
|
|
47
|
-
const [nearest] = byDir.get(dir) ?? [];
|
|
48
|
-
if (nearest !== undefined) {
|
|
49
|
-
joins.set(nearest, [...(joins.get(nearest) ?? []), file]);
|
|
50
|
-
break;
|
|
51
|
-
}
|
|
52
|
-
if (host.kindOf(joinPath(dir, "package.json")) === "file" ||
|
|
53
|
-
dir === root ||
|
|
54
|
-
relativePath(root, dir) === undefined) {
|
|
55
|
-
break;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
return joins;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* How the snapshot reads each configuration a test file joins: the program `programs`
|
|
63
|
-
* describes with the files added to its root files, or a configuration only the snapshot
|
|
64
|
-
* holds that extends the one `programs` writes, or the configuration itself, and lists
|
|
65
|
-
* every file the configuration lists and the joined ones.
|
|
66
|
-
*/
|
|
67
|
-
export function withJoinedTests(engine, host, programs, joins) {
|
|
68
|
-
const found = new Map(programs);
|
|
69
|
-
for (const [configFile, files] of joins) {
|
|
70
|
-
const program = programs.get(configFile);
|
|
71
|
-
if (program?.kind === "program") {
|
|
72
|
-
found.set(configFile, {
|
|
73
|
-
kind: "program",
|
|
74
|
-
params: {
|
|
75
|
-
...program.params,
|
|
76
|
-
rootFiles: [...(program.params.rootFiles ?? []), ...files],
|
|
77
|
-
},
|
|
78
|
-
});
|
|
79
|
-
continue;
|
|
80
|
-
}
|
|
81
|
-
let listed;
|
|
82
|
-
try {
|
|
83
|
-
listed =
|
|
84
|
-
program?.kind === "configuration"
|
|
85
|
-
? engine.parseConfigJson(JSON.parse(program.text), program.file).fileNames
|
|
86
|
-
: engine.parseConfigFile(configFile).fileNames;
|
|
87
|
-
}
|
|
88
|
-
catch {
|
|
89
|
-
continue;
|
|
90
|
-
}
|
|
91
|
-
const value = program?.kind === "configuration"
|
|
92
|
-
? { ...JSON.parse(program.text), files: [...listed, ...files] }
|
|
93
|
-
: { extends: configFile, files: [...listed, ...files] };
|
|
94
|
-
found.set(configFile, {
|
|
95
|
-
kind: "configuration",
|
|
96
|
-
file: program?.kind === "configuration" ? program.file : writtenPath(host, configFile),
|
|
97
|
-
text: `${JSON.stringify({ ...value, include: [] }, null, 2)}\n`,
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
return found;
|
|
101
|
-
}
|
package/dist/src/version.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The Contract version this analyzer implements. It is the resolved value of
|
|
3
|
-
* `contract_version` when no configuration source supplies one, and it moves
|
|
4
|
-
* independently of the analyzer's own version, which is the one the host answers
|
|
5
|
-
* from the package the analyzer was installed from.
|
|
6
|
-
*/
|
|
7
|
-
export const CONTRACT_VERSION = "7.2.0";
|