eaa-kit 0.7.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/README.md +30 -8
  2. package/dist/astro/index.js +1 -1
  3. package/dist/audit-CJDCQaFY.js +2 -0
  4. package/dist/{audit-DRjAY2iY.js → audit-J2jeLo-y.js} +38 -198
  5. package/dist/{baseline-rtnj3RHB.js → baseline-477B1CZ_.js} +1 -1
  6. package/dist/baseline-D9ihb-wk.js +2 -0
  7. package/dist/{baseline-BpE7DbDq.js → baseline-DrFh7joZ.js} +14 -3
  8. package/dist/baseline-wyJsSIFQ.js +127 -0
  9. package/dist/{checklist-DDd9jewi.js → checklist-Gx2g3LFC.js} +6 -6
  10. package/dist/cli/index.js +83 -143
  11. package/dist/{collect-Cu1q9NTB.js → collect-BJYk7_pJ.js} +1 -1
  12. package/dist/{command-3r4fht5f.js → command-BGGMf4vn.js} +30 -4
  13. package/dist/countries-DRTBubeE.js +25 -0
  14. package/dist/countries-Dg0BdytB.js +156 -0
  15. package/dist/{coverage-n1X9CkiG.js → coverage-GvaMpV64.js} +1 -1
  16. package/dist/{coverage-cb5kPp48.js → coverage-zdzgSKjz.js} +1 -1
  17. package/dist/{crawl-BHkJmUkA.js → crawl-DwdqiljK.js} +5 -3
  18. package/dist/{load-BaWMa-G_.js → define-Ctf2uOEh.js} +41 -94
  19. package/dist/eleventy/index.js +1 -1
  20. package/dist/entry-CjqjrUBY.js +174 -0
  21. package/dist/{html-BIxxF3FC.js → html-whingnfj.js} +6 -4
  22. package/dist/index.d.ts +42 -5
  23. package/dist/index.js +3 -2
  24. package/dist/init-CPbFVMuk.js +293 -0
  25. package/dist/{json-CrQmoTj6.js → json-CyLmvF5P.js} +1 -1
  26. package/dist/{json-Bus6YhxB.js → json-SGCgxSPT.js} +1 -1
  27. package/dist/load-CH-ltdlq.js +99 -0
  28. package/dist/load-D7lBeOsq.js +2 -0
  29. package/dist/nuxt/index.js +1 -1
  30. package/dist/pages-DxY5Z0gl.js +300 -0
  31. package/dist/{project-MFrXcw1M.js → project-BLFdCbOq.js} +1 -1
  32. package/dist/{project-CzOnkLH6.js → project-v2PoRw70.js} +18 -1
  33. package/dist/{remediation-C0klJblu.js → remediation-Bbs4KcX1.js} +18 -1
  34. package/dist/{render-C1sUZZI_.js → render-C6zYfaba.js} +29 -5
  35. package/dist/{review-CdMK2GpQ.js → review-Bz0fO9_I.js} +9 -1
  36. package/dist/{review-DIbOTmOM.js → review-a-2ghjQ5.js} +1 -1
  37. package/dist/{routes-CmdRUuOs.js → routes-CSctpS1P.js} +1 -1
  38. package/dist/{run-DrS0Komf.js → run-DzVEOkiF.js} +1 -1
  39. package/dist/{sarif-BNCE0PNT.js → sarif-9BAgNiOa.js} +3 -2
  40. package/dist/site-BHMtf3q2.js +72 -0
  41. package/dist/start-DzOM0p6I.js +101 -0
  42. package/dist/statement/templates/be.de.md +148 -0
  43. package/dist/statement/templates/be.en.md +142 -0
  44. package/dist/statement/templates/be.fr.md +146 -0
  45. package/dist/statement/templates/be.nl.md +147 -0
  46. package/dist/statement/templates/cz.cs.md +137 -0
  47. package/dist/statement/templates/cz.en.md +139 -0
  48. package/dist/statement/templates/dk.da.md +141 -0
  49. package/dist/statement/templates/dk.en.md +141 -0
  50. package/dist/statement/templates/fi.en.md +139 -0
  51. package/dist/statement/templates/fi.fi.md +141 -0
  52. package/dist/statement/templates/ie.en.md +144 -0
  53. package/dist/statement/templates/pl.en.md +143 -0
  54. package/dist/statement/templates/pl.pl.md +144 -0
  55. package/dist/statement/templates/pt.en.md +142 -0
  56. package/dist/statement/templates/pt.pt.md +145 -0
  57. package/dist/statement/templates/se.en.md +139 -0
  58. package/dist/statement/templates/se.sv.md +142 -0
  59. package/dist/vite/index.js +1 -1
  60. package/dist/watch-B2RoUbo0.js +122 -0
  61. package/dist/webpack/index.js +1 -1
  62. package/dist/{worksheet-BIxMtbUd.js → worksheet-B_kQ1pxq.js} +1 -1
  63. package/package.json +2 -2
  64. package/dist/audit-Bwm1xBdJ.js +0 -2
  65. package/dist/init-DrFfzjvm.js +0 -119
  66. package/dist/load-n62iXDq_.js +0 -2
