@v-office/site-checks 0.5.0 → 0.5.2

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/dist/bin.mjs CHANGED
@@ -1,9 +1,8 @@
1
1
  #!/usr/bin/env node
2
- import { n as cli } from "./cli-ChBTZhc7.mjs";
3
- //#region src/bin.ts
2
+ import { n as cli } from "./cli-Xd9RQ91Q.mjs";
3
+ // src/bin.ts
4
4
  process.exitCode = await cli(process.argv.slice(2), {
5
5
  out: (line) => console.log(line),
6
6
  err: (line) => console.error(line)
7
7
  });
8
- //#endregion
9
8
  export {};
@@ -5,7 +5,7 @@ import { brotliCompressSync, constants } from "node:zlib";
5
5
  import os from "node:os";
6
6
  import { spawn } from "node:child_process";
7
7
  import { parseArgs } from "node:util";
8
- //#region src/jsComments.ts
8
+ // src/jsComments.ts
9
9
  /** One pass over JavaScript (or the script parts of a component): its comments, and the code with
10
10
  * them blanked. String and template literals are kept whole, so `//` in `"https://…"` or `/*` in
11
11
  * `'a /* b'` is no comment; `${…}` inside a template is code again, to its matching `}`. `'…'` and
@@ -189,8 +189,7 @@ const stripComments = (text, options = {}) => {
189
189
  };
190
190
  /** Every comment in the text, as written. */
191
191
  const jsComments = (text, options = {}) => findComments(text, options).map((c) => c.text);
192
- //#endregion
193
- //#region src/astroConfig.ts
192
+ // src/astroConfig.ts
194
193
  /** The Astro config files, in the order Astro itself looks for them. */
195
194
  const CONFIG_FILES = [
196
195
  "astro.config.mjs",
@@ -266,8 +265,7 @@ const readAstroConfig = (root) => {
266
265
  layoutKey: LAYOUT_KEYS.find((key) => mentions(text, key) > 0)
267
266
  };
268
267
  };
269
- //#endregion
270
- //#region src/sourceComments.ts
268
+ // src/sourceComments.ts
271
269
  /** Files of code only, read by the string-aware JavaScript lexer: no text runs between their
272
270
  * tokens, so a `//` outside a string always opens a comment. */
273
271
  const CODE = /* @__PURE__ */ new Set([
@@ -302,8 +300,7 @@ const blankSourceComments = (raw, extension) => {
302
300
  if (extension === ".mdx" || extension === ".md") return htmlComments$1(raw.replace(/\{\s*\/\*[\s\S]*?\*\/\s*\}/g, blank));
303
301
  return raw;
304
302
  };
305
- //#endregion
306
- //#region src/checks/consentGate.ts
303
+ // src/checks/consentGate.ts
307
304
  /** The consent kit's files in a site: its presence under `src/lib/consent/` is what makes the
308
305
  * check apply; the vendors the site enables and the fleet registry's review of them. */
309
306
  const KIT_DIR = "src/lib/consent/";
@@ -457,8 +454,7 @@ const consentGateSource = {
457
454
  } };
458
455
  }
459
456
  };
460
- //#endregion
461
- //#region src/context.ts
457
+ // src/context.ts
462
458
  const SKIPPED_TEXT_TAGS = /* @__PURE__ */ new Set([
463
459
  "SCRIPT",
464
460
  "STYLE",
@@ -699,8 +695,7 @@ const xmlText = (text) => text.replace(/&(?:#x([0-9a-f]+)|#(\d+)|(amp|lt|gt|quot
699
695
  apos: "'"
700
696
  }[name.toLowerCase()] ?? entity;
701
697
  });
702
- //#endregion
703
- //#region src/exclude.ts
698
+ // src/exclude.ts
704
699
  const LOCALE = /^\/[a-z]{2}(?:-[a-z]{2})?(?=\/|$)/i;
705
700
  /** The `:line` (and `:column`) a source finding's path ends with. */
706
701
  const LINE = /:\d+(?::\d+)?$/;
@@ -738,8 +733,7 @@ const assertKnownChecks = (exclude, ids) => {
738
733
  const unknown = Object.keys(exclude).filter((id) => !known.has(id));
739
734
  if (unknown.length > 0) throw new Error(`[site-checks] "exclude" names ${unknown.length === 1 ? "an unknown check" : "unknown checks"}: ${unknown.join(", ")}`);
740
735
  };
741
- //#endregion
742
- //#region src/checks/copy.ts
736
+ // src/checks/copy.ts
743
737
  /** Pages the copy checks read: not a redirect stub, not the 404 page, not an excluded path. An
744
738
  * entry covers the path and everything below it, with or without a locale prefix: `/impressum`
745
739
  * also covers `/de/impressum`. */
@@ -930,8 +924,7 @@ const quoteSources = {
930
924
  };
931
925
  }
932
926
  };
933
- //#endregion
934
- //#region src/checks/donorTerms.ts
927
+ // src/checks/donorTerms.ts
935
928
  /** More than this and the point is made; the runner keeps 25 anyway. */
936
929
  const MAX_RAW_FINDINGS = 100;
937
930
  const collapse$2 = (text) => text.normalize("NFC").replace(/\s+/g, " ");
@@ -1094,8 +1087,7 @@ const donorTermsSource = {
1094
1087
  } };
1095
1088
  }
1096
1089
  };
1097
- //#endregion
1098
- //#region src/checks/htmlComments.ts
1090
+ // src/checks/htmlComments.ts
1099
1091
  /** Files that hold no text: an image or font can carry the bytes `<!--` by chance, and reading
1100
1092
  * every photo under `src/assets/` costs time for nothing. */
