@v-office/site-checks 0.2.4 → 0.3.1

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/index.d.mts CHANGED
@@ -1,11 +1,327 @@
1
- import { a as WiringEntry, c as loadOptions, i as SiteChecksOptions, n as CONFIG_FILE, o as WiringHook, r as ResolvedOptions, s as WiringKept, t as BannedCopy } from "./options-CANJso9Q.mjs";
2
- import { C as SiteCheck, S as Severity, _ as CheckStatus, a as blockingResults, b as Finding, c as refusalMessage, d as writeSiteChecksReport, f as BuildOutput, g as CheckRun, h as CheckResult, i as RunInput, l as summarizeBlocking, m as CheckReport, n as MAX_MESSAGE_CHARS, o as runSiteChecks, p as Check, r as MAX_PATH_CHARS, s as SITE_CHECKS_FILE, t as MAX_FINDINGS_PER_CHECK, u as summaryLines, v as DistCheck, w as SiteCheckContext, x as Page, y as DistContext } from "./runner-CK4iXk8Z.mjs";
1
+ import { parseHTML } from "linkedom";
2
+ //#region src/astroConfig.d.ts
3
+ type AstroConfigFacts = {
4
+ /** Whether the project has an Astro config file at all: a Vite app has none. */
5
+ found: boolean;
6
+ /** `site: "https://…"`, when the config sets it once, as a plain string. */
7
+ site: string | undefined;
8
+ /** `trailingSlash`, when the config sets it once as a plain string, or Astro's default when it
9
+ * surely does not set it; `undefined` when it cannot be told. */
10
+ trailingSlash: string | undefined;
11
+ /** The first of `root`, `srcDir` and `publicDir` the config names, in any form: the checks know
12
+ * Astro's default layout only. */
13
+ layoutKey: string | undefined;
14
+ };
15
+ /** The facts the checks need from the Astro config, read from the file as text: importing the
16
+ * config would run every integration in it. Comments are stripped first, so a commented-out
17
+ * value never stands in for the active one. A value that is computed (`site:
18
+ * process.env.SITE_URL`) or ambiguous is not taken; the builder passes the site URL, and without
19
+ * one the checks that need it wait. */
20
+ export declare const readAstroConfig: (root: string) => AstroConfigFacts;
21
+ //#endregion
22
+ //#region src/options.d.ts
23
+ /** A wording a recorded customer correction bans from the rendered pages. */
24
+ interface BannedCopy {
25
+ /** A regular expression (source), matched against each page's visible text, whitespace
26
+ * collapsed, so a line break cannot hide a match. */
27
+ pattern: string;
28
+ /** The correction behind it, shown with every finding. */
29
+ why: string;
30
+ }
31
+ /** What a site configures: data for the checks, never their severity. Read from
32
+ * `site-checks.config.json` at the project root; a programmatic run may pass the same keys, and
33
+ * those win over the file's. */
34
+ interface SiteChecksOptions {
35
+ /** Terms that must not ship: the template ("donor") site's brand, people, places, phone, email,
36
+ * domain, asset names. Matched case-insensitively, whitespace collapsed. Empty: the check skips. */
37
+ donorTerms?: string[];
38
+ /** Raster images under `public/` that ship without an AVIF sibling on purpose, as paths
39
+ * relative to the project root (`public/brand/logo.png`). */
40
+ imageIgnore?: string[];
41
+ /** Regular expressions (sources, case-insensitive) matching a feed photo URL that is still
42
+ * requested as JPEG or PNG. Defaults to the vOffice image hosts. */
43
+ feedImagePatterns?: string[];
44
+ /** URL paths of pages that list rentals, in addition to the pages the check recognizes by their
45
+ * markup (`/angebote`). */
46
+ listingPages?: string[];
47
+ /** Listing pages whose list stays client-only, with the reason: their list is the rentals free
48
+ * in a window, and a build-time list would show booked-out flats. */
49
+ listingClientOnly?: {
50
+ path: string;
51
+ reason: string;
52
+ }[];
53
+ /** Hosts a `<script src>` or `<iframe src>` may load before consent: the site's own CDN, a
54
+ * consent-free host. The site's own host (`site` in the Astro config) is always allowed. */
55
+ consentAllowedHosts?: string[];
56
+ /** Wordings recorded customer corrections ban. Empty: `banned-copy` skips. */
57
+ bannedCopy?: BannedCopy[];
58
+ /** URL paths (and everything below them) the copy checks do not read: legal pages ported
59
+ * verbatim. `/impressum` also covers `/de/impressum`. */
60
+ copyExcludePaths?: string[];
61
+ /** URL paths only `banned-copy` skips: pages whose prose is the site's but whose answers port
62
+ * verbatim (an FAQ). */
63
+ bannedCopyExcludePaths?: string[];
64
+ /** Sentences `duplicate-sentences` accepts twice on one page. */
65
+ allowDuplicateSentences?: string[];
66
+ /** Files or directories (project-relative) holding the text a `<blockquote>` may quote: content
67
+ * captures, the feed's review texts written by the build. Empty: `quote-sources` skips. */
68
+ quoteSources?: string[];
69
+ /** `rental-facts` disagreements the customer confirmed must ship as they are, one per line in
70
+ * the form the finding prints: `<slug> <kind> prose=<n> feed=<n>`. Either side changing makes
71
+ * it a finding again. */
72
+ factCheckAccepted?: string[];
73
+ /** Rules of `page-structure` this site declines: `one-h1`, `heading-skip`, `landmark-main`,
74
+ * `img-alt`, `control-label`, `table-headers`, `heading-ratio`. */
75
+ structureIgnore?: string[];
76
+ /** v9 only: the Website SDK options the site's `website-sdk hub-filters check` needs
77
+ * (`rentalScope`, `customAttributeFilterDefinitions`), as the site passes them to the SDK. */
78
+ hubFilterOptions?: Record<string, unknown>;
79
+ }
80
+ type ResolvedOptions = Required<SiteChecksOptions>;
81
+ export declare const CONFIG_FILE = "site-checks.config.json";
82
+ /** The file's keys with the given options on top. A file that cannot be parsed throws: a broken
83
+ * config must not silently disable a check. `note` hears about a retired key. */
84
+ export declare function loadOptions(root: string, overrides?: SiteChecksOptions, note?: (message: string) => void): ResolvedOptions;
85
+ //#endregion
86
+ //#region src/types.d.ts
87
+ /** Two families of checks share these types, one runner and one report shape:
88
+ * - the site checks (`checks/`) over a site's source and built output, at the site's pinned
89
+ * version: `site-checks src` before the build, `site-checks dist` after it;
90
+ * - the dist checks (`distChecks/`) over the built output only: the platform's checks, part of
91
+ * the `dist` stage, and run by the build worker on every build of every website, the guest and
92
+ * owner apps and sites without this package included.
93
+ * Both land in one report, which the controller validates and stores alike. Only a check whose
94
+ * severity is `error` refuses the build, the way a failed `astro check` does. */
95
+ type Severity = "warning" | "error";
96
+ /** When a site check runs: `src` reads the project before the build (no `dist/`, even when an
97
+ * older one is lying around); `dist` reads the built output after it. */
98
+ type Stage = "src" | "dist";
99
+ /** `skipped`: the check does not apply to this site (no config, no built pages). `failed`: the
100
+ * check itself threw — reported, never blocking. */
101
+ type CheckStatus = "ok" | Severity | "skipped" | "failed";
102
+ /** One thing a check found: what, and on which file when known. Paths of the built output are
103
+ * relative to `dist/`, source paths relative to the project root. */
104
+ type Finding = {
105
+ message: string;
106
+ path?: string;
107
+ };
108
+ type CheckResult = {
109
+ id: string;
110
+ status: CheckStatus;
111
+ /** Capped by the runner; `omitted` counts what the cap cut. */
112
+ findings: Finding[];
113
+ omitted: number;
114
+ };
115
+ type CheckReport = {
116
+ ranAt: string;
117
+ durationMs: number;
118
+ results: CheckResult[];
119
+ };
120
+ type Document = ReturnType<typeof parseHTML>["document"];
121
+ /** One HTML file of the build, parsed once, shown to every check, then let go: the runner holds
122
+ * one page at a time, so memory follows the largest page and not the page count. */
123
+ type Page = {
124
+ /** Posix path relative to `dist/`, e.g. `about-us/index.html`. */
125
+ path: string;
126
+ /** The URL path the file is served at, e.g. `/about-us/`. */
127
+ url: string;
128
+ /** What relative references resolve against: `<base href>` when the page has one, else `url`. */
129
+ base: string;
130
+ /** A redirect stub (`<meta http-equiv="refresh">`): nobody reads it, so page checks skip it. */
131
+ redirect: boolean;
132
+ /** `<meta name="robots">` says `noindex`. */
133
+ noindex: boolean;
134
+ document: Document;
135
+ /** The text a visitor can read: script, style, noscript and template contents left out. */
136
+ visibleText: () => string;
137
+ /** Every attribute value on the page (`alt`, `title`, `href`, island props, …). */
138
+ attributeValues: () => string[];
139
+ /** The data of every HTML comment node, outside script and style text. */
140
+ comments: () => string[];
141
+ };
142
+ /** A build's output, listed once: what both families read of `dist/`. */
143
+ type BuildOutput = {
144
+ distDir: string;
145
+ /** Every file of the build, as a posix path relative to `distDir`. */
146
+ files: string[];
147
+ has: (file: string) => boolean;
148
+ read: (file: string) => string;
149
+ /** Whether a same-site URL path is served by a file of the build: the file itself,
150
+ * `<path>/index.html` or `<path>.html`. Query and fragment ignored. */
151
+ serves: (urlPath: string) => boolean;
152
+ };
153
+ /** What a dist check gets: the build's output, and which kind of build it is. */
154
+ type DistContext = BuildOutput & {
155
+ /** An Astro build (public website: many pages, a 404 page, a sitemap) as opposed to a Vite
156
+ * single-page app (guest, owner: one index.html, routes handled by the app). Checks that only
157
+ * make sense for one kind skip the other. */
158
+ isAstro: boolean;
159
+ /** The site's own origin (`https://www.example-fewo.de`) when the build knows its public URL:
160
+ * absolute links to it are the site's own and are checked like relative ones — with a `site`,
161
+ * canonical, alternate and sitemap URLs are absolute. */
162
+ origin: string | undefined;
163
+ };
164
+ /** What a site check gets. The built output is absent in the `src` stage: checks that need pages
165
+ * return `null` from `begin` then. */
166
+ type SiteCheckContext = BuildOutput & {
167
+ root: string;
168
+ srcDir: string;
169
+ publicDir: string;
170
+ hasDist: boolean;
171
+ config: {
172
+ /** The site's public URL: `--site`, else `site` read from the Astro config file. */
173
+ site: string | undefined;
174
+ /** `trailingSlash` read from the Astro config file ("always", "never", "ignore"), when known. */
175
+ trailingSlash: string | undefined;
176
+ };
177
+ options: ResolvedOptions;
178
+ /** Files under `srcDir` with one of the extensions (`.astro`, …), as absolute paths. */
179
+ sourceFiles: (extensions: ReadonlySet<string>) => string[];
180
+ readSource: (absolute: string) => string;
181
+ /** A finding path for a file of the project: relative to `root`, posix. */
182
+ rel: (absolute: string) => string;
183
+ packageJson: {
184
+ dependencies: Record<string, string>;
185
+ devDependencies: Record<string, string>;
186
+ };
187
+ };
188
+ /** One check on one build. The runner parses the HTML pages one after the other and shows each to
189
+ * `visit`; a page is gone after its visit, so a check keeps what it needs from it, never the page.
190
+ * `finish` runs after the last page. */
191
+ type CheckRun = {
192
+ visit?: (page: Page) => void;
193
+ finish: () => Finding[] | Promise<Finding[]>;
194
+ };
195
+ type Check<Context> = {
196
+ /** Stable kebab-case id; the controller stores results by it. Unique across both families: the
197
+ * worker merges them into one report (a test holds the rule). */
198
+ id: string;
199
+ title: string;
200
+ /** Fixed here, never by a site. A check whose outcome depends on PMS data, not on the site's
201
+ * code, must be `warning`: an `error` also refuses the nightly deploy builds. */
202
+ severity: Severity;
203
+ /** Starts the check, or returns `null` when it does not apply to this site. Deterministic,
204
+ * touches no network. */
205
+ begin: (ctx: Context) => CheckRun | null;
206
+ };
207
+ type SiteCheck = Check<SiteCheckContext> & {
208
+ stage: Stage;
209
+ };
210
+ type DistCheck = Check<DistContext>;
211
+ /** What the `dist` stage runs over: the site's context with the build, which is also everything a
212
+ * dist check reads, so both families see each page once. */
213
+ type DistStageContext = SiteCheckContext & DistContext;
214
+ //#endregion
3
215
  //#region src/checks/index.d.ts
