eaa-kit 0.7.0 → 0.11.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 (115) hide show
  1. package/README.md +182 -135
  2. package/dist/astro/index.d.ts +1 -3
  3. package/dist/astro/index.js +2 -3
  4. package/dist/audit/runners/worker.js +2 -3
  5. package/dist/{audit-DRjAY2iY.js → audit-DbqNIrt6.js} +85 -219
  6. package/dist/audit-rUhqnm3o.js +1 -0
  7. package/dist/{baseline-BpE7DbDq.js → baseline-CKElWbx4.js} +18 -8
  8. package/dist/baseline-DU0EPiTq.js +1 -0
  9. package/dist/baseline-DYOejLFO.js +1 -0
  10. package/dist/baseline-DvdsFTQy.js +126 -0
  11. package/dist/{cache-D4dOIuOi.js → cache-DIV4G0TI.js} +24 -5
  12. package/dist/{checklist-DDd9jewi.js → checklist-CA0Ri71Z.js} +8 -9
  13. package/dist/cli/index.js +115 -158
  14. package/dist/{collect-Cu1q9NTB.js → collect-CjucwTEF.js} +16 -8
  15. package/dist/{command-3r4fht5f.js → command-C8ZFvcc1.js} +33 -10
  16. package/dist/completeness-Cg-XIKWN.js +1 -0
  17. package/dist/completeness-Dzyvgr4Z.js +72 -0
  18. package/dist/component-CgbeRgJa.js +1 -0
  19. package/dist/{component-ChisoFyY.js → component-ZLd8DA_a.js} +3 -4
  20. package/dist/countries-B_PE6r5R.js +180 -0
  21. package/dist/countries-CCqog6dy.js +28 -0
  22. package/dist/coverage-B9_6yv_8.js +2 -0
  23. package/dist/{coverage-cb5kPp48.js → coverage-C1Z6t9Ct.js} +5 -7
  24. package/dist/{crawl-BHkJmUkA.js → crawl-CkHJJV4w.js} +135 -25
  25. package/dist/{criteria-CnPJKGeb.js → criteria-CacF0HP1.js} +1 -2
  26. package/dist/{load-BaWMa-G_.js → define-BdTPIfqE.js} +46 -99
  27. package/dist/detect-DnFHXpWh.js +49 -0
  28. package/dist/detect-oLDadgee.js +160 -0
  29. package/dist/doctor-q8IebwAb.js +248 -0
  30. package/dist/eleventy/index.d.ts +1 -3
  31. package/dist/eleventy/index.js +2 -3
  32. package/dist/entry-kf94P140.js +173 -0
  33. package/dist/{fingerprint-BjYV_0F7.js → fingerprint-CcoQ1WxQ.js} +1 -2
  34. package/dist/{frameworks-B4ClIJgE.js → frameworks-BboC8eNk.js} +234 -28
  35. package/dist/frameworks-Y-n3NUuG.js +1 -0
  36. package/dist/{fs-BmPtmFke.js → fs-tPD5r0wY.js} +1 -2
  37. package/dist/hosts-B48qR6Vt.js +19 -0
  38. package/dist/{html-BIxxF3FC.js → html-Bjq3Iw3g.js} +56 -14
  39. package/dist/{impact-luGCnN8F.js → impact-BGlJ6j0Y.js} +1 -2
  40. package/dist/{impact-EEB9ZXmC.d.ts → impact-CZjUloYC.d.ts} +0 -2
  41. package/dist/index.d.ts +50 -26
  42. package/dist/index.js +3 -2
  43. package/dist/init-3Ti3ao5Z.js +232 -0
  44. package/dist/issues-WLlepU95.js +120 -0
  45. package/dist/{jsdom-CsW_xVcA.js → jsdom-C4pLIMyP.js} +2 -3
  46. package/dist/jsdom-Zle--VQ1.js +2 -0
  47. package/dist/{json-Bus6YhxB.js → json-B_k4CDmR.js} +5 -6
  48. package/dist/json-IL1JxlTL.js +1 -0
  49. package/dist/load-C3eFEdoH.js +98 -0
  50. package/dist/load-oQQJPNlV.js +1 -0
  51. package/dist/markdown-D-QpPYsz.js +138 -0
  52. package/dist/next-8zDgH0nP.js +119 -0
  53. package/dist/nuxt/index.d.ts +1 -3
  54. package/dist/nuxt/index.js +2 -3
  55. package/dist/pages-CCP1WfYe.js +363 -0
  56. package/dist/{playwright-ukCr_5o3.js → playwright-ky4b_HME.js} +98 -16
  57. package/dist/{pool-B4tEUa2S.js → pool-B3XKdk57.js} +4 -5
  58. package/dist/project-B21NT_aX.js +502 -0
  59. package/dist/project-Dht13sb1.js +1 -0
  60. package/dist/{remediation-C0klJblu.js → remediation-BkE7q7dT.js} +2 -176
  61. package/dist/{render-C1sUZZI_.js → render-ky8cm4QF.js} +50 -24
  62. package/dist/result-DhoT4g0P.js +1 -0
  63. package/dist/{result-B7_zVxAX.js → result-g8dGsrcv.js} +1 -2
  64. package/dist/{review-CdMK2GpQ.js → review-BGjTBFvd.js} +11 -4
  65. package/dist/review-iheEjp7_.js +1 -0
  66. package/dist/{routes-CmdRUuOs.js → routes-BpQeBDmM.js} +4 -5
  67. package/dist/{run-DrS0Komf.js → run-D7tc7IU2.js} +2 -3
  68. package/dist/{run-BK2blxMI.d.ts → run-VXnP4uLp.d.ts} +2 -6
  69. package/dist/{sarif-BNCE0PNT.js → sarif-v66-PjdE.js} +9 -9
  70. package/dist/{schema-DJSF4K05.js → schema-DfC-Ww1w.js} +1 -2
  71. package/dist/setup-BYlqHlo0.js +2 -0
  72. package/dist/setup-Cf82ONw0.js +353 -0
  73. package/dist/shell-BdQYTaBQ.js +89 -0
  74. package/dist/site-CxVyh8IO.js +71 -0
  75. package/dist/start-bdanSxZr.js +100 -0
  76. package/dist/statement/templates/be.de.md +148 -0
  77. package/dist/statement/templates/be.en.md +142 -0
  78. package/dist/statement/templates/be.fr.md +146 -0
  79. package/dist/statement/templates/be.nl.md +147 -0
  80. package/dist/statement/templates/cz.cs.md +138 -0
  81. package/dist/statement/templates/cz.en.md +140 -0
  82. package/dist/statement/templates/dk.da.md +142 -0
  83. package/dist/statement/templates/dk.en.md +142 -0
  84. package/dist/statement/templates/fi.en.md +139 -0
  85. package/dist/statement/templates/fi.fi.md +141 -0
  86. package/dist/statement/templates/ie.en.md +144 -0
  87. package/dist/statement/templates/pl.en.md +143 -0
  88. package/dist/statement/templates/pl.pl.md +144 -0
  89. package/dist/statement/templates/pt.en.md +143 -0
  90. package/dist/statement/templates/pt.pt.md +145 -0
  91. package/dist/statement/templates/se.en.md +148 -0
  92. package/dist/statement/templates/se.sv.md +150 -0
  93. package/dist/{text-BF1LHMiV.js → text-CISDPU49.js} +11 -3
  94. package/dist/{version-B3v4rNoG.js → version-C8aJm8YJ.js} +1 -2
  95. package/dist/vite/index.d.ts +1 -3
  96. package/dist/vite/index.js +2 -3
  97. package/dist/watch-CefxwMsZ.js +121 -0
  98. package/dist/webpack/index.d.ts +1 -3
  99. package/dist/webpack/index.js +2 -3
  100. package/dist/{worksheet-BIxMtbUd.js → worksheet-CcBo9G7s.js} +4 -5
  101. package/dist/workspaces-BBFXOyeV.js +85 -0
  102. package/package.json +16 -14
  103. package/dist/audit-Bwm1xBdJ.js +0 -2
  104. package/dist/baseline-rtnj3RHB.js +0 -2
  105. package/dist/component-DcCn3BJS.js +0 -2
  106. package/dist/coverage-n1X9CkiG.js +0 -3
  107. package/dist/frameworks-etFg_O8K.js +0 -2
  108. package/dist/init-DrFfzjvm.js +0 -119
  109. package/dist/jsdom-BUYuVJJm.js +0 -3
  110. package/dist/json-CrQmoTj6.js +0 -2
  111. package/dist/load-n62iXDq_.js +0 -2
  112. package/dist/project-CzOnkLH6.js +0 -274
  113. package/dist/project-MFrXcw1M.js +0 -2
  114. package/dist/result-CRmjjoAA.js +0 -2
  115. package/dist/review-DIbOTmOM.js +0 -2