1101
1093
  const BINARY_EXTENSIONS = new Set(".png .jpg .jpeg .gif .webp .avif .ico .bmp .tif .tiff .woff .woff2 .ttf .otf .eot .mp4 .webm .mov .mp3 .pdf .zip".split(" "));
@@ -1129,8 +1121,7 @@ const htmlComments = {
1129
1121
  return findings;
1130
1122
  } })
1131
1123
  };
1132
- //#endregion
1133
- //#region src/checks/imageFormats.ts
1124
+ // src/checks/imageFormats.ts
1134
1125
  const RASTER = /* @__PURE__ */ new Set([
1135
1126
  ".jpg",
1136
1127
  ".jpeg",
@@ -1256,8 +1247,7 @@ const feedImageFormats = {
1256
1247
  };
1257
1248
  }
1258
1249
  };
1259
- //#endregion
1260
- //#region src/sitemaps.ts
1250
+ // src/sitemaps.ts
1261
1251
  /** A URL path as the sitemap checks compare it: query and fragment dropped, escapes decoded, no
1262
1252
  * trailing slash but the root's. The slash is a project-wide setting (`trailingSlash`), not a
1263
1253
  * statement about the page. */
@@ -1321,8 +1311,7 @@ const walkSitemaps = (ctx) => {
1321
1311
  };
1322
1312
  /** The paths (`normalize`d) the build's sitemaps list; empty without a sitemap. */
1323
1313
  const sitemapPaths = (ctx) => new Set(readSitemaps(ctx).entries.map((entry) => entry.path));
1324
- //#endregion
1325
- //#region src/checks/launchHead.ts
1314
+ // src/checks/launchHead.ts
1326
1315
  /** Hosts a site is previewed on before it has its own domain: a `site` there is not a launch. */
1327
1316
  const PREVIEW_HOST = /(?:^|\.)(?:cloudfront\.net|vercel\.app|netlify\.app|pages\.dev|github\.io)$|^(?:localhost|127\.0\.0\.1)$|\.local$/i;
1328
1317
  /** The site's production host, when the Astro config names one that is not a preview origin. */
@@ -1444,8 +1433,7 @@ const trailingSlash = {
1444
1433
  stage: "dist",
1445
1434
  begin: (ctx) => ctx.config.trailingSlash === void 0 ? null : whenLaunched(ctx, () => ctx.config.trailingSlash === "never" ? [] : [{ message: `trailingSlash is "${ctx.config.trailingSlash}" in the Astro config: set it to "never" and write internal links without a trailing slash.` }])
1446
1435
  };
1447
- //#endregion
1448
- //#region src/checks/jsonLd.ts
1436
+ // src/checks/jsonLd.ts
1449
1437
  const blocksOf = (page) => [...page.document.querySelectorAll("script")].filter((s) => s.getAttribute("type")?.trim().toLowerCase() === "application/ld+json").map((s) => s.textContent ?? "");
1450
1438
  /** The blocks of a page that parse; the others are `json-ld`'s findings. */
1451
1439
  const parsedBlocks = (page) => blocksOf(page).flatMap((block) => {
@@ -1542,8 +1530,7 @@ const breadcrumbs = {
1542
1530
  };
1543
1531
  }
1544
1532
  };
1545
- //#endregion
1546
- //#region src/checks/listingLinks.ts
1533
+ // src/checks/listingLinks.ts
1547
1534
  /** A page that lists rentals renders the list into its HTML too, inside this container, so a
1548
1535
  * crawler running no JavaScript sees the rentals the live island will show. The search page of
1549
1536
  * the site starter marks its server-rendered results this way. */
@@ -1648,8 +1635,7 @@ const listingLinks = {
1648
1635
  };
1649
1636
  }
1650
1637
  };
1651
- //#endregion
1652
- //#region src/checks/loadOrder.ts
1638
+ // src/checks/loadOrder.ts
1653
1639
  /** Libraries that serve one feature a visitor reaches later (a map, a chart, a 3D view): `name` is
1654
1640
  * the package (a chunk named after it), `signature` a string only its code carries. */
1655
1641
  const ON_DEMAND = [
@@ -1924,8 +1910,7 @@ const firstPaintPhotos = {
1924
1910
  };
1925
1911
  }
1926
1912
  };
1927
- //#endregion
1928
- //#region src/checks/orphanPages.ts
1913
+ // src/checks/orphanPages.ts
1929
1914
  /** Every indexable page but the home page is linked from another page of the build, in its HTML: a
1930
1915
  * page only the sitemap reaches reads as unimportant to a crawler. Links an island renders in the
1931
1916
  * browser do not count, which is the point: a crawler that runs no JavaScript sees none of them. A
@@ -1961,8 +1946,7 @@ const orphanPages = {
1961
1946
  };
1962
1947
  }
1963
1948
  };
1964
- //#endregion
1965
- //#region src/siteTexts.ts
1949
+ // src/siteTexts.ts
1966
1950
  const CODE_EXTENSIONS = /* @__PURE__ */ new Set([
1967
1951
  ".ts",
1968
1952
  ".tsx",
@@ -2120,8 +2104,7 @@ const flatSources = (ctx) => filesOf(ctx, OWN_EXTENSIONS).map((file) => ({
2120
2104
  rel: ctx.rel(file),
2121
2105
  ...flatten(ctx.readSource(file), path.extname(file).toLowerCase())
2122
2106
  }));
2123
- //#endregion
2124
- //#region src/checks/ownCopy.ts
2107
+ // src/checks/ownCopy.ts
2125
2108
  /** The copy checks over the site's own words in `src/` (`siteTexts.ts`), never the built pages,
2126
2109
  * which also print the PMS feed's text: what they find is the site's to fix, so they are errors. */
2127
2110
  const excerpt$1 = (text, max) => {
@@ -2251,8 +2234,7 @@ const bannedCopySrc = {
2251
2234
  } };
2252
2235
  }
2253
2236
  };
