eaa-kit 0.6.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 (97) hide show
  1. package/README.md +52 -15
  2. package/dist/astro/index.d.ts +1 -1
  3. package/dist/astro/index.js +1 -1
  4. package/dist/audit/runners/worker.js +1 -1
  5. package/dist/audit-CJDCQaFY.js +2 -0
  6. package/dist/{audit-e_uixhPG.js → audit-J2jeLo-y.js} +170 -241
  7. package/dist/{baseline-BscHfFSW.js → baseline-477B1CZ_.js} +1 -1
  8. package/dist/baseline-D9ihb-wk.js +2 -0
  9. package/dist/{baseline-D2qWmUC6.js → baseline-DrFh7joZ.js} +15 -4
  10. package/dist/baseline-wyJsSIFQ.js +127 -0
  11. package/dist/cache-D4dOIuOi.js +219 -0
  12. package/dist/{checklist-BtgkxMEa.js → checklist-Gx2g3LFC.js} +6 -6
  13. package/dist/cli/index.js +103 -147
  14. package/dist/{collect-Cu1q9NTB.js → collect-BJYk7_pJ.js} +1 -1
  15. package/dist/{command-CZKp9Wi_.js → command-BGGMf4vn.js} +35 -8
  16. package/dist/countries-DRTBubeE.js +25 -0
  17. package/dist/countries-Dg0BdytB.js +156 -0
  18. package/dist/coverage-GvaMpV64.js +3 -0
  19. package/dist/{coverage-BD2_CYns.js → coverage-zdzgSKjz.js} +4 -286
  20. package/dist/{crawl-BHkJmUkA.js → crawl-DwdqiljK.js} +5 -3
  21. package/dist/criteria-CnPJKGeb.js +286 -0
  22. package/dist/{load-vZdV_fD1.js → define-Ctf2uOEh.js} +47 -95
  23. package/dist/eleventy/index.d.ts +1 -1
  24. package/dist/eleventy/index.js +1 -1
  25. package/dist/entry-CjqjrUBY.js +174 -0
  26. package/dist/{html-Bmh7X_sM.js → html-whingnfj.js} +9 -5
  27. package/dist/index.d.ts +61 -5
  28. package/dist/index.js +3 -2
  29. package/dist/init-CPbFVMuk.js +293 -0
  30. package/dist/jsdom-BUYuVJJm.js +3 -0
  31. package/dist/{jsdom-CQar6OQS.js → jsdom-CsW_xVcA.js} +11 -12
  32. package/dist/{json-HJDgJp09.js → json-CyLmvF5P.js} +1 -1
  33. package/dist/{json-PNg6BeXp.js → json-SGCgxSPT.js} +4 -3
  34. package/dist/load-CH-ltdlq.js +99 -0
  35. package/dist/load-D7lBeOsq.js +2 -0
  36. package/dist/nuxt/index.d.ts +1 -1
  37. package/dist/nuxt/index.js +1 -1
  38. package/dist/pages-DxY5Z0gl.js +300 -0
  39. package/dist/{playwright-C-miJP2b.js → playwright-ukCr_5o3.js} +1 -1
  40. package/dist/{pool-dkexq5xo.js → pool-B4tEUa2S.js} +6 -2
  41. package/dist/{project-MFrXcw1M.js → project-BLFdCbOq.js} +1 -1
  42. package/dist/{project-CzOnkLH6.js → project-v2PoRw70.js} +18 -1
  43. package/dist/{completeness-Dwq3CPB3.js → remediation-Bbs4KcX1.js} +72 -42
  44. package/dist/{render-CtsqR0k-.js → render-C6zYfaba.js} +69 -7
  45. package/dist/{result-DfUru6y_.js → result-B7_zVxAX.js} +1 -1
  46. package/dist/result-CRmjjoAA.js +2 -0
  47. package/dist/{review-CdMK2GpQ.js → review-Bz0fO9_I.js} +9 -1
  48. package/dist/{review-DIbOTmOM.js → review-a-2ghjQ5.js} +1 -1
  49. package/dist/{routes-CmdRUuOs.js → routes-CSctpS1P.js} +1 -1
  50. package/dist/{run-YiqyQA2b.d.ts → run-BK2blxMI.d.ts} +8 -0
  51. package/dist/{run-D7hdVXLA.js → run-DzVEOkiF.js} +6 -2
  52. package/dist/{sarif-BKvq_AUm.js → sarif-9BAgNiOa.js} +5 -3
  53. package/dist/site-BHMtf3q2.js +72 -0
  54. package/dist/start-DzOM0p6I.js +101 -0
  55. package/dist/statement/templates/at.de.md +14 -0
  56. package/dist/statement/templates/at.en.md +14 -0
  57. package/dist/statement/templates/be.de.md +148 -0
  58. package/dist/statement/templates/be.en.md +142 -0
  59. package/dist/statement/templates/be.fr.md +146 -0
  60. package/dist/statement/templates/be.nl.md +147 -0
  61. package/dist/statement/templates/ch.de.md +14 -0
  62. package/dist/statement/templates/ch.en.md +14 -0
  63. package/dist/statement/templates/cz.cs.md +137 -0
  64. package/dist/statement/templates/cz.en.md +139 -0
  65. package/dist/statement/templates/de.de.md +14 -0
  66. package/dist/statement/templates/de.en.md +14 -0
  67. package/dist/statement/templates/dk.da.md +141 -0
  68. package/dist/statement/templates/dk.en.md +141 -0
  69. package/dist/statement/templates/es.en.md +14 -0
  70. package/dist/statement/templates/es.es.md +15 -0
  71. package/dist/statement/templates/fi.en.md +139 -0
  72. package/dist/statement/templates/fi.fi.md +141 -0
  73. package/dist/statement/templates/fr.en.md +14 -0
  74. package/dist/statement/templates/fr.fr.md +15 -0
  75. package/dist/statement/templates/ie.en.md +144 -0
  76. package/dist/statement/templates/it.en.md +14 -0
  77. package/dist/statement/templates/it.it.md +15 -0
  78. package/dist/statement/templates/nl.en.md +14 -0
  79. package/dist/statement/templates/nl.nl.md +15 -0
  80. package/dist/statement/templates/pl.en.md +143 -0
  81. package/dist/statement/templates/pl.pl.md +144 -0
  82. package/dist/statement/templates/pt.en.md +142 -0
  83. package/dist/statement/templates/pt.pt.md +145 -0
  84. package/dist/statement/templates/se.en.md +139 -0
  85. package/dist/statement/templates/se.sv.md +142 -0
  86. package/dist/vite/index.d.ts +1 -1
  87. package/dist/vite/index.js +1 -1
  88. package/dist/watch-B2RoUbo0.js +122 -0
  89. package/dist/webpack/index.d.ts +1 -1
  90. package/dist/webpack/index.js +1 -1
  91. package/dist/{worksheet-eUjwYLxC.js → worksheet-B_kQ1pxq.js} +3 -2
  92. package/package.json +4 -3
  93. package/dist/audit-DK2StT1_.js +0 -2
  94. package/dist/coverage-7bQqWNfN.js +0 -2
  95. package/dist/init-BjKYttxc.js +0 -119
  96. package/dist/jsdom-DMvU2h-f.js +0 -3
  97. package/dist/load-Bc_xDGAh.js +0 -2