4
- /** The site checks, in the order the report shows them: the source first, then the built pages.
5
- * The integration runs these inside the site's own `astro build`; the build worker's checks are
6
- * the other family (`distChecks/`), and an id here must not reuse one of theirs (a test holds the
7
- * rule). Adding a check is one file here, one entry, one test, a README row and a CHANGELOG
8
- * entry. */
216
+ /** The site checks, in the order the report shows them: the `src` stage first, then the `dist`
217
+ * stage. Each check names its stage; `site-checks src` runs the first group before the build and
218
+ * `site-checks dist` the second after it, together with the platform's dist checks
219
+ * (`distChecks/`), whose ids a check here must not reuse (a test holds the rule). Adding a check
220
+ * is one file here, one entry, one test, a README row and a CHANGELOG entry. */
9
221
  export declare const checks: readonly SiteCheck[];
222
+ export declare const checksOf: (stage: Stage) => readonly SiteCheck[];
223
+ //#endregion
224
+ //#region src/cli.d.ts
225
+ type Io = {
226
+ out: (line: string) => void;
227
+ err: (line: string) => void;
228
+ };
229
+ export declare const USAGE = "Usage: site-checks <src | dist> [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\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, 2 on a usage\nor configuration error. Data for the checks: site-checks.config.json at the project root.";
230
+ /** The command line. Returns the exit code; prints to `io`. */
231
+ export declare function cli(argv: readonly string[], io: Io, cwd?: string): Promise<number>;
232
+ //#endregion
233
+ //#region src/report.d.ts
234
+ /** The `dist` stage's report file under `dist/`. The build worker reads it after the build and
235
+ * never uploads it (it names source paths and configured terms). */
236
+ export declare const SITE_CHECKS_FILE = "site-checks.json";
237
+ /** `<path>: <message>`, or the message alone. */
238
+ export declare const findingLine: (finding: CheckResult["findings"][number]) => string;
239
+ /** One line per check that found something or could not run, for the build log. */
240
+ export declare const summaryLines: (report: CheckReport) => string[];
241
+ /** What a refused stage ends with: every failing check, its first findings, and where the whole
242
+ * report is when one was written. */
243
+ export declare const refusalMessage: (report: CheckReport, stage: string, reportFile?: string) => string;
244
+ /** One line naming what refused the build, for the studio: the failing checks and their counts. */
245
+ export declare const summarizeBlocking: (report: CheckReport) => string;
246
+ //#endregion
247
+ //#region src/context.d.ts
248
+ type ContextInput = {
249
+ root: string;
250
+ srcDir: string;
251
+ publicDir: string;
252
+ distDir: string;
253
+ /** `src`: the build output is left out even when a `dist/` is lying around from an earlier
254
+ * build, so the stage reads the same project on every machine. `dist`: it is read, and its
255
+ * absence fails the checks that need it. */
256
+ stage?: Stage | undefined;
257
+ config: SiteCheckContext["config"];
258
+ options: ResolvedOptions;
259
+ };
260
+ //#endregion
261
+ //#region src/runner.d.ts
262
+ /** Findings kept per check in the report; the rest is counted in `omitted`. */
263
+ export declare const MAX_FINDINGS_PER_CHECK = 25;
264
+ /** The controller's `siteCheckReportSchema` accepts a finding message of at most 2000 characters
265
+ * and a path of at most 1000, and skips a report it cannot read as a whole: one over-long finding
266
+ * (a check that quotes a long URL or template expression) must not cost the whole report. */
267
+ export declare const MAX_MESSAGE_CHARS = 2000;
268
+ export declare const MAX_PATH_CHARS = 1000;
269
+ type RunInput = {
270
+ root: string;
271
+ distDir: string;
272
+ srcDir?: string | undefined;
273
+ publicDir?: string | undefined;
274
+ stage?: ContextInput["stage"];
275
+ config?: Partial<ContextInput["config"]> | undefined;
276
+ options?: SiteChecksOptions | undefined;
277
+ /** Hears about a retired config key (`loadOptions`). */
278
+ note?: ((message: string) => void) | undefined;
279
+ };
280
+ /** Runs the given site checks over the project, with its build when there is one and the stage
281
+ * does not exclude it. The stages (`stages.ts`) are built on this; tests run one check through it. */
282
+ export declare const runSiteChecks: (input: RunInput, list?: readonly SiteCheck[]) => Promise<CheckReport>;
283
+ /** Results with status `error`: the only ones that refuse a build. */
284
+ export declare const blockingResults: (report: CheckReport) => CheckResult[];
285
+ //#endregion
286
+ //#region src/distChecks/index.d.ts
287
+ /**
288
+ * The dist checks: the platform's checks over a build's `dist/`. They are part of the `dist`
289
+ * stage (`site-checks dist` runs them after the site's own), and the build worker also runs them
290
+ * on its own, at its pinned version, over every build of every website: public sites, the guest
291
+ * and owner apps, and sites without this package. A site configures nothing for them. A check
292
+ * every website must pass, whether or not it has this package, belongs here.
293
+ * See docs/website-platform/process/10-dist-checks.md.
294
+ */
295
+ export declare const distChecks: readonly DistCheck[];
296
+ /** Runs every dist check over `distDir`. Never throws: a check that throws is a `failed` result,
297
+ * an unreadable `distDir` fails every check the same way. */
298
+ export declare const runDistChecks: (distDir: string, opts: {
299
+ isAstro: boolean;
300
+ siteUrl?: string | undefined;
301
+ }, list?: readonly DistCheck[]) => Promise<CheckReport>;
302
+ //#endregion
303
+ //#region src/stages.d.ts
304
+ type StageInput = {
305
+ root: string;
306
+ /** The build output; `<root>/dist` by default. Read by the `dist` stage only. */
307
+ distDir?: string | undefined;
308
+ /** The site's public URL. Without it, `site` is read from the Astro config file; without
309
+ * either, the checks that need it wait. */
310
+ site?: string | undefined;
311
+ /** Options on top of `site-checks.config.json`; a programmatic caller's, never a site's. */
312
+ options?: SiteChecksOptions | undefined;
313
+ /** Hears about a retired config key. */
314
+ note?: ((message: string) => void) | undefined;
315
+ };
316
+ /**
317
+ * Runs one stage over a project. `src` runs the source checks and leaves any `dist/` unread;
318
+ * `dist` runs the site's dist-stage checks and the platform's dist checks over the build output,
319
+ * each page parsed once for all of them. Never throws for a check's sake: a check that throws is
320
+ * a `failed` result. A config file that cannot be read throws before anything runs, and so does
321
+ * an Astro config that names `root`, `srcDir` or `publicDir`: the checks read `src/` and `public/`
322
+ * under the root, and must not pass over folders the build does not use. A site URL that is no
323
+ * URL throws too: the dist stage would fail every check on it, and failed checks do not refuse.
324
+ */
325
+ export declare const runStage: (stage: Stage, input: StageInput) => Promise<CheckReport>;
10
326
  //#endregion