2254
- //#endregion
2255
- //#region src/checks/pageHeads.ts
2237
+ // src/checks/pageHeads.ts
2256
2238
  const MAX_TITLE = 60;
2257
2239
  const MAX_DESCRIPTION = 160;
2258
2240
  /** The head of every indexable page as a search result shows it: a title over 60 or a description
@@ -2349,8 +2331,7 @@ const pageHeads = {
2349
2331
  };
2350
2332
  }
2351
2333
  };
2352
- //#endregion
2353
- //#region src/checks/pageStructure.ts
2334
+ // src/checks/pageStructure.ts
2354
2335
  /** Not in the document's structure: icon internals answer no alt or label question, template markup
2355
2336
  * is not in the page until a script clones it. */
2356
2337
  const OUTSIDE = "svg, script, style, noscript, template";
@@ -2476,8 +2457,7 @@ const headingRatio = {
2476
2457
  };
2477
2458
  }
2478
2459
  };
2479
- //#endregion
2480
- //#region src/env.ts
2460
+ // src/env.ts
2481
2461
  /** The env files a production build reads, in the order Vite applies them (a later file wins per
2482
2462
  * key). The `.local` pair is left out on purpose: it is the developer's machine, never what the
2483
2463
  * deployed site builds against, and a site must not commit it. */
@@ -2546,8 +2526,26 @@ const sdkEnv = (root, processEnv = process.env) => {
2546
2526
  };
2547
2527
  /** What the developer's `.local` files set. */
2548
2528
  const localEnv = (root) => Object.assign({}, ...LOCAL_ENV_FILES.map((file) => readEnvFile(root, file)));
2549
- //#endregion
2550
- //#region src/checks/v9.ts
2529
+ // src/packageBin.ts
2530
+ /**
2531
+ * The script an installed package's bin runs, for starting it with this Node
2532
+ * (`spawn(process.execPath, [script, ...args])`). `node_modules/.bin` holds shims: a shell script,
2533
+ * and on Windows a `.cmd`, which Node starts there only through a shell (CVE-2024-27980), and a
2534
+ * shell would split the temp paths under a user name with a space. Undefined when the package is
2535
+ * not installed or names no such bin.
2536
+ */
2537
+ const packageBin = (root, pkg, name) => {
2538
+ const dir = path.join(root, "node_modules", ...pkg.split("/"));
2539
+ let bin;
2540
+ try {
2541
+ ({bin} = JSON.parse(fs.readFileSync(path.join(dir, "package.json"), "utf8")));
2542
+ } catch {
2543
+ return;
2544
+ }
2545
+ const file = typeof bin === "string" ? bin : bin && typeof bin === "object" ? bin[name] : void 0;
2546
+ return typeof file === "string" ? path.join(dir, file) : void 0;
2547
+ };
2548
+ // src/checks/v9.ts
2551
2549
  /** The be-on! Hub endpoints per stage, as `@v-office/website-headless` resolves `CMS_STAGE` for v9
2552
2550
  * (`sdk/endpoints.ts`). Production is what a live v9 site calls. */
2553
2551
  const HUB = {
@@ -2602,7 +2600,7 @@ const sdkVersion = (root) => {
2602
2600
  const run = async (cli, args, cwd) => {
2603
2601
  const { execFile } = await import("node:child_process");
2604
2602
  return new Promise((resolve) => {
2605
- execFile(cli, args, {
2603
+ execFile(process.execPath, [cli, ...args], {
2606
2604
  cwd,
2607
2605
  timeout: HUB_TIMEOUT_MS,
2608
2606
  maxBuffer: 1048576
@@ -2647,8 +2645,8 @@ const v9HubFilters = {
2647
2645
  customAttributeFilterDefinitions: list
2648
2646
  };
2649
2647
  }
2650
- const cli = path.join(ctx.root, "node_modules", ".bin", process.platform === "win32" ? "website-sdk.cmd" : "website-sdk");
2651
- 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." }];
2648
+ const cli = packageBin(ctx.root, "@v-office/website-sdk", "website-sdk");
2649
+ 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." }];
2652
2650
  const config = cliConfig(env);
2653
2651
  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." }];
2654
2652
  const dir = fs.mkdtempSync(path.join(os.tmpdir(), "site-checks-hub-"));
@@ -2679,8 +2677,7 @@ const v9HubFilters = {
2679
2677
  } };
2680
2678
  }
2681
2679
  };
2682
- //#endregion
2683
- //#region src/checks/productionEnv.ts
2680
+ // src/checks/productionEnv.ts
2684
2681
  /** The v10 endpoints of production, as `@v-office/website-headless` resolves `CMS_STAGE`
2685
2682
  * (`sdk/endpoints.ts`, `VOFFICE_ENDPOINTS`). */
2686
2683
  const V10_PRODUCTION = {
@@ -2764,8 +2761,7 @@ const v10ProductionApi = productionEnv({
2764
2761
  id: "v10-production-api",
2765
2762
  title: "A launched v10 site calls the production vOffice API"
2766
2763
  }, "v10", "vOffice API", V10_PRODUCTION);
2767
- //#endregion
2768
- //#region src/checks/rentalFacts.ts
2764
+ // src/checks/rentalFacts.ts
2769
2765
  /** The markers the platform's rental blocks carry for this check (`GATE_MARKERS` in
2770
2766
  * `@v-office/website-headless`): the fact row, the owner's description, the amenity section and
2771
2767
  * its all-amenities dialog. A site's own layout may put facts in a chip row marked
@@ -3038,8 +3034,7 @@ const rentalFacts = {
3038
3034
  };
3039
3035
  }
3040
3036
  };
3041
- //#endregion
3042
- //#region src/checks/robotsTxt.ts
3037
+ // src/checks/robotsTxt.ts
3043
3038
  /** The extensions an Astro endpoint is written in. */
3044
3039
  const ENDPOINT_EXTENSIONS = [
3045
3040
  ".ts",
@@ -3064,8 +3059,7 @@ const robotsTxt = {
3064
3059
  }] : [] };
3065
3060
  }
3066
3061
  };
3067
- //#endregion
3068
- //#region src/checks/sitemapNoindex.ts
3062
+ // src/checks/sitemapNoindex.ts
3069
3063
  const SITEMAP = /^sitemap[^/]*\.xml$/;
3070
3064
  const SITEMAP_INDEX = "sitemap-index.xml";
3071
3065
  const LLMS = "llms.txt";
@@ -3172,8 +3166,7 @@ const sitemapCoverage = {
3172
3166
  };
3173
3167
  }
3174
3168
  };
3175
- //#endregion
3176
- //#region src/checks/syncOnce.ts
3169
+ // src/checks/syncOnce.ts
3177
3170
  const LOADER_FILES = ["src/content.config.ts", "src/content/config.ts"];
3178
3171
  /** A loader written inline, as opposed to `glob()` or `file()`. */
3179
3172
  const INLINE_LOADER = /\bloader\s*:\s*\{/;
@@ -3227,8 +3220,7 @@ const syncOnce = {
3227
3220
  } };
3228
3221
  }