@@ -1,14 +1,16 @@
1
- import { a as impactLabel, r as byImpactThenRule } from "./impact-luGCnN8F.js";
2
- import { i as escapeText, n as count, r as escapeAttribute, s as standardsReference, t as collapse } from "./text-BF1LHMiV.js";
3
- import { t as TOOL_VERSION } from "./version-B3v4rNoG.js";
4
- import { u as runEngine } from "./result-B7_zVxAX.js";
5
- import { l as reviewSentence } from "./review-CdMK2GpQ.js";
6
- import { a as isShared, c as missedParts, i as groupIssues, l as reusedPart, n as blindRules, o as issueTotals, r as coverageParts, s as discoveryLabel, t as remediationFor } from "./remediation-C0klJblu.js";
7
- import { r as componentPath } from "./component-ChisoFyY.js";
8
- import { a as manualCheckFor, o as understandingUrl, r as reviewSummary, t as buildCoverage } from "./coverage-cb5kPp48.js";
9
- import { n as buildSummary } from "./json-Bus6YhxB.js";
1
+ import { c as standardsReference, i as escapeText, n as count, r as escapeAttribute, t as collapse } from "./text-CISDPU49.js";
2
+ import { t as TOOL_VERSION } from "./version-C8aJm8YJ.js";
3
+ import { a as reusedPart, n as missedParts, r as redirectPart, t as discoveryLabel } from "./completeness-Dzyvgr4Z.js";
4
+ import { r as componentPath } from "./component-ZLd8DA_a.js";
5
+ import { a as manualCheckFor, o as understandingUrl, r as reviewSummary, t as buildCoverage } from "./coverage-C1Z6t9Ct.js";
6
+ import { a as impactLabel, r as byImpactThenRule } from "./impact-BGlJ6j0Y.js";
7
+ import { a as issueTotals, i as isShared, n as coverageParts, r as groupIssues, t as blindRules } from "./issues-WLlepU95.js";
8
+ import { t as remediationFor } from "./remediation-BkE7q7dT.js";
9
+ import { u as runEngine } from "./result-g8dGsrcv.js";
10
+ import { l as reviewSentence } from "./review-BGjTBFvd.js";
11
+ import { n as buildSummary } from "./json-B_k4CDmR.js";
10
12
  import axe from "axe-core";
