@v-office/site-checks 0.1.0 → 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.
@@ -1,4 +1,4 @@
1
- import { n as ResolvedOptions, r as SiteChecksOptions } from "./options-XdHJYRcb.mjs";
1
+ import { i as SiteChecksOptions, r as ResolvedOptions } from "./options-CANJso9Q.mjs";
2
2
  import { parseHTML } from "linkedom";
3
3
  //#region src/types.d.ts
4
4
  /** Two families of checks share these types, one runner and one report shape:
@@ -86,6 +86,8 @@ type SiteCheckContext = BuildOutput & {
86
86
  site: string | undefined;
87
87
  /** `vite.optimizeDeps.include` from the resolved Astro config. */
88
88
  optimizeDepsInclude: string[];
89
+ /** `trailingSlash` from the Astro config ("always", "never", "ignore"), when known. */
90
+ trailingSlash: string | undefined;
89
91
  };
90
92
  options: ResolvedOptions;
91
93
  /** Files under `srcDir` with one of the extensions (`.astro`, …), as absolute paths. */
@@ -4,5 +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
7
8
  - `versions/0.1.0/CHANGELOG.md`: release notes for 0.1.0
8
9
  - `versions/0.0.1/CHANGELOG.md`: release notes for 0.0.1
@@ -4,5 +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
7
8
  - `versions/0.1.0/MIGRATION.md`: Migration: 0.1.0
8
9
  - `versions/0.0.1/MIGRATION.md`: Migration: 0.0.1
@@ -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,6 +1,6 @@
1
1
  {
2
2
  "name": "@v-office/site-checks",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
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": {
@@ -1,37 +0,0 @@
1
- //#region src/options.d.ts
2
- /** What a site configures: data for the checks, never their severity. The same keys are read from
3
- * `site-checks.config.json` at the project root and accepted by `siteChecks({ … })`; an option
4
- * given to the integration wins over the file's key. */
5
- interface SiteChecksOptions {
6
- /** Terms that must not ship: the template ("donor") site's brand, people, places, phone, email,
7
- * domain, asset names. Matched case-insensitively, whitespace collapsed. Empty: the check skips. */
8
- donorTerms?: string[];
9
- /** Packages imported from `src/` that may stay out of `vite.optimizeDeps.include`: a package
10
- * only the server-side code imports, or one Vite handles itself. Exact specifier or package name. */
11
- optimizeDepsIgnore?: string[];
12
- /** Raster images under `public/` that ship without an AVIF sibling on purpose, as paths
13
- * relative to the project root (`public/brand/logo.png`). */
14
- imageIgnore?: string[];
15
- /** Regular expressions (sources, case-insensitive) matching a feed photo URL that is still
16
- * requested as JPEG or PNG. Defaults to the vOffice image hosts. */
17
- feedImagePatterns?: string[];
18
- /** URL paths of pages that list rentals, in addition to the pages the check recognizes by their
19
- * markup (`/angebote`). */
20
- listingPages?: string[];
21
- /** Listing pages whose list stays client-only, with the reason: their list is the rentals free
22
- * in a window, and a build-time list would show booked-out flats. */
23
- listingClientOnly?: {
24
- path: string;
25
- reason: string;
26
- }[];
27
- /** Hosts a `<script src>` or `<iframe src>` may load before consent: the site's own CDN, a
28
- * consent-free host. The site's own host (`site` in the Astro config) is always allowed. */
29
- consentAllowedHosts?: string[];
30
- }
31
- type ResolvedOptions = Required<SiteChecksOptions>;
32
- declare const CONFIG_FILE = "site-checks.config.json";
33
- /** The file's keys with the integration's options on top. A file that cannot be parsed throws:
34
- * a broken config must not silently disable a check. */
35
- declare function loadOptions(root: string, overrides?: SiteChecksOptions): ResolvedOptions;
36
- //#endregion
37
- export { loadOptions as i, ResolvedOptions as n, SiteChecksOptions as r, CONFIG_FILE as t };