3229
3222
  };
3230
- //#endregion
3231
- //#region src/checks/viewSource.ts
3223
+ // src/checks/viewSource.ts
3232
3224
  /** Comments the frameworks themselves write into static HTML, and no developer did, matched
3233
3225
  * exactly on the trimmed comment text: Astro's island end and server-island start, React 19's
3234
3226
  * form-state and document markers, Vue's teleport markers and its placeholder for a false `v-if`
@@ -3397,8 +3389,7 @@ const viewSource = {
3397
3389
  };
3398
3390
  }
3399
3391
  };
3400
- //#endregion
3401
- //#region src/checks/vofficeCredit.ts
3392
+ // src/checks/vofficeCredit.ts
3402
3393
  /** The host itself, not a substring: `v-office.com.example` is someone else's, `dyn.v-office.com`
3403
3394
  * the photo host. */
3404
3395
  const CREDIT = /^https?:\/\/(?:www\.)?v-office\.com(?:[/?#]|$)/i;
@@ -3417,8 +3408,7 @@ const footerCredit = (document) => {
3417
3408
  credit
3418
3409
  };
3419
3410
  };
3420
- //#endregion
3421
- //#region src/checks/index.ts
3411
+ // src/checks/index.ts
3422
3412
  /** The site checks, in the order the report shows them: the `src` stage first, then the `dist`
3423
3413
  * stage. Each check names its stage; `site-checks src` runs the first group before the build and
3424
3414
  * `site-checks dist` the second after it, together with the platform's dist checks
@@ -3488,8 +3478,7 @@ const checks = [
3488
3478
  rentalFacts
3489
3479
  ];
3490
3480
  const checksOf = (stage) => checks.filter((check) => check.stage === stage);
3491
- //#endregion
3492
- //#region src/options.ts
3481
+ // src/options.ts
3493
3482
  const CONFIG_FILE = "site-checks.config.json";
3494
3483
  /** Keys of checks earlier versions had. A file that still carries one is noted, never refused: a
3495
3484
  * site mid-rollout must not be stopped by a key it was told to add a release ago. */
@@ -3637,8 +3626,7 @@ function loadOptions(root, overrides = {}, note = () => {}) {
3637
3626
  exclude: pick("exclude", {})
3638
3627
  };
3639
3628
  }
3640
- //#endregion
3641
- //#region src/runner.ts
3629
+ // src/runner.ts
3642
3630
  /** Findings kept per check in the report; the rest is counted in `omitted`. */
3643
3631
  const MAX_FINDINGS_PER_CHECK = 25;
3644
3632
  /** The controller's `siteCheckReportSchema` accepts a finding message of at most 2000 characters
@@ -3769,8 +3757,7 @@ const contextInput = (input) => ({
3769
3757
  const runSiteChecks = (input, list = checks) => runChecks(() => loadContext(contextInput(input)), list, (ctx) => ctx.options.exclude);
3770
3758
  /** Results with status `error`: the ones `site-checks` exits non-zero for. */
3771
3759
  const blockingResults = (report) => report.results.filter((r) => r.status === "error");
3772
- //#endregion
3773
- //#region src/report.ts
3760
+ // src/report.ts
3774
3761
  /** The `dist` stage's report file under `dist/`. The build worker reads it after the build and
3775
3762
  * never uploads it (it names source paths and configured terms). */
3776
3763
  const SITE_CHECKS_FILE = "site-checks.json";
@@ -3798,8 +3785,7 @@ const refusalMessage = (report, stage, reportFile) => {
3798
3785
  };
3799
3786
  /** One line naming what refused the build, for the studio: the failing checks and their counts. */