11
- //#region src/audit/report/html.ts
13
+ // src/audit/report/html.ts
12
14
  /**
13
15
  * A standalone HTML audit report.
14
16
  *
@@ -57,6 +59,7 @@ ${STYLES}
57
59
  <main>
58
60
  <h1>Accessibility audit</h1>
59
61
  ${verdict(totals, options)}
62
+ ${sinceBaseline(totals, options)}
60
63
  ${scoreboard(audits)}
61
64
  ${issues(audits, options)}
62
65
  ${runDetails(audits, engine, generatedAt, options)}
@@ -89,6 +92,26 @@ function verdict(totals, options) {
89
92
  if (completeness && !completeness.complete) return banner("partial", "No violations found, but the whole site was not measured", `${escapeText(missedParts(completeness).join(", "))}. This report describes ${count(completeness.audited, "page")}, not the site.`);
90
93
  return banner("pass", "No violations found", "Automated testing found nothing to report.");
91
94
  }
95
+ /**
96
+ * What changed since the baseline was recorded, for the reader who wants to
97
+ * know whether things are getting better: what is new, what the project still
98
+ * lives with, and what has been fixed since.
99
+ *
100
+ * Only with a baseline. Without one there is no "last time" this report can
101
+ * speak for, and inventing one from an earlier run nobody pointed at would be
102
+ * a comparison the reader never asked for.
103
+ */
104
+ function sinceBaseline(totals, options) {
105
+ const baseline = options.baseline;
106
+ if (baseline === void 0) return "";
107
+ const items = [
108
+ `<li><strong>${totals.failing}</strong> new ${totals.failing === 1 ? "violation" : "violations"} at or above ${escapeText(options.failOn)}, which the baseline does not list</li>`,
109
+ `<li><strong>${totals.accepted}</strong> ${totals.accepted === 1 ? "element" : "elements"} the baseline still accepts</li>`,
110
+ `<li><strong>${baseline.stale}</strong> baseline ${baseline.stale === 1 ? "entry" : "entries"} no longer found: fixed, or the element is gone</li>`
111
+ ];
112
+ if (baseline.expired > 0) items.push(`<li><strong>${baseline.expired}</strong> baseline ${baseline.expired === 1 ? "entry has" : "entries have"} expired and no longer ${baseline.expired === 1 ? "suppresses" : "suppress"} anything</li>`);
113
+ return `<h2>Since the baseline</h2>\n<ul class="counts since">\n ${items.join("\n ")}\n</ul>`;
114
+ }
92
115
  function banner(kind, heading, detail) {
93
116
  return `<p class="verdict ${escapeAttribute(kind)}"><strong>${escapeText(heading)}</strong> ${detail}</p>`;
94
117
  }
@@ -105,6 +128,8 @@ function runDetails(audits, engine, generatedAt, options) {
105
128
  if (options.completeness) rows.splice(2, 0, ["Pages found via", discoveryLabel(options.completeness.discovery)]);
106
129
  const reused = options.completeness ? reusedPart(options.completeness) : void 0;
107
130
  if (reused !== void 0) rows.push(["Reused", reused]);
131
+ const redirected = options.completeness ? redirectPart(options.completeness) : void 0;
132
+ if (redirected !== void 0) rows.splice(1, 0, ["Redirected", redirected]);
108
133
  return `<h2>The run</h2>\n<dl class="run">\n${rows.map(([term, value]) => ` <div><dt>${escapeText(term)}</dt><dd>${escapeText(value)}</dd></div>`).join("\n")}\n</dl>`;
109
134
  }
110
135
  /** Pages named individually before the rest are counted. */