package/README.md CHANGED
@@ -6,10 +6,22 @@ Build-time WCAG 2.2 AA auditor and EU accessibility statement generator for stat
6
6
  built for the freelancers and small agencies who have to comply with the European
7
7
  Accessibility Act (in force since 28 June 2025) without an accessibility budget. It started
8
8
  in the DACH region — the BFSG in Germany, the BaFG in Austria — and the statement now names
9
- the statute and supervisory body of **seven countries**: Austria, Germany, Switzerland,
10
- Spain, France, Italy and the Netherlands, each in its own language as well as English.
11
-
12
- 0.7.0 makes a run cost what it should. A page that has not changed byte for byte is not
9
+ the statute and supervisory body of **fifteen countries**: Austria, Belgium, Czechia,
10
+ Denmark, Finland, France, Germany, Ireland, Italy, the Netherlands, Poland, Portugal,
11
+ Spain, Sweden and Switzerland, each in its own language as well as English.
12
+
13
+ 0.9.0 needs no setup. `npx eaa-kit` on its own finds the site, audits it, writes an HTML
14
+ report and says which command comes next. `init` fills itself in from what the built site
15
+ states, and also writes a baseline and a GitHub Actions workflow tailored to the project.
16
+ Every error a new user is likely to hit ends with the command to type next. A `--url` run
17
+ checks where the address leads before it crawls: a redirect to another site is shown and
18
+ needs a yes (or `--redirects follow`), and a sign-in wall stops the run instead of being
19
+ audited as the site. `audit --watch` re-checks the build on every save, and eight countries
20
+ join the statement. Their citations were established from secondary sources and are marked
21
+ as such in `eaa-kit countries` and the docs until they are checked against the primary
22
+ text.
23
+
24
+ 0.7.0 made a run cost what it should. A page that has not changed byte for byte is not
13
25
  audited again, and a run with nothing to re-audit never loads an engine at all: twenty
14
26
  pages go from ~2,520 ms to ~230 ms, which is about what starting the process costs. A
15
27
  reused result is never passed off as a fresh one — every report says how much was reused
@@ -24,10 +36,12 @@ through, `audit --review` reads the answers back beside what the run measured, a
24
36
  Sites behind a login or a preview protection are auditable too.
25
37
 
26
38
  ```bash
39
+ npx eaa-kit # nothing to set up: finds your site, audits it, writes a report
27
40
  npx eaa-kit audit # WCAG 2.2 AA report; finds your build itself
28
41
  npx eaa-kit diff a.json b.json # what a change made worse, and what it fixed
29
- npx eaa-kit init # write an eaa.config.json
30
- npx eaa-kit statement # accessibility statement, in one of seven countries
42
+ npx eaa-kit init # the config, a baseline and a CI workflow
43
+ npx eaa-kit statement # accessibility statement, in one of fifteen countries
44
+ npx eaa-kit countries # which ones, in which languages, under which law
31
45
  npx eaa-kit checklist # the manual review no engine can do for you
32
46
  ```
33
47
 
@@ -72,7 +86,7 @@ listing the barriers a real audit found.
72
86
 
73
87
  ```bash
74
88
  eaa-kit statement --output src/content/a11y.md
75
- eaa-kit statement --country FR --lang fr # or ES, IT, NL, AT, DE, CH
89
+ eaa-kit statement --country PL --lang pl # eaa-kit countries lists all fifteen
76
90
  ```
77
91
 
78
92
  Each country's statement is a document under its own law rather than a translation of
@@ -130,6 +144,14 @@ your site.
130
144
  **Says what it did not measure.** A crawl that stopped at its page limit, or could not
131
145
  fetch forty URLs, no longer produces a report that looks like a complete one.
132
146
 
147
+ **Keeps up while you work.** `--watch` audits again every time the build changes. Because
148
+ of the cache below, only the pages you touched are audited again, so the report is ready
149
+ by the time you switch windows.
150
+
151
+ ```bash
152
+ eaa-kit audit ./dist --watch
153
+ ```
154
+
133
155
  **Audits only what changed.** A page whose markup is byte-identical to the last run's keeps
134
156
  the result it already had, and a run with nothing to re-audit never loads an engine —
135
157
  twenty pages in ~230 ms instead of ~2,520 ms, which is about what starting the process
@@ -182,7 +204,7 @@ eaa-kit audit --url https://preview.example.com --basic-auth user:password
182
204
  | --- | --- |
183
205
  | [Auditing a build](docs/audit.md) | The `audit` command, both engines, exit codes, and what an automated run can and cannot tell you |
