Adds the URL rules to the preview server, IIS config and deploy
The preview server and web.config now follow the same URLs as nginx, without the SPA fallback. Lighthouse exceptions need a recorded reason and the 404 page is audited through an opt-in route. The deploy checks the build first and the served result afterwards. The IIS rules stay unverified until a host exists. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+18
-11
@@ -247,7 +247,7 @@ The riskiest mechanism is the nginx block (a `map`, a server-level `if` and `rew
|
||||
|
||||
## Part C: Preview server (batch B2, Sonnet; parallel with B3, B4, B5)
|
||||
|
||||
### Step 7: New `resolveRequest` contract and audit route (BR-HST-01 to 08, 22; V7) [ ]
|
||||
### Step 7: New `resolveRequest` contract and audit route (BR-HST-01 to 08, 22; V7) [x]
|
||||
|
||||
- Executor: Sonnet.
|
||||
- Implements: BR-HST-01 to 08, 11, 13, 22; FR-PR-14, 16, 23.
|
||||
@@ -259,8 +259,9 @@ The riskiest mechanism is the nginx block (a `map`, a server-level `if` and `rew
|
||||
4. `startPreviewServer(clientDir, port, options?: { auditRoute?: boolean })`; `parseArguments` accepts `--audit-route` (boolean) next to `--port`, `--strictPort`, `--dir`; unknown arguments are still ignored. Update the file's header comment: the 404 page is audited through the opt-in route; `/404.html` is a real 404.
|
||||
- Done when: `pnpm exec tsc --noEmit`, `pnpm lint` clean; the tests of § 6 for this file fail as expected and no others (they are rewritten in Step 8).
|
||||
- Record: one line naming the exported types.
|
||||
- Done: exported `FileResult`, `RedirectResult`, `ResolvedRequest` (union), `ResolveOptions`, `PreviewOptions`; `resolveRequest(path, fileExists, options?)` and `startPreviewServer(clientDir, port, options?)`.
|
||||
|
||||
### Step 8: Tests for the preview server (P-HST-01, 05, 06; V3, V7) [ ]
|
||||
### Step 8: Tests for the preview server (P-HST-01, 05, 06; V3, V7) [x]
|
||||
|
||||
- Executor: Sonnet.
|
||||
- Implements: P-HST-01, 02, 03, 04, 05, 06; V3, V7.
|
||||
@@ -272,12 +273,13 @@ The riskiest mechanism is the nginx block (a `map`, a server-level `if` and `rew
|
||||
4. Server level with `startPreviewServer`: a redirect response has status 301, a relative `Location` with the query kept byte for byte (P-HST-05, `(invariant)` over `queryString`), the five security headers, no body, and works for HEAD; `/404.html` and `/404` answer 404 with the page and headers; `/__audit/404` is 404 without the option and 200 with it, and `/404.html` stays 404 with the option; `--audit-route` through the command-line tests (`previewServer als opdrachtregel`): with the flag the route answers 200.
|
||||
- Done when: `pnpm exec vitest run config/previewServer.test.ts` green; `pnpm exec tsc --noEmit`, `pnpm lint` clean.
|
||||
- Record: which existing tests changed (names), and the P17 note.
|
||||
- Done: changed the group `tussenregels uit BR-SRV-07` (now `regels uit BR-HST-03 tot 05`), `behandelt een laatste segment met een punt als bestandsverzoek` (`/over-mij.html` is a 301), the drive-letter assertion (now `toEqual(NOT_FOUND)`, stricter), `antwoordt op /404 met status 404` (now `/404` and `/404.html`, 404 with page and headers), `comprimeert elk teksttype` (requests `/over-mij` instead of `/over-mij.html`, same gzip assertions), P16 (redirect results are skipped, `file` checks unchanged) and P17 (the model returns the redirect for any input that `canonicalRedirect` maps, and `/404.html` is 404). `siteDir` gained `soorten-fotoshoots.html` and its directory.
|
||||
|
||||
---
|
||||
|
||||
## Part D: IIS text and config tests (batch B3, Sonnet; parallel with B2, B4, B5)
|
||||
|
||||
### Step 9: The IIS `web.config` text (BR-HST-04, 07, 10, 19) [ ]
|
||||
### Step 9: The IIS `web.config` text (BR-HST-04, 07, 10, 19) [x]
|
||||
|
||||
- Executor: Sonnet.
|
||||
- Implements: BR-HST-02, 04, 06, 07, 10, 12, 13, 19; FR-PR-14, 16, 23. **These rules are unverified until a host exists; do not build any tooling to verify them.**
|
||||
@@ -285,8 +287,9 @@ The riskiest mechanism is the nginx block (a `map`, a server-level `if` and `rew
|
||||
- Do: rewrite `iisWebConfig` per infrastructure-design.md § 4.3. Rule order inside `<rewrite><rules>`: `www naar andreaslop.nl` and `HTTPS` unchanged; then `Index naar root`, `Pagina canoniek` (alternation of the page names built from `redirectNames` and `variantPattern`, condition `{R:0}` not matching the exact lower-case canonical form with `ignoreCase="false"`, `Redirect` to `/{ToLower:{R:1}}`, permanent), `Slash weg` (`^([^/\\].*?)/+$`, redirect `/{R:1}`), `404 direct` (`^404(?:\.html)?$`, `CustomResponse` 404), `Pagina bestand` (`^(.+)$`, condition `{REQUEST_FILENAME}.html` `IsFile`, rewrite `{R:1}.html`), `Map zonder pagina` (`^(.+)$`, condition `{REQUEST_FILENAME}` `IsDirectory`, `CustomResponse` 404). All with `stopProcessing="true"`. The "SPA fallback" rule is **removed**. After `<rewrite>`: `<httpErrors errorMode="Custom" existingResponse="Replace">` with `<remove statusCode="404" subStatusCode="-1" />` and `<error statusCode="404" subStatusCode="-1" path="/404.html" responseMode="ExecuteURL" />`; `<urlCompression doStaticCompression="true" doDynamicCompression="false" />`; in `staticContent` the existing `woff2` entry plus remove-then-add MIME pins for `.js` (`text/javascript`), `.svg`, `.json`, `.xml` (`text/xml`) taken from `compressibleTypes.ts`; `clientCache` and the `/assets` location block as now; `httpProtocol` headers as now. No `httpCompression`, no `directoryBrowse`, no `defaultDocument`. Escape all attribute values with the existing `xmlAttribute`. Update the header comment: the rules are generated from the page list; unverified until a host exists (open points U1 to U6 in infrastructure-design.md § 7.2).
|
||||
- Done when: the generated file is well-formed XML (parse it in a test, Step 10); `pnpm exec tsc --noEmit`, `pnpm lint` clean.
|
||||
- Record: one line listing the rule names in order.
|
||||
Record (done): www naar andreaslop.nl, HTTPS, Index naar root, Pagina canoniek, Slash weg, 404 direct, Pagina bestand, Map zonder pagina. Unverified until a host exists (V6 withdrawn).
|
||||
|
||||
### Step 10: Complete `serverConfig.test.ts` (P-HST-07, 08, 10) [ ]
|
||||
### Step 10: Complete `serverConfig.test.ts` (P-HST-07, 08, 10) [x]
|
||||
|
||||
- Executor: Sonnet.
|
||||
- Implements: P-HST-07, 08, 10; BR-HST-03, 04, 06, 07, 09 to 13, 19.
|
||||
@@ -297,12 +300,13 @@ The riskiest mechanism is the nginx block (a `map`, a server-level `if` and `rew
|
||||
3. P-HST-10 replacement (example-based text test): `iisWebConfig()` parses as XML (use a small regex-free check with the built-in `DOMParser` via `// @vitest-environment jsdom`, or a string balance check if jsdom is not already used in this file; keep the environment of the file in mind), contains the rule names in the designed order, has no `SPA fallback` and no `index.html` rewrite, contains `ToLower` only inside the canonical rule, `[^/\\]` in the slash rule, `ExecuteURL`, `urlCompression`, and neither `httpCompression` nor `directoryBrowse`; the five headers appear as before.
|
||||
- Done when: `pnpm exec vitest run config/serverConfig.test.ts` green; the number of assertions in the file is higher than before.
|
||||
- Record: the names of replaced tests.
|
||||
Record (done): "IIS heeft een SPA-fallback en een HTTPS-redirect" became "IIS heeft een HTTPS-redirect en geen SPA-fallback" (stricter: also no index.html). The nginx replacements were already in place. 13 tests became 26.
|
||||
|
||||
---
|
||||
|
||||
## Part E: Lighthouse configuration (batch B4, Sonnet; parallel with B2, B3, B5)
|
||||
|
||||
### Step 11: Data-driven `lighthouserc.cjs` and the audit route (BR-HST-21 to 23) [ ]
|
||||
### Step 11: Data-driven `lighthouserc.cjs` and the audit route (BR-HST-21 to 23) [x]
|
||||
|
||||
- Executor: Sonnet.
|
||||
- Implements: BR-HST-21, 22, 23; NFR-PR-P-01, P-02, S-01; V13.
|
||||
@@ -313,9 +317,9 @@ The riskiest mechanism is the nginx block (a `map`, a server-level `if` and `rew
|
||||
3. Update `lighthouserc.d.cts` for the new exports.
|
||||
4. Keep the comment block that explains why performance is `warn` in CI; add one line that `numberOfRuns` is 1 on purpose and that a page exactly at 0.90 can fail `pnpm check` by chance (owner decision O6).
|
||||
- Done when: `node -e "const c=require('./lighthouserc.cjs'); console.log(Object.keys(c.mobileExceptions).length, c.notFoundPath, c.ci.collect.startServerCommand)"` prints 8, `/__audit/404` and the new command; the effective targets per URL are identical to before (compare the output of a small script that prints, per URL, the `minScore` of the matching mobile and desktop entries before (from `git stash`-free means: read the original file with `git show HEAD:web/lighthouserc.cjs` into the scratch folder and load both) and after: all equal); `pnpm exec tsc --noEmit`, `pnpm lint` clean.
|
||||
- Record: the before/after table of targets (must be identical).
|
||||
- Record: targets identical before and after (per URL, mobile and desktop, performance level error and warn): `/` 0.8; `/over-mij`, `/soorten-fotoshoots` and the five shoot pages 0.85; `/portfolio`, `/contact`, `/privacyverklaring` and the 404 page 0.9; desktop 0.9 everywhere. The 404 URL changed to `/__audit/404` as the plan prescribes. `photoPagePaths` is kept as a derived export because `src/app.test.tsx` imports it.
|
||||
|
||||
### Step 12: Tests for the Lighthouse configuration (P-HST-11, V13) [ ]
|
||||
### Step 12: Tests for the Lighthouse configuration (P-HST-11, V13) [x]
|
||||
|
||||
- Executor: Sonnet.
|
||||
- Implements: P-HST-11; BR-HST-22, 23; V13.
|
||||
@@ -324,13 +328,13 @@ The riskiest mechanism is the nginx block (a `map`, a server-level `if` and `rew
|
||||
1. `app.test.tsx`: `expect(lighthouseConfig.notFoundPath).toBe('/__audit/404')` and update the comment (Lighthouse refuses an error status; the preview serves the 404 page with 200 only through the opt-in route; `/404.html` is a real 404).
|
||||
2. `config/lighthouserc.test.ts` (loads the CJS module with `createRequire`): every exception has a non-empty `decision` string, `minScore < 0.9`, and names a path in `indexedPaths`; no URL of the collect list matches two assert-matrix entries and none matches zero (use each entry's `matchingUrlPattern` as a RegExp); `notFoundPath` is not in `indexedPaths` or `noindexPaths`; `startServerCommand` contains `--audit-route`; `numberOfRuns` is 1; the quality categories accessibility, best-practices, SEO have `minScore: 1` in every entry that has them; the desktop config sets every performance assertion to 0.9. Property-style (`(invariant)`) where useful: for any generated subset of exception entries the matrix builder (if exported as a function; otherwise test the produced matrix) covers each indexed page exactly once. Include an example-based test that a deliberately invalid exception (empty decision, `minScore` 0.9) would be rejected by the validation helper you extract (`validateExceptions` in the CJS file, exported and used by the module itself at load time so a bad table fails at import).
|
||||
- Done when: `pnpm exec vitest run config/lighthouserc.test.ts src/app.test.tsx` green; `pnpm exec tsc --noEmit`, `pnpm lint` clean.
|
||||
- Record: one line.
|
||||
- Record: `config/lighthouserc.test.ts` added (invariants, validation helper, desktop); only the `notFoundPath` assertion and its comment changed in `src/app.test.tsx`; 55 tests green across both files.
|
||||
|
||||
---
|
||||
|
||||
## Part F: Deploy scripts and CI (batch B5, Sonnet; parallel with B2, B3, B4)
|
||||
|
||||
### Step 13: Artifact guard and post-deploy script (BR-HST-15, 18; V11) [ ]
|
||||
### Step 13: Artifact guard and post-deploy script (BR-HST-15, 18; V11) [x]
|
||||
|
||||
- Executor: Sonnet.
|
||||
- Implements: BR-HST-15, 18; FR-PR-17; NFR-PR-SEC-03; V11.
|
||||
@@ -341,8 +345,9 @@ The riskiest mechanism is the nginx block (a `map`, a server-level `if` and `rew
|
||||
3. `e2e/deployScripts.e2e.ts`: skipped with a visible line when `bash` or `curl` is missing outside CI (fails in CI). Tests: `check-artifact.sh` passes on a fixture dist and fails for each violation (missing file, `server/`, a `.map`); `verify-deployment.sh` passes against `startPreviewServer` on the fixture site (without `--test`) and **fails against a tiny stub server** that imitates the old behaviour (serves `index.html` with 200 for every path, no 404, no redirects) with a message naming the `/over-mij` byte check (V11); and fails when a security header is missing (stub).
|
||||
- Done when: `pnpm exec vitest run --config vitest.e2e.config.ts e2e/deployScripts.e2e.ts` green (or skipped with the visible line when bash is absent); `pnpm exec tsc --noEmit`, `pnpm lint` clean.
|
||||
- Record: V11 outcome.
|
||||
- Done: check-artifact.sh, verify-deployment.sh and e2e/deployScripts.e2e.ts written. V11: verify-deployment.sh fails against a stub with the old behaviour (homepage with 200 for every path) with "/over-mij: antwoord is niet gelijk aan over-mij.html", and passes against a stub with the new rules and against the preview server on the fixture site. Proven against stubs, not against the real old nginx file. Locally 22 passed, 5 skipped (the lftp tests).
|
||||
|
||||
### Step 14: Production upload script and the lftp passes (BR-HST-14; V10) [ ]
|
||||
### Step 14: Production upload script and the lftp passes (BR-HST-14; V10) [x]
|
||||
|
||||
- Executor: Sonnet.
|
||||
- Implements: BR-HST-14, 15; FR-PR-18; V10.
|
||||
@@ -354,8 +359,9 @@ The riskiest mechanism is the nginx block (a `map`, a server-level `if` and `rew
|
||||
4. If `lftp` is not installed locally, the local test does not run and the syntax is **unverified until the first CI run**: state that plainly in the Record and in the verification log V10 (Status OPEN), and do not install lftp.
|
||||
- Done when: the script exists and passes `bash -n`; the test runs green with lftp, or V10 is recorded OPEN with the reason; `pnpm exec tsc --noEmit`, `pnpm lint` clean.
|
||||
- Record: V10 outcome and the chosen syntax with its source.
|
||||
- Done: upload-production.sh written (passes `bash -n`; command text checked with a fake lftp on the PATH). Chosen syntax: `--exclude-glob '*.html' --exclude-glob web.config` for pass 1 and `--include-glob '*.html'` for pass 2 (the design sketch; lftp manual at https://lftp.yar.ru/ not consulted offline). lftp is not installed locally, so V10 is OPEN: the syntax is unverified until the first CI run (the lighthouse job installs lftp and runs the test). Open question for that run: whether `--include-glob` alone includes only HTML and still descends into directories.
|
||||
|
||||
### Step 15: Workflow edits for the deploy jobs (BR-HST-14 to 18) [ ]
|
||||
### Step 15: Workflow edits for the deploy jobs (BR-HST-14 to 18) [x]
|
||||
|
||||
- Executor: Sonnet.
|
||||
- Implements: BR-HST-14 to 18; FR-PR-17, 18.
|
||||
@@ -366,6 +372,7 @@ The riskiest mechanism is the nginx block (a `map`, a server-level `if` and `rew
|
||||
3. Update the header comment of the workflow only if it states something that is now wrong.
|
||||
- Done when: the YAML is valid (same check as Step 5); the diff touches only the two deploy jobs; the lftp command text exists in exactly one place (`upload-production.sh`).
|
||||
- Record: the diff summary.
|
||||
- Done: deploy-test: new step "Controle van de build" (check-artifact.sh) before the upload; "Controle na deploy" runs verify-deployment.sh with --test. deploy-production: the web.config step and the inline lftp block are replaced by one call of upload-production.sh; the post-deploy step runs verify-deployment.sh; if-condition unchanged. YAML parses (yaml 1.10.3 from the pnpm store); no mirror/lftp command text left in the workflow. See `git diff .gitea`.
|
||||
|
||||
**CP2** (merge point after Steps 7 to 15): run `pnpm exec tsc --noEmit`, `pnpm lint`, `pnpm format:check`, `pnpm test`, `pnpm build`, in that order, alone (no parallel batch running). All green, or STOP.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user