11
- export { type BannedCopy, type BuildOutput, CONFIG_FILE, type Check, type CheckReport, type CheckResult, type CheckRun, type CheckStatus, type DistCheck, type DistContext, type Finding, MAX_FINDINGS_PER_CHECK, MAX_MESSAGE_CHARS, MAX_PATH_CHARS, type Page, type ResolvedOptions, type RunInput, SITE_CHECKS_FILE, type Severity, type SiteCheck, type SiteCheckContext, type SiteChecksOptions, type WiringEntry, type WiringHook, type WiringKept, blockingResults, loadOptions, refusalMessage, runSiteChecks, summarizeBlocking, summaryLines, writeSiteChecksReport };
327
+ export type { AstroConfigFacts, BannedCopy, BuildOutput, Check, CheckReport, CheckResult, CheckRun, CheckStatus, DistCheck, DistContext, DistStageContext, Finding, Io, Page, ResolvedOptions, RunInput, Severity, SiteCheck, SiteCheckContext, SiteChecksOptions, Stage, StageInput };
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { a as writeSiteChecksReport, c as MAX_PATH_CHARS, d as runSiteChecks, f as CONFIG_FILE, i as summaryLines, l as blockingResults, m as checks, n as refusalMessage, o as MAX_FINDINGS_PER_CHECK, p as loadOptions, r as summarizeBlocking, s as MAX_MESSAGE_CHARS, t as SITE_CHECKS_FILE } from "./report-D8jkvHtK.mjs";
2
- export { CONFIG_FILE, MAX_FINDINGS_PER_CHECK, MAX_MESSAGE_CHARS, MAX_PATH_CHARS, SITE_CHECKS_FILE, blockingResults, checks, loadOptions, refusalMessage, runSiteChecks, summarizeBlocking, summaryLines, writeSiteChecksReport };
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-Cj1FkuvI.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 };
@@ -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.3.1/CHANGELOG.md`: release notes for 0.3.1
8
+ - `versions/0.3.0/CHANGELOG.md`: release notes for 0.3.0
7
9
  - `versions/0.2.4/CHANGELOG.md`: release notes for 0.2.4
8
10
  - `versions/0.2.3/CHANGELOG.md`: release notes for 0.2.3
9
11
  - `versions/0.2.2/CHANGELOG.md`: release notes for 0.2.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.3.1/MIGRATION.md`: Migration: 0.3.0 to 0.3.1