184
206
  | [Defaults from eaa.config](docs/audit.md#defaults-from-eaaconfig) | Writing the flags down once, and what still overrides them |
185
- | [The statement command](docs/statement.md) | The config file, the seven countries, and filling a statement from audit results |
207
+ | [The statement command](docs/statement.md) | The config file, the fifteen countries, and filling a statement from audit results |
186
208
  | [Baselines](docs/baseline.md) | Adopting the tool on a site that already has violations |
187
209
  | [Comparing two runs](docs/reports.md#comparing-two-runs) | The `diff` command, and what it refuses to call fixed |
188
210
  | [Coverage of WCAG](docs/audit.md#how-much-of-wcag-a-run-reaches) | What an automated engine can reach at all, and what it cannot |
@@ -1,4 +1,4 @@
1
- import { n as auditBuild, t as BuildAuditError } from "../run-DrS0Komf.js";
1
+ import { n as auditBuild, t as BuildAuditError } from "../run-DzVEOkiF.js";
2
2
  import { fileURLToPath } from "node:url";
3
3
  //#region src/astro/index.ts
4
4
  var AstroAuditError = class extends Error {
@@ -0,0 +1,2 @@
1
+ import { n as runAuditCommand } from "./audit-J2jeLo-y.js";
2
+ export { runAuditCommand };
@@ -2,14 +2,13 @@ import { a as impactLabel, i as countAtOrAbove, r as byImpactThenRule } from "./
2
2
  import { n as count, o as plural, t as collapse } from "./text-BF1LHMiV.js";
3
3
  import { t as TOOL_VERSION } from "./version-B3v4rNoG.js";
4
4
  import { n as DEFAULT_TAGS, u as runEngine } from "./result-B7_zVxAX.js";
5
- import { a as emitDocument, c as runEngine$1, l as warn, o as fail, s as note, t as advise } from "./command-3r4fht5f.js";
6
- import { l as reviewSentence } from "./review-CdMK2GpQ.js";
7
- import { a as isShared, i as groupIssues, l as reusedPart, n as blindRules, o as issueTotals, r as coverageParts, t as remediationFor, u as runCompleteness } from "./remediation-C0klJblu.js";
5
+ import { a as emitDocument, d as warn, l as note, o as fail, s as failWith, t as advise, u as runEngine$1 } from "./command-BGGMf4vn.js";
6
+ import { l as reviewSentence } from "./review-Bz0fO9_I.js";
7
+ import { a as isShared, d as runCompleteness, i as groupIssues, n as blindRules, o as issueTotals, r as coverageParts, t as remediationFor, u as reusedPart } from "./remediation-Bbs4KcX1.js";
8
8
  import { r as componentPath } from "./component-ChisoFyY.js";
9
- import { a as manualCheckFor, n as coverageSummary, o as understandingUrl, r as reviewSummary, t as buildCoverage } from "./coverage-cb5kPp48.js";
10
- import { n as buildSummary } from "./json-Bus6YhxB.js";
11
- import { i as holdsHtml, n as collectPages, r as emptyDirectoryHint, t as BuildDirectoryError } from "./collect-Cu1q9NTB.js";
12
- import path from "node:path";
9
+ import { a as manualCheckFor, n as coverageSummary, o as understandingUrl, r as reviewSummary, t as buildCoverage } from "./coverage-zdzgSKjz.js";
10
+ import { n as buildSummary } from "./json-SGCgxSPT.js";
11
+ import { t as resolvePages } from "./pages-DxY5Z0gl.js";
13
12
  import pc from "picocolors";
14
13
  //#region src/audit/report/console.ts
15
14
  const DEFAULT_MAX_NODES = 3;
@@ -278,6 +277,15 @@ function completenessLines(ctx) {
278
277
  if (completeness === void 0) return [];
279
278
  const reused = reusedPart(completeness);
280
279
  const lines = reused === void 0 ? [] : [line(ctx, ` ${reused}`, ctx.c.dim)];
280
+ const redirect = completeness.entryRedirect;
281
+ if (redirect !== void 0) {
282
+ const why = {
283
+ "same-site": "same site",
284
+ flag: "--redirects follow",
285
+ prompt: "approved"
286
+ }[redirect.followedBecause];
287
+ lines.unshift(line(ctx, ` Redirected (${redirect.statuses.join(" → ")}, ${why}):`, ctx.c.yellow), line(ctx, ` from ${redirect.requested}`, ctx.c.yellow), line(ctx, ` to ${redirect.auditedFrom}`, ctx.c.yellow), line(ctx, " Everything below is about the second address.", ctx.c.dim));
288
+ }
281
289
  if (completeness.complete) return lines;
282
290
  if (completeness.unreachable.length > 0) {
283
291
  const noun = plural(completeness.unreachable.length, "page");
@@ -445,187 +453,6 @@ function wrap(text, width) {
445
453
  return lines;
446
454
  }
447
455
  //#endregion
448
- //#region src/cli/pages.ts
449
- /**
450
- * Collect the pages to audit, reporting to stderr on the way.
451
- *
452
- * Returns undefined when there is nothing to audit, having already explained
453
- * why. Every caller turns that into exit 2 — a run that reached no verdict,
454
- * which is not the same as a clean one.
455
- */
456
- async function resolvePages(directory, options = {}) {
457
- if (directory === void 0 && options.url === void 0) return resolveAutomatically(options);
458
- if (options.url !== void 0) {
459
- const crawled = await crawlPages(options.url, options);
460
- if (!crawled) return void 0;
461
- if (crawled.pages.length === 0) {
462
- warn(`No pages could be fetched from ${options.url}`);
463
- return;
464
- }
465
- return {
466
- pages: crawled.pages,
467
- origin: crawled.origin,
468
- label: options.url,
469
- completeness: crawled.completeness
470
- };
471
- }
472
- const cwd = options.cwd ?? process.cwd();
473
- const shown = options.label ?? directory;
474
- const unreachable = [];
475
- let pages;
476
- try {
477
- pages = await collectPages(directory, {
478
- ...options.include ? { include: options.include } : {},
479
- ...options.exclude ? { exclude: options.exclude } : {},
480
- onUnreadable: (relativePath, reason) => unreachable.push({
481
- location: relativePath,
482
- reason
483
- })
484
- });
485
- } catch (cause) {
486
- if (!(cause instanceof BuildDirectoryError)) throw cause;
487
- fail(cause.message);
488
- note(await emptyDirectoryHint(shown, cwd));
489
- return;
490
- }
491
- if (pages.length === 0) {
492
- if ((options.include !== void 0 || options.exclude !== void 0) && await holdsHtml(directory)) {
493
- warn(`No page in ${shown} matched the filters, so nothing was audited.`);
494
- if (options.include !== void 0) note(` --include ${options.include.join(" ")}`);
495
- if (options.exclude !== void 0) note(` --exclude ${options.exclude.join(" ")}`);
496
- note(" Patterns are relative to the audited directory, with POSIX separators.");
497
- return;
498
- }
499
- warn(await emptyDirectoryHint(shown, cwd));
500
- return;
501
- }
502
- warnUnmeasured(unreachable, "file", "readable");
503
- return {
504
- pages,
505
- directory,
506
- label: shown,
507
- completeness: {
508
- discovery: "directory",
509
- collected: pages.length,
510
- unreachable,
511
- truncated: false
512
- }
513
- };
514
- }
515
- /**
516
- * Name what was missed, up to ten of them, and count the rest.
517
- *
518
- * Both collectors need this and neither may skip it: a file that could not be
519
- * read and a URL that could not be fetched are pages with no verdict, and a run
520
- * that mentioned neither would report the rest of the site as though it were
521
- * the site. Ten because the point is to make the problem recognisable, and two
522
- * hundred failures usually have the one reason the first few show — the count
523
- * that follows is what says the list was cut.
524
- */
525
- function warnUnmeasured(missed, noun, reached) {
526
- if (missed.length === 0) return;
527
- warn(`${count(missed.length, noun)} ${missed.length === 1 ? "was" : "were"} not ${reached}, and so not audited:`);
528
- for (const item of missed.slice(0, 10)) note(` ${item.location} — ${item.reason}`);
529
- if (missed.length > 10) note(` …and ${missed.length - 10} more`);
530
- }
531
- /**
532
- * Fetch the pages of a running site, reporting what happened on the way.
533
- *
534
- * Returns undefined when the crawl could not start, which the caller turns into
535
- * exit 2 — a run that reached no verdict, not a clean one.
536
- */
537
- async function crawlPages(url, options) {
538
- const { collapsedOnto, crawlSite, CrawlError, parseEntryUrl } = await import("./crawl-BHkJmUkA.js");
539
- let entry;
540
- try {
541
- entry = parseEntryUrl(url, options.allowRemote ?? false);
542
- } catch (cause) {
543
- if (cause instanceof CrawlError) {
544
- fail(cause.message);
545
- return;
546
- }
547
- throw cause;
548
- }
549
- note(`Crawling ${entry.origin}…`);
550
- const result = await crawlSite(entry, {
551
- ...options.allowRemote ? { allowRemote: true } : {},
552
- ...options.ignoreRobots ? { ignoreRobots: true } : {},
553
- ...options.sitemap === void 0 ? {} : { sitemap: options.sitemap },
554
- ...options.maxPages === void 0 ? {} : { maxPages: options.maxPages },
555
- ...options.maxDepth === void 0 ? {} : { maxDepth: options.maxDepth },
556
- ...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs },
557
- ...options.headers === void 0 ? {} : { headers: options.headers }
558
- });
559
- if (result.pages.length === 0 && result.failures.length > 0) {
560
- fail(`Could not fetch ${entry.href} (${result.failures[0]?.reason})`);
561
- note(" Is the site running at that address?");
562
- return;
563
- }
564
- const found = result.discovery === "sitemap" ? "sitemap.xml and links" : "links";
565
- note(`Found ${count(result.pages.length, "page")} from ${found}`);
566
- const failed = result.failures.map((failure) => ({
567
- location: failure.url,
568
- reason: failure.reason
569
- }));
570
- warnUnmeasured(failed, "URL", "fetched");
571
- if (result.truncated) warn(`Stopped at ${count(result.pages.length, "page")}; the site has more. Raise --max-pages to go further.`);
572
- const collapsed = collapsedOnto(result);
573
- if (collapsed.length > 0) {
574
- const landedOn = collapsed[0]?.landedOn ?? "";
575
- warn(`Every page requested answered at ${landedOn}, which is not where it was asked.`);
576
- note(" A sign-in page in front of the site looks like this.");
577
- note(" If it is behind one, pass --basic-auth user:password or --header \"Cookie: …\".");
578
- }
579
- return {
580
- pages: result.pages,
581
- origin: result.origin,
582
- completeness: {
583
- discovery: result.discovery,
584
- collected: result.pages.length,
585
- unreachable: [...failed, ...collapsed.map((redirect) => ({
586
- location: redirect.requested,
587
- reason: `answered at ${redirect.landedOn} instead, so this page was not audited`
588
- }))],
589
- truncated: result.truncated
590
- }
591
- };
592
- }
593
- /**
594
- * No directory and no URL: work out what this project needs.
595
- *
596
- * The point is that `eaa-kit audit` on its own does something useful. Anything
597
- * this starts is handed back as `cleanup` so the caller can stop it once the
598
- * report is written.
599
- */
600
- async function resolveAutomatically(options) {
601
- const cwd = options.cwd ?? process.cwd();
602
- const { autoDetectSource } = await import("./project-MFrXcw1M.js");
603
- const detected = await autoDetectSource(cwd, {
604
- ...options.noBuild ? { noBuild: true } : {},
605
- onStep: note
606
- });
607
- if (detected?.directory !== void 0) return resolvePages(detected.directory, {
608
- ...options,
609
- label: path.relative(cwd, detected.directory) || "."
610
- });
611
- if (detected?.url !== void 0) {
612
- const resolved = await resolvePages(void 0, {
613
- ...options,
614
- url: detected.url
615
- });
616
- if (resolved === void 0) {
617
- await detected.cleanup?.();
618
- return;
619
- }
620
- return {
621
- ...resolved,
622
- ...detected.cleanup ? { cleanup: detected.cleanup } : {}
623
- };
624
- }
625
- await detected?.cleanup?.();
626
- warn(await emptyDirectoryHint("./dist", cwd));
627
- }
628
- //#endregion
629
456
  //#region src/cli/audit.ts
630
457
  const OUTPUT_FORMATS = [
631
458
  "console",
@@ -647,6 +474,7 @@ async function runAuditCommand(dir, options = {}) {
647
474
  exitCode: 2
648
475
  };
649
476
  const { pages, origin, label, cleanup, directory, completeness: collection } = resolved;
477
+ const found = directory === void 0 ? {} : { directory };
650
478
  if (options.headers !== void 0 && directory !== void 0 && !options.browser) warn("--header and --basic-auth apply to pages that are fetched; this run read files.");
651
479
  try {
652
480
  const baseUrl = options.baseUrl ?? origin;
@@ -665,6 +493,7 @@ async function runAuditCommand(dir, options = {}) {
665
493
  });
666
494
  if (!fresh) return {
667
495
  audits: [],
496
+ ...found,
668
497
  exitCode: 2
669
498
  };
670
499
  for (const [index, page] of misses.entries()) {
@@ -678,6 +507,7 @@ async function runAuditCommand(dir, options = {}) {
678
507
  const applied = await acceptBaseline(audits, options);
679
508
  if (!applied) return {
680
509
  audits,
510
+ ...found,
681
511
  exitCode: 2
682
512
  };
683
513
  audits = applied;
@@ -686,6 +516,7 @@ async function runAuditCommand(dir, options = {}) {
686
516
  const review = await loadReview(options);
687
517
  if (review === FAILED) return {
688
518
  audits,
519
+ ...found,
689
520
  exitCode: 2
690
521
  };
691
522
  await emit(audits, label, failOn, completeness, options, review);
@@ -694,11 +525,13 @@ async function runAuditCommand(dir, options = {}) {
694
525
  fail(`${unaudited.length} of ${audits.length} pages could not be audited`);
695
526
  return {
696
527
  audits,
528
+ ...found,
697
529
  exitCode: 2
698
530
  };
699
531
  }
700
532
  return {
701
533
  audits,
534
+ ...found,
702
535
  exitCode: countAtOrAbove(audits, failOn) > 0 ? 1 : 0
703
536
  };
704
537
  } finally {
@@ -775,7 +608,7 @@ function inCollectedOrder(pages, audits) {
775
608
  * would be as wrong as silently passing.
776
609
  */
777
610
  async function acceptBaseline(audits, options) {
778
- const { applyBaseline, BaselineError, readBaseline } = await import("./baseline-rtnj3RHB.js");
611
+ const { applyBaseline, BaselineError, readBaseline } = await import("./baseline-477B1CZ_.js");
779
612
  try {
780
613
  const outcome = applyBaseline(audits, await readBaseline(options.baseline, options.cwd ?? process.cwd()));
781
614
  if (outcome.accepted > 0) note(`Baseline accepted ${outcome.accepted} violating elements`);
@@ -787,7 +620,7 @@ async function acceptBaseline(audits, options) {
787
620
  return outcome.audits;
788
621
  } catch (cause) {
789
622
  if (cause instanceof BaselineError) {
790
- fail(cause.message);
623
+ failWith(cause);
791
624
  return;
792
625
  }
793
626
  throw cause;
@@ -803,7 +636,7 @@ const FAILED = Symbol("review-failed");
803
636
  */
804
637
  async function loadReview(options) {
805
638
  if (options.review === void 0) return void 0;
806
- const { answeredCount, readReview, ReviewError } = await import("./review-DIbOTmOM.js");
639
+ const { answeredCount, readReview, ReviewError } = await import("./review-a-2ghjQ5.js");
807
640
  try {
808
641
  const record = await readReview(options.review, options.cwd ?? process.cwd());
809
642
  note(`Review record: ${count(answeredCount(record), "criterion")} answered`);
@@ -813,7 +646,7 @@ async function loadReview(options) {
813
646
  };
814
647
  } catch (cause) {
815
648
  if (cause instanceof ReviewError) {
816
- fail(cause.message);
649
+ failWith(cause);
817
650
  return FAILED;
818
651
  }
819
652
  throw cause;
@@ -846,11 +679,18 @@ async function emit(audits, dir, failOn, completeness, options, review) {
846
679
  const body = await render(audits, dir, failOn, completeness, typeof options.output === "string", options, review);
847
680
  await emitDocument(body, options.output, options.cwd ?? process.cwd());
848
681
  if (options.output !== void 0) note(`Report written to ${options.output}`);
682
+ if (options.htmlReport !== void 0) {
683
+ const html = await render(audits, dir, failOn, completeness, true, {
684
+ ...options,
685
+ format: "html"
686
+ }, review);
687
+ await emitDocument(html, options.htmlReport, options.cwd ?? process.cwd());
688
+ }
849
689
  }
850
690
  async function render(audits, dir, failOn, completeness, toFile, options, review) {
851
691
  switch (options.format ?? "console") {
852
692
  case "json": {
853
- const { buildJsonReport, serialiseJsonReport } = await import("./json-CrQmoTj6.js");
693
+ const { buildJsonReport, serialiseJsonReport } = await import("./json-CyLmvF5P.js");
854
694
  return serialiseJsonReport(buildJsonReport(audits, {
855
695
  directory: dir,
856
696
  ...options.url === void 0 ? {} : { sourceKind: "url" },
@@ -861,7 +701,7 @@ async function render(audits, dir, failOn, completeness, toFile, options, review
861
701
  }));
862
702
  }
863
703
  case "sarif": {
864
- const { buildSarifReport, serialiseSarifReport } = await import("./sarif-BNCE0PNT.js");
704
+ const { buildSarifReport, serialiseSarifReport } = await import("./sarif-9BAgNiOa.js");
865
705
  return serialiseSarifReport(buildSarifReport(audits, {
866
706
  directory: dir,
867
707
  completeness,
@@ -869,7 +709,7 @@ async function render(audits, dir, failOn, completeness, toFile, options, review
869
709
  }));
870
710
  }
871
711
  case "html": {
872
- const { buildHtmlReport } = await import("./html-BIxxF3FC.js");
712
+ const { buildHtmlReport } = await import("./html-whingnfj.js");
873
713
  return buildHtmlReport(audits, {
874
714
  ...await fromTheProject(audits, options),
875
715
  directory: dir,
@@ -903,7 +743,7 @@ async function render(audits, dir, failOn, completeness, toFile, options, review
903
743
  async function fromTheProject(audits, options) {
904
744
  const cwd = options.cwd ?? process.cwd();
905
745
  const { detectFramework } = await import("./frameworks-etFg_O8K.js");
906
- const { readPackageJson } = await import("./project-MFrXcw1M.js");
746
+ const { readPackageJson } = await import("./project-BLFdCbOq.js");
907
747
  const detected = await detectFramework(cwd, await readPackageJson(cwd));
908
748
  return {
909
749
  ...await sourceLookups(cwd, audits),
@@ -916,7 +756,7 @@ async function fromTheProject(audits, options) {
916
756
  * report it always got, with no source named.
917
757
  */
918
758
  async function sourceLookups(cwd, audits) {
919
- const { buildRouteMap, sourceFor } = await import("./routes-CmdRUuOs.js");
759
+ const { buildRouteMap, sourceFor } = await import("./routes-CSctpS1P.js");
920
760
  const routes = await buildRouteMap(cwd);
921
761
  if (!hasElementsToAttribute(audits)) return {
922
762
  sourceFor: (page) => sourceFor(routes, page),
@@ -934,4 +774,4 @@ function hasElementsToAttribute(audits) {
934
774
  return audits.some((audit) => audit.violations.length > 0 || (audit.accepted?.length ?? 0) > 0);
935
775
  }
936
776
  //#endregion
937
- export { runAuditCommand as n, resolvePages as r, OUTPUT_FORMATS as t };
777
+ export { runAuditCommand as n, OUTPUT_FORMATS as t };
@@ -1,2 +1,2 @@
1
- import { o as readBaseline, r as applyBaseline, t as BaselineError } from "./baseline-BpE7DbDq.js";
1
+ import { o as readBaseline, r as applyBaseline, t as BaselineError } from "./baseline-DrFh7joZ.js";
2
2
  export { BaselineError, applyBaseline, readBaseline };
@@ -0,0 +1,2 @@
1
+ import { t as runBaselineCommand } from "./baseline-wyJsSIFQ.js";
2
+ export { runBaselineCommand };
@@ -29,7 +29,12 @@ const baselineSchema = object({
29
29
  entries: withDefault(array(entrySchema), () => [])
30
30
  });
31
31
  var BaselineError = class extends Error {
32
+ next;
32
33
  name = "BaselineError";
34
+ constructor(message, next) {
35
+ super(message);
36
+ this.next = next;
37
+ }
33
38
  };
34
39
  /**
35
40
  * Move the violations a baseline accounts for out of the failing set.
@@ -154,7 +159,10 @@ async function readBaseline(file, cwd = process.cwd()) {
154
159
  try {
155
160
  raw = await readFile(target, "utf8");
156
161
  } catch {
157
- throw new BaselineError(`Could not read the baseline at ${file}. Create one with: eaa-kit baseline`);
162
+ throw new BaselineError(`Could not read the baseline at ${file}`, {
163
+ command: `eaa-kit baseline --output ${file}`,
164
+ why: "record what the build has today"
165
+ });
158
166
  }
159
167
  let value;
160
168
  try {
@@ -167,8 +175,11 @@ async function readBaseline(file, cwd = process.cwd()) {
167
175
  const issues = result.error.issues.map((issue) => `${issue.path.join(".") || "document"}: ${issue.message}`).slice(0, 5);
168
176
  throw new BaselineError(`${path.basename(target)} is not an eaa-kit baseline (${issues.join("; ")})`);
169
177
  }
170
- if (result.data.schemaVersion !== 2) throw new BaselineError(`${path.basename(target)} has schemaVersion ${result.data.schemaVersion}; this version of eaa-kit reads 2.\n Record it again on the current build: eaa-kit baseline\n Read the new file before committing it: it lists what this run found, which is
171
- not necessarily what the old one accepted.`);
178
+ if (result.data.schemaVersion !== 2) throw new BaselineError(`${path.basename(target)} has schemaVersion ${result.data.schemaVersion}; this version of eaa-kit reads 2.\n Read the new file before committing it: it lists what this run found, which is
179
+ not necessarily what the old one accepted.`, {
180
+ command: `eaa-kit baseline --output ${file}`,
181
+ why: "record it again on the current build"
182
+ });
172
183
  return result.data;
173
184
  }
174
185
  async function writeBaseline(file, baseline, cwd = process.cwd()) {
@@ -0,0 +1,127 @@
1
+ import { n as count } from "./text-BF1LHMiV.js";
2
+ import { a as pruneBaseline, c as writeBaseline, i as buildBaseline, o as readBaseline, r as applyBaseline, t as BaselineError } from "./baseline-DrFh7joZ.js";
3
+ import { l as note, o as fail, s as failWith, t as advise, u as runEngine } from "./command-BGGMf4vn.js";
4
+ import { t as resolvePages } from "./pages-DxY5Z0gl.js";
5
+ import path from "node:path";
6
+ //#region src/cli/baseline.ts
7
+ /**
8
+ * `eaa-kit baseline [dir]`.
9
+ *
10
+ * Runs the same audit the audit command runs and writes down every violation it
11
+ * found, so that a later run can fail on what is new instead of on everything.
12
+ *
13
+ * Deliberately a subcommand rather than a flag on `audit`. Accepting a set of
14
+ * violations is a decision somebody makes once and commits to a file others
15
+ * will read; folding it into the command that checks them would make it far too
16
+ * easy to type by reflex when a build goes red, which is precisely the moment
17
+ * it should take a deliberate act.
18
+ */
19
+ async function runBaselineCommand(dir, options = {}) {
20
+ const cwd = options.cwd ?? process.cwd();
21
+ const resolved = await resolvePages(path.resolve(cwd, dir), {
22
+ ...options,
23
+ label: dir
24
+ });
25
+ if (!resolved) return {
26
+ entries: 0,
27
+ exitCode: 2
28
+ };
29
+ const { pages, origin, label, directory } = resolved;
30
+ note(`Auditing ${count(pages.length, "page")} in ${label}…`);
31
+ const baseUrl = options.baseUrl ?? origin;
32
+ const audits = await runEngine(pages, {
33
+ cwd,
34
+ ...options.headers === void 0 ? {} : { headers: options.headers },
35
+ ...baseUrl === void 0 ? {} : { baseUrl },
36
+ ...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs },
37
+ ...options.browser ? { browser: true } : {},
38
+ ...options.concurrency === void 0 ? {} : { concurrency: options.concurrency },
39
+ ...directory === void 0 ? {} : { directory }
40
+ });
41
+ if (!audits) return {
42
+ entries: 0,
43
+ exitCode: 2
44
+ };
45
+ const unaudited = audits.filter((audit) => audit.error);
46
+ if (unaudited.length > 0) {
47
+ fail(`${unaudited.length} of ${audits.length} pages could not be audited, so no baseline was written`);
48
+ return {
49
+ entries: 0,
50
+ exitCode: 2
51
+ };
52
+ }
53
+ const target = options.output ?? "eaa-baseline.json";
54
+ if (options.prune) return await prune(audits, target, cwd);
55
+ const baseline = buildBaseline(audits, {
56
+ ...options.note ? { note: options.note } : {},
57
+ ...options.expiresOn ? { expiresOn: options.expiresOn } : {}
58
+ });
59
+ try {
60
+ await writeBaseline(target, baseline, cwd);
61
+ } catch (cause) {
62
+ if (cause instanceof BaselineError) {
63
+ failWith(cause);
64
+ return {
65
+ entries: 0,
66
+ exitCode: 2
67
+ };
68
+ }
69
+ throw cause;
70
+ }
71
+ const entries = baseline.entries.length;
72
+ note(`Wrote ${count(entries, "entry")} to ${target}`);
73
+ if (entries > 0) advise("These are barriers, not exceptions. Commit the file, then work the list down.");
74
+ return {
75
+ entries,
76
+ exitCode: 0
77
+ };
78
+ }
79
+ /**
80
+ * `--prune`: take out what this run shows is gone, and add nothing.
81
+ *
82
+ * The audit already tells anybody running it that entries no longer match and
83
+ * can be removed. Acting on that advice meant editing JSON by hand, entry by
84
+ * entry, against a file whose whole purpose is that nobody has to remember what
85
+ * is in it — so most people did not, and a baseline accumulated barriers that
86
+ * were fixed years ago while looking exactly like one that had not been read.
87
+ *
88
+ * Recording a new baseline is not the same operation and is not a substitute:
89
+ * it accepts whatever the site fails today, which on a bad day quietly adopts a
90
+ * barrier nobody agreed to.
91
+ */
92
+ async function prune(audits, target, cwd) {
93
+ let existing;
94
+ try {
95
+ existing = await readBaseline(target, cwd);
96
+ } catch (cause) {
97
+ if (cause instanceof BaselineError) {
98
+ failWith(cause);
99
+ return {
100
+ entries: 0,
101
+ exitCode: 2
102
+ };
103
+ }
104
+ throw cause;
105
+ }
106
+ const outcome = applyBaseline(audits, existing);
107
+ const { baseline, removed } = pruneBaseline(existing, outcome.stale);
108
+ if (removed.length === 0) {
109
+ note(`Nothing to remove from ${target}: every entry still matches something on this run`);
110
+ return {
111
+ entries: existing.entries.length,
112
+ removed: 0,
113
+ exitCode: 0
114
+ };
115
+ }
116
+ await writeBaseline(target, baseline, cwd);
117
+ note(`Removed ${count(removed.length, "entry")} from ${target}; ${count(baseline.entries.length, "entry")} left`);
118
+ for (const entry of removed) note(` ${entry.page} ${entry.ruleId}`);
119
+ if (outcome.expired.length > 0) advise(`${count(outcome.expired.length, "entry")} have expired and suppress nothing; --prune leaves them for you to decide about`);
120
+ return {
121
+ entries: baseline.entries.length,
122
+ removed: removed.length,
123
+ exitCode: 0
124
+ };
125
+ }
126
+ //#endregion
127
+ export { runBaselineCommand as t };
@@ -1,21 +1,21 @@
1
1
  import { n as count } from "./text-BF1LHMiV.js";
2
- import { a as emitDocument, o as fail, s as note } from "./command-3r4fht5f.js";
3
- import "./review-CdMK2GpQ.js";
2
+ import { a as emitDocument, l as note, s as failWith } from "./command-BGGMf4vn.js";
3
+ import "./review-Bz0fO9_I.js";
4
4
  import { access } from "node:fs/promises";
5
5
  import path from "node:path";
6
6
  //#region src/cli/checklist.ts
7
7
  async function runChecklistCommand(options = {}) {
8
8
  const cwd = options.cwd ?? process.cwd();
9
9
  const recordPath = options.record ?? "eaa-review.json";
10
- const { WCAG22_AA_CRITERIA } = await import("./coverage-n1X9CkiG.js");
11
- const { answeredCount, blankReview, readReview, ReviewError, writeReview } = await import("./review-DIbOTmOM.js");
10
+ const { WCAG22_AA_CRITERIA } = await import("./coverage-GvaMpV64.js");
11
+ const { answeredCount, blankReview, readReview, ReviewError, writeReview } = await import("./review-a-2ghjQ5.js");
12
12
  let existing;
13
13
  try {
14
14
  existing = await readReview(recordPath, cwd);
15
15
  } catch (cause) {
16
16
  if (!(cause instanceof ReviewError)) throw cause;
17
17
  if (await exists(path.resolve(cwd, recordPath))) {
18
- fail(cause.message);
18
+ failWith(cause);
19
19
  return { exitCode: 2 };
20
20
  }
21
21
  }
@@ -23,7 +23,7 @@ async function runChecklistCommand(options = {}) {
23
23
  if (options.reviewedBy !== void 0) record.reviewedBy = options.reviewedBy;
24
24
  await writeReview(recordPath, record, cwd);
25
25
  note(existing === void 0 ? `Review record written to ${recordPath}` : `Review record updated at ${recordPath}: ${count(answeredCount(record), "criterion")} already answered`);
26
- const { buildWorksheet } = await import("./worksheet-BIxMtbUd.js");
26
+ const { buildWorksheet } = await import("./worksheet-B_kQ1pxq.js");
27
27
  await emitDocument(buildWorksheet({
28
28
  recordPath,
29
29
  review: record