@v-office/site-checks 0.0.1 → 0.1.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 CHANGED
@@ -1,5 +1,131 @@
1
1
  # @v-office/site-checks
2
2
 
3
- Checks of a built v-office website. No checks are published here yet: the package exports nothing
4
- and only holds its name and its trusted publisher on npm until the checks move in
5
- ([Trusted publishing](../../docs/internal/releasing/how-to-release.md#trusted-publishing)).
3
+ Build-time checks for the sites. The `siteChecks()` Astro integration runs at the end of
4
+ `astro build`, checks the project's source and the built `dist/`, writes
5
+ `dist/site-checks.json` and refuses the build when a check with severity `error` finds
6
+ something. The build worker reads the report, merges it with its own dist checks and shows both
7
+ on the admin page; a refused build never goes live.
8
+
9
+ It replaces the site-shipping guards of the sites' git commit gate with a pinned package that
10
+ runs wherever the site is built: locally, in the site's CI and in AI Studio.
11
+
12
+ ## Use
13
+
14
+ ```sh
15
+ pnpm add --save-exact --save-dev @v-office/site-checks
16
+ ```
17
+
18
+ ```js
19
+ // astro.config.mjs
20
+ import { siteManifest } from "@v-office/site-manifest/astro";
21
+ import { siteChecks } from "@v-office/site-checks/astro";
22
+
23
+ export default defineConfig({
24
+ integrations: [siteManifest(), siteChecks()],
25
+ });
26
+ ```
27
+
28
+ A refused build ends with the failing checks and their first findings:
29
+
30
+ ```
31
+ [site-checks] build refused: 1 check with errors
32
+ - html-comments (2 findings)
33
+ src/pages/index.astro:41: An HTML comment ships to the built page, readable with View Source. …
34
+ src/components/Nav.astro:12: …
35
+ Report: dist/site-checks.json
36
+ ```
37
+
38
+ ## Configuration
39
+
40
+ `site-checks.config.json` at the project root holds the site's data for the checks. The same
41
+ keys are accepted by `siteChecks({ … })`, and an option given there wins over the file's key.
42
+ Severities are fixed by the package: a site configures data, never whether a check blocks.
43
+
44
+ | Key | Used by | What |
45
+ | --------------------- | ---------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
46
+ | `donorTerms` | `donor-terms` | Terms that must not ship: the template site's brand, people, places, phone, email, domain, asset names. Plain strings, matched case-insensitively with whitespace collapsed. |
47
+ | `optimizeDepsIgnore` | `optimize-deps` | Packages imported from `src/` that may stay out of `vite.optimizeDeps.include` (only server-side code uses them). Exact specifier or package name. |
48
+ | `imageIgnore` | `image-formats` | Raster images under `public/` that ship without an AVIF sibling on purpose, as paths relative to the project root (`public/brand/logo.png`). |
49
+ | `feedImagePatterns` | `feed-image-formats` | Regular expressions (case-insensitive) matching a feed photo URL still requested as JPEG or PNG. Defaults to the vOffice image hosts (imgproxy `plain` paths, `dyn.v-office.com`). |
50
+ | `listingPages` | `listing-noindex`, `listing-links` | URL paths of pages that list rentals, in addition to the pages the check recognizes by their markup. |
51
+ | `listingClientOnly` | `listing-links` | Listing pages whose list stays client-only, as `{ "path", "reason" }`: their list is the rentals free in a window, and a build-time list would show booked-out flats. |
52
+ | `consentAllowedHosts` | `consent-gate` | Hosts a `<script src>` or `<iframe src>` may load before consent. The site's own host (`site` in the Astro config) is always allowed. |
53
+
54
+ ## The checks
55
+
56
+ | id | Severity | What it refuses or reports | How to fix |
57
+ | -------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
58
+ | `html-comments` | error | An HTML comment (`<!-- … -->`) in `src/**/*.{astro,tsx,jsx,md,mdx,html}`: Astro passes it into the built page, readable with View Source. | `{/* … */}` in `.astro` and JSX markup, `//` in frontmatter, remove it from Markdown. |
59
+ | `view-source` | error | A developer's note a visitor can read with View Source: an HTML comment in a built page (the frameworks' own markers are allowed), a comment in an inline `<script>` or `<style>` or in shipped CSS, a line comment in shipped JS, a source map or a reference to one. | Remove the comment; turn source maps off in the build. |
60
+ | `donor-terms` | error | A configured term in the visible text, the title, inline scripts and styles (JSON-LD) or an attribute of a built page, in a built file name, or in the shipped JS and CSS. Skipped without configured terms. | Replace the term; list the template site's terms in `donorTerms`. |
61
+ | `optimize-deps` | warning | A runtime package (`dependencies`) imported from `src/` that is not listed, with the exact specifier, in `vite.optimizeDeps.include`. Vite discovers it mid-session instead and re-bundles every dependency. | Add the specifier to `vite.optimizeDeps.include` in `astro.config`, or to `optimizeDepsIgnore` when only server-side code uses it. |
62
+ | `sync-once` | warning | An inline content loader in `src/content.config.ts` that fetches the PMS without the `CONTENT_SYNC_TOKEN` reuse idiom: `astro check` and `astro build` each run it, twice per build. | Keep the token in the store's meta (`meta.get`) and reuse the entries (`store.keys()`) when it matches. |
63
+ | `consent-gate` | error | A third-party `<script src>` or `<iframe src>` outside the consent kit's `ConsentEmbed` frame, loading before consent; a vendor in `ENABLED_VENDOR_IDS` that is not `approved` in `consent-registry.snapshot.json`. Skipped without `src/lib/consent/`. | Frame it with `ConsentEmbed`, or register the vendor so the kit injects it after consent; list a consent-free host in `consentAllowedHosts`. |
64
+ | `image-formats` | error | A raster image under `public/` without an `.avif` sibling. | Encode the AVIF (or list the file in `imageIgnore`). |
65
+ | `feed-image-formats` | warning | A feed photo from the vOffice image hosts requested as JPEG or PNG in `src`, `srcset` or `poster`; a warning because the photos come from the PMS feed. | Pass feed photos through `webpUrl()`. |
66
+ | `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. |
67
+ | `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. |
68
+ | `sitemap-noindex` | error | A sitemap entry whose page says 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. |
69
+ | `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 the build worker's `page-metadata`. | Shorten; give each page its own. |
70
+
71
+ A check that does not apply to the site reports `skipped`; a check that fails itself reports
72
+ `failed` and never blocks.
73
+
74
+ A check whose outcome depends on PMS data, not on the site's code, is a warning: the integration
75
+ runs in every build, the nightly deploy builds included.
76
+
77
+ ## The report
78
+
79
+ `dist/site-checks.json`:
80
+
81
+ ```json
82
+ {
83
+ "ranAt": "2026-10-08T14:00:00.000Z",
84
+ "durationMs": 812,
85
+ "results": [
86
+ { "id": "html-comments", "status": "ok", "findings": [], "omitted": 0 },
87
+ {
88
+ "id": "donor-terms",
89
+ "status": "error",
90
+ "findings": [
91
+ { "path": "index.html", "message": "donor term \"brisenhof\" in the visible text: \"…\"" }
92
+ ],
93
+ "omitted": 0
94
+ }
95
+ ]
96
+ }
97
+ ```
98
+
99
+ `status` is `ok`, `warning`, `error`, `skipped` or `failed`. At most 25 findings are kept per
100
+ check; `omitted` counts the rest. The build worker merges the file into the report of its own
101
+ checks (below), so the controller stores both families alike. The worker never uploads the file:
102
+ it names source paths and configured terms.
103
+
104
+ ## The build worker's checks
105
+
106
+ The package also holds the dist checks AI Studio's build worker runs over `dist/` after every
107
+ build of every website, whether or not the site installed this package: `site-manifest`,
108
+ `key-pages`, `not-found-beacon`, `internal-links`, `legal-pages`, `page-metadata`,
109
+ `placeholder-content`, `insecure-resources` and `sitemap`, all warnings. The integration never runs
110
+ them and a site configures nothing for them; their findings show up next to the site checks'. They
111
+ are exported from `@v-office/site-checks/dist-checks` (`runDistChecks(distDir, { isAstro, siteUrl })`)
112
+ for the worker.
113
+
114
+ ## Programmatic use
115
+
116
+ ```ts
117
+ import { runSiteChecks } from "@v-office/site-checks";
118
+
119
+ const report = await runSiteChecks({
120
+ root: "/path/to/site",
121
+ distDir: "/path/to/site/dist",
122
+ config: { optimizeDepsInclude: ["react"] },
123
+ });
124
+ ```
125
+
126
+ Without a `dist/`, the checks that need built pages report `skipped`.
127
+
128
+ ## Development
129
+
130
+ `pnpm check` (tsc, oxlint, oxfmt --check) · `pnpm test` (vitest) · `pnpm build` (tsdown).
131
+ See `AGENTS.md` for the rules and the release steps.
@@ -0,0 +1,36 @@
1
+ import { r as SiteChecksOptions } from "./options-XdHJYRcb.mjs";
2
+ //#region src/astro.d.ts
3
+ /** The part of Astro's resolved config the checks read. A structural subset, so that astro is a
4
+ * devDependency for the compile-time type test only; `__tests__/types.test.ts` proves Astro's
5
+ * `AstroIntegration` accepts the result. */
6
+ export interface SiteChecksAstroConfig {
7
+ root: URL;
8
+ srcDir: URL;
9
+ publicDir: URL;
10
+ site?: string | undefined;
11
+ vite: {
12
+ optimizeDeps?: {
13
+ include?: string[] | undefined;
14
+ } | undefined;
15
+ };
16
+ }
17
+ export interface SiteChecksIntegration {
18
+ name: string;
19
+ hooks: {
20
+ "astro:config:done": (ctx: {
21
+ config: SiteChecksAstroConfig;
22
+ }) => void;
23
+ "astro:build:done": (ctx: {
24
+ dir: URL;
25
+ }) => Promise<void>;
26
+ };
27
+ }
28
+ /**
29
+ * The checks as an Astro integration: `integrations: [siteManifest(), siteChecks()]`. After the
30
+ * build it runs every check over the project and `dist/`, writes `dist/site-checks.json`, prints
31
+ * one line per check that found something, and refuses the build (throws, so `astro build` exits
32
+ * non-zero) when a check with severity `error` found something. The file is written before the
33
+ * throw: the build worker reads the report of a refused build.
34
+ */
35
+ export declare function siteChecks(options?: SiteChecksOptions): SiteChecksIntegration;
36
+ //#endregion
package/dist/astro.mjs ADDED
@@ -0,0 +1,54 @@
1
+ import { a as writeSiteChecksReport, d as runSiteChecks, i as summaryLines, l as blockingResults, m as checks, n as refusalMessage, p as loadOptions } from "./report-BJUPXJt0.mjs";
2
+ import { fileURLToPath } from "node:url";
3
+ //#region src/astro.ts
4
+ /**
5
+ * The checks as an Astro integration: `integrations: [siteManifest(), siteChecks()]`. After the
6
+ * build it runs every check over the project and `dist/`, writes `dist/site-checks.json`, prints
7
+ * one line per check that found something, and refuses the build (throws, so `astro build` exits
8
+ * non-zero) when a check with severity `error` found something. The file is written before the
9
+ * throw: the build worker reads the report of a refused build.
10
+ */
11
+ function siteChecks(options = {}) {
12
+ let paths = {
13
+ root: process.cwd(),
14
+ srcDir: "",
15
+ publicDir: ""
16
+ };
17
+ let config = {
18
+ site: void 0,
19
+ optimizeDepsInclude: []
20
+ };
21
+ let resolved;
22
+ return {
23
+ name: "@v-office/site-checks",
24
+ hooks: {
25
+ "astro:config:done": ({ config: astro }) => {
26
+ paths = {
27
+ root: fileURLToPath(astro.root),
28
+ srcDir: fileURLToPath(astro.srcDir),
29
+ publicDir: fileURLToPath(astro.publicDir)
30
+ };
31
+ config = {
32
+ site: astro.site,
33
+ optimizeDepsInclude: astro.vite.optimizeDeps?.include ?? []
34
+ };
35
+ resolved = loadOptions(paths.root, options);
36
+ },
37
+ "astro:build:done": async ({ dir }) => {
38
+ const distDir = fileURLToPath(dir);
39
+ const report = await runSiteChecks({
40
+ ...paths,
41
+ distDir,
42
+ config,
43
+ options: resolved ?? loadOptions(paths.root, options)
44
+ }, checks);
45
+ writeSiteChecksReport(distDir, report);
46
+ for (const line of summaryLines(report)) console.warn(line);
47
+ if (blockingResults(report).length > 0) throw new Error(refusalMessage(report));
48
+ console.log(`[site-checks] ${report.results.length} checks, nothing refused`);
49
+ }
50
+ }
51
+ };
52
+ }
53
+ //#endregion
54
+ export { siteChecks };
@@ -0,0 +1,21 @@
1
+ import { S as Severity, _ as CheckStatus, a as blockingResults, b as Finding, g as CheckRun, h as CheckResult, l as summarizeBlocking, m as CheckReport, n as MAX_MESSAGE_CHARS, r as MAX_PATH_CHARS, s as SITE_CHECKS_FILE, t as MAX_FINDINGS_PER_CHECK, v as DistCheck, x as Page, y as DistContext } from "./runner-Cra9mzYM.mjs";
2
+ //#region src/distChecks/index.d.ts
3
+ /**
4
+ * The dist checks: the platform's checks over a build's `dist/`, run by the build worker on every
5
+ * build of every website at the worker's pinned version of this package — public sites, the guest
6
+ * and owner apps, and sites that never installed it. The site checks (`checks/`) are the other
7
+ * family: they run inside a site's own `astro build`, at the site's pinned version. What decides
8
+ * the family is who runs a check, not what it reads: several site checks read `dist/` too. A check
9
+ * every website must pass, whether or not it adopted this package, belongs here.
10
+ * `@v-office/site-checks/dist-checks` is this file; the integration never runs these.
11
+ * See docs/website-platform/process/10-dist-checks.md.
12
+ */
13
+ export declare const distChecks: readonly DistCheck[];
14
+ /** Runs every dist check over `distDir`. Never throws: a check that throws is a `failed` result,
15
+ * an unreadable `distDir` fails every check the same way. */
16
+ export declare const runDistChecks: (distDir: string, opts: {
17
+ isAstro: boolean;
18
+ siteUrl?: string | undefined;
19
+ }, list?: readonly DistCheck[]) => Promise<CheckReport>;
20
+ //#endregion
21
+ export { type CheckReport, type CheckResult, type CheckRun, type CheckStatus, type DistCheck, type DistContext, type Finding, MAX_FINDINGS_PER_CHECK, MAX_MESSAGE_CHARS, MAX_PATH_CHARS, type Page, SITE_CHECKS_FILE, type Severity, blockingResults, summarizeBlocking };
@@ -0,0 +1,410 @@
1
+ import { _ as referencedUrls, c as MAX_PATH_CHARS, g as loadDistContext, h as isSameSiteReference, l as blockingResults, o as MAX_FINDINGS_PER_CHECK, r as summarizeBlocking, s as MAX_MESSAGE_CHARS, t as SITE_CHECKS_FILE, u as runChecks, v as resolveReference, y as xmlText } from "./report-BJUPXJt0.mjs";
2
+ //#region src/distChecks/insecureResources.ts
3
+ /** `<link>` relations the browser fetches as a subresource; canonical,
4
+ * alternate, preconnect and friends are hints or metadata, not loads. */
5
+ const RESOURCE_RELS = /* @__PURE__ */ new Set([
6
+ "stylesheet",
7
+ "preload",
8
+ "modulepreload",
9
+ "prefetch",
10
+ "icon",
11
+ "apple-touch-icon",
12
+ "manifest"
13
+ ]);
14
+ const isResource = (el) => {
15
+ if (el.tagName === "A" || el.tagName === "AREA" || el.tagName === "BASE") return false;
16
+ if (el.tagName !== "LINK") return true;
17
+ return (el.getAttribute("rel") ?? "").toLowerCase().split(/\s+/).some((rel) => RESOURCE_RELS.has(rel));
18
+ };
19
+ /** A resource loaded over plain http on an https site is blocked or downgraded
20
+ * by the browser (mixed content); the page renders without it. Links a
21
+ * visitor clicks (`<a href>`) are not resources and are left alone. */
22
+ const insecureResources = {
23
+ id: "insecure-resources",
24
+ title: "No script, style, image or media is loaded over http://",
25
+ severity: "warning",
26
+ begin() {
27
+ const findings = [];
28
+ const visit = (page) => {
29
+ const seen = /* @__PURE__ */ new Set();
30
+ for (const el of page.document.querySelectorAll("[href], [src], [srcset], [poster]")) {
31
+ if (!isResource(el)) continue;
32
+ for (const value of referencedUrls(el)) {
33
+ const v = value.trim();
34
+ if (!/^http:\/\//i.test(v) || seen.has(v)) continue;
35
+ seen.add(v);
36
+ findings.push({
37
+ message: `${el.tagName.toLowerCase()} loads ${v} over http://`,
38
+ path: page.path
39
+ });
40
+ }
41
+ }
42
+ };
43
+ return {
44
+ visit,
45
+ finish: () => findings
46
+ };
47
+ }
48
+ };
49
+ //#endregion
50
+ //#region src/distChecks/internalLinks.ts
51
+ /** A same-site reference (`href`, `src`, `srcset`, `poster`) that no file of
52
+ * the build serves — the 404 class, caught before a guest hits it. One finding
53
+ * per missing target, on the first page that references it and with the count
54
+ * of pages that do: a layout link to one missing file must not bury every other
55
+ * finding under a copy per page. On a single-page app only file-like paths
56
+ * (with an extension) are checked: its routes are handled by the app, not by
57
+ * files. */
58
+ const internalLinks = {
59
+ id: "internal-links",
60
+ title: "Every internal link and asset reference is served by the build",
61
+ severity: "warning",
62
+ begin(ctx) {
63
+ const missing = /* @__PURE__ */ new Map();
64
+ const visit = (page) => {
65
+ const seen = /* @__PURE__ */ new Set();
66
+ for (const el of page.document.querySelectorAll("[href], [src], [srcset], [poster]")) {
67
+ if (el.tagName === "BASE") continue;
68
+ for (const value of referencedUrls(el)) {
69
+ if (!isSameSiteReference(value, ctx.origin)) continue;
70
+ const target = resolveReference(page, value);
71
+ if (seen.has(target)) continue;
72
+ seen.add(target);
73
+ if (!ctx.isAstro && !/\.[a-z0-9]+$/i.test(target)) continue;
74
+ if (ctx.serves(target)) continue;
75
+ const known = missing.get(target);
76
+ if (known) known.pages++;
77
+ else missing.set(target, {
78
+ tag: el.tagName.toLowerCase(),
79
+ path: page.path,
80
+ pages: 1
81
+ });
82
+ }
83
+ }
84
+ };
85
+ const finish = () => [...missing].map(([target, { tag, path, pages }]) => ({
86
+ message: `${tag} references ${target}, which no file in the build serves${pages > 1 ? ` (from ${pages} pages)` : ""}`,
87
+ path
88
+ }));
89
+ return {
90
+ visit,
91
+ finish
92
+ };
93
+ }
94
+ };
95
+ //#endregion
96
+ //#region src/distChecks/keyPages.ts
97
+ /** The pages every build must emit: the home page, and on an Astro site the
98
+ * 404 page the hosting serves for unknown paths. */
99
+ const keyPages = {
100
+ id: "key-pages",
101
+ title: "The home page and the 404 page are in the build",
102
+ severity: "warning",
103
+ begin(ctx) {
104
+ const findings = [];
105
+ if (!ctx.has("index.html")) findings.push({
106
+ message: "No index.html: the site has no home page",
107
+ path: "index.html"
108
+ });
109
+ if (ctx.isAstro && !ctx.has("404.html")) findings.push({
110
+ message: "No 404.html: unknown paths get the hosting's default error page",
111
+ path: "404.html"
112
+ });
113
+ return { finish: () => findings };
114
+ }
115
+ };
116
+ //#endregion
117
+ //#region src/distChecks/legalPages.ts
118
+ /** German sites owe an Impressum (§ 5 DDG) and a privacy notice (Art. 13
119
+ * DSGVO) reachable from every page; English wordings count too. Matched on
120
+ * the link's target and its text, so a footer link named either way passes.
121
+ * The 404 page and redirect stubs are skipped. */
122
+ const LEGAL = [{
123
+ name: "Impressum / legal notice",
124
+ pattern: /impressum|imprint|legal[-_ ]?notice|colophon/i
125
+ }, {
126
+ name: "Datenschutz / privacy notice",
127
+ pattern: /datenschutz|privacy/i
128
+ }];
129
+ const legalPages = {
130
+ id: "legal-pages",
131
+ title: "Every page links to an Impressum and a privacy notice",
132
+ severity: "warning",
133
+ begin(ctx) {
134
+ if (!ctx.isAstro) return null;
135
+ const findings = [];
136
+ const visit = (page) => {
137
+ if (page.path === "404.html" || page.redirect) return;
138
+ const links = [...page.document.querySelectorAll("a[href]")].map((a) => `${a.getAttribute("href") ?? ""} ${a.textContent ?? ""}`);
139
+ for (const { name, pattern } of LEGAL) {
140
+ if (pattern.test(page.path)) continue;
141
+ if (!links.some((link) => pattern.test(link))) findings.push({
142
+ message: `No link to a ${name} on this page`,
143
+ path: page.path
144
+ });
145
+ }
146
+ };
147
+ return {
148
+ visit,
149
+ finish: () => findings
150
+ };
151
+ }
152
+ };
153
+ //#endregion
154
+ //#region src/distChecks/notFoundBeacon.ts
155
+ const BEACON = /\/api\/404-log\b/;
156
+ /** The hosting serves 404.html for every unknown path, and AI Studio learns of
157
+ * the miss only when that page posts the URL to /api/404-log
158
+ * (docs/internal/operations/404-logging.md). Without the beacon the site's 404 list stays
159
+ * empty and no redirect is ever suggested. Astro bundles page scripts into
160
+ * files under _astro/, so the page's same-site scripts count as well. */
161
+ const notFoundBeacon = {
162
+ id: "not-found-beacon",
163
+ title: "The 404 page reports missing URLs to AI Studio",
164
+ severity: "warning",
165
+ begin(ctx) {
166
+ if (!ctx.isAstro || !ctx.has("404.html")) return null;
167
+ let beacon = false;
168
+ const visit = (page) => {
169
+ if (page.path !== "404.html") return;
170
+ beacon = [...page.document.querySelectorAll("script")].map((script) => {
171
+ const src = script.getAttribute("src");
172
+ if (!src) return script.textContent ?? "";
173
+ if (!isSameSiteReference(src, ctx.origin)) return "";
174
+ const file = resolveReference(page, src).replace(/^\//, "");
175
+ return ctx.has(file) ? ctx.read(file) : "";
176
+ }).some((code) => BEACON.test(code));
177
+ };
178
+ const finish = () => beacon ? [] : [{
179
+ message: "404.html does not call /api/404-log: missing URLs are never logged",
180
+ path: "404.html"
181
+ }];
182
+ return {
183
+ visit,
184
+ finish
185
+ };
186
+ }
187
+ };
188
+ //#endregion
189
+ //#region src/distChecks/pageMetadata.ts
190
+ /** What every page needs in its head: a title, a description, the document
191
+ * language. Missing ones are the classic leftovers of a generated layout. A
192
+ * redirect stub is no page anyone reads and is skipped. */
193
+ const pageMetadata = {
194
+ id: "page-metadata",
195
+ title: "Every page has a title, a description and a language",
196
+ severity: "warning",
197
+ begin() {
198
+ const findings = [];
199
+ const visit = (page) => {
200
+ if (page.redirect) return;
201
+ const { document } = page;
202
+ if (!document.querySelector("title")?.textContent?.trim()) findings.push({
203
+ message: "No <title>",
204
+ path: page.path
205
+ });
206
+ if (!document.querySelector("meta[name=\"description\"]")?.getAttribute("content")?.trim()) findings.push({
207
+ message: "No <meta name=\"description\">",
208
+ path: page.path
209
+ });
210
+ if (!document.documentElement?.getAttribute("lang")?.trim()) findings.push({
211
+ message: "No lang attribute on <html>",
212
+ path: page.path
213
+ });
214
+ };
215
+ return {
216
+ visit,
217
+ finish: () => findings
218
+ };
219
+ }
220
+ };
221
+ //#endregion
222
+ //#region src/distChecks/placeholderContent.ts
223
+ /** Text that should never reach a visitor: template filler, a value that was
224
+ * rendered instead of formatted, a template expression the build did not
225
+ * evaluate. And references to development hosts or example domains. */
226
+ const TEXT_PATTERNS = [
227
+ {
228
+ name: "lorem ipsum",
229
+ pattern: /lorem ipsum/i
230
+ },
231
+ {
232
+ name: "[object Object]",
233
+ pattern: /\[object Object\]/
234
+ },
235
+ {
236
+ name: "a bare 'undefined'",
237
+ pattern: /(?<![\w-])undefined(?![\w-])/
238
+ },
239
+ {
240
+ name: "a bare 'NaN'",
241
+ pattern: /(?<![\w-])NaN(?![\w-])/
242
+ },
243
+ {
244
+ name: "an unrendered template expression",
245
+ pattern: /\{\{[^}]*\}\}/
246
+ }
247
+ ];
248
+ /** Development hosts and the RFC 2606 example domains, including their
249
+ * subdomains — but not a real host that merely ends in "example.com", such as
250
+ * counterexample.com (fixed 2026-09-24). */
251
+ const DEV_HOSTS = /^(https?:)?\/\/(localhost|127\.0\.0\.1|0\.0\.0\.0|(?:[^/:?#]+\.)?example\.(com|org|net))(?=[/:?#]|$)/i;
252
+ const CONTEXT = 40;
253
+ const placeholderContent = {
254
+ id: "placeholder-content",
255
+ title: "No placeholder text or development hosts reach the visitor",
256
+ severity: "warning",
257
+ begin() {
258
+ const findings = [];
259
+ const visit = (page) => {
260
+ const text = page.visibleText();
261
+ for (const { name, pattern } of TEXT_PATTERNS) {
262
+ const match = pattern.exec(text);
263
+ if (!match) continue;
264
+ const start = Math.max(0, match.index - CONTEXT);
265
+ const snippet = text.slice(start, match.index + match[0].length + CONTEXT).trim();
266
+ findings.push({
267
+ message: `Visible text contains ${name}: "…${snippet}…"`,
268
+ path: page.path
269
+ });
270
+ }
271
+ const seen = /* @__PURE__ */ new Set();
272
+ for (const el of page.document.querySelectorAll("[href], [src], [srcset], [poster]")) for (const value of referencedUrls(el)) {
273
+ const v = value.trim();
274
+ if (!DEV_HOSTS.test(v) || seen.has(v)) continue;
275
+ seen.add(v);
276
+ findings.push({
277
+ message: `References a development or example host: ${v}`,
278
+ path: page.path
279
+ });
280
+ }
281
+ };
282
+ return {
283
+ visit,
284
+ finish: () => findings
285
+ };
286
+ }
287
+ };
288
+ //#endregion
289
+ //#region src/distChecks/siteManifest.ts
290
+ const FILE = "site-manifest.json";
291
+ const isRecord = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
292
+ const manifestFindings = (ctx) => {
293
+ if (!ctx.has(FILE)) return [{
294
+ message: "No site-manifest.json in the build: the site has not adopted @v-office/site-manifest and no rollout can reach it",
295
+ path: FILE
296
+ }];
297
+ let doc;
298
+ try {
299
+ doc = JSON.parse(ctx.read(FILE));
300
+ } catch {
301
+ return [{
302
+ message: "site-manifest.json is not valid JSON",
303
+ path: FILE
304
+ }];
305
+ }
306
+ if (!isRecord(doc)) return [{
307
+ message: "site-manifest.json is not a JSON object",
308
+ path: FILE
309
+ }];
310
+ if (doc.manifestVersion !== 1) return [{
311
+ message: `manifestVersion ${JSON.stringify(doc.manifestVersion)} is not one of the versions the controller reads (1); the build is reported without a manifest`,
312
+ path: FILE
313
+ }];
314
+ if (!isRecord(doc.packages) || Object.keys(doc.packages).length === 0) return [{
315
+ message: "packages is empty: no installed version was recorded",
316
+ path: FILE
317
+ }];
318
+ return [];
319
+ };
320
+ /** A site without a readable manifest is outside every rollout: the controller
321
+ * reads manifestVersion 1 and skips everything else. */
322
+ const siteManifest = {
323
+ id: "site-manifest",
324
+ title: "The build wrote a readable site-manifest.json",
325
+ severity: "warning",
326
+ begin: (ctx) => ({ finish: () => manifestFindings(ctx) })
327
+ };
328
+ //#endregion
329
+ //#region src/distChecks/sitemap.ts
330
+ const pathOf = (url) => {
331
+ try {
332
+ return new URL(url.trim(), "http://site.invalid").pathname;
333
+ } catch {
334
+ return null;
335
+ }
336
+ };
337
+ //#endregion
338
+ //#region src/distChecks/index.ts
339
+ /**
340
+ * The dist checks: the platform's checks over a build's `dist/`, run by the build worker on every
341
+ * build of every website at the worker's pinned version of this package — public sites, the guest
342
+ * and owner apps, and sites that never installed it. The site checks (`checks/`) are the other
343
+ * family: they run inside a site's own `astro build`, at the site's pinned version. What decides
344
+ * the family is who runs a check, not what it reads: several site checks read `dist/` too. A check
345
+ * every website must pass, whether or not it adopted this package, belongs here.
346
+ * `@v-office/site-checks/dist-checks` is this file; the integration never runs these.
347
+ * See docs/website-platform/process/10-dist-checks.md.
348
+ */
349
+ const distChecks = [
350
+ siteManifest,
351
+ keyPages,
352
+ notFoundBeacon,
353
+ internalLinks,
354
+ legalPages,
355
+ pageMetadata,
356
+ placeholderContent,
357
+ insecureResources,
358
+ {
359
+ id: "sitemap",
360
+ title: "robots.txt and the sitemap point at files of the build",
361
+ severity: "warning",
362
+ begin(ctx) {
363
+ if (!ctx.isAstro) return null;
364
+ const findings = [];
365
+ const sitemaps = new Set(ctx.files.filter((f) => /^sitemap[^/]*\.xml$/i.test(f)));
366
+ if (!ctx.has("robots.txt")) findings.push({
367
+ message: "No robots.txt",
368
+ path: "robots.txt"
369
+ });
370
+ else for (const line of ctx.read("robots.txt").split(/\r?\n/)) {
371
+ const match = /^\s*sitemap\s*:\s*(\S+)/i.exec(line);
372
+ if (!match) continue;
373
+ const file = pathOf(match[1])?.replace(/^\/+/, "");
374
+ if (file && !ctx.has(file)) findings.push({
375
+ message: `robots.txt names sitemap ${match[1]}, which is not in the build`,
376
+ path: "robots.txt"
377
+ });
378
+ else if (file) sitemaps.add(file);
379
+ }
380
+ if (sitemaps.size === 0) findings.push({
381
+ message: "No sitemap in the build",
382
+ path: "sitemap-index.xml"
383
+ });
384
+ for (const file of sitemaps) {
385
+ if (!ctx.has(file)) continue;
386
+ for (const match of ctx.read(file).matchAll(/<loc>\s*([^<]+?)\s*<\/loc>/g)) {
387
+ const target = pathOf(xmlText(match[1]));
388
+ if (target === null) continue;
389
+ const asFile = target.replace(/^\/+/, "");
390
+ if (/\.xml$/i.test(asFile)) {
391
+ if (ctx.has(asFile)) sitemaps.add(asFile);
392
+ else findings.push({
393
+ message: `Sitemap index lists ${target}, which is not in the build`,
394
+ path: file
395
+ });
396
+ } else if (!ctx.serves(target)) findings.push({
397
+ message: `Sitemap lists ${target}, which no file in the build serves`,
398
+ path: file
399
+ });
400
+ }
401
+ }
402
+ return { finish: () => findings };
403
+ }
404
+ }
405
+ ];
406
+ /** Runs every dist check over `distDir`. Never throws: a check that throws is a `failed` result,
407
+ * an unreadable `distDir` fails every check the same way. */
408
+ const runDistChecks = (distDir, opts, list = distChecks) => runChecks(() => loadDistContext(distDir, opts), list);
409
+ //#endregion
410
+ export { MAX_FINDINGS_PER_CHECK, MAX_MESSAGE_CHARS, MAX_PATH_CHARS, SITE_CHECKS_FILE, blockingResults, distChecks, runDistChecks, summarizeBlocking };
@@ -0,0 +1,11 @@
1
+ import { i as loadOptions, n as ResolvedOptions, r as SiteChecksOptions, t as CONFIG_FILE } from "./options-XdHJYRcb.mjs";
2
+ import { C as SiteCheck, S as Severity, _ as CheckStatus, a as blockingResults, b as Finding, c as refusalMessage, d as writeSiteChecksReport, f as BuildOutput, g as CheckRun, h as CheckResult, i as RunInput, l as summarizeBlocking, m as CheckReport, n as MAX_MESSAGE_CHARS, o as runSiteChecks, p as Check, r as MAX_PATH_CHARS, s as SITE_CHECKS_FILE, t as MAX_FINDINGS_PER_CHECK, u as summaryLines, v as DistCheck, w as SiteCheckContext, x as Page, y as DistContext } from "./runner-Cra9mzYM.mjs";
3
+ //#region src/checks/index.d.ts
4
+ /** The site checks, in the order the report shows them: the source first, then the built pages.
5
+ * The integration runs these inside the site's own `astro build`; the build worker's checks are
6
+ * the other family (`distChecks/`), and an id here must not reuse one of theirs (a test holds the
7
+ * rule). Adding a check is one file here, one entry, one test, a README row and a CHANGELOG
8
+ * entry. */
9
+ export declare const checks: readonly SiteCheck[];
10
+ //#endregion
11
+ export { type BuildOutput, CONFIG_FILE, type Check, type CheckReport, type CheckResult, type CheckRun, type CheckStatus, type DistCheck, type DistContext, type Finding, MAX_FINDINGS_PER_CHECK, MAX_MESSAGE_CHARS, MAX_PATH_CHARS, type Page, type ResolvedOptions, type RunInput, SITE_CHECKS_FILE, type Severity, type SiteCheck, type SiteCheckContext, type SiteChecksOptions, blockingResults, loadOptions, refusalMessage, runSiteChecks, summarizeBlocking, summaryLines, writeSiteChecksReport };