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
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import { a as impactLabel, i as countAtOrAbove, r as byImpactThenRule } from "./impact-
|
|
2
|
-
import { n as count,
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { a as
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { n as buildSummary } from "./json-
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
1
|
+
import { a as impactLabel, i as countAtOrAbove, r as byImpactThenRule } from "./impact-BGlJ6j0Y.js";
|
|
2
|
+
import { n as count, s as plural, t as collapse } from "./text-CISDPU49.js";
|
|
3
|
+
import { a as reusedPart, o as runCompleteness } from "./completeness-Dzyvgr4Z.js";
|
|
4
|
+
import { r as componentPath } from "./component-ZLd8DA_a.js";
|
|
5
|
+
import { a as manualCheckFor, n as coverageSummary, o as understandingUrl, r as reviewSummary, t as buildCoverage } from "./coverage-C1Z6t9Ct.js";
|
|
6
|
+
import { a as issueTotals, i as isShared, n as coverageParts, r as groupIssues, t as blindRules } from "./issues-WLlepU95.js";
|
|
7
|
+
import { t as remediationFor } from "./remediation-BkE7q7dT.js";
|
|
8
|
+
import { n as DEFAULT_TAGS, u as runEngine } from "./result-g8dGsrcv.js";
|
|
9
|
+
import { l as reviewSentence } from "./review-BGjTBFvd.js";
|
|
10
|
+
import { n as buildSummary } from "./json-B_k4CDmR.js";
|
|
11
|
+
import { t as TOOL_VERSION } from "./version-C8aJm8YJ.js";
|
|
12
|
+
import { a as emitDocument, d as warn, l as note, o as fail, s as failWith, t as advise, u as runEngine$1 } from "./command-C8ZFvcc1.js";
|
|
13
|
+
import { t as resolvePages } from "./pages-CCP1WfYe.js";
|
|
13
14
|
import pc from "picocolors";
|
|
14
|
-
|
|
15
|
+
// src/audit/report/console.ts
|
|
15
16
|
const DEFAULT_MAX_NODES = 3;
|
|
16
17
|
const MIN_WIDTH = 40;
|
|
17
18
|
const MAX_WIDTH = 100;
|
|
@@ -278,6 +279,15 @@ function completenessLines(ctx) {
|
|
|
278
279
|
if (completeness === void 0) return [];
|
|
279
280
|
const reused = reusedPart(completeness);
|
|
280
281
|
const lines = reused === void 0 ? [] : [line(ctx, ` ${reused}`, ctx.c.dim)];
|
|
282
|
+
const redirect = completeness.entryRedirect;
|
|
283
|
+
if (redirect !== void 0) {
|
|
284
|
+
const why = {
|
|
285
|
+
"same-site": "same site",
|
|
286
|
+
flag: "--redirects follow",
|
|
287
|
+
prompt: "approved"
|
|
288
|
+
}[redirect.followedBecause];
|
|
289
|
+
lines.unshift(line(ctx, ` Redirected (${redirect.statuses.join(" → ")}, ${why}):`, ctx.c.yellow), line(ctx, ` from ${redirect.requested}`, ctx.c.yellow), line(ctx, ` to ${redirect.auditedFrom}`, ctx.c.yellow), line(ctx, " Everything below is about the second address.", ctx.c.dim));
|
|
290
|
+
}
|
|
281
291
|
if (completeness.complete) return lines;
|
|
282
292
|
if (completeness.unreachable.length > 0) {
|
|
283
293
|
const noun = plural(completeness.unreachable.length, "page");
|
|
@@ -444,194 +454,13 @@ function wrap(text, width) {
|
|
|
444
454
|
if (line !== "") lines.push(line);
|
|
445
455
|
return lines;
|
|
446
456
|
}
|
|
447
|
-
|
|
448
|
-
//#region src/cli/pages.ts
|
|
449
|
-
/**
|
|
450
|
-
* Collect the pages to audit, reporting to stderr on the way.
|
|
451
|
-
*
|
|
452
|
-
* Returns undefined when there is nothing to audit, having already explained
|
|
453
|
-
* why. Every caller turns that into exit 2 — a run that reached no verdict,
|
|
454
|
-
* which is not the same as a clean one.
|
|
455
|
-
*/
|
|
456
|
-
async function resolvePages(directory, options = {}) {
|
|
457
|
-
if (directory === void 0 && options.url === void 0) return resolveAutomatically(options);
|
|
458
|
-
if (options.url !== void 0) {
|
|
459
|
-
const crawled = await crawlPages(options.url, options);
|
|
460
|
-
if (!crawled) return void 0;
|
|
461
|
-
if (crawled.pages.length === 0) {
|
|
462
|
-
warn(`No pages could be fetched from ${options.url}`);
|
|
463
|
-
return;
|
|
464
|
-
}
|
|
465
|
-
return {
|
|
466
|
-
pages: crawled.pages,
|
|
467
|
-
origin: crawled.origin,
|
|
468
|
-
label: options.url,
|
|
469
|
-
completeness: crawled.completeness
|
|
470
|
-
};
|
|
471
|
-
}
|
|
472
|
-
const cwd = options.cwd ?? process.cwd();
|
|
473
|
-
const shown = options.label ?? directory;
|
|
474
|
-
const unreachable = [];
|
|
475
|
-
let pages;
|
|
476
|
-
try {
|
|
477
|
-
pages = await collectPages(directory, {
|
|
478
|
-
...options.include ? { include: options.include } : {},
|
|
479
|
-
...options.exclude ? { exclude: options.exclude } : {},
|
|
480
|
-
onUnreadable: (relativePath, reason) => unreachable.push({
|
|
481
|
-
location: relativePath,
|
|
482
|
-
reason
|
|
483
|
-
})
|
|
484
|
-
});
|
|
485
|
-
} catch (cause) {
|
|
486
|
-
if (!(cause instanceof BuildDirectoryError)) throw cause;
|
|
487
|
-
fail(cause.message);
|
|
488
|
-
note(await emptyDirectoryHint(shown, cwd));
|
|
489
|
-
return;
|
|
490
|
-
}
|
|
491
|
-
if (pages.length === 0) {
|
|
492
|
-
if ((options.include !== void 0 || options.exclude !== void 0) && await holdsHtml(directory)) {
|
|
493
|
-
warn(`No page in ${shown} matched the filters, so nothing was audited.`);
|
|
494
|
-
if (options.include !== void 0) note(` --include ${options.include.join(" ")}`);
|
|
495
|
-
if (options.exclude !== void 0) note(` --exclude ${options.exclude.join(" ")}`);
|
|
496
|
-
note(" Patterns are relative to the audited directory, with POSIX separators.");
|
|
497
|
-
return;
|
|
498
|
-
}
|
|
499
|
-
warn(await emptyDirectoryHint(shown, cwd));
|
|
500
|
-
return;
|
|
501
|
-
}
|
|
502
|
-
warnUnmeasured(unreachable, "file", "readable");
|
|
503
|
-
return {
|
|
504
|
-
pages,
|
|
505
|
-
directory,
|
|
506
|
-
label: shown,
|
|
507
|
-
completeness: {
|
|
508
|
-
discovery: "directory",
|
|
509
|
-
collected: pages.length,
|
|
510
|
-
unreachable,
|
|
511
|
-
truncated: false
|
|
512
|
-
}
|
|
513
|
-
};
|
|
514
|
-
}
|
|
515
|
-
/**
|
|
516
|
-
* Name what was missed, up to ten of them, and count the rest.
|
|
517
|
-
*
|
|
518
|
-
* Both collectors need this and neither may skip it: a file that could not be
|
|
519
|
-
* read and a URL that could not be fetched are pages with no verdict, and a run
|
|
520
|
-
* that mentioned neither would report the rest of the site as though it were
|
|
521
|
-
* the site. Ten because the point is to make the problem recognisable, and two
|
|
522
|
-
* hundred failures usually have the one reason the first few show — the count
|
|
523
|
-
* that follows is what says the list was cut.
|
|
524
|
-
*/
|
|
525
|
-
function warnUnmeasured(missed, noun, reached) {
|
|
526
|
-
if (missed.length === 0) return;
|
|
527
|
-
warn(`${count(missed.length, noun)} ${missed.length === 1 ? "was" : "were"} not ${reached}, and so not audited:`);
|
|
528
|
-
for (const item of missed.slice(0, 10)) note(` ${item.location} — ${item.reason}`);
|
|
529
|
-
if (missed.length > 10) note(` …and ${missed.length - 10} more`);
|
|
530
|
-
}
|
|
531
|
-
/**
|
|
532
|
-
* Fetch the pages of a running site, reporting what happened on the way.
|
|
533
|
-
*
|
|
534
|
-
* Returns undefined when the crawl could not start, which the caller turns into
|
|
535
|
-
* exit 2 — a run that reached no verdict, not a clean one.
|
|
536
|
-
*/
|
|
537
|
-
async function crawlPages(url, options) {
|
|
538
|
-
const { collapsedOnto, crawlSite, CrawlError, parseEntryUrl } = await import("./crawl-BHkJmUkA.js");
|
|
539
|
-
let entry;
|
|
540
|
-
try {
|
|
541
|
-
entry = parseEntryUrl(url, options.allowRemote ?? false);
|
|
542
|
-
} catch (cause) {
|
|
543
|
-
if (cause instanceof CrawlError) {
|
|
544
|
-
fail(cause.message);
|
|
545
|
-
return;
|
|
546
|
-
}
|
|
547
|
-
throw cause;
|
|
548
|
-
}
|
|
549
|
-
note(`Crawling ${entry.origin}…`);
|
|
550
|
-
const result = await crawlSite(entry, {
|
|
551
|
-
...options.allowRemote ? { allowRemote: true } : {},
|
|
552
|
-
...options.ignoreRobots ? { ignoreRobots: true } : {},
|
|
553
|
-
...options.sitemap === void 0 ? {} : { sitemap: options.sitemap },
|
|
554
|
-
...options.maxPages === void 0 ? {} : { maxPages: options.maxPages },
|
|
555
|
-
...options.maxDepth === void 0 ? {} : { maxDepth: options.maxDepth },
|
|
556
|
-
...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs },
|
|
557
|
-
...options.headers === void 0 ? {} : { headers: options.headers }
|
|
558
|
-
});
|
|
559
|
-
if (result.pages.length === 0 && result.failures.length > 0) {
|
|
560
|
-
fail(`Could not fetch ${entry.href} (${result.failures[0]?.reason})`);
|
|
561
|
-
note(" Is the site running at that address?");
|
|
562
|
-
return;
|
|
563
|
-
}
|
|
564
|
-
const found = result.discovery === "sitemap" ? "sitemap.xml and links" : "links";
|
|
565
|
-
note(`Found ${count(result.pages.length, "page")} from ${found}`);
|
|
566
|
-
const failed = result.failures.map((failure) => ({
|
|
567
|
-
location: failure.url,
|
|
568
|
-
reason: failure.reason
|
|
569
|
-
}));
|
|
570
|
-
warnUnmeasured(failed, "URL", "fetched");
|
|
571
|
-
if (result.truncated) warn(`Stopped at ${count(result.pages.length, "page")}; the site has more. Raise --max-pages to go further.`);
|
|
572
|
-
const collapsed = collapsedOnto(result);
|
|
573
|
-
if (collapsed.length > 0) {
|
|
574
|
-
const landedOn = collapsed[0]?.landedOn ?? "";
|
|
575
|
-
warn(`Every page requested answered at ${landedOn}, which is not where it was asked.`);
|
|
576
|
-
note(" A sign-in page in front of the site looks like this.");
|
|
577
|
-
note(" If it is behind one, pass --basic-auth user:password or --header \"Cookie: …\".");
|
|
578
|
-
}
|
|
579
|
-
return {
|
|
580
|
-
pages: result.pages,
|
|
581
|
-
origin: result.origin,
|
|
582
|
-
completeness: {
|
|
583
|
-
discovery: result.discovery,
|
|
584
|
-
collected: result.pages.length,
|
|
585
|
-
unreachable: [...failed, ...collapsed.map((redirect) => ({
|
|
586
|
-
location: redirect.requested,
|
|
587
|
-
reason: `answered at ${redirect.landedOn} instead, so this page was not audited`
|
|
588
|
-
}))],
|
|
589
|
-
truncated: result.truncated
|
|
590
|
-
}
|
|
591
|
-
};
|
|
592
|
-
}
|
|
593
|
-
/**
|
|
594
|
-
* No directory and no URL: work out what this project needs.
|
|
595
|
-
*
|
|
596
|
-
* The point is that `eaa-kit audit` on its own does something useful. Anything
|
|
597
|
-
* this starts is handed back as `cleanup` so the caller can stop it once the
|
|
598
|
-
* report is written.
|
|
599
|
-
*/
|
|
600
|
-
async function resolveAutomatically(options) {
|
|
601
|
-
const cwd = options.cwd ?? process.cwd();
|
|
602
|
-
const { autoDetectSource } = await import("./project-MFrXcw1M.js");
|
|
603
|
-
const detected = await autoDetectSource(cwd, {
|
|
604
|
-
...options.noBuild ? { noBuild: true } : {},
|
|
605
|
-
onStep: note
|
|
606
|
-
});
|
|
607
|
-
if (detected?.directory !== void 0) return resolvePages(detected.directory, {
|
|
608
|
-
...options,
|
|
609
|
-
label: path.relative(cwd, detected.directory) || "."
|
|
610
|
-
});
|
|
611
|
-
if (detected?.url !== void 0) {
|
|
612
|
-
const resolved = await resolvePages(void 0, {
|
|
613
|
-
...options,
|
|
614
|
-
url: detected.url
|
|
615
|
-
});
|
|
616
|
-
if (resolved === void 0) {
|
|
617
|
-
await detected.cleanup?.();
|
|
618
|
-
return;
|
|
619
|
-
}
|
|
620
|
-
return {
|
|
621
|
-
...resolved,
|
|
622
|
-
...detected.cleanup ? { cleanup: detected.cleanup } : {}
|
|
623
|
-
};
|
|
624
|
-
}
|
|
625
|
-
await detected?.cleanup?.();
|
|
626
|
-
warn(await emptyDirectoryHint("./dist", cwd));
|
|
627
|
-
}
|
|
628
|
-
//#endregion
|
|
629
|
-
//#region src/cli/audit.ts
|
|
457
|
+
// src/cli/audit.ts
|
|
630
458
|
const OUTPUT_FORMATS = [
|
|
631
459
|
"console",
|
|
632
460
|
"json",
|
|
633
461
|
"sarif",
|
|
634
|
-
"html"
|
|
462
|
+
"html",
|
|
463
|
+
"markdown"
|
|
635
464
|
];
|
|
636
465
|
/**
|
|
637
466
|
* `eaa-kit audit [dir]`.
|
|
@@ -647,6 +476,7 @@ async function runAuditCommand(dir, options = {}) {
|
|
|
647
476
|
exitCode: 2
|
|
648
477
|
};
|
|
649
478
|
const { pages, origin, label, cleanup, directory, completeness: collection } = resolved;
|
|
479
|
+
const found = directory === void 0 ? {} : { directory };
|
|
650
480
|
if (options.headers !== void 0 && directory !== void 0 && !options.browser) warn("--header and --basic-auth apply to pages that are fetched; this run read files.");
|
|
651
481
|
try {
|
|
652
482
|
const baseUrl = options.baseUrl ?? origin;
|
|
@@ -665,6 +495,7 @@ async function runAuditCommand(dir, options = {}) {
|
|
|
665
495
|
});
|
|
666
496
|
if (!fresh) return {
|
|
667
497
|
audits: [],
|
|
498
|
+
...found,
|
|
668
499
|
exitCode: 2
|
|
669
500
|
};
|
|
670
501
|
for (const [index, page] of misses.entries()) {
|
|
@@ -674,31 +505,37 @@ async function runAuditCommand(dir, options = {}) {
|
|
|
674
505
|
await cache?.flush();
|
|
675
506
|
let audits = inCollectedOrder(pages, [...hits, ...fresh]);
|
|
676
507
|
const failOn = options.failOn ?? "serious";
|
|
508
|
+
let baseline;
|
|
677
509
|
if (options.baseline) {
|
|
678
510
|
const applied = await acceptBaseline(audits, options);
|
|
679
511
|
if (!applied) return {
|
|
680
512
|
audits,
|
|
513
|
+
...found,
|
|
681
514
|
exitCode: 2
|
|
682
515
|
};
|
|
683
|
-
audits = applied;
|
|
516
|
+
audits = applied.audits;
|
|
517
|
+
baseline = applied.counts;
|
|
684
518
|
}
|
|
685
519
|
const completeness = runCompleteness(audits, collection);
|
|
686
520
|
const review = await loadReview(options);
|
|
687
521
|
if (review === FAILED) return {
|
|
688
522
|
audits,
|
|
523
|
+
...found,
|
|
689
524
|
exitCode: 2
|
|
690
525
|
};
|
|
691
|
-
await emit(audits, label, failOn, completeness, options, review);
|
|
526
|
+
await emit(audits, label, failOn, completeness, options, review, baseline);
|
|
692
527
|
const unaudited = audits.filter((audit) => audit.error);
|
|
693
528
|
if (unaudited.length > 0) {
|
|
694
529
|
fail(`${unaudited.length} of ${audits.length} pages could not be audited`);
|
|
695
530
|
return {
|
|
696
531
|
audits,
|
|
532
|
+
...found,
|
|
697
533
|
exitCode: 2
|
|
698
534
|
};
|
|
699
535
|
}
|
|
700
536
|
return {
|
|
701
537
|
audits,
|
|
538
|
+
...found,
|
|
702
539
|
exitCode: countAtOrAbove(audits, failOn) > 0 ? 1 : 0
|
|
703
540
|
};
|
|
704
541
|
} finally {
|
|
@@ -719,8 +556,8 @@ async function splitByCache(pages, baseUrl, options) {
|
|
|
719
556
|
misses: [...pages],
|
|
720
557
|
cache: void 0
|
|
721
558
|
};
|
|
722
|
-
const { fromEntry, openCache } = await import("./cache-
|
|
723
|
-
const { pageUrl } = await import("./result-
|
|
559
|
+
const { fromEntry, openCache } = await import("./cache-DIV4G0TI.js");
|
|
560
|
+
const { pageUrl } = await import("./result-DhoT4g0P.js");
|
|
724
561
|
const axe = (await import("axe-core")).default;
|
|
725
562
|
const engine = options.browser ? "browser" : "jsdom";
|
|
726
563
|
const cache = await openCache({
|
|
@@ -775,7 +612,7 @@ function inCollectedOrder(pages, audits) {
|
|
|
775
612
|
* would be as wrong as silently passing.
|
|
776
613
|
*/
|
|
777
614
|
async function acceptBaseline(audits, options) {
|
|
778
|
-
const { applyBaseline, BaselineError, readBaseline } = await import("./baseline-
|
|
615
|
+
const { applyBaseline, BaselineError, readBaseline } = await import("./baseline-DYOejLFO.js");
|
|
779
616
|
try {
|
|
780
617
|
const outcome = applyBaseline(audits, await readBaseline(options.baseline, options.cwd ?? process.cwd()));
|
|
781
618
|
if (outcome.accepted > 0) note(`Baseline accepted ${outcome.accepted} violating elements`);
|
|
@@ -784,10 +621,16 @@ async function acceptBaseline(audits, options) {
|
|
|
784
621
|
note(`${stale} baseline ${stale === 1 ? "entry no longer matches" : "entries no longer match"} and can be removed`);
|
|
785
622
|
}
|
|
786
623
|
if (outcome.expired.length > 0) advise(`${outcome.expired.length} baseline entries have expired and no longer suppress anything`);
|
|
787
|
-
return
|
|
624
|
+
return {
|
|
625
|
+
audits: outcome.audits,
|
|
626
|
+
counts: {
|
|
627
|
+
stale: outcome.stale.length,
|
|
628
|
+
expired: outcome.expired.length
|
|
629
|
+
}
|
|
630
|
+
};
|
|
788
631
|
} catch (cause) {
|
|
789
632
|
if (cause instanceof BaselineError) {
|
|
790
|
-
|
|
633
|
+
failWith(cause);
|
|
791
634
|
return;
|
|
792
635
|
}
|
|
793
636
|
throw cause;
|
|
@@ -803,7 +646,7 @@ const FAILED = Symbol("review-failed");
|
|
|
803
646
|
*/
|
|
804
647
|
async function loadReview(options) {
|
|
805
648
|
if (options.review === void 0) return void 0;
|
|
806
|
-
const { answeredCount, readReview, ReviewError } = await import("./review-
|
|
649
|
+
const { answeredCount, readReview, ReviewError } = await import("./review-iheEjp7_.js");
|
|
807
650
|
try {
|
|
808
651
|
const record = await readReview(options.review, options.cwd ?? process.cwd());
|
|
809
652
|
note(`Review record: ${count(answeredCount(record), "criterion")} answered`);
|
|
@@ -813,7 +656,7 @@ async function loadReview(options) {
|
|
|
813
656
|
};
|
|
814
657
|
} catch (cause) {
|
|
815
658
|
if (cause instanceof ReviewError) {
|
|
816
|
-
|
|
659
|
+
failWith(cause);
|
|
817
660
|
return FAILED;
|
|
818
661
|
}
|
|
819
662
|
throw cause;
|
|
@@ -828,7 +671,7 @@ async function loadReview(options) {
|
|
|
828
671
|
*/
|
|
829
672
|
async function describeEngine(pages, options) {
|
|
830
673
|
if (options.browser) return " with Chromium";
|
|
831
|
-
const { plannedWorkers } = await import("./pool-
|
|
674
|
+
const { plannedWorkers } = await import("./pool-B3XKdk57.js");
|
|
832
675
|
const workers = options.concurrency ?? plannedWorkers(pages);
|
|
833
676
|
const threads = workers > 1 ? ` across ${workers} threads` : "";
|
|
834
677
|
return options.fast ? `${threads}, skipping what this engine cannot decide` : threads;
|
|
@@ -842,15 +685,38 @@ async function describeEngine(pages, options) {
|
|
|
842
685
|
* to know where the document was going anyway — which is the whole of what the
|
|
843
686
|
* split was carrying between them.
|
|
844
687
|
*/
|
|
845
|
-
async function emit(audits, dir, failOn, completeness, options, review) {
|
|
846
|
-
const body = await render(audits, dir, failOn, completeness, typeof options.output === "string", options, review);
|
|
688
|
+
async function emit(audits, dir, failOn, completeness, options, review, baseline) {
|
|
689
|
+
const body = await render(audits, dir, failOn, completeness, typeof options.output === "string", options, review, baseline);
|
|
847
690
|
await emitDocument(body, options.output, options.cwd ?? process.cwd());
|
|
848
691
|
if (options.output !== void 0) note(`Report written to ${options.output}`);
|
|
692
|
+
if (options.htmlReport !== void 0) {
|
|
693
|
+
const html = await render(audits, dir, failOn, completeness, true, {
|
|
694
|
+
...options,
|
|
695
|
+
format: "html"
|
|
696
|
+
}, review, baseline);
|
|
697
|
+
await emitDocument(html, options.htmlReport, options.cwd ?? process.cwd());
|
|
698
|
+
}
|
|
699
|
+
if (options.summary !== void 0) {
|
|
700
|
+
const markdown = await render(audits, dir, failOn, completeness, true, {
|
|
701
|
+
...options,
|
|
702
|
+
format: "markdown"
|
|
703
|
+
}, review, baseline);
|
|
704
|
+
await emitDocument(markdown, options.summary, options.cwd ?? process.cwd());
|
|
705
|
+
}
|
|
849
706
|
}
|
|
850
|
-
async function render(audits, dir, failOn, completeness, toFile, options, review) {
|
|
707
|
+
async function render(audits, dir, failOn, completeness, toFile, options, review, baseline) {
|
|
851
708
|
switch (options.format ?? "console") {
|
|
709
|
+
case "markdown": {
|
|
710
|
+
const { buildMarkdownReport } = await import("./markdown-D-QpPYsz.js");
|
|
711
|
+
return buildMarkdownReport(audits, {
|
|
712
|
+
directory: dir,
|
|
713
|
+
failOn,
|
|
714
|
+
completeness,
|
|
715
|
+
...baseline === void 0 ? {} : { baseline }
|
|
716
|
+
});
|
|
717
|
+
}
|
|
852
718
|
case "json": {
|
|
853
|
-
const { buildJsonReport, serialiseJsonReport } = await import("./json-
|
|
719
|
+
const { buildJsonReport, serialiseJsonReport } = await import("./json-IL1JxlTL.js");
|
|
854
720
|
return serialiseJsonReport(buildJsonReport(audits, {
|
|
855
721
|
directory: dir,
|
|
856
722
|
...options.url === void 0 ? {} : { sourceKind: "url" },
|
|
@@ -861,7 +727,7 @@ async function render(audits, dir, failOn, completeness, toFile, options, review
|
|
|
861
727
|
}));
|
|
862
728
|
}
|
|
863
729
|
case "sarif": {
|
|
864
|
-
const { buildSarifReport, serialiseSarifReport } = await import("./sarif-
|
|
730
|
+
const { buildSarifReport, serialiseSarifReport } = await import("./sarif-v66-PjdE.js");
|
|
865
731
|
return serialiseSarifReport(buildSarifReport(audits, {
|
|
866
732
|
directory: dir,
|
|
867
733
|
completeness,
|
|
@@ -869,13 +735,14 @@ async function render(audits, dir, failOn, completeness, toFile, options, review
|
|
|
869
735
|
}));
|
|
870
736
|
}
|
|
871
737
|
case "html": {
|
|
872
|
-
const { buildHtmlReport } = await import("./html-
|
|
738
|
+
const { buildHtmlReport } = await import("./html-Bjq3Iw3g.js");
|
|
873
739
|
return buildHtmlReport(audits, {
|
|
874
740
|
...await fromTheProject(audits, options),
|
|
875
741
|
directory: dir,
|
|
876
742
|
failOn,
|
|
877
743
|
completeness,
|
|
878
744
|
...review === void 0 ? {} : { review },
|
|
745
|
+
...baseline === void 0 ? {} : { baseline },
|
|
879
746
|
...options.baseUrl ? { baseUrl: options.baseUrl } : {}
|
|
880
747
|
});
|
|
881
748
|
}
|
|
@@ -902,8 +769,8 @@ async function render(audits, dir, failOn, completeness, toFile, options, review
|
|
|
902
769
|
*/
|
|
903
770
|
async function fromTheProject(audits, options) {
|
|
904
771
|
const cwd = options.cwd ?? process.cwd();
|
|
905
|
-
const { detectFramework } = await import("./frameworks-
|
|
906
|
-
const { readPackageJson } = await import("./project-
|
|
772
|
+
const { detectFramework } = await import("./frameworks-Y-n3NUuG.js");
|
|
773
|
+
const { readPackageJson } = await import("./project-Dht13sb1.js");
|
|
907
774
|
const detected = await detectFramework(cwd, await readPackageJson(cwd));
|
|
908
775
|
return {
|
|
909
776
|
...await sourceLookups(cwd, audits),
|
|
@@ -916,13 +783,13 @@ async function fromTheProject(audits, options) {
|
|
|
916
783
|
* report it always got, with no source named.
|
|
917
784
|
*/
|
|
918
785
|
async function sourceLookups(cwd, audits) {
|
|
919
|
-
const { buildRouteMap, sourceFor } = await import("./routes-
|
|
786
|
+
const { buildRouteMap, sourceFor } = await import("./routes-BpQeBDmM.js");
|
|
920
787
|
const routes = await buildRouteMap(cwd);
|
|
921
788
|
if (!hasElementsToAttribute(audits)) return {
|
|
922
789
|
sourceFor: (page) => sourceFor(routes, page),
|
|
923
790
|
componentFor: () => void 0
|
|
924
791
|
};
|
|
925
|
-
const { buildComponentIndex, componentFor } = await import("./component-
|
|
792
|
+
const { buildComponentIndex, componentFor } = await import("./component-CgbeRgJa.js");
|
|
926
793
|
const components = await buildComponentIndex(cwd);
|
|
927
794
|
return {
|
|
928
795
|
sourceFor: (page) => sourceFor(routes, page),
|
|
@@ -933,5 +800,4 @@ async function sourceLookups(cwd, audits) {
|
|
|
933
800
|
function hasElementsToAttribute(audits) {
|
|
934
801
|
return audits.some((audit) => audit.violations.length > 0 || (audit.accepted?.length ?? 0) > 0);
|
|
935
802
|
}
|
|
936
|
-
|
|
937
|
-
export { runAuditCommand as n, resolvePages as r, OUTPUT_FORMATS as t };
|
|
803
|
+
export { runAuditCommand as n, OUTPUT_FORMATS as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { n as runAuditCommand } from "./audit-DbqNIrt6.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { c as nullable, d as optional, h as string, l as number, m as safeParse, o as isoDate, t as array, u as object, y as withDefault } from "./schema-
|
|
2
|
-
import {
|
|
3
|
-
import { t as elementFingerprint } from "./fingerprint-
|
|
4
|
-
import { s as findingElements } from "./result-
|
|
1
|
+
import { c as nullable, d as optional, h as string, l as number, m as safeParse, o as isoDate, t as array, u as object, y as withDefault } from "./schema-DfC-Ww1w.js";
|
|
2
|
+
import { o as isoDate$1 } from "./text-CISDPU49.js";
|
|
3
|
+
import { t as elementFingerprint } from "./fingerprint-CcoQ1WxQ.js";
|
|
4
|
+
import { s as findingElements } from "./result-g8dGsrcv.js";
|
|
5
5
|
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
/** Default filename, used by the CLI when no path is given. */
|
|
@@ -29,7 +29,12 @@ const baselineSchema = object({
|
|
|
29
29
|
entries: withDefault(array(entrySchema), () => [])
|
|
30
30
|
});
|
|
31
31
|
var BaselineError = class extends Error {
|
|
32
|
+
next;
|
|
32
33
|
name = "BaselineError";
|
|
34
|
+
constructor(message, next) {
|
|
35
|
+
super(message);
|
|
36
|
+
this.next = next;
|
|
37
|
+
}
|
|
33
38
|
};
|
|
34
39
|
/**
|
|
35
40
|
* Move the violations a baseline accounts for out of the failing set.
|
|
@@ -154,7 +159,10 @@ async function readBaseline(file, cwd = process.cwd()) {
|
|
|
154
159
|
try {
|
|
155
160
|
raw = await readFile(target, "utf8");
|
|
156
161
|
} catch {
|
|
157
|
-
throw new BaselineError(`Could not read the baseline at ${file}
|
|
162
|
+
throw new BaselineError(`Could not read the baseline at ${file}`, {
|
|
163
|
+
command: `eaa-kit baseline --output ${file}`,
|
|
164
|
+
why: "record what the build has today"
|
|
165
|
+
});
|
|
158
166
|
}
|
|
159
167
|
let value;
|
|
160
168
|
try {
|
|
@@ -167,8 +175,11 @@ async function readBaseline(file, cwd = process.cwd()) {
|
|
|
167
175
|
const issues = result.error.issues.map((issue) => `${issue.path.join(".") || "document"}: ${issue.message}`).slice(0, 5);
|
|
168
176
|
throw new BaselineError(`${path.basename(target)} is not an eaa-kit baseline (${issues.join("; ")})`);
|
|
169
177
|
}
|
|
170
|
-
if (result.data.schemaVersion !== 2) throw new BaselineError(`${path.basename(target)} has schemaVersion ${result.data.schemaVersion}; this version of eaa-kit reads 2.\n
|
|
171
|
-
not necessarily what the old one accepted
|
|
178
|
+
if (result.data.schemaVersion !== 2) throw new BaselineError(`${path.basename(target)} has schemaVersion ${result.data.schemaVersion}; this version of eaa-kit reads 2.\n Read the new file before committing it: it lists what this run found, which is
|
|
179
|
+
not necessarily what the old one accepted.`, {
|
|
180
|
+
command: `eaa-kit baseline --output ${file}`,
|
|
181
|
+
why: "record it again on the current build"
|
|
182
|
+
});
|
|
172
183
|
return result.data;
|
|
173
184
|
}
|
|
174
185
|
async function writeBaseline(file, baseline, cwd = process.cwd()) {
|
|
@@ -183,5 +194,4 @@ function key(page, ruleId, fingerprint) {
|
|
|
183
194
|
function byEntry(a, b) {
|
|
184
195
|
return a.page.localeCompare(b.page) || a.ruleId.localeCompare(b.ruleId) || a.fingerprint.localeCompare(b.fingerprint);
|
|
185
196
|
}
|
|
186
|
-
//#endregion
|
|
187
197
|
export { pruneBaseline as a, writeBaseline as c, buildBaseline as i, DEFAULT_BASELINE_FILE as n, readBaseline as o, applyBaseline as r, serialiseBaseline as s, BaselineError as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as runBaselineCommand } from "./baseline-DvdsFTQy.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as BaselineError, n as DEFAULT_BASELINE_FILE, r as applyBaseline, o as readBaseline } from "./baseline-CKElWbx4.js";
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { a as pruneBaseline, c as writeBaseline, i as buildBaseline, o as readBaseline, r as applyBaseline, t as BaselineError } from "./baseline-CKElWbx4.js";
|
|
2
|
+
import { n as count } from "./text-CISDPU49.js";
|
|
3
|
+
import { l as note, o as fail, s as failWith, t as advise, u as runEngine } from "./command-C8ZFvcc1.js";
|
|
4
|
+
import { t as resolvePages } from "./pages-CCP1WfYe.js";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
// src/cli/baseline.ts
|
|
7
|
+
/**
|
|
8
|
+
* `eaa-kit baseline [dir]`.
|
|
9
|
+
*
|
|
10
|
+
* Runs the same audit the audit command runs and writes down every violation it
|
|
11
|
+
* found, so that a later run can fail on what is new instead of on everything.
|
|
12
|
+
*
|
|
13
|
+
* Deliberately a subcommand rather than a flag on `audit`. Accepting a set of
|
|
14
|
+
* violations is a decision somebody makes once and commits to a file others
|
|
15
|
+
* will read; folding it into the command that checks them would make it far too
|
|
16
|
+
* easy to type by reflex when a build goes red, which is precisely the moment
|
|
17
|
+
* it should take a deliberate act.
|
|
18
|
+
*/
|
|
19
|
+
async function runBaselineCommand(dir, options = {}) {
|
|
20
|
+
const cwd = options.cwd ?? process.cwd();
|
|
21
|
+
const resolved = await resolvePages(path.resolve(cwd, dir), {
|
|
22
|
+
...options,
|
|
23
|
+
label: dir
|
|
24
|
+
});
|
|
25
|
+
if (!resolved) return {
|
|
26
|
+
entries: 0,
|
|
27
|
+
exitCode: 2
|
|
28
|
+
};
|
|
29
|
+
const { pages, origin, label, directory } = resolved;
|
|
30
|
+
note(`Auditing ${count(pages.length, "page")} in ${label}…`);
|
|
31
|
+
const baseUrl = options.baseUrl ?? origin;
|
|
32
|
+
const audits = await runEngine(pages, {
|
|
33
|
+
cwd,
|
|
34
|
+
...options.headers === void 0 ? {} : { headers: options.headers },
|
|
35
|
+
...baseUrl === void 0 ? {} : { baseUrl },
|
|
36
|
+
...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs },
|
|
37
|
+
...options.browser ? { browser: true } : {},
|
|
38
|
+
...options.concurrency === void 0 ? {} : { concurrency: options.concurrency },
|
|
39
|
+
...directory === void 0 ? {} : { directory }
|
|
40
|
+
});
|
|
41
|
+
if (!audits) return {
|
|
42
|
+
entries: 0,
|
|
43
|
+
exitCode: 2
|
|
44
|
+
};
|
|
45
|
+
const unaudited = audits.filter((audit) => audit.error);
|
|
46
|
+
if (unaudited.length > 0) {
|
|
47
|
+
fail(`${unaudited.length} of ${audits.length} pages could not be audited, so no baseline was written`);
|
|
48
|
+
return {
|
|
49
|
+
entries: 0,
|
|
50
|
+
exitCode: 2
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
const target = options.output ?? "eaa-baseline.json";
|
|
54
|
+
if (options.prune) return await prune(audits, target, cwd);
|
|
55
|
+
const baseline = buildBaseline(audits, {
|
|
56
|
+
...options.note ? { note: options.note } : {},
|
|
57
|
+
...options.expiresOn ? { expiresOn: options.expiresOn } : {}
|
|
58
|
+
});
|
|
59
|
+
try {
|
|
60
|
+
await writeBaseline(target, baseline, cwd);
|
|
61
|
+
} catch (cause) {
|
|
62
|
+
if (cause instanceof BaselineError) {
|
|
63
|
+
failWith(cause);
|
|
64
|
+
return {
|
|
65
|
+
entries: 0,
|
|
66
|
+
exitCode: 2
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
throw cause;
|
|
70
|
+
}
|
|
71
|
+
const entries = baseline.entries.length;
|
|
72
|
+
note(`Wrote ${count(entries, "entry")} to ${target}`);
|
|
73
|
+
if (entries > 0) advise("These are barriers, not exceptions. Commit the file, then work the list down.");
|
|
74
|
+
return {
|
|
75
|
+
entries,
|
|
76
|
+
exitCode: 0
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* `--prune`: take out what this run shows is gone, and add nothing.
|
|
81
|
+
*
|
|
82
|
+
* The audit already tells anybody running it that entries no longer match and
|
|
83
|
+
* can be removed. Acting on that advice meant editing JSON by hand, entry by
|
|
84
|
+
* entry, against a file whose whole purpose is that nobody has to remember what
|
|
85
|
+
* is in it — so most people did not, and a baseline accumulated barriers that
|
|
86
|
+
* were fixed years ago while looking exactly like one that had not been read.
|
|
87
|
+
*
|
|
88
|
+
* Recording a new baseline is not the same operation and is not a substitute:
|
|
89
|
+
* it accepts whatever the site fails today, which on a bad day quietly adopts a
|
|
90
|
+
* barrier nobody agreed to.
|
|
91
|
+
*/
|
|
92
|
+
async function prune(audits, target, cwd) {
|
|
93
|
+
let existing;
|
|
94
|
+
try {
|
|
95
|
+
existing = await readBaseline(target, cwd);
|
|
96
|
+
} catch (cause) {
|
|
97
|
+
if (cause instanceof BaselineError) {
|
|
98
|
+
failWith(cause);
|
|
99
|
+
return {
|
|
100
|
+
entries: 0,
|
|
101
|
+
exitCode: 2
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
throw cause;
|
|
105
|
+
}
|
|
106
|
+
const outcome = applyBaseline(audits, existing);
|
|
107
|
+
const { baseline, removed } = pruneBaseline(existing, outcome.stale);
|
|
108
|
+
if (removed.length === 0) {
|
|
109
|
+
note(`Nothing to remove from ${target}: every entry still matches something on this run`);
|
|
110
|
+
return {
|
|
111
|
+
entries: existing.entries.length,
|
|
112
|
+
removed: 0,
|
|
113
|
+
exitCode: 0
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
await writeBaseline(target, baseline, cwd);
|
|
117
|
+
note(`Removed ${count(removed.length, "entry")} from ${target}; ${count(baseline.entries.length, "entry")} left`);
|
|
118
|
+
for (const entry of removed) note(` ${entry.page} ${entry.ruleId}`);
|
|
119
|
+
if (outcome.expired.length > 0) advise(`${count(outcome.expired.length, "entry")} have expired and suppress nothing; --prune leaves them for you to decide about`);
|
|
120
|
+
return {
|
|
121
|
+
entries: baseline.entries.length,
|
|
122
|
+
removed: removed.length,
|
|
123
|
+
exitCode: 0
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
export { runBaselineCommand as t };
|