8
+ - `versions/0.3.0/MIGRATION.md`: Migration: 0.2.x to 0.3.0
7
9
  - `versions/0.2.4/MIGRATION.md`: Migration: 0.2.3 to 0.2.4
8
10
  - `versions/0.2.3/MIGRATION.md`: Migration: 0.2.2 to 0.2.3
9
11
  - `versions/0.2.2/MIGRATION.md`: Migration: 0.2.1 to 0.2.2
@@ -0,0 +1,39 @@
1
+ # Changelog: 0.3.0
2
+
3
+ The checks leave the Astro build and become a command of their own, in two stages: `site-checks
4
+ src` before the build and `site-checks dist` after it. AI Studio's build worker runs both around
5
+ `astro build` on every deploy; locally they are how a developer looks before pushing. Three checks
6
+ that guarded hand-wired kit-era code, or the dev server only, are gone.
7
+
8
+ ## Added
9
+
10
+ - The `site-checks` bin with two stages. `src` runs `html-comments`, `image-formats`, `sync-once`
11
+ and `v9-hub-filters` over the project and never reads `dist/`; a refusal there costs seconds, not
12
+ a build. `dist` runs the other site checks and the platform's dist checks over the built output,
13
+ each page parsed once, and writes `dist/site-checks.json`. Exit 1 when a check with severity
14
+ `error` found something, 2 on a usage or configuration error.
15
+ - `--site <url>` names the site's public URL; without it, `site` and `trailingSlash` are read from
16
+ the Astro config file as text. A value the file computes, sets twice or sets in a file that
17
+ spreads an object is left unknown, and the checks that need it wait (`trailing-slash` too).
18
+ The checks read `src/` and `public/` under the project root: a config that names `root`,
19
+ `srcDir` or `publicDir` stops the command with exit 2. `--root`,
20
+ `--dist` and `--report` place the project, the build output and the report.
21
+ - `runStage(stage, input)` for programmatic use.
22
+
23
+ ## Changed
24
+
25
+ - `siteChecks()`, the Astro integration, and the `@v-office/site-checks/astro` entry are gone;
26
+ nothing goes into `astro.config` any more. The platform's dist checks are exported from the
27
+ package root instead of `@v-office/site-checks/dist-checks`.
28
+ - A `site-checks.config.json` key of a removed check (`wiring`, `optimizeDepsIgnore`) is noted and
29
+ ignored, so a site mid-rollout keeps building; an unknown key still stops the command.
30
+ - `image-formats` leaves out the web-app-manifest icons (`web-app-manifest-<w>x<h>.png`) and the
31
+ icons kept in `public/favicon/`, the site starter's layout, as it already did for the icons at
32
+ the root of `public/`: browsers load them as PNG by name, so no `imageIgnore` entry is needed.
33
+
34
+ ## Removed
35
+
36
+ - `wiring` and `unused-initializers`: they guarded markup hand-bound to scripts in `src/scripts/`,
37
+ which imported components make unnecessary.
38
+ - `optimize-deps`: it was about the dev server's pre-bundling, which the production build does not
39
+ share.
@@ -0,0 +1,43 @@
1
+ # Migration: 0.2.x to 0.3.0
2
+
3
+ ## 1. Upgrade
4
+
5
+ ```sh
6
+ pnpm add --save-exact --save-dev @v-office/site-checks@0.3.0
7
+ ```
8
+
9
+ ## 2. Take the integration out of `astro.config`
10
+
11
+ Remove `siteChecks()` from `integrations` and its import of `@v-office/site-checks/astro`. The
12
+ build no longer runs the checks; the two commands below do.
13
+
14
+ ## 3. Add the two scripts
15
+
16
+ ```json
17
+ {
18
+ "scripts": {
19
+ "check:src": "site-checks src",
20
+ "check:dist": "site-checks dist"
21
+ }
22
+ }
23
+ ```
24
+
25
+ They are for developers: `pnpm check:src` any time, `pnpm check:dist` after `pnpm build`. AI
26
+ Studio's build worker calls the bin itself, around `astro build`, on every deploy.
27
+
28
+ **Order matters.** Until AI Studio's build worker runs the two stages, nothing runs them on a
29
+ deploy: a site that takes the integration out before that ships its build unchecked. Upgrade a
30
+ site only through AI Studio's rollout, which starts once the worker runs the stages. Until then a
31
+ site stays on 0.2.x with `siteChecks()`: 0.3.0 has no integration and no
32
+ `@v-office/site-checks/astro` entry, so a config that still imports it fails to load.
33
+
34
+ ## 4. Clean `site-checks.config.json`
35
+
36
+ Delete the `wiring` and `optimizeDepsIgnore` keys if the file has them: their checks are gone. A
37
+ site that passed options to `siteChecks({ … })` in code moves them into the file; the file is the
38
+ one place the checks read.
39
+
40
+ ## What stays the same
41
+
42
+ Every other check, its severity and its config keys. The report in `dist/site-checks.json` has
43
+ the same shape, now with the platform's dist checks in it as well.
@@ -0,0 +1,16 @@
1
+ # Changelog: 0.3.1
2
+
3
+ The notes only: the code is the same as 0.3.0. They now say how AI Studio runs the checks. Its
4
+ build worker runs the `src` stage itself for every Astro site, from its own copy of this package,
5
+ so a site installs nothing for the source checks; installing the package adds the `dist` stage's
6
+ site checks and the two commands.
7
+
8
+ ## Changed
9
+
10
+ - The README, the package description and the migration notes describe how the build worker runs
11
+ the stages. `src` (`html-comments`, `image-formats`, `sync-once`, `v9-hub-filters`) runs in the
12
+ worker for every Astro site, at the worker's version, with the site's `site-checks.config.json`
13
+ as its data, before `astro check`. `dist` runs as the site's own `site-checks dist` when the
14
+ site installed this package; without it, the worker runs the platform's dist checks only.
15
+ - The worker no longer stores the report of the 0.2.x `siteChecks()` integration: a site still on
16
+ 0.2.x takes the integration out (Migration: 0.2.x to 0.3.0, step 2).
@@ -0,0 +1,24 @@
1
+ # Migration: 0.3.0 to 0.3.1
2
+
3
+ No changes required: 0.3.1 changes the notes only.
4
+
5
+ ## 1. Upgrade
6
+
7
+ ```sh
8
+ pnpm add --save-exact --save-dev @v-office/site-checks@0.3.1
9
+ ```
10
+
11
+ ## What changes for the site
12
+
13
+ - Nothing in the build. AI Studio's build worker runs the source checks of every Astro site
14
+ itself, whether or not the site installs this package: a finding with severity `error` in the
15
+ project refuses the deploy before `astro check`, and the previous build stays live.
16
+ - `site-checks.config.json` stays at the project root: the worker's source checks read it. A key
17
+ of a removed check is noted and ignored; an unknown key stops the checks, and with them the
18
+ build.
19
+ - With this package installed, the build also runs `site-checks dist` at the site's version, the
20
+ site checks of the `dist` stage included. Without it, the build gets the platform's dist checks
21
+ only. "Order matters" in the 0.3.0 notes no longer applies: the worker runs the stages now.
22
+ - A site still on 0.2.x takes `siteChecks()` out of `astro.config` (Migration: 0.2.x to 0.3.0,
23
+ step 2), and either removes the package or upgrades to this version. The worker no longer
24
+ stores the integration's report.
package/package.json CHANGED
@@ -1,13 +1,16 @@
1
1
  {
2
2
  "name": "@v-office/site-checks",
3
- "version": "0.2.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",
3
+ "version": "0.3.1",
4
+ "description": "The checks over a v-office website in two stages: `site-checks src` before the build (AI Studio's build worker runs it for every Astro site) and `site-checks dist` after it, with the report in the shape of the build worker's dist-check report. A check with severity error refuses the deploy",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "git+https://github.com/vofficeGmbh/ai-studio.git",
9
9
  "directory": "packages/site-checks"
10
10
  },
