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
|
@@ -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 };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { a as holdsHtml, i as emptyDirectoryHint, r as collectPages, t as BuildDirectoryError } from "./collect-CjucwTEF.js";
|
|
2
|
+
import { n as count } from "./text-CISDPU49.js";
|
|
3
|
+
import { c as nextStep, d as warn, l as note, o as fail, s as failWith } from "./command-C8ZFvcc1.js";
|
|
4
4
|
import path from "node:path";
|
|
5
|
-
|
|
5
|
+
// src/cli/pages.ts
|
|
6
6
|
/**
|
|
7
7
|
* Collect the pages to audit, reporting to stderr on the way.
|
|
8
8
|
*
|
|
@@ -19,8 +19,19 @@ async function resolvePages(directory, options = {}) {
|
|
|
19
19
|
warn(`No pages could be fetched from ${options.url}`);
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
22
|
+
const { kept, shells } = await setAsideShells(crawled.pages, options.browser, "absolutePath");
|
|
23
|
+
if (kept.length === 0) {
|
|
24
|
+
warn(`${options.url} serves only a single-page-app shell, which JavaScript fills in and this engine does not run.`);
|
|
25
|
+
nextStep({
|
|
26
|
+
command: `eaa-kit audit --url ${options.url} --browser`,
|
|
27
|
+
why: "audit it in Chromium, scripts and all"
|
|
28
|
+
});
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
warnUnmeasured(shells, "page", "audited");
|
|
32
|
+
crawled.completeness.unreachable.push(...shells);
|
|
22
33
|
return {
|
|
23
|
-
pages:
|
|
34
|
+
pages: kept,
|
|
24
35
|
origin: crawled.origin,
|
|
25
36
|
label: options.url,
|
|
26
37
|
completeness: crawled.completeness
|
|
@@ -57,6 +68,18 @@ async function resolvePages(directory, options = {}) {
|
|
|
57
68
|
return;
|
|
58
69
|
}
|
|
59
70
|
warnUnmeasured(unreachable, "file", "readable");
|
|
71
|
+
const { kept, shells } = await setAsideShells(pages, options.browser);
|
|
72
|
+
if (kept.length === 0) {
|
|
73
|
+
warn(`${shown} holds only a single-page-app shell, which JavaScript fills in and this engine does not run.`);
|
|
74
|
+
nextStep({
|
|
75
|
+
command: `eaa-kit audit ${shown} --browser`,
|
|
76
|
+
why: "audit it in Chromium, scripts and all"
|
|
77
|
+
});
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
warnUnmeasured(shells, "page", "audited");
|
|
81
|
+
pages = kept;
|
|
82
|
+
unreachable.push(...shells);
|
|
60
83
|
return {
|
|
61
84
|
pages,
|
|
62
85
|
directory,
|
|
@@ -70,6 +93,28 @@ async function resolvePages(directory, options = {}) {
|
|
|
70
93
|
};
|
|
71
94
|
}
|
|
72
95
|
/**
|
|
96
|
+
* Take out the pages that are empty shells a script fills in, unless the audit
|
|
97
|
+
* runs in a browser that would run the script. See `isAppShell`.
|
|
98
|
+
*/
|
|
99
|
+
async function setAsideShells(pages, browser, locate = "relativePath") {
|
|
100
|
+
if (browser) return {
|
|
101
|
+
kept: pages,
|
|
102
|
+
shells: []
|
|
103
|
+
};
|
|
104
|
+
const { isAppShell } = await import("./shell-BdQYTaBQ.js");
|
|
105
|
+
const kept = [];
|
|
106
|
+
const shells = [];
|
|
107
|
+
for (const page of pages) if (isAppShell(page.html)) shells.push({
|
|
108
|
+
location: page[locate],
|
|
109
|
+
reason: "a single-page-app shell: its content is rendered by JavaScript, which this engine does not run; audit it with --browser"
|
|
110
|
+
});
|
|
111
|
+
else kept.push(page);
|
|
112
|
+
return {
|
|
113
|
+
kept,
|
|
114
|
+
shells
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
73
118
|
* Name what was missed, up to ten of them, and count the rest.
|
|
74
119
|
*
|
|
75
120
|
* Both collectors need this and neither may skip it: a file that could not be
|
|
@@ -92,7 +137,7 @@ function warnUnmeasured(missed, noun, reached) {
|
|
|
92
137
|
* exit 2 — a run that reached no verdict, not a clean one.
|
|
93
138
|
*/
|
|
94
139
|
async function crawlPages(url, options) {
|
|
95
|
-
const { collapsedOnto, crawlSite, CrawlError, parseEntryUrl } = await import("./crawl-
|
|
140
|
+
const { collapsedOnto, crawlSite, CrawlError, parseEntryUrl } = await import("./crawl-CkHJJV4w.js");
|
|
96
141
|
let entry;
|
|
97
142
|
try {
|
|
98
143
|
entry = parseEntryUrl(url, options.allowRemote ?? false);
|
|
@@ -115,6 +160,7 @@ async function crawlPages(url, options) {
|
|
|
115
160
|
...options.maxDepth === void 0 ? {} : { maxDepth: options.maxDepth },
|
|
116
161
|
...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs },
|
|
117
162
|
...options.headers === void 0 ? {} : { headers: options.headers },
|
|
163
|
+
...options.seeds === void 0 ? {} : { seeds: options.seeds },
|
|
118
164
|
...options.fetchImpl === void 0 ? {} : { fetchImpl: options.fetchImpl }
|
|
119
165
|
});
|
|
120
166
|
if (result.pages.length === 0 && result.failures.length > 0) {
|
|
@@ -122,16 +168,19 @@ async function crawlPages(url, options) {
|
|
|
122
168
|
note(" Is the site running at that address?");
|
|
123
169
|
return;
|
|
124
170
|
}
|
|
125
|
-
const
|
|
171
|
+
const { discoveryLabel } = await import("./completeness-Cg-XIKWN.js");
|
|
172
|
+
const found = discoveryLabel(result.discovery);
|
|
126
173
|
note(`Found ${count(result.pages.length, "page")} from ${found}`);
|
|
127
174
|
const failed = result.failures.map((failure) => ({
|
|
128
175
|
location: failure.url,
|
|
129
176
|
reason: failure.reason
|
|
130
177
|
}));
|
|
131
178
|
warnUnmeasured(failed, "URL", "fetched");
|
|
179
|
+
const known = options.knownUnreachable ?? [];
|
|
180
|
+
warnUnmeasured(known, "route", "listed");
|
|
132
181
|
if (result.truncated) warn(`Stopped at ${count(result.pages.length, "page")}; the site has more. Raise --max-pages to go further.`);
|
|
133
182
|
const collapsed = collapsedOnto(result);
|
|
134
|
-
const { hasPasswordField } = await import("./entry-
|
|
183
|
+
const { hasPasswordField } = await import("./entry-kf94P140.js");
|
|
135
184
|
const landedOn = collapsed[0]?.landedOn ?? "";
|
|
136
185
|
const signInForm = collapsed.length > 0 && result.pages.some((page) => page.absolutePath === landedOn && hasPasswordField(page.html));
|
|
137
186
|
if (collapsed.length > 0) {
|
|
@@ -151,10 +200,14 @@ async function crawlPages(url, options) {
|
|
|
151
200
|
completeness: {
|
|
152
201
|
discovery: result.discovery,
|
|
153
202
|
collected: result.pages.length,
|
|
154
|
-
unreachable: [
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
203
|
+
unreachable: [
|
|
204
|
+
...failed,
|
|
205
|
+
...known,
|
|
206
|
+
...collapsed.map((redirect) => ({
|
|
207
|
+
location: redirect.requested,
|
|
208
|
+
reason: signInForm ? `answered at ${redirect.landedOn} instead, a sign-in page, so this page was not audited` : `answered at ${redirect.landedOn} instead, so this page was not audited`
|
|
209
|
+
}))
|
|
210
|
+
],
|
|
158
211
|
truncated: result.truncated,
|
|
159
212
|
...followed.redirect === void 0 ? {} : { entryRedirect: followed.redirect }
|
|
160
213
|
}
|
|
@@ -169,12 +222,13 @@ async function crawlPages(url, options) {
|
|
|
169
222
|
* and each one ends here rather than in a report about the wrong pages.
|
|
170
223
|
*/
|
|
171
224
|
async function followEntry(entry, options) {
|
|
172
|
-
const { describeSignIn, isSameSite, probeEntry } = await import("./entry-
|
|
173
|
-
const { CrawlError, DEFAULT_REQUEST_TIMEOUT_MS, MAX_BODY_BYTES, parseEntryUrl } = await import("./crawl-
|
|
225
|
+
const { describeSignIn, isSameSite, probeEntry } = await import("./entry-kf94P140.js");
|
|
226
|
+
const { CrawlError, DEFAULT_REQUEST_TIMEOUT_MS, MAX_BODY_BYTES, parseEntryUrl } = await import("./crawl-CkHJJV4w.js");
|
|
174
227
|
const probe = await probeEntry(entry, {
|
|
175
228
|
timeoutMs: options.timeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS,
|
|
176
229
|
maxBodyBytes: MAX_BODY_BYTES,
|
|
177
230
|
...options.headers === void 0 ? {} : { headers: options.headers },
|
|
231
|
+
...options.seeds === void 0 ? {} : { seeds: options.seeds },
|
|
178
232
|
...options.fetchImpl === void 0 ? {} : { fetchImpl: options.fetchImpl }
|
|
179
233
|
});
|
|
180
234
|
if (probe.error !== void 0 && probe.hops.length === 0) return { entry };
|
|
@@ -270,7 +324,7 @@ function terminalConfirm() {
|
|
|
270
324
|
*/
|
|
271
325
|
async function resolveAutomatically(options) {
|
|
272
326
|
const cwd = options.cwd ?? process.cwd();
|
|
273
|
-
const { autoDetectSource } = await import("./project-
|
|
327
|
+
const { autoDetectSource } = await import("./project-Dht13sb1.js");
|
|
274
328
|
const detected = await autoDetectSource(cwd, {
|
|
275
329
|
...options.noBuild ? { noBuild: true } : {},
|
|
276
330
|
onStep: note
|
|
@@ -282,7 +336,9 @@ async function resolveAutomatically(options) {
|
|
|
282
336
|
if (detected?.url !== void 0) {
|
|
283
337
|
const resolved = await resolvePages(void 0, {
|
|
284
338
|
...options,
|
|
285
|
-
url: detected.url
|
|
339
|
+
url: detected.url,
|
|
340
|
+
...detected.seeds === void 0 ? {} : { seeds: detected.seeds },
|
|
341
|
+
...detected.unreachable === void 0 ? {} : { knownUnreachable: detected.unreachable }
|
|
286
342
|
});
|
|
287
343
|
if (resolved === void 0) {
|
|
288
344
|
await detected.cleanup?.();
|
|
@@ -294,7 +350,14 @@ async function resolveAutomatically(options) {
|
|
|
294
350
|
};
|
|
295
351
|
}
|
|
296
352
|
await detected?.cleanup?.();
|
|
353
|
+
if (detected?.sites !== void 0) {
|
|
354
|
+
warn("Choose which site to audit, and run the audit inside it:");
|
|
355
|
+
for (const site of detected.sites) nextStep({
|
|
356
|
+
command: `cd ${site} && npx eaa-kit`,
|
|
357
|
+
why: ""
|
|
358
|
+
});
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
297
361
|
warn(await emptyDirectoryHint("./dist", cwd));
|
|
298
362
|
}
|
|
299
|
-
//#endregion
|
|
300
363
|
export { resolvePages as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { c as pageUrl, d as runOptions, f as shapeResults, n as DEFAULT_TAGS, o as failedPage } from "./result-g8dGsrcv.js";
|
|
2
|
+
import { r as isFile } from "./fs-tPD5r0wY.js";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import { stat } from "node:fs/promises";
|
|
5
5
|
import path from "node:path";
|
|
@@ -7,7 +7,7 @@ import { pathToFileURL } from "node:url";
|
|
|
7
7
|
import axe from "axe-core";
|
|
8
8
|
import { createReadStream } from "node:fs";
|
|
9
9
|
import { createServer } from "node:http";
|
|
10
|
-
|
|
10
|
+
// src/audit/serve.ts
|
|
11
11
|
/**
|
|
12
12
|
* Content types for what a static build actually contains. Anything else is
|
|
13
13
|
* served as an octet-stream, which is fine: the browser only needs to parse
|
|
@@ -109,8 +109,7 @@ function closeServer(server) {
|
|
|
109
109
|
server.close(() => resolve());
|
|
110
110
|
});
|
|
111
111
|
}
|
|
112
|
-
|
|
113
|
-
//#region src/audit/runners/playwright.ts
|
|
112
|
+
// src/audit/runners/playwright.ts
|
|
114
113
|
/** Per-page ceiling. Real pages fetch real resources, so it is looser. */
|
|
115
114
|
const DEFAULT_TIMEOUT_MS = 6e4;
|
|
116
115
|
var BrowserUnavailableError = class extends Error {
|
|
@@ -165,9 +164,13 @@ async function runBrowserAudit(directory, pages, options = {}) {
|
|
|
165
164
|
try {
|
|
166
165
|
const context = await browser.newContext({
|
|
167
166
|
viewport,
|
|
168
|
-
bypassCSP: true
|
|
169
|
-
...options.headers === void 0 ? {} : { extraHTTPHeaders: options.headers }
|
|
167
|
+
bypassCSP: true
|
|
170
168
|
});
|
|
169
|
+
if (options.headers !== void 0) {
|
|
170
|
+
const credentials = options.headers;
|
|
171
|
+
const origins = siteOrigins(pages, server?.origin);
|
|
172
|
+
await context.route("**/*", credentialsRoute(origins, credentials));
|
|
173
|
+
}
|
|
171
174
|
const audits = Array.from({ length: pages.length });
|
|
172
175
|
const lanes = Math.max(1, Math.min(options.concurrency ?? DEFAULT_CONCURRENCY, pages.length));
|
|
173
176
|
let next = 0;
|
|
@@ -238,6 +241,60 @@ function servedUrl(origin, relativePath) {
|
|
|
238
241
|
return `${origin}/${relativePath.split("/").map(encodeURIComponent).join("/")}`;
|
|
239
242
|
}
|
|
240
243
|
/**
|
|
244
|
+
* A route handler that adds `credentials` to requests for `origins`, and to
|
|
245
|
+
* nothing else, redirects included.
|
|
246
|
+
*
|
|
247
|
+
* Requests to the site are fetched here and handed back, not continued with
|
|
248
|
+
* the headers added: Playwright carries a continued request's header
|
|
249
|
+
* overrides onto every redirect hop, so a page or asset on the site that
|
|
250
|
+
* redirected elsewhere took the credentials with it. With no redirects
|
|
251
|
+
* followed here, a 3xx goes back to the browser, which follows it as a new
|
|
252
|
+
* request; that one is routed again, and leaves the site bare.
|
|
253
|
+
*
|
|
254
|
+
* One side effect, on the safe side: Chromium treats a document handed back
|
|
255
|
+
* this way as public, so it may not load assets from another loopback or
|
|
256
|
+
* private address. Turning that check off would let an audited page probe the
|
|
257
|
+
* network of the machine running the audit.
|
|
258
|
+
*/
|
|
259
|
+
function credentialsRoute(origins, credentials) {
|
|
260
|
+
return async (route) => {
|
|
261
|
+
const request = route.request();
|
|
262
|
+
if (!origins.has(originOf(request.url()))) return route.continue();
|
|
263
|
+
try {
|
|
264
|
+
const response = await route.fetch({
|
|
265
|
+
headers: {
|
|
266
|
+
...request.headers(),
|
|
267
|
+
...credentials
|
|
268
|
+
},
|
|
269
|
+
maxRedirects: 0
|
|
270
|
+
});
|
|
271
|
+
return await route.fulfill({ response });
|
|
272
|
+
} catch {
|
|
273
|
+
return route.abort();
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* The origins credentials may go to: those of the crawled pages, which a crawl
|
|
279
|
+
* keeps to one origin, and the loopback server for a build off disk.
|
|
280
|
+
*/
|
|
281
|
+
function siteOrigins(pages, serverOrigin) {
|
|
282
|
+
const origins = /* @__PURE__ */ new Set();
|
|
283
|
+
if (serverOrigin !== void 0) origins.add(serverOrigin);
|
|
284
|
+
for (const page of pages) {
|
|
285
|
+
const origin = originOf(page.absolutePath);
|
|
286
|
+
if (origin.startsWith("http")) origins.add(origin);
|
|
287
|
+
}
|
|
288
|
+
return origins;
|
|
289
|
+
}
|
|
290
|
+
function originOf(url) {
|
|
291
|
+
try {
|
|
292
|
+
return new URL(url).origin;
|
|
293
|
+
} catch {
|
|
294
|
+
return "null";
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
241
298
|
* A launch that failed because the browser was never downloaded, told as setup.
|
|
242
299
|
*
|
|
243
300
|
* The third setup failure, and the only one that used to arrive as a crash.
|
|
@@ -268,10 +325,19 @@ function launchFailure(cause) {
|
|
|
268
325
|
async function loadChromium(cwd = process.cwd()) {
|
|
269
326
|
const tried = [];
|
|
270
327
|
const specifiers = ["playwright", "@playwright/test"];
|
|
271
|
-
const
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
328
|
+
const passes = [
|
|
329
|
+
{
|
|
330
|
+
root: cwd,
|
|
331
|
+
installedIn: cwd
|
|
332
|
+
},
|
|
333
|
+
{ root: cwd },
|
|
334
|
+
{ root: void 0 }
|
|
335
|
+
];
|
|
336
|
+
const seen = /* @__PURE__ */ new Set();
|
|
337
|
+
for (const { root, installedIn } of passes) for (const specifier of specifiers) {
|
|
338
|
+
const loaded = await tryLoad(specifier, root, installedIn);
|
|
339
|
+
if (loaded === void 0 || seen.has(loaded)) continue;
|
|
340
|
+
seen.add(loaded);
|
|
275
341
|
tried.push(`${specifier}${root === void 0 ? " (from eaa-kit)" : ""}`);
|
|
276
342
|
const chromium = launcherIn(loaded);
|
|
277
343
|
if (chromium !== void 0) return chromium;
|
|
@@ -282,16 +348,33 @@ async function loadChromium(cwd = process.cwd()) {
|
|
|
282
348
|
npx playwright install chromium --force`);
|
|
283
349
|
}
|
|
284
350
|
/** Import a specifier, resolved from `root` when given. Undefined if absent. */
|
|
285
|
-
async function tryLoad(specifier, root) {
|
|
351
|
+
async function tryLoad(specifier, root, installedIn) {
|
|
286
352
|
try {
|
|
287
353
|
if (root === void 0) return await import(specifier);
|
|
288
|
-
const
|
|
289
|
-
|
|
354
|
+
const resolved = createRequire(pathToFileURL(path.join(root, "package.json")).href).resolve(specifier);
|
|
355
|
+
if (installedIn !== void 0 && !isInstalledFor(resolved, installedIn)) return void 0;
|
|
356
|
+
return await import(pathToFileURL(resolved).href);
|
|
290
357
|
} catch {
|
|
291
358
|
return;
|
|
292
359
|
}
|
|
293
360
|
}
|
|
294
361
|
/**
|
|
362
|
+
* Whether a resolved file came from the project's own dependencies: a
|
|
363
|
+
* node_modules directory in the project or above it (a monorepo hoists to its
|
|
364
|
+
* root), or Yarn's cache, which is where Plug'n'Play keeps them.
|
|
365
|
+
*/
|
|
366
|
+
function isInstalledFor(resolved, project, paths = path) {
|
|
367
|
+
const fold = paths.sep === "\\" ? (value) => value.toLowerCase() : (value) => value;
|
|
368
|
+
const file = fold(paths.resolve(resolved));
|
|
369
|
+
let dir = fold(paths.resolve(project));
|
|
370
|
+
for (;;) {
|
|
371
|
+
for (const store of ["node_modules", ".yarn"]) if (file.startsWith(paths.join(dir, store) + paths.sep)) return true;
|
|
372
|
+
const parent = paths.dirname(dir);
|
|
373
|
+
if (parent === dir) return false;
|
|
374
|
+
dir = parent;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
295
378
|
* The chromium launcher, whichever shape the module came back in.
|
|
296
379
|
*
|
|
297
380
|
* Playwright is CommonJS. Whether `await import()` of it exposes named exports
|
|
@@ -314,5 +397,4 @@ function launcherIn(module) {
|
|
|
314
397
|
if (chromium !== void 0 && typeof chromium.launch === "function") return chromium;
|
|
315
398
|
}
|
|
316
399
|
}
|
|
317
|
-
|
|
318
|
-
export { BrowserUnavailableError, runBrowserAudit };
|
|
400
|
+
export { BrowserUnavailableError, loadChromium, runBrowserAudit };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { r as isFile } from "./fs-
|
|
2
|
-
import { c as pageUrl, o as failedPage } from "./result-
|
|
1
|
+
import { r as isFile } from "./fs-tPD5r0wY.js";
|
|
2
|
+
import { c as pageUrl, o as failedPage } from "./result-g8dGsrcv.js";
|
|
3
3
|
import { Worker } from "node:worker_threads";
|
|
4
4
|
import { availableParallelism } from "node:os";
|
|
5
|
-
|
|
5
|
+
// src/audit/runners/pool.ts
|
|
6
6
|
/**
|
|
7
7
|
* Audit pages across worker threads.
|
|
8
8
|
*
|
|
@@ -110,7 +110,7 @@ async function runPooledAudit(pages, options = {}) {
|
|
|
110
110
|
* for pages the threads never reported on.
|
|
111
111
|
*/
|
|
112
112
|
async function auditHere(pages, options) {
|
|
113
|
-
const { runJsdomAudit } = await import("./jsdom-
|
|
113
|
+
const { runJsdomAudit } = await import("./jsdom-Zle--VQ1.js");
|
|
114
114
|
return runJsdomAudit(pages, options);
|
|
115
115
|
}
|
|
116
116
|
/**
|
|
@@ -230,5 +230,4 @@ async function findWorkerEntry() {
|
|
|
230
230
|
];
|
|
231
231
|
for (const candidate of candidates) if (await isFile(candidate)) return candidate;
|
|
232
232
|
}
|
|
233
|
-
//#endregion
|
|
234
233
|
export { plannedWorkers, runPooledAudit };
|