3800
3787
  const summarizeBlocking = (report) => "Checks refused the build: " + blockingResults(report).map((r) => `${r.id} (${plural(count(r), "finding")})`).join(", ");
3801
- //#endregion
3802
- //#region src/distChecks/insecureResources.ts
3788
+ // src/distChecks/insecureResources.ts
3803
3789
  /** `<link>` relations the browser fetches as a subresource; canonical,
3804
3790
  * alternate, preconnect and friends are hints or metadata, not loads. */
3805
3791
  const RESOURCE_RELS = /* @__PURE__ */ new Set([
@@ -3846,8 +3832,7 @@ const insecureResources = {
3846
3832
  };
3847
3833
  }
3848
3834
  };
3849
- //#endregion
3850
- //#region src/distChecks/internalLinks.ts
3835
+ // src/distChecks/internalLinks.ts
3851
3836
  /** A same-site reference (`href`, `src`, `srcset`, `poster`) that no file of
3852
3837
  * the build serves — the 404 class, caught before a guest hits it. One finding
3853
3838
  * per missing target, on the first page that references it and with the count
@@ -3892,8 +3877,7 @@ const internalLinks = {
3892
3877
  };
3893
3878
  }
3894
3879
  };
3895
- //#endregion
3896
- //#region src/distChecks/keyPages.ts
3880
+ // src/distChecks/keyPages.ts
3897
3881
  /** The pages every build must emit: the home page, and on an Astro site the
3898
3882
  * 404 page the hosting serves for unknown paths. */
3899
3883
  const keyPages = {
@@ -3913,8 +3897,7 @@ const keyPages = {
3913
3897
  return { finish: () => findings };
3914
3898
  }
3915
3899
  };
3916
- //#endregion
3917
- //#region src/distChecks/legalPages.ts
3900
+ // src/distChecks/legalPages.ts
3918
3901
  /** German sites owe an Impressum (§ 5 DDG) and a privacy notice (Art. 13
3919
3902
  * DSGVO) reachable from every page; English wordings count too. Matched on
3920
3903
  * the link's target and its text, so a footer link named either way passes.
@@ -3950,8 +3933,7 @@ const legalPages = {
3950
3933
  };
3951
3934
  }
3952
3935
  };
3953
- //#endregion
3954
- //#region src/distChecks/notFoundBeacon.ts
3936
+ // src/distChecks/notFoundBeacon.ts
3955
3937
  /** A call that posts to the endpoint, not the bare path: a comment or a string naming
3956
3938
  * `/api/404-log` logs nothing. `fetch("/api/404-log", …)`, `fetch(new URL("/api/404-log", …))`,
3957
3939
  * `navigator.sendBeacon("…/api/404-log", …)`. */
@@ -4018,8 +4000,7 @@ const notFoundBeacon = {
4018
4000
  };
4019
4001
  }
4020
4002
  };
4021
- //#endregion
4022
- //#region src/distChecks/pageMetadata.ts
4003
+ // src/distChecks/pageMetadata.ts
4023
4004
  /** What every page needs in its head: a title, a description, the document
4024
4005
  * language. Missing ones are the classic leftovers of a generated layout. A
4025
4006
  * redirect stub is no page anyone reads and is skipped. */
@@ -4051,8 +4032,7 @@ const pageMetadata = {
4051
4032
  };
4052
4033
  }
4053
4034
  };
4054
- //#endregion
4055
- //#region src/distChecks/placeholderContent.ts
4035
+ // src/distChecks/placeholderContent.ts
4056
4036
  /** Text that should never reach a visitor: template filler, a value that was
4057
4037
  * rendered instead of formatted, a template expression the build did not
4058
4038
  * evaluate. And references to development hosts or example domains. */
@@ -4118,8 +4098,7 @@ const placeholderContent = {
4118
4098
  };
4119
4099
  }
4120
4100
  };
4121
- //#endregion
4122
- //#region src/distChecks/siteManifest.ts
4101
+ // src/distChecks/siteManifest.ts
4123
4102
  const FILE = "site-manifest.json";
4124
4103
  const isRecord = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