11
+ "bin": {
12
+ "site-checks": "./dist/bin.mjs"
13
+ },
11
14
  "files": [
12
15
  "dist",
13
16
  "README.md",
@@ -17,8 +20,6 @@
17
20
  "types": "./dist/index.d.mts",
18
21
  "exports": {
19
22
  ".": "./dist/index.mjs",
20
- "./astro": "./dist/astro.mjs",
21
- "./dist-checks": "./dist/dist-checks.mjs",
22
23
  "./package.json": "./package.json"
23
24
  },
24
25
  "publishConfig": {
@@ -29,7 +30,6 @@
29
30
  },
30
31
  "devDependencies": {
31
32
  "@types/node": "26.5.1",
32
- "astro": "7.3.2",
33
33
  "oxfmt": "0.67.0",
34
34
  "oxlint": "1.82.0",
35
35
  "tsdown": "0.23.0",
package/dist/astro.d.mts DELETED
@@ -1,37 +0,0 @@
1
- import { i as SiteChecksOptions } from "./options-CANJso9Q.mjs";
2
- //#region src/astro.d.ts
3
- /** The part of Astro's resolved config the checks read. A structural subset, so that astro is a
4
- * devDependency for the compile-time type test only; `__tests__/types.test.ts` proves Astro's
5
- * `AstroIntegration` accepts the result. */
6
- export interface SiteChecksAstroConfig {
7
- root: URL;
8
- srcDir: URL;
9
- publicDir: URL;
10
- site?: string | undefined;
11
- trailingSlash?: string | undefined;
12
- vite: {
13
- optimizeDeps?: {
14
- include?: string[] | undefined;
15
- } | undefined;
16
- };
17
- }
18
- export interface SiteChecksIntegration {
19
- name: string;
20
- hooks: {
21
- "astro:config:done": (ctx: {
22
- config: SiteChecksAstroConfig;
23
- }) => void;
24
- "astro:build:done": (ctx: {
25
- dir: URL;
26
- }) => Promise<void>;
27
- };
28
- }
29
- /**
30
- * The checks as an Astro integration: `integrations: [siteManifest(), siteChecks()]`. After the
31
- * build it runs every check over the project and `dist/`, writes `dist/site-checks.json`, prints
32
- * one line per check that found something, and refuses the build (throws, so `astro build` exits
33
- * non-zero) when a check with severity `error` found something. The file is written before the
34
- * throw: the build worker reads the report of a refused build.
35
- */
36
- export declare function siteChecks(options?: SiteChecksOptions): SiteChecksIntegration;
37
- //#endregion
package/dist/astro.mjs DELETED
@@ -1,56 +0,0 @@
1
- import { a as writeSiteChecksReport, d as runSiteChecks, i as summaryLines, l as blockingResults, m as checks, n as refusalMessage, p as loadOptions } from "./report-D8jkvHtK.mjs";
2
- import { fileURLToPath } from "node:url";
3
- //#region src/astro.ts
4
- /**
5
- * The checks as an Astro integration: `integrations: [siteManifest(), siteChecks()]`. After the
6
- * build it runs every check over the project and `dist/`, writes `dist/site-checks.json`, prints
7
- * one line per check that found something, and refuses the build (throws, so `astro build` exits
8
- * non-zero) when a check with severity `error` found something. The file is written before the
9
- * throw: the build worker reads the report of a refused build.
10
- */
11
- function siteChecks(options = {}) {
12
- let paths = {
13
- root: process.cwd(),
14
- srcDir: "",
15
- publicDir: ""
16
- };
17
- let config = {
18
- site: void 0,
19
- optimizeDepsInclude: [],
20
- trailingSlash: void 0
21
- };
22
- let resolved;
23
- return {
24
- name: "@v-office/site-checks",
25
- hooks: {
26
- "astro:config:done": ({ config: astro }) => {
27
- paths = {
28
- root: fileURLToPath(astro.root),
29
- srcDir: fileURLToPath(astro.srcDir),
30
- publicDir: fileURLToPath(astro.publicDir)
31
- };
32
- config = {
33
- site: astro.site,
34
- optimizeDepsInclude: astro.vite.optimizeDeps?.include ?? [],
35
- trailingSlash: astro.trailingSlash
36
- };
37
- resolved = loadOptions(paths.root, options);
38
- },
39
- "astro:build:done": async ({ dir }) => {
40
- const distDir = fileURLToPath(dir);
41
- const report = await runSiteChecks({
42
- ...paths,
43
- distDir,
44
- config,
45
- options: resolved ?? loadOptions(paths.root, options)
46
- }, checks);
47
- writeSiteChecksReport(distDir, report);
48
- for (const line of summaryLines(report)) console.warn(line);
49
- if (blockingResults(report).length > 0) throw new Error(refusalMessage(report));
50
- console.log(`[site-checks] ${report.results.length} checks, nothing refused`);
51
- }
52
- }
53
- };
54
- }
55
- //#endregion
56
- export { siteChecks };
@@ -1,21 +0,0 @@
1
- import { S as Severity, _ as CheckStatus, a as blockingResults, b as Finding, g as CheckRun, h as CheckResult, l as summarizeBlocking, m as CheckReport, n as MAX_MESSAGE_CHARS, r as MAX_PATH_CHARS, s as SITE_CHECKS_FILE, t as MAX_FINDINGS_PER_CHECK, v as DistCheck, x as Page, y as DistContext } from "./runner-CK4iXk8Z.mjs";
2
- //#region src/distChecks/index.d.ts
3
- /**
4
- * The dist checks: the platform's checks over a build's `dist/`, run by the build worker on every
5
- * build of every website at the worker's pinned version of this package — public sites, the guest
6
- * and owner apps, and sites that never installed it. The site checks (`checks/`) are the other
7
- * family: they run inside a site's own `astro build`, at the site's pinned version. What decides
8
- * the family is who runs a check, not what it reads: several site checks read `dist/` too. A check
9
- * every website must pass, whether or not it adopted this package, belongs here.
10
- * `@v-office/site-checks/dist-checks` is this file; the integration never runs these.
11
- * See docs/website-platform/process/10-dist-checks.md.
12
- */
13
- export declare const distChecks: readonly DistCheck[];
14
- /** Runs every dist check over `distDir`. Never throws: a check that throws is a `failed` result,
15
- * an unreadable `distDir` fails every check the same way. */
16
- export declare const runDistChecks: (distDir: string, opts: {
17
- isAstro: boolean;
18
- siteUrl?: string | undefined;
19
- }, list?: readonly DistCheck[]) => Promise<CheckReport>;
20
- //#endregion
21
- export { type CheckReport, type CheckResult, type CheckRun, type CheckStatus, type DistCheck, type DistContext, type Finding, MAX_FINDINGS_PER_CHECK, MAX_MESSAGE_CHARS, MAX_PATH_CHARS, type Page, SITE_CHECKS_FILE, type Severity, blockingResults, summarizeBlocking };