@v-office/site-checks 0.3.3 → 0.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 +95 -5
- package/dist/bin.mjs +1 -1
- package/dist/{cli-C2uCbjyQ.mjs → cli-632ORKer.mjs} +106 -38
- package/dist/index.d.mts +27 -7
- package/dist/index.mjs +1 -1
- package/instructions/CHANGELOG.md +1 -0
- package/instructions/MIGRATION.md +1 -0
- package/instructions/versions/0.4.0/CHANGELOG.md +23 -0
- package/instructions/versions/0.4.0/MIGRATION.md +30 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -9,9 +9,8 @@ AI Studio's build worker runs the checks itself on every build, from its own pin
|
|
|
9
9
|
package and with the site's `site-checks.config.json`: for an Astro site the `src` stage before
|
|
10
10
|
`astro check` and the whole `dist` stage after the build, for any other website (the guest and
|
|
11
11
|
owner apps) the platform's dist checks alone. What a build checks does not depend on whether the
|
|
12
|
-
site installed this package.
|
|
13
|
-
|
|
14
|
-
looks before pushing.
|
|
12
|
+
site installed this package. What the checks find lands on the studio's admin pages; it never
|
|
13
|
+
stops a deploy. Locally the two commands are how a developer looks before pushing.
|
|
15
14
|
|
|
16
15
|
## Use
|
|
17
16
|
|
|
@@ -67,8 +66,8 @@ A refused stage ends with the failing checks and their first findings:
|
|
|
67
66
|
|
|
68
67
|
## Configuration
|
|
69
68
|
|
|
70
|
-
`site-checks.config.json` at the project root holds the site's data for the checks
|
|
71
|
-
are fixed by the package
|
|
69
|
+
`site-checks.config.json` at the project root holds the site's data for the checks and the
|
|
70
|
+
findings it excludes (below). Severities are fixed by the package. A key of a check
|
|
72
71
|
an earlier version had (`wiring`, `optimizeDepsIgnore`) is noted and ignored; an unknown key stops
|
|
73
72
|
the command.
|
|
74
73
|
|
|
@@ -88,6 +87,97 @@ the command.
|
|
|
88
87
|
| `allowDuplicateSentences` | `duplicate-sentences` | Sentences a page may render twice. |
|
|
89
88
|
| `quoteSources` | `quote-sources` | Files or directories holding the text a `<blockquote>` may quote (content captures, the feed's reviews written by the build). |
|
|
90
89
|
| `factCheckAccepted` | `rental-facts` | Disagreements the customer confirmed, as the finding prints them: `<slug> <kind> prose=<n> feed=<n>`. |
|
|
90
|
+
| `exclude` | every check | The findings the site accepts, by check id: see [Excluding findings](#excluding-findings). |
|
|
91
|
+
|
|
92
|
+
## Excluding findings
|
|
93
|
+
|
|
94
|
+
`exclude` takes the findings a site accepts, by check id. Every check reads it, the platform's dist
|
|
95
|
+
checks included:
|
|
96
|
+
|
|
97
|
+
```json
|
|
98
|
+
{
|
|
99
|
+
"exclude": {
|
|
100
|
+
"trailing-slash": true,
|
|
101
|
+
"canonical-link": ["/impressum"],
|
|
102
|
+
"image-formats": ["public/brand/logo.png"],
|
|
103
|
+
"html-comments": ["src/legacy/"],
|
|
104
|
+
"donor-terms": [
|
|
105
|
+
{ "path": "/ueber-uns", "match": "Bauernhof", "reason": "the customer's own farm" }
|
|
106
|
+
],
|
|
107
|
+
"internal-links": [{ "match": "/alte-seite" }]
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
- `true`: the check does not run for the site; the report lists it as skipped.
|
|
113
|
+
- A path hides the check's findings on it. A path starting with `/` is a URL path: it covers a built
|
|
114
|
+
page and every page below it, with or without a language prefix (`/impressum` also covers
|
|
115
|
+
`/de/impressum`). `/` is the home page alone; every page is `true`, or a `match` without a
|
|
116
|
+
`path`. Any other path is a file or a folder, project-relative (`public/brand/logo.png`,
|
|
117
|
+
`src/legacy/`, whatever line a source finding names) or relative to `dist/` (`_astro/`).
|
|
118
|
+
- `{ "path", "match", "reason" }` hides the findings whose message contains `match`
|
|
119
|
+
(case-insensitive), on `path` when it is given. Give at least one of the two, neither empty;
|
|
120
|
+
`reason` is for whoever reads the config next.
|
|
121
|
+
|
|
122
|
+
An excluded finding is dropped before the check's status is decided: a check whose findings are all
|
|
123
|
+
excluded is `ok`. A check id this version does not know stops the command, like an unknown key. The
|
|
124
|
+
keys above (`imageIgnore`, `copyExcludePaths`, `structureIgnore`, …) keep working. The build's
|
|
125
|
+
`astro-check` result is the build worker's own, not a check of this package, and cannot be excluded.
|
|
126
|
+
|
|
127
|
+
### One example per check
|
|
128
|
+
|
|
129
|
+
A `match` is text of the finding's message, as the report prints it: copy it from there. Where a
|
|
130
|
+
check's findings all name the same file or page, a path is enough; where one page or file holds
|
|
131
|
+
unrelated findings, `match` picks one.
|
|
132
|
+
|
|
133
|
+
`src` stage:
|
|
134
|
+
|
|
135
|
+
| Check | Example | Exempts |
|
|
136
|
+
| ---------------- | ---------------------------------------------- | ------------------------------------------------------------------------------------------- |
|
|
137
|
+
| `html-comments` | `"src/components/legacy/"` | the comments in that folder (a finding names `file:line`, so a file or a folder is the way) |
|
|
138
|
+
| `image-formats` | `"public/brand/logo.png"` | that image; `"public/brand/"` the folder |
|
|
139
|
+
| `sync-once` | `true` | the loader finding (`src/content.config.ts`) |
|
|
140
|
+
| `v9-hub-filters` | `true`, or `{ "match": "could not be asked" }` | the check, or only "the Hub could not be asked" |
|
|
141
|
+
|
|
142
|
+
`dist` stage, site checks:
|
|
143
|
+
|
|
144
|
+
| Check | Example | Exempts |
|
|
145
|
+
| --------------------- | -------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
|
|
146
|
+
| `view-source` | `{ "match": "comment in shipped JS" }` | every comment in the shipped JS |
|
|
147
|
+
| | `{ "path": "/kontakt", "match": "HTML comment" }` | the HTML comments on one page |
|
|
148
|
+
| `donor-terms` | `{ "path": "/ueber-uns", "match": "\"Bauernhof\"" }` | that term on that page only |
|
|
149
|
+
| `consent-gate` | `{ "match": "from www.youtube-nocookie.com" }` | that host (or list it in `consentAllowedHosts`) |
|
|
150
|
+
| | `{ "match": "vendor \"matomo\"" }` | that vendor's registry finding |
|
|
151
|
+
| `feed-image-formats` | `"/angebote"` | the feed photos on that page |
|
|
152
|
+
| `listing-noindex` | `"/suche/last-minute"` | that listing page |
|
|
153
|
+
| `listing-links` | `"/merkliste"` | that listing page (or `listingClientOnly`, with the reason) |
|
|
154
|
+
| `sitemap-noindex` | `{ "match": "https://www.example.de/agb" }` | that sitemap entry: the finding's path is the sitemap file, so `match` names the URL |
|
|
155
|
+
| `page-heads` | `"/blog"` | the title and description lengths on the blog |
|
|
156
|
+
| | `{ "match": "description \"Ferienwohnungen an der Ostsee\"" }` | one repeated description |
|
|
157
|
+
| `canonical-link` | `"/impressum"` | that page |
|
|
158
|
+
| `open-graph` | `{ "path": "/impressum", "match": "og:image" }` | the findings naming `og:image` on that page (a page missing both tags has one finding naming both) |
|
|
159
|
+
| `trailing-slash` | `true` | the check: its one finding is about the whole site |
|
|
160
|
+
| `v9-production-hub` | `{ "match": ".env.local is committed" }` | that finding alone |
|
|
161
|
+
| `page-structure` | `{ "path": "/impressum", "match": "heading-skip:" }` | one rule on one page (`structureIgnore` declines a rule on every page) |
|
|
162
|
+
| `load-order` | `{ "match": "leaflet" }` | the findings about that library |
|
|
163
|
+
| `banned-copy` | `"/faq"` | that page (or `bannedCopyExcludePaths`) |
|
|
164
|
+
| `duplicate-sentences` | `{ "match": "Wir freuen uns auf Ihre Anfrage" }` | that sentence on every page (or `allowDuplicateSentences`) |
|
|
165
|
+
| `quote-sources` | `"/bewertungen"` | that page |
|
|
166
|
+
| `rental-facts` | `"/unterkunft/seeblick"` | that rental (`factCheckAccepted` accepts one exact disagreement) |
|
|
167
|
+
|
|
168
|
+
`dist` stage, the platform's dist checks:
|
|
169
|
+
|
|
170
|
+
| Check | Example | Exempts |
|
|
171
|
+
| --------------------- | ---------------------------------------------- | ---------------------------------------------------------------------------- |
|
|
172
|
+
| `site-manifest` | `true` | the check |
|
|
173
|
+
| `key-pages` | `"404.html"` | "No 404.html" |
|
|
174
|
+
| `not-found-beacon` | `true` | the check |
|
|
175
|
+
| `internal-links` | `{ "match": "references /alte-seite," }` | the references to that target (the path is only the first page that has one) |
|
|
176
|
+
| `legal-pages` | `{ "path": "/landing", "match": "Impressum" }` | the missing Impressum link on that page |
|
|
177
|
+
| `page-metadata` | `{ "path": "/danke", "match": "description" }` | the missing description on that page |
|
|
178
|
+
| `placeholder-content` | `{ "match": "example.com" }` | that example host |
|
|
179
|
+
| `insecure-resources` | `{ "match": "http://partner.example.de" }` | that resource |
|
|
180
|
+
| `sitemap` | `"robots.txt"` | "No robots.txt" |
|
|
91
181
|
|
|
92
182
|
## The checks
|
|
93
183
|
|
package/dist/bin.mjs
CHANGED
|
@@ -506,19 +506,50 @@ const xmlText = (text) => text.replace(/&(?:#x([0-9a-f]+)|#(\d+)|(amp|lt|gt|quot
|
|
|
506
506
|
}[name.toLowerCase()] ?? entity;
|
|
507
507
|
});
|
|
508
508
|
//#endregion
|
|
509
|
+
//#region src/exclude.ts
|
|
510
|
+
const LOCALE = /^\/[a-z]{2}(?:-[a-z]{2})?(?=\/|$)/i;
|
|
511
|
+
/** The `:line` (and `:column`) a source finding's path ends with. */
|
|
512
|
+
const LINE = /:\d+(?::\d+)?$/;
|
|
513
|
+
/** Whether a URL path entry covers `url`: the path and everything below it, with or without a
|
|
514
|
+
* locale prefix, so `/impressum` also covers `/de/impressum`. `/` is the home page alone: the whole
|
|
515
|
+
* site is the check's `true`, or a `match` without a `path`. */
|
|
516
|
+
const coversUrl = (entry, url) => {
|
|
517
|
+
const own = url.length > 1 ? url.replace(/\/+$/, "") : url;
|
|
518
|
+
const unprefixed = own.replace(LOCALE, "") || "/";
|
|
519
|
+
const p = `/${entry.replace(/^\/+|\/+$/g, "")}`;
|
|
520
|
+
return [own, unprefixed].some((u) => u === p || u.startsWith(`${p}/`));
|
|
521
|
+
};
|
|
522
|
+
/** Whether a path entry covers a finding's path. An entry starting with `/` is a URL path, matched
|
|
523
|
+
* against the URL a built file is served at; any other entry is a file path, project-relative
|
|
524
|
+
* (`public/brand/logo.png`, `src/legacy/`) or relative to `dist/`, and covers that file or
|
|
525
|
+
* everything in that folder. */
|
|
526
|
+
const coversPath = (entry, findingPath) => {
|
|
527
|
+
if (findingPath === void 0) return false;
|
|
528
|
+
const file = findingPath.replace(LINE, "");
|
|
529
|
+
if (entry.startsWith("/")) return coversUrl(entry, fileToUrl(file));
|
|
530
|
+
const folder = entry.replace(/\/+$/, "");
|
|
531
|
+
return file === folder || file.startsWith(`${folder}/`);
|
|
532
|
+
};
|
|
533
|
+
/** Whether one of a check's exclusions covers a finding: its path, and the text its message
|
|
534
|
+
* contains (case-insensitive), each when the entry gives one. */
|
|
535
|
+
const isExcluded = (entries, finding) => entries.some((entry) => {
|
|
536
|
+
if (typeof entry === "string") return coversPath(entry, finding.path);
|
|
537
|
+
if (entry.path !== void 0 && !coversPath(entry.path, finding.path)) return false;
|
|
538
|
+
return entry.match === void 0 || finding.message.toLowerCase().includes(entry.match.toLowerCase());
|
|
539
|
+
});
|
|
540
|
+
/** An `exclude` naming a check this version does not have stops the command: a typo would
|
|
541
|
+
* otherwise hide nothing, silently. */
|
|
542
|
+
const assertKnownChecks = (exclude, ids) => {
|
|
543
|
+
const known = new Set(ids);
|
|
544
|
+
const unknown = Object.keys(exclude).filter((id) => !known.has(id));
|
|
545
|
+
if (unknown.length > 0) throw new Error(`[site-checks] "exclude" names ${unknown.length === 1 ? "an unknown check" : "unknown checks"}: ${unknown.join(", ")}`);
|
|
546
|
+
};
|
|
547
|
+
//#endregion
|
|
509
548
|
//#region src/checks/copy.ts
|
|
510
549
|
/** Pages the copy checks read: not a redirect stub, not the 404 page, not an excluded path. An
|
|
511
550
|
* entry covers the path and everything below it, with or without a locale prefix: `/impressum`
|
|
512
551
|
* also covers `/de/impressum`. */
|
|
513
|
-
const excluded = (page, paths) =>
|
|
514
|
-
if (page.redirect || page.path === "404.html") return true;
|
|
515
|
-
const url = page.url.length > 1 ? page.url.replace(/\/+$/, "") : page.url;
|
|
516
|
-
const unprefixed = url.replace(/^\/[a-z]{2}(?:-[a-z]{2})?(?=\/|$)/i, "") || "/";
|
|
517
|
-
return paths.some((entry) => {
|
|
518
|
-
const p = `/${entry.replace(/^\/+|\/+$/g, "")}`;
|
|
519
|
-
return [url, unprefixed].some((u) => u === p || u.startsWith(`${p}/`));
|
|
520
|
-
});
|
|
521
|
-
};
|
|
552
|
+
const excluded = (page, paths) => page.redirect || page.path === "404.html" || paths.some((entry) => coversUrl(entry, page.url));
|
|
522
553
|
const excerpt$2 = (text, max = 90) => text.length > max ? `${text.slice(0, max - 1)}…` : text;
|
|
523
554
|
/** Quotes and whitespace removed, lower-cased: two renderings of one sentence compare equal. */
|
|
524
555
|
const normalize$3 = (text) => text.toLowerCase().replace(/[„“”"‚’'«»]/g, "").replace(/\s+/g, " ").trim();
|
|
@@ -736,6 +767,8 @@ const donorTerms = {
|
|
|
736
767
|
re: wholeWord(term)
|
|
737
768
|
}));
|
|
738
769
|
if (terms.length === 0 || !ctx.hasDist) return null;
|
|
770
|
+
const exclusions = ctx.options.exclude["donor-terms"];
|
|
771
|
+
const excluded = Array.isArray(exclusions) ? exclusions : [];
|
|
739
772
|
const findings = [];
|
|
740
773
|
/** One finding per term and place: the first text of `texts` that contains it. */
|
|
741
774
|
const scan = (texts, path, where) => {
|
|
@@ -745,10 +778,11 @@ const donorTerms = {
|
|
|
745
778
|
for (const haystack of haystacks) {
|
|
746
779
|
const match = re.exec(haystack);
|
|
747
780
|
if (!match) continue;
|
|
748
|
-
|
|
781
|
+
const finding = {
|
|
749
782
|
path,
|
|
750
783
|
message: `donor term "${term}" in ${where}: "${excerpt$1(haystack, match.index, term.length)}"`
|
|
751
|
-
}
|
|
784
|
+
};
|
|
785
|
+
if (!isExcluded(excluded, finding)) findings.push(finding);
|
|
752
786
|
break;
|
|
753
787
|
}
|
|
754
788
|
}
|
|
@@ -2245,6 +2279,10 @@ const compiles = (source, key, pattern, flags) => {
|
|
|
2245
2279
|
throw new Error(`[site-checks] ${source}: "${key}" has an invalid regular expression ${JSON.stringify(pattern)}: ${err.message}`);
|
|
2246
2280
|
}
|
|
2247
2281
|
};
|
|
2282
|
+
/** An `exclude` entry: a path, or an object with a path, a match or both, and a reason at will.
|
|
2283
|
+
* `path` and `match` are never empty: an entry with neither, or an empty `match`, which every
|
|
2284
|
+
* message contains, would hide every finding (that is `true`). */
|
|
2285
|
+
const isExclusion = (entry) => nonEmpty(entry) || isObject(entry) && (entry.path !== void 0 || entry.match !== void 0) && Object.entries(entry).every(([field, value]) => field === "reason" ? isString(value) : (field === "path" || field === "match") && nonEmpty(value));
|
|
2248
2286
|
const stringList = (source, key, value) => {
|
|
2249
2287
|
if (!isStringList(value)) throw new Error(`[site-checks] ${source}: "${key}" must be an array of strings`);
|
|
2250
2288
|
};
|
|
@@ -2276,6 +2314,10 @@ const VALIDATORS = {
|
|
|
2276
2314
|
},
|
|
2277
2315
|
hubFilterOptions: (source, key, value) => {
|
|
2278
2316
|
if (!isObject(value)) throw new Error(`[site-checks] ${source}: "${key}" must be an object`);
|
|
2317
|
+
},
|
|
2318
|
+
exclude: (source, key, value) => {
|
|
2319
|
+
if (!isObject(value)) throw new Error(`[site-checks] ${source}: "${key}" must be an object of check ids`);
|
|
2320
|
+
for (const [id, entries] of Object.entries(value)) if (entries !== true && !(Array.isArray(entries) && entries.every(isExclusion))) throw new Error(`[site-checks] ${source}: "${key}.${id}" must be true or an array of paths and { path, match, reason }`);
|
|
2279
2321
|
}
|
|
2280
2322
|
};
|
|
2281
2323
|
const validate = (source, raw, note) => {
|
|
@@ -2327,7 +2369,8 @@ function loadOptions(root, overrides = {}, note = () => {}) {
|
|
|
2327
2369
|
quoteSources: pick("quoteSources", []),
|
|
2328
2370
|
factCheckAccepted: pick("factCheckAccepted", []),
|
|
2329
2371
|
structureIgnore: pick("structureIgnore", []),
|
|
2330
|
-
hubFilterOptions: pick("hubFilterOptions", {})
|
|
2372
|
+
hubFilterOptions: pick("hubFilterOptions", {}),
|
|
2373
|
+
exclude: pick("exclude", {})
|
|
2331
2374
|
};
|
|
2332
2375
|
}
|
|
2333
2376
|
//#endregion
|
|
@@ -2357,9 +2400,9 @@ const failed = (check, message) => ({
|
|
|
2357
2400
|
});
|
|
2358
2401
|
const broken = (check, err) => failed(check, `The check itself failed: ${errorMessage(err)}`);
|
|
2359
2402
|
const unreadable = (check, err) => failed(check, `The build output could not be read: ${errorMessage(err)}`);
|
|
2360
|
-
const finish = async (check, run) => {
|
|
2403
|
+
const finish = async (check, run, excluded) => {
|
|
2361
2404
|
try {
|
|
2362
|
-
const findings = await run.finish();
|
|
2405
|
+
const findings = (await run.finish()).filter((finding) => !isExcluded(excluded, finding));
|
|
2363
2406
|
return {
|
|
2364
2407
|
id: check.id,
|
|
2365
2408
|
status: findings.length === 0 ? "ok" : check.severity,
|
|
@@ -2372,8 +2415,9 @@ const finish = async (check, run) => {
|
|
|
2372
2415
|
};
|
|
2373
2416
|
/** Runs every check of `list` over the context `load` returns. Never throws: a check that throws
|
|
2374
2417
|
* is a `failed` result, a context that cannot be loaded fails every check the same way. The HTML
|
|
2375
|
-
* pages are parsed one at a time and shown to every check before the next one is read.
|
|
2376
|
-
|
|
2418
|
+
* pages are parsed one at a time and shown to every check before the next one is read. The
|
|
2419
|
+
* site's exclusions (`exclusionsOf` the loaded context) skip a check or drop its findings. */
|
|
2420
|
+
const runChecks = async (load, list, exclusionsOf = () => ({})) => {
|
|
2377
2421
|
const started = Date.now();
|
|
2378
2422
|
const ranAt = new Date(started).toISOString();
|
|
2379
2423
|
let ctx;
|
|
@@ -2386,19 +2430,31 @@ const runChecks = async (load, list) => {
|
|
|
2386
2430
|
results: list.map((check) => unreadable(check, err))
|
|
2387
2431
|
};
|
|
2388
2432
|
}
|
|
2433
|
+
const exclude = exclusionsOf(ctx);
|
|
2389
2434
|
const results = /* @__PURE__ */ new Map();
|
|
2390
2435
|
const runs = /* @__PURE__ */ new Map();
|
|
2391
|
-
for (const check of list)
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2436
|
+
for (const check of list) {
|
|
2437
|
+
if (exclude[check.id] === true) {
|
|
2438
|
+
results.set(check, {
|
|
2439
|
+
id: check.id,
|
|
2440
|
+
status: "skipped",
|
|
2441
|
+
findings: [],
|
|
2442
|
+
omitted: 0
|
|
2443
|
+
});
|
|
2444
|
+
continue;
|
|
2445
|
+
}
|
|
2446
|
+
try {
|
|
2447
|
+
const run = check.begin(ctx);
|
|
2448
|
+
if (run) runs.set(check, run);
|
|
2449
|
+
else results.set(check, {
|
|
2450
|
+
id: check.id,
|
|
2451
|
+
status: "skipped",
|
|
2452
|
+
findings: [],
|
|
2453
|
+
omitted: 0
|
|
2454
|
+
});
|
|
2455
|
+
} catch (err) {
|
|
2456
|
+
results.set(check, broken(check, err));
|
|
2457
|
+
}
|
|
2402
2458
|
}
|
|
2403
2459
|
for (const file of ctx.files) {
|
|
2404
2460
|
if (!file.endsWith(".html")) continue;
|
|
@@ -2421,7 +2477,10 @@ const runChecks = async (load, list) => {
|
|
|
2421
2477
|
results.set(check, broken(check, err));
|
|
2422
2478
|
}
|
|
2423
2479
|
}
|
|
2424
|
-
for (const [check, run] of runs)
|
|
2480
|
+
for (const [check, run] of runs) {
|
|
2481
|
+
const entries = exclude[check.id];
|
|
2482
|
+
results.set(check, await finish(check, run, Array.isArray(entries) ? entries : []));
|
|
2483
|
+
}
|
|
2425
2484
|
return {
|
|
2426
2485
|
ranAt,
|
|
2427
2486
|
durationMs: Date.now() - started,
|
|
@@ -2443,8 +2502,8 @@ const contextInput = (input) => ({
|
|
|
2443
2502
|
});
|
|
2444
2503
|
/** Runs the given site checks over the project, with its build when there is one and the stage
|
|
2445
2504
|
* does not exclude it. The stages (`stages.ts`) are built on this; tests run one check through it. */
|
|
2446
|
-
const runSiteChecks = (input, list = checks) => runChecks(() => loadContext(contextInput(input)), list);
|
|
2447
|
-
/** Results with status `error`: the
|
|
2505
|
+
const runSiteChecks = (input, list = checks) => runChecks(() => loadContext(contextInput(input)), list, (ctx) => ctx.options.exclude);
|
|
2506
|
+
/** Results with status `error`: the ones `site-checks` exits non-zero for. */
|
|
2448
2507
|
const blockingResults = (report) => report.results.filter((r) => r.status === "error");
|
|
2449
2508
|
//#endregion
|
|
2450
2509
|
//#region src/report.ts
|
|
@@ -2817,8 +2876,8 @@ const pathOf = (url) => {
|
|
|
2817
2876
|
* The dist checks: the platform's checks over a build's `dist/`. They are part of the `dist`
|
|
2818
2877
|
* stage (`site-checks dist` runs them after the site's own), and the build worker also runs them
|
|
2819
2878
|
* on its own, at its pinned version, over every build of every website: public sites, the guest
|
|
2820
|
-
* and owner apps, and sites without this package. A site configures nothing for them
|
|
2821
|
-
* every website must pass, whether or not it has this package, belongs here.
|
|
2879
|
+
* and owner apps, and sites without this package. A site configures nothing for them but its
|
|
2880
|
+
* exclusions. A check every website must pass, whether or not it has this package, belongs here.
|
|
2822
2881
|
* See docs/website-platform/process/10-dist-checks.md.
|
|
2823
2882
|
*/
|
|
2824
2883
|
const distChecks = [
|
|
@@ -2878,9 +2937,15 @@ const distChecks = [
|
|
|
2878
2937
|
}
|
|
2879
2938
|
}
|
|
2880
2939
|
];
|
|
2881
|
-
/** Runs every dist check over `distDir
|
|
2882
|
-
*
|
|
2883
|
-
|
|
2940
|
+
/** Runs every dist check over `distDir`, with the exclusions of the `site-checks.config.json` at
|
|
2941
|
+
* `root` when given. Never throws for a check's sake: a check that throws is a `failed` result, an
|
|
2942
|
+
* unreadable `distDir` fails every check the same way. A config that cannot be read throws, as in
|
|
2943
|
+
* `runStage`. */
|
|
2944
|
+
const runDistChecks = (distDir, opts, list = distChecks) => {
|
|
2945
|
+
const exclude = opts.root === void 0 ? {} : loadOptions(opts.root).exclude;
|
|
2946
|
+
assertKnownChecks(exclude, [...checks, ...distChecks].map((check) => check.id));
|
|
2947
|
+
return runChecks(() => loadDistContext(distDir, opts), list, () => exclude);
|
|
2948
|
+
};
|
|
2884
2949
|
//#endregion
|
|
2885
2950
|
//#region src/stages.ts
|
|
2886
2951
|
/**
|
|
@@ -2890,7 +2955,8 @@ const runDistChecks = (distDir, opts, list = distChecks) => runChecks(() => load
|
|
|
2890
2955
|
* a `failed` result. A config file that cannot be read throws before anything runs, and so does
|
|
2891
2956
|
* an Astro config that names `root`, `srcDir` or `publicDir`: the checks read `src/` and `public/`
|
|
2892
2957
|
* under the root, and must not pass over folders the build does not use. A site URL that is no
|
|
2893
|
-
* URL throws too: the dist stage would fail every check on it
|
|
2958
|
+
* URL throws too: the dist stage would fail every check on it. So does an `exclude` naming a check
|
|
2959
|
+
* this version does not have.
|
|
2894
2960
|
*/
|
|
2895
2961
|
const runStage = async (stage, input) => {
|
|
2896
2962
|
const astro = readAstroConfig(input.root);
|
|
@@ -2908,13 +2974,15 @@ const runStage = async (stage, input) => {
|
|
|
2908
2974
|
options: input.options,
|
|
2909
2975
|
note: input.note
|
|
2910
2976
|
});
|
|
2911
|
-
|
|
2977
|
+
const exclude = base.options.exclude;
|
|
2978
|
+
assertKnownChecks(exclude, [...checks, ...distChecks].map((check) => check.id));
|
|
2979
|
+
if (stage === "src") return runChecks(() => loadContext(base), checksOf("src"), () => exclude);
|
|
2912
2980
|
const isAstro = astro.found || fs.existsSync(path.join(input.root, "node_modules", "astro"));
|
|
2913
2981
|
const list = [...distChecks, ...checksOf("dist")];
|
|
2914
2982
|
return runChecks(() => loadDistStageContext({
|
|
2915
2983
|
...base,
|
|
2916
2984
|
isAstro
|
|
2917
|
-
}), list);
|
|
2985
|
+
}), list, () => exclude);
|
|
2918
2986
|
};
|
|
2919
2987
|
//#endregion
|
|
2920
2988
|
//#region src/cli.ts
|
package/dist/index.d.mts
CHANGED
|
@@ -19,6 +19,18 @@ type AstroConfigFacts = {
|
|
|
19
19
|
* one the checks that need it wait. */
|
|
20
20
|
export declare const readAstroConfig: (root: string) => AstroConfigFacts;
|
|
21
21
|
//#endregion
|
|
22
|
+
//#region src/exclude.d.ts
|
|
23
|
+
/** One exclusion of a check's findings: a path, or a path and text the finding's message contains.
|
|
24
|
+
* `reason` is for whoever reads the config next. */
|
|
25
|
+
type Exclusion = string | {
|
|
26
|
+
path?: string;
|
|
27
|
+
match?: string;
|
|
28
|
+
reason?: string;
|
|
29
|
+
};
|
|
30
|
+
/** A site's exclusions (`exclude` in `site-checks.config.json`), by check id: `true` turns the
|
|
31
|
+
* check off for the site, a list hides the findings an entry covers. */
|
|
32
|
+
type Exclusions = Record<string, true | Exclusion[]>;
|
|
33
|
+
//#endregion
|
|
22
34
|
//#region src/options.d.ts
|
|
23
35
|
/** A wording a recorded customer correction bans from the rendered pages. */
|
|
24
36
|
interface BannedCopy {
|
|
@@ -76,6 +88,10 @@ interface SiteChecksOptions {
|
|
|
76
88
|
/** v9 only: the Website SDK options the site's `website-sdk hub-filters check` needs
|
|
77
89
|
* (`rentalScope`, `customAttributeFilterDefinitions`), as the site passes them to the SDK. */
|
|
78
90
|
hubFilterOptions?: Record<string, unknown>;
|
|
91
|
+
/** Findings the site excludes, by check id: `true` turns the check off for the site; a list
|
|
92
|
+
* hides the findings an entry covers, a path (`/impressum`, `public/brand/logo.png`) or
|
|
93
|
+
* `{ path, match, reason }` (`match`: text the finding's message contains). */
|
|
94
|
+
exclude?: Exclusions;
|
|
79
95
|
}
|
|
80
96
|
type ResolvedOptions = Required<SiteChecksOptions>;
|
|
81
97
|
export declare const CONFIG_FILE = "site-checks.config.json";
|
|
@@ -280,7 +296,7 @@ type RunInput = {
|
|
|
280
296
|
/** Runs the given site checks over the project, with its build when there is one and the stage
|
|
281
297
|
* does not exclude it. The stages (`stages.ts`) are built on this; tests run one check through it. */
|
|
282
298
|
export declare const runSiteChecks: (input: RunInput, list?: readonly SiteCheck[]) => Promise<CheckReport>;
|
|
283
|
-
/** Results with status `error`: the
|
|
299
|
+
/** Results with status `error`: the ones `site-checks` exits non-zero for. */
|
|
284
300
|
export declare const blockingResults: (report: CheckReport) => CheckResult[];
|
|
285
301
|
//#endregion
|
|
286
302
|
//#region src/distChecks/index.d.ts
|
|
@@ -288,16 +304,19 @@ export declare const blockingResults: (report: CheckReport) => CheckResult[];
|
|
|
288
304
|
* The dist checks: the platform's checks over a build's `dist/`. They are part of the `dist`
|
|
289
305
|
* stage (`site-checks dist` runs them after the site's own), and the build worker also runs them
|
|
290
306
|
* on its own, at its pinned version, over every build of every website: public sites, the guest
|
|
291
|
-
* and owner apps, and sites without this package. A site configures nothing for them
|
|
292
|
-
* every website must pass, whether or not it has this package, belongs here.
|
|
307
|
+
* and owner apps, and sites without this package. A site configures nothing for them but its
|
|
308
|
+
* exclusions. A check every website must pass, whether or not it has this package, belongs here.
|
|
293
309
|
* See docs/website-platform/process/10-dist-checks.md.
|
|
294
310
|
*/
|
|
295
311
|
export declare const distChecks: readonly DistCheck[];
|
|
296
|
-
/** Runs every dist check over `distDir
|
|
297
|
-
*
|
|
312
|
+
/** Runs every dist check over `distDir`, with the exclusions of the `site-checks.config.json` at
|
|
313
|
+
* `root` when given. Never throws for a check's sake: a check that throws is a `failed` result, an
|
|
314
|
+
* unreadable `distDir` fails every check the same way. A config that cannot be read throws, as in
|
|
315
|
+
* `runStage`. */
|
|
298
316
|
export declare const runDistChecks: (distDir: string, opts: {
|
|
299
317
|
isAstro: boolean;
|
|
300
318
|
siteUrl?: string | undefined;
|
|
319
|
+
root?: string | undefined;
|
|
301
320
|
}, list?: readonly DistCheck[]) => Promise<CheckReport>;
|
|
302
321
|
//#endregion
|
|
303
322
|
//#region src/stages.d.ts
|
|
@@ -320,8 +339,9 @@ type StageInput = {
|
|
|
320
339
|
* a `failed` result. A config file that cannot be read throws before anything runs, and so does
|
|
321
340
|
* an Astro config that names `root`, `srcDir` or `publicDir`: the checks read `src/` and `public/`
|
|
322
341
|
* under the root, and must not pass over folders the build does not use. A site URL that is no
|
|
323
|
-
* URL throws too: the dist stage would fail every check on it
|
|
342
|
+
* URL throws too: the dist stage would fail every check on it. So does an `exclude` naming a check
|
|
343
|
+
* this version does not have.
|
|
324
344
|
*/
|
|
325
345
|
export declare const runStage: (stage: Stage, input: StageInput) => Promise<CheckReport>;
|
|
326
346
|
//#endregion
|
|
327
|
-
export type { AstroConfigFacts, BannedCopy, BuildOutput, Check, CheckReport, CheckResult, CheckRun, CheckStatus, DistCheck, DistContext, DistStageContext, Finding, Io, Page, ResolvedOptions, RunInput, Severity, SiteCheck, SiteCheckContext, SiteChecksOptions, Stage, StageInput };
|
|
347
|
+
export type { AstroConfigFacts, BannedCopy, BuildOutput, Check, CheckReport, CheckResult, CheckRun, CheckStatus, DistCheck, DistContext, DistStageContext, Exclusion, Exclusions, Finding, Io, Page, ResolvedOptions, RunInput, Severity, SiteCheck, SiteCheckContext, SiteChecksOptions, Stage, StageInput };
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as loadOptions, a as runDistChecks, b as readAstroConfig, c as refusalMessage, d as MAX_FINDINGS_PER_CHECK, f as MAX_MESSAGE_CHARS, g as CONFIG_FILE, h as runSiteChecks, i as distChecks, l as summarizeBlocking, m as blockingResults, n as cli, o as SITE_CHECKS_FILE, p as MAX_PATH_CHARS, r as runStage, s as findingLine, t as USAGE, u as summaryLines, v as checks, y as checksOf } from "./cli-
|
|
1
|
+
import { _ as loadOptions, a as runDistChecks, b as readAstroConfig, c as refusalMessage, d as MAX_FINDINGS_PER_CHECK, f as MAX_MESSAGE_CHARS, g as CONFIG_FILE, h as runSiteChecks, i as distChecks, l as summarizeBlocking, m as blockingResults, n as cli, o as SITE_CHECKS_FILE, p as MAX_PATH_CHARS, r as runStage, s as findingLine, t as USAGE, u as summaryLines, v as checks, y as checksOf } from "./cli-632ORKer.mjs";
|
|
2
2
|
export { CONFIG_FILE, MAX_FINDINGS_PER_CHECK, MAX_MESSAGE_CHARS, MAX_PATH_CHARS, SITE_CHECKS_FILE, USAGE, blockingResults, checks, checksOf, cli, distChecks, findingLine, loadOptions, readAstroConfig, refusalMessage, runDistChecks, runSiteChecks, runStage, summarizeBlocking, summaryLines };
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
Release notes of `@v-office/site-checks`, newest first. Each version has its own directory.
|
|
6
6
|
|
|
7
|
+
- `versions/0.4.0/CHANGELOG.md`: release notes for 0.4.0
|
|
7
8
|
- `versions/0.3.3/CHANGELOG.md`: release notes for 0.3.3
|
|
8
9
|
- `versions/0.3.2/CHANGELOG.md`: release notes for 0.3.2
|
|
9
10
|
- `versions/0.3.1/CHANGELOG.md`: release notes for 0.3.1
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
Migration guides of `@v-office/site-checks`, newest first. Apply them in order when skipping versions.
|
|
6
6
|
|
|
7
|
+
- `versions/0.4.0/MIGRATION.md`: Migration: 0.3.3 to 0.4.0
|
|
7
8
|
- `versions/0.3.3/MIGRATION.md`: Migration: 0.3.2 to 0.3.3
|
|
8
9
|
- `versions/0.3.2/MIGRATION.md`: Migration: 0.3.1 to 0.3.2
|
|
9
10
|
- `versions/0.3.1/MIGRATION.md`: Migration: 0.3.0 to 0.3.1
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Changelog: 0.4.0
|
|
2
|
+
|
|
3
|
+
A site can exclude the findings it accepts, for every check, in `site-checks.config.json`.
|
|
4
|
+
|
|
5
|
+
## Added
|
|
6
|
+
|
|
7
|
+
- `exclude`, by check id. `true` turns a check off for the site (the report lists it as skipped).
|
|
8
|
+
A list hides the findings an entry covers: a URL path (`/impressum`, the page and every page
|
|
9
|
+
below it, with or without a language prefix), a file or folder path (`public/brand/logo.png`,
|
|
10
|
+
`src/legacy/`), or `{ "path", "match", "reason" }`, where `match` is text the finding's message
|
|
11
|
+
contains. The README's "Excluding findings" says which to use for which check.
|
|
12
|
+
- The platform's dist checks read `exclude` too. `runDistChecks` takes the project `root` to read
|
|
13
|
+
the config from; without it, nothing is excluded, as before.
|
|
14
|
+
- Exported types `Exclusion` and `Exclusions`.
|
|
15
|
+
|
|
16
|
+
## Changed
|
|
17
|
+
|
|
18
|
+
- An excluded finding is dropped before a check's status is decided: a check whose findings are
|
|
19
|
+
all excluded is `ok`.
|
|
20
|
+
- `runStage` and `runDistChecks` stop on an `exclude` that names a check this version does not
|
|
21
|
+
have, as on an unknown key.
|
|
22
|
+
- The README and the package description say what AI Studio's build does with the findings: it
|
|
23
|
+
reports them and deploys; no check stops a deploy. The command's exit codes stay as they were.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Migration: 0.3.3 to 0.4.0
|
|
2
|
+
|
|
3
|
+
No changes required: `exclude` is new and optional, and the existing keys keep working.
|
|
4
|
+
|
|
5
|
+
## 1. Upgrade
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
pnpm add --save-exact --save-dev @v-office/site-checks@0.4.0
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## 2. Exclude what the site accepts (optional)
|
|
12
|
+
|
|
13
|
+
```json
|
|
14
|
+
{
|
|
15
|
+
"exclude": {
|
|
16
|
+
"canonical-link": ["/impressum"],
|
|
17
|
+
"donor-terms": [{ "match": "Bauernhof", "reason": "the customer's own farm" }]
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## What changes for the site
|
|
23
|
+
|
|
24
|
+
- Add `exclude` only once AI Studio's build worker runs 0.4.0 or later. An older worker does not
|
|
25
|
+
know the key: it reports the stage as not started, with no checks run.
|
|
26
|
+
- An `exclude` naming a check id that does not exist stops `site-checks src` and `site-checks dist`
|
|
27
|
+
(exit code 2) and the build's stage: check the spelling against the README's table.
|
|
28
|
+
- What stays the same: severities, the exit codes, the report's shape, and the older keys
|
|
29
|
+
(`imageIgnore`, `copyExcludePaths`, `structureIgnore`, `allowDuplicateSentences`,
|
|
30
|
+
`consentAllowedHosts`, `factCheckAccepted`, `listingClientOnly`).
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@v-office/site-checks",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "The checks over a v-office website in two stages, `site-checks src` before the build and `site-checks dist` after it, which AI Studio's build worker runs on every build from its own pinned copy; the report has the shape of the build worker's dist-check report
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "The checks over a v-office website in two stages, `site-checks src` before the build and `site-checks dist` after it, which AI Studio's build worker runs on every build from its own pinned copy; the report has the shape of the build worker's dist-check report, and a site excludes the findings it accepts in site-checks.config.json",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|