@v-office/site-checks 0.4.0 → 0.4.2
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 +11 -4
- package/dist/bin.mjs +1 -1
- package/dist/{cli-632ORKer.mjs → cli-AmQJK-Qj.mjs} +212 -106
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/instructions/CHANGELOG.md +2 -0
- package/instructions/MIGRATION.md +2 -0
- package/instructions/versions/0.4.1/CHANGELOG.md +9 -0
- package/instructions/versions/0.4.1/MIGRATION.md +4 -0
- package/instructions/versions/0.4.2/CHANGELOG.md +13 -0
- package/instructions/versions/0.4.2/MIGRATION.md +11 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,16 +25,20 @@ pnpm add --save-exact --save-dev @v-office/site-checks
|
|
|
25
25
|
{
|
|
26
26
|
"scripts": {
|
|
27
27
|
"check:src": "site-checks src",
|
|
28
|
-
"check:dist": "site-checks dist"
|
|
28
|
+
"check:dist": "site-checks dist",
|
|
29
|
+
"check:all": "site-checks verify"
|
|
29
30
|
}
|
|
30
31
|
}
|
|
31
32
|
```
|
|
32
33
|
|
|
34
|
+
A pre-push hook (`.githooks/pre-push`) runs `pnpm exec site-checks verify` on a push to `main`.
|
|
35
|
+
|
|
33
36
|
The scripts are for developers; the build worker never runs the site's installed copy, it runs
|
|
34
37
|
both stages from its own. Nothing goes into `astro.config`.
|
|
35
38
|
|
|
36
39
|
```
|
|
37
40
|
site-checks <src | dist> [--root <dir>] [--dist <dir>] [--site <url>] [--report <file>]
|
|
41
|
+
site-checks verify [--root <dir>] [--site <url>]
|
|
38
42
|
```
|
|
39
43
|
|
|
40
44
|
- `src` runs the source checks over the project. It never reads `dist/`, so it gives the same
|
|
@@ -48,8 +52,11 @@ site-checks <src | dist> [--root <dir>] [--dist <dir>] [--site <url>] [--report
|
|
|
48
52
|
do for a preview host. `trailingSlash` is read from the config file the same way. The checks
|
|
49
53
|
read `src/` and `public/` under the root (Astro's default layout); a config that names `root`,
|
|
50
54
|
`srcDir` or `publicDir` stops the command.
|
|
55
|
+
- `verify` runs what the build worker runs, in its order, and stops at the first failure: `src`,
|
|
56
|
+
`astro check` (skipped without `@astrojs/check`), the `build` script (pnpm or npm) and `dist`.
|
|
51
57
|
|
|
52
|
-
Exit codes: 0 when nothing refused, 1 when a check with severity `error` found something
|
|
58
|
+
Exit codes: 0 when nothing refused, 1 when a check with severity `error` found something (for `verify`,
|
|
59
|
+
also when `astro check` or the build fails), 2 on a
|
|
53
60
|
usage or configuration error (a `site-checks.config.json` that cannot be read stops the command).
|
|
54
61
|
|
|
55
62
|
A refused stage ends with the failing checks and their first findings:
|
|
@@ -201,12 +208,12 @@ unrelated findings, `match` picks one.
|
|
|
201
208
|
| `listing-noindex` | error | A page that lists rentals (the search page's `data-prerendered-results` container, the `SearchResults` island, or `listingPages`) that is noindex. Waits while every page is noindex. | Take the page out of the noindex routes. |
|
|
202
209
|
| `listing-links` | warning | A page that lists rentals that carries no links to rentals in its HTML, so a crawler without JavaScript sees an empty list. Runs once some listing has links or the build has more than ten pages; a warning because the links come from the PMS feed. | Render the list server-side, or list the page in `listingClientOnly` with the reason. |
|
|
203
210
|
| `sitemap-noindex` | error | A sitemap entry whose page says noindex (waits while every page is noindex) or is not in the build; an `llms.txt` link to a page that is not there. Skipped without a sitemap and `llms.txt`. | Make the sitemap filter and the noindex routes agree; fix the link. |
|
|
204
|
-
| `page-heads` | warning | On indexable pages: a title over 60 characters, a description empty or over 160, a title or description another page repeats. A missing one is `page-metadata`.
|
|
211
|
+
| `page-heads` | warning | On indexable pages: a title over 60 characters, a description empty or over 160, a title or description another page repeats (language versions naming each other as `hreflang` alternates do not count). A missing one is `page-metadata`. | Shorten; give each page its own. |
|
|
205
212
|
| `canonical-link` | error | On the launched site (a production site URL, some indexable page): an indexable page without an absolute `<link rel="canonical">`. | Build it from the Astro `site` and the page path. |
|
|
206
213
|
| `open-graph` | warning | On the launched site: an indexable page without an absolute `og:url` and `og:image`. | Add them, absolute. |
|
|
207
214
|
| `trailing-slash` | warning | On the launched site: `trailingSlash` is not `"never"`. | Set `trailingSlash: "never"`; write internal links without a trailing slash. |
|
|
208
215
|
| `v9-production-hub` | warning | v9 only, on the launched site: the build's env does not call the production Hub (`CMS_STAGE=production` or the production Hub URLs); a committed `.env.local`; a committed `HUB_API_KEY` equal to `.env.local`'s. Waits for a production site URL and an indexable page. | Set the production stage or URLs and the customer's production key; untrack `.env.local`. |
|
|
209
|
-
| `page-structure` | warning | One `<h1>`, no skipped heading level, no flood of `<h3>` under few `<h2>`, a `<main>`, `alt` on every image, a label on every control, a caption and scoped `<th>` on every table.
|
|
216
|
+
| `page-structure` | warning | One `<h1>`, no skipped heading level, no flood of `<h3>` under few `<h2>`, a `<main>`, `alt` on every image, a label on every control, a caption (or `aria-label`/`aria-labelledby`) and scoped `<th>` on every table. | Fix the component where a fault repeats; decline a rule in `structureIgnore`. |
|
|
210
217
|
| `load-order` | warning | At start: an on-demand library (map, chart, 3D) in the start-up code, a start-up chunk over 150 KB compressed, photos after the first in card swipe strips with a URL, a first-paint photo from 100 KB up in one size only, a preloaded swap face without a `size-adjust` stand-in. | `import()` on demand; first slide only; width `srcset`; a `local()` stand-in. |
|
|
211
218
|
| `banned-copy` | warning | A `bannedCopy` wording in a page's visible text. Skipped without configured wordings. | Reword. |
|
|
212
219
|
| `duplicate-sentences` | warning | The same sentence rendered twice on one page. Waits while every page is noindex. | Remove one, or list it in `allowDuplicateSentences`. |
|
package/dist/bin.mjs
CHANGED
|
@@ -3,6 +3,7 @@ import path from "node:path";
|
|
|
3
3
|
import { parseHTML } from "linkedom";
|
|
4
4
|
import { brotliCompressSync, constants } from "node:zlib";
|
|
5
5
|
import os from "node:os";
|
|
6
|
+
import { spawn } from "node:child_process";
|
|
6
7
|
import { parseArgs } from "node:util";
|
|
7
8
|
//#region src/jsComments.ts
|
|
8
9
|
/** One pass over JavaScript (or the script parts of a component): its comments, and the code with
|
|
@@ -1310,13 +1311,112 @@ const loadOrder = {
|
|
|
1310
1311
|
}
|
|
1311
1312
|
};
|
|
1312
1313
|
//#endregion
|
|
1314
|
+
//#region src/checks/sitemapNoindex.ts
|
|
1315
|
+
const SITEMAP_INDEX = "sitemap-index.xml";
|
|
1316
|
+
const LLMS = "llms.txt";
|
|
1317
|
+
/** A URL path as the sitemap checks compare it: query and fragment dropped, escapes decoded, no
|
|
1318
|
+
* trailing slash but the root's. */
|
|
1319
|
+
const normalize = (urlPath) => {
|
|
1320
|
+
let p = urlPath.split(/[?#]/, 1)[0] ?? "";
|
|
1321
|
+
try {
|
|
1322
|
+
p = decodeURIComponent(p);
|
|
1323
|
+
} catch {}
|
|
1324
|
+
return p.length > 1 ? p.replace(/\/+$/, "") : p;
|
|
1325
|
+
};
|
|
1326
|
+
/** `https://www.example.de/a/` and `/a/` → `/a`. */
|
|
1327
|
+
const toPath = (loc) => {
|
|
1328
|
+
const value = loc.trim();
|
|
1329
|
+
try {
|
|
1330
|
+
return normalize(new URL(value).pathname);
|
|
1331
|
+
} catch {
|
|
1332
|
+
return normalize(value);
|
|
1333
|
+
}
|
|
1334
|
+
};
|
|
1335
|
+
const locs = (xml) => [...xml.matchAll(/<loc>\s*([^<]+?)\s*<\/loc>/g)].map((m) => xmlText(m[1]));
|
|
1336
|
+
/** The URL lists the build publishes agree with the pages it built: no sitemap entry whose own page
|
|
1337
|
+
* says noindex or is not in the build, no `llms.txt` link to a page that is not there. Skipped when
|
|
1338
|
+
* the build publishes neither. While every page is noindex (a site before launch, under its blanket
|
|
1339
|
+
* robots meta), a sitemap listing them is not refused: that disagreement ends with the launch. */
|
|
1340
|
+
const sitemapNoindex = {
|
|
1341
|
+
id: "sitemap-noindex",
|
|
1342
|
+
title: "Published URL lists match the built pages",
|
|
1343
|
+
severity: "error",
|
|
1344
|
+
stage: "dist",
|
|
1345
|
+
begin: (ctx) => {
|
|
1346
|
+
if (!ctx.hasDist) return null;
|
|
1347
|
+
const start = ctx.has(SITEMAP_INDEX) ? [SITEMAP_INDEX] : ctx.files.filter((f) => /^sitemap[^/]*\.xml$/.test(f));
|
|
1348
|
+
if (start.length === 0 && !ctx.has(LLMS)) return null;
|
|
1349
|
+
const noindex = /* @__PURE__ */ new Map();
|
|
1350
|
+
let indexable = 0;
|
|
1351
|
+
return {
|
|
1352
|
+
visit: (page) => {
|
|
1353
|
+
if (page.redirect) return;
|
|
1354
|
+
if (page.noindex) noindex.set(normalize(page.url), page.path);
|
|
1355
|
+
else indexable += 1;
|
|
1356
|
+
},
|
|
1357
|
+
finish: () => {
|
|
1358
|
+
const findings = [];
|
|
1359
|
+
const sitemaps = new Map(start.map((file) => [file, ""]));
|
|
1360
|
+
for (const [sitemap, index] of sitemaps) {
|
|
1361
|
+
if (!ctx.has(sitemap)) {
|
|
1362
|
+
findings.push({
|
|
1363
|
+
path: index,
|
|
1364
|
+
message: `The sitemap index names ${sitemap}, which is not in the build.`
|
|
1365
|
+
});
|
|
1366
|
+
continue;
|
|
1367
|
+
}
|
|
1368
|
+
const xml = ctx.read(sitemap);
|
|
1369
|
+
if (/<sitemapindex\b/i.test(xml)) {
|
|
1370
|
+
for (const loc of locs(xml)) {
|
|
1371
|
+
const child = toPath(loc).replace(/^\//, "");
|
|
1372
|
+
if (!sitemaps.has(child)) sitemaps.set(child, sitemap);
|
|
1373
|
+
}
|
|
1374
|
+
continue;
|
|
1375
|
+
}
|
|
1376
|
+
for (const loc of locs(xml)) {
|
|
1377
|
+
const urlPath = toPath(loc);
|
|
1378
|
+
if (!ctx.serves(urlPath)) findings.push({
|
|
1379
|
+
path: sitemap,
|
|
1380
|
+
message: `The sitemap lists ${loc}, which is not in the build.`
|
|
1381
|
+
});
|
|
1382
|
+
else if (indexable > 0 && noindex.has(urlPath)) findings.push({
|
|
1383
|
+
path: sitemap,
|
|
1384
|
+
message: `The sitemap lists ${loc}, whose page says noindex: the sitemap filter and the noindex routes disagree.`
|
|
1385
|
+
});
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
if (ctx.has(LLMS)) for (const match of ctx.read(LLMS).matchAll(/\]\(([^)\s]+)\)/g)) {
|
|
1389
|
+
const link = match[1];
|
|
1390
|
+
if (/^[a-z][a-z0-9+.-]*:/i.test(link) && !ctx.config.site) continue;
|
|
1391
|
+
if (/^[a-z][a-z0-9+.-]*:/i.test(link)) {
|
|
1392
|
+
let host;
|
|
1393
|
+
try {
|
|
1394
|
+
host = new URL(link).host;
|
|
1395
|
+
} catch {
|
|
1396
|
+
continue;
|
|
1397
|
+
}
|
|
1398
|
+
if (host !== new URL(ctx.config.site).host) continue;
|
|
1399
|
+
}
|
|
1400
|
+
if (!ctx.serves(toPath(link))) findings.push({
|
|
1401
|
+
path: LLMS,
|
|
1402
|
+
message: `llms.txt links ${link}, which is not in the build.`
|
|
1403
|
+
});
|
|
1404
|
+
}
|
|
1405
|
+
return findings;
|
|
1406
|
+
}
|
|
1407
|
+
};
|
|
1408
|
+
}
|
|
1409
|
+
};
|
|
1410
|
+
//#endregion
|
|
1313
1411
|
//#region src/checks/pageHeads.ts
|
|
1314
1412
|
const MAX_TITLE = 60;
|
|
1315
1413
|
const MAX_DESCRIPTION = 160;
|
|
1316
1414
|
/** The head of every indexable page as a search result shows it: a title over 60 or a description
|
|
1317
1415
|
* over 160 characters is cut, an empty description is replaced by whatever the crawler picks, and a
|
|
1318
|
-
* title or description another page repeats makes the two compete.
|
|
1319
|
-
*
|
|
1416
|
+
* title or description another page repeats makes the two compete. Language versions of one page
|
|
1417
|
+
* that name each other as `<link rel="alternate" hreflang>` do not compete: a search engine shows
|
|
1418
|
+
* the one in the searcher's language. A missing title or description is the build worker's
|
|
1419
|
+
* `page-metadata` finding, not repeated here. A warning: the page works. */
|
|
1320
1420
|
const pageHeads = {
|
|
1321
1421
|
id: "page-heads",
|
|
1322
1422
|
title: "Titles and descriptions of indexable pages",
|
|
@@ -1325,12 +1425,24 @@ const pageHeads = {
|
|
|
1325
1425
|
begin: (ctx) => {
|
|
1326
1426
|
if (!ctx.hasDist) return null;
|
|
1327
1427
|
const findings = [];
|
|
1428
|
+
/** Each page's URL path, and the URL paths it names as hreflang alternates. Any origin: the
|
|
1429
|
+
* links are absolute on the production host, also in a preview build, and a match needs both
|
|
1430
|
+
* pages to name each other. */
|
|
1431
|
+
const urls = /* @__PURE__ */ new Map();
|
|
1432
|
+
const alternates = /* @__PURE__ */ new Map();
|
|
1328
1433
|
const titles = /* @__PURE__ */ new Map();
|
|
1329
1434
|
const descriptions = /* @__PURE__ */ new Map();
|
|
1330
1435
|
const remember = (map, value, path) => map.set(value, [...map.get(value) ?? [], path]);
|
|
1331
1436
|
return {
|
|
1332
1437
|
visit: (page) => {
|
|
1333
1438
|
if (page.redirect || page.noindex || page.path === "404.html") return;
|
|
1439
|
+
const own = normalize(page.url);
|
|
1440
|
+
urls.set(page.path, own);
|
|
1441
|
+
const named = /* @__PURE__ */ new Set();
|
|
1442
|
+
for (const link of page.document.querySelectorAll("link[rel~=\"alternate\"][hreflang][href]")) try {
|
|
1443
|
+
named.add(normalize(resolveReference(page, link.getAttribute("href") ?? "")));
|
|
1444
|
+
} catch {}
|
|
1445
|
+
if (named.size > 0) alternates.set(own, named);
|
|
1334
1446
|
const title = page.document.querySelector("title")?.textContent?.trim();
|
|
1335
1447
|
const description = page.document.querySelector("meta[name=\"description\"]")?.getAttribute("content")?.trim();
|
|
1336
1448
|
if (title) {
|
|
@@ -1353,8 +1465,24 @@ const pageHeads = {
|
|
|
1353
1465
|
}
|
|
1354
1466
|
},
|
|
1355
1467
|
finish: () => {
|
|
1468
|
+
const mutual = (a, b) => {
|
|
1469
|
+
const [ua, ub] = [urls.get(a), urls.get(b)];
|
|
1470
|
+
return !!alternates.get(ua)?.has(ub) && !!alternates.get(ub)?.has(ua);
|
|
1471
|
+
};
|
|
1472
|
+
/** The pages that compete for one value: one per group of language versions, where every
|
|
1473
|
+
* page of a group names every other one and is named back. */
|
|
1474
|
+
const competing = (paths) => {
|
|
1475
|
+
const groups = [];
|
|
1476
|
+
for (const path of paths) {
|
|
1477
|
+
const group = groups.find((members) => members.every((other) => mutual(path, other)));
|
|
1478
|
+
if (group) group.push(path);
|
|
1479
|
+
else groups.push([path]);
|
|
1480
|
+
}
|
|
1481
|
+
return groups.map((group) => group[0]);
|
|
1482
|
+
};
|
|
1356
1483
|
const duplicates = (map, what) => {
|
|
1357
|
-
for (const [value,
|
|
1484
|
+
for (const [value, all] of map) {
|
|
1485
|
+
const pages = all.length < 2 ? all : competing(all);
|
|
1358
1486
|
if (pages.length < 2) continue;
|
|
1359
1487
|
const shown = pages.slice(0, 3).join(", ");
|
|
1360
1488
|
const more = pages.length > 3 ? ` (+${pages.length - 3} more)` : "";
|
|
@@ -1421,7 +1549,7 @@ const structureFaults = (page) => {
|
|
|
1421
1549
|
if (unlabelled.length > 0) faults.set("control-label", `${unlabelled.length} control(s) without a label: ${unlabelled.slice(0, 3).map((c) => `<${c.tagName.toLowerCase()}${c.getAttribute("id") ? ` #${c.getAttribute("id")}` : ""}>`).join(", ")}`);
|
|
1422
1550
|
const tables = inDocument(page, "table").flatMap((table) => {
|
|
1423
1551
|
const problems = [];
|
|
1424
|
-
if (!table.querySelector("caption")) problems.push("no <caption>");
|
|
1552
|
+
if (!["aria-label", "aria-labelledby"].some((a) => table.getAttribute(a)?.trim()) && !table.querySelector("caption")) problems.push("no <caption> or aria-label");
|
|
1425
1553
|
const headers = [...table.querySelectorAll("th")];
|
|
1426
1554
|
if (headers.length === 0) problems.push("no <th>");
|
|
1427
1555
|
else if (!headers.some((th) => th.hasAttribute("scope"))) problems.push("<th> without scope");
|
|
@@ -1432,10 +1560,10 @@ const structureFaults = (page) => {
|
|
|
1432
1560
|
};
|
|
1433
1561
|
/** The built pages' own structure, which a screen reader navigates by and nothing else reads: one
|
|
1434
1562
|
* `<h1>`, no skipped heading level, a `<main>` landmark, `alt` on every image, a label on every
|
|
1435
|
-
* control, a caption and scoped headers on every table, and
|
|
1436
|
-
* sections. Contrast, focus order and keyboard traps are not
|
|
1437
|
-
* warning: the alt text of feed photos and the headings of feed
|
|
1438
|
-
* declines a rule in `structureIgnore`. */
|
|
1563
|
+
* control, a caption (or `aria-label`/`aria-labelledby`) and scoped headers on every table, and
|
|
1564
|
+
* no flood of small headings under few sections. Contrast, focus order and keyboard traps are not
|
|
1565
|
+
* decidable from static markup. A warning: the alt text of feed photos and the headings of feed
|
|
1566
|
+
* text come from the PMS. A site declines a rule in `structureIgnore`. */
|
|
1439
1567
|
const pageStructure = {
|
|
1440
1568
|
id: "page-structure",
|
|
1441
1569
|
title: "Page outline, landmarks, alt text, labels and tables",
|
|
@@ -1701,101 +1829,6 @@ const rentalFacts = {
|
|
|
1701
1829
|
}
|
|
1702
1830
|
};
|
|
1703
1831
|
//#endregion
|
|
1704
|
-
//#region src/checks/sitemapNoindex.ts
|
|
1705
|
-
const SITEMAP_INDEX = "sitemap-index.xml";
|
|
1706
|
-
const LLMS = "llms.txt";
|
|
1707
|
-
const normalize = (urlPath) => {
|
|
1708
|
-
let p = urlPath.split(/[?#]/, 1)[0] ?? "";
|
|
1709
|
-
try {
|
|
1710
|
-
p = decodeURIComponent(p);
|
|
1711
|
-
} catch {}
|
|
1712
|
-
return p.length > 1 ? p.replace(/\/+$/, "") : p;
|
|
1713
|
-
};
|
|
1714
|
-
/** `https://www.example.de/a/` and `/a/` → `/a`. */
|
|
1715
|
-
const toPath = (loc) => {
|
|
1716
|
-
const value = loc.trim();
|
|
1717
|
-
try {
|
|
1718
|
-
return normalize(new URL(value).pathname);
|
|
1719
|
-
} catch {
|
|
1720
|
-
return normalize(value);
|
|
1721
|
-
}
|
|
1722
|
-
};
|
|
1723
|
-
const locs = (xml) => [...xml.matchAll(/<loc>\s*([^<]+?)\s*<\/loc>/g)].map((m) => xmlText(m[1]));
|
|
1724
|
-
/** The URL lists the build publishes agree with the pages it built: no sitemap entry whose own page
|
|
1725
|
-
* says noindex or is not in the build, no `llms.txt` link to a page that is not there. Skipped when
|
|
1726
|
-
* the build publishes neither. While every page is noindex (a site before launch, under its blanket
|
|
1727
|
-
* robots meta), a sitemap listing them is not refused: that disagreement ends with the launch. */
|
|
1728
|
-
const sitemapNoindex = {
|
|
1729
|
-
id: "sitemap-noindex",
|
|
1730
|
-
title: "Published URL lists match the built pages",
|
|
1731
|
-
severity: "error",
|
|
1732
|
-
stage: "dist",
|
|
1733
|
-
begin: (ctx) => {
|
|
1734
|
-
if (!ctx.hasDist) return null;
|
|
1735
|
-
const start = ctx.has(SITEMAP_INDEX) ? [SITEMAP_INDEX] : ctx.files.filter((f) => /^sitemap[^/]*\.xml$/.test(f));
|
|
1736
|
-
if (start.length === 0 && !ctx.has(LLMS)) return null;
|
|
1737
|
-
const noindex = /* @__PURE__ */ new Map();
|
|
1738
|
-
let indexable = 0;
|
|
1739
|
-
return {
|
|
1740
|
-
visit: (page) => {
|
|
1741
|
-
if (page.redirect) return;
|
|
1742
|
-
if (page.noindex) noindex.set(normalize(page.url), page.path);
|
|
1743
|
-
else indexable += 1;
|
|
1744
|
-
},
|
|
1745
|
-
finish: () => {
|
|
1746
|
-
const findings = [];
|
|
1747
|
-
const sitemaps = new Map(start.map((file) => [file, ""]));
|
|
1748
|
-
for (const [sitemap, index] of sitemaps) {
|
|
1749
|
-
if (!ctx.has(sitemap)) {
|
|
1750
|
-
findings.push({
|
|
1751
|
-
path: index,
|
|
1752
|
-
message: `The sitemap index names ${sitemap}, which is not in the build.`
|
|
1753
|
-
});
|
|
1754
|
-
continue;
|
|
1755
|
-
}
|
|
1756
|
-
const xml = ctx.read(sitemap);
|
|
1757
|
-
if (/<sitemapindex\b/i.test(xml)) {
|
|
1758
|
-
for (const loc of locs(xml)) {
|
|
1759
|
-
const child = toPath(loc).replace(/^\//, "");
|
|
1760
|
-
if (!sitemaps.has(child)) sitemaps.set(child, sitemap);
|
|
1761
|
-
}
|
|
1762
|
-
continue;
|
|
1763
|
-
}
|
|
1764
|
-
for (const loc of locs(xml)) {
|
|
1765
|
-
const urlPath = toPath(loc);
|
|
1766
|
-
if (!ctx.serves(urlPath)) findings.push({
|
|
1767
|
-
path: sitemap,
|
|
1768
|
-
message: `The sitemap lists ${loc}, which is not in the build.`
|
|
1769
|
-
});
|
|
1770
|
-
else if (indexable > 0 && noindex.has(urlPath)) findings.push({
|
|
1771
|
-
path: sitemap,
|
|
1772
|
-
message: `The sitemap lists ${loc}, whose page says noindex: the sitemap filter and the noindex routes disagree.`
|
|
1773
|
-
});
|
|
1774
|
-
}
|
|
1775
|
-
}
|
|
1776
|
-
if (ctx.has(LLMS)) for (const match of ctx.read(LLMS).matchAll(/\]\(([^)\s]+)\)/g)) {
|
|
1777
|
-
const link = match[1];
|
|
1778
|
-
if (/^[a-z][a-z0-9+.-]*:/i.test(link) && !ctx.config.site) continue;
|
|
1779
|
-
if (/^[a-z][a-z0-9+.-]*:/i.test(link)) {
|
|
1780
|
-
let host;
|
|
1781
|
-
try {
|
|
1782
|
-
host = new URL(link).host;
|
|
1783
|
-
} catch {
|
|
1784
|
-
continue;
|
|
1785
|
-
}
|
|
1786
|
-
if (host !== new URL(ctx.config.site).host) continue;
|
|
1787
|
-
}
|
|
1788
|
-
if (!ctx.serves(toPath(link))) findings.push({
|
|
1789
|
-
path: LLMS,
|
|
1790
|
-
message: `llms.txt links ${link}, which is not in the build.`
|
|
1791
|
-
});
|
|
1792
|
-
}
|
|
1793
|
-
return findings;
|
|
1794
|
-
}
|
|
1795
|
-
};
|
|
1796
|
-
}
|
|
1797
|
-
};
|
|
1798
|
-
//#endregion
|
|
1799
1832
|
//#region src/checks/syncOnce.ts
|
|
1800
1833
|
const LOADER_FILES = ["src/content.config.ts", "src/content/config.ts"];
|
|
1801
1834
|
/** A loader written inline, as opposed to `glob()` or `file()`. */
|
|
@@ -2986,10 +3019,12 @@ const runStage = async (stage, input) => {
|
|
|
2986
3019
|
};
|
|
2987
3020
|
//#endregion
|
|
2988
3021
|
//#region src/cli.ts
|
|
2989
|
-
const USAGE = `Usage: site-checks <src | dist> [options]
|
|
3022
|
+
const USAGE = `Usage: site-checks <src | dist | verify> [options]
|
|
2990
3023
|
|
|
2991
3024
|
src the source checks, before the build (reads the project, never dist/)
|
|
2992
3025
|
dist the checks over the built output, after the build
|
|
3026
|
+
verify what AI Studio's build runs, stopping at the first failure: src, astro check, the
|
|
3027
|
+
build script, dist (--root and --site only)
|
|
2993
3028
|
|
|
2994
3029
|
Options:
|
|
2995
3030
|
--root <dir> the project (default: the current directory)
|
|
@@ -2998,8 +3033,9 @@ Options:
|
|
|
2998
3033
|
--report <file> write the report as JSON here (default for dist: <dist>/${SITE_CHECKS_FILE})
|
|
2999
3034
|
-h, --help this text
|
|
3000
3035
|
|
|
3001
|
-
Exits 0 when nothing refused, 1 when a check with severity error found something
|
|
3002
|
-
or configuration error. Data for the checks:
|
|
3036
|
+
Exits 0 when nothing refused, 1 when a check with severity error found something or (verify)
|
|
3037
|
+
astro check or the build failed, 2 on a usage or configuration error. Data for the checks:
|
|
3038
|
+
${CONFIG_FILE} at the project root.`;
|
|
3003
3039
|
const STAGES = ["src", "dist"];
|
|
3004
3040
|
const isStage = (value) => value !== void 0 && STAGES.includes(value);
|
|
3005
3041
|
const isUrl = (value) => {
|
|
@@ -3052,6 +3088,7 @@ async function cli(argv, io, cwd = process.cwd()) {
|
|
|
3052
3088
|
return 0;
|
|
3053
3089
|
}
|
|
3054
3090
|
const [stage, ...rest] = positionals;
|
|
3091
|
+
if (stage === "verify" && rest.length === 0 && values.dist === void 0 && values.report === void 0) return verify(path.resolve(cwd, values.root ?? "."), values.site, io, cwd);
|
|
3055
3092
|
if (!isStage(stage) || rest.length > 0) {
|
|
3056
3093
|
io.err(USAGE);
|
|
3057
3094
|
return 2;
|
|
@@ -3099,5 +3136,74 @@ async function cli(argv, io, cwd = process.cwd()) {
|
|
|
3099
3136
|
io.out(`[site-checks] ${stage}: ${report.results.length} checks, nothing refused` + (shown ? ` (report: ${shown})` : ""));
|
|
3100
3137
|
return 0;
|
|
3101
3138
|
}
|
|
3139
|
+
/** Runs a child in the project with its output on ours: 0, 1 when it fails, 2 when it cannot
|
|
3140
|
+
* start. No stdin: a pre-push hook's stdin holds git's refs. */
|
|
3141
|
+
const exec = (command, args, root, env, io) => new Promise((resolve) => {
|
|
3142
|
+
const child = spawn(command, args, {
|
|
3143
|
+
cwd: root,
|
|
3144
|
+
env,
|
|
3145
|
+
stdio: [
|
|
3146
|
+
"ignore",
|
|
3147
|
+
"inherit",
|
|
3148
|
+
"inherit"
|
|
3149
|
+
]
|
|
3150
|
+
});
|
|
3151
|
+
child.on("error", (err) => {
|
|
3152
|
+
io.err(`site-checks: cannot run ${command}: ${err.message}`);
|
|
3153
|
+
resolve(2);
|
|
3154
|
+
});
|
|
3155
|
+
child.on("close", (code) => resolve(code === 0 ? 0 : 1));
|
|
3156
|
+
});
|
|
3157
|
+
/**
|
|
3158
|
+
* `site-checks verify`: the build worker's sequence (services/worker/src/builder.ts), stopping at
|
|
3159
|
+
* the first failure: the src stage, `astro check` (skipped without @astrojs/check, as the worker
|
|
3160
|
+
* reports it), the project's build script, the dist stage. `astro check` and the build share one
|
|
3161
|
+
* CONTENT_SYNC_TOKEN, as the worker's `buildEnv`, so a content loader syncs the PMS once.
|
|
3162
|
+
*/
|
|
3163
|
+
async function verify(root, site, io, cwd) {
|
|
3164
|
+
let pkg;
|
|
3165
|
+
try {
|
|
3166
|
+
pkg = JSON.parse(fs.readFileSync(path.join(root, "package.json"), "utf8"));
|
|
3167
|
+
} catch {
|
|
3168
|
+
pkg = void 0;
|
|
3169
|
+
}
|
|
3170
|
+
if (typeof pkg?.scripts?.build !== "string") {
|
|
3171
|
+
io.err(`site-checks: no \`build\` script in ${path.join(root, "package.json")}.`);
|
|
3172
|
+
return 2;
|
|
3173
|
+
}
|
|
3174
|
+
const pm = fs.existsSync(path.join(root, "pnpm-lock.yaml")) || String(pkg.packageManager).startsWith("pnpm@") ? "pnpm" : "npm";
|
|
3175
|
+
const env = {
|
|
3176
|
+
...process.env,
|
|
3177
|
+
CONTENT_SYNC_TOKEN: `${process.pid}-${Date.now()}`
|
|
3178
|
+
};
|
|
3179
|
+
const stageArgs = [
|
|
3180
|
+
"--root",
|
|
3181
|
+
root,
|
|
3182
|
+
...site !== void 0 ? ["--site", site] : []
|
|
3183
|
+
];
|
|
3184
|
+
const steps = [
|
|
3185
|
+
["src", () => cli(["src", ...stageArgs], io, cwd)],
|
|
3186
|
+
["astro check", async () => {
|
|
3187
|
+
if (fs.existsSync(path.join(root, "node_modules/@astrojs/check"))) return exec(path.join(root, "node_modules/.bin/astro"), ["check"], root, env, io);
|
|
3188
|
+
io.out("[site-checks] astro check skipped: @astrojs/check is not installed.");
|
|
3189
|
+
return "skipped";
|
|
3190
|
+
}],
|
|
3191
|
+
["build", () => exec(pm, ["run", "build"], root, env, io)],
|
|
3192
|
+
["dist", () => cli(["dist", ...stageArgs], io, cwd)]
|
|
3193
|
+
];
|
|
3194
|
+
const passed = [];
|
|
3195
|
+
for (const [name, step] of steps) {
|
|
3196
|
+
io.out(`[site-checks] verify: ${name === "build" ? `build (${pm} run build)` : name}`);
|
|
3197
|
+
const code = await step();
|
|
3198
|
+
if (code === "skipped") continue;
|
|
3199
|
+
if (code !== 0) {
|
|
3200
|
+
io.err(`[site-checks] verify stopped at ${name}; passed: ${passed.join(", ") || "none"}`);
|
|
3201
|
+
return code;
|
|
3202
|
+
}
|
|
3203
|
+
passed.push(name);
|
|
3204
|
+
}
|
|
3205
|
+
io.out(`[site-checks] verify passed: ${passed.join(", ")}`);
|
|
3206
|
+
return 0;
|
|
3207
|
+
}
|
|
3102
3208
|
//#endregion
|
|
3103
3209
|
export { loadOptions as _, runDistChecks as a, readAstroConfig as b, refusalMessage as c, MAX_FINDINGS_PER_CHECK as d, MAX_MESSAGE_CHARS as f, CONFIG_FILE as g, runSiteChecks as h, distChecks as i, summarizeBlocking as l, blockingResults as m, cli as n, SITE_CHECKS_FILE as o, MAX_PATH_CHARS as p, runStage as r, findingLine as s, USAGE as t, summaryLines as u, checks as v, checksOf as y };
|
package/dist/index.d.mts
CHANGED
|
@@ -242,7 +242,7 @@ type Io = {
|
|
|
242
242
|
out: (line: string) => void;
|
|
243
243
|
err: (line: string) => void;
|
|
244
244
|
};
|
|
245
|
-
export declare const USAGE = "Usage: site-checks <src | dist> [options]\n\n src the source checks, before the build (reads the project, never dist/)\n dist the checks over the built output, after the build\n\nOptions:\n --root <dir> the project (default: the current directory)\n --dist <dir> the build output, relative to the root (default: dist; dist stage only)\n --site <url> the site's public URL (default: `site` in the Astro config file)\n --report <file> write the report as JSON here (default for dist: <dist>/site-checks.json)\n -h, --help this text\n\nExits 0 when nothing refused, 1 when a check with severity error found something, 2 on a usage
|
|
245
|
+
export declare const USAGE = "Usage: site-checks <src | dist | verify> [options]\n\n src the source checks, before the build (reads the project, never dist/)\n dist the checks over the built output, after the build\n verify what AI Studio's build runs, stopping at the first failure: src, astro check, the\n build script, dist (--root and --site only)\n\nOptions:\n --root <dir> the project (default: the current directory)\n --dist <dir> the build output, relative to the root (default: dist; dist stage only)\n --site <url> the site's public URL (default: `site` in the Astro config file)\n --report <file> write the report as JSON here (default for dist: <dist>/site-checks.json)\n -h, --help this text\n\nExits 0 when nothing refused, 1 when a check with severity error found something or (verify)\nastro check or the build failed, 2 on a usage or configuration error. Data for the checks:\nsite-checks.config.json at the project root.";
|
|
246
246
|
/** The command line. Returns the exit code; prints to `io`. */
|
|
247
247
|
export declare function cli(argv: readonly string[], io: Io, cwd?: string): Promise<number>;
|
|
248
248
|
//#endregion
|
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-AmQJK-Qj.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,8 @@
|
|
|
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.2/CHANGELOG.md`: release notes for 0.4.2
|
|
8
|
+
- `versions/0.4.1/CHANGELOG.md`: release notes for 0.4.1
|
|
7
9
|
- `versions/0.4.0/CHANGELOG.md`: release notes for 0.4.0
|
|
8
10
|
- `versions/0.3.3/CHANGELOG.md`: release notes for 0.3.3
|
|
9
11
|
- `versions/0.3.2/CHANGELOG.md`: release notes for 0.3.2
|
|
@@ -4,6 +4,8 @@
|
|
|
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.2/MIGRATION.md`: Migration: 0.4.1 to 0.4.2
|
|
8
|
+
- `versions/0.4.1/MIGRATION.md`: Migration: 0.4.0 to 0.4.1
|
|
7
9
|
- `versions/0.4.0/MIGRATION.md`: Migration: 0.3.3 to 0.4.0
|
|
8
10
|
- `versions/0.3.3/MIGRATION.md`: Migration: 0.3.2 to 0.3.3
|
|
9
11
|
- `versions/0.3.2/MIGRATION.md`: Migration: 0.3.1 to 0.3.2
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Changelog: 0.4.1
|
|
2
|
+
|
|
3
|
+
## Added
|
|
4
|
+
|
|
5
|
+
- `site-checks verify [--root <dir>] [--site <url>]` runs what AI Studio's build runs, in its
|
|
6
|
+
order, and stops at the first failure: the `src` stage, `astro check` (skipped without
|
|
7
|
+
`@astrojs/check`), the site's `build` script (pnpm or npm), the `dist` stage.
|
|
8
|
+
- Exit codes: 0 when nothing failed (warnings pass), 1 when `astro check` or the build fails or a
|
|
9
|
+
check with severity `error` finds something, 2 on a usage or configuration error.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Changelog: 0.4.2
|
|
2
|
+
|
|
3
|
+
Two warnings that fired on correct pages no longer do.
|
|
4
|
+
|
|
5
|
+
## Fixed
|
|
6
|
+
|
|
7
|
+
- `page-heads` no longer reports language versions of one page as duplicate titles or
|
|
8
|
+
descriptions: two pages that name each other as `<link rel="alternate" hreflang>` share a title
|
|
9
|
+
without competing, also when the links are absolute on the production host. A page that repeats a
|
|
10
|
+
title without that link both ways is still reported.
|
|
11
|
+
- `page-structure` (`table-headers`) takes `aria-label` or `aria-labelledby` as a table's name, as a
|
|
12
|
+
calendar grid (`<table role="grid" aria-label="November 2026">`) has it; a table with neither
|
|
13
|
+
and no `<caption>` is still reported.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Migration: 0.4.1 to 0.4.2
|
|
2
|
+
|
|
3
|
+
No changes required. Fewer warnings: a table named by `aria-label` or `aria-labelledby` (a date
|
|
4
|
+
picker's grid) needs no `<caption>`, and language versions that name each other as `hreflang`
|
|
5
|
+
alternates may share a title and description. An `exclude` entry a site added for either can go.
|
|
6
|
+
|
|
7
|
+
## 1. Upgrade
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
pnpm add --save-exact --save-dev @v-office/site-checks@0.4.2
|
|
11
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@v-office/site-checks",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
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": {
|