@flytedesk/app-kit 11.2.0 → 11.4.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 +26 -0
- package/dist/auth/guards.d.ts +4 -0
- package/dist/auth/guards.js +22 -0
- package/dist/auth/guards.js.map +1 -1
- package/dist/auth/index.d.ts +1 -1
- package/dist/auth/index.js +1 -1
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/prisma/index.d.ts +1 -0
- package/dist/auth/prisma/index.js +2 -0
- package/dist/auth/prisma/index.js.map +1 -0
- package/dist/auth/prisma/prismaAuthStore.d.ts +181 -0
- package/dist/auth/prisma/prismaAuthStore.js +273 -0
- package/dist/auth/prisma/prismaAuthStore.js.map +1 -0
- package/dist/cli/auth-sync.d.ts +2 -0
- package/dist/cli/auth-sync.js +23 -0
- package/dist/cli/auth-sync.js.map +1 -0
- package/dist/csv/index.d.ts +19 -0
- package/dist/csv/index.js +36 -0
- package/dist/csv/index.js.map +1 -0
- package/dist/repo-check/checkNarration.d.ts +13 -0
- package/dist/repo-check/checkNarration.js +346 -0
- package/dist/repo-check/checkNarration.js.map +1 -0
- package/dist/repo-check/checkNoNul.d.ts +3 -0
- package/dist/repo-check/checkNoNul.js +35 -0
- package/dist/repo-check/checkNoNul.js.map +1 -0
- package/dist/repo-check/cli.d.ts +9 -0
- package/dist/repo-check/cli.js +103 -0
- package/dist/repo-check/cli.js.map +1 -0
- package/dist/repo-check/config.d.ts +13 -0
- package/dist/repo-check/config.js +39 -0
- package/dist/repo-check/config.js.map +1 -0
- package/dist/repo-check/repoFiles.d.ts +8 -0
- package/dist/repo-check/repoFiles.js +44 -0
- package/dist/repo-check/repoFiles.js.map +1 -0
- package/dist/repo-check/repoHygiene.d.ts +5 -0
- package/dist/repo-check/repoHygiene.js +12 -0
- package/dist/repo-check/repoHygiene.js.map +1 -0
- package/dist/repo-check/scriptComments.d.ts +28 -0
- package/dist/repo-check/scriptComments.js +243 -0
- package/dist/repo-check/scriptComments.js.map +1 -0
- package/dist/spa-server/index.d.ts +25 -0
- package/dist/spa-server/index.js +35 -2
- package/dist/spa-server/index.js.map +1 -1
- package/package.json +14 -2
- package/prisma/fragments/auth.meta.json +4 -0
- package/prisma/fragments/auth.prisma +75 -0
- package/prisma/migrations/0004_app_kit_auth_init/migration.sql +47 -0
- package/prisma/migrations/manifest.json +7 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CSV text, written once for every export in the app. RFC 4180 (CRLF between records, a field holding a comma, a quote or a
|
|
3
|
+
* line break is double-quoted, a quote inside it is doubled) plus the OWASP CSV-injection guard: a cell whose first character is
|
|
4
|
+
* `=`, `+`, `-`, `@`, a tab or a carriage return is a formula the moment a spreadsheet opens the file, so it gets a leading
|
|
5
|
+
* single quote that makes it plain text. The guard runs before the quoting, so a cell that is both a formula and holds a comma
|
|
6
|
+
* comes out defused and quoted.
|
|
7
|
+
*/
|
|
8
|
+
const CSV_INJECTION_TRIGGER = /^[=+\-@\t\r]/;
|
|
9
|
+
const NEEDS_QUOTING = /[",\r\n]/;
|
|
10
|
+
/** One cell quoted as RFC 4180 asks, its text otherwise exactly as given: for a file our own code reads back, where the
|
|
11
|
+
* formula guard below would change the value (a phone number written `+1 555 ...` would be read as `'+1 555 ...`). */
|
|
12
|
+
export function csvQuote(value) {
|
|
13
|
+
if (!NEEDS_QUOTING.test(value))
|
|
14
|
+
return value;
|
|
15
|
+
return `"${value.replace(/"/g, '""')}"`;
|
|
16
|
+
}
|
|
17
|
+
/** One cell, defused and quoted. */
|
|
18
|
+
export function csvCell(value) {
|
|
19
|
+
return csvQuote(CSV_INJECTION_TRIGGER.test(value) ? `'${value}` : value);
|
|
20
|
+
}
|
|
21
|
+
/** One record, without its line break. */
|
|
22
|
+
export function csvLine(cells) {
|
|
23
|
+
return cells.map(csvCell).join(",");
|
|
24
|
+
}
|
|
25
|
+
/** A whole file from its rendered lines: every one followed by CRLF, the last one included. */
|
|
26
|
+
const csvLines = (lines) => lines.map((line) => `${line}\r\n`).join("");
|
|
27
|
+
/** A whole file: every record followed by CRLF, the last one included. */
|
|
28
|
+
export function csvDocument(records) {
|
|
29
|
+
return csvLines(records.map(csvLine));
|
|
30
|
+
}
|
|
31
|
+
/** A whole file for our own code to read back: the records and line breaks of `csvDocument`, its cells quoted by `csvQuote`
|
|
32
|
+
* alone so a value such as a phone number written `+1 555 ...` reaches the reader exactly as given. */
|
|
33
|
+
export function csvReadBackDocument(records) {
|
|
34
|
+
return csvLines(records.map((record) => record.map(csvQuote).join(",")));
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/csv/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,qBAAqB,GAAG,cAAc,CAAC;AAC7C,MAAM,aAAa,GAAG,UAAU,CAAC;AAEjC;uHACuH;AACvH,MAAM,UAAU,QAAQ,CAAC,KAAa;IACpC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAC7C,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC;AAC1C,CAAC;AAED,oCAAoC;AACpC,MAAM,UAAU,OAAO,CAAC,KAAa;IACnC,OAAO,QAAQ,CAAC,qBAAqB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AAC3E,CAAC;AAED,0CAA0C;AAC1C,MAAM,UAAU,OAAO,CAAC,KAAwB;IAC9C,OAAO,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACtC,CAAC;AAED,+FAA+F;AAC/F,MAAM,QAAQ,GAAG,CAAC,KAAwB,EAAU,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,IAAI,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAEnG,0EAA0E;AAC1E,MAAM,UAAU,WAAW,CAAC,OAAuC;IACjE,OAAO,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;AACxC,CAAC;AAED;wGACwG;AACxG,MAAM,UAAU,mBAAmB,CAAC,OAAuC;IACzE,OAAO,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAC3E,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { RepoCheckConfig } from "./config.js";
|
|
2
|
+
export declare const NARRATION_PATTERN: RegExp;
|
|
3
|
+
export interface NarrationHit {
|
|
4
|
+
file: string;
|
|
5
|
+
line: number;
|
|
6
|
+
match: string;
|
|
7
|
+
}
|
|
8
|
+
/** Scans every source file under `rootDir` for `NARRATION_PATTERN`, inside
|
|
9
|
+
* comments and test titles only (see `extractFragments`). A match listed in
|
|
10
|
+
* `config.narrationAllowlist` is skipped; a file whose basename is in
|
|
11
|
+
* `config.narrationExcludedBasenames` is not read (a checker's own module and
|
|
12
|
+
* test spell out the forbidden patterns as data). */
|
|
13
|
+
export declare function scanForNarration(rootDir: string, config: RepoCheckConfig): NarrationHit[];
|
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fails when a source file's comments or test titles carry review/checklist
|
|
3
|
+
* narration that reads fine the day it's written and rots the moment the
|
|
4
|
+
* thing it names is renumbered or resolved:
|
|
5
|
+
* - a bare review-item code, the "K5:"/"R1:"/"(S3)"/"O2:"/"J4" family —
|
|
6
|
+
* a single/double letter plus 1-2 digits, with no hyphen, standing in
|
|
7
|
+
* for a checklist line or review round that has no meaning once the
|
|
8
|
+
* review is over;
|
|
9
|
+
* - a numbered review/card comment reference, "comment 2720";
|
|
10
|
+
* - a checklist or AC item number, "AC 2099"/"item 2388".
|
|
11
|
+
*
|
|
12
|
+
* A real card id (ABC-9, PLN-2, DX-1234, ...) is deliberately NEVER banned:
|
|
13
|
+
* danxbot's Issue-Ref Comment Protocol (`issue-card-workflow` skill) makes
|
|
14
|
+
* `// CARD-ID: <reason>` the sanctioned, DEFAULT way to record why a
|
|
15
|
+
* non-obvious decision exists — that reference travels with the code for as
|
|
16
|
+
* long as the constraint applies and is meant to outlive any one review. The
|
|
17
|
+
* letters-HYPHEN-digits shape (`ABC-9`) is exactly what tells a durable card
|
|
18
|
+
* id apart from a review-round code that has none (`K5`).
|
|
19
|
+
*
|
|
20
|
+
* This class of narration has come back in every review pass on this
|
|
21
|
+
* codebase, so it is enforced here (run by the `hygiene` check
|
|
22
|
+
* of `app-kit-repo-check`) rather than relied on to be caught by hand
|
|
23
|
+
* again.
|
|
24
|
+
*
|
|
25
|
+
* Scoped to comments and test titles, not arbitrary code: real, compiling
|
|
26
|
+
* source can otherwise contain text that coincidentally matches the same
|
|
27
|
+
* shape without being narration at all — an ISO timestamp built as
|
|
28
|
+
* `` `${x}T00:00:00Z` `` matches `\b[A-Z]\d{1,2}:`, and a spreadsheet-formula
|
|
29
|
+
* test fixture like `"=SUM(A1:A9)"` does too. Comments and test titles are
|
|
30
|
+
* exactly the surface this guard means to cover; scanning everything else
|
|
31
|
+
* would only add false positives.
|
|
32
|
+
*
|
|
33
|
+
* Accepted trade-off: a one-off, genuinely unrelated capital-letter-plus-digits
|
|
34
|
+
* token inside a comment or title — a lettered outline heading like
|
|
35
|
+
* `// Section A1: header row`, say — still matches. Narrowing the pattern to
|
|
36
|
+
* exclude that shape would also blind it to the real review-code family this
|
|
37
|
+
* guard exists to catch, which has exactly the same shape; there is no
|
|
38
|
+
* pattern that tells the two apart from the text alone, so a one-off case is
|
|
39
|
+
* left to be reworded by hand rather than grown into a general exemption.
|
|
40
|
+
*
|
|
41
|
+
* A recurring, closed-vocabulary domain term that happens to share the shape
|
|
42
|
+
* (a telephony "N11" short code, say) is different: the repo's config lists it
|
|
43
|
+
* in `narrationAllowlist`: it names one exact string,
|
|
44
|
+
* used identically everywhere it appears, never a pattern or a review code
|
|
45
|
+
* that will ever resolve.
|
|
46
|
+
*/
|
|
47
|
+
import { readFileSync } from "node:fs";
|
|
48
|
+
import { basename, relative } from "node:path";
|
|
49
|
+
import { extensionOf, listRepoFiles } from "./repoFiles.js";
|
|
50
|
+
import { extractScriptComments, } from "./scriptComments.js";
|
|
51
|
+
// Order matters: the colon- and paren-wrapped alternatives are tried before
|
|
52
|
+
// the bare fallback, so a form that DOES carry a colon or parens still
|
|
53
|
+
// reports that punctuation in the match (`"K1:"`, `"(S3)"`) — the bare
|
|
54
|
+
// alternative only fires for a review code with neither, such as
|
|
55
|
+
// `// fixed per J4` or `// K5 mutation coverage`, which the earlier
|
|
56
|
+
// alternatives alone never catch since there's nothing but a word boundary
|
|
57
|
+
// on either side.
|
|
58
|
+
export const NARRATION_PATTERN = /\bcomment \d{3,}\b|\b(?:AC|item) \d{3,}\b|\([A-Z]\d{1,2}\)|\b[A-Z]\d{1,2}:|\b[A-Z]\d{1,2}\b/g;
|
|
59
|
+
/** Only source files a human actually writes comments/test titles into —
|
|
60
|
+
* never a lockfile, a `.md`, or a binary/image asset. `.prisma` is included
|
|
61
|
+
* its `///`/`//` comments are the same shape this scanner already
|
|
62
|
+
* parses, and schema.prisma carries the same review/AC narration every other
|
|
63
|
+
* source file does. `.sh` and `.tf` are included: the deploy script and
|
|
64
|
+
* the Terraform stack are read as closely as any application code, so their
|
|
65
|
+
* `#` comments are held to the same rule. `.sql` is deliberately NOT included: `.sql` files are
|
|
66
|
+
* typically already-applied migrations, which must never be edited after the
|
|
67
|
+
* fact — scanning them would flag narration that cannot be fixed forward
|
|
68
|
+
* without rewriting history. */
|
|
69
|
+
const INCLUDED_EXTENSIONS = new Set([
|
|
70
|
+
".ts",
|
|
71
|
+
".tsx",
|
|
72
|
+
".js",
|
|
73
|
+
".jsx",
|
|
74
|
+
".prisma",
|
|
75
|
+
".sh",
|
|
76
|
+
".tf",
|
|
77
|
+
]);
|
|
78
|
+
/** Extensions whose comment syntax is not JavaScript's (shell's `#`, and HCL's
|
|
79
|
+
* `#`, `//` and block comments), so they use their own tokenizer
|
|
80
|
+
* (`scriptComments.ts`) instead of `extractFragments`. */
|
|
81
|
+
const SCRIPT_DIALECT_BY_EXTENSION = {
|
|
82
|
+
".sh": "shell",
|
|
83
|
+
".tf": "hcl",
|
|
84
|
+
};
|
|
85
|
+
/** Consumes one whole string literal starting at `source[i]` (which must be
|
|
86
|
+
* a quote character), returning the index right after its closing quote.
|
|
87
|
+
* Shared by the title extractor and the main walk below so both treat an
|
|
88
|
+
* escaped quote (`\"`) identically. */
|
|
89
|
+
function skipStringLiteral(source, i) {
|
|
90
|
+
const quote = source[i];
|
|
91
|
+
let j = i + 1;
|
|
92
|
+
const n = source.length;
|
|
93
|
+
while (j < n && source[j] !== quote) {
|
|
94
|
+
if (source[j] === "\\")
|
|
95
|
+
j += 2;
|
|
96
|
+
else
|
|
97
|
+
j++;
|
|
98
|
+
}
|
|
99
|
+
return Math.min(j + 1, n);
|
|
100
|
+
}
|
|
101
|
+
/** Skips one balanced, ALREADY-OPENED parenthesised argument list — `start`
|
|
102
|
+
* points at the character right after its opening `(` (counted as depth 1)
|
|
103
|
+
* — and returns the index right after the matching closing `)`. A string
|
|
104
|
+
* literal inside the list is consumed whole via `skipStringLiteral` before
|
|
105
|
+
* its own characters are inspected, so a paren INSIDE a string (an
|
|
106
|
+
* `it.each(["=SUM(A1:A9)"])` fixture value, for instance) never miscounts
|
|
107
|
+
* as a real one. */
|
|
108
|
+
function skipBalancedParens(source, start) {
|
|
109
|
+
const n = source.length;
|
|
110
|
+
let depth = 1;
|
|
111
|
+
let j = start;
|
|
112
|
+
while (j < n && depth > 0) {
|
|
113
|
+
const ch = source[j];
|
|
114
|
+
if (ch === "'" || ch === '"' || ch === "`") {
|
|
115
|
+
j = skipStringLiteral(source, j);
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
if (ch === "(")
|
|
119
|
+
depth++;
|
|
120
|
+
else if (ch === ")")
|
|
121
|
+
depth--;
|
|
122
|
+
j++;
|
|
123
|
+
}
|
|
124
|
+
return j;
|
|
125
|
+
}
|
|
126
|
+
/** Locates every `describe`/`it`/`test` call's own TITLE argument —
|
|
127
|
+
* including `.only`/`.skip` and `.each(table)("title", fn)` variants, where
|
|
128
|
+
* the title is the SECOND parenthesised list's first argument, not the
|
|
129
|
+
* first. A table entry such as `it.each(["=SUM(A1:A9)"])(...)` is skipped
|
|
130
|
+
* as a balanced, opaque argument list (`skipBalancedParens`) rather than
|
|
131
|
+
* matched by a single regex, so a paren embedded inside one of its string
|
|
132
|
+
* values can never be mistaken for the call's own closing paren. */
|
|
133
|
+
function extractTestTitles(source) {
|
|
134
|
+
const fragments = [];
|
|
135
|
+
const n = source.length;
|
|
136
|
+
const callStartRegex = /\b(?:describe|it|test)(?:\.\w+)*\s*\(/g;
|
|
137
|
+
let m;
|
|
138
|
+
while ((m = callStartRegex.exec(source)) !== null) {
|
|
139
|
+
let pos = m.index + m[0].length;
|
|
140
|
+
while (pos < n && /\s/.test(source[pos]))
|
|
141
|
+
pos++;
|
|
142
|
+
const firstChar = source[pos];
|
|
143
|
+
if (firstChar !== '"' && firstChar !== "'" && firstChar !== "`") {
|
|
144
|
+
// Not a title directly at the first parenthesised list — e.g.
|
|
145
|
+
// `.each(table)("title", fn)`. Skip that first list whole and look
|
|
146
|
+
// for the title at the start of the next one.
|
|
147
|
+
pos = skipBalancedParens(source, pos);
|
|
148
|
+
while (pos < n && /\s/.test(source[pos]))
|
|
149
|
+
pos++;
|
|
150
|
+
if (source[pos] !== "(")
|
|
151
|
+
continue;
|
|
152
|
+
pos++;
|
|
153
|
+
while (pos < n && /\s/.test(source[pos]))
|
|
154
|
+
pos++;
|
|
155
|
+
}
|
|
156
|
+
const quote = source[pos];
|
|
157
|
+
if (quote !== '"' && quote !== "'" && quote !== "`")
|
|
158
|
+
continue;
|
|
159
|
+
const end = skipStringLiteral(source, pos);
|
|
160
|
+
const title = source.slice(pos + 1, end - 1);
|
|
161
|
+
const titleLine = source.slice(0, pos).split("\n").length;
|
|
162
|
+
fragments.push({ line: titleLine, text: title });
|
|
163
|
+
}
|
|
164
|
+
return fragments;
|
|
165
|
+
}
|
|
166
|
+
/** Punctuation and keywords after which a bare `/` starts a REGEX literal,
|
|
167
|
+
* not a division — the standard heuristic every JS tokenizer needs for this
|
|
168
|
+
* ambiguity. Not exhaustive, but wide enough for this codebase's own style
|
|
169
|
+
* (division is rare; a regex literal following one of these is common). */
|
|
170
|
+
const REGEX_PRECEDING_PUNCTUATION = new Set([
|
|
171
|
+
"(",
|
|
172
|
+
"[",
|
|
173
|
+
"{",
|
|
174
|
+
",",
|
|
175
|
+
";",
|
|
176
|
+
":",
|
|
177
|
+
"!",
|
|
178
|
+
"&",
|
|
179
|
+
"|",
|
|
180
|
+
"?",
|
|
181
|
+
"+",
|
|
182
|
+
"-",
|
|
183
|
+
"*",
|
|
184
|
+
"%",
|
|
185
|
+
"^",
|
|
186
|
+
"~",
|
|
187
|
+
"<",
|
|
188
|
+
">",
|
|
189
|
+
"=",
|
|
190
|
+
]);
|
|
191
|
+
const REGEX_PRECEDING_KEYWORDS = new Set([
|
|
192
|
+
"return",
|
|
193
|
+
"typeof",
|
|
194
|
+
"instanceof",
|
|
195
|
+
"in",
|
|
196
|
+
"of",
|
|
197
|
+
"new",
|
|
198
|
+
"delete",
|
|
199
|
+
"void",
|
|
200
|
+
"throw",
|
|
201
|
+
"case",
|
|
202
|
+
"do",
|
|
203
|
+
"else",
|
|
204
|
+
"yield",
|
|
205
|
+
"await",
|
|
206
|
+
"extends",
|
|
207
|
+
]);
|
|
208
|
+
/** True when `source[i]` (a `/`) opens a regex literal rather than dividing
|
|
209
|
+
* two values — decided by what precedes it, skipping whitespace/newlines. */
|
|
210
|
+
function startsRegexLiteral(source, i) {
|
|
211
|
+
let j = i - 1;
|
|
212
|
+
while (j >= 0 && /\s/.test(source[j]))
|
|
213
|
+
j--;
|
|
214
|
+
if (j < 0)
|
|
215
|
+
return true;
|
|
216
|
+
const ch = source[j];
|
|
217
|
+
if (REGEX_PRECEDING_PUNCTUATION.has(ch))
|
|
218
|
+
return true;
|
|
219
|
+
let k = j;
|
|
220
|
+
while (k >= 0 && /[A-Za-z0-9_$]/.test(source[k]))
|
|
221
|
+
k--;
|
|
222
|
+
const word = source.slice(k + 1, j + 1);
|
|
223
|
+
return REGEX_PRECEDING_KEYWORDS.has(word);
|
|
224
|
+
}
|
|
225
|
+
/** Skips one regex literal starting at `source[i]` (a `/` already confirmed
|
|
226
|
+
* by `startsRegexLiteral`), respecting a `[...]` character class (where an
|
|
227
|
+
* unescaped `/` doesn't end the literal) and trailing flags, and returns
|
|
228
|
+
* the index right after it. Without this, the main walk below would treat
|
|
229
|
+
* the regex's own delimiters as ordinary characters and its first quote
|
|
230
|
+
* character — inside `/['"]/`, for instance — as the START of a string
|
|
231
|
+
* literal, then scan for a matching close quote through everything that
|
|
232
|
+
* follows, silently swallowing every comment after it as "inside a
|
|
233
|
+
* string" until the next stray quote of the same kind (if any). */
|
|
234
|
+
function skipRegexLiteral(source, i) {
|
|
235
|
+
const n = source.length;
|
|
236
|
+
let j = i + 1;
|
|
237
|
+
let inClass = false;
|
|
238
|
+
while (j < n) {
|
|
239
|
+
const ch = source[j];
|
|
240
|
+
if (ch === "\\") {
|
|
241
|
+
j += 2;
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
244
|
+
if (ch === "\n")
|
|
245
|
+
break; // unterminated on this line — bail out safely
|
|
246
|
+
if (ch === "[")
|
|
247
|
+
inClass = true;
|
|
248
|
+
else if (ch === "]")
|
|
249
|
+
inClass = false;
|
|
250
|
+
else if (ch === "/" && !inClass) {
|
|
251
|
+
j++;
|
|
252
|
+
break;
|
|
253
|
+
}
|
|
254
|
+
j++;
|
|
255
|
+
}
|
|
256
|
+
while (j < n && /[a-z]/i.test(source[j]))
|
|
257
|
+
j++;
|
|
258
|
+
return j;
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Splits `source` into line-comment bodies, block-comment bodies, and every
|
|
262
|
+
* `describe`/`it`/`test` call's own title (`extractTestTitles`).
|
|
263
|
+
*
|
|
264
|
+
* This is a lightweight scan, not a real parser: it tracks line/block
|
|
265
|
+
* comments, string literals and regex literals well enough for this
|
|
266
|
+
* codebase's own style (no attempt to handle a `//`/`/*` sequence embedded
|
|
267
|
+
* inside a string, for instance) — proportionate to what a narration guard
|
|
268
|
+
* needs, not a general-purpose tokenizer.
|
|
269
|
+
*/
|
|
270
|
+
function extractFragments(source) {
|
|
271
|
+
const fragments = extractTestTitles(source);
|
|
272
|
+
let line = 1;
|
|
273
|
+
let i = 0;
|
|
274
|
+
const n = source.length;
|
|
275
|
+
while (i < n) {
|
|
276
|
+
const two = source.slice(i, i + 2);
|
|
277
|
+
if (two === "//") {
|
|
278
|
+
const end = source.indexOf("\n", i);
|
|
279
|
+
const stop = end === -1 ? n : end;
|
|
280
|
+
fragments.push({ line, text: source.slice(i, stop) });
|
|
281
|
+
i = stop;
|
|
282
|
+
continue;
|
|
283
|
+
}
|
|
284
|
+
if (two === "/*") {
|
|
285
|
+
const end = source.indexOf("*/", i + 2);
|
|
286
|
+
const stop = end === -1 ? n : end + 2;
|
|
287
|
+
const chunk = source.slice(i, stop);
|
|
288
|
+
fragments.push({ line, text: chunk });
|
|
289
|
+
line += chunk.split("\n").length - 1;
|
|
290
|
+
i = stop;
|
|
291
|
+
continue;
|
|
292
|
+
}
|
|
293
|
+
const ch = source[i];
|
|
294
|
+
if (ch === "/" && startsRegexLiteral(source, i)) {
|
|
295
|
+
const stop = skipRegexLiteral(source, i);
|
|
296
|
+
line += source.slice(i, stop).split("\n").length - 1;
|
|
297
|
+
i = stop;
|
|
298
|
+
continue;
|
|
299
|
+
}
|
|
300
|
+
if (ch === "'" || ch === '"' || ch === "`") {
|
|
301
|
+
const stop = skipStringLiteral(source, i);
|
|
302
|
+
line += source.slice(i, stop).split("\n").length - 1;
|
|
303
|
+
i = stop;
|
|
304
|
+
continue;
|
|
305
|
+
}
|
|
306
|
+
if (ch === "\n")
|
|
307
|
+
line++;
|
|
308
|
+
i++;
|
|
309
|
+
}
|
|
310
|
+
return fragments;
|
|
311
|
+
}
|
|
312
|
+
/** Scans every source file under `rootDir` for `NARRATION_PATTERN`, inside
|
|
313
|
+
* comments and test titles only (see `extractFragments`). A match listed in
|
|
314
|
+
* `config.narrationAllowlist` is skipped; a file whose basename is in
|
|
315
|
+
* `config.narrationExcludedBasenames` is not read (a checker's own module and
|
|
316
|
+
* test spell out the forbidden patterns as data). */
|
|
317
|
+
export function scanForNarration(rootDir, config) {
|
|
318
|
+
const hits = [];
|
|
319
|
+
const allowlist = new Set(config.narrationAllowlist);
|
|
320
|
+
const excludedBasenames = new Set(config.narrationExcludedBasenames);
|
|
321
|
+
for (const file of listRepoFiles(rootDir, INCLUDED_EXTENSIONS, config.excludedDirs)) {
|
|
322
|
+
if (excludedBasenames.has(basename(file)))
|
|
323
|
+
continue;
|
|
324
|
+
const text = readFileSync(file, "utf8");
|
|
325
|
+
const dialect = SCRIPT_DIALECT_BY_EXTENSION[extensionOf(file)];
|
|
326
|
+
const fragments = dialect
|
|
327
|
+
? extractScriptComments(text, dialect)
|
|
328
|
+
: extractFragments(text);
|
|
329
|
+
for (const fragment of fragments) {
|
|
330
|
+
const matches = fragment.text.match(NARRATION_PATTERN);
|
|
331
|
+
if (!matches)
|
|
332
|
+
continue;
|
|
333
|
+
for (const match of matches) {
|
|
334
|
+
if (allowlist.has(match))
|
|
335
|
+
continue;
|
|
336
|
+
hits.push({
|
|
337
|
+
file: relative(rootDir, file),
|
|
338
|
+
line: fragment.line,
|
|
339
|
+
match,
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
return hits;
|
|
345
|
+
}
|
|
346
|
+
//# sourceMappingURL=checkNarration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkNarration.js","sourceRoot":"","sources":["../../src/repo-check/checkNarration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EACL,qBAAqB,GAGtB,MAAM,qBAAqB,CAAC;AAE7B,4EAA4E;AAC5E,uEAAuE;AACvE,uEAAuE;AACvE,iEAAiE;AACjE,oEAAoE;AACpE,2EAA2E;AAC3E,kBAAkB;AAClB,MAAM,CAAC,MAAM,iBAAiB,GAC5B,8FAA8F,CAAC;AAEjG;;;;;;;;;iCASiC;AACjC,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC;IAClC,KAAK;IACL,MAAM;IACN,KAAK;IACL,MAAM;IACN,SAAS;IACT,KAAK;IACL,KAAK;CACN,CAAC,CAAC;AAEH;;2DAE2D;AAC3D,MAAM,2BAA2B,GAAkC;IACjE,KAAK,EAAE,OAAO;IACd,KAAK,EAAE,KAAK;CACb,CAAC;AAQF;;;wCAGwC;AACxC,SAAS,iBAAiB,CAAC,MAAc,EAAE,CAAS;IAClD,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IACxB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACd,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC;IACxB,OAAO,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,KAAK,EA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AS,GAAG,OAAO;YACvB,CAAC,CAAC,qBAAqB,CAAC,IAAI,EAAE,OAAO,CAAC;YACtC,CAAC,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;QAC3B,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;YACjC,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;YACvD,IAAI,CAAC,OAAO;gBAAE,SAAS;YACvB,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;gBAC5B,IAAI,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC;oBAAE,SAAS;gBACnC,IAAI,CAAC,IAAI,CAAC;oBACR,IAAI,EAAE,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC;oBAC7B,IAAI,EAAE,QAAQ,CAAC,IAAI;oBACnB,KAAK;iBACN,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fails when a text source file in the tree holds a NUL byte. A NUL makes grep, git diff and most
|
|
3
|
+
* editors treat the whole file as binary, so searches silently skip it. A key or
|
|
4
|
+
* separator that needs to be unambiguous is built structurally (`JSON.stringify([a, b])`), and
|
|
5
|
+
* a NUL a test needs is written as the `\u0000` escape.
|
|
6
|
+
*/
|
|
7
|
+
import { readFileSync } from "node:fs";
|
|
8
|
+
import { relative } from "node:path";
|
|
9
|
+
import { listRepoFiles } from "./repoFiles.js";
|
|
10
|
+
const TEXT_EXTENSIONS = new Set([
|
|
11
|
+
".ts",
|
|
12
|
+
".tsx",
|
|
13
|
+
".js",
|
|
14
|
+
".jsx",
|
|
15
|
+
".mjs",
|
|
16
|
+
".json",
|
|
17
|
+
".md",
|
|
18
|
+
".sql",
|
|
19
|
+
".prisma",
|
|
20
|
+
".sh",
|
|
21
|
+
".tf",
|
|
22
|
+
".hcl",
|
|
23
|
+
".yml",
|
|
24
|
+
".yaml",
|
|
25
|
+
".toml",
|
|
26
|
+
".html",
|
|
27
|
+
".css",
|
|
28
|
+
]);
|
|
29
|
+
/** The repo-relative paths of the text files under `rootDir` that contain a NUL byte. */
|
|
30
|
+
export function findFilesWithNul(rootDir, config) {
|
|
31
|
+
return listRepoFiles(rootDir, TEXT_EXTENSIONS, config.excludedDirs)
|
|
32
|
+
.filter((file) => readFileSync(file).includes(0))
|
|
33
|
+
.map((file) => relative(rootDir, file).replaceAll("\\", "/"));
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=checkNoNul.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkNoNul.js","sourceRoot":"","sources":["../../src/repo-check/checkNoNul.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC;IAC9B,KAAK;IACL,MAAM;IACN,KAAK;IACL,MAAM;IACN,MAAM;IACN,OAAO;IACP,KAAK;IACL,MAAM;IACN,SAAS;IACT,KAAK;IACL,KAAK;IACL,MAAM;IACN,MAAM;IACN,OAAO;IACP,OAAO;IACP,OAAO;IACP,MAAM;CACP,CAAC,CAAC;AAEH,yFAAyF;AACzF,MAAM,UAAU,gBAAgB,CAC9B,OAAe,EACf,MAAuB;IAEvB,OAAO,aAAa,CAAC,OAAO,EAAE,eAAe,EAAE,MAAM,CAAC,YAAY,CAAC;SAChE,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;SAChD,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;AAClE,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { type RepoCheckConfig } from "./config.js";
|
|
3
|
+
export declare const CHECKS: readonly ["narration", "no-nul", "hygiene", "script-comments", "repo-files"];
|
|
4
|
+
type Check = (typeof CHECKS)[number];
|
|
5
|
+
export declare const DEFAULT_CONFIG_NAME = "app-kit-repo-check.json";
|
|
6
|
+
/** Findings (one per line) of `check` under `rootDir`; empty means the check passes. */
|
|
7
|
+
export declare function runCheck(check: Check, rootDir: string, config: RepoCheckConfig): string[];
|
|
8
|
+
export declare function main(argv: string[]): number;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* app-kit-repo-check <check> [--root <dir>] [--config <file>]
|
|
4
|
+
*
|
|
5
|
+
* Runs one of the repo hygiene checks over a tree and exits 1 naming every finding:
|
|
6
|
+
* narration review/checklist narration in comments and test titles
|
|
7
|
+
* no-nul text files holding a NUL byte
|
|
8
|
+
* hygiene no-nul and narration together
|
|
9
|
+
* script-comments prints every comment found in the .sh/.tf files (shell and HCL tokenizer)
|
|
10
|
+
* repo-files lists the files the checks read (the shared walk)
|
|
11
|
+
*
|
|
12
|
+
* `--root` defaults to the current directory. `--config` defaults to
|
|
13
|
+
* `app-kit-repo-check.json` in the root when that file exists; see `RepoCheckConfig`.
|
|
14
|
+
*/
|
|
15
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
16
|
+
import { relative, resolve } from "node:path";
|
|
17
|
+
import { scanForNarration } from "./checkNarration.js";
|
|
18
|
+
import { findFilesWithNul } from "./checkNoNul.js";
|
|
19
|
+
import { loadRepoCheckConfig, parseRepoCheckConfig, } from "./config.js";
|
|
20
|
+
import { extractScriptComments } from "./scriptComments.js";
|
|
21
|
+
import { extensionOf, listRepoFiles } from "./repoFiles.js";
|
|
22
|
+
import { repoHygieneFindings } from "./repoHygiene.js";
|
|
23
|
+
import { isRunningAsMain } from "../cli/is-running-as-main.js";
|
|
24
|
+
export const CHECKS = [
|
|
25
|
+
"narration",
|
|
26
|
+
"no-nul",
|
|
27
|
+
"hygiene",
|
|
28
|
+
"script-comments",
|
|
29
|
+
"repo-files",
|
|
30
|
+
];
|
|
31
|
+
export const DEFAULT_CONFIG_NAME = "app-kit-repo-check.json";
|
|
32
|
+
const SCRIPT_DIALECTS = { ".sh": "shell", ".tf": "hcl" };
|
|
33
|
+
/** Findings (one per line) of `check` under `rootDir`; empty means the check passes. */
|
|
34
|
+
export function runCheck(check, rootDir, config) {
|
|
35
|
+
switch (check) {
|
|
36
|
+
case "narration":
|
|
37
|
+
return scanForNarration(rootDir, config).map((hit) => `${hit.file.replaceAll("\\", "/")}:${hit.line}: review narration "${hit.match}"`);
|
|
38
|
+
case "no-nul":
|
|
39
|
+
return findFilesWithNul(rootDir, config).map((file) => `${file}: holds a NUL byte`);
|
|
40
|
+
case "hygiene":
|
|
41
|
+
return repoHygieneFindings(rootDir, config);
|
|
42
|
+
case "script-comments":
|
|
43
|
+
case "repo-files":
|
|
44
|
+
throw new Error(`"${check}" lists output and has no findings`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function listing(check, rootDir, config) {
|
|
48
|
+
const rel = (file) => relative(rootDir, file).replaceAll("\\", "/");
|
|
49
|
+
if (check === "repo-files") {
|
|
50
|
+
return listRepoFiles(rootDir, new Set([".ts", ".tsx", ".js", ".jsx", ".prisma", ".sh", ".tf"]), config.excludedDirs).map(rel);
|
|
51
|
+
}
|
|
52
|
+
const out = [];
|
|
53
|
+
for (const file of listRepoFiles(rootDir, new Set(Object.keys(SCRIPT_DIALECTS)), config.excludedDirs)) {
|
|
54
|
+
const dialect = SCRIPT_DIALECTS[extensionOf(file)];
|
|
55
|
+
for (const c of extractScriptComments(readFileSync(file, "utf8"), dialect)) {
|
|
56
|
+
out.push(`${rel(file)}:${c.line}: ${c.text}`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return out;
|
|
60
|
+
}
|
|
61
|
+
export function main(argv) {
|
|
62
|
+
const [check, ...rest] = argv;
|
|
63
|
+
if (!check || !CHECKS.includes(check)) {
|
|
64
|
+
console.error(`usage: app-kit-repo-check <${CHECKS.join("|")}> [--root <dir>] [--config <file>]`);
|
|
65
|
+
return 2;
|
|
66
|
+
}
|
|
67
|
+
let root = process.cwd();
|
|
68
|
+
let configPath;
|
|
69
|
+
for (let i = 0; i < rest.length; i += 2) {
|
|
70
|
+
const value = rest[i + 1];
|
|
71
|
+
if (value === undefined ||
|
|
72
|
+
(rest[i] !== "--root" && rest[i] !== "--config")) {
|
|
73
|
+
console.error(`unexpected argument "${rest[i]}"`);
|
|
74
|
+
return 2;
|
|
75
|
+
}
|
|
76
|
+
if (rest[i] === "--root")
|
|
77
|
+
root = resolve(value);
|
|
78
|
+
else
|
|
79
|
+
configPath = resolve(value);
|
|
80
|
+
}
|
|
81
|
+
const defaultPath = resolve(root, DEFAULT_CONFIG_NAME);
|
|
82
|
+
const config = configPath
|
|
83
|
+
? loadRepoCheckConfig(configPath)
|
|
84
|
+
: existsSync(defaultPath)
|
|
85
|
+
? loadRepoCheckConfig(defaultPath)
|
|
86
|
+
: parseRepoCheckConfig("{}", "defaults");
|
|
87
|
+
if (check === "script-comments" || check === "repo-files") {
|
|
88
|
+
for (const line of listing(check, root, config))
|
|
89
|
+
console.log(line);
|
|
90
|
+
return 0;
|
|
91
|
+
}
|
|
92
|
+
const findings = runCheck(check, root, config);
|
|
93
|
+
for (const finding of findings)
|
|
94
|
+
console.error(finding);
|
|
95
|
+
if (findings.length > 0)
|
|
96
|
+
return 1;
|
|
97
|
+
console.log(`[repo-check] OK: ${check}`);
|
|
98
|
+
return 0;
|
|
99
|
+
}
|
|
100
|
+
if (isRunningAsMain(import.meta.url)) {
|
|
101
|
+
process.exitCode = main(process.argv.slice(2));
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/repo-check/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EACL,mBAAmB,EACnB,oBAAoB,GAErB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,WAAW;IACX,QAAQ;IACR,SAAS;IACT,iBAAiB;IACjB,YAAY;CACJ,CAAC;AAGX,MAAM,CAAC,MAAM,mBAAmB,GAAG,yBAAyB,CAAC;AAE7D,MAAM,eAAe,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAW,CAAC;AAElE,wFAAwF;AACxF,MAAM,UAAU,QAAQ,CACtB,KAAY,EACZ,OAAe,EACf,MAAuB;IAEvB,QAAQ,KAAK,EAAE,CAAC;QACd,KAAK,WAAW;YACd,OAAO,gBAAgB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,GAAG,CAC1C,CAAC,GAAG,EAAE,EAAE,CACN,GAAG,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,GAAG,C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IAAI,EAAE,mBAAmB,CAAC,CAAC;IACvD,MAAM,MAAM,GAAG,UAAU;QACvB,CAAC,CAAC,mBAAmB,CAAC,UAAU,CAAC;QACjC,CAAC,CAAC,UAAU,CAAC,WAAW,CAAC;YACvB,CAAC,CAAC,mBAAmB,CAAC,WAAW,CAAC;YAClC,CAAC,CAAC,oBAAoB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IAE7C,IAAI,KAAK,KAAK,iBAAiB,IAAI,KAAK,KAAK,YAAY,EAAE,CAAC;QAC1D,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC;YAAE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACnE,OAAO,CAAC,CAAC;IACX,CAAC;IACD,MAAM,QAAQ,GAAG,QAAQ,CAAC,KAAc,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;IACxD,KAAK,MAAM,OAAO,IAAI,QAAQ;QAAE,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACvD,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,CAAC,CAAC;IAClC,OAAO,CAAC,GAAG,CAAC,oBAAoB,KAAK,EAAE,CAAC,CAAC;IACzC,OAAO,CAAC,CAAC;AACX,CAAC;AAED,IAAI,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;IACrC,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** What differs between repos; everything else about the checks is shared. */
|
|
2
|
+
export interface RepoCheckConfig {
|
|
3
|
+
/** Directory names no check reads, on top of `DEFAULT_EXCLUDED_DIRS`. */
|
|
4
|
+
excludedDirs: readonly string[];
|
|
5
|
+
/** Exact matched strings the narration check accepts (a closed-vocabulary domain term). */
|
|
6
|
+
narrationAllowlist: readonly string[];
|
|
7
|
+
/** File basenames the narration check never reads (a checker's own module and test). */
|
|
8
|
+
narrationExcludedBasenames: readonly string[];
|
|
9
|
+
}
|
|
10
|
+
/** Parses a repo's config file: a JSON object whose keys are all optional string arrays.
|
|
11
|
+
* An unknown key or a wrong type throws, so a typo cannot silently disable a check. */
|
|
12
|
+
export declare function parseRepoCheckConfig(json: string, source: string): RepoCheckConfig;
|
|
13
|
+
export declare function loadRepoCheckConfig(path: string): RepoCheckConfig;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { DEFAULT_EXCLUDED_DIRS } from "./repoFiles.js";
|
|
3
|
+
const KEYS = [
|
|
4
|
+
"excludedDirs",
|
|
5
|
+
"narrationAllowlist",
|
|
6
|
+
"narrationExcludedBasenames",
|
|
7
|
+
];
|
|
8
|
+
/** Parses a repo's config file: a JSON object whose keys are all optional string arrays.
|
|
9
|
+
* An unknown key or a wrong type throws, so a typo cannot silently disable a check. */
|
|
10
|
+
export function parseRepoCheckConfig(json, source) {
|
|
11
|
+
const raw = JSON.parse(json);
|
|
12
|
+
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
|
|
13
|
+
throw new Error(`${source}: config must be a JSON object`);
|
|
14
|
+
}
|
|
15
|
+
const record = raw;
|
|
16
|
+
for (const key of Object.keys(record)) {
|
|
17
|
+
if (!KEYS.includes(key)) {
|
|
18
|
+
throw new Error(`${source}: unknown config key "${key}" (allowed: ${KEYS.join(", ")})`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
const list = (key) => {
|
|
22
|
+
const value = record[key];
|
|
23
|
+
if (value === undefined)
|
|
24
|
+
return [];
|
|
25
|
+
if (!Array.isArray(value) || !value.every((v) => typeof v === "string")) {
|
|
26
|
+
throw new Error(`${source}: "${key}" must be an array of strings`);
|
|
27
|
+
}
|
|
28
|
+
return value;
|
|
29
|
+
};
|
|
30
|
+
return {
|
|
31
|
+
excludedDirs: [...DEFAULT_EXCLUDED_DIRS, ...list("excludedDirs")],
|
|
32
|
+
narrationAllowlist: list("narrationAllowlist"),
|
|
33
|
+
narrationExcludedBasenames: list("narrationExcludedBasenames"),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export function loadRepoCheckConfig(path) {
|
|
37
|
+
return parseRepoCheckConfig(readFileSync(path, "utf8"), path);
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/repo-check/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAYvD,MAAM,IAAI,GAAG;IACX,cAAc;IACd,oBAAoB;IACpB,4BAA4B;CACpB,CAAC;AAEX;wFACwF;AACxF,MAAM,UAAU,oBAAoB,CAClC,IAAY,EACZ,MAAc;IAEd,MAAM,GAAG,GAAY,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACtC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QAClE,MAAM,IAAI,KAAK,CAAC,GAAG,MAAM,gCAAgC,CAAC,CAAC;IAC7D,CAAC;IACD,MAAM,MAAM,GAAG,GAA8B,CAAC;IAC9C,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QACtC,IAAI,CAAE,IAA0B,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YAC/C,MAAM,IAAI,KAAK,CACb,GAAG,MAAM,yBAAyB,GAAG,eAAe,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CACvE,CAAC;QACJ,CAAC;IACH,CAAC;IACD,MAAM,IAAI,GAAG,CAAC,GAA0B,EAAY,EAAE;QACpD,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAC1B,IAAI,KAAK,KAAK,SAAS;YAAE,OAAO,EAAE,CAAC;QACnC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,EAAE,CAAC;YACxE,MAAM,IAAI,KAAK,CAAC,GAAG,MAAM,MAAM,GAAG,+BAA+B,CAAC,CAAC;QACrE,CAAC;QACD,OAAO,KAAiB,CAAC;IAC3B,CAAC,CAAC;IACF,OAAO;QACL,YAAY,EAAE,CAAC,GAAG,qBAAqB,EAAE,GAAG,IAAI,CAAC,cAAc,CAAC,CAAC;QACjE,kBAAkB,EAAE,IAAI,CAAC,oBAAoB,CAAC;QAC9C,0BAA0B,EAAE,IAAI,CAAC,4BAA4B,CAAC;KAC/D,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,IAAY;IAC9C,OAAO,oBAAoB,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,IAAI,CAAC,CAAC;AAChE,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Directories no check reads: dependency/build output no one hand-writes into, VCS internals,
|
|
2
|
+
* and a checked-out worktree (a full separate copy of the same repo — scanning it would just
|
|
3
|
+
* double-report, or scan another in-flight change's uncommitted work). A repo's config adds
|
|
4
|
+
* its own to these. */
|
|
5
|
+
export declare const DEFAULT_EXCLUDED_DIRS: readonly string[];
|
|
6
|
+
export declare function extensionOf(fileName: string): string;
|
|
7
|
+
/** The absolute paths of the files under `rootDir` with one of `extensions`, outside `excludedDirs`. */
|
|
8
|
+
export declare function listRepoFiles(rootDir: string, extensions: ReadonlySet<string>, excludedDirs: readonly string[]): string[];
|