package/dist/cli/index.js CHANGED
@@ -1,142 +1,29 @@
1
1
  #!/usr/bin/env node
2
2
  import { c as meetsThreshold, n as IMPACT_LEVELS, o as impactRank, s as isImpactLevel, t as DEFAULT_FAIL_ON } from "../impact-luGCnN8F.js";
3
3
  import { c as nullable, d as optional, h as string, l as number, m as safeParse, n as boolean, p as record, t as array, u as object, y as withDefault } from "../schema-DJSF4K05.js";
4
- import { c as ConfigError, i as loadConfig, s as COUNTRIES, u as STATEMENT_LOCALES } from "../load-vZdV_fD1.js";
5
- import { c as StatementError, i as readAuditReport, o as checkStatementEvidence, s as refuses, t as renderStatement } from "../render-CtsqR0k-.js";
4
+ import { i as ConfigError, o as REDIRECT_MODES, r as COUNTRIES, s as STATEMENT_LOCALES } from "../define-Ctf2uOEh.js";
5
+ import { i as loadConfig } from "../load-CH-ltdlq.js";
6
+ import { c as StatementError, i as readAuditReport, o as checkStatementEvidence, s as refuses, t as renderStatement } from "../render-C6zYfaba.js";
6
7
  import { n as count, t as collapse } from "../text-BF1LHMiV.js";
7
8
  import { t as TOOL_VERSION } from "../version-B3v4rNoG.js";
8
9
  import { t as elementFingerprint } from "../fingerprint-BjYV_0F7.js";
9
- import { a as pruneBaseline, c as writeBaseline, i as buildBaseline, n as DEFAULT_BASELINE_FILE, o as readBaseline, r as applyBaseline, t as BaselineError } from "../baseline-D2qWmUC6.js";
10
- import { a as emitDocument, c as runEngine, d as parseHeader, i as baselineInvocation, l as warn, n as auditDefaults, o as fail, r as auditInvocation, s as note, t as advise, u as basicAuth } from "../command-CZKp9Wi_.js";
11
- import { t as DEFAULT_REVIEW_FILE } from "../review-CdMK2GpQ.js";
12
- import { n as runAuditCommand, r as resolvePages, t as OUTPUT_FORMATS } from "../audit-e_uixhPG.js";
10
+ import { n as DEFAULT_BASELINE_FILE } from "../baseline-DrFh7joZ.js";
11
+ import { a as emitDocument, c as nextStep, d as warn, f as basicAuth, i as baselineInvocation, l as note, n as auditDefaults, o as fail, p as parseHeader, r as auditInvocation, s as failWith, t as advise } from "../command-BGGMf4vn.js";
12
+ import { t as DEFAULT_REVIEW_FILE } from "../review-Bz0fO9_I.js";
13
+ import { n as runAuditCommand, t as OUTPUT_FORMATS } from "../audit-J2jeLo-y.js";
14
+ import { t as runBaselineCommand } from "../baseline-wyJsSIFQ.js";
13
15
  import { enableCompileCache } from "node:module";
14
16
  import { readFile } from "node:fs/promises";
15
17
  import path from "node:path";
16
18
  import { Command, InvalidArgumentError } from "commander";
17
19
  import pc from "picocolors";
