@tayomi/deterministic-gates 0.6.0 → 0.7.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/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/catalog/angular.json +28 -4
- package/catalog/index.html +34 -8
- package/catalog/typescript.json +4 -3
- package/dist/src/core/check.js +4 -2
- package/dist/src/core/config.js +10 -4
- package/dist/src/core/run.js +38 -22
- package/dist/src/core/watch.js +219 -83
- package/dist/src/helpers/angular-watch.js +46 -13
- package/dist/src/helpers/template-errors.js +85 -0
- package/dist/src/helpers/tsc.js +1 -1
- package/dist/src/helpers/type-errors.js +22 -14
- package/package.json +1 -1
- package/src/core/check.ts +4 -2
- package/src/core/config.ts +14 -4
- package/src/core/run.ts +55 -23
- package/src/core/watch.ts +229 -79
- package/src/helpers/angular-watch.ts +39 -13
- package/src/helpers/template-errors.ts +101 -0
- package/src/helpers/tsc.ts +1 -1
- package/src/helpers/type-errors.ts +35 -15
|
@@ -26,27 +26,47 @@ function cut(text: string, chars: number): string {
|
|
|
26
26
|
return text.length > chars ? `${text.slice(0, chars)}…` : text;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
/** An error of a file, as a strict gate compares it: its source line is the text of the line it points at. */
|
|
30
|
+
export interface StrictError {
|
|
31
|
+
file: string;
|
|
32
|
+
code: string;
|
|
33
|
+
source: string;
|
|
34
|
+
message: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The errors, each on one line: a key, its file, code and source line, with a count after one its file already has
|
|
39
|
+
* on the same source; then, after a tab, the first line of its message. An error of no file is kept as it is.
|
|
40
|
+
*/
|
|
41
|
+
export function strictErrorLines(errors: (StrictError | string)[]): string[] {
|
|
42
|
+
const seen = new Map<string, number>();
|
|
43
|
+
return errors.map((error) => {
|
|
44
|
+
const source = typeof error === "string" ? "" : error.source.replaceAll("\t", " ").trim();
|
|
45
|
+
const found =
|
|
46
|
+
typeof error === "string" ? error : `${error.file}: error ${error.code} at \`${cut(source, SOURCE_CHARS)}\``;
|
|
47
|
+
const count = (seen.get(found) ?? 0) + 1;
|
|
48
|
+
seen.set(found, count);
|
|
49
|
+
const key = count === 1 ? found : `${found} (${count})`;
|
|
50
|
+
return typeof error === "string" ? key : `${key}\t${cut(error.message, MESSAGE_CHARS)}`;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
29
54
|
/** The errors tsc printed, each on one line, as the gate compares them. */
|
|
30
55
|
export function typeErrors(printed: string[], sources: Sources): string[] {
|
|
31
56
|
const lines = new Map<string, string[]>();
|
|
32
57
|
const sourceLine = (file: string, line: number) => {
|
|
33
58
|
if (!lines.has(file)) lines.set(file, (sources(file) ?? "").split("\n"));
|
|
34
|
-
return
|
|
59
|
+
return lines.get(file)?.[line - 1] ?? "";
|
|
35
60
|
};
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
seen.set(found, count);
|
|
46
|
-
const key = count === 1 ? found : `${found} (${count})`;
|
|
47
|
-
errors.push(file === undefined ? key : `${key}\t${cut(message, MESSAGE_CHARS)}`);
|
|
48
|
-
}
|
|
49
|
-
return errors;
|
|
61
|
+
return strictErrorLines(
|
|
62
|
+
printed
|
|
63
|
+
// The lines under an error explain it, and name its first failing member.
|
|
64
|
+
.filter((line) => line.trim() && !/^\s/.test(line))
|
|
65
|
+
.map((line) => {
|
|
66
|
+
const [, file, at, code = "", message = ""] = POSITION.exec(line) ?? [];
|
|
67
|
+
return file === undefined ? line : { file, code, source: sourceLine(file, Number(at)), message };
|
|
68
|
+
}),
|
|
69
|
+
);
|
|
50
70
|
}
|
|
51
71
|
|
|
52
72
|
/** What to print for each line of tsc in watch mode: nothing until a compilation ends, then its errors. */
|