@cplieger/deadset-ts 8.0.0-dev.14 → 8.0.0-dev.16
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/dist/src/alias-chain.js +2 -2
- package/dist/src/analysis.js +43 -38
- package/dist/src/commands/read.js +6 -7
- package/dist/src/conformance-record.js +1 -1
- package/dist/src/consumers.js +4 -2
- package/dist/src/contract/config.generated.js +1 -1
- package/dist/src/contract/contract.generated.js +120 -2
- package/dist/src/dependencies.js +81 -49
- package/dist/src/entries/build-scripts.js +222 -0
- package/dist/src/{configuration-files.js → entries/configuration-files.js} +20 -58
- package/dist/src/{convention-rows.js → entries/convention-rows.js} +120 -27
- package/dist/src/entries/conventions.js +739 -0
- package/dist/src/{html-entries.js → entries/html-entries.js} +3 -3
- package/dist/src/{mdx-entries.js → entries/mdx-entries.js} +2 -2
- package/dist/src/entries/run-directories.js +77 -0
- package/dist/src/entries/sources.js +144 -0
- package/dist/src/entries/static-module.js +669 -0
- package/dist/src/entries/test-runners.js +684 -0
- package/dist/src/{workflow-steps.js → entries/workflow-steps.js} +18 -8
- package/dist/src/extensions.js +37 -0
- package/dist/src/facts.js +38 -0
- package/dist/src/file-facts.js +1 -1
- package/dist/src/findings/emitters.js +5 -8
- package/dist/src/findings/self-check.js +36 -20
- package/dist/src/findings-pass.js +5 -6
- package/dist/src/framework-lifecycle.js +1 -1
- package/dist/src/fs/manifest.js +15 -20
- package/dist/src/generated-file.js +172 -29
- package/dist/src/graph.js +2 -5
- package/dist/src/index.js +1 -1
- package/dist/src/injection-container.js +1 -1
- package/dist/src/inventory/commonjs.js +507 -0
- package/dist/src/inventory/enumerate.js +167 -0
- package/dist/src/inventory/syntax.js +236 -0
- package/dist/src/inventory.js +305 -705
- package/dist/src/javascript-file.js +26 -11
- package/dist/src/load/classify.js +28 -9
- package/dist/src/load/diagnostics.js +8 -1
- package/dist/src/load/discover.js +16 -8
- package/dist/src/load/package-scope.js +56 -0
- package/dist/src/load/plan.js +2 -2
- package/dist/src/load/synthesize.js +5 -5
- package/dist/src/load/workspace-manifests.js +1 -1
- package/dist/src/matrix.js +6 -13
- package/dist/src/outside-tests.js +1 -1
- package/dist/src/paths.js +16 -0
- package/dist/src/platform-calls.js +78 -0
- package/dist/src/platform-symbols.js +140 -0
- package/dist/src/position.js +41 -0
- package/dist/src/ref.js +11 -20
- package/dist/src/references.js +281 -50
- package/dist/src/resolve.js +1 -1
- package/dist/src/{configured-declarations.js → roots/configured-declarations.js} +4 -4
- package/dist/src/{entry-point-gaps.js → roots/entry-point-gaps.js} +5 -8
- package/dist/src/{manifest.js → roots/manifest.js} +4 -4
- package/dist/src/roots/published-reach.js +412 -0
- package/dist/src/roots/root-set.js +489 -0
- package/dist/src/roots/unseen-loads.js +208 -0
- package/dist/src/serialization-contract.js +1 -1
- package/dist/src/session.js +3 -0
- package/dist/src/source-files.js +5 -9
- package/dist/src/suppress-inline.js +33 -81
- package/dist/src/suppress.js +30 -32
- package/dist/src/test-support.js +4 -2
- package/dist/src/verbs/analyze.js +13 -1
- package/dist/src/verbs/describe.js +5 -3
- package/jsr.json +1 -1
- package/package.json +3 -3
- package/src/alias-chain.ts +2 -2
- package/src/analysis.ts +77 -53
- package/src/automatic-types.ts +1 -1
- package/src/commands/read.ts +6 -8
- package/src/conformance-record.ts +1 -1
- package/src/consumers.ts +5 -1
- package/src/contract/config.generated.ts +1 -1
- package/src/contract/contract.generated.ts +139 -2
- package/src/dependencies.ts +98 -50
- package/src/entries/build-scripts.ts +292 -0
- package/src/{configuration-files.ts → entries/configuration-files.ts} +23 -75
- package/src/{convention-rows.ts → entries/convention-rows.ts} +167 -28
- package/src/{conventions.ts → entries/conventions.ts} +347 -522
- package/src/{html-entries.ts → entries/html-entries.ts} +5 -5
- package/src/{mdx-entries.ts → entries/mdx-entries.ts} +4 -4
- package/src/entries/run-directories.ts +108 -0
- package/src/entries/sources.ts +266 -0
- package/src/entries/static-module.ts +857 -0
- package/src/entries/test-runners.ts +868 -0
- package/src/{workflow-steps.ts → entries/workflow-steps.ts} +29 -11
- package/src/exempt.ts +3 -2
- package/src/extensions.ts +45 -0
- package/src/facts.ts +44 -0
- package/src/file-facts.ts +2 -2
- package/src/findings/emitters.ts +14 -10
- package/src/findings/self-check.ts +41 -22
- package/src/findings/visibility-narrowing.ts +1 -1
- package/src/findings-pass.ts +5 -12
- package/src/framework-lifecycle.ts +1 -1
- package/src/fs/manifest.ts +25 -21
- package/src/generated-file.ts +240 -36
- package/src/graph.ts +3 -6
- package/src/index.ts +1 -1
- package/src/injection-container.ts +1 -1
- package/src/inventory/commonjs.ts +696 -0
- package/src/inventory/enumerate.ts +203 -0
- package/src/inventory/syntax.ts +311 -0
- package/src/inventory.ts +424 -878
- package/src/javascript-file.ts +29 -12
- package/src/load/classify.ts +49 -13
- package/src/load/diagnostics.ts +11 -1
- package/src/load/discover.ts +28 -12
- package/src/load/package-scope.ts +74 -0
- package/src/load/plan.ts +11 -2
- package/src/load/synthesize.ts +6 -6
- package/src/load/test-globals.ts +1 -1
- package/src/load/workspace-manifests.ts +1 -1
- package/src/load/workspace-run.ts +1 -1
- package/src/matrix.ts +7 -14
- package/src/outside-tests.ts +1 -1
- package/src/paths.ts +18 -0
- package/src/platform-calls.ts +119 -0
- package/src/platform-symbols.ts +205 -0
- package/src/position.ts +42 -0
- package/src/ref.ts +11 -20
- package/src/references.ts +383 -73
- package/src/report.ts +1 -1
- package/src/resolve.ts +1 -1
- package/src/{configured-declarations.ts → roots/configured-declarations.ts} +7 -7
- package/src/{entry-point-gaps.ts → roots/entry-point-gaps.ts} +5 -8
- package/src/{manifest.ts → roots/manifest.ts} +5 -5
- package/src/roots/published-reach.ts +481 -0
- package/src/{roots.ts → roots/root-set.ts} +203 -630
- package/src/roots/unseen-loads.ts +307 -0
- package/src/serialization-contract.ts +1 -1
- package/src/session.ts +17 -1
- package/src/source-files.ts +5 -10
- package/src/suppress-inline.ts +53 -89
- package/src/suppress.ts +48 -33
- package/src/test-support.ts +8 -3
- package/src/verbs/analyze.ts +17 -4
- package/src/verbs/describe.ts +5 -2
- package/src/verbs/explain.ts +1 -1
- package/dist/src/build-scripts.js +0 -418
- package/dist/src/conventions.js +0 -907
- package/dist/src/entry-points.js +0 -513
- package/dist/src/roots.js +0 -865
- package/dist/src/unseen-loads.js +0 -100
- package/src/build-scripts.ts +0 -536
- package/src/entry-points.ts +0 -661
- package/src/unseen-loads.ts +0 -134
package/src/generated-file.ts
CHANGED
|
@@ -2,12 +2,25 @@
|
|
|
2
2
|
* The generated-file class on TypeScript: every declaration in a file that marks itself
|
|
3
3
|
* generated, below a directory an applied convention row names as generated, or minified,
|
|
4
4
|
* is retained, because a generator owns the file and a deletion there is undone at the next
|
|
5
|
-
* generation.
|
|
5
|
+
* generation. The same decision is each `generated` entry of the facts document.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import {
|
|
9
|
+
isIdentifier,
|
|
10
|
+
isImportDeclaration,
|
|
11
|
+
isPropertyAssignment,
|
|
12
|
+
isStringLiteralLikeNode,
|
|
13
|
+
isVariableStatement,
|
|
14
|
+
NodeFlags,
|
|
15
|
+
type Node,
|
|
16
|
+
type SourceFile,
|
|
17
|
+
} from "@typescript/native/ast";
|
|
18
|
+
import { GENERATORS } from "./contract/contract.generated.ts";
|
|
8
19
|
import type { DetectorInput, Evidence } from "./exempt.ts";
|
|
9
|
-
import {
|
|
20
|
+
import { minifiedBy } from "./javascript-file.ts";
|
|
10
21
|
import type { SourceFiles } from "./source-files.ts";
|
|
22
|
+
import { bytewise } from "./text/compare.ts";
|
|
23
|
+
import { satisfies } from "./version-range.ts";
|
|
11
24
|
|
|
12
25
|
/** The generated-code header, matched against each line of a leading comment. */
|
|
13
26
|
const HEADER_LINE = /^\/\/ Code generated .* DO NOT EDIT\.$/u;
|
|
@@ -24,9 +37,44 @@ const GENERATED_WORD = /\bgenerated\b/iu;
|
|
|
24
37
|
/** The phrases a generator's notice asks a reader not to edit the file by. */
|
|
25
38
|
const KEEP_OUT = /\b(?:do not edit|will be overwritten|should not make any changes)\b/iu;
|
|
26
39
|
|
|
27
|
-
/**
|
|
28
|
-
|
|
29
|
-
|
|
40
|
+
/** What decided a file generated, as the facts document's `evidence` names it. */
|
|
41
|
+
type GeneratedEvidence = "header" | "tag" | "notice" | "convention" | "minified";
|
|
42
|
+
|
|
43
|
+
/** The generator row one generated file matches, with the version and the schema files its output states. */
|
|
44
|
+
interface GeneratorMatch {
|
|
45
|
+
readonly row: string;
|
|
46
|
+
readonly version?: string;
|
|
47
|
+
readonly schemaFiles: readonly string[];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Why one file is generated, and which generator wrote it. */
|
|
51
|
+
export interface GeneratedFact {
|
|
52
|
+
readonly evidence: GeneratedEvidence;
|
|
53
|
+
/** The 1-based line of the comment line that marks the file; 1 for a row or a minified file. */
|
|
54
|
+
readonly line: number;
|
|
55
|
+
/** The marking line's text, the convention row's name, or what decided the file minified. */
|
|
56
|
+
readonly detail: string;
|
|
57
|
+
readonly generator?: GeneratorMatch;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** One line of a leading comment, with its 1-based line in the file. */
|
|
61
|
+
interface CommentLine {
|
|
62
|
+
readonly text: string;
|
|
63
|
+
readonly line: number;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** The comments before a text's first token, a leading hashbang line skipped, each as its lines. */
|
|
67
|
+
function leadingComments(text: string): readonly (readonly CommentLine[])[] {
|
|
68
|
+
const comments: CommentLine[][] = [];
|
|
69
|
+
const lineAt = (offset: number): number =>
|
|
70
|
+
text.slice(0, offset).split(/\r\n|[\n\r\u2028\u2029]/u).length;
|
|
71
|
+
const lines = (from: number, to: number): CommentLine[] => {
|
|
72
|
+
const first = lineAt(from);
|
|
73
|
+
return text
|
|
74
|
+
.slice(from, to)
|
|
75
|
+
.split(/\r\n|[\n\r\u2028\u2029]/u)
|
|
76
|
+
.map((one, index) => ({ text: one, line: first + index }));
|
|
77
|
+
};
|
|
30
78
|
let at = text.startsWith("\uFEFF") ? 1 : 0;
|
|
31
79
|
if (text.startsWith("#!", at)) {
|
|
32
80
|
const end = text.indexOf("\n", at);
|
|
@@ -39,14 +87,14 @@ function leadingComments(text: string): readonly string[] {
|
|
|
39
87
|
if (text.startsWith("//", at)) {
|
|
40
88
|
const end = text.slice(at).search(/[\r\n\u2028\u2029]/u);
|
|
41
89
|
const stop = end === -1 ? text.length : at + end;
|
|
42
|
-
comments.push(
|
|
90
|
+
comments.push(lines(at, stop));
|
|
43
91
|
at = stop;
|
|
44
92
|
} else if (text.startsWith("/*", at)) {
|
|
45
93
|
const end = text.indexOf("*/", at + 2);
|
|
46
94
|
if (end === -1) {
|
|
47
95
|
return comments;
|
|
48
96
|
}
|
|
49
|
-
comments.push(
|
|
97
|
+
comments.push(lines(at, end + 2));
|
|
50
98
|
at = end + 2;
|
|
51
99
|
} else {
|
|
52
100
|
return comments;
|
|
@@ -54,51 +102,201 @@ function leadingComments(text: string): readonly string[] {
|
|
|
54
102
|
}
|
|
55
103
|
}
|
|
56
104
|
|
|
57
|
-
/** The
|
|
58
|
-
export function
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
105
|
+
/** The mark one file's leading comments make it generated by, or undefined where they mark nothing. */
|
|
106
|
+
export function generatedMark(text: string): Omit<GeneratedFact, "generator"> | undefined {
|
|
107
|
+
const lines = leadingComments(text).flat();
|
|
108
|
+
const header = lines.find((one) => HEADER_LINE.test(one.text));
|
|
109
|
+
if (header !== undefined) {
|
|
110
|
+
return { evidence: "header", line: header.line, detail: header.text };
|
|
111
|
+
}
|
|
112
|
+
const tag = lines.find((one) => GENERATED_TAG.test(one.text));
|
|
113
|
+
if (tag !== undefined) {
|
|
114
|
+
return { evidence: "tag", line: tag.line, detail: tag.text };
|
|
62
115
|
}
|
|
63
|
-
|
|
64
|
-
|
|
116
|
+
const [first] = lines;
|
|
117
|
+
if (first !== undefined && GENERATED_BY.test(first.text)) {
|
|
118
|
+
return { evidence: "notice", line: first.line, detail: first.text };
|
|
65
119
|
}
|
|
66
|
-
const notice =
|
|
67
|
-
if (
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
120
|
+
const notice = lines.map((one) => one.text).join("\n");
|
|
121
|
+
if (GENERATED_WORD.test(notice) && KEEP_OUT.test(notice)) {
|
|
122
|
+
const marked = lines.find((one) => GENERATED_WORD.test(one.text) || KEEP_OUT.test(one.text));
|
|
123
|
+
return marked === undefined
|
|
124
|
+
? undefined
|
|
125
|
+
: { evidence: "notice", line: marked.line, detail: marked.text };
|
|
126
|
+
}
|
|
127
|
+
return undefined;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** What one form's first group captures, for each line the form matches. */
|
|
131
|
+
function after(lines: readonly CommentLine[], form: RegExp): readonly string[] {
|
|
132
|
+
return lines.flatMap((one) => form.exec(one.text)?.[1] ?? []);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Where each plugin's output states its version and its schema files, as `references-ts.36`
|
|
137
|
+
* states: a plugin missing here states no version, and one with no schema form names none.
|
|
138
|
+
*/
|
|
139
|
+
const STATEMENTS: Readonly<Record<string, { version?: RegExp; schemaFiles?: RegExp }>> = {
|
|
140
|
+
"protoc-gen-es": {
|
|
141
|
+
version: /^\/\/ @generated by protoc-gen-es (\S+)/u,
|
|
142
|
+
schemaFiles: /^\/\/ @generated from file (\S+)/u,
|
|
143
|
+
},
|
|
144
|
+
"protoc-gen-connect-es": {
|
|
145
|
+
version: /^\/\/ @generated by protoc-gen-connect-es (\S+)/u,
|
|
146
|
+
schemaFiles: /^\/\/ @generated from file (\S+)/u,
|
|
147
|
+
},
|
|
148
|
+
"protobuf-ts": {
|
|
149
|
+
version: /^\/\/ @generated by protobuf-ts (\S+)/u,
|
|
150
|
+
schemaFiles: /^\/\/ @generated from protobuf file "([^"]+)"/u,
|
|
151
|
+
},
|
|
152
|
+
"ts-proto": {
|
|
153
|
+
version: /^\/\/\s+protoc-gen-ts_proto\s+(\S+)$/u,
|
|
154
|
+
schemaFiles: /^\/\/ source: (.+)$/u,
|
|
155
|
+
},
|
|
156
|
+
"protoc-gen-grpc-web": {
|
|
157
|
+
version: /^\/\/\s+protoc-gen-grpc-web\s+(\S+)$/u,
|
|
158
|
+
schemaFiles: /^\/\/ source: (.+)$/u,
|
|
159
|
+
},
|
|
160
|
+
"protoc-gen-js": { schemaFiles: /^\/\/ source: (.+)$/u },
|
|
161
|
+
"ts-protoc-gen": { schemaFiles: /^\/\/ file: (.+)$/u },
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
/** A ts-proto service path literal: `/<package>.<service>/<method>`. */
|
|
165
|
+
const SERVICE_PATH = /^\/(?:\w+\.)+\w+\/\w+$/u;
|
|
166
|
+
|
|
167
|
+
/** Whether one ts-proto file writes a service path, as `references-ts.36` reads one. */
|
|
168
|
+
function writesServicePath(file: SourceFile): boolean {
|
|
169
|
+
const named = file.statements.some(
|
|
170
|
+
(statement) =>
|
|
171
|
+
isVariableStatement(statement) &&
|
|
172
|
+
(statement.declarationList.flags & NodeFlags.Const) !== 0 &&
|
|
173
|
+
statement.declarationList.declarations.some(
|
|
174
|
+
(one) =>
|
|
175
|
+
isIdentifier(one.name) &&
|
|
176
|
+
one.name.text.endsWith("ServiceName") &&
|
|
177
|
+
one.initializer !== undefined &&
|
|
178
|
+
isStringLiteralLikeNode(one.initializer),
|
|
179
|
+
),
|
|
180
|
+
);
|
|
181
|
+
let found = named;
|
|
182
|
+
const visit = (node: Node): void => {
|
|
183
|
+
if (found) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
if (
|
|
187
|
+
isPropertyAssignment(node) &&
|
|
188
|
+
isIdentifier(node.name) &&
|
|
189
|
+
node.name.text === "path" &&
|
|
190
|
+
isStringLiteralLikeNode(node.initializer) &&
|
|
191
|
+
SERVICE_PATH.test(node.initializer.text)
|
|
192
|
+
) {
|
|
193
|
+
found = true;
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
node.forEachChild(visit);
|
|
197
|
+
};
|
|
198
|
+
file.forEachChild(visit);
|
|
199
|
+
return found;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/** Whether one file imports a module by its specifier. */
|
|
203
|
+
function imports(file: SourceFile, module: string): boolean {
|
|
204
|
+
return file.statements.some(
|
|
205
|
+
(statement) =>
|
|
206
|
+
isImportDeclaration(statement) &&
|
|
207
|
+
isStringLiteralLikeNode(statement.moduleSpecifier) &&
|
|
208
|
+
statement.moduleSpecifier.text === module,
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/** The option sets the rows of `references-ts.36` name, by row; every other row's is met by any output. */
|
|
213
|
+
const OPTION_SETS: Readonly<Record<string, (file: SourceFile) => boolean>> = {
|
|
214
|
+
"ts-proto-2-output-schema": (file) => imports(file, "ts-proto-descriptors"),
|
|
215
|
+
"ts-proto-2": writesServicePath,
|
|
216
|
+
"ts-proto-2-types": (file) => !writesServicePath(file),
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
/** The first generator row one file matches, in `generators.json`'s order, as `bindings.3` reads it. */
|
|
220
|
+
export function generatorOf(file: SourceFile): GeneratorMatch | undefined {
|
|
221
|
+
const lines = leadingComments(file.text).flat();
|
|
222
|
+
for (const row of GENERATORS) {
|
|
223
|
+
const header = new RegExp(row.header, "u");
|
|
224
|
+
if (!lines.some((one) => header.test(one.text))) {
|
|
225
|
+
continue;
|
|
226
|
+
}
|
|
227
|
+
const statements = STATEMENTS[row.plugin] ?? {};
|
|
228
|
+
const [version] = statements.version === undefined ? [] : after(lines, statements.version);
|
|
229
|
+
if (
|
|
230
|
+
"versions" in row &&
|
|
231
|
+
(version === undefined ||
|
|
232
|
+
!satisfies(
|
|
233
|
+
version.replace(/^v/u, ""),
|
|
234
|
+
`>=${row.versions.min.replace(/^v/u, "")} <=${row.versions.max.replace(/^v/u, "")}`,
|
|
235
|
+
))
|
|
236
|
+
) {
|
|
237
|
+
continue;
|
|
238
|
+
}
|
|
239
|
+
if (OPTION_SETS[row.id]?.(file) === false) {
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
242
|
+
const schemaFiles =
|
|
243
|
+
statements.schemaFiles === undefined
|
|
244
|
+
? []
|
|
245
|
+
: [
|
|
246
|
+
...new Set(
|
|
247
|
+
after(lines, statements.schemaFiles).filter((one) => one.endsWith(".proto")),
|
|
248
|
+
),
|
|
249
|
+
].sort(bytewise);
|
|
250
|
+
return { row: row.id, ...(version === undefined ? {} : { version }), schemaFiles };
|
|
72
251
|
}
|
|
73
252
|
return undefined;
|
|
74
253
|
}
|
|
75
254
|
|
|
76
255
|
/**
|
|
77
|
-
* Every own file of one project that is generated, by its path below the target root,
|
|
78
|
-
*
|
|
79
|
-
*
|
|
256
|
+
* Every own file of one project that is generated, by its path below the target root, with
|
|
257
|
+
* what decided it: its leading comments' mark, else the row naming its directory as
|
|
258
|
+
* generated, else its minified name or text; and the generator row it matches.
|
|
80
259
|
*/
|
|
81
260
|
export function generatedFilesOf(
|
|
82
261
|
files: SourceFiles,
|
|
83
262
|
byRow: ReadonlyMap<string, string>,
|
|
84
|
-
): ReadonlyMap<string,
|
|
85
|
-
const found = new Map<string,
|
|
263
|
+
): ReadonlyMap<string, GeneratedFact> {
|
|
264
|
+
const found = new Map<string, GeneratedFact>();
|
|
86
265
|
for (const [path, file] of files.byPath) {
|
|
87
266
|
const row = byRow.get(path);
|
|
88
|
-
const
|
|
89
|
-
|
|
267
|
+
const minified = row === undefined ? minifiedBy(file.fileName, file.text) : undefined;
|
|
268
|
+
const fact =
|
|
269
|
+
generatedMark(file.text) ??
|
|
90
270
|
(row === undefined
|
|
91
|
-
? minified
|
|
92
|
-
?
|
|
93
|
-
:
|
|
94
|
-
:
|
|
95
|
-
if (
|
|
96
|
-
|
|
271
|
+
? minified === undefined
|
|
272
|
+
? undefined
|
|
273
|
+
: { evidence: "minified" as const, line: 1, detail: minified }
|
|
274
|
+
: { evidence: "convention" as const, line: 1, detail: row });
|
|
275
|
+
if (fact === undefined) {
|
|
276
|
+
continue;
|
|
97
277
|
}
|
|
278
|
+
const generator = generatorOf(file);
|
|
279
|
+
found.set(path, generator === undefined ? fact : { ...fact, generator });
|
|
98
280
|
}
|
|
99
281
|
return found;
|
|
100
282
|
}
|
|
101
283
|
|
|
284
|
+
/** The detail a retention in a generated file names, from what decided the file. */
|
|
285
|
+
function retentionDetail(fact: GeneratedFact): string {
|
|
286
|
+
switch (fact.evidence) {
|
|
287
|
+
case "header":
|
|
288
|
+
return "generated by the header line its leading comments hold";
|
|
289
|
+
case "tag":
|
|
290
|
+
return "generated by the @generated tag its leading comments hold";
|
|
291
|
+
case "notice":
|
|
292
|
+
return "generated by the notice its leading comments hold";
|
|
293
|
+
case "convention":
|
|
294
|
+
return `generated below a directory the convention row ${fact.detail} names`;
|
|
295
|
+
case "minified":
|
|
296
|
+
return "generated as a minified JavaScript file";
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
102
300
|
/** The generated-file detector, recording each file's first line. */
|
|
103
301
|
export function generatedFile<Brand>(input: DetectorInput<Brand>): readonly Evidence[] {
|
|
104
302
|
const generated = input.generated;
|
|
@@ -106,9 +304,15 @@ export function generatedFile<Brand>(input: DetectorInput<Brand>): readonly Evid
|
|
|
106
304
|
return [];
|
|
107
305
|
}
|
|
108
306
|
return input.held.symbols.flatMap((symbol): Evidence[] => {
|
|
109
|
-
const
|
|
110
|
-
return symbol.kind === "file" ||
|
|
307
|
+
const fact = generated.get(symbol.position.path);
|
|
308
|
+
return symbol.kind === "file" || fact === undefined
|
|
111
309
|
? []
|
|
112
|
-
: [
|
|
310
|
+
: [
|
|
311
|
+
{
|
|
312
|
+
id: symbol.id,
|
|
313
|
+
detail: retentionDetail(fact),
|
|
314
|
+
site: { path: symbol.position.path, line: 1, column: 1 },
|
|
315
|
+
},
|
|
316
|
+
];
|
|
113
317
|
});
|
|
114
318
|
}
|
package/src/graph.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import type { InventorySymbol, SymbolKind } from "./inventory.ts";
|
|
9
9
|
import type { Reference } from "./references.ts";
|
|
10
|
-
import type { Root, RootKind } from "./roots.ts";
|
|
10
|
+
import type { Root, RootKind } from "./roots/root-set.ts";
|
|
11
11
|
|
|
12
12
|
/** The position of a declaration the inventory does not hold. */
|
|
13
13
|
export const OUTSIDE = -1;
|
|
@@ -39,8 +39,8 @@ const SWEPT: Readonly<Record<SymbolKind, boolean>> = {
|
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
41
|
* Whether a root of each kind names a caller, which holds it live under both relations: a
|
|
42
|
-
* tool reads what it loads and what its strings name, a runtime runs a test
|
|
43
|
-
*
|
|
42
|
+
* tool reads what it loads and what its strings name, a runtime runs a test or setup
|
|
43
|
+
* file, a page's module script, a command, a script or a workflow step, the manifest
|
|
44
44
|
* names what enters the package, an alias global stands for its export, an outside
|
|
45
45
|
* declaration names a global interface merging into it, and an entry file, a configured root
|
|
46
46
|
* and a pattern assert a caller. A published API supposes a consumer: reachability alone.
|
|
@@ -61,11 +61,8 @@ const NAMES_A_CALLER: Readonly<Record<RootKind, boolean>> = {
|
|
|
61
61
|
"configuration-string": true,
|
|
62
62
|
"bundler-entry": true,
|
|
63
63
|
"test-runner": true,
|
|
64
|
-
"browser-tests": true,
|
|
65
|
-
worker: true,
|
|
66
64
|
"html-entry": true,
|
|
67
65
|
"workflow-step": true,
|
|
68
|
-
"computed-import": true,
|
|
69
66
|
"document-import": true,
|
|
70
67
|
};
|
|
71
68
|
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { run, SETTING_OPTIONS, type Writer } from "./run.ts";
|
|
2
2
|
export type { DirectoryEntry, Host, PathKind, TemporaryDirectory } from "./host.ts";
|
|
3
|
-
export { DECLINED_CONVENTIONS, type DeclinedConvention } from "./entry-point-gaps.ts";
|
|
3
|
+
export { DECLINED_CONVENTIONS, type DeclinedConvention } from "./roots/entry-point-gaps.ts";
|
|
4
4
|
export {
|
|
5
5
|
byPosition,
|
|
6
6
|
positionKey,
|
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
resolveEntries,
|
|
28
28
|
spelledEntry,
|
|
29
29
|
type ResolvedEntry,
|
|
30
|
-
} from "./configured-declarations.ts";
|
|
30
|
+
} from "./roots/configured-declarations.ts";
|
|
31
31
|
import type { DetectorInput, Evidence } from "./exempt.ts";
|
|
32
32
|
import { isParameterProperty, nodeKey } from "./inventory.ts";
|
|
33
33
|
import { renderPosition } from "./position.ts";
|