4125
4104
  const manifestFindings = (ctx) => {
@@ -4158,8 +4137,7 @@ const siteManifest = {
4158
4137
  severity: "warning",
4159
4138
  begin: (ctx) => ({ finish: () => manifestFindings(ctx) })
4160
4139
  };
4161
- //#endregion
4162
- //#region src/distChecks/sitemap.ts
4140
+ // src/distChecks/sitemap.ts
4163
4141
  const pathOf = (url) => {
4164
4142
  try {
4165
4143
  return new URL(url.trim(), "http://site.invalid").pathname;
@@ -4167,8 +4145,7 @@ const pathOf = (url) => {
4167
4145
  return null;
4168
4146
  }
4169
4147
  };
4170
- //#endregion
4171
- //#region src/distChecks/index.ts
4148
+ // src/distChecks/index.ts
4172
4149
  /**
4173
4150
  * The dist checks: the platform's checks over a build's `dist/`. They are part of the `dist`
4174
4151
  * stage (`site-checks dist` runs them after the site's own), and the build worker also runs them
@@ -4243,8 +4220,7 @@ const runDistChecks = (distDir, opts, list = distChecks) => {
4243
4220
  assertKnownChecks(exclude, [...checks, ...distChecks].map((check) => check.id));
4244
4221
  return runChecks(() => loadDistContext(distDir, opts), list, () => exclude);
4245
4222
  };
4246
- //#endregion
4247
- //#region src/stages.ts
4223
+ // src/stages.ts
4248
4224
  /**
4249
4225
  * Runs one stage over a project. `src` runs the source checks and leaves any `dist/` unread;
4250
4226
  * `dist` runs the site's dist-stage checks and the platform's dist checks over the build output,
@@ -4281,8 +4257,7 @@ const runStage = async (stage, input) => {
4281
4257
  isAstro
4282
4258
  }), list, () => exclude);
4283
4259
  };
4284
- //#endregion
4285
- //#region src/cli.ts
4260
+ // src/cli.ts
4286
4261
  const USAGE = `Usage: site-checks <src | dist | verify> [options]
4287
4262
 
4288
4263
  src the source checks, before the build (reads the project, never dist/)
@@ -4401,11 +4376,12 @@ async function cli(argv, io, cwd = process.cwd()) {
4401
4376
  return 0;
4402
4377
  }
4403
4378
  /** Runs a child in the project with its output on ours: 0, 1 when it fails, 2 when it cannot
4404
- * start. No stdin: a pre-push hook's stdin holds git's refs. */
4405
- const exec = (command, args, root, env, io) => new Promise((resolve) => {
4379
+ * start. No stdin: a pre-push hook's stdin holds git's refs. `name` is what an error calls it. */
4380
+ const exec = (name, [command, args, shell = false], root, env, io) => new Promise((resolve) => {
4406
4381
  const child = spawn(command, args, {
4407
4382
  cwd: root,
4408
4383
  env,
4384
+ shell,
4409
4385
  stdio: [
4410
4386
  "ignore",
4411
4387
  "inherit",
@@ -4413,7 +4389,7 @@ const exec = (command, args, root, env, io) => new Promise((resolve) => {
4413
4389
  ]
4414
4390
  });
4415
4391
  child.on("error", (err) => {
4416
- io.err(`site-checks: cannot run ${command}: ${err.message}`);
4392
+ io.err(`site-checks: cannot run ${name}: ${err.message}`);
4417
4393
  resolve(2);
4418
4394
  });
4419
4395
  child.on("close", (code) => resolve(code === 0 ? 0 : 1));
@@ -4448,11 +4424,22 @@ async function verify(root, site, io, cwd) {
4448
4424
  const steps = [
4449
4425
  ["src", () => cli(["src", ...stageArgs], io, cwd)],
4450
4426
  ["astro check", async () => {
4451
- if (fs.existsSync(path.join(root, "node_modules/@astrojs/check"))) return exec(path.join(root, "node_modules/.bin/astro"), ["check"], root, env, io);
4452
- io.out("[site-checks] astro check skipped: @astrojs/check is not installed.");
4453
- return "skipped";
4427
+ if (!fs.existsSync(path.join(root, "node_modules/@astrojs/check"))) {
4428
+ io.out("[site-checks] astro check skipped: @astrojs/check is not installed.");
4429
+ return "skipped";
4430
+ }
4431
+ const astro = packageBin(root, "astro", "astro");
4432
+ if (!astro) {
4433
+ io.err("site-checks: cannot run astro check: the astro package is not installed.");
4434
+ return 2;
4435
+ }
4436
+ return exec("astro check", [process.execPath, [astro, "check"]], root, env, io);
4454
4437
  }],
4455
- ["build", () => exec(pm, ["run", "build"], root, env, io)],
4438
+ ["build", () => exec(`${pm} run build`, process.platform === "win32" ? [
4439
+ `${pm} run build`,
4440
+ [],
4441
+ true
4442
+ ] : [pm, ["run", "build"]], root, env, io)],
4456
4443
  ["dist", () => cli(["dist", ...stageArgs], io, cwd)]
4457
4444
  ];
4458
4445
  const passed = [];
@@ -4469,5 +4456,4 @@ async function verify(root, site, io, cwd) {
4469
4456
  io.out(`[site-checks] verify passed: ${passed.join(", ")}`);
4470
4457
  return 0;
4471
4458
  }
4472
- //#endregion
4473
4459
  export { loadOptions as _, runDistChecks as a, readAstroConfig as b, refusalMessage as c, MAX_FINDINGS_PER_CHECK as d, MAX_MESSAGE_CHARS as f, CONFIG_FILE as g, runSiteChecks as h, distChecks as i, summarizeBlocking as l, blockingResults as m, cli as n, SITE_CHECKS_FILE as o, MAX_PATH_CHARS as p, runStage as r, findingLine as s, USAGE as t, summaryLines as u, checks as v, checksOf as y };
package/dist/index.d.mts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { parseHTML } from "linkedom";
2
- //#region src/astroConfig.d.ts
3
2
  type AstroConfigFacts = {
4
3
  /** Whether the project has an Astro config file at all: a Vite app has none. */
5
4
  found: boolean;
@@ -18,8 +17,6 @@ type AstroConfigFacts = {
18
17
  * process.env.SITE_URL`) or ambiguous is not taken; the builder passes the site URL, and without
19
18
  * one the checks that need it wait. */
20
19
  export declare const readAstroConfig: (root: string) => AstroConfigFacts;
21
- //#endregion
22
- //#region src/exclude.d.ts
23
20
  /** One exclusion of a check's findings: a path, or a path and text the finding's message contains.
24
21
  * `reason` is for whoever reads the config next. */
25
22
  type Exclusion = string | {
@@ -30,8 +27,6 @@ type Exclusion = string | {
30
27
  /** A site's exclusions (`exclude` in `site-checks.config.json`), by check id: `true` turns the
31
28
  * check off for the site, a list hides the findings an entry covers. */
32
29
  type Exclusions = Record<string, true | Exclusion[]>;
33
- //#endregion
34
- //#region src/options.d.ts
35
30
  /** A wording a recorded customer correction bans from the rendered pages. */
36
31
  interface BannedCopy {
37
32
  /** A regular expression (source), matched against each page's visible text, whitespace
@@ -117,8 +112,6 @@ export declare const CONFIG_FILE = "site-checks.config.json";
117
112
  /** The file's keys with the given options on top. A file that cannot be parsed throws: a broken
118
113
  * config must not silently disable a check. `note` hears about a retired key. */
119
114
  export declare function loadOptions(root: string, overrides?: SiteChecksOptions, note?: (message: string) => void): ResolvedOptions;
120
- //#endregion
121
- //#region src/types.d.ts
122
115
  /** Two families of checks share these types, one runner and one report shape:
123
116
  * - the site checks (`checks/`) over a site's source and built output, at the site's pinned
124
117
  * version: `site-checks src` before the build, `site-checks dist` after it;
@@ -247,8 +240,6 @@ type DistCheck = Check<DistContext>;
247
240
  /** What the `dist` stage runs over: the site's context with the build, which is also everything a
248
241
  * dist check reads, so both families see each page once. */
249
242
  type DistStageContext = SiteCheckContext & DistContext;
250
- //#endregion
251
- //#region src/checks/index.d.ts
252
243
  /** The site checks, in the order the report shows them: the `src` stage first, then the `dist`
253
244
  * stage. Each check names its stage; `site-checks src` runs the first group before the build and
254
245
  * `site-checks dist` the second after it, together with the platform's dist checks
@@ -256,8 +247,6 @@ type DistStageContext = SiteCheckContext & DistContext;
256
247
  * is one file here, one entry, one test, a README row and a CHANGELOG entry. */
257
248
  export declare const checks: readonly SiteCheck[];
258
249
  export declare const checksOf: (stage: Stage) => readonly SiteCheck[];
259
- //#endregion
260
- //#region src/cli.d.ts
261
250
  type Io = {
262
251
  out: (line: string) => void;
263
252
  err: (line: string) => void;
@@ -265,8 +254,6 @@ type Io = {
265
254
  export declare const USAGE = "Usage: site-checks <src | dist | verify> [options]\n\n src the source checks, before the build (reads the project, never dist/)\n dist the checks over the built output, after the build\n verify what AI Studio's build runs, stopping at the first failure: src, astro check, the\n build script, dist (--root and --site only)\n\nOptions:\n --root <dir> the project (default: the current directory)\n --dist <dir> the build output, relative to the root (default: dist; dist stage only)\n --site <url> the site's public URL (default: `site` in the Astro config file)\n --report <file> write the report as JSON here (default for dist: <dist>/site-checks.json)\n -h, --help this text\n\nExits 0 when nothing refused, 1 when a check with severity error found something or (verify)\nastro check or the build failed, 2 on a usage or configuration error. Data for the checks:\nsite-checks.config.json at the project root.";
266
255
  /** The command line. Returns the exit code; prints to `io`. */
267
256
  export declare function cli(argv: readonly string[], io: Io, cwd?: string): Promise<number>;
268
- //#endregion
269
- //#region src/report.d.ts
270
257
  /** The `dist` stage's report file under `dist/`. The build worker reads it after the build and
271
258
  * never uploads it (it names source paths and configured terms). */
272
259
  export declare const SITE_CHECKS_FILE = "site-checks.json";
@@ -279,8 +266,6 @@ export declare const summaryLines: (report: CheckReport) => string[];
279
266
  export declare const refusalMessage: (report: CheckReport, stage: string, reportFile?: string) => string;
280
267
  /** One line naming what refused the build, for the studio: the failing checks and their counts. */
281
268
  export declare const summarizeBlocking: (report: CheckReport) => string;
282
- //#endregion
283
- //#region src/context.d.ts
284
269
  type ContextInput = {
285
270
  root: string;
286
271
  srcDir: string;
@@ -293,8 +278,6 @@ type ContextInput = {
293
278
  config: SiteCheckContext["config"];
294
279
  options: ResolvedOptions;
295
280
  };
296
- //#endregion
297
- //#region src/runner.d.ts
298
281
  /** Findings kept per check in the report; the rest is counted in `omitted`. */
299
282
  export declare const MAX_FINDINGS_PER_CHECK = 25;
300
283
  /** The controller's `siteCheckReportSchema` accepts a finding message of at most 2000 characters
@@ -318,8 +301,6 @@ type RunInput = {
318
301
  export declare const runSiteChecks: (input: RunInput, list?: readonly SiteCheck[]) => Promise<CheckReport>;
319
302
  /** Results with status `error`: the ones `site-checks` exits non-zero for. */
320
303
  export declare const blockingResults: (report: CheckReport) => CheckResult[];
321
- //#endregion
322
- //#region src/distChecks/index.d.ts
323
304
  /**
324
305
  * The dist checks: the platform's checks over a build's `dist/`. They are part of the `dist`
325
306
  * stage (`site-checks dist` runs them after the site's own), and the build worker also runs them
@@ -338,8 +319,6 @@ export declare const runDistChecks: (distDir: string, opts: {
338
319
  siteUrl?: string | undefined;
339
320
  root?: string | undefined;
340
321
  }, list?: readonly DistCheck[]) => Promise<CheckReport>;
341
- //#endregion
342
- //#region src/stages.d.ts
343
322
  type StageInput = {
344
323
  root: string;
345
324
  /** The build output; `<root>/dist` by default. Read by the `dist` stage only. */
@@ -363,5 +342,4 @@ type StageInput = {
363
342
  * this version does not have.
364
343
  */
365
344
  export declare const runStage: (stage: Stage, input: StageInput) => Promise<CheckReport>;
366
- //#endregion
367
345
  export type { AstroConfigFacts, BannedCopy, BuildOutput, Check, CheckReport, CheckResult, CheckRun, CheckStatus, DistCheck, DistContext, DistStageContext, Exclusion, Exclusions, Finding, Io, Page, ResolvedOptions, RunInput, Severity, SiteCheck, SiteCheckContext, SiteChecksOptions, Stage, StageInput };
package/dist/index.mjs CHANGED
@@ -1,2 +1 @@
1
- import { _ as loadOptions, a as runDistChecks, b as readAstroConfig, c as refusalMessage, d as MAX_FINDINGS_PER_CHECK, f as MAX_MESSAGE_CHARS, g as CONFIG_FILE, h as runSiteChecks, i as distChecks, l as summarizeBlocking, m as blockingResults, n as cli, o as SITE_CHECKS_FILE, p as MAX_PATH_CHARS, r as runStage, s as findingLine, t as USAGE, u as summaryLines, v as checks, y as checksOf } from "./cli-ChBTZhc7.mjs";
2
- export { CONFIG_FILE, MAX_FINDINGS_PER_CHECK, MAX_MESSAGE_CHARS, MAX_PATH_CHARS, SITE_CHECKS_FILE, USAGE, blockingResults, checks, checksOf, cli, distChecks, findingLine, loadOptions, readAstroConfig, refusalMessage, runDistChecks, runSiteChecks, runStage, summarizeBlocking, summaryLines };
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-Xd9RQ91Q.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.2/CHANGELOG.md`: release notes for 0.5.2
8
+ - `versions/0.5.1/CHANGELOG.md`: release notes for 0.5.1
7
9
  - `versions/0.5.0/CHANGELOG.md`: release notes for 0.5.0
8
10
  - `versions/0.4.2/CHANGELOG.md`: release notes for 0.4.2
9
11
  - `versions/0.4.1/CHANGELOG.md`: release notes for 0.4.1
@@ -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.2/MIGRATION.md`: Migration: 0.5.1 to 0.5.2
8
+ - `versions/0.5.1/MIGRATION.md`: Migration: 0.5.0 to 0.5.1
7
9
  - `versions/0.5.0/MIGRATION.md`: Migration: 0.4.2 to 0.5.0
8
10
  - `versions/0.4.2/MIGRATION.md`: Migration: 0.4.1 to 0.4.2
9
11
  - `versions/0.4.1/MIGRATION.md`: Migration: 0.4.0 to 0.4.1
@@ -10,8 +10,9 @@ pnpm add --save-exact --save-dev @v-office/site-checks@0.1.0
10
10
 
11
11
  ```js
12
12
  // astro.config.mjs
13
- import { siteManifest } from "@v-office/site-manifest/astro";
13
+
14
14
  import { siteChecks } from "@v-office/site-checks/astro";
15
+ import { siteManifest } from "@v-office/site-manifest/astro";
15
16
 
16
17
  export default defineConfig({
17
18
  integrations: [siteManifest(), siteChecks()],
@@ -22,7 +22,7 @@ PMS or Hub data is a warning; the nightly builds that update prices never stop o
22
22
  - `v9-hub-filters` (warning, v9 only): the be-on! Hub the site builds against serves every filter
23
23
  the site's search needs (the scope filter, the Merkliste's rental-id filter, each searchable
24
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
25
+ check`, with the build's env and `hubFilterOptions`; a site that sets the SDK CLI's
26
26
  `HUB_RENTAL_SCOPE_PROPERTY_KIND` or `HUB_RENTAL_IDS_SEARCH` has them forwarded. A Hub that cannot be asked (no
27
27
  `website-sdk`, an SDK without the command, no key) is reported, never passed.
28
28
  - `v9-production-hub` (error, v9 only): a launched v9 site builds against the production Hub:
@@ -0,0 +1,11 @@
1
+ # Changelog: 0.5.1
2
+
3
+ Dependency update; the checks report the same.
4
+
5
+ ## Changed
6
+
7
+ - `linkedom` 0.18.13 → 0.18.15, the HTML parser the checks read the built pages with: an attribute
8
+ selector on `class` no longer matches an element without the attribute.
9
+
10
+ The rules, their levels, the configuration keys, the exit codes and the report's shape stay the
11
+ same.
@@ -0,0 +1,9 @@
1
+ # Migration: 0.5.0 to 0.5.1
2
+
3
+ ## 1. Upgrade
4
+
5
+ ```sh
6
+ pnpm add --save-exact --save-dev @v-office/site-checks@0.5.1
7
+ ```
8
+
9
+ No changes required.
@@ -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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@v-office/site-checks",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
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": {
@@ -26,15 +26,15 @@
26
26
  "access": "public"
27
27
  },
28
28
  "dependencies": {
29
- "linkedom": "0.18.13"
29
+ "linkedom": "0.18.15"
30
30
  },
31
31
  "devDependencies": {
32
- "@types/node": "26.5.1",
33
- "oxfmt": "0.67.0",
34
- "oxlint": "1.82.0",
35
- "tsdown": "0.23.0",
32
+ "@types/node": "24.19.2",
33
+ "oxfmt": "0.79.0",
34
+ "oxlint": "1.94.0",
35
+ "tsdown": "0.23.7",
36
36
  "typescript": "7.0.2",
37
- "vitest": "^5.0.0"
37
+ "vitest": "^5.1.0"
38
38
  },
39
39
  "engines": {
40
40
  "node": "^22.0.0 || ^24.0.0 || ^25.0.0 || >=26.0.0"