18
- //#region src/cli/baseline.ts
19
- /**
20
- * `eaa-kit baseline [dir]`.
21
- *
22
- * Runs the same audit the audit command runs and writes down every violation it
23
- * found, so that a later run can fail on what is new instead of on everything.
24
- *
25
- * Deliberately a subcommand rather than a flag on `audit`. Accepting a set of
26
- * violations is a decision somebody makes once and commits to a file others
27
- * will read; folding it into the command that checks them would make it far too
28
- * easy to type by reflex when a build goes red, which is precisely the moment
29
- * it should take a deliberate act.
30
- */
31
- async function runBaselineCommand(dir, options = {}) {
32
- const cwd = options.cwd ?? process.cwd();
33
- const resolved = await resolvePages(path.resolve(cwd, dir), {
34
- ...options,
35
- label: dir
36
- });
37
- if (!resolved) return {
38
- entries: 0,
39
- exitCode: 2
40
- };
41
- const { pages, origin, label, directory } = resolved;
42
- note(`Auditing ${count(pages.length, "page")} in ${label}…`);
43
- const baseUrl = options.baseUrl ?? origin;
44
- const audits = await runEngine(pages, {
45
- cwd,
46
- ...options.headers === void 0 ? {} : { headers: options.headers },
47
- ...baseUrl === void 0 ? {} : { baseUrl },
48
- ...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs },
49
- ...options.browser ? { browser: true } : {},
50
- ...options.concurrency === void 0 ? {} : { concurrency: options.concurrency },
51
- ...directory === void 0 ? {} : { directory }
52
- });
53
- if (!audits) return {
54
- entries: 0,
55
- exitCode: 2
56
- };
57
- const unaudited = audits.filter((audit) => audit.error);
58
- if (unaudited.length > 0) {
59
- fail(`${unaudited.length} of ${audits.length} pages could not be audited, so no baseline was written`);
60
- return {
61
- entries: 0,
62
- exitCode: 2
63
- };
64
- }
65
- const target = options.output ?? "eaa-baseline.json";
66
- if (options.prune) return await prune(audits, target, cwd);
67
- const baseline = buildBaseline(audits, {
68
- ...options.note ? { note: options.note } : {},
69
- ...options.expiresOn ? { expiresOn: options.expiresOn } : {}
70
- });
71
- try {
72
- await writeBaseline(target, baseline, cwd);
73
- } catch (cause) {
74
- if (cause instanceof BaselineError) {
75
- fail(cause.message);
76
- return {
77
- entries: 0,
78
- exitCode: 2
79
- };
80
- }
81
- throw cause;
82
- }
83
- const entries = baseline.entries.length;
84
- note(`Wrote ${count(entries, "entry")} to ${target}`);
85
- if (entries > 0) advise("These are barriers, not exceptions. Commit the file, then work the list down.");
86
- return {
87
- entries,
88
- exitCode: 0
89
- };
90
- }
91
- /**
92
- * `--prune`: take out what this run shows is gone, and add nothing.
93
- *
94
- * The audit already tells anybody running it that entries no longer match and
95
- * can be removed. Acting on that advice meant editing JSON by hand, entry by
96
- * entry, against a file whose whole purpose is that nobody has to remember what
97
- * is in it — so most people did not, and a baseline accumulated barriers that
98
- * were fixed years ago while looking exactly like one that had not been read.
99
- *
100
- * Recording a new baseline is not the same operation and is not a substitute:
101
- * it accepts whatever the site fails today, which on a bad day quietly adopts a
102
- * barrier nobody agreed to.
103
- */
104
- async function prune(audits, target, cwd) {
105
- let existing;
106
- try {
107
- existing = await readBaseline(target, cwd);
108
- } catch (cause) {
109
- if (cause instanceof BaselineError) {
110
- fail(cause.message);
111
- return {
112
- entries: 0,
113
- exitCode: 2
114
- };
115
- }
116
- throw cause;
117
- }
118
- const outcome = applyBaseline(audits, existing);
119
- const { baseline, removed } = pruneBaseline(existing, outcome.stale);
120
- if (removed.length === 0) {
121
- note(`Nothing to remove from ${target}: every entry still matches something on this run`);
122
- return {
123
- entries: existing.entries.length,
124
- removed: 0,
125
- exitCode: 0
126
- };
127
- }
128
- await writeBaseline(target, baseline, cwd);
129
- note(`Removed ${count(removed.length, "entry")} from ${target}; ${count(baseline.entries.length, "entry")} left`);
130
- for (const entry of removed) note(` ${entry.page} ${entry.ruleId}`);
131
- if (outcome.expired.length > 0) advise(`${count(outcome.expired.length, "entry")} have expired and suppress nothing; --prune leaves them for you to decide about`);
132
- return {
133
- entries: baseline.entries.length,
134
- removed: removed.length,
135
- exitCode: 0
136
- };
137
- }
138
20
  var DiffError = class extends Error {
21
+ next;
139
22
  name = "DiffError";
23
+ constructor(message, next) {
24
+ super(message);
25
+ this.next = next;
26
+ }
140
27
  };