@@ -418,7 +443,8 @@ p.reach, p.sources, p.selector, p.more, p.written-in { margin: 0.35rem 0; font-s
418
443
  .element details { font-size: 0.9rem; color: #4a4a4a; }
419
444
  .element summary { cursor: pointer; }
420
445
  ul.page-list { margin: 0.35rem 0 0; padding-left: 1.25rem; }
421
- @media (prefers-color-scheme: dark) {
446
+ /* Screen only: a reader whose system is dark still prints on white paper. */
447
+ @media screen and (prefers-color-scheme: dark) {
422
448
  body { background: #121212; color: #ededed; }
423
449
  a { color: #9ec1ff; }
424
450
  h2, hr { border-color: #3a3a3a; }
@@ -454,9 +480,26 @@ ul.page-list { margin: 0.35rem 0 0; padding-left: 1.25rem; }
454
480
  .badge.unclassified { background: #1f1f1f; border-color: #b6b6b6; color: #d8d8d8; }
455
481
  }
456
482
  @media print {
457
- body { background: #ffffff; color: #000000; }
458
- main { max-width: none; }
483
+ @page { margin: 16mm 14mm; }
484
+ :root { color-scheme: light; }
485
+ body { background: #ffffff; color: #000000; font-size: 10.5pt; line-height: 1.45; }
486
+ main { max-width: none; padding: 0; }
459
487
  a { color: #000000; }
488
+ /* Paper has no links, so the address goes beside the text it was behind. */
489
+ a[href^="http"]::after { content: " <" attr(href) ">"; font-size: 0.8em; color: #333333;
490
+ overflow-wrap: anywhere; }
491
+ h1, h2, h3, p.rule, p.review-heading, p.accepted-heading { break-after: avoid; }
492
+ h2 { margin-top: 1.5rem; padding-top: 0.75rem; }
493
+ li.finding, li.issue, .element, .tile, .verdict, dl.run, tr, ul.counts { break-inside: avoid; }
494
+ pre, pre code { white-space: pre-wrap; overflow-wrap: anywhere; overflow: visible; }
495
+ .scroll { overflow: visible; }
496
+ /* Collapsed detail is still detail: a printed report is read without a mouse. */
497
+ details::details-content { content-visibility: visible; display: block; }
498
+ summary { list-style: none; font-weight: 600; }
499
+ .badge, .tile, .verdict, pre.suggested { print-color-adjust: exact;
500
+ -webkit-print-color-adjust: exact; }
501
+ .scoreboard { gap: 0.4rem; }
502
+ .tile { padding: 0.4rem 0.6rem; }
460
503
  }`;
461
504
  /**
462
505
  * The counts, worst first, with what was never checked beside them.
@@ -563,5 +606,4 @@ function manualBlock(ruleId, finding) {
563
606
  links.length === 0 ? "" : ` <p class="criteria">${links.join(" · ")}</p>`
564
607
  ].filter((line) => line !== "").join("\n");
565
608
  }
566
- //#endregion
567
609
  export { buildHtmlReport };
@@ -1,4 +1,4 @@
1
- //#region src/audit/impact.ts
1
+ // src/audit/impact.ts
2
2
  /** axe-core's impact scale, least to most severe. */
3
3
  const IMPACT_LEVELS = [
4
4
  "minor",
@@ -52,5 +52,4 @@ function countAtOrAbove(audits, threshold) {
52
52
  for (const audit of audits) for (const finding of audit.violations) if (meetsThreshold(finding.impact, threshold)) total += 1;
53
53
  return total;
54
54
  }
55
- //#endregion
56
55
  export { impactLabel as a, meetsThreshold as c, countAtOrAbove as i, IMPACT_LEVELS as n, impactRank as o, byImpactThenRule as r, isImpactLevel as s, DEFAULT_FAIL_ON as t };
@@ -1,7 +1,5 @@
1
1
  import "axe-core";
2
- //#region src/audit/impact.d.ts
3
2
  /** axe-core's impact scale, least to most severe. */
4
3
  declare const IMPACT_LEVELS: readonly ['minor', 'moderate', 'serious', 'critical'];
5
4
  type ImpactLevel = (typeof IMPACT_LEVELS)[number];
6
- //#endregion
7
5
  export { ImpactLevel as t };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,23 @@
1
- import { t as ImpactLevel } from "./impact-EEB9ZXmC.js";
2
- //#region src/schema.d.ts
1
+ import { t as ImpactLevel } from "./impact-CZjUloYC.js";
2
+ /**
3
+ * The command that gets somebody past an error.
4
+ *
5
+ * An error the reader cannot act on without opening the docs is half an error.
6
+ * Every error class a command can stop on carries one of these where there is a
7
+ * command that fixes it, and `fail` prints it under the message. That keeps
8
+ * "what went wrong" and "what to type" apart, so the second one can be copied
9
+ * as it is.
10
+ *
11
+ * Only where the fix is a command. An invalid field in a config file is fixed
12
+ * by editing the field, and the issues printed under that error already name
13
+ * it, so pointing at a command there would send somebody somewhere else.
14
+ */
15
+ interface NextStep {
16
+ /** Exactly what to type. */
17
+ command: string;
18
+ /** What it does, in a few words. */
19
+ why: string;
20
+ }
3
21
  /**
4
22
  * The small amount of schema validation this package actually needs.
5
23
  *
@@ -57,10 +75,11 @@ declare const DEFAULTED: unique symbol;
57
75
  type DefaultedSchema<T> = Schema<T> & {
58
76
  readonly [DEFAULTED]: true;
59
77
  };
60
- //#endregion
61
- //#region src/config/define.d.ts
62
- /** Countries with their own supervisory body and statute text. */
63
- declare const COUNTRIES: readonly ['AT', 'DE', 'CH', 'ES', 'FR', 'IT', 'NL'];
78
+ /**
79
+ * Countries with their own supervisory body and statute text. What is known
80
+ * about each one is in `countries.ts`.
81
+ */
82
+ declare const COUNTRIES: readonly ['AT', 'BE', 'CH', 'CZ', 'DE', 'DK', 'ES', 'FI', 'FR', 'IE', 'IT', 'NL', 'PL', 'PT', 'SE'];
64
83
  type Country = (typeof COUNTRIES)[number];
65
84
  /**
66
85
  * Languages a statement can be rendered in.
@@ -70,7 +89,7 @@ type Country = (typeof COUNTRIES)[number];
70
89
  * has the language it is published in and English. `renderStatement` says which
71
90
  * ones a country has when asked for one it does not.
72
91
  */
73
- declare const STATEMENT_LOCALES: readonly ['de', 'en', 'es', 'fr', 'it', 'nl'];
92
+ declare const STATEMENT_LOCALES: readonly ['cs', 'da', 'de', 'en', 'es', 'fi', 'fr', 'it', 'nl', 'pl', 'pt', 'sv'];
74
93
  type StatementLocale = (typeof STATEMENT_LOCALES)[number];
75
94
  /**
76
95
  * Wording follows the EU model statement: fully, partially, or not conformant
@@ -115,12 +134,14 @@ declare const auditSchema: Schema<ObjectOf<{
115
134
  ignoreRobots: OptionalSchema<boolean>;
116
135
  /** Where the site lists its pages, when that is not /sitemap.xml. */
117
136
  sitemap: OptionalSchema<string>;
137
+ /** What to do when the entry URL redirects to another site. */
138
+ redirects: OptionalSchema<"ask" | "follow" | "stop">;
118
139
  maxPages: OptionalSchema<number>;
119
140
  /** 0 audits the entry page alone. */
120
141
  maxDepth: OptionalSchema<number>;
121
142
  /** Lowest impact that exits 1. */
122
143
  failOn: OptionalSchema<"critical" | "minor" | "moderate" | "serious">;
123
- format: OptionalSchema<"console" | "html" | "json" | "sarif">;
144
+ format: OptionalSchema<"console" | "html" | "json" | "markdown" | "sarif">;
124
145
  /** Write the report here instead of stdout. */
125
146
  output: OptionalSchema<string>;
126
147
  /** Audit in real Chromium. Needs the playwright peer. */
@@ -203,7 +224,7 @@ declare const configSchema: Schema<ObjectOf<{
203
224
  }>>;
204
225
  enforcement: Schema<ObjectOf<{
205
226
  /** Drives which supervisory body and statute the template names. */
206
- country: Schema<"AT" | "CH" | "DE" | "ES" | "FR" | "IT" | "NL">;
227
+ country: Schema<"AT" | "BE" | "CH" | "CZ" | "DE" | "DK" | "ES" | "FI" | "FR" | "IE" | "IT" | "NL" | "PL" | "PT" | "SE">;
207
228
  }>>;
208
229
  /** Defaults for the audit commands. Nothing here reaches the statement. */
209
230
  audit: OptionalSchema<ObjectOf<{
@@ -220,12 +241,14 @@ declare const configSchema: Schema<ObjectOf<{
220
241
  ignoreRobots: OptionalSchema<boolean>;
221
242
  /** Where the site lists its pages, when that is not /sitemap.xml. */
222
243
  sitemap: OptionalSchema<string>;
244
+ /** What to do when the entry URL redirects to another site. */
245
+ redirects: OptionalSchema<"ask" | "follow" | "stop">;
223
246
  maxPages: OptionalSchema<number>;
224
247
  /** 0 audits the entry page alone. */
225
248
  maxDepth: OptionalSchema<number>;
226
249
  /** Lowest impact that exits 1. */
227
250
  failOn: OptionalSchema<"critical" | "minor" | "moderate" | "serious">;
228
- format: OptionalSchema<"console" | "html" | "json" | "sarif">;
251
+ format: OptionalSchema<"console" | "html" | "json" | "markdown" | "sarif">;
229
252
  /** Write the report here instead of stdout. */
230
253
  output: OptionalSchema<string>;
231
254
  /** Audit in real Chromium. Needs the playwright peer. */
@@ -320,13 +343,15 @@ type AuditConfig = { [K in keyof Infer<typeof auditSchema>]?: Exclude<Infer<type
320
343
  declare function defineConfig(config: EaaConfigInput): EaaConfigInput;
321
344
  declare class ConfigError extends Error {
322
345
  readonly issues: string[];
346
+ /** The command that fixes it, printed under the message and the issues. */
347
+ readonly next?: NextStep | undefined;
323
348
  readonly name = "ConfigError";
324
- constructor(message: string, issues?: string[]);
349
+ constructor(message: string, issues?: string[],
350
+ /** The command that fixes it, printed under the message and the issues. */
351
+ next?: NextStep | undefined);
325
352
  }
326
353
  /** Validate an already-loaded config object. */
327
354
  declare function parseConfig(value: unknown, source?: string): EaaConfig;
328
- //#endregion
329
- //#region src/config/load.d.ts
330
355
  /** Checked in this order, first match wins. */
331
356
  declare const CONFIG_FILENAMES: readonly ['eaa.config.ts', 'eaa.config.mts', 'eaa.config.js', 'eaa.config.mjs', 'eaa.config.json'];
332
357
  interface LoadedConfig {
@@ -352,8 +377,6 @@ interface LoadConfigOptions {
352
377
  declare function loadConfig(options?: LoadConfigOptions): Promise<LoadedConfig>;
353
378
  /** Walks up from `cwd`, so the CLI works from a subdirectory of the project. */
354
379
  declare function findConfigFile(cwd: string): Promise<string | undefined>;
355
- //#endregion
356
- //#region src/statement/error.d.ts
357
380
  /**
358
381
  * Lives in its own module so that both the renderer and the audit-report reader
359
382
  * can throw it without importing each other.
@@ -364,10 +387,13 @@ declare function findConfigFile(cwd: string): Promise<string | undefined>;
364
387
  * it — nothing is emitted at all.
365
388
  */
366
389
  declare class StatementError extends Error {
390
+ /** The command that fixes it, printed under the message. */
391
+ readonly next?: NextStep | undefined;
367
392
  readonly name = "StatementError";
393
+ constructor(message: string,
394
+ /** The command that fixes it, printed under the message. */
395
+ next?: NextStep | undefined);
368
396
  }
369
- //#endregion
370
- //#region src/audit/review.d.ts
371
397
  declare const reviewSchema: Schema<ObjectOf<{
372
398
  schemaVersion: Schema<number>;
373
399
  /** Who carried out the review, for the record as a whole. */
@@ -384,8 +410,6 @@ declare const reviewSchema: Schema<ObjectOf<{
384
410
  }>>>;
385
411
  }>>;
386
412
  type ReviewRecord = Infer<typeof reviewSchema>;
387
- //#endregion
388
- //#region src/statement/findings.d.ts
389
413
  /** One rule that failed, folded across every page it failed on. */
390
414
  interface AuditFinding {
391
415
  ruleId: string;
@@ -429,8 +453,6 @@ interface AuditSummary {
429
453
  declare function summariseAuditReport(value: unknown, source?: string): AuditSummary;
430
454
  /** Read and summarise a report written by `eaa-kit audit --format json`. */
431
455
  declare function readAuditReport(file: string, cwd?: string): Promise<AuditSummary>;
432
- //#endregion
433
- //#region src/statement/evidence.d.ts
434
456
  /**
435
457
  * Whether the statement's claim survives contact with the evidence beside it.
436
458
  *
@@ -470,8 +492,6 @@ interface EvidenceInput {
470
492
  declare function checkStatementEvidence(input: EvidenceInput): EvidenceProblem[];
471
493
  /** Whether any problem is bad enough to stop the document being written. */
472
494
  declare function refuses(problems: readonly EvidenceProblem[]): boolean;
473
- //#endregion
474
- //#region src/statement/html.d.ts
475
495
  /**
476
496
  * Markdown-to-HTML for exactly the subset the statement templates emit, and
477
497
  * nothing else.
@@ -512,8 +532,6 @@ interface HtmlDocumentOptions {
512
532
  declare function toHtmlDocument(markdown: string, options: HtmlDocumentOptions): string;
513
533
  /** The document body: the block elements alone, for embedding in a page. */
514
534
  declare function toHtmlBody(markdown: string): string;
515
- //#endregion
516
- //#region src/statement/render.d.ts
517
535
  interface RenderStatementOptions {
518
536
  /** Language to render in. Defaults to the site's own language when it is German. */
519
537
  locale?: StatementLocale;
@@ -533,6 +551,13 @@ interface RenderStatementOptions {
533
551
  * statement is the barrier list, which a person writes.
534
552
  */
535
553
  review?: ReviewRecord;
554
+ /**
555
+ * The day the statement is generated, as an ISO date. Decides which
556
+ * supervisor a country names where the law has scheduled a change, such as
557
+ * Sweden's on 1 January 2027. Defaults to today in the local calendar; tests
558
+ * and previews set it.
559
+ */
560
+ today?: string;
536
561
  }
537
562
  interface RenderedStatement {
538
563
  markdown: string;
@@ -551,5 +576,4 @@ interface RenderedStatement {
551
576
  * template branches on, so that no German sentence is assembled in TypeScript.
552
577
  */
553
578
  declare function renderStatement(config: EaaConfig, options?: RenderStatementOptions): Promise<RenderedStatement>;
554
- //#endregion
555
579
  export { ASSESSMENT_METHODS, type AssessmentMethod, type AuditFinding, type AuditSummary, COMPLIANCE_STATUSES, CONFIG_FILENAMES, COUNTRIES, type ComplianceStatus, ConfigError, type Country, type EaaConfig, type EaaConfigInput, type EvidenceInput, type EvidenceProblem, type EvidenceSeverity, type HtmlDocumentOptions, ISSUE_REASONS, type IssueReason, type KnownIssue, type LoadConfigOptions, type LoadedConfig, type RenderStatementOptions, type RenderedStatement, STATEMENT_LOCALES, StatementError, type StatementLocale, checkStatementEvidence, configSchema, defineConfig, findConfigFile, loadConfig, parseConfig, readAuditReport, refuses, renderStatement, summariseAuditReport, toHtmlBody, toHtmlDocument };
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
- import { a as ASSESSMENT_METHODS, c as ConfigError, d as configSchema, f as defineConfig, i as loadConfig, l as ISSUE_REASONS, n as findConfigFile, o as COMPLIANCE_STATUSES, p as parseConfig, s as COUNTRIES, t as CONFIG_FILENAMES, u as STATEMENT_LOCALES } from "./load-BaWMa-G_.js";
2
- import { a as summariseAuditReport, c as StatementError, i as readAuditReport, n as toHtmlBody, o as checkStatementEvidence, r as toHtmlDocument, s as refuses, t as renderStatement } from "./render-C1sUZZI_.js";
1
+ import { a as ISSUE_REASONS, c as configSchema, d as parseConfig, i as ConfigError, l as defineConfig, n as COMPLIANCE_STATUSES, r as COUNTRIES, s as STATEMENT_LOCALES, t as ASSESSMENT_METHODS } from "./define-BdTPIfqE.js";
2
+ import { i as loadConfig, n as findConfigFile, t as CONFIG_FILENAMES } from "./load-C3eFEdoH.js";
3
+ import { a as summariseAuditReport, c as StatementError, i as readAuditReport, n as toHtmlBody, o as checkStatementEvidence, r as toHtmlDocument, s as refuses, t as renderStatement } from "./render-ky8cm4QF.js";
3
4
  export { ASSESSMENT_METHODS, COMPLIANCE_STATUSES, CONFIG_FILENAMES, COUNTRIES, ConfigError, ISSUE_REASONS, STATEMENT_LOCALES, StatementError, checkStatementEvidence, configSchema, defineConfig, findConfigFile, loadConfig, parseConfig, readAuditReport, refuses, renderStatement, summariseAuditReport, toHtmlBody, toHtmlDocument };
@@ -0,0 +1,232 @@
1
+ import { n as DEFAULT_BASELINE_FILE } from "./baseline-CKElWbx4.js";
2
+ import { t as DEFAULT_FAIL_ON } from "./impact-BGlJ6j0Y.js";
3
+ import { a as findCountry, i as countryForLocale, t as COUNTRY_INFO } from "./countries-B_PE6r5R.js";
4
+ import { r as COUNTRIES } from "./define-BdTPIfqE.js";
5
+ import { t as CONFIG_FILENAMES } from "./load-C3eFEdoH.js";
6
+ import { t as exists } from "./fs-tPD5r0wY.js";
7
+ import { c as nextStep, d as warn, l as note, o as fail } from "./command-C8ZFvcc1.js";
8
+ import { n as CI_HOST_NAMES } from "./hosts-B48qR6Vt.js";
9
+ import { l as pipelineFor, o as detectCiHost, s as findGitRoot, u as pipelinePlan } from "./setup-Cf82ONw0.js";
10
+ import { mkdir, readFile, writeFile } from "node:fs/promises";
11
+ import path from "node:path";
12
+ import pc from "picocolors";
13
+ import { createInterface } from "node:readline/promises";
14
+ // src/cli/init.ts
15
+ /**
16
+ * Everything the project already says about itself.
17
+ *
18
+ * A guess that is wrong is worse than an empty field somebody has to fill, so
19
+ * this only reads what a project states outright.
20
+ */
21
+ async function detectDefaults(cwd) {
22
+ const detected = {};
23
+ try {
24
+ const pkg = JSON.parse(await readFile(path.join(cwd, "package.json"), "utf8"));
25
+ if (typeof pkg.name === "string" && pkg.name !== "") detected.name = pkg.name.replace(/^@[^/]+\//, "");
26
+ if (typeof pkg.homepage === "string" && /^https?:\/\//.test(pkg.homepage)) detected.url = pkg.homepage;
27
+ } catch {}
28
+ const site = await builtSite(cwd);
29
+ if (site !== void 0) {
30
+ const { readSiteFacts } = await import("./site-CxVyh8IO.js");
31
+ const facts = await readSiteFacts(site);
32
+ if (facts.url !== void 0) detected.url = facts.url;
33
+ if (facts.title !== void 0 && detected.name === void 0) detected.name = facts.title;
34
+ if (facts.lang !== void 0) {
35
+ detected.locale = facts.lang;
36
+ const country = countryForLocale(facts.lang);
37
+ if (country !== void 0) detected.country = country;
38
+ }
39
+ }
40
+ return detected;
41
+ }
42
+ /** The built site's directory, from the same search `audit` makes, without building. */
43
+ async function builtSite(cwd) {
44
+ const { autoDetectSource } = await import("./project-Dht13sb1.js");
45
+ const found = await autoDetectSource(cwd, { noBuild: true });
46
+ await found?.cleanup?.();
47
+ return found?.directory;
48
+ }
49
+ /** Whether a config is already there, so init never overwrites one silently. */
50
+ async function existingConfig(cwd) {
51
+ for (const name of CONFIG_FILENAMES) if (await exists(path.join(cwd, name))) return name;
52
+ }
53
+ /** Reads answers, showing what each will be if the reader just hits enter. */
54
+ function terminalPrompt() {
55
+ const rl = createInterface({
56
+ input: process.stdin,
57
+ output: process.stderr
58
+ });
59
+ return {
60
+ ask: async (question, fallback) => {
61
+ const shown = fallback === "" ? "" : pc.dim(` (${fallback})`);
62
+ const answer = (await rl.question(`${question}${shown}: `)).trim();
63
+ return answer === "" ? fallback : answer;
64
+ },
65
+ close: () => rl.close()
66
+ };
67
+ }
68
+ async function runInitCommand(options = {}) {
69
+ const cwd = await chooseSite(options.cwd ?? process.cwd(), options);
70
+ if (cwd === void 0) return { exitCode: 1 };
71
+ const target = path.resolve(cwd, options.output ?? "eaa.config.json");
72
+ const already = await existingConfig(cwd);
73
+ if (already !== void 0 && !options.force) {
74
+ warn(`${already} already exists, and init never overwrites one without being told to.`);
75
+ nextStep({
76
+ command: "eaa-kit init --force",
77
+ why: `start ${already} again from scratch`
78
+ });
79
+ return { exitCode: 1 };
80
+ }
81
+ const detected = await detectDefaults(cwd);
82
+ const terminal = options.ask === void 0 && !options.yes && process.stdin.isTTY === true ? terminalPrompt() : void 0;
83
+ const rl = options.ask ?? terminal?.ask;
84
+ const ask = async (question, fallback) => rl === void 0 ? fallback : rl(question, fallback);
85
+ if (rl !== void 0) process.stderr.write(`${pc.bold("eaa-kit init")}\n${pc.dim("Everything here is a claim you are making. Press enter to take a default.\n\n")}`);
86
+ const name = await ask("Site name", detected.name ?? "");
87
+ const url = await ask("Site URL", detected.url ?? "https://example.com");
88
+ const country = await askCountry(ask, rl !== void 0, detected.country);
89
+ const locale = await ask("Language of the site", detected.locale !== void 0 && detected.country === country ? detected.locale : COUNTRY_INFO[country].siteLocale);
90
+ const legalName = await ask("Legal entity answerable for the site", name);
91
+ const email = await ask("Feedback email", "");
92
+ const feedbackUrl = await ask("Feedback or contact form URL (optional)", "");
93
+ const site = options.baseline === false ? void 0 : await builtSite(cwd);
94
+ const recordBaseline = site !== void 0 && isYes(await ask("Record a baseline of the barriers the site has today, so CI fails only on new ones? (y/n)", "y"));
95
+ const root = options.ci === false ? void 0 : await findGitRoot(cwd);
96
+ const host = root === void 0 ? void 0 : options.ciHost ?? await detectCiHost(root);
97
+ const plan = root === void 0 || host === void 0 ? void 0 : await pipelinePlan(root, host);
98
+ if (plan !== void 0 && "refused" in plan) note(`No CI pipeline written: ${plan.refused}`);
99
+ const pipeline = plan !== void 0 && "file" in plan ? plan : void 0;
100
+ const writeWorkflow = pipeline !== void 0 && host !== void 0 && isYes(await ask(`Add a ${CI_HOST_NAMES[host]} that audits every push? (y/n)`, "y"));
101
+ terminal?.close();
102
+ let baseline;
103
+ if (recordBaseline && site !== void 0) {
104
+ const { runBaselineCommand } = await import("./baseline-DU0EPiTq.js");
105
+ if ((await runBaselineCommand(path.relative(cwd, site) || ".", { cwd })).exitCode === 0) baseline = DEFAULT_BASELINE_FILE;
106
+ } else if (await exists(path.join(cwd, "eaa-baseline.json"))) baseline = DEFAULT_BASELINE_FILE;
107
+ const config = {
108
+ site: {
109
+ name,
110
+ url,
111
+ locale
112
+ },
113
+ provider: {
114
+ legalName,
115
+ email,
116
+ ...feedbackUrl === "" ? {} : { feedbackUrl }
117
+ },
118
+ compliance: {
119
+ status: "partially-compliant",
120
+ assessedOn: (/* @__PURE__ */ new Date()).toISOString().slice(0, 10),
121
+ assessmentMethod: "self-assessment",
122
+ knownIssues: []
123
+ },
124
+ enforcement: { country },
125
+ audit: {
126
+ failOn: DEFAULT_FAIL_ON,
127
+ ...baseline === void 0 ? {} : { baseline }
128
+ }
129
+ };
130
+ try {
131
+ await writeFile(target, `${JSON.stringify(config, null, 2)}\n`, "utf8");
132
+ } catch (cause) {
133
+ const reason = cause instanceof Error ? cause.message : String(cause);
134
+ fail(`Could not write ${path.basename(target)}: ${reason}`);
135
+ return { exitCode: 2 };
136
+ }
137
+ process.stderr.write(`Wrote ${path.relative(cwd, target) || path.basename(target)}\n`);
138
+ const missing = [name === "" ? "site.name" : void 0, email === "" ? "provider.email" : void 0].filter((field) => field !== void 0);
139
+ if (missing.length > 0) {
140
+ const [verb, pronoun] = missing.length === 1 ? ["is", "it"] : ["are", "them"];
141
+ warn(`${missing.join(" and ")} ${verb} empty and required. Fill ${pronoun} in before generating a statement.`);
142
+ }
143
+ note("Read it before publishing anything from it: status is partially-compliant,\nwhich is the honest default before an audit has run.");
144
+ if (writeWorkflow && root !== void 0 && host !== void 0 && pipeline !== void 0) {
145
+ const file = path.join(root, pipeline.file);
146
+ const content = await pipelineFor(host, {
147
+ cwd,
148
+ root,
149
+ ...site === void 0 ? {} : { site },
150
+ ...baseline === void 0 ? {} : { baseline },
151
+ failOn: DEFAULT_FAIL_ON
152
+ });
153
+ try {
154
+ await mkdir(path.dirname(file), { recursive: true });
155
+ await writeFile(file, content, "utf8");
156
+ process.stderr.write(`Wrote ${path.relative(cwd, file)}\n`);
157
+ if (pipeline.include !== void 0) note(`.gitlab-ci.yml is already there, so the job went in a file of its own. Include it:\n\n include:\n - local: ${pipeline.include}\n`);
158
+ } catch (cause) {
159
+ warn(`Could not write ${pipeline.file}: ${cause instanceof Error ? cause.message : String(cause)}`);
160
+ }
161
+ }
162
+ note(`\nNext: eaa-kit statement${writeWorkflow ? " · commit and push to run the workflow" : " · eaa-kit audit"}`);
163
+ return {
164
+ file: target,
165
+ exitCode: 0
166
+ };
167
+ }
168
+ /**
169
+ * The directory to set up: `cwd`, or in a monorepo with several sites, the
170
+ * one the reader names. The config goes in that site, next to what it audits,
171
+ * and the workflow runs there. With nobody to ask, this refuses rather than
172
+ * picks: a config for the wrong site passes CI on a site nobody checked.
173
+ */
174
+ async function chooseSite(cwd, options) {
175
+ const { detectFramework } = await import("./frameworks-Y-n3NUuG.js");
176
+ const { readPackageJson } = await import("./project-Dht13sb1.js");
177
+ if (await detectFramework(cwd, await readPackageJson(cwd)) !== void 0) return cwd;
178
+ const { findWorkspaceSites } = await import("./workspaces-BBFXOyeV.js");
179
+ const sites = (await findWorkspaceSites(cwd))?.sites.map((site) => site.dir) ?? [];
180
+ if (sites.length < 2) return cwd;
181
+ if (!(options.ask !== void 0 || !options.yes && process.stdin.isTTY === true)) {
182
+ warn(`This is a monorepo with ${sites.length} sites; set up one at a time, inside it:`);
183
+ for (const site of sites) nextStep({
184
+ command: `cd ${site} && npx eaa-kit init`,
185
+ why: ""
186
+ });
187
+ return;
188
+ }
189
+ const terminal = options.ask === void 0 ? terminalPrompt() : void 0;
190
+ const ask = options.ask ?? terminal?.ask;
191
+ let answer;
192
+ try {
193
+ answer = ask === void 0 ? "" : await ask(`Which site is this for? (${sites.join(", ")})`, sites[0] ?? "");
194
+ } finally {
195
+ terminal?.close();
196
+ }
197
+ const chosen = sites.find((site) => site === answer.replace(/^\.\//, "").replace(/\/$/, ""));
198
+ if (chosen === void 0) {
199
+ fail(`${answer} is not one of the sites here: ${sites.join(", ")}`);
200
+ return;
201
+ }
202
+ return path.join(cwd, chosen);
203
+ }
204
+ function isYes(answer) {
205
+ return /^y(es)?$/i.test(answer.trim());
206
+ }
207
+ /** How often an answer that is not a country is asked again before giving up on it. */
208
+ const COUNTRY_ATTEMPTS = 3;
209
+ /**
210
+ * The country whose law the statement is written under.
211
+ *
212
+ * An answer that is not a country is asked again, with the list. It used to
213
+ * become Austria without a word, which is how somebody who typed `pl` got an
214
+ * Austrian legal document. Once the attempts run out the default is used,
215
+ * because a typo should not throw away every other answer, but it is said out
216
+ * loud, so the file is not left looking like the answer somebody gave.
217
+ */
218
+ async function askCountry(ask, interactive, suggested) {
219
+ const fallback = suggested ?? "AT";
220
+ const choices = COUNTRIES.map((code) => `${code} ${COUNTRY_INFO[code].name}`).join(", ");
221
+ if (interactive) process.stderr.write(pc.dim(`Countries: ${choices}\n`));
222
+ let answer = "";
223
+ for (let attempt = 0; attempt < COUNTRY_ATTEMPTS; attempt += 1) {
224
+ answer = await ask("Country whose law applies", fallback);
225
+ const country = findCountry(answer);
226
+ if (country !== void 0) return country;
227
+ warn(`${answer} is not one of the countries a statement can be written for: ${COUNTRIES.join(", ")}`);
228
+ }
229
+ warn(`enforcement.country is set to ${fallback} because ${answer} was not recognised. Change it before generating a statement.`);
230
+ return fallback;
231
+ }
232
+ export { existingConfig, runInitCommand };