@v-office/site-checks 0.2.4 → 0.3.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,13 +1,13 @@
1
1
  # @v-office/site-checks
2
2
 
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.
3
+ The checks over a v-office website, run by the site's own pinned version in two stages:
4
+ `site-checks src` reads the project before the build, `site-checks dist` reads the built `dist/`
5
+ after it. Each stage prints what it found, writes a report in the shape of the build worker's
6
+ dist-check report, and exits non-zero when a check with severity `error` found something.
8
7
 
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.
8
+ AI Studio's build worker runs both stages around `astro build` on every deploy, so a refused
9
+ stage never goes live and the previous build stays up; the report lands in the studio and on the
10
+ admin page. Locally the two commands are how a developer looks before pushing.
11
11
 
12
12
  ## Use
13
13
 
@@ -15,42 +15,64 @@ runs wherever the site is built: locally, in the site's CI and in AI Studio.
15
15
  pnpm add --save-exact --save-dev @v-office/site-checks
16
16
  ```
17
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";
18
+ ```json
19
+ {
20
+ "scripts": {
21
+ "check:src": "site-checks src",
22
+ "check:dist": "site-checks dist"
23
+ }
24
+ }
25
+ ```
22
26
 
23
- export default defineConfig({
24
- integrations: [siteManifest(), siteChecks()],
25
- });
27
+ The scripts are a convenience for developers; the build worker calls the bin directly. Nothing
28
+ goes into `astro.config`.
29
+
30
+ ```
31
+ site-checks <src | dist> [--root <dir>] [--dist <dir>] [--site <url>] [--report <file>]
26
32
  ```
27
33
 
28
- A refused build ends with the failing checks and their first findings:
34
+ - `src` runs the source checks over the project. It never reads `dist/`, so it gives the same
35
+ answer on every machine, with or without an earlier build lying around.
36
+ - `dist` runs the site's checks over the built output together with the platform's dist checks
37
+ (below), each page parsed once. It writes `dist/site-checks.json` unless `--report` names
38
+ another file.
39
+ - `--site` is the site's public URL. Without it, `site` is read from the Astro config file as
40
+ text; without either, the checks that need it (`canonical-link`, `open-graph`,
41
+ `consent-gate`'s host rule, `sitemap-noindex`'s host rule, `v9-production-hub`) wait, as they
42
+ do for a preview host. `trailingSlash` is read from the config file the same way. The checks
43
+ read `src/` and `public/` under the root (Astro's default layout); a config that names `root`,
44
+ `srcDir` or `publicDir` stops the command.
45
+
46
+ Exit codes: 0 when nothing refused, 1 when a check with severity `error` found something, 2 on a
47
+ usage or configuration error (a `site-checks.config.json` that cannot be read stops the command).
48
+
49
+ A refused stage ends with the failing checks and their first findings:
29
50
 
30
51
  ```
31
- [site-checks] build refused: 1 check with errors
52
+ [site-checks] html-comments: error, 2 findings
53
+ src/pages/index.astro:41: An HTML comment ships to the built page, readable with View Source. …
54
+ src/components/Nav.astro:12: …
55
+ [site-checks] src refused: 1 check with errors
32
56
  - html-comments (2 findings)
33
- src/pages/index.astro:41: An HTML comment ships to the built page, readable with View Source. …
57
+ src/pages/index.astro:41: …
34
58
  src/components/Nav.astro:12: …
35
- Report: dist/site-checks.json
36
59
  ```
37
60
 
38
61
  ## Configuration
39
62
 
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.
63
+ `site-checks.config.json` at the project root holds the site's data for the checks. Severities
64
+ are fixed by the package: a site configures data, never whether a check blocks. A key of a check
65
+ an earlier version had (`wiring`, `optimizeDepsIgnore`) is noted and ignored; an unknown key stops
66
+ the command.
43
67
 
44
68
  | Key | Used by | What |
45
69
  | ------------------------- | ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
46
70
  | `donorTerms` | `donor-terms` | Terms that must not ship: the template site's brand, people, places, phone, email, domain, asset names. Plain strings, matched as whole words, 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
71
  | `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
