@v-office/site-checks 0.5.1 → 0.5.3

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
@@ -247,7 +247,7 @@ unrelated findings, `match` picks one.
247
247
  | `page-structure` | warning | One `<h1>`, no skipped heading level, a `<main>`, `alt` on every image, a label on every control the keyboard reaches (only `aria-hidden` with `tabindex="-1"` is out of reach), a caption (or `aria-label`/`aria-labelledby`) and scoped `<th>` on every table. | Fix the component where a fault repeats; decline a rule in `structureIgnore`. |
248
248
  | `heading-ratio` | warning | Ten or more `<h3>` and more than three times as many as `<h2>` on a page: usually card titles marked up as headings. | Style a `<p>` for a card's name; decline it in `structureIgnore`. |
249
249
  | `voffice-credit` | error | A page whose site footer (a `<footer>` outside `main`, `article`, `section`, `aside`, `nav`, `blockquote`, `figure`, `dialog`) has no link to `https://www.v-office.com` (look-alike hosts and `dyn.v-office.com` do not count); a home page (a locale's `de/index.html` too) without a site footer. The wording is not read. | Add `Realisiert mit <a href="https://www.v-office.com">vOffice</a>` to the site footer, worded per language. |
250
- | `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 swap face without a `size-adjust` stand-in (preloaded, or apart: not preloaded). | `import()` on demand; first slide only; a `local()` stand-in. |
250
+ | `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 swap face without a `size-adjust` stand-in (preloaded, or apart: not preloaded), a used `font-display: optional` face. Stacks are read from `font-family` and `--font-*`. | `import()` on demand; first slide only; `swap` with a `local()` stand-in. |
251
251
  | `first-paint-photos` | error | A first-paint photo (not lazy) or image preload from 100 KB up, a file of the build, in one size only (no width `srcset` / `imagesrcset`); in the `<header>`/`<section>` of the `fetchpriority="high"` photo, a hidden slide (`aria-hidden`, `inert`, `invisible` or `opacity-0`, also at a breakpoint, never a `hover:` state; `hidden` or a closed `<dialog>` when the image is not lazy) whose image carries a URL, an SVG icon aside. | Width variants in a `srcset` with a measured `sizes`; hidden slides get `data-src` and their URL after load. |
252
252
  | `banned-copy` | warning | A `bannedCopy` wording (not scoped `"in": "src"`) in a page's visible text. Skipped without configured wordings. | Reword. |
253
253
  | `duplicate-sentences` | warning | The same sentence rendered twice on one page. Waits while every page but the 404 page is noindex. | Remove one, or list it in `allowDuplicateSentences`. |
package/dist/bin.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { n as cli } from "./cli-DDeid5ml.mjs";
2
+ import { n as cli } from "./cli-BZOXjO-z.mjs";
3
3
  // src/bin.ts
4
4
  process.exitCode = await cli(process.argv.slice(2), {
5
5
  out: (line) => console.log(line),
@@ -1714,7 +1714,11 @@ const hiddenWithin = (img, block) => {
1714
1714
  * - on a page with two or more card swipe strips, a photo after a strip's first carrying a URL
1715
1715
  * (native lazy loading reaches sideways on slow links);
1716
1716
  * - a `font-display: swap` face without a `size-adjust` stand-in behind it, which reflows the line
1717
- * (a preloaded one at first paint; one not preloaded, likely below the fold, named apart).
1717
+ * (a preloaded one at first paint; one not preloaded, likely below the fold, named apart);
1718
+ * - a used `font-display: optional` face, which a first visit keeps out for the whole page view
1719
+ * when it misses the ~100 ms block window (a homepage, where the hero photo competes).
1720
+ * Font stacks are read from `font-family` and from the `--font-*` custom properties Tailwind v4
1721
+ * puts them in (`font-family: var(--font-sans)`).
1718
1722
  * A warning: each is a cost, not a fault. The first-paint photo rules are `first-paint-photos`. */
1719
1723
  const loadOrder = {
1720
1724
  id: "load-order",
@@ -1745,6 +1749,7 @@ const loadOrder = {
1745
1749
  const strips = /* @__PURE__ */ new Map();
1746
1750
  const faces = /* @__PURE__ */ new Map();
1747
1751
  const lateFaces = /* @__PURE__ */ new Map();
1752
+ const optionalFaces = /* @__PURE__ */ new Map();
1748
1753
  const startup = (page) => {
1749
1754
  const roots = /* @__PURE__ */ new Set();
1750
1755
  for (const script of page.document.querySelectorAll("script[type=\"module\"]")) {
@@ -1813,15 +1818,18 @@ const loadOrder = {
1813
1818
  return {
1814
1819
  family: (/font-family:\s*([^;]+)/.exec(m[1])?.[1] ?? "").trim().replace(/^["']|["']$/g, ""),
1815
1820
  swap: /font-display:\s*swap/.test(m[1]),
1821
+ optional: /font-display:\s*optional/.test(m[1]),
1816
1822
  file: url && !url.startsWith("data:") ? resolve(url, base) : "",
1817
1823
  adjusted: /size-adjust\s*:/.test(m[1])
1818
1824
  };
1819
1825
  }));
1820
1826
  const adjusted = new Set(declared.filter((f) => f.adjusted).map((f) => f.family));
1821
- const stacks = [...css.replace(/@font-face\s*\{[^}]*\}/g, "").matchAll(/font-family:\s*([^;}]+)/g)].map((m) => m[1].split(",").map((s) => s.trim().replace(/^["']|["']$/g, "")));
1827
+ const stacks = [...css.replace(/@font-face\s*\{[^}]*\}/g, "").matchAll(/(?:font-family|--font-[\w-]+):\s*([^;}]+)/g)].map((m) => m[1].split(",").map((s) => s.trim().replace(/^["']|["']$/g, "")));
1822
1828
  const preloaded = new Set([...page.document.querySelectorAll("link[rel=\"preload\"][href]")].map((l) => resolve(l.getAttribute("href"), page.base)));
1823
- for (const face of declared) if (face.swap && !face.adjusted) {
1824
- if (stacks.filter((stack) => stack[0] === face.family).some((stack) => !adjusted.has(stack[1] ?? ""))) add(face.file && preloaded.has(face.file) ? faces : lateFaces, face.family, page.path);
1829
+ for (const face of declared) {
1830
+ const users = stacks.filter((stack) => stack[0] === face.family);
1831
+ if (face.optional && users.length > 0) add(optionalFaces, face.family, page.path);
1832
+ if (face.swap && !face.adjusted && users.some((stack) => !adjusted.has(stack[1] ?? ""))) add(face.file && preloaded.has(face.file) ? faces : lateFaces, face.family, page.path);
1825
1833
  }
1826
1834
  };
1827
1835
  return {
@@ -1841,6 +1849,7 @@ const loadOrder = {
1841
1849
  });
1842
1850
  for (const [family, pages] of faces) findings.push({ message: `The preloaded face "${family}" swaps in without a width-matched stand-in (size-adjust) behind it, on ${few(pages)}. Add a local() stand-in with size-adjust right after it in the stack.` });
1843
1851
  for (const [family, pages] of lateFaces) if (!faces.has(family)) findings.push({ message: `The face "${family}" swaps in without a width-matched stand-in (size-adjust) behind it, on ${few(pages)}; not preloaded, so likely below the fold. A local() stand-in with size-adjust right after it in the stack keeps the line from moving.` });
1852
+ for (const [family, pages] of optionalFaces) findings.push({ message: `The face "${family}" uses font-display: optional, on ${few(pages)}: a first visit where it arrives after the ~100 ms block window keeps the fallback font for the whole page view, until a reload finds it cached. Use font-display: swap with a local() stand-in carrying size-adjust right after it in the stack.` });
1844
1853
  return findings;
1845
1854
  }
1846
1855
  };
@@ -2526,6 +2535,25 @@ const sdkEnv = (root, processEnv = process.env) => {
2526
2535
  };
2527
2536
  /** What the developer's `.local` files set. */
2528
2537
  const localEnv = (root) => Object.assign({}, ...LOCAL_ENV_FILES.map((file) => readEnvFile(root, file)));
2538
+ // src/packageBin.ts
2539
+ /**
2540
+ * The script an installed package's bin runs, for starting it with this Node
2541
+ * (`spawn(process.execPath, [script, ...args])`). `node_modules/.bin` holds shims: a shell script,
2542
+ * and on Windows a `.cmd`, which Node starts there only through a shell (CVE-2024-27980), and a
2543
+ * shell would split the temp paths under a user name with a space. Undefined when the package is
2544
+ * not installed or names no such bin.
2545
+ */
2546
+ const packageBin = (root, pkg, name) => {
2547
+ const dir = path.join(root, "node_modules", ...pkg.split("/"));
2548
+ let bin;
2549
+ try {
2550
+ ({bin} = JSON.parse(fs.readFileSync(path.join(dir, "package.json"), "utf8")));
2551
+ } catch {
2552
+ return;
2553
+ }
2554
+ const file = typeof bin === "string" ? bin : bin && typeof bin === "object" ? bin[name] : void 0;
2555
+ return typeof file === "string" ? path.join(dir, file) : void 0;
2556
+ };
2529
2557
  // src/checks/v9.ts
2530
2558
  /** The be-on! Hub endpoints per stage, as `@v-office/website-headless` resolves `CMS_STAGE` for v9
2531
2559
  * (`sdk/endpoints.ts`). Production is what a live v9 site calls. */
@@ -2581,7 +2609,7 @@ const sdkVersion = (root) => {
2581
2609
  const run = async (cli, args, cwd) => {
2582
2610
  const { execFile } = await import("node:child_process");
2583
2611
  return new Promise((resolve) => {
2584
- execFile(cli, args, {
2612
+ execFile(process.execPath, [cli, ...args], {
2585
2613
  cwd,
2586
2614
  timeout: HUB_TIMEOUT_MS,
2587
2615
  maxBuffer: 1048576
@@ -2626,8 +2654,8 @@ const v9HubFilters = {
2626
2654
  customAttributeFilterDefinitions: list
2627
2655
  };
2628
2656
  }
2629
- const cli = path.join(ctx.root, "node_modules", ".bin", process.platform === "win32" ? "website-sdk.cmd" : "website-sdk");
2630
- if (!fs.existsSync(cli)) return [{ message: "node_modules/.bin/website-sdk is missing, so the Hub could not be asked. Install @v-office/website-sdk." }];
2657
+ const cli = packageBin(ctx.root, "@v-office/website-sdk", "website-sdk");
2658
+ if (!cli || !fs.existsSync(cli)) return [{ message: "@v-office/website-sdk is not installed, so the Hub could not be asked. Install @v-office/website-sdk." }];
2631
2659
  const config = cliConfig(env);
2632
2660
  if (!config.apiKey || !config.graphqlUrl) return [{ message: "No HUB_API_KEY or Hub URLs in the build's env, so the Hub could not be asked." }];
2633
2661
  const dir = fs.mkdtempSync(path.join(os.tmpdir(), "site-checks-hub-"));
@@ -4357,11 +4385,12 @@ async function cli(argv, io, cwd = process.cwd()) {
4357
4385
  return 0;
4358
4386
  }
4359
4387
  /** Runs a child in the project with its output on ours: 0, 1 when it fails, 2 when it cannot
4360
- * start. No stdin: a pre-push hook's stdin holds git's refs. */
4361
- const exec = (command, args, root, env, io) => new Promise((resolve) => {
4388
+ * start. No stdin: a pre-push hook's stdin holds git's refs. `name` is what an error calls it. */
4389
+ const exec = (name, [command, args, shell = false], root, env, io) => new Promise((resolve) => {
4362
4390
  const child = spawn(command, args, {
4363
4391
  cwd: root,
4364
4392
  env,
4393
+ shell,
4365
4394
  stdio: [
4366
4395
  "ignore",
4367
4396
  "inherit",
@@ -4369,7 +4398,7 @@ const exec = (command, args, root, env, io) => new Promise((resolve) => {
4369
4398
  ]
4370
4399
  });
4371
4400
  child.on("error", (err) => {
4372
- io.err(`site-checks: cannot run ${command}: ${err.message}`);
4401
+ io.err(`site-checks: cannot run ${name}: ${err.message}`);
4373
4402
  resolve(2);
4374
4403
  });
4375
4404
  child.on("close", (code) => resolve(code === 0 ? 0 : 1));
@@ -4404,11 +4433,22 @@ async function verify(root, site, io, cwd) {
4404
4433
  const steps = [
4405
4434
  ["src", () => cli(["src", ...stageArgs], io, cwd)],
4406
4435
  ["astro check", async () => {
4407
- if (fs.existsSync(path.join(root, "node_modules/@astrojs/check"))) return exec(path.join(root, "node_modules/.bin/astro"), ["check"], root, env, io);
4408
- io.out("[site-checks] astro check skipped: @astrojs/check is not installed.");
4409
- return "skipped";
4436
+ if (!fs.existsSync(path.join(root, "node_modules/@astrojs/check"))) {
4437
+ io.out("[site-checks] astro check skipped: @astrojs/check is not installed.");
4438
+ return "skipped";
4439
+ }
4440
+ const astro = packageBin(root, "astro", "astro");
4441
+ if (!astro) {
4442
+ io.err("site-checks: cannot run astro check: the astro package is not installed.");
4443
+ return 2;
4444
+ }
4445
+ return exec("astro check", [process.execPath, [astro, "check"]], root, env, io);
4410
4446
  }],
4411
- ["build", () => exec(pm, ["run", "build"], root, env, io)],
4447
+ ["build", () => exec(`${pm} run build`, process.platform === "win32" ? [
4448
+ `${pm} run build`,
4449
+ [],
4450
+ true
4451
+ ] : [pm, ["run", "build"]], root, env, io)],
4412
4452
  ["dist", () => cli(["dist", ...stageArgs], io, cwd)]
4413
4453
  ];
4414
4454
  const passed = [];
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- export { g as CONFIG_FILE, d as MAX_FINDINGS_PER_CHECK, f as MAX_MESSAGE_CHARS, p as MAX_PATH_CHARS, o as SITE_CHECKS_FILE, t as USAGE, m as blockingResults, v as checks, y as checksOf, n as cli, i as distChecks, s as findingLine, _ as loadOptions, b as readAstroConfig, c as refusalMessage, a as runDistChecks, h as runSiteChecks, r as runStage, l as summarizeBlocking, u as summaryLines } from "./cli-DDeid5ml.mjs";
1
+ export { g as CONFIG_FILE, d as MAX_FINDINGS_PER_CHECK, f as MAX_MESSAGE_CHARS, p as MAX_PATH_CHARS, o as SITE_CHECKS_FILE, t as USAGE, m as blockingResults, v as checks, y as checksOf, n as cli, i as distChecks, s as findingLine, _ as loadOptions, b as readAstroConfig, c as refusalMessage, a as runDistChecks, h as runSiteChecks, r as runStage, l as summarizeBlocking, u as summaryLines } from "./cli-BZOXjO-z.mjs";
@@ -4,6 +4,8 @@
4
4
 
5
5
  Release notes of `@v-office/site-checks`, newest first. Each version has its own directory.
6
6
 
7
+ - `versions/0.5.3/CHANGELOG.md`: release notes for 0.5.3
8
+ - `versions/0.5.2/CHANGELOG.md`: release notes for 0.5.2
7
9
  - `versions/0.5.1/CHANGELOG.md`: release notes for 0.5.1
8
10
  - `versions/0.5.0/CHANGELOG.md`: release notes for 0.5.0
9
11
  - `versions/0.4.2/CHANGELOG.md`: release notes for 0.4.2
@@ -4,6 +4,8 @@
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.5.3/MIGRATION.md`: Migration: 0.5.2 to 0.5.3
8
+ - `versions/0.5.2/MIGRATION.md`: Migration: 0.5.1 to 0.5.2
7
9
  - `versions/0.5.1/MIGRATION.md`: Migration: 0.5.0 to 0.5.1
8
10
  - `versions/0.5.0/MIGRATION.md`: Migration: 0.4.2 to 0.5.0
9
11
  - `versions/0.4.2/MIGRATION.md`: Migration: 0.4.1 to 0.4.2
@@ -0,0 +1,18 @@
1
+ # Changelog: 0.5.2
2
+
3
+ `site-checks verify` runs on Windows, so a pre-push hook that runs it no longer rejects every push
4
+ from there.
5
+
6
+ ## Fixed
7
+
8
+ - `verify` starts `astro check` with Node from the astro package's own script instead of
9
+ `node_modules/.bin/astro`, which Windows cannot start (`spawn … ENOENT`).
10
+ - `verify` runs the build (`pnpm run build` or `npm run build`) through the shell on Windows, where
11
+ pnpm and npm are usually `.cmd` files.
12
+ - `v9-hub-filters` starts `website-sdk` with Node from the package's own script instead of
13
+ `website-sdk.cmd`, which Node refuses without a shell (`spawn EINVAL`). The check now runs on
14
+ Windows instead of reporting that it failed. Its message for a missing SDK now reads
15
+ "@v-office/website-sdk is not installed".
16
+
17
+ The rules, their levels, the configuration keys, the exit codes and the report's shape stay the
18
+ same.
@@ -0,0 +1,9 @@
1
+ # Migration: 0.5.1 to 0.5.2
2
+
3
+ ## 1. Upgrade
4
+
5
+ ```sh
6
+ pnpm add --save-exact --save-dev @v-office/site-checks@0.5.2
7
+ ```
8
+
9
+ No changes required.
@@ -0,0 +1,22 @@
1
+ # Changelog: 0.5.3
2
+
3
+ `load-order` warns about web fonts declared with `font-display: optional`, and reads the font
4
+ stacks of a Tailwind v4 build, so its font rules now fire on real sites.
5
+
6
+ ## Added
7
+
8
+ - `load-order` reports a used face declared with `font-display: optional` (first in a font stack),
9
+ once per family: "The face "Lato" uses font-display: optional, on …". Under `optional`, a first
10
+ visit where the font arrives after the browser's ~100 ms block window (typically the homepage,
11
+ where the hero photo competes for the connection) keeps the fallback font for the whole page
12
+ view, until a reload finds the font cached. A face declared but used in no stack is not reported.
13
+
14
+ ## Fixed
15
+
16
+ - `load-order` reads font stacks from `--font-*` custom properties (`--font-sans: "Lato", …`,
17
+ `--font-display: …`) as well as from `font-family`. Tailwind v4 puts every stack there and the
18
+ rules only say `font-family: var(--font-sans)`, so the check saw no stack on a Tailwind site and
19
+ never reported a font. The existing warning for a `font-display: swap` face without a
20
+ `size-adjust` stand-in behind it is unchanged, and now also fires on such sites.
21
+
22
+ The levels, the configuration keys, the exit codes and the report's shape stay the same.
@@ -0,0 +1,46 @@
1
+ # Migration: 0.5.2 to 0.5.3
2
+
3
+ ## 1. Upgrade
4
+
5
+ ```sh
6
+ pnpm add --save-exact --save-dev @v-office/site-checks@0.5.3
7
+ ```
8
+
9
+ No changes required to build. `load-order` is a warning and may now report the site's fonts.
10
+
11
+ ## 2. Fix a face that uses `font-display: optional`
12
+
13
+ For each `@font-face` the warning names (usually in `src/styles/global.css`):
14
+
15
+ 1. Set `font-display: swap`.
16
+ 2. Add a stand-in face built from Arial, resized to the web font's metrics, so the swap barely
17
+ moves the text:
18
+
19
+ ```css
20
+ @font-face {
21
+ font-family: "Lexend Fallback";
22
+ src: local("Arial"), local("ArialMT");
23
+ size-adjust: 109.52%;
24
+ ascent-override: 91.3%;
25
+ descent-override: 22.83%;
26
+ line-gap-override: 0%;
27
+ }
28
+ ```
29
+
30
+ These are Lexend's values; never copy them to another font. Measure each font's own from the
31
+ site's woff2 file against Arial (average glyph width over German sample copy for
32
+ `size-adjust`; the font's ascent, descent and line gap divided by `size-adjust` for the
33
+ overrides). One stand-in per web font family; a variable font with all weights needs one.
34
+
35
+ 3. Name the stand-in right after the web font in every `--font-*` stack that starts with it:
36
+
37
+ ```css
38
+ @theme {
39
+ --font-sans: "Lexend Variable", "Lexend Fallback", ui-sans-serif, sans-serif;
40
+ --font-display: "Lexend Variable", "Lexend Fallback", ui-sans-serif, sans-serif;
41
+ }
42
+ ```
43
+
44
+ Keep the font's `<link rel="preload">` where it has one. A `swap` face whose stack has no
45
+ `size-adjust` stand-in right after it is reported by the same check ("swaps in without a
46
+ width-matched stand-in"); the same stand-in fixes that warning.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@v-office/site-checks",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "description": "The checks over a v-office website in two stages, `site-checks src` before the build and `site-checks dist` after it, which AI Studio's build worker runs on every build from its own pinned copy; the report has the shape of the build worker's dist-check report, and a site excludes the findings it accepts in site-checks.config.json",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {