@v-office/site-checks 0.0.1 → 0.2.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 +151 -3
- package/dist/astro.d.mts +37 -0
- package/dist/astro.mjs +56 -0
- package/dist/dist-checks.d.mts +21 -0
- package/dist/dist-checks.mjs +410 -0
- package/dist/index.d.mts +11 -0
- package/dist/index.mjs +2 -0
- package/dist/options-CANJso9Q.d.mts +95 -0
- package/dist/report-xp_FHnYb.mjs +2538 -0
- package/dist/runner-CK4iXk8Z.d.mts +169 -0
- package/instructions/CHANGELOG.md +2 -0
- package/instructions/MIGRATION.md +2 -0
- package/instructions/versions/0.1.0/CHANGELOG.md +79 -0
- package/instructions/versions/0.1.0/MIGRATION.md +61 -0
- package/instructions/versions/0.2.0/CHANGELOG.md +64 -0
- package/instructions/versions/0.2.0/MIGRATION.md +65 -0
- package/package.json +33 -4
- package/index.js +0 -2
|
@@ -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-xp_FHnYb.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 };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { a as WiringEntry, c as loadOptions, i as SiteChecksOptions, n as CONFIG_FILE, o as WiringHook, r as ResolvedOptions, s as WiringKept, t as BannedCopy } from "./options-CANJso9Q.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-CK4iXk8Z.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 BannedCopy, 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, type WiringEntry, type WiringHook, type WiringKept, blockingResults, loadOptions, refusalMessage, runSiteChecks, summarizeBlocking, summaryLines, writeSiteChecksReport };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as writeSiteChecksReport, c as MAX_PATH_CHARS, d as runSiteChecks, f as CONFIG_FILE, i as summaryLines, l as blockingResults, m as checks, n as refusalMessage, o as MAX_FINDINGS_PER_CHECK, p as loadOptions, r as summarizeBlocking, s as MAX_MESSAGE_CHARS, t as SITE_CHECKS_FILE } from "./report-xp_FHnYb.mjs";
|
|
2
|
+
export { CONFIG_FILE, MAX_FINDINGS_PER_CHECK, MAX_MESSAGE_CHARS, MAX_PATH_CHARS, SITE_CHECKS_FILE, blockingResults, checks, loadOptions, refusalMessage, runSiteChecks, summarizeBlocking, summaryLines, writeSiteChecksReport };
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
//#region src/options.d.ts
|
|
2
|
+
/** A wording a recorded customer correction bans from the rendered pages. */
|
|
3
|
+
interface BannedCopy {
|
|
4
|
+
/** A regular expression (source), matched against each page's visible text, whitespace
|
|
5
|
+
* collapsed, so a line break cannot hide a match. */
|
|
6
|
+
pattern: string;
|
|
7
|
+
/** The correction behind it, shown with every finding. */
|
|
8
|
+
why: string;
|
|
9
|
+
}
|
|
10
|
+
/** Markup that stays inert until an initializer in `src/scripts/*.ts` binds it. */
|
|
11
|
+
interface WiringHook {
|
|
12
|
+
/** The exported initializer, e.g. `initImageCarousels`. */
|
|
13
|
+
init: string;
|
|
14
|
+
/** The text (a class, a data attribute) that identifies the markup it binds. */
|
|
15
|
+
marker: string;
|
|
16
|
+
/** "section": every component carrying the marker calls the initializer itself (a leaf that
|
|
17
|
+
* ships the markup for its parent opts out with `@bound-by-parent <init>`). "global": one call
|
|
18
|
+
* anywhere in `src/` binds every carrier. */
|
|
19
|
+
scope: "section" | "global";
|
|
20
|
+
/** Optional: a project-relative file that must still carry the marker in code; without it a
|
|
21
|
+
* renamed marker leaves nothing to bind and the call can go unnoticed. */
|
|
22
|
+
file?: string;
|
|
23
|
+
}
|
|
24
|
+
/** A text that must stay in a file: behaviour a site keeps apart from what it was built from. */
|
|
25
|
+
interface WiringKept {
|
|
26
|
+
/** Project-relative path. */
|
|
27
|
+
file: string;
|
|
28
|
+
/** The exact text, in code (a copy left in a comment does not count). */
|
|
29
|
+
contains: string;
|
|
30
|
+
/** Why it must stay, shown when it is gone. */
|
|
31
|
+
guard: string;
|
|
32
|
+
}
|
|
33
|
+
type WiringEntry = WiringHook | WiringKept;
|
|
34
|
+
/** What a site configures: data for the checks, never their severity. The same keys are read from
|
|
35
|
+
* `site-checks.config.json` at the project root and accepted by `siteChecks({ … })`; an option
|
|
36
|
+
* given to the integration wins over the file's key. */
|
|
37
|
+
interface SiteChecksOptions {
|
|
38
|
+
/** Terms that must not ship: the template ("donor") site's brand, people, places, phone, email,
|
|
39
|
+
* domain, asset names. Matched case-insensitively, whitespace collapsed. Empty: the check skips. */
|
|
40
|
+
donorTerms?: string[];
|
|
41
|
+
/** Packages imported from `src/` that may stay out of `vite.optimizeDeps.include`: a package
|
|
42
|
+
* only the server-side code imports, or one Vite handles itself. Exact specifier or package name. */
|
|
43
|
+
optimizeDepsIgnore?: string[];
|
|
44
|
+
/** Raster images under `public/` that ship without an AVIF sibling on purpose, as paths
|
|
45
|
+
* relative to the project root (`public/brand/logo.png`). */
|
|
46
|
+
imageIgnore?: string[];
|
|
47
|
+
/** Regular expressions (sources, case-insensitive) matching a feed photo URL that is still
|
|
48
|
+
* requested as JPEG or PNG. Defaults to the vOffice image hosts. */
|
|
49
|
+
feedImagePatterns?: string[];
|
|
50
|
+
/** URL paths of pages that list rentals, in addition to the pages the check recognizes by their
|
|
51
|
+
* markup (`/angebote`). */
|
|
52
|
+
listingPages?: string[];
|
|
53
|
+
/** Listing pages whose list stays client-only, with the reason: their list is the rentals free
|
|
54
|
+
* in a window, and a build-time list would show booked-out flats. */
|
|
55
|
+
listingClientOnly?: {
|
|
56
|
+
path: string;
|
|
57
|
+
reason: string;
|
|
58
|
+
}[];
|
|
59
|
+
/** Hosts a `<script src>` or `<iframe src>` may load before consent: the site's own CDN, a
|
|
60
|
+
* consent-free host. The site's own host (`site` in the Astro config) is always allowed. */
|
|
61
|
+
consentAllowedHosts?: string[];
|
|
62
|
+
/** Wordings recorded customer corrections ban. Empty: `banned-copy` skips. */
|
|
63
|
+
bannedCopy?: BannedCopy[];
|
|
64
|
+
/** URL paths (and everything below them) the copy checks do not read: legal pages ported
|
|
65
|
+
* verbatim. `/impressum` also covers `/de/impressum`. */
|
|
66
|
+
copyExcludePaths?: string[];
|
|
67
|
+
/** URL paths only `banned-copy` skips: pages whose prose is the site's but whose answers port
|
|
68
|
+
* verbatim (an FAQ). */
|
|
69
|
+
bannedCopyExcludePaths?: string[];
|
|
70
|
+
/** Sentences `duplicate-sentences` accepts twice on one page. */
|
|
71
|
+
allowDuplicateSentences?: string[];
|
|
72
|
+
/** Files or directories (project-relative) holding the text a `<blockquote>` may quote: content
|
|
73
|
+
* captures, the feed's review texts written by the build. Empty: `quote-sources` skips. */
|
|
74
|
+
quoteSources?: string[];
|
|
75
|
+
/** `rental-facts` disagreements the customer confirmed must ship as they are, one per line in
|
|
76
|
+
* the form the finding prints: `<slug> <kind> prose=<n> feed=<n>`. Either side changing makes
|
|
77
|
+
* it a finding again. */
|
|
78
|
+
factCheckAccepted?: string[];
|
|
79
|
+
/** The markup hooks and kept texts `wiring` holds (the former `scripts/wiring.json` `hooks`).
|
|
80
|
+
* Empty: the check skips. */
|
|
81
|
+
wiring?: WiringEntry[];
|
|
82
|
+
/** Rules of `page-structure` this site declines: `one-h1`, `heading-skip`, `landmark-main`,
|
|
83
|
+
* `img-alt`, `control-label`, `table-headers`, `heading-ratio`. */
|
|
84
|
+
structureIgnore?: string[];
|
|
85
|
+
/** v9 only: the Website SDK options the site's `website-sdk hub-filters check` needs
|
|
86
|
+
* (`rentalScope`, `customAttributeFilterDefinitions`), as the site passes them to the SDK. */
|
|
87
|
+
hubFilterOptions?: Record<string, unknown>;
|
|
88
|
+
}
|
|
89
|
+
type ResolvedOptions = Required<SiteChecksOptions>;
|
|
90
|
+
declare const CONFIG_FILE = "site-checks.config.json";
|
|
91
|
+
/** The file's keys with the integration's options on top. A file that cannot be parsed throws:
|
|
92
|
+
* a broken config must not silently disable a check. */
|
|
93
|
+
declare function loadOptions(root: string, overrides?: SiteChecksOptions): ResolvedOptions;
|
|
94
|
+
//#endregion
|
|
95
|
+
export { WiringEntry as a, loadOptions as c, SiteChecksOptions as i, CONFIG_FILE as n, WiringHook as o, ResolvedOptions as r, WiringKept as s, BannedCopy as t };
|