eaa-kit 0.9.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.
- package/README.md +174 -149
- package/dist/astro/index.d.ts +1 -3
- package/dist/astro/index.js +2 -3
- package/dist/audit/runners/worker.js +2 -3
- package/dist/{audit-J2jeLo-y.js → audit-DbqNIrt6.js} +61 -35
- package/dist/audit-rUhqnm3o.js +1 -0
- package/dist/{baseline-DrFh7joZ.js → baseline-CKElWbx4.js} +4 -5
- package/dist/baseline-DU0EPiTq.js +1 -0
- package/dist/baseline-DYOejLFO.js +1 -0
- package/dist/{baseline-wyJsSIFQ.js → baseline-DvdsFTQy.js} +5 -6
- package/dist/{cache-D4dOIuOi.js → cache-DIV4G0TI.js} +24 -5
- package/dist/{checklist-Gx2g3LFC.js → checklist-CA0Ri71Z.js} +7 -8
- package/dist/cli/index.js +52 -35
- package/dist/{collect-BJYk7_pJ.js → collect-CjucwTEF.js} +16 -8
- package/dist/{command-BGGMf4vn.js → command-C8ZFvcc1.js} +6 -9
- package/dist/completeness-Cg-XIKWN.js +1 -0
- package/dist/completeness-Dzyvgr4Z.js +72 -0
- package/dist/component-CgbeRgJa.js +1 -0
- package/dist/{component-ChisoFyY.js → component-ZLd8DA_a.js} +3 -4
- package/dist/{countries-Dg0BdytB.js → countries-B_PE6r5R.js} +42 -18
- package/dist/{countries-DRTBubeE.js → countries-CCqog6dy.js} +10 -7
- package/dist/coverage-B9_6yv_8.js +2 -0
- package/dist/{coverage-zdzgSKjz.js → coverage-C1Z6t9Ct.js} +5 -7
- package/dist/{crawl-DwdqiljK.js → crawl-CkHJJV4w.js} +131 -23
- package/dist/{criteria-CnPJKGeb.js → criteria-CacF0HP1.js} +1 -2
- package/dist/{define-Ctf2uOEh.js → define-BdTPIfqE.js} +5 -5
- package/dist/detect-DnFHXpWh.js +49 -0
- package/dist/detect-oLDadgee.js +160 -0
- package/dist/doctor-q8IebwAb.js +248 -0
- package/dist/eleventy/index.d.ts +1 -3
- package/dist/eleventy/index.js +2 -3
- package/dist/{entry-CjqjrUBY.js → entry-kf94P140.js} +1 -2
- package/dist/{fingerprint-BjYV_0F7.js → fingerprint-CcoQ1WxQ.js} +1 -2
- package/dist/{frameworks-B4ClIJgE.js → frameworks-BboC8eNk.js} +234 -28
- package/dist/frameworks-Y-n3NUuG.js +1 -0
- package/dist/{fs-BmPtmFke.js → fs-tPD5r0wY.js} +1 -2
- package/dist/hosts-B48qR6Vt.js +19 -0
- package/dist/{html-whingnfj.js → html-Bjq3Iw3g.js} +54 -14
- package/dist/{impact-luGCnN8F.js → impact-BGlJ6j0Y.js} +1 -2
- package/dist/{impact-EEB9ZXmC.d.ts → impact-CZjUloYC.d.ts} +0 -2
- package/dist/index.d.ts +10 -23
- package/dist/index.js +3 -3
- package/dist/{init-CPbFVMuk.js → init-3Ti3ao5Z.js} +65 -126
- package/dist/issues-WLlepU95.js +120 -0
- package/dist/{jsdom-CsW_xVcA.js → jsdom-C4pLIMyP.js} +2 -3
- package/dist/jsdom-Zle--VQ1.js +2 -0
- package/dist/{json-SGCgxSPT.js → json-B_k4CDmR.js} +5 -6
- package/dist/json-IL1JxlTL.js +1 -0
- package/dist/{load-CH-ltdlq.js → load-C3eFEdoH.js} +3 -4
- package/dist/load-oQQJPNlV.js +1 -0
- package/dist/markdown-D-QpPYsz.js +138 -0
- package/dist/next-8zDgH0nP.js +119 -0
- package/dist/nuxt/index.d.ts +1 -3
- package/dist/nuxt/index.js +2 -3
- package/dist/{pages-DxY5Z0gl.js → pages-CCP1WfYe.js} +80 -17
- package/dist/{playwright-ukCr_5o3.js → playwright-ky4b_HME.js} +98 -16
- package/dist/{pool-B4tEUa2S.js → pool-B3XKdk57.js} +4 -5
- package/dist/project-B21NT_aX.js +502 -0
- package/dist/project-Dht13sb1.js +1 -0
- package/dist/{remediation-Bbs4KcX1.js → remediation-BkE7q7dT.js} +2 -193
- package/dist/{render-C6zYfaba.js → render-ky8cm4QF.js} +22 -20
- package/dist/result-DhoT4g0P.js +1 -0
- package/dist/{result-B7_zVxAX.js → result-g8dGsrcv.js} +1 -2
- package/dist/{review-Bz0fO9_I.js → review-BGjTBFvd.js} +2 -3
- package/dist/review-iheEjp7_.js +1 -0
- package/dist/{routes-CSctpS1P.js → routes-BpQeBDmM.js} +4 -5
- package/dist/{run-DzVEOkiF.js → run-D7tc7IU2.js} +2 -3
- package/dist/{run-BK2blxMI.d.ts → run-VXnP4uLp.d.ts} +2 -6
- package/dist/{sarif-9BAgNiOa.js → sarif-v66-PjdE.js} +7 -8
- package/dist/{schema-DJSF4K05.js → schema-DfC-Ww1w.js} +1 -2
- package/dist/setup-BYlqHlo0.js +2 -0
- package/dist/setup-Cf82ONw0.js +353 -0
- package/dist/shell-BdQYTaBQ.js +89 -0
- package/dist/{site-BHMtf3q2.js → site-CxVyh8IO.js} +1 -2
- package/dist/{start-DzOM0p6I.js → start-bdanSxZr.js} +9 -10
- package/dist/statement/templates/cz.cs.md +2 -1
- package/dist/statement/templates/cz.en.md +2 -1
- package/dist/statement/templates/dk.da.md +3 -2
- package/dist/statement/templates/dk.en.md +4 -3
- package/dist/statement/templates/pt.en.md +3 -2
- package/dist/statement/templates/pt.pt.md +3 -3
- package/dist/statement/templates/se.en.md +9 -0
- package/dist/statement/templates/se.sv.md +8 -0
- package/dist/{text-BF1LHMiV.js → text-CISDPU49.js} +11 -3
- package/dist/{version-B3v4rNoG.js → version-C8aJm8YJ.js} +1 -2
- package/dist/vite/index.d.ts +1 -3
- package/dist/vite/index.js +2 -3
- package/dist/{watch-B2RoUbo0.js → watch-CefxwMsZ.js} +3 -4
- package/dist/webpack/index.d.ts +1 -3
- package/dist/webpack/index.js +2 -3
- package/dist/{worksheet-B_kQ1pxq.js → worksheet-CcBo9G7s.js} +4 -5
- package/dist/workspaces-BBFXOyeV.js +85 -0
- package/package.json +15 -13
- package/dist/audit-CJDCQaFY.js +0 -2
- package/dist/baseline-477B1CZ_.js +0 -2
- package/dist/baseline-D9ihb-wk.js +0 -2
- package/dist/component-DcCn3BJS.js +0 -2
- package/dist/coverage-GvaMpV64.js +0 -3
- package/dist/frameworks-etFg_O8K.js +0 -2
- package/dist/jsdom-BUYuVJJm.js +0 -3
- package/dist/json-CyLmvF5P.js +0 -2
- package/dist/load-D7lBeOsq.js +0 -2
- package/dist/project-BLFdCbOq.js +0 -2
- package/dist/project-v2PoRw70.js +0 -291
- package/dist/result-CRmjjoAA.js +0 -2
- package/dist/review-a-2ghjQ5.js +0 -2
|
@@ -1,119 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { t as
|
|
4
|
-
import {
|
|
5
|
-
import { t as
|
|
6
|
-
import {
|
|
7
|
-
import { c as nextStep, d as warn, l as note, o as fail } from "./command-
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { mkdir, readFile,
|
|
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
11
|
import path from "node:path";
|
|
12
12
|
import pc from "picocolors";
|
|
13
13
|
import { createInterface } from "node:readline/promises";
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* The CI half of `eaa-kit init`: a GitHub Actions workflow written for this
|
|
17
|
-
* project rather than copied from the docs and edited until it works.
|
|
18
|
-
*
|
|
19
|
-
* Everything in it is read from the project. The package manager comes from
|
|
20
|
-
* the lockfile, the build from the `build` script, the directory from what
|
|
21
|
-
* `init` found, and the baseline from whether one was just recorded. Anything
|
|
22
|
-
* it cannot read is left to the action's own detection rather than guessed,
|
|
23
|
-
* because a workflow that fails on its first push teaches somebody to switch
|
|
24
|
-
* it off.
|
|
25
|
-
*/
|
|
26
|
-
/** Where the workflow goes, relative to the repository root. */
|
|
27
|
-
const WORKFLOW_FILE = path.join(".github", "workflows", "accessibility.yml");
|
|
28
|
-
/** The repository this project is in, found the way git finds it: upwards. */
|
|
29
|
-
async function findGitRoot(cwd) {
|
|
30
|
-
let current = path.resolve(cwd);
|
|
31
|
-
for (;;) try {
|
|
32
|
-
await stat(path.join(current, ".git"));
|
|
33
|
-
return current;
|
|
34
|
-
} catch {
|
|
35
|
-
const parent = path.dirname(current);
|
|
36
|
-
if (parent === current) return void 0;
|
|
37
|
-
current = parent;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
/** The branch HEAD points at, which is the one worth auditing on push. */
|
|
41
|
-
async function currentBranch(root) {
|
|
42
|
-
try {
|
|
43
|
-
const head = await readFile(path.join(root, ".git", "HEAD"), "utf8");
|
|
44
|
-
return /^ref: refs\/heads\/(.+)$/m.exec(head)?.[1]?.trim();
|
|
45
|
-
} catch {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* The workflow, as text. YAML is written by hand rather than through a
|
|
51
|
-
* library: it is one fixed shape with a few values in it, and the comments in
|
|
52
|
-
* it are the documentation somebody reads when it first fails.
|
|
53
|
-
*/
|
|
54
|
-
async function workflowFor(inputs) {
|
|
55
|
-
const pkg = await readPackageJson(inputs.cwd);
|
|
56
|
-
const manager = pkg === void 0 ? void 0 : await detectPackageManager(inputs.cwd);
|
|
57
|
-
const branch = await currentBranch(inputs.root) ?? "main";
|
|
58
|
-
const workingDirectory = toPosix(path.relative(inputs.root, inputs.cwd));
|
|
59
|
-
const directory = inputs.site === void 0 ? "" : toPosix(path.relative(inputs.cwd, inputs.site)) || ".";
|
|
60
|
-
const setup = [];
|
|
61
|
-
if (manager === "pnpm") setup.push(" - uses: pnpm/action-setup@v4", ...typeof pkg?.packageManager === "string" ? [] : [" with:", " version: 10"]);
|
|
62
|
-
if (manager === "bun") setup.push(" - uses: oven-sh/setup-bun@v2");
|
|
63
|
-
const install = manager === void 0 ? void 0 : {
|
|
64
|
-
npm: "npm ci",
|
|
65
|
-
pnpm: "pnpm install --frozen-lockfile",
|
|
66
|
-
yarn: "yarn install --frozen-lockfile",
|
|
67
|
-
bun: "bun install --frozen-lockfile"
|
|
68
|
-
}[manager];
|
|
69
|
-
const build = manager !== void 0 && pkg?.scripts?.["build"] !== void 0 ? `${manager} run build` : void 0;
|
|
70
|
-
const withLines = [
|
|
71
|
-
...workingDirectory === "" ? [] : [`working-directory: ${workingDirectory}`],
|
|
72
|
-
...install === void 0 ? [] : [`install-command: ${install}`],
|
|
73
|
-
...build === void 0 ? [] : [`build-command: ${build}`],
|
|
74
|
-
`directory: ${directory === "" ? "''" : directory}`,
|
|
75
|
-
`fail-on: ${inputs.failOn}`,
|
|
76
|
-
...inputs.baseline === void 0 ? [] : [`baseline: ${toPosix(inputs.baseline)}`]
|
|
77
|
-
].map((line) => ` ${line}`);
|
|
78
|
-
return [
|
|
79
|
-
"# Written by eaa-kit init. Audits the built site against WCAG 2.2 AA on every",
|
|
80
|
-
"# push and pull request, uploads what it finds to GitHub code scanning, and",
|
|
81
|
-
"# fails the job on barriers at or above fail-on.",
|
|
82
|
-
"#",
|
|
83
|
-
"# The inputs are documented at",
|
|
84
|
-
"# https://github.com/likeBloodMoon/eaa-kit/blob/master/docs/integrations.md#github-actions",
|
|
85
|
-
"name: Accessibility",
|
|
86
|
-
"",
|
|
87
|
-
"on:",
|
|
88
|
-
" push:",
|
|
89
|
-
` branches: [${branch}]`,
|
|
90
|
-
" pull_request:",
|
|
91
|
-
"",
|
|
92
|
-
"permissions:",
|
|
93
|
-
" contents: read",
|
|
94
|
-
" # Required by the SARIF upload to code scanning.",
|
|
95
|
-
" security-events: write",
|
|
96
|
-
"",
|
|
97
|
-
"jobs:",
|
|
98
|
-
" audit:",
|
|
99
|
-
" runs-on: ubuntu-latest",
|
|
100
|
-
" steps:",
|
|
101
|
-
" - uses: actions/checkout@v4",
|
|
102
|
-
...setup,
|
|
103
|
-
" - uses: actions/setup-node@v4",
|
|
104
|
-
" with:",
|
|
105
|
-
" node-version: 22",
|
|
106
|
-
` - uses: likeBloodMoon/eaa-kit@v${TOOL_VERSION}`,
|
|
107
|
-
" with:",
|
|
108
|
-
...withLines,
|
|
109
|
-
""
|
|
110
|
-
].join("\n");
|
|
111
|
-
}
|
|
112
|
-
function toPosix(value) {
|
|
113
|
-
return value.split(path.sep).join("/");
|
|
114
|
-
}
|
|
115
|
-
//#endregion
|
|
116
|
-
//#region src/cli/init.ts
|
|
14
|
+
// src/cli/init.ts
|
|
117
15
|
/**
|
|
118
16
|
* Everything the project already says about itself.
|
|
119
17
|
*
|
|
@@ -129,7 +27,7 @@ async function detectDefaults(cwd) {
|
|
|
129
27
|
} catch {}
|
|
130
28
|
const site = await builtSite(cwd);
|
|
131
29
|
if (site !== void 0) {
|
|
132
|
-
const { readSiteFacts } = await import("./site-
|
|
30
|
+
const { readSiteFacts } = await import("./site-CxVyh8IO.js");
|
|
133
31
|
const facts = await readSiteFacts(site);
|
|
134
32
|
if (facts.url !== void 0) detected.url = facts.url;
|
|
135
33
|
if (facts.title !== void 0 && detected.name === void 0) detected.name = facts.title;
|
|
@@ -143,7 +41,7 @@ async function detectDefaults(cwd) {
|
|
|
143
41
|
}
|
|
144
42
|
/** The built site's directory, from the same search `audit` makes, without building. */
|
|
145
43
|
async function builtSite(cwd) {
|
|
146
|
-
const { autoDetectSource } = await import("./project-
|
|
44
|
+
const { autoDetectSource } = await import("./project-Dht13sb1.js");
|
|
147
45
|
const found = await autoDetectSource(cwd, { noBuild: true });
|
|
148
46
|
await found?.cleanup?.();
|
|
149
47
|
return found?.directory;
|
|
@@ -168,7 +66,8 @@ function terminalPrompt() {
|
|
|
168
66
|
};
|
|
169
67
|
}
|
|
170
68
|
async function runInitCommand(options = {}) {
|
|
171
|
-
const cwd = options.cwd ?? process.cwd();
|
|
69
|
+
const cwd = await chooseSite(options.cwd ?? process.cwd(), options);
|
|
70
|
+
if (cwd === void 0) return { exitCode: 1 };
|
|
172
71
|
const target = path.resolve(cwd, options.output ?? "eaa.config.json");
|
|
173
72
|
const already = await existingConfig(cwd);
|
|
174
73
|
if (already !== void 0 && !options.force) {
|
|
@@ -194,12 +93,15 @@ async function runInitCommand(options = {}) {
|
|
|
194
93
|
const site = options.baseline === false ? void 0 : await builtSite(cwd);
|
|
195
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"));
|
|
196
95
|
const root = options.ci === false ? void 0 : await findGitRoot(cwd);
|
|
197
|
-
const
|
|
198
|
-
const
|
|
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"));
|
|
199
101
|
terminal?.close();
|
|
200
102
|
let baseline;
|
|
201
103
|
if (recordBaseline && site !== void 0) {
|
|
202
|
-
const { runBaselineCommand } = await import("./baseline-
|
|
104
|
+
const { runBaselineCommand } = await import("./baseline-DU0EPiTq.js");
|
|
203
105
|
if ((await runBaselineCommand(path.relative(cwd, site) || ".", { cwd })).exitCode === 0) baseline = DEFAULT_BASELINE_FILE;
|
|
204
106
|
} else if (await exists(path.join(cwd, "eaa-baseline.json"))) baseline = DEFAULT_BASELINE_FILE;
|
|
205
107
|
const config = {
|
|
@@ -239,8 +141,9 @@ async function runInitCommand(options = {}) {
|
|
|
239
141
|
warn(`${missing.join(" and ")} ${verb} empty and required. Fill ${pronoun} in before generating a statement.`);
|
|
240
142
|
}
|
|
241
143
|
note("Read it before publishing anything from it: status is partially-compliant,\nwhich is the honest default before an audit has run.");
|
|
242
|
-
if (writeWorkflow && root !== void 0 &&
|
|
243
|
-
const
|
|
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, {
|
|
244
147
|
cwd,
|
|
245
148
|
root,
|
|
246
149
|
...site === void 0 ? {} : { site },
|
|
@@ -248,11 +151,12 @@ async function runInitCommand(options = {}) {
|
|
|
248
151
|
failOn: DEFAULT_FAIL_ON
|
|
249
152
|
});
|
|
250
153
|
try {
|
|
251
|
-
await mkdir(path.dirname(
|
|
252
|
-
await writeFile(
|
|
253
|
-
process.stderr.write(`Wrote ${path.relative(cwd,
|
|
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`);
|
|
254
158
|
} catch (cause) {
|
|
255
|
-
warn(`Could not write ${
|
|
159
|
+
warn(`Could not write ${pipeline.file}: ${cause instanceof Error ? cause.message : String(cause)}`);
|
|
256
160
|
}
|
|
257
161
|
}
|
|
258
162
|
note(`\nNext: eaa-kit statement${writeWorkflow ? " · commit and push to run the workflow" : " · eaa-kit audit"}`);
|
|
@@ -261,6 +165,42 @@ async function runInitCommand(options = {}) {
|
|
|
261
165
|
exitCode: 0
|
|
262
166
|
};
|
|
263
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
|
+
}
|
|
264
204
|
function isYes(answer) {
|
|
265
205
|
return /^y(es)?$/i.test(answer.trim());
|
|
266
206
|
}
|
|
@@ -289,5 +229,4 @@ async function askCountry(ask, interactive, suggested) {
|
|
|
289
229
|
warn(`enforcement.country is set to ${fallback} because ${answer} was not recognised. Change it before generating a statement.`);
|
|
290
230
|
return fallback;
|
|
291
231
|
}
|
|
292
|
-
//#endregion
|
|
293
232
|
export { existingConfig, runInitCommand };
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { t as elementFingerprint } from "./fingerprint-CcoQ1WxQ.js";
|
|
2
|
+
import { o as impactRank } from "./impact-BGlJ6j0Y.js";
|
|
3
|
+
import { s as findingElements } from "./result-g8dGsrcv.js";
|
|
4
|
+
/** Whether this element looks like one component rendered on many pages. */
|
|
5
|
+
function isShared(element) {
|
|
6
|
+
return element.pages.length >= 3;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Fold a run's violations into one entry per rule, and one per element within it.
|
|
10
|
+
*
|
|
11
|
+
* Accepted violations are not included: a baseline moves them out of what fails
|
|
12
|
+
* the build, and this is a view of what fails.
|
|
13
|
+
*/
|
|
14
|
+
function groupIssues(audits) {
|
|
15
|
+
const byRule = /* @__PURE__ */ new Map();
|
|
16
|
+
for (const audit of audits) for (const finding of audit.violations) {
|
|
17
|
+
let issue = byRule.get(finding.ruleId);
|
|
18
|
+
if (issue === void 0) {
|
|
19
|
+
issue = {
|
|
20
|
+
ruleId: finding.ruleId,
|
|
21
|
+
help: finding.help,
|
|
22
|
+
impact: finding.impact ?? null,
|
|
23
|
+
successCriteria: finding.successCriteria,
|
|
24
|
+
enClauses: finding.enClauses,
|
|
25
|
+
helpUrl: finding.helpUrl,
|
|
26
|
+
elements: [],
|
|
27
|
+
pages: [],
|
|
28
|
+
occurrences: 0
|
|
29
|
+
};
|
|
30
|
+
byRule.set(finding.ruleId, issue);
|
|
31
|
+
}
|
|
32
|
+
if (!issue.pages.includes(audit.relativePath)) issue.pages.push(audit.relativePath);
|
|
33
|
+
for (const node of findingElements(finding)) {
|
|
34
|
+
issue.occurrences += 1;
|
|
35
|
+
const fingerprint = elementFingerprint(finding.ruleId, node.selector, node.html);
|
|
36
|
+
const existing = issue.elements.find((element) => element.fingerprint === fingerprint);
|
|
37
|
+
if (existing) {
|
|
38
|
+
if (!existing.pages.includes(audit.relativePath)) existing.pages.push(audit.relativePath);
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
issue.elements.push({
|
|
42
|
+
fingerprint,
|
|
43
|
+
selector: node.selector,
|
|
44
|
+
html: node.html,
|
|
45
|
+
pages: [audit.relativePath]
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const issues = [...byRule.values()];
|
|
50
|
+
for (const issue of issues) {
|
|
51
|
+
issue.pages.sort();
|
|
52
|
+
for (const element of issue.elements) element.pages.sort();
|
|
53
|
+
issue.elements.sort(byReachThenSelector);
|
|
54
|
+
}
|
|
55
|
+
issues.sort(bySeverityThenReach);
|
|
56
|
+
return issues;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* What the grouped issues add up to: distinct elements, and the violations they
|
|
60
|
+
* account for. Both reports open their issues section with these two numbers,
|
|
61
|
+
* and say something different when they are equal.
|
|
62
|
+
*/
|
|
63
|
+
function issueTotals(issues) {
|
|
64
|
+
let elements = 0;
|
|
65
|
+
let occurrences = 0;
|
|
66
|
+
for (const issue of issues) {
|
|
67
|
+
elements += issue.elements.length;
|
|
68
|
+
occurrences += issue.occurrences;
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
elements,
|
|
72
|
+
occurrences
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Unevaluated rules folded across the site, sorted by rule id.
|
|
77
|
+
*
|
|
78
|
+
* Both reports list these once at the end rather than under every page: on a
|
|
79
|
+
* large site the same handful recurs on each one, and a wall of "not evaluated"
|
|
80
|
+
* would bury the findings that are real.
|
|
81
|
+
*/
|
|
82
|
+
function blindRules(audits) {
|
|
83
|
+
const byRule = /* @__PURE__ */ new Map();
|
|
84
|
+
for (const audit of audits) for (const finding of audit.incomplete) {
|
|
85
|
+
if (finding.reason !== "engine-limitation") continue;
|
|
86
|
+
const entry = byRule.get(finding.ruleId);
|
|
87
|
+
if (entry) entry.pages += 1;
|
|
88
|
+
else byRule.set(finding.ruleId, {
|
|
89
|
+
ruleId: finding.ruleId,
|
|
90
|
+
pages: 1,
|
|
91
|
+
finding
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
return [...byRule.values()].sort((a, b) => a.ruleId.localeCompare(b.ruleId));
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* What one page's result actually rests on, as phrases both reports print.
|
|
98
|
+
*
|
|
99
|
+
* The counts stay separate on purpose. Only `passed` is evidence that a
|
|
100
|
+
* criterion was met here; `not applicable` means the rule found nothing to
|
|
101
|
+
* check, and adding the two together would turn an empty page into a
|
|
102
|
+
* near-perfect score.
|
|
103
|
+
*/
|
|
104
|
+
function coverageParts(audit) {
|
|
105
|
+
const blind = audit.incomplete.filter((finding) => finding.reason === "engine-limitation").length;
|
|
106
|
+
const review = audit.incomplete.length - blind;
|
|
107
|
+
const parts = [`${audit.passes.length} passed`, `${audit.inapplicable.length} not applicable`];
|
|
108
|
+
if (review > 0) parts.push(`${review} to review`);
|
|
109
|
+
if (blind > 0) parts.push(`${blind} not evaluated`);
|
|
110
|
+
return parts;
|
|
111
|
+
}
|
|
112
|
+
/** Widest reach first, then by selector so two runs agree. */
|
|
113
|
+
function byReachThenSelector(a, b) {
|
|
114
|
+
return b.pages.length - a.pages.length || a.selector.localeCompare(b.selector);
|
|
115
|
+
}
|
|
116
|
+
/** Worst first, then widest reach, then by rule id. */
|
|
117
|
+
function bySeverityThenReach(a, b) {
|
|
118
|
+
return impactRank(a.impact) - impactRank(b.impact) || b.pages.length - a.pages.length || a.ruleId.localeCompare(b.ruleId);
|
|
119
|
+
}
|
|
120
|
+
export { issueTotals as a, isShared as i, coverageParts as n, groupIssues as r, blindRules as t };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { c as pageUrl, d as runOptions, f as shapeResults, i as blindRulesInScope, n as DEFAULT_TAGS, o as failedPage } from "./result-
|
|
1
|
+
import { c as pageUrl, d as runOptions, f as shapeResults, i as blindRulesInScope, n as DEFAULT_TAGS, o as failedPage } from "./result-g8dGsrcv.js";
|
|
2
2
|
import axe from "axe-core";
|
|
3
3
|
import { Script } from "node:vm";
|
|
4
4
|
import { JSDOM, VirtualConsole } from "jsdom";
|
|
5
|
-
|
|
5
|
+
// src/audit/runners/jsdom.ts
|
|
6
6
|
/**
|
|
7
7
|
* Audit collected pages with axe-core inside jsdom.
|
|
8
8
|
*
|
|
@@ -84,5 +84,4 @@ async function withTimeout(promise, ms) {
|
|
|
84
84
|
clearTimeout(timer);
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
|
-
//#endregion
|
|
88
87
|
export { runJsdomAudit as n, auditPage as t };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as
|
|
3
|
-
import { t as elementFingerprint } from "./fingerprint-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { t as TOOL_VERSION } from "./version-C8aJm8YJ.js";
|
|
2
|
+
import { t as buildCoverage } from "./coverage-C1Z6t9Ct.js";
|
|
3
|
+
import { t as elementFingerprint } from "./fingerprint-CcoQ1WxQ.js";
|
|
4
|
+
import { a as impactLabel, i as countAtOrAbove, s as isImpactLevel } from "./impact-BGlJ6j0Y.js";
|
|
5
|
+
import { m as uniqueRuleOutcomes, u as runEngine } from "./result-g8dGsrcv.js";
|
|
6
6
|
import axe from "axe-core";
|
|
7
7
|
/**
|
|
8
8
|
* Build the machine-readable report.
|
|
@@ -130,5 +130,4 @@ function toJsonIncomplete(finding) {
|
|
|
130
130
|
function byRuleId(a, b) {
|
|
131
131
|
return a.ruleId.localeCompare(b.ruleId);
|
|
132
132
|
}
|
|
133
|
-
//#endregion
|
|
134
133
|
export { buildSummary as n, serialiseJsonReport as r, buildJsonReport as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as buildJsonReport, r as serialiseJsonReport } from "./json-B_k4CDmR.js";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { r as isFile } from "./fs-tPD5r0wY.js";
|
|
2
|
+
import { d as parseConfig, i as ConfigError, u as parseAuditConfig } from "./define-BdTPIfqE.js";
|
|
3
3
|
import { readFile } from "node:fs/promises";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { pathToFileURL } from "node:url";
|
|
6
|
-
|
|
6
|
+
// src/config/load.ts
|
|
7
7
|
/** Checked in this order, first match wins. */
|
|
8
8
|
const CONFIG_FILENAMES = [
|
|
9
9
|
"eaa.config.ts",
|
|
@@ -95,5 +95,4 @@ async function importModule(file) {
|
|
|
95
95
|
if (module.default === void 0) throw new ConfigError(`${path.basename(file)} has no default export`, ["Expected: export default defineConfig({ … })"]);
|
|
96
96
|
return module.default;
|
|
97
97
|
}
|
|
98
|
-
//#endregion
|
|
99
98
|
export { loadConfig as i, findConfigFile as n, loadAuditConfig as r, CONFIG_FILENAMES as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { n as findConfigFile, r as loadAuditConfig, i as loadConfig } from "./load-C3eFEdoH.js";
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { n as count } from "./text-CISDPU49.js";
|
|
2
|
+
import { t as TOOL_VERSION } from "./version-C8aJm8YJ.js";
|
|
3
|
+
import { n as missedParts } from "./completeness-Dzyvgr4Z.js";
|
|
4
|
+
import { a as impactLabel, c as meetsThreshold } from "./impact-BGlJ6j0Y.js";
|
|
5
|
+
import { r as groupIssues, t as blindRules } from "./issues-WLlepU95.js";
|
|
6
|
+
import { n as buildSummary } from "./json-B_k4CDmR.js";
|
|
7
|
+
// src/audit/report/markdown.ts
|
|
8
|
+
/**
|
|
9
|
+
* A Markdown summary of a run, for a CI job summary or a pull request comment.
|
|
10
|
+
*
|
|
11
|
+
* The other reports describe the site. This one describes the change: it is
|
|
12
|
+
* read by somebody looking at one push, who wants to know whether that push
|
|
13
|
+
* added a barrier, and who will not scroll. So it leads with the verdict, lists
|
|
14
|
+
* only what fails the run, and with a baseline it separates what this change
|
|
15
|
+
* introduced from what the project had already accepted.
|
|
16
|
+
*
|
|
17
|
+
* It keeps the refusals the other reports make. Rules the engine could not
|
|
18
|
+
* evaluate and pages the run never reached are said in the summary itself, not
|
|
19
|
+
* left for a reader to infer from a green tick, and nothing here is a
|
|
20
|
+
* conformance claim.
|
|
21
|
+
*
|
|
22
|
+
* GitHub caps a comment at 65,536 characters and a job summary at 1 MiB, and a
|
|
23
|
+
* site with a broken shared component can produce thousands of elements. The
|
|
24
|
+
* lists are bounded, and what was cut is counted.
|
|
25
|
+
*/
|
|
26
|
+
/** Rules listed in the table before the rest are counted. */
|
|
27
|
+
const MAX_RULES = 25;
|
|
28
|
+
/** Pages named per rule before the rest are counted. */
|
|
29
|
+
const MAX_PAGES = 3;
|
|
30
|
+
function buildMarkdownReport(audits, options) {
|
|
31
|
+
const totals = buildSummary(audits, options.failOn);
|
|
32
|
+
const issues = groupIssues(audits);
|
|
33
|
+
const failing = issues.filter((issue) => fails(issue, options.failOn));
|
|
34
|
+
const below = issues.filter((issue) => !fails(issue, options.failOn));
|
|
35
|
+
const blind = blindRules(audits).length;
|
|
36
|
+
const review = needsReviewRules(audits);
|
|
37
|
+
const lines = [
|
|
38
|
+
"## Accessibility audit",
|
|
39
|
+
"",
|
|
40
|
+
verdict(totals, failing, options),
|
|
41
|
+
""
|
|
42
|
+
];
|
|
43
|
+
lines.push("| | |", "| --- | ---: |");
|
|
44
|
+
lines.push(`| ${newLabel(options)} at or above ${options.failOn} | ${totals.failing} |`);
|
|
45
|
+
if (below.length > 0) lines.push(`| Violations below ${options.failOn}, not failing | ${belowCount(below, audits)} |`);
|
|
46
|
+
if (options.baseline) {
|
|
47
|
+
lines.push(`| Elements the baseline accepts | ${totals.accepted} |`);
|
|
48
|
+
if (options.baseline.stale > 0) lines.push(`| Baseline entries now fixed or gone | ${options.baseline.stale} |`);
|
|
49
|
+
if (options.baseline.expired > 0) lines.push(`| Baseline entries expired | ${options.baseline.expired} |`);
|
|
50
|
+
}
|
|
51
|
+
lines.push(`| Rules that need a person to decide | ${review} |`);
|
|
52
|
+
lines.push(`| Rules this engine could not evaluate | ${blind} |`);
|
|
53
|
+
lines.push(`| Pages audited | ${totals.pages - totals.pagesNotAudited} |`);
|
|
54
|
+
if (totals.pagesNotAudited > 0) lines.push(`| Pages that could not be audited | ${totals.pagesNotAudited} |`);
|
|
55
|
+
lines.push("");
|
|
56
|
+
if (failing.length > 0) {
|
|
57
|
+
lines.push(`### ${options.baseline ? "New barriers" : "Barriers that fail the run"}`, "");
|
|
58
|
+
lines.push(...issueTable(failing));
|
|
59
|
+
}
|
|
60
|
+
const unmeasured = notMeasured(options, blind, totals.pagesNotAudited);
|
|
61
|
+
if (unmeasured.length > 0) lines.push("### Not checked by this run", "", ...unmeasured.map((part) => `- ${part}`), "");
|
|
62
|
+
lines.push(`<sub>eaa-kit ${TOOL_VERSION} · ${escapeCell(options.directory)} · Automated testing finds only some barriers. This is not a conformance claim.</sub>`, "");
|
|
63
|
+
return lines.join("\n");
|
|
64
|
+
}
|
|
65
|
+
/** One line a reader can stop at. */
|
|
66
|
+
function verdict(totals, failing, options) {
|
|
67
|
+
if (totals.pagesNotAudited > 0) return `**Could not finish.** ${count(totals.pagesNotAudited, "page")} could not be audited, so this run reached no verdict.`;
|
|
68
|
+
if (failing.length > 0) {
|
|
69
|
+
const what = options.baseline ? "new violation" : "violation";
|
|
70
|
+
return `**${count(totals.failing, what)}** at or above ${options.failOn}, across ${count(failing.length, "rule")}.`;
|
|
71
|
+
}
|
|
72
|
+
const prefix = options.baseline ? "No new violations" : "No violations";
|
|
73
|
+
const completeness = options.completeness;
|
|
74
|
+
if (completeness && !completeness.complete) return `**${prefix} found, but the whole site was not measured.** ${missedParts(completeness).join(", ")}.`;
|
|
75
|
+
return `**${prefix} found** at or above ${options.failOn}.`;
|
|
76
|
+
}
|
|
77
|
+
function newLabel(options) {
|
|
78
|
+
return options.baseline ? "New violations" : "Violations";
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The failing rules, worst first, with where they are.
|
|
82
|
+
*
|
|
83
|
+
* Elements rather than occurrences: one broken header on forty pages is one
|
|
84
|
+
* thing to fix, and the reader of a pull request is deciding what to fix.
|
|
85
|
+
*/
|
|
86
|
+
function issueTable(issues) {
|
|
87
|
+
const lines = ["| Severity | Rule | WCAG | Elements | Pages |", "| --- | --- | --- | ---: | --- |"];
|
|
88
|
+
for (const issue of issues.slice(0, MAX_RULES)) {
|
|
89
|
+
const criteria = issue.successCriteria.join(", ") || "–";
|
|
90
|
+
lines.push(`| ${impactLabel(issue.impact)} | [\`${issue.ruleId}\`](${issue.helpUrl}) ${escapeCell(issue.help)} | ${criteria} | ${issue.elements.length} | ${pageList(issue.pages)} |`);
|
|
91
|
+
}
|
|
92
|
+
if (issues.length > MAX_RULES) lines.push("", `${count(issues.length - MAX_RULES, "more rule")} not listed. The HTML or JSON report has them all.`);
|
|
93
|
+
lines.push("");
|
|
94
|
+
return lines;
|
|
95
|
+
}
|
|
96
|
+
function pageList(pages) {
|
|
97
|
+
const named = pages.slice(0, MAX_PAGES).map((page) => `\`${escapeCode(page)}\``);
|
|
98
|
+
const rest = pages.length - named.length;
|
|
99
|
+
return rest > 0 ? `${named.join(", ")} and ${rest} more` : named.join(", ");
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* What the run never looked at, in the summary rather than behind a link: a
|
|
103
|
+
* green summary over half a site is the result most worth qualifying.
|
|
104
|
+
*/
|
|
105
|
+
function notMeasured(options, blind, unaudited) {
|
|
106
|
+
const parts = [];
|
|
107
|
+
const completeness = options.completeness;
|
|
108
|
+
if (completeness && !completeness.complete) parts.push(...missedParts(completeness));
|
|
109
|
+
if (unaudited > 0) parts.push(`${count(unaudited, "page")} could not be audited`);
|
|
110
|
+
if (blind > 0) parts.push(`${count(blind, "rule")} this engine could not evaluate, such as colour contrast without a browser. They are not counted as passes.`);
|
|
111
|
+
return parts;
|
|
112
|
+
}
|
|
113
|
+
/** The same test `--fail-on` applies, unclassified included. */
|
|
114
|
+
function fails(issue, failOn) {
|
|
115
|
+
return meetsThreshold(issue.impact, failOn);
|
|
116
|
+
}
|
|
117
|
+
/** Violations below the threshold, counted the way `summary.violations` counts them. */
|
|
118
|
+
function belowCount(below, audits) {
|
|
119
|
+
const rules = new Set(below.map((issue) => issue.ruleId));
|
|
120
|
+
let total = 0;
|
|
121
|
+
for (const audit of audits) for (const finding of audit.violations) if (rules.has(finding.ruleId)) total += 1;
|
|
122
|
+
return total;
|
|
123
|
+
}
|
|
124
|
+
/** Distinct rules that want a person, not one per page. */
|
|
125
|
+
function needsReviewRules(audits) {
|
|
126
|
+
const rules = /* @__PURE__ */ new Set();
|
|
127
|
+
for (const audit of audits) for (const finding of audit.incomplete) if (finding.reason === "needs-review") rules.add(finding.ruleId);
|
|
128
|
+
return rules.size;
|
|
129
|
+
}
|
|
130
|
+
/** Text in a table cell: a pipe or a newline would end the cell or the row. */
|
|
131
|
+
function escapeCell(text) {
|
|
132
|
+
return text.replace(/\s+/g, " ").replace(/[\\|`*_[\]<>]/g, (char) => `\\${char}`).trim();
|
|
133
|
+
}
|
|
134
|
+
/** Text inside backticks: a backtick would close the span early. */
|
|
135
|
+
function escapeCode(text) {
|
|
136
|
+
return text.replace(/`/g, "'").replace(/\|/g, "\\|");
|
|
137
|
+
}
|
|
138
|
+
export { buildMarkdownReport };
|