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.
- package/README.md +182 -135
- 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-DRjAY2iY.js → audit-DbqNIrt6.js} +85 -219
- package/dist/audit-rUhqnm3o.js +1 -0
- package/dist/{baseline-BpE7DbDq.js → baseline-CKElWbx4.js} +18 -8
- package/dist/baseline-DU0EPiTq.js +1 -0
- package/dist/baseline-DYOejLFO.js +1 -0
- package/dist/baseline-DvdsFTQy.js +126 -0
- package/dist/{cache-D4dOIuOi.js → cache-DIV4G0TI.js} +24 -5
- package/dist/{checklist-DDd9jewi.js → checklist-CA0Ri71Z.js} +8 -9
- package/dist/cli/index.js +115 -158
- package/dist/{collect-Cu1q9NTB.js → collect-CjucwTEF.js} +16 -8
- package/dist/{command-3r4fht5f.js → command-C8ZFvcc1.js} +33 -10
- 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-B_PE6r5R.js +180 -0
- package/dist/countries-CCqog6dy.js +28 -0
- package/dist/coverage-B9_6yv_8.js +2 -0
- package/dist/{coverage-cb5kPp48.js → coverage-C1Z6t9Ct.js} +5 -7
- package/dist/{crawl-BHkJmUkA.js → crawl-CkHJJV4w.js} +135 -25
- package/dist/{criteria-CnPJKGeb.js → criteria-CacF0HP1.js} +1 -2
- package/dist/{load-BaWMa-G_.js → define-BdTPIfqE.js} +46 -99
- 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-kf94P140.js +173 -0
- 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-BIxxF3FC.js → html-Bjq3Iw3g.js} +56 -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 +50 -26
- package/dist/index.js +3 -2
- package/dist/init-3Ti3ao5Z.js +232 -0
- 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-Bus6YhxB.js → json-B_k4CDmR.js} +5 -6
- package/dist/json-IL1JxlTL.js +1 -0
- package/dist/load-C3eFEdoH.js +98 -0
- 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-CCP1WfYe.js +363 -0
- 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-C0klJblu.js → remediation-BkE7q7dT.js} +2 -176
- package/dist/{render-C1sUZZI_.js → render-ky8cm4QF.js} +50 -24
- package/dist/result-DhoT4g0P.js +1 -0
- package/dist/{result-B7_zVxAX.js → result-g8dGsrcv.js} +1 -2
- package/dist/{review-CdMK2GpQ.js → review-BGjTBFvd.js} +11 -4
- package/dist/review-iheEjp7_.js +1 -0
- package/dist/{routes-CmdRUuOs.js → routes-BpQeBDmM.js} +4 -5
- package/dist/{run-DrS0Komf.js → run-D7tc7IU2.js} +2 -3
- package/dist/{run-BK2blxMI.d.ts → run-VXnP4uLp.d.ts} +2 -6
- package/dist/{sarif-BNCE0PNT.js → sarif-v66-PjdE.js} +9 -9
- 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-CxVyh8IO.js +71 -0
- package/dist/start-bdanSxZr.js +100 -0
- package/dist/statement/templates/be.de.md +148 -0
- package/dist/statement/templates/be.en.md +142 -0
- package/dist/statement/templates/be.fr.md +146 -0
- package/dist/statement/templates/be.nl.md +147 -0
- package/dist/statement/templates/cz.cs.md +138 -0
- package/dist/statement/templates/cz.en.md +140 -0
- package/dist/statement/templates/dk.da.md +142 -0
- package/dist/statement/templates/dk.en.md +142 -0
- package/dist/statement/templates/fi.en.md +139 -0
- package/dist/statement/templates/fi.fi.md +141 -0
- package/dist/statement/templates/ie.en.md +144 -0
- package/dist/statement/templates/pl.en.md +143 -0
- package/dist/statement/templates/pl.pl.md +144 -0
- package/dist/statement/templates/pt.en.md +143 -0
- package/dist/statement/templates/pt.pt.md +145 -0
- package/dist/statement/templates/se.en.md +148 -0
- package/dist/statement/templates/se.sv.md +150 -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-CefxwMsZ.js +121 -0
- package/dist/webpack/index.d.ts +1 -3
- package/dist/webpack/index.js +2 -3
- package/dist/{worksheet-BIxMtbUd.js → worksheet-CcBo9G7s.js} +4 -5
- package/dist/workspaces-BBFXOyeV.js +85 -0
- package/package.json +16 -14
- package/dist/audit-Bwm1xBdJ.js +0 -2
- package/dist/baseline-rtnj3RHB.js +0 -2
- package/dist/component-DcCn3BJS.js +0 -2
- package/dist/coverage-n1X9CkiG.js +0 -3
- package/dist/frameworks-etFg_O8K.js +0 -2
- package/dist/init-DrFfzjvm.js +0 -119
- package/dist/jsdom-BUYuVJJm.js +0 -3
- package/dist/json-CrQmoTj6.js +0 -2
- package/dist/load-n62iXDq_.js +0 -2
- package/dist/project-CzOnkLH6.js +0 -274
- package/dist/project-MFrXcw1M.js +0 -2
- package/dist/result-CRmjjoAA.js +0 -2
- package/dist/review-DIbOTmOM.js +0 -2
|
@@ -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";
|
|
@@ -0,0 +1,98 @@
|
|
|
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
|
+
import { readFile } from "node:fs/promises";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { pathToFileURL } from "node:url";
|
|
6
|
+
// src/config/load.ts
|
|
7
|
+
/** Checked in this order, first match wins. */
|
|
8
|
+
const CONFIG_FILENAMES = [
|
|
9
|
+
"eaa.config.ts",
|
|
10
|
+
"eaa.config.mts",
|
|
11
|
+
"eaa.config.js",
|
|
12
|
+
"eaa.config.mjs",
|
|
13
|
+
"eaa.config.json"
|
|
14
|
+
];
|
|
15
|
+
/**
|
|
16
|
+
* Find and load `eaa.config.{ts,mts,js,mjs,json}`.
|
|
17
|
+
*
|
|
18
|
+
* TypeScript configs are imported directly: Node strips types natively from
|
|
19
|
+
* 22.18 onwards, which is below this package's floor, so no bundler or loader
|
|
20
|
+
* dependency is needed. The failure mode that remains is a project with no
|
|
21
|
+
* package.json at all, where Node cannot tell ESM from CommonJS; the error says
|
|
22
|
+
* so rather than surfacing "Unexpected token 'export'".
|
|
23
|
+
*/
|
|
24
|
+
async function loadConfig(options = {}) {
|
|
25
|
+
const cwd = path.resolve(options.cwd ?? process.cwd());
|
|
26
|
+
const file = options.path ? path.resolve(cwd, options.path) : await findConfigFile(cwd);
|
|
27
|
+
if (!file) throw new ConfigError(`No config file found in ${cwd} or its parent directories`, CONFIG_FILENAMES.map((name) => `looked for ${name}`), {
|
|
28
|
+
command: "eaa-kit init",
|
|
29
|
+
why: "write one, filled in from what the site already states"
|
|
30
|
+
});
|
|
31
|
+
if (!await isFile(file)) throw new ConfigError(`Config file not found: ${file}`, [], {
|
|
32
|
+
command: `eaa-kit init --output ${path.relative(cwd, file) || path.basename(file)}`,
|
|
33
|
+
why: "write it there"
|
|
34
|
+
});
|
|
35
|
+
return {
|
|
36
|
+
config: parseConfig(await readConfigFile(file), path.basename(file)),
|
|
37
|
+
path: file
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Find the config file and read its `audit` block, for the commands that take
|
|
42
|
+
* defaults from it.
|
|
43
|
+
*
|
|
44
|
+
* Returns undefined when there is no config file at all. That is not an error
|
|
45
|
+
* here as it is for `statement`: `eaa-kit audit` has always run against a
|
|
46
|
+
* project that has never heard of a config file, and it must keep doing so. An
|
|
47
|
+
* explicit path that is not there is still an error, because somebody named it.
|
|
48
|
+
*/
|
|
49
|
+
async function loadAuditConfig(options = {}) {
|
|
50
|
+
const cwd = path.resolve(options.cwd ?? process.cwd());
|
|
51
|
+
const file = options.path ? path.resolve(cwd, options.path) : await findConfigFile(cwd);
|
|
52
|
+
if (!file) return void 0;
|
|
53
|
+
if (!await isFile(file)) throw new ConfigError(`Config file not found: ${file}`, [], {
|
|
54
|
+
command: `eaa-kit init --output ${path.relative(cwd, file) || path.basename(file)}`,
|
|
55
|
+
why: "write it there"
|
|
56
|
+
});
|
|
57
|
+
return {
|
|
58
|
+
audit: parseAuditConfig(await readConfigFile(file), path.basename(file)),
|
|
59
|
+
path: file
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function readConfigFile(file) {
|
|
63
|
+
return file.endsWith(".json") ? importJson(file) : importModule(file);
|
|
64
|
+
}
|
|
65
|
+
/** Walks up from `cwd`, so the CLI works from a subdirectory of the project. */
|
|
66
|
+
async function findConfigFile(cwd) {
|
|
67
|
+
let directory = path.resolve(cwd);
|
|
68
|
+
while (true) {
|
|
69
|
+
for (const name of CONFIG_FILENAMES) {
|
|
70
|
+
const candidate = path.join(directory, name);
|
|
71
|
+
if (await isFile(candidate)) return candidate;
|
|
72
|
+
}
|
|
73
|
+
const parent = path.dirname(directory);
|
|
74
|
+
if (parent === directory) return void 0;
|
|
75
|
+
directory = parent;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
async function importJson(file) {
|
|
79
|
+
const raw = await readFile(file, "utf8");
|
|
80
|
+
try {
|
|
81
|
+
return JSON.parse(raw);
|
|
82
|
+
} catch (cause) {
|
|
83
|
+
throw new ConfigError(`${path.basename(file)} is not valid JSON`, [cause instanceof Error ? cause.message : String(cause)]);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
async function importModule(file) {
|
|
87
|
+
let module;
|
|
88
|
+
try {
|
|
89
|
+
module = await import(`${pathToFileURL(file).href}?t=${Date.now()}`);
|
|
90
|
+
} catch (cause) {
|
|
91
|
+
const message = cause instanceof Error ? cause.message : String(cause);
|
|
92
|
+
const hint = message.includes("Unexpected token") ? "If the project has no package.json, Node cannot tell ESM from CommonJS. Add one with \"type\": \"module\", or use eaa.config.json." : message;
|
|
93
|
+
throw new ConfigError(`Could not load ${path.basename(file)}`, [hint]);
|
|
94
|
+
}
|
|
95
|
+
if (module.default === void 0) throw new ConfigError(`${path.basename(file)} has no default export`, ["Expected: export default defineConfig({ … })"]);
|
|
96
|
+
return module.default;
|
|
97
|
+
}
|
|
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 };
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
// src/audit/next.ts
|
|
4
|
+
/**
|
|
5
|
+
* What a Next.js build says about its own pages.
|
|
6
|
+
*
|
|
7
|
+
* A plain `next build` writes no browsable HTML anywhere this tool can audit
|
|
8
|
+
* as files: the prerendered pages under `.next/server` link to
|
|
9
|
+
* `/_next/static/…`, which exists at that path only when `next start` serves
|
|
10
|
+
* it, so auditing them off disk would audit pages without their CSS and get
|
|
11
|
+
* contrast wrong. The only honest view of the site is the one `next start`
|
|
12
|
+
* serves.
|
|
13
|
+
*
|
|
14
|
+
* Following links from the home page then finds what the navigation links to,
|
|
15
|
+
* which is not the site. Next already wrote down every page it built, in the
|
|
16
|
+
* manifests beside the build, so those are read instead and the crawl is
|
|
17
|
+
* seeded from them: a page nothing links to is still audited, and a dynamic
|
|
18
|
+
* route that renders on request is named as not audited rather than silently
|
|
19
|
+
* missed.
|
|
20
|
+
*
|
|
21
|
+
* The manifest formats are internal to Next and have changed between majors.
|
|
22
|
+
* Every field here is read defensively, and the fixtures in
|
|
23
|
+
* `tests/fixtures/stacks/next-*` are copied from real builds, so a format
|
|
24
|
+
* change shows up as a failing test rather than a quietly shorter audit.
|
|
25
|
+
*/
|
|
26
|
+
const CONFIG_FILES = [
|
|
27
|
+
"next.config.ts",
|
|
28
|
+
"next.config.mjs",
|
|
29
|
+
"next.config.js",
|
|
30
|
+
"next.config.cjs"
|
|
31
|
+
];
|
|
32
|
+
/**
|
|
33
|
+
* The facts in `next.config.*` that decide how to audit the site.
|
|
34
|
+
*
|
|
35
|
+
* Read with patterns rather than executed, for the reason `outputFromConfig`
|
|
36
|
+
* gives: a config file is code, and this runs before anything has decided the
|
|
37
|
+
* project is trustworthy. A value computed at runtime is simply not seen,
|
|
38
|
+
* which leaves the default, which is what the caller would do anyway.
|
|
39
|
+
*/
|
|
40
|
+
async function readNextConfig(cwd) {
|
|
41
|
+
for (const file of CONFIG_FILES) {
|
|
42
|
+
let source;
|
|
43
|
+
try {
|
|
44
|
+
source = await readFile(path.join(cwd, file), "utf8");
|
|
45
|
+
} catch {
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
const string = (key) => new RegExp(`\\b${key}\\s*:\\s*['"\`]([^'"\`]*)['"\`]`).exec(source)?.[1];
|
|
49
|
+
const facts = { file };
|
|
50
|
+
const output = string("output");
|
|
51
|
+
if (output === "export" || output === "standalone") facts.output = output;
|
|
52
|
+
const distDir = string("distDir");
|
|
53
|
+
if (distDir !== void 0 && distDir !== "" && !path.isAbsolute(distDir)) facts.distDir = distDir.replace(/^\.\//, "").replace(/\/$/, "");
|
|
54
|
+
const basePath = string("basePath");
|
|
55
|
+
if (basePath !== void 0 && basePath !== "") facts.basePath = basePath.replace(/\/$/, "");
|
|
56
|
+
if (/\btrailingSlash\s*:\s*true\b/.test(source)) facts.trailingSlash = true;
|
|
57
|
+
return facts;
|
|
58
|
+
}
|
|
59
|
+
return {};
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Every page a `next build` produced or can serve at a known address.
|
|
63
|
+
*
|
|
64
|
+
* Undefined when there is no build to read, which the caller takes as "build
|
|
65
|
+
* first".
|
|
66
|
+
*/
|
|
67
|
+
async function nextRoutes(cwd) {
|
|
68
|
+
const config = await readNextConfig(cwd);
|
|
69
|
+
const dist = path.join(cwd, config.distDir ?? ".next");
|
|
70
|
+
const routesManifest = await readJson(path.join(dist, "routes-manifest.json"));
|
|
71
|
+
const prerender = await readJson(path.join(dist, "prerender-manifest.json"));
|
|
72
|
+
if (routesManifest === void 0 && prerender === void 0) return void 0;
|
|
73
|
+
const pagesManifest = await readJson(path.join(dist, "server", "pages-manifest.json")) ?? {};
|
|
74
|
+
const appPaths = await readJson(path.join(dist, "app-path-routes-manifest.json")) ?? {};
|
|
75
|
+
const defaultLocale = routesManifest?.i18n?.defaultLocale;
|
|
76
|
+
const unprefixed = (route) => {
|
|
77
|
+
if (defaultLocale === void 0) return route;
|
|
78
|
+
if (route === `/${defaultLocale}`) return "/";
|
|
79
|
+
if (route.startsWith(`/${defaultLocale}/`)) return route.slice(defaultLocale.length + 1);
|
|
80
|
+
return route;
|
|
81
|
+
};
|
|
82
|
+
const candidates = [
|
|
83
|
+
...Object.keys(prerender?.routes ?? {}),
|
|
84
|
+
...Object.keys(pagesManifest),
|
|
85
|
+
...Object.entries(appPaths).filter(([file]) => file.endsWith("/page")).map(([, route]) => route)
|
|
86
|
+
].map(unprefixed);
|
|
87
|
+
const isPage = (route) => {
|
|
88
|
+
const segments = route.split("/").filter(Boolean);
|
|
89
|
+
if (segments[0] === "api") return false;
|
|
90
|
+
if (segments.some((segment) => segment.startsWith("_"))) return false;
|
|
91
|
+
if (/^(404|500)$/.test(segments.at(-1) ?? "")) return false;
|
|
92
|
+
if (/\.[a-z0-9]+$/i.test(segments.at(-1) ?? "")) return false;
|
|
93
|
+
return true;
|
|
94
|
+
};
|
|
95
|
+
const known = new Set(candidates.filter(isPage));
|
|
96
|
+
const pages = [...known].filter((route) => !route.includes("[")).sort();
|
|
97
|
+
const withPages = new Set(Object.keys(prerender?.dynamicRoutes ?? {}).map(unprefixed));
|
|
98
|
+
const dynamic = [...known].filter((route) => route.includes("[") && !withPages.has(route)).sort();
|
|
99
|
+
return {
|
|
100
|
+
basePath: (routesManifest?.basePath ?? config.basePath ?? "").replace(/\/$/, ""),
|
|
101
|
+
pages,
|
|
102
|
+
dynamic,
|
|
103
|
+
trailingSlash: config.trailingSlash === true
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/** The page's address on a running server, basePath and trailing slash included. */
|
|
107
|
+
function nextPageUrl(origin, routes, page) {
|
|
108
|
+
let pathname = `${routes.basePath}${page === "/" ? "" : page}` || "/";
|
|
109
|
+
if (routes.trailingSlash && !pathname.endsWith("/")) pathname += "/";
|
|
110
|
+
return new URL(pathname, origin).href;
|
|
111
|
+
}
|
|
112
|
+
async function readJson(file) {
|
|
113
|
+
try {
|
|
114
|
+
return JSON.parse(await readFile(file, "utf8"));
|
|
115
|
+
} catch {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
export { nextPageUrl, nextRoutes, readNextConfig };
|
package/dist/nuxt/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { n as IntegrationOptions, t as BuildAuditError } from "../run-
|
|
2
|
-
//#region src/nuxt/index.d.ts
|
|
1
|
+
import { n as IntegrationOptions, t as BuildAuditError } from "../run-VXnP4uLp.js";
|
|
3
2
|
/** The part of the Nitro instance this reads, handed over by `nitro:init`. */
|
|
4
3
|
interface NitroLike {
|
|
5
4
|
options: {
|
|
@@ -31,5 +30,4 @@ interface EaaKitNuxtOptions extends IntegrationOptions {
|
|
|
31
30
|
allowServerBuild?: boolean;
|
|
32
31
|
}
|
|
33
32
|
declare function eaaKitModule(options?: EaaKitNuxtOptions, nuxt?: NuxtLike): void;
|
|
34
|
-
//#endregion
|
|
35
33
|
export { BuildAuditError, EaaKitNuxtOptions, NitroLike, NuxtLike, NuxtOptionsLike, eaaKitModule as default };
|
package/dist/nuxt/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as auditBuild, r as stderrLogger, t as BuildAuditError } from "../run-
|
|
1
|
+
import { n as auditBuild, r as stderrLogger, t as BuildAuditError } from "../run-D7tc7IU2.js";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
|
|
3
|
+
// src/nuxt/index.ts
|
|
4
4
|
function eaaKitModule(options = {}, nuxt) {
|
|
5
5
|
if (nuxt === void 0) return;
|
|
6
6
|
let publicDir;
|
|
@@ -19,5 +19,4 @@ function eaaKitModule(options = {}, nuxt) {
|
|
|
19
19
|
await auditBuild(path.resolve(nuxt.options.rootDir ?? process.cwd(), directory), options, stderrLogger());
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
|
-
//#endregion
|
|
23
22
|
export { BuildAuditError, eaaKitModule as default };
|