72
  | `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
73
  | `listingPages` | `listing-noindex`, `listing-links` | URL paths of pages that list rentals, in addition to the pages the check recognizes by their markup. |
51
74
  | `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
- | `wiring` | `wiring` | Markup hooks `{ init, marker, scope: "section" \| "global", file? }` and kept texts `{ file, contains, guard }` (the former `scripts/wiring.json` `hooks`). |
75
+ | `consentAllowedHosts` | `consent-gate` | Hosts a `<script src>` or `<iframe src>` may load before consent. The site's own host is always allowed. |
54
76
  | `hubFilterOptions` | `v9-hub-filters` | v9: the Website SDK options the Hub filter check needs (`rentalScope`, `customAttributeFilterDefinitions`), as the site passes them to the SDK. |
55
77
  | `structureIgnore` | `page-structure` | Rules the site declines: `one-h1`, `heading-skip`, `landmark-main`, `img-alt`, `control-label`, `table-headers`, `heading-ratio`. |
56
78
  | `bannedCopy` | `banned-copy` | Wordings recorded customer corrections ban, as `{ "pattern", "why" }` (a regular expression over the page's visible text). |
@@ -62,27 +84,31 @@ Severities are fixed by the package: a site configures data, never whether a che
62
84
 
63
85
  ## The checks
64
86
 
87
+ ### `src`: before the build
88
+
89
+ | id | Severity | What it refuses or reports | How to fix |
90
+ | ---------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
91
+ | `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. |
92
+ | `image-formats` | error | A raster image under `public/` without an `.avif` sibling. Favicons, the apple-touch icon and `icon-<n>` PNGs at the root of `public/` are left out. | Encode the AVIF (or list the file in `imageIgnore`). |
93
+ | `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 deploy. | Keep the token in the store's meta (`meta.get`) and reuse the entries (`store.keys()`) when it matches. |
94
+ | `v9-hub-filters` | warning | v9 only (`CMS_BACKEND=v9` in the build's env or `.env` / `.env.production`, else AI Studio's `PMS_BACKEND=v9`): a Hub filter the site's search needs that the be-on! Hub does not serve, asked through the site's own `website-sdk hub-filters check`; a Hub that cannot be asked. A warning: the outcome is the Hub's data. | Add the entry in the Hub (`website-sdk hub-filters request`), or drop it from the SDK options. Needs `install`. |
95
+
96
+ ### `dist`: after the build
97
+
65
98
  | id | Severity | What it refuses or reports | How to fix |
66
99
  | --------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
67
- | `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. |
68
100
  | `view-source` | error | A developer's note a visitor can read with View Source: an HTML comment in a built page (framework markers are allowed), a comment in an inline `<script>`, `<style>` or event handler that is also in `src/` or `public/`, a comment in CSS or a line comment in JS copied from `public/`, a source map or a reference to one in any shipped file. Bundled JS and CSS are not scanned for comments. | Remove the comment; turn source maps off in the build. |
69
101
  | `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, as a whole word. Skipped without configured terms. | Replace the term; list the template site's terms in `donorTerms`. |
70
- | `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. |
71
- | `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. |
72
102
  | `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`. |
73
- | `image-formats` | error | A raster image under `public/` without an `.avif` sibling. | Encode the AVIF (or list the file in `imageIgnore`). |
74
103
  | `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()`. |
75
104
  | `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. |
76
105
  | `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. |
77
106
  | `sitemap-noindex` | error | A sitemap entry whose page says noindex (waits while every page is noindex) or is not in the build; an `llms.txt` link to a page that is not there. Skipped without a sitemap and `llms.txt`. | Make the sitemap filter and the noindex routes agree; fix the link. |
78
- | `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. |
79
- | `wiring` | error | A component carrying a configured hook's marker whose initializer nothing calls (`section`: the component itself; `global`: anything in `src/`), through leaves marked `@bound-by-parent <init>`; a kept text gone from its file. Comments are stripped first. Skipped without `wiring`. | Call the initializer, mark the leaf `@bound-by-parent`, or put the kept text back. |
80
- | `unused-initializers` | warning | An `init*` exported from `src/scripts/*.ts` that nothing calls. Skipped without `src/scripts/`. | Wire the feature, or delete the leftover. |
81
- | `v9-hub-filters` | warning | v9 only (`CMS_BACKEND=v9` in the build's env or `.env` / `.env.production`, else AI Studio's `PMS_BACKEND=v9`): a Hub filter the site's search needs that the be-on! Hub does not serve, asked through the site's own `website-sdk hub-filters check`; a Hub that cannot be asked. A warning: the outcome is the Hub's data. | Add the entry in the Hub (`website-sdk hub-filters request`), or drop it from the SDK options. |
82
- | `canonical-link` | error | On the launched site (a production `site`, some indexable page): an indexable page without an absolute `<link rel="canonical">`. | Build it from the Astro `site` and the page path. |
107
+ | `page-heads` | warning | On indexable pages: a title over 60 characters, a description empty or over 160, a title or description another page repeats. A missing one is `page-metadata`. | Shorten; give each page its own. |
108
+ | `canonical-link` | error | On the launched site (a production site URL, some indexable page): an indexable page without an absolute `<link rel="canonical">`. | Build it from the Astro `site` and the page path. |
83
109
  | `open-graph` | warning | On the launched site: an indexable page without an absolute `og:url` and `og:image`. | Add them, absolute. |
84
110
  | `trailing-slash` | warning | On the launched site: `trailingSlash` is not `"never"`. | Set `trailingSlash: "never"`; write internal links without a trailing slash. |
85
- | `v9-production-hub` | warning | v9 only, on the launched site: the build's env does not call the production Hub (`CMS_STAGE=production` or the production Hub URLs); a committed `.env.local`; a committed `HUB_API_KEY` equal to `.env.local`'s. Waits for a production `site` and an indexable page. | Set the production stage or URLs and the customer's production key; untrack `.env.local`. |
111
+ | `v9-production-hub` | warning | v9 only, on the launched site: the build's env does not call the production Hub (`CMS_STAGE=production` or the production Hub URLs); a committed `.env.local`; a committed `HUB_API_KEY` equal to `.env.local`'s. Waits for a production site URL and an indexable page. | Set the production stage or URLs and the customer's production key; untrack `.env.local`. |
86
112
  | `page-structure` | warning | One `<h1>`, no skipped heading level, no flood of `<h3>` under few `<h2>`, a `<main>`, `alt` on every image, a label on every control, a caption and scoped `<th>` on every table. | Fix the component where a fault repeats; decline a rule in `structureIgnore`. |
87
113
  | `load-order` | warning | At start: an on-demand library (map, chart, 3D) in the start-up code, a start-up chunk over 150 KB compressed, photos after the first in card swipe strips with a URL, a first-paint photo from 100 KB up in one size only, a preloaded swap face without a `size-adjust` stand-in. | `import()` on demand; first slide only; width `srcset`; a `local()` stand-in. |
88
114
  | `banned-copy` | warning | A `bannedCopy` wording in a page's visible text. Skipped without configured wordings. | Reword. |
@@ -90,22 +116,27 @@ Severities are fixed by the package: a site configures data, never whether a che
90
116
  | `quote-sources` | warning | A `<blockquote>` not word for word in `quoteSources`; a configured source that is missing. Skipped without sources. | Quote the source exactly; restore the step that writes the source. |
91
117
  | `rental-facts` | warning | On rental pages (the rental blocks' `data-rental-stats` / `data-rental-description` markers): the fact row against the same number in the owner's German description; a perk line of `src/data/perks.ts` a unit's amenities do not back. | The customer corrects the PMS; a confirmed one goes into `factCheckAccepted`. |
92
118
 
119
+ The `dist` stage also runs the platform's dist checks, all warnings, which a site configures
120
+ nothing for: `site-manifest`, `key-pages`, `not-found-beacon`, `internal-links`, `legal-pages`,
121
+ `page-metadata`, `placeholder-content`, `insecure-resources` and `sitemap`. The build worker runs
122
+ these on its own too, over every build of every website, with or without this package.
123
+
93
124
  A check that does not apply to the site reports `skipped`; a check that fails itself reports
94
125
  `failed` and never blocks.
95
126
 
96
- A check whose outcome depends on PMS data, not on the site's code, is a warning: the integration
97
- runs in every build, the nightly deploy builds included.
127
+ A check whose outcome depends on PMS data, not on the site's code, is a warning: the stages run in
128
+ every build, the nightly deploy builds included.
98
129
 
99
130
  ## The report
100
131
 
101
- `dist/site-checks.json`:
132
+ `dist/site-checks.json` (the `dist` stage), or the file `--report` names:
102
133
 
103
134
  ```json
104
135
  {
105
136
  "ranAt": "2026-10-08T14:00:00.000Z",
106
137
  "durationMs": 812,
107
138
  "results": [
108
- { "id": "html-comments", "status": "ok", "findings": [], "omitted": 0 },
139
+ { "id": "site-manifest", "status": "ok", "findings": [], "omitted": 0 },
109
140
  {
110
141
  "id": "donor-terms",
111
142
  "status": "error",
@@ -119,33 +150,20 @@ runs in every build, the nightly deploy builds included.
119
150
  ```
120
151
 
121
152
  `status` is `ok`, `warning`, `error`, `skipped` or `failed`. At most 25 findings are kept per
122
- check; `omitted` counts the rest. The build worker merges the file into the report of its own
123
- checks (below), so the controller stores both families alike. The worker never uploads the file:
124
- it names source paths and configured terms.
125
-
126
- ## The build worker's checks
127
-
128
- The package also holds the dist checks AI Studio's build worker runs over `dist/` after every
129
- build of every website, whether or not the site installed this package: `site-manifest`,
130
- `key-pages`, `not-found-beacon`, `internal-links`, `legal-pages`, `page-metadata`,
131
- `placeholder-content`, `insecure-resources` and `sitemap`, all warnings. The integration never runs
132
- them and a site configures nothing for them; their findings show up next to the site checks'. They
133
- are exported from `@v-office/site-checks/dist-checks` (`runDistChecks(distDir, { isAstro, siteUrl })`)
134
- for the worker.
153
+ check; `omitted` counts the rest. The build worker stores the report with the build; it never
154
+ uploads the file, which names source paths and configured terms.
135
155
 
136
156
  ## Programmatic use
137
157
 
138
158
  ```ts
139
- import { runSiteChecks } from "@v-office/site-checks";
159
+ import { runStage } from "@v-office/site-checks";
140
160
 
141
- const report = await runSiteChecks({
142
- root: "/path/to/site",
143
- distDir: "/path/to/site/dist",
144
- config: { optimizeDepsInclude: ["react"] },
145
- });
161
+ const before = await runStage("src", { root: "/path/to/site" });
162
+ const after = await runStage("dist", { root: "/path/to/site", site: "https://www.example.de" });
146
163
  ```
147
164
 
148
- Without a `dist/`, the checks that need built pages report `skipped`.
165
+ `runDistChecks(distDir, { isAstro, siteUrl })` runs the platform's dist checks alone, over any
166
+ build output: the worker uses it for the guest and owner apps and for sites without this package.
149
167
 
150
168
  ## Development
151
169
 
package/dist/bin.d.mts ADDED
@@ -0,0 +1 @@
1
+ export {}
package/dist/bin.mjs ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ import { n as cli } from "./cli-Cj1FkuvI.mjs";
3
+ //#region src/bin.ts
4
+ process.exitCode = await cli(process.argv.slice(2), {
5
+ out: (line) => console.log(line),
6
+ err: (line) => console.error(line)
7
+ });
8
+ //#endregion
9
+ export {};