@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,169 @@
|
|
|
1
|
+
import { i as SiteChecksOptions, r as ResolvedOptions } from "./options-CANJso9Q.mjs";
|
|
2
|
+
import { parseHTML } from "linkedom";
|
|
3
|
+
//#region src/types.d.ts
|
|
4
|
+
/** Two families of checks share these types, one runner and one report shape:
|
|
5
|
+
* - the site checks (`checks/`) over a site's source and built output, run inside the site's own
|
|
6
|
+
* `astro build` and written to `dist/site-checks.json`;
|
|
7
|
+
* - the dist checks (`distChecks/`) over the built output only, run by the build worker on every
|
|
8
|
+
* build of every website, the guest and owner apps included.
|
|
9
|
+
* The worker merges both into one report, which the controller validates and stores alike. Only a
|
|
10
|
+
* check whose severity is `error` refuses the build, the way a failed `astro check` does. */
|
|
11
|
+
type Severity = "warning" | "error";
|
|
12
|
+
/** `skipped`: the check does not apply to this site (no config, no built pages). `failed`: the
|
|
13
|
+
* check itself threw — reported, never blocking. */
|
|
14
|
+
type CheckStatus = "ok" | Severity | "skipped" | "failed";
|
|
15
|
+
/** One thing a check found: what, and on which file when known. Paths of the built output are
|
|
16
|
+
* relative to `dist/`, source paths relative to the project root. */
|
|
17
|
+
type Finding = {
|
|
18
|
+
message: string;
|
|
19
|
+
path?: string;
|
|
20
|
+
};
|
|
21
|
+
type CheckResult = {
|
|
22
|
+
id: string;
|
|
23
|
+
status: CheckStatus;
|
|
24
|
+
/** Capped by the runner; `omitted` counts what the cap cut. */
|
|
25
|
+
findings: Finding[];
|
|
26
|
+
omitted: number;
|
|
27
|
+
};
|
|
28
|
+
type CheckReport = {
|
|
29
|
+
ranAt: string;
|
|
30
|
+
durationMs: number;
|
|
31
|
+
results: CheckResult[];
|
|
32
|
+
};
|
|
33
|
+
type Document = ReturnType<typeof parseHTML>["document"];
|
|
34
|
+
/** One HTML file of the build, parsed once, shown to every check, then let go: the runner holds
|
|
35
|
+
* one page at a time, so memory follows the largest page and not the page count. */
|
|
36
|
+
type Page = {
|
|
37
|
+
/** Posix path relative to `dist/`, e.g. `about-us/index.html`. */
|
|
38
|
+
path: string;
|
|
39
|
+
/** The URL path the file is served at, e.g. `/about-us/`. */
|
|
40
|
+
url: string;
|
|
41
|
+
/** What relative references resolve against: `<base href>` when the page has one, else `url`. */
|
|
42
|
+
base: string;
|
|
43
|
+
/** A redirect stub (`<meta http-equiv="refresh">`): nobody reads it, so page checks skip it. */
|
|
44
|
+
redirect: boolean;
|
|
45
|
+
/** `<meta name="robots">` says `noindex`. */
|
|
46
|
+
noindex: boolean;
|
|
47
|
+
document: Document;
|
|
48
|
+
/** The text a visitor can read: script, style, noscript and template contents left out. */
|
|
49
|
+
visibleText: () => string;
|
|
50
|
+
/** Every attribute value on the page (`alt`, `title`, `href`, island props, …). */
|
|
51
|
+
attributeValues: () => string[];
|
|
52
|
+
/** The data of every HTML comment node, outside script and style text. */
|
|
53
|
+
comments: () => string[];
|
|
54
|
+
};
|
|
55
|
+
/** A build's output, listed once: what both families read of `dist/`. */
|
|
56
|
+
type BuildOutput = {
|
|
57
|
+
distDir: string;
|
|
58
|
+
/** Every file of the build, as a posix path relative to `distDir`. */
|
|
59
|
+
files: string[];
|
|
60
|
+
has: (file: string) => boolean;
|
|
61
|
+
read: (file: string) => string;
|
|
62
|
+
/** Whether a same-site URL path is served by a file of the build: the file itself,
|
|
63
|
+
* `<path>/index.html` or `<path>.html`. Query and fragment ignored. */
|
|
64
|
+
serves: (urlPath: string) => boolean;
|
|
65
|
+
};
|
|
66
|
+
/** What a dist check gets: the build's output, and which kind of build it is. */
|
|
67
|
+
type DistContext = BuildOutput & {
|
|
68
|
+
/** An Astro build (public website: many pages, a 404 page, a sitemap) as opposed to a Vite
|
|
69
|
+
* single-page app (guest, owner: one index.html, routes handled by the app). Checks that only
|
|
70
|
+
* make sense for one kind skip the other. */
|
|
71
|
+
isAstro: boolean;
|
|
72
|
+
/** The site's own origin (`https://www.example-fewo.de`) when the build knows its public URL:
|
|
73
|
+
* absolute links to it are the site's own and are checked like relative ones — with a `site`,
|
|
74
|
+
* canonical, alternate and sitemap URLs are absolute. */
|
|
75
|
+
origin: string | undefined;
|
|
76
|
+
};
|
|
77
|
+
/** What a site check gets. The built output may be absent (a programmatic run before a build):
|
|
78
|
+
* checks that need pages return `null` from `begin` then. */
|
|
79
|
+
type SiteCheckContext = BuildOutput & {
|
|
80
|
+
root: string;
|
|
81
|
+
srcDir: string;
|
|
82
|
+
publicDir: string;
|
|
83
|
+
hasDist: boolean;
|
|
84
|
+
config: {
|
|
85
|
+
/** `site` from the Astro config, when set. */
|
|
86
|
+
site: string | undefined;
|
|
87
|
+
/** `vite.optimizeDeps.include` from the resolved Astro config. */
|
|
88
|
+
optimizeDepsInclude: string[];
|
|
89
|
+
/** `trailingSlash` from the Astro config ("always", "never", "ignore"), when known. */
|
|
90
|
+
trailingSlash: string | undefined;
|
|
91
|
+
};
|
|
92
|
+
options: ResolvedOptions;
|
|
93
|
+
/** Files under `srcDir` with one of the extensions (`.astro`, …), as absolute paths. */
|
|
94
|
+
sourceFiles: (extensions: ReadonlySet<string>) => string[];
|
|
95
|
+
readSource: (absolute: string) => string;
|
|
96
|
+
/** A finding path for a file of the project: relative to `root`, posix. */
|
|
97
|
+
rel: (absolute: string) => string;
|
|
98
|
+
packageJson: {
|
|
99
|
+
dependencies: Record<string, string>;
|
|
100
|
+
devDependencies: Record<string, string>;
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
/** One check on one build. The runner parses the HTML pages one after the other and shows each to
|
|
104
|
+
* `visit`; a page is gone after its visit, so a check keeps what it needs from it, never the page.
|
|
105
|
+
* `finish` runs after the last page. */
|
|
106
|
+
type CheckRun = {
|
|
107
|
+
visit?: (page: Page) => void;
|
|
108
|
+
finish: () => Finding[] | Promise<Finding[]>;
|
|
109
|
+
};
|
|
110
|
+
type Check<Context> = {
|
|
111
|
+
/** Stable kebab-case id; the controller stores results by it. Unique across both families: the
|
|
112
|
+
* worker merges them into one report (a test holds the rule). */
|
|
113
|
+
id: string;
|
|
114
|
+
title: string;
|
|
115
|
+
/** Fixed here, never by a site. A check whose outcome depends on PMS data, not on the site's
|
|
116
|
+
* code, must be `warning`: an `error` also refuses the nightly deploy builds. */
|
|
117
|
+
severity: Severity;
|
|
118
|
+
/** Starts the check, or returns `null` when it does not apply to this site. Deterministic,
|
|
119
|
+
* touches no network. */
|
|
120
|
+
begin: (ctx: Context) => CheckRun | null;
|
|
121
|
+
};
|
|
122
|
+
type SiteCheck = Check<SiteCheckContext>;
|
|
123
|
+
type DistCheck = Check<DistContext>;
|
|
124
|
+
//#endregion
|
|
125
|
+
//#region src/report.d.ts
|
|
126
|
+
/** The report's file name under `dist/`. The build worker reads it after `astro build`, merges it
|
|
127
|
+
* with its own checks and never uploads it (it names source paths and configured terms). */
|
|
128
|
+
declare const SITE_CHECKS_FILE = "site-checks.json";
|
|
129
|
+
declare const writeSiteChecksReport: (distDir: string, report: CheckReport) => void;
|
|
130
|
+
/** One line per check that found something or could not run, for the build log. */
|
|
131
|
+
declare const summaryLines: (report: CheckReport) => string[];
|
|
132
|
+
/** The error `astro build` ends with when a check refuses: every failing check, its first findings,
|
|
133
|
+
* and where the whole report is. */
|
|
134
|
+
declare const refusalMessage: (report: CheckReport) => string;
|
|
135
|
+
/** One line naming what refused the build, for the studio: the failing checks and their counts. */
|
|
136
|
+
declare const summarizeBlocking: (report: CheckReport) => string;
|
|
137
|
+
//#endregion
|
|
138
|
+
//#region src/context.d.ts
|
|
139
|
+
type ContextInput = {
|
|
140
|
+
root: string;
|
|
141
|
+
srcDir: string;
|
|
142
|
+
publicDir: string;
|
|
143
|
+
distDir: string;
|
|
144
|
+
config: SiteCheckContext["config"];
|
|
145
|
+
options: ResolvedOptions;
|
|
146
|
+
};
|
|
147
|
+
//#endregion
|
|
148
|
+
//#region src/runner.d.ts
|
|
149
|
+
/** Findings kept per check in the report; the rest is counted in `omitted`. */
|
|
150
|
+
declare const MAX_FINDINGS_PER_CHECK = 25;
|
|
151
|
+
/** The controller's `siteCheckReportSchema` accepts a finding message of at most 2000 characters
|
|
152
|
+
* and a path of at most 1000, and skips a report it cannot read as a whole: one over-long finding
|
|
153
|
+
* (a check that quotes a long URL or template expression) must not cost the whole report. */
|
|
154
|
+
declare const MAX_MESSAGE_CHARS = 2000;
|
|
155
|
+
declare const MAX_PATH_CHARS = 1000;
|
|
156
|
+
type RunInput = {
|
|
157
|
+
root: string;
|
|
158
|
+
distDir: string;
|
|
159
|
+
srcDir?: string | undefined;
|
|
160
|
+
publicDir?: string | undefined;
|
|
161
|
+
config?: Partial<ContextInput["config"]> | undefined;
|
|
162
|
+
options?: SiteChecksOptions | undefined;
|
|
163
|
+
};
|
|
164
|
+
/** Runs every site check over the project and its build. */
|
|
165
|
+
declare const runSiteChecks: (input: RunInput, list?: readonly SiteCheck[]) => Promise<CheckReport>;
|
|
166
|
+
/** Results with status `error`: the only ones that refuse a build. */
|
|
167
|
+
declare const blockingResults: (report: CheckReport) => CheckResult[];
|
|
168
|
+
//#endregion
|
|
169
|
+
export { SiteCheck as C, Severity as S, CheckStatus as _, blockingResults as a, Finding as b, refusalMessage as c, writeSiteChecksReport as d, BuildOutput as f, CheckRun as g, CheckResult as h, RunInput as i, summarizeBlocking as l, CheckReport as m, MAX_MESSAGE_CHARS as n, runSiteChecks as o, Check as p, MAX_PATH_CHARS as r, SITE_CHECKS_FILE as s, MAX_FINDINGS_PER_CHECK as t, summaryLines as u, DistCheck as v, SiteCheckContext as w, Page as x, DistContext as y };
|
|
@@ -4,4 +4,6 @@
|
|
|
4
4
|
|
|
5
5
|
Release notes of `@v-office/site-checks`, newest first. Each version has its own directory.
|
|
6
6
|
|
|
7
|
+
- `versions/0.2.0/CHANGELOG.md`: release notes for 0.2.0
|
|
8
|
+
- `versions/0.1.0/CHANGELOG.md`: release notes for 0.1.0
|
|
7
9
|
- `versions/0.0.1/CHANGELOG.md`: release notes for 0.0.1
|
|
@@ -4,4 +4,6 @@
|
|
|
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.2.0/MIGRATION.md`: Migration: 0.1.0 to 0.2.0
|
|
8
|
+
- `versions/0.1.0/MIGRATION.md`: Migration: 0.1.0
|
|
7
9
|
- `versions/0.0.1/MIGRATION.md`: Migration: 0.0.1
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Changelog: 0.1.0
|
|
2
|
+
|
|
3
|
+
The first release with checks (0.0.1 only held the package name on npm). `@v-office/site-checks` runs checks over a site's source and built output at
|
|
4
|
+
the end of `astro build`, writes `dist/site-checks.json` and refuses the build when a check with
|
|
5
|
+
severity `error` finds something. It takes over the site-shipping guards of the sites' git commit
|
|
6
|
+
gate, as a pinned package that runs wherever the site is built. A refused build never goes live;
|
|
7
|
+
a build with warnings does, and the findings show up in AI Studio with the build.
|
|
8
|
+
|
|
9
|
+
## Added
|
|
10
|
+
|
|
11
|
+
- The `siteChecks()` Astro integration (`@v-office/site-checks/astro`). It runs after the build,
|
|
12
|
+
prints one line per check that found something, and ends the build with
|
|
13
|
+
`[site-checks] build refused: …` naming the failing checks and their first findings when a check
|
|
14
|
+
with severity `error` found something.
|
|
15
|
+
- `site-checks.config.json` at the project root: the site's data for the checks (`donorTerms`,
|
|
16
|
+
`optimizeDepsIgnore`, `imageIgnore`, `feedImagePatterns`, `listingPages`, `listingClientOnly`,
|
|
17
|
+
`consentAllowedHosts`). The same keys can be given as `siteChecks({ … })` options, which win over
|
|
18
|
+
the file. A file that is not valid JSON fails the build before it starts.
|
|
19
|
+
- `html-comments` (error): an HTML comment in `src/**/*.{astro,tsx,jsx,md,mdx,html}`. Astro passes
|
|
20
|
+
it into the built page, where a visitor reads it with View Source. Use `{/* … */}` in `.astro`
|
|
21
|
+
and JSX markup, `//` in frontmatter, and remove it from Markdown. The finding names the file and
|
|
22
|
+
line.
|
|
23
|
+
- `view-source` (error): a developer's note a visitor can read with View Source. An HTML comment
|
|
24
|
+
in a built page (Astro's, React's and Vue's own markers are allowed), a comment in an inline
|
|
25
|
+
`<script>` or `<style>`, a comment in shipped CSS, a line comment in shipped JS, a source map file
|
|
26
|
+
or a reference to one. Remove the comment; turn source maps off in the build.
|
|
27
|
+
- `donor-terms` (error): a term from `donorTerms` in the visible text, the title, an inline script
|
|
28
|
+
or style (JSON-LD included) or an attribute of a built page, in a built file name, or in the
|
|
29
|
+
shipped JS and CSS. Terms are matched case-insensitively
|
|
30
|
+
with whitespace collapsed. Without configured terms the check reports `skipped`: list the
|
|
31
|
+
template site's brand, people, places, phone, email, domain and asset names.
|
|
32
|
+
- `optimize-deps` (warning): a runtime package imported from `src/` that is not listed, with the
|
|
33
|
+
exact specifier, in `vite.optimizeDeps.include`. Vite discovers it mid-session instead and
|
|
34
|
+
re-bundles every dependency, which leaves an open preview asking for files that no longer exist.
|
|
35
|
+
Add the specifier to `vite.optimizeDeps.include`, or to `optimizeDepsIgnore` when only
|
|
36
|
+
server-side code uses it.
|
|
37
|
+
- `sync-once` (warning): an inline content loader in `src/content.config.ts` that fetches the PMS
|
|
38
|
+
without the `CONTENT_SYNC_TOKEN` reuse idiom. `astro check` and `astro build` each run the
|
|
39
|
+
loader, so it syncs twice per build against a rate-limited PMS. Keep the token in the store's
|
|
40
|
+
meta (`meta.get`) and reuse the entries (`store.keys()`) when it matches.
|
|
41
|
+
- `consent-gate` (error): a third-party `<script src>` or `<iframe src>` in a built page outside
|
|
42
|
+
the consent kit's `ConsentEmbed` frame, so it loads before consent; or a vendor in
|
|
43
|
+
`ENABLED_VENDOR_IDS` (`src/data/consent.ts`) that is not `approved` in
|
|
44
|
+
`src/data/consent-registry.snapshot.json`. Frame it with `ConsentEmbed`, or register the vendor so
|
|
45
|
+
the kit injects it after consent; a consent-free host goes into `consentAllowedHosts`. Skipped in
|
|
46
|
+
a project without `src/lib/consent/`.
|
|
47
|
+
- `image-formats` (error): a raster image (`jpg`, `jpeg`, `png`, `webp`) under `public/` without an
|
|
48
|
+
`.avif` sibling, unless listed in `imageIgnore`. Encode the AVIF.
|
|
49
|
+
- `feed-image-formats` (warning): a feed photo from the vOffice image hosts requested as JPEG or
|
|
50
|
+
PNG in an `img`, `source` or `poster`. Pass feed photos through `webpUrl()`. A warning, because
|
|
51
|
+
the photos come from the PMS feed. `feedImagePatterns` overrides the host patterns; a pattern
|
|
52
|
+
that is not a valid regular expression fails the build before it starts.
|
|
53
|
+
- `listing-noindex` (error): a page that lists rentals is noindex, so the rentals it lists are
|
|
54
|
+
hidden with it. A listing page is one with the search page's `data-prerendered-results`
|
|
55
|
+
container, the `SearchResults` island, or a path in `listingPages`. Waits while every page is
|
|
56
|
+
noindex (before launch). Take the page out of the noindex routes.
|
|
57
|
+
- `listing-links` (warning): a listing page carries no links to rentals in its built HTML, so a
|
|
58
|
+
crawler running no JavaScript sees an empty list. Only the list's own links count, not the
|
|
59
|
+
header, navigation or footer. Runs once some listing has links or the build has more than ten
|
|
60
|
+
pages (a starter with an empty feed). A warning, because the links come from the PMS feed: an
|
|
61
|
+
empty or booked-out feed must not stop the builds that update prices. Render the list
|
|
62
|
+
server-side, or list the page in `listingClientOnly` with the reason.
|
|
63
|
+
- `sitemap-noindex` (error): a sitemap entry whose page says noindex or is not in the build, a
|
|
64
|
+
sitemap the index names that is not there, an `llms.txt` link to a page that is not served.
|
|
65
|
+
Skipped when the build has neither a sitemap nor `llms.txt`.
|
|
66
|
+
- `page-heads` (warning): on indexable pages, a title over 60 characters, a description that is
|
|
67
|
+
empty or over 160, a title or description another indexable page repeats. A missing title or
|
|
68
|
+
description is the build worker's `page-metadata` finding.
|
|
69
|
+
- `dist/site-checks.json`: the report, in the shape of the build worker's dist-check report
|
|
70
|
+
(`ranAt`, `durationMs`, `results` with `id`, `status`, `findings`, `omitted`). At most 25
|
|
71
|
+
findings per check are kept. The build worker reads and never uploads it.
|
|
72
|
+
- `runSiteChecks()` from `@v-office/site-checks` runs the checks programmatically; without a
|
|
73
|
+
`dist/`, the checks that need built pages report `skipped`.
|
|
74
|
+
- `@v-office/site-checks/dist-checks`: the checks AI Studio's build worker runs over `dist/` after
|
|
75
|
+
every build of every website (`site-manifest`, `key-pages`, `not-found-beacon`,
|
|
76
|
+
`internal-links`, `legal-pages`, `page-metadata`, `placeholder-content`, `insecure-resources`,
|
|
77
|
+
`sitemap`, all warnings), the same checks the worker runs today; it switches to this export
|
|
78
|
+
after the release. A site does nothing for them: the integration does not run them, and their
|
|
79
|
+
findings show up next to the site checks'.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Migration: 0.1.0
|
|
2
|
+
|
|
3
|
+
## 1. Install
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
pnpm add --save-exact --save-dev @v-office/site-checks@0.1.0
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## 2. Add the integration
|
|
10
|
+
|
|
11
|
+
```js
|
|
12
|
+
// astro.config.mjs
|
|
13
|
+
import { siteManifest } from "@v-office/site-manifest/astro";
|
|
14
|
+
import { siteChecks } from "@v-office/site-checks/astro";
|
|
15
|
+
|
|
16
|
+
export default defineConfig({
|
|
17
|
+
integrations: [siteManifest(), siteChecks()],
|
|
18
|
+
});
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## 3. Configure the site's data
|
|
22
|
+
|
|
23
|
+
Create `site-checks.config.json` at the project root:
|
|
24
|
+
|
|
25
|
+
```json
|
|
26
|
+
{
|
|
27
|
+
"donorTerms": ["Brisenhof", "Familie Petersen", "+49 4651 123", "fewo-brisenhof.de"],
|
|
28
|
+
"optimizeDepsIgnore": [],
|
|
29
|
+
"imageIgnore": ["public/brand/logo.png"],
|
|
30
|
+
"listingClientOnly": []
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
- `donorTerms`: the terms of the template site this site was started from, as plain strings,
|
|
35
|
+
one entry per spelling (the phone number with and without spaces). A site that already carries
|
|
36
|
+
`scripts/donor-terms.sh` moves its terms here.
|
|
37
|
+
- `optimizeDepsIgnore`: packages that only server-side code imports (a content loader's SDK, for
|
|
38
|
+
example), so `optimize-deps` does not ask for them in `vite.optimizeDeps.include`.
|
|
39
|
+
- `imageIgnore`: the lines of `scripts/image-check.ignore`, rasters that ship without an AVIF on
|
|
40
|
+
purpose.
|
|
41
|
+
- `listingClientOnly`: the entries of `scripts/listing-links.allow`, as `{ "path", "reason" }`.
|
|
42
|
+
- `listingPages`, `consentAllowedHosts`, `feedImagePatterns`: only when the defaults do not fit;
|
|
43
|
+
the README describes them.
|
|
44
|
+
|
|
45
|
+
## 4. Build once and read the report
|
|
46
|
+
|
|
47
|
+
```sh
|
|
48
|
+
pnpm build
|
|
49
|
+
cat dist/site-checks.json
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Fix what the checks with severity `error` refuse (the finding says how), then build again.
|
|
53
|
+
`optimize-deps`, `sync-once`, `feed-image-formats`, `listing-links` and `page-heads` findings are
|
|
54
|
+
warnings: the build goes through.
|
|
55
|
+
|
|
56
|
+
## What stays the same
|
|
57
|
+
|
|
58
|
+
- The git commit gate (`.githooks/pre-commit`) keeps running as before; this package does not
|
|
59
|
+
touch it. Its site-shipping guards now also run inside every `astro build`, with the same
|
|
60
|
+
outcome wherever the site is built.
|
|
61
|
+
- `@v-office/site-manifest` and the rest of the build are unchanged.
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Changelog: 0.2.0
|
|
2
|
+
|
|
3
|
+
The rest of the commit gate's site-shipping guards move into the package: the copy, fact, wiring,
|
|
4
|
+
structure, load-order and launch-head checks, and two checks that run only for a v9 site. Every
|
|
5
|
+
check runs inside `astro build` wherever the site is built, at the version the site pins, instead of
|
|
6
|
+
being fetched from the blueprints repository on every commit. A check whose outcome depends on
|
|
7
|
+
PMS or Hub data is a warning; the nightly builds that update prices never stop over one.
|
|
8
|
+
|
|
9
|
+
## Added
|
|
10
|
+
|
|
11
|
+
- `wiring` (error): markup that stays inert until an initializer binds it. Every component
|
|
12
|
+
carrying a configured hook's marker calls its initializer (`scope: "section"`), or something in
|
|
13
|
+
`src/` does (`scope: "global"`); a leaf that ships the markup for its parent opts out with a
|
|
14
|
+
`@bound-by-parent <init>` comment. An entry with `contains` fails when that text leaves its file.
|
|
15
|
+
Comments are stripped before any match. Configured by `wiring`; skipped without it.
|
|
16
|
+
- `unused-initializers` (warning): an `init*` exported from `src/scripts/*.ts` that nothing calls.
|
|
17
|
+
Skipped without `src/scripts/`.
|
|
18
|
+
- The two v9 checks run only when the build's backend is v9: `CMS_BACKEND` from the build's
|
|
19
|
+
environment, else from `.env` / `.env.production`, else the `PMS_BACKEND` AI Studio's builder
|
|
20
|
+
passes (a site created from the starter commits no backend). A v10 site, or one with no backend,
|
|
21
|
+
reports them `skipped`. The key falls back to the builder's `PMS_TOKEN` the same way.
|
|
22
|
+
- `v9-hub-filters` (warning, v9 only): the be-on! Hub the site builds against serves every filter
|
|
23
|
+
the site's search needs (the scope filter, the Merkliste's rental-id filter, each searchable
|
|
24
|
+
backend-filter definition). It asks the Hub through the site's own `website-sdk hub-filters
|
|
25
|
+
check`, with the build's env and `hubFilterOptions`; a site that sets the SDK CLI's
|
|
26
|
+
`HUB_RENTAL_SCOPE_PROPERTY_KIND` or `HUB_RENTAL_IDS_SEARCH` has them forwarded. A Hub that cannot be asked (no
|
|
27
|
+
`website-sdk`, an SDK without the command, no key) is reported, never passed.
|
|
28
|
+
- `v9-production-hub` (error, v9 only): a launched v9 site builds against the production Hub:
|
|
29
|
+
`CMS_STAGE=production`, or the four production Hub URLs in the build's env. Also refused: a
|
|
30
|
+
committed `.env.local` / `.env.production.local`, and a committed `HUB_API_KEY` that is the key of
|
|
31
|
+
`.env.local`. Waits while the Astro `site` is unset or a preview host, and while every page is
|
|
32
|
+
noindex.
|
|
33
|
+
- `canonical-link` (error): every indexable page of the launched site has an absolute
|
|
34
|
+
`<link rel="canonical">`. Waits for a production `site` (not a preview host) and an indexable page.
|
|
35
|
+
- `open-graph` (warning): every indexable page of the launched site has an absolute `og:url` and
|
|
36
|
+
`og:image`.
|
|
37
|
+
- `trailing-slash` (warning): the launched site declares `trailingSlash: "never"`.
|
|
38
|
+
- `page-structure` (warning): one `<h1>`, no skipped heading level, no flood of `<h3>` under few
|
|
39
|
+
`<h2>`, a `<main>` landmark, `alt` on every image, a label on every control (an `aria-hidden`
|
|
40
|
+
mirror input is not one), a caption and scoped headers on every table. `structureIgnore`
|
|
41
|
+
declines a rule.
|
|
42
|
+
- `load-order` (warning): what a built page fetches at start on a slow phone: an on-demand library
|
|
43
|
+
(a map engine, a chart library) in the start-up code, start-up chunks over 150 KB compressed,
|
|
44
|
+
photos after the first in card swipe strips carrying a URL, first-paint photos from 100 KB up in
|
|
45
|
+
one size only, a preloaded `font-display: swap` face without a `size-adjust` stand-in.
|
|
46
|
+
- `banned-copy` (warning): a wording from `bannedCopy`, a recorded customer correction, in a
|
|
47
|
+
page's visible text. Skipped without configured wordings.
|
|
48
|
+
- `duplicate-sentences` (warning): the same sentence rendered twice on one page. Waits while every
|
|
49
|
+
page is noindex.
|
|
50
|
+
- `quote-sources` (warning): a `<blockquote>` that is not word for word in the files of
|
|
51
|
+
`quoteSources`; a configured source that is missing is a finding. Skipped without sources.
|
|
52
|
+
- `rental-facts` (warning): on rental pages, the fact row (guests, bedrooms, bathrooms, area,
|
|
53
|
+
beach distance) against the same facts in the owner's description, German prose; a perk line in
|
|
54
|
+
`src/data/perks.ts` against every unit's amenities. Reads the rental blocks' gate markers
|
|
55
|
+
(`data-rental-stats`, `data-rental-description`, `data-amenities-modal`). A disagreement the
|
|
56
|
+
customer confirmed goes into `factCheckAccepted`; an entry that no longer disagrees is reported.
|
|
57
|
+
- Configuration keys: `wiring`, `hubFilterOptions`, `structureIgnore`, `bannedCopy`,
|
|
58
|
+
`copyExcludePaths`, `bannedCopyExcludePaths`, `allowDuplicateSentences`, `quoteSources`,
|
|
59
|
+
`factCheckAccepted`. A malformed value (a pattern that does not compile, a wiring entry of two
|
|
60
|
+
kinds, an unknown structure rule) fails the build before it starts.
|
|
61
|
+
|
|
62
|
+
## Changed
|
|
63
|
+
|
|
64
|
+
- `view-source` also reads inline event handler attributes (`onclick="… // note"`).
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Migration: 0.1.0 to 0.2.0
|
|
2
|
+
|
|
3
|
+
## 1. Upgrade
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
pnpm add --save-exact --save-dev @v-office/site-checks@0.2.0
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## 2. Move the commit gate's config into `site-checks.config.json`
|
|
10
|
+
|
|
11
|
+
A site that carries the blueprints guards' config files moves their content into the keys below,
|
|
12
|
+
then deletes the files. A site without one skips its row: the check reports `skipped` or uses its
|
|
13
|
+
default.
|
|
14
|
+
|
|
15
|
+
| Old file | New key |
|
|
16
|
+
| ---------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
17
|
+
| `scripts/wiring.json` `hooks` | `wiring`, the entries unchanged |
|
|
18
|
+
| `scripts/copy-check.json` `banned` | `bannedCopy`, the entries unchanged (`{ "pattern", "why" }`) |
|
|
19
|
+
| `… excludeRoutes` | `copyExcludePaths` (`"impressum"` also covers `/de/impressum`; the 404 page is always left out) |
|
|
20
|
+
| `… bannedAlsoExclude` | `bannedCopyExcludePaths` |
|
|
21
|
+
| `… allowDuplicates` | `allowDuplicateSentences` |
|
|
22
|
+
| `… capturesDir` + `quoteCorpus` | `quoteSources`, every path in one list (`["content-port/captures", "src/data/reviews.json"]`) |
|
|
23
|
+
| `scripts/fact-check.known` | `factCheckAccepted`, one string per line without its comment (`"haus-a bedrooms prose=3 feed=2"`) |
|
|
24
|
+
| `scripts/structure.deny` | `structureIgnore`, the rule ids |
|
|
25
|
+
| `src/data/hub-filters.json` (v9) | `hubFilterOptions`: `{ "customAttributeFilterDefinitions": <the list> }`, plus `rentalScope` when the site scopes its rentals; the options the site passes to the Website SDK |
|
|
26
|
+
|
|
27
|
+
A site that keeps its SDK options in code passes them from `astro.config.mjs` instead of copying
|
|
28
|
+
them:
|
|
29
|
+
|
|
30
|
+
```js
|
|
31
|
+
import { SDK_CUSTOM_ATTRIBUTE_FILTER_DEFINITIONS } from "#content-config/sdk-custom-attributes";
|
|
32
|
+
|
|
33
|
+
siteChecks({
|
|
34
|
+
hubFilterOptions: { customAttributeFilterDefinitions: SDK_CUSTOM_ATTRIBUTE_FILTER_DEFINITIONS },
|
|
35
|
+
});
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## 3. Build once and fix what refuses the build
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
pnpm build
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
New checks that can refuse a build:
|
|
45
|
+
|
|
46
|
+
- `wiring`: only with `wiring` configured. Call the initializer the finding names, or mark the leaf
|
|
47
|
+
`@bound-by-parent <init>` when its parent owns the call.
|
|
48
|
+
- `canonical-link`: only for a launched site (a production `site`, some indexable page). Give
|
|
49
|
+
every indexable page an absolute `<link rel="canonical">` from the Astro `site` and the path.
|
|
50
|
+
- `v9-production-hub`: only for a launched v9 site (`CMS_BACKEND=v9` in the build's environment,
|
|
51
|
+
`.env` or `.env.production`, or `PMS_BACKEND=v9` from AI Studio's builder). Set `CMS_STAGE=production`, or the four production Hub URLs
|
|
52
|
+
(`https://api.voffice.be-on.io/api/v1`, `…/api/v0`, `…/graphql`, `https://imgproxy.voffice.be-on.io`),
|
|
53
|
+
and the customer's production `HUB_API_KEY`; untrack a committed `.env.local`.
|
|
54
|
+
- `view-source`: a comment in an inline event handler. Remove it.
|
|
55
|
+
|
|
56
|
+
Every other new check is a warning: the build goes through and the findings show up with it.
|
|
57
|
+
|
|
58
|
+
## What stays the same
|
|
59
|
+
|
|
60
|
+
The git commit hook keeps running `astro check` and `astro build`; the build now runs these checks
|
|
61
|
+
too. The blueprints guards this release replaces whole (`copy-check.mjs`, `fact-check.py`,
|
|
62
|
+
`wiring-check.py`, `hub-filters-check.sh`, `perf-check.mjs`) can be declined in
|
|
63
|
+
`scripts/gates.deny` once the site runs 0.2.0, so a commit does not run each twice. `seo-check.sh`
|
|
64
|
+
stays: its preview-noindex, robots generator, llms.txt and host-redirect parts are not in the
|
|
65
|
+
package.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@v-office/site-checks",
|
|
3
|
-
"version": "0.0
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Build-time checks for the sites: runs inside `astro build`, writes dist/site-checks.json in the shape of the build worker's dist-check report, and refuses the build when a check with severity error finds something. The site-shipping guards of the commit gate, pinned and run where the site is built",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -9,16 +9,45 @@
|
|
|
9
9
|
"directory": "packages/site-checks"
|
|
10
10
|
},
|
|
11
11
|
"files": [
|
|
12
|
-
"
|
|
12
|
+
"dist",
|
|
13
13
|
"README.md",
|
|
14
14
|
"instructions"
|
|
15
15
|
],
|
|
16
16
|
"type": "module",
|
|
17
|
+
"types": "./dist/index.d.mts",
|
|
17
18
|
"exports": {
|
|
18
|
-
".": "./index.
|
|
19
|
+
".": "./dist/index.mjs",
|
|
20
|
+
"./astro": "./dist/astro.mjs",
|
|
21
|
+
"./dist-checks": "./dist/dist-checks.mjs",
|
|
19
22
|
"./package.json": "./package.json"
|
|
20
23
|
},
|
|
21
24
|
"publishConfig": {
|
|
22
25
|
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"linkedom": "0.18.13"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@types/node": "26.5.1",
|
|
32
|
+
"astro": "7.3.2",
|
|
33
|
+
"oxfmt": "0.67.0",
|
|
34
|
+
"oxlint": "1.82.0",
|
|
35
|
+
"tsdown": "0.23.0",
|
|
36
|
+
"typescript": "7.0.2",
|
|
37
|
+
"vitest": "^5.0.0"
|
|
38
|
+
},
|
|
39
|
+
"engines": {
|
|
40
|
+
"node": "^22.0.0 || ^24.0.0 || ^25.0.0 || >=26.0.0"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "tsdown",
|
|
44
|
+
"dev": "tsdown --watch",
|
|
45
|
+
"typecheck": "tsc --noEmit",
|
|
46
|
+
"lint": "oxlint .",
|
|
47
|
+
"lint:fix": "oxlint --fix .",
|
|
48
|
+
"fmt": "oxfmt",
|
|
49
|
+
"fmt:check": "oxfmt --check",
|
|
50
|
+
"check": "pnpm run typecheck && pnpm run lint && pnpm run fmt:check",
|
|
51
|
+
"test": "vitest run"
|
|
23
52
|
}
|
|
24
53
|
}
|
package/index.js
DELETED