141
28
  /**
142
29
  * Only the fields a comparison reads. `completeness` is optional: a report
@@ -155,6 +42,8 @@ const reportSchema = object({
155
42
  pages: withDefault(array(object({
156
43
  path: string(),
157
44
  error: withDefault(nullable(string()), () => null),
45
+ /** Present when the later run reused this page rather than auditing it. */
46
+ reusedFrom: optional(string()),
158
47
  violations: withDefault(array(object({
159
48
  ruleId: string(),
160
49
  impact: withDefault(nullable(string()), () => null),
@@ -205,9 +94,22 @@ function entriesOf(report) {
205
94
  }
206
95
  return entries;
207
96
  }
208
- /** Pages a run reached a verdict on. A page that errored is not one of them. */
97
+ /**
98
+ * Pages a run reached a verdict on *itself*.
99
+ *
100
+ * A page that errored is not one of them, and neither is a page whose result
101
+ * was reused from a cache: this comparison exists to say what changed between
102
+ * two runs, and a run that did not look at a page learned nothing about it. The
103
+ * difference matters in one direction only, and it is the direction that lies —
104
+ * a violation present in the earlier report and absent from a reused page would
105
+ * otherwise be announced as fixed, which is a changelog of work nobody did.
106
+ *
107
+ * A report written before reuse existed carries no marker, and is read exactly
108
+ * as it was meant when it was written: those runs audited every page they
109
+ * listed.
110
+ */
209
111
  function auditedPages(report) {
210
- return new Set(report.pages.filter((page) => page.error === null).map((page) => page.path));
112
+ return new Set(report.pages.filter((page) => page.error === null && page.reusedFrom === void 0).map((page) => page.path));
211
113
  }
212
114
  function sideOf(report) {
213
115
  return {
@@ -260,7 +162,10 @@ async function readReport(file, cwd = process.cwd()) {
260
162
  try {
261
163
  raw = await readFile(target, "utf8");
262
164
  } catch {
263
- throw new DiffError(`Report not found: ${file}`);
165
+ throw new DiffError(`Report not found: ${file}`, {
166
+ command: `eaa-kit audit --format json --output ${file}`,
167
+ why: "write it from the build as it is now"
168
+ });
264
169
  }
265
170
  let parsed;
266
171
  try {
@@ -273,7 +178,10 @@ async function readReport(file, cwd = process.cwd()) {
273
178
  const first = result.error.issues[0];
274
179
  throw new DiffError(`${file} is not an eaa-kit JSON report${first === void 0 || first.path.length === 0 ? "" : ` at ${first.path.join(".")}`}: ${first?.message ?? "unrecognised shape"}`);
275
180
  }
276
- if (result.data.schemaVersion !== 2) throw new DiffError(`${file} is schemaVersion ${result.data.schemaVersion}; this version of eaa-kit reads 2.\n Write both reports with the same version of eaa-kit before comparing them.`);
181
+ if (result.data.schemaVersion !== 2) throw new DiffError(`${file} is schemaVersion ${result.data.schemaVersion}; this version of eaa-kit reads 2.\n Write both reports with the same version of eaa-kit before comparing them.`, {
182
+ command: `eaa-kit audit --format json --output ${file}`,
183
+ why: "write it again with this version"
184
+ });
277
185
  return result.data;
278
186
  }
279
187
  //#endregion
@@ -302,7 +210,7 @@ async function runDiffCommand(base, head, options = {}) {
302
210
  diff = diffReports(await readReport(base, cwd), await readReport(head, cwd));
303
211
  } catch (cause) {
304
212
  if (cause instanceof DiffError) {
305
- fail(cause.message);
213
+ failWith(cause);
306
214
  return { exitCode: 2 };
307
215
  }
308
216
  throw cause;
@@ -405,7 +313,7 @@ async function runStatementCommand(options = {}) {
405
313
  if (options.audit) audit = await readAuditReport(options.audit, options.cwd ?? process.cwd());
406
314
  let review;
407
315
  if (options.review) {
408
- const { readReview } = await import("../review-DIbOTmOM.js");
316
+ const { readReview } = await import("../review-a-2ghjQ5.js");
409
317
  review = await readReview(options.review, options.cwd ?? process.cwd());
410
318
  }
411
319
  const problems = checkStatementEvidence({
@@ -423,7 +331,8 @@ async function runStatementCommand(options = {}) {
423
331
  const statement = await renderStatement(config, {
424
332
  ...options.locale ? { locale: options.locale } : {},
425
333
  ...options.country ? { country: options.country } : {},
426
- ...audit ? { audit } : {}
334
+ ...audit ? { audit } : {},
335
+ ...review ? { review } : {}
427
336
  });
428
337
  note(`Statement for ${config.site.url} from ${path.basename(configPath)} (${statement.template}, ${format})`);
429
338
  if (audit) {
@@ -441,10 +350,11 @@ async function runStatementCommand(options = {}) {
441
350
  exitCode: 0
442
351
  };
443
352
  } catch (cause) {
444
- const { ReviewError } = await import("../review-DIbOTmOM.js");
353
+ const { ReviewError } = await import("../review-a-2ghjQ5.js");
445
354
  if (cause instanceof ConfigError || cause instanceof StatementError || cause instanceof ReviewError) {
446
355
  fail(cause.message);
447
356
  if (cause instanceof ConfigError) for (const issue of cause.issues) note(` ${issue}`);
357
+ if (cause.next !== void 0) nextStep(cause.next);
448
358
  return {
449
359
  document: "",
450
360
  format,
@@ -547,34 +457,61 @@ function parseBasicAuth(value) {
547
457
  }
548
458
  const program = new Command();
549
459
  program.exitOverride();
550
- program.name("eaa-kit").description("WCAG 2.2 AA auditor and EU accessibility statement generator for static sites.\nNot legal advice.").version(TOOL_VERSION, "-v, --version");
551
- program.command("audit").description("Audit built HTML against WCAG 2.2 AA").argument("[dir]", "directory holding the built site (default: found automatically)").option("--include <globs...>", "glob patterns to audit, relative to dir").option("--exclude <globs...>", "glob patterns to skip").option("--base-url <url>", "audit pages under their real site URL").option("--url <url>", "audit a running site instead of a build directory").option("--no-build", "never run the project build or start its server").option("--per-page", "also list every page and its result").option("--manual", "what to check by hand for the rules this engine cannot evaluate").option("--coverage", "list every WCAG 2.2 A/AA criterion and what this run reached on it").option("--allow-remote", "allow --url to crawl a host that is not localhost").option("--ignore-robots", "crawl paths robots.txt disallows").option("--sitemap <path>", "where the site lists its pages, if not /sitemap.xml").option("--max-pages <n>", "stop the crawl after this many pages", parsePositive).option("--max-depth <n>", "how far from the entry URL to follow links", parseDepth).option("--header <header>", "send this header with every request, e.g. \"Authorization: Bearer …\". Repeatable", collectHeader).option("--basic-auth <user:password>", "send an Authorization header for basic auth", parseBasicAuth).option("--fail-on <impact>", `exit 1 on violations at or above this impact (${IMPACT_LEVELS.join("|")}; default: ${DEFAULT_FAIL_ON})`, parseImpact).option("--format <format>", `output format (${OUTPUT_FORMATS.join("|")}; default: console)`, parseFormat).option("--output <path>", "write the report to a file instead of stdout").option("--browser", "audit in real Chromium, covering the rules jsdom cannot evaluate").option("--fast", "skip the rules the browserless engine cannot decide anyway, losing their element lists").option("--concurrency <n>", "pages to audit at once, or 1 for none (default: from the page and core count)", parseConcurrency).option("--baseline <path>", "accept the violations recorded in this file; fail only on new ones").option("--review <path>", "what a person checked, from eaa-kit checklist").option("--review-max-age <days>", "stop counting review entries older than this", parseDepth).option("--config <path>", "take defaults from this config file, otherwise it is searched for").action(async (dir, flags) => {
460
+ program.name("eaa-kit").description("WCAG 2.2 AA auditor and EU accessibility statement generator for static sites.\nRun it with no command to find your site, audit it and write a report.\nNot legal advice.").version(TOOL_VERSION, "-v, --version");
461
+ program.command("audit").description("Audit built HTML against WCAG 2.2 AA").argument("[dir]", "directory holding the built site (default: found automatically)").option("--include <globs...>", "glob patterns to audit, relative to dir").option("--exclude <globs...>", "glob patterns to skip").option("--base-url <url>", "audit pages under their real site URL").option("--url <url>", "audit a running site instead of a build directory").option("--no-build", "never run the project build or start its server").option("--per-page", "also list every page and its result").option("--manual", "what to check by hand for the rules this engine cannot evaluate").option("--coverage", "list every WCAG 2.2 A/AA criterion and what this run reached on it").option("--allow-remote", "allow --url to crawl a host that is not localhost").option("--ignore-robots", "crawl paths robots.txt disallows").option("--sitemap <path>", "where the site lists its pages, if not /sitemap.xml").option("--redirects <mode>", `when the URL redirects to another site: ${REDIRECT_MODES.join("|")} (default: ask)`, oneOf(REDIRECT_MODES)).option("--max-pages <n>", "stop the crawl after this many pages", parsePositive).option("--max-depth <n>", "how far from the entry URL to follow links", parseDepth).option("--header <header>", "send this header with every request, e.g. \"Authorization: Bearer …\". Repeatable", collectHeader).option("--basic-auth <user:password>", "send an Authorization header for basic auth", parseBasicAuth).option("--fail-on <impact>", `exit 1 on violations at or above this impact (${IMPACT_LEVELS.join("|")}; default: ${DEFAULT_FAIL_ON})`, parseImpact).option("--format <format>", `output format (${OUTPUT_FORMATS.join("|")}; default: console)`, parseFormat).option("--output <path>", "write the report to a file instead of stdout").option("--browser", "audit in real Chromium, covering the rules jsdom cannot evaluate").option("--fast", "skip the rules the browserless engine cannot decide anyway, losing their element lists").option("--concurrency <n>", "pages to audit at once, or 1 for none (default: from the page and core count)", parseConcurrency).option("--baseline <path>", "accept the violations recorded in this file; fail only on new ones").option("--no-cache", "audit every page, reusing no result from an earlier run").option("--review <path>", "what a person checked, from eaa-kit checklist").option("--review-max-age <days>", "stop counting review entries older than this", parseDepth).option("--config <path>", "take defaults from this config file, otherwise it is searched for").option("--watch", "audit again whenever the build directory changes, until Ctrl-C").action(async (dir, { watch, ...flags }) => {
552
462
  const defaults = await auditDefaults({ ...flags.config ? { config: flags.config } : {} });
553
463
  const invocation = auditInvocation(dir, defaults, flags);
554
- const { exitCode } = await runAuditCommand(invocation.dir, invocation.options);
555
- process.exitCode = exitCode;
464
+ if (!watch) {
465
+ const { exitCode } = await runAuditCommand(invocation.dir, invocation.options);
466
+ process.exitCode = exitCode;
467
+ return;
468
+ }
469
+ if (invocation.options.url !== void 0) {
470
+ fail("--watch watches a build directory, and --url audits a running site.", {
471
+ command: "eaa-kit audit ./dist --watch",
472
+ why: "watch the build instead, with your build directory in place of ./dist"
473
+ });
474
+ process.exitCode = 2;
475
+ return;
476
+ }
477
+ const { watchAudit } = await import("../watch-B2RoUbo0.js");
478
+ process.exitCode = await watchAudit({
479
+ run: (directory) => runAuditCommand(directory, invocation.options),
480
+ directory: invocation.dir,
481
+ cwd: process.cwd(),
482
+ ignore: [".eaa-kit", ...invocation.options.output ? [invocation.options.output] : []]
483
+ });
556
484
  });
557
- program.command("baseline").description("Record the violations a build already has, so later runs fail only on new ones").argument("[dir]", "directory holding the built site (default: ./dist)").option("--include <globs...>", "glob patterns to audit, relative to dir").option("--exclude <globs...>", "glob patterns to skip").option("--base-url <url>", "audit pages under their real site URL").option("--url <url>", "record a baseline from a running site instead of a directory").option("--allow-remote", "allow --url to crawl a host that is not localhost").option("--ignore-robots", "crawl paths robots.txt disallows").option("--sitemap <path>", "where the site lists its pages, if not /sitemap.xml").option("--max-pages <n>", "stop the crawl after this many pages", parsePositive).option("--max-depth <n>", "how far from the entry URL to follow links", parseDepth).option("--header <header>", "send this header with every request, e.g. \"Authorization: Bearer …\". Repeatable", collectHeader).option("--basic-auth <user:password>", "send an Authorization header for basic auth", parseBasicAuth).option("--output <path>", `where to write it (default: ${DEFAULT_BASELINE_FILE})`).option("--prune", "remove the entries this run shows are gone, instead of recording a new baseline").option("--note <text>", "recorded on every entry, for whoever reads the file").option("--expires-on <date>", "ISO date after which the entries stop suppressing", parseDate).option("--browser", "audit in real Chromium instead of jsdom").option("--concurrency <n>", "pages to audit at once, or 1 for none", parseConcurrency).option("--config <path>", "take defaults from this config file, otherwise it is searched for").action(async (dir, flags) => {
485
+ program.command("baseline").description("Record the violations a build already has, so later runs fail only on new ones").argument("[dir]", "directory holding the built site (default: ./dist)").option("--include <globs...>", "glob patterns to audit, relative to dir").option("--exclude <globs...>", "glob patterns to skip").option("--base-url <url>", "audit pages under their real site URL").option("--url <url>", "record a baseline from a running site instead of a directory").option("--allow-remote", "allow --url to crawl a host that is not localhost").option("--ignore-robots", "crawl paths robots.txt disallows").option("--sitemap <path>", "where the site lists its pages, if not /sitemap.xml").option("--redirects <mode>", `when the URL redirects to another site: ${REDIRECT_MODES.join("|")} (default: ask)`, oneOf(REDIRECT_MODES)).option("--max-pages <n>", "stop the crawl after this many pages", parsePositive).option("--max-depth <n>", "how far from the entry URL to follow links", parseDepth).option("--header <header>", "send this header with every request, e.g. \"Authorization: Bearer …\". Repeatable", collectHeader).option("--basic-auth <user:password>", "send an Authorization header for basic auth", parseBasicAuth).option("--output <path>", `where to write it (default: ${DEFAULT_BASELINE_FILE})`).option("--prune", "remove the entries this run shows are gone, instead of recording a new baseline").option("--note <text>", "recorded on every entry, for whoever reads the file").option("--expires-on <date>", "ISO date after which the entries stop suppressing", parseDate).option("--browser", "audit in real Chromium instead of jsdom").option("--concurrency <n>", "pages to audit at once, or 1 for none", parseConcurrency).option("--config <path>", "take defaults from this config file, otherwise it is searched for").action(async (dir, flags) => {
558
486
  const defaults = await auditDefaults({ ...flags.config ? { config: flags.config } : {} });
559
487
  const invocation = baselineInvocation(dir, defaults, flags);
560
488
  const { exitCode } = await runBaselineCommand(invocation.dir, invocation.options);
561
489
  process.exitCode = exitCode;
562
490
  });
563
491
  program.command("checklist").description("Write the manual review: the 34 WCAG criteria no automated rule can reach").option("--record <path>", `where the answers live (default: ${DEFAULT_REVIEW_FILE})`).option("--output <path>", "write the worksheet here instead of stdout").option("--reviewed-by <name>", "who is carrying out the review").action(async (flags) => {
564
- const { runChecklistCommand } = await import("../checklist-BtgkxMEa.js");
492
+ const { runChecklistCommand } = await import("../checklist-Gx2g3LFC.js");
565
493
  const { exitCode } = await runChecklistCommand(flags);
566
494
  process.exitCode = exitCode;
567
495
  });
496
+ program.command("countries").description("List the countries a statement can be written for, and what each one names").option("--json", "print the list as JSON").action(async (flags) => {
497
+ const { formatCountries } = await import("../countries-DRTBubeE.js");
498
+ process.stdout.write(formatCountries(flags));
499
+ });
568
500
  program.command("diff").description("Compare two JSON reports: what a change made worse, and what it fixed").argument("<before>", "JSON report from before the change").argument("<after>", "JSON report from after it").option("--format <format>", `output format (${DIFF_FORMATS.join("|")})`, oneOf(DIFF_FORMATS)).option("--output <path>", "write the diff here instead of stdout").option("--fail-on <impact>", `exit 1 on NEW violations at or above this impact (${IMPACT_LEVELS.join("|")})`, parseImpact, DEFAULT_FAIL_ON).action(async (before, after, flags) => {
569
501
  const { exitCode } = await runDiffCommand(before, after, flags);
570
502
  process.exitCode = exitCode;
571
503
  });
572
- program.command("init").description("Write an eaa.config.json to generate statements from").option("--output <path>", "write here instead of eaa.config.json").option("--force", "overwrite a config that is already there").option("-y, --yes", "take every default without asking").action(async (flags) => {
573
- const { runInitCommand } = await import("../init-BjKYttxc.js");
574
- const { exitCode } = await runInitCommand(flags);
504
+ program.command("init").description("Write an eaa.config.json to generate statements from").option("--output <path>", "write here instead of eaa.config.json").option("--force", "overwrite a config that is already there").option("-y, --yes", "take every default without asking").option("--no-ci", "never offer the GitHub Actions workflow").option("--no-baseline", "never offer to record a baseline").action(async (flags) => {
505
+ const { ci, baseline, ...rest } = flags;
506
+ const { runInitCommand } = await import("../init-CPbFVMuk.js");
507
+ const { exitCode } = await runInitCommand({
508
+ ...rest,
509
+ ...ci ? {} : { ci: false },
510
+ ...baseline ? {} : { baseline: false }
511
+ });
575
512
  process.exitCode = exitCode;
576
513
  });
577
- program.command("statement").description("Generate an EU accessibility statement from eaa.config").option("--config <path>", "path to the config file, otherwise it is searched for").option("--lang <locale>", `statement language (${STATEMENT_LOCALES.join("|")})`, parseLocale).option("--country <code>", `override the country template (${COUNTRIES.join("|")})`, parseCountry).option("--audit <path>", "list the barriers from an eaa-kit audit --format json report").option("--review <path>", "check the conformance claim against a review record; nothing from it is published").option("--format <format>", `output format (${STATEMENT_FORMATS.join("|")}), otherwise from the --output extension`, parseStatementFormat).option("--output <path>", "write the statement to a file instead of stdout").action(async (flags) => {
514
+ program.command("statement").description("Generate an EU accessibility statement from eaa.config").option("--config <path>", "path to the config file, otherwise it is searched for").option("--lang <locale>", `statement language (${STATEMENT_LOCALES.join("|")})`, parseLocale).option("--country <code>", `override the country template (${COUNTRIES.join("|")})`, parseCountry).option("--audit <path>", "list the barriers from an eaa-kit audit --format json report").option("--review <path>", "say how many criteria a person checked, and check the conformance claim against them").option("--format <format>", `output format (${STATEMENT_FORMATS.join("|")}), otherwise from the --output extension`, parseStatementFormat).option("--output <path>", "write the statement to a file instead of stdout").action(async (flags) => {
578
515
  const { lang, ...options } = flags;
579
516
  const { exitCode } = await runStatementCommand({
580
517
  ...options,
@@ -583,17 +520,36 @@ program.command("statement").description("Generate an EU accessibility statement
583
520
  process.exitCode = exitCode;
584
521
  });
585
522
  try {
586
- await program.parseAsync(process.argv);
523
+ if (process.argv.length <= 2) {
524
+ const { runFirstRun } = await import("../start-DzOM0p6I.js");
525
+ process.exitCode = (await runFirstRun()).exitCode;
526
+ } else await program.parseAsync(process.argv);
587
527
  } catch (cause) {
588
528
  if (cause instanceof ConfigError) {
589
529
  fail(cause.message);
590
530
  for (const issue of cause.issues) note(` ${issue}`);
531
+ if (cause.next !== void 0) nextStep(cause.next);
591
532
  process.exitCode = 2;
592
533
  process.exit(2);
593
534
  }
594
535
  const error = cause;
595
- if (typeof error.exitCode === "number") process.exitCode = error.exitCode === 0 ? 0 : 2;
596
- else {
536
+ if (typeof error.exitCode === "number") {
537
+ process.exitCode = error.exitCode === 0 ? 0 : 2;
538
+ if (error.exitCode !== 0 && error.code !== "commander.unknownCommand") {
539
+ const typed = process.argv[2];
540
+ const known = program.commands.find((command) => command.name() === typed);
541
+ nextStep(error.message?.includes("'--country") === true ? {
542
+ command: "eaa-kit countries",
543
+ why: "the countries a statement can be written for"
544
+ } : known === void 0 ? {
545
+ command: "eaa-kit --help",
546
+ why: "the commands, and what each one does"
547
+ } : {
548
+ command: `eaa-kit ${known.name()} --help`,
549
+ why: "every flag it takes"
550
+ });
551
+ }
552
+ } else {
597
553
  process.stderr.write(`${cause instanceof Error ? cause.stack : String(cause)}\n`);
598
554
  process.exitCode = 2;
599
555
  }
@@ -114,7 +114,7 @@ async function readPage(root, relativePath, onUnreadable, maxBytes) {
114
114
  async function emptyDirectoryHint(dir, cwd = process.cwd()) {
115
115
  const head = await exists(dir, cwd) ? `${dir} holds no HTML files.` : `${dir} does not exist.`;
116
116
  const { detectFramework } = await import("./frameworks-etFg_O8K.js");
117
- const { readPackageJson } = await import("./project-MFrXcw1M.js");
117
+ const { readPackageJson } = await import("./project-BLFdCbOq.js");
118
118
  const detected = await detectFramework(cwd, await readPackageJson(cwd));
119
119
  if (detected !== void 0) return frameworkAdvice(head, detected, cwd, dir);
120
120
  return await siblingAdvice(head, cwd, dir) ?? generic(head);
@@ -81,6 +81,19 @@ function requestHeaders(options) {
81
81
  return Object.keys(headers).length === 0 ? void 0 : headers;
82
82
  }
83
83
  //#endregion
84
+ //#region src/next.ts
85
+ /** The next step an error carries, if it carries one. */
86
+ function nextStepOf(cause) {
87
+ if (cause === null || typeof cause !== "object") return void 0;
88
+ const next = cause.next;
89
+ if (next === null || typeof next !== "object") return void 0;
90
+ const { command, why } = next;
91
+ return typeof command === "string" && typeof why === "string" ? {
92
+ command,
93
+ why
94
+ } : void 0;
95
+ }
96
+ //#endregion
84
97
  //#region src/cli/command.ts
85
98
  /**
86
99
  * What every command does around the audit itself: say what is happening, run
@@ -98,8 +111,20 @@ function note(message) {
98
111
  function warn(message) {
99
112
  process.stderr.write(`${pc.yellow("warning")} ${message}\n`);
100
113
  }
101
- function fail(message) {
114
+ function fail(message, next) {
102
115
  process.stderr.write(`${pc.red("error")} ${message}\n`);
116
+ if (next !== void 0) nextStep(next);
117
+ }
118
+ /**
119
+ * An error a command stops on: its message, then the command that fixes it
120
+ * when the error carries one.
121
+ */
122
+ function failWith(cause) {
123
+ fail(cause.message, nextStepOf(cause));
124
+ }
125
+ /** The line under an error that says what to type. */
126
+ function nextStep(next) {
127
+ process.stderr.write(` ${pc.cyan("→")} ${pc.bold(next.command)} ${pc.dim(next.why)}\n`);
103
128
  }
104
129
  /**
105
130
  * Advice the reader should not miss, without the `warning` prefix: nothing has
@@ -122,14 +147,14 @@ async function runEngine(pages, options) {
122
147
  ...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs }
123
148
  };
124
149
  if (!options.browser) {
125
- const { runPooledAudit } = await import("./pool-dkexq5xo.js");
150
+ const { runPooledAudit } = await import("./pool-B4tEUa2S.js");
126
151
  return runPooledAudit(pages, {
127
152
  ...runnerOptions,
128
153
  ...options.fast ? { fast: true } : {},
129
154
  ...options.concurrency === void 0 ? {} : { concurrency: options.concurrency }
130
155
  });
131
156
  }
132
- const { BrowserUnavailableError, runBrowserAudit } = await import("./playwright-C-miJP2b.js");
157
+ const { BrowserUnavailableError, runBrowserAudit } = await import("./playwright-ukCr_5o3.js");
133
158
  try {
134
159
  return await runBrowserAudit(options.directory, pages, {
135
160
  ...runnerOptions,
@@ -138,7 +163,7 @@ async function runEngine(pages, options) {
138
163
  });
139
164
  } catch (cause) {
140
165
  if (cause instanceof BrowserUnavailableError) {
141
- fail(cause.message);
166
+ failWith(cause);
142
167
  return;
143
168
  }
144
169
  throw cause;
@@ -176,7 +201,7 @@ async function emitDocument(body, output, cwd) {
176
201
  * on different settings than it names would be worse than stopping.
177
202
  */
178
203
  async function auditDefaults(options = {}) {
179
- const { loadAuditConfig } = await import("./load-Bc_xDGAh.js");
204
+ const { loadAuditConfig } = await import("./load-D7lBeOsq.js");
180
205
  const loaded = await loadAuditConfig({
181
206
  ...options.cwd ? { cwd: options.cwd } : {},
182
207
  ...options.config ? { path: options.config } : {}
@@ -186,8 +211,8 @@ async function auditDefaults(options = {}) {
186
211
  return loaded.audit;
187
212
  }
188
213
  function auditInvocation(dir, defaults, flags) {
189
- const { build, config: _config, header, basicAuth, ...typed } = flags;
190
- const { dir: configDir, build: configBuild, headers: _fromFile, ...fromConfig } = defaults;
214
+ const { build, cache, config: _config, header, basicAuth, ...typed } = flags;
215
+ const { dir: configDir, build: configBuild, cache: configCache, headers: _fromFile, ...fromConfig } = defaults;
191
216
  const headers = requestHeaders({
192
217
  ...header ? { header } : {},
193
218
  ...basicAuth ? { basicAuth } : {}
@@ -198,6 +223,7 @@ function auditInvocation(dir, defaults, flags) {
198
223
  ...fromConfig,
199
224
  ...typed,
200
225
  ...build === false || configBuild === false ? { noBuild: true } : {},
226
+ ...cache === false || configCache === false ? { noCache: true } : {},
201
227
  ...headers === void 0 ? {} : { headers }
202
228
  }
203
229
  };
@@ -235,6 +261,7 @@ function baselineDefaults(config) {
235
261
  "allowRemote",
236
262
  "ignoreRobots",
237
263
  "sitemap",
264
+ "redirects",
238
265
  "maxPages",
239
266
  "maxDepth",
240
267
  "browser",
@@ -248,4 +275,4 @@ function pick(source, keys) {
248
275
  return out;
249
276
  }
250
277
  //#endregion
251
- export { emitDocument as a, runEngine as c, parseHeader as d, baselineInvocation as i, warn as l, auditDefaults as n, fail as o, auditInvocation as r, note as s, advise as t, basicAuth as u };
278
+ export { emitDocument as a, nextStep as c, warn as d, basicAuth as f, baselineInvocation as i, note as l, auditDefaults as n, fail as o, parseHeader as p, auditInvocation as r, failWith as s, advise as t, runEngine as u };
@@ -0,0 +1,25 @@
1
+ import { r as COUNTRIES } from "./define-Ctf2uOEh.js";
2
+ import { t as COUNTRY_INFO } from "./countries-Dg0BdytB.js";
3
+ import pc from "picocolors";
4
+ //#region src/cli/countries.ts
5
+ function formatCountries(options = {}) {
6
+ if (options.json) {
7
+ const entries = COUNTRIES.map((code) => ({
8
+ code,
9
+ ...COUNTRY_INFO[code]
10
+ }));
11
+ return `${JSON.stringify(entries, null, 2)}\n`;
12
+ }
13
+ const colors = pc.createColors(options.color ?? pc.isColorSupported);
14
+ const lines = [];
15
+ for (const code of COUNTRIES) {
16
+ const info = COUNTRY_INFO[code];
17
+ lines.push(`${colors.bold(code)} ${info.name} ${colors.dim(`(${info.languages.join(", ")})`)}`, ` Statute: ${info.statute}`, ` Authority: ${info.authority}`);
18
+ if (info.unverified) lines.push(colors.yellow(" New in 0.8: citations not yet checked against the primary text"));
19
+ lines.push("");
20
+ }
21
+ lines.push("eaa-kit statement --country <code> --lang <language>");
22
+ return `${lines.join("\n")}\n`;
23
+ }
24
+ //#endregion
25
+ export { formatCountries };