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
package/dist/project-v2PoRw70.js
DELETED
|
@@ -1,291 +0,0 @@
|
|
|
1
|
-
import { n as isDirectory, t as exists } from "./fs-BmPtmFke.js";
|
|
2
|
-
import { r as candidateOutputs } from "./frameworks-B4ClIJgE.js";
|
|
3
|
-
import { readFile } from "node:fs/promises";
|
|
4
|
-
import path from "node:path";
|
|
5
|
-
import { glob } from "tinyglobby";
|
|
6
|
-
import { spawn } from "node:child_process";
|
|
7
|
-
//#region src/audit/project.ts
|
|
8
|
-
/**
|
|
9
|
-
* Working out what to audit when nobody said.
|
|
10
|
-
*
|
|
11
|
-
* `eaa-kit audit ./dist` assumes the reader knows which directory their builder
|
|
12
|
-
* fills, that it has been built, and that it produces HTML at all — three
|
|
13
|
-
* assumptions that are wrong often enough to be the main thing standing between
|
|
14
|
-
* installing this tool and getting a report out of it. A Next.js project fails
|
|
15
|
-
* all three at once.
|
|
16
|
-
*
|
|
17
|
-
* So with no directory and no --url, the tool works it out: an existing build
|
|
18
|
-
* output if there is one, the project's own build if there is not, and the
|
|
19
|
-
* project's server if the build produces nothing browsable. Naming a directory
|
|
20
|
-
* or passing --url skips all of it.
|
|
21
|
-
*/
|
|
22
|
-
/** Ports the common dev and preview servers use, tried if nothing is announced. */
|
|
23
|
-
const KNOWN_PORTS = [
|
|
24
|
-
3e3,
|
|
25
|
-
4321,
|
|
26
|
-
5173,
|
|
27
|
-
8080,
|
|
28
|
-
4173,
|
|
29
|
-
3001
|
|
30
|
-
];
|
|
31
|
-
/** How long to wait for a started server to answer. */
|
|
32
|
-
const SERVER_START_TIMEOUT_MS = 9e4;
|
|
33
|
-
async function readPackageJson(cwd) {
|
|
34
|
-
try {
|
|
35
|
-
return JSON.parse(await readFile(path.join(cwd, "package.json"), "utf8"));
|
|
36
|
-
} catch {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* The package manager this project uses, from its lockfile.
|
|
42
|
-
*
|
|
43
|
-
* Running the wrong one either fails or, worse, silently installs a second
|
|
44
|
-
* dependency tree, so the lockfile decides rather than a guess.
|
|
45
|
-
*/
|
|
46
|
-
async function detectPackageManager(cwd) {
|
|
47
|
-
for (const [file, manager] of [
|
|
48
|
-
["pnpm-lock.yaml", "pnpm"],
|
|
49
|
-
["yarn.lock", "yarn"],
|
|
50
|
-
["bun.lockb", "bun"]
|
|
51
|
-
]) if (await exists(path.join(cwd, file))) return manager;
|
|
52
|
-
return "npm";
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* The first build directory that exists and actually holds HTML.
|
|
56
|
-
*
|
|
57
|
-
* Existence alone is not enough: `.next/` exists after any Next.js build and
|
|
58
|
-
* holds no browsable page, and `public/` exists in most projects and holds
|
|
59
|
-
* assets. What makes a directory the build output is that there is HTML in it.
|
|
60
|
-
*/
|
|
61
|
-
async function findBuildOutput(cwd) {
|
|
62
|
-
const candidates = await candidateOutputs(cwd, await readPackageJson(cwd));
|
|
63
|
-
for (const candidate of candidates) {
|
|
64
|
-
const directory = path.join(cwd, candidate);
|
|
65
|
-
if (!await isDirectory(directory)) continue;
|
|
66
|
-
if ((await glob(["**/*.html", "**/*.htm"], {
|
|
67
|
-
cwd: directory,
|
|
68
|
-
ignore: ["**/node_modules/**"],
|
|
69
|
-
onlyFiles: true,
|
|
70
|
-
dot: false
|
|
71
|
-
})).length > 0) return directory;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
/** Whether a folder has an HTML file directly in it, not only somewhere below. */
|
|
75
|
-
async function holdsTopLevelHtml(cwd) {
|
|
76
|
-
return (await glob(["*.html", "*.htm"], {
|
|
77
|
-
cwd,
|
|
78
|
-
onlyFiles: true,
|
|
79
|
-
dot: false
|
|
80
|
-
})).length > 0;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* How to invoke a package-manager script on this platform.
|
|
84
|
-
*
|
|
85
|
-
* Not `shell: true` with an argument array: Node deprecated that in DEP0190
|
|
86
|
-
* because the arguments are concatenated rather than escaped, and it prints a
|
|
87
|
-
* warning into the middle of somebody's build output. Windows still needs a
|
|
88
|
-
* shell — npm and pnpm are `.cmd` shims there, which cannot be spawned
|
|
89
|
-
* directly — so cmd.exe is invoked explicitly with one command string instead.
|
|
90
|
-
*/
|
|
91
|
-
function scriptCommand(manager, script) {
|
|
92
|
-
if (process.platform !== "win32") return {
|
|
93
|
-
command: manager,
|
|
94
|
-
args: ["run", script]
|
|
95
|
-
};
|
|
96
|
-
return {
|
|
97
|
-
command: process.env["ComSpec"] ?? "cmd.exe",
|
|
98
|
-
args: [
|
|
99
|
-
"/d",
|
|
100
|
-
"/s",
|
|
101
|
-
"/c",
|
|
102
|
-
`${manager} run ${script}`
|
|
103
|
-
]
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Run one of the project's own scripts and wait for it.
|
|
108
|
-
*
|
|
109
|
-
* stdio is inherited so the build's output goes where the user expects it. This
|
|
110
|
-
* runs project code, which is what a build-time tool does — the Astro
|
|
111
|
-
* integration already audits from inside one — but it is announced first and
|
|
112
|
-
* `--no-build` turns it off.
|
|
113
|
-
*/
|
|
114
|
-
async function runScript(cwd, script) {
|
|
115
|
-
const manager = await detectPackageManager(cwd);
|
|
116
|
-
const command = `${manager} run ${script}`;
|
|
117
|
-
return new Promise((resolve) => {
|
|
118
|
-
const { command: bin, args } = scriptCommand(manager, script);
|
|
119
|
-
const child = spawn(bin, args, {
|
|
120
|
-
cwd,
|
|
121
|
-
stdio: [
|
|
122
|
-
"ignore",
|
|
123
|
-
"inherit",
|
|
124
|
-
"inherit"
|
|
125
|
-
]
|
|
126
|
-
});
|
|
127
|
-
child.on("error", () => resolve({
|
|
128
|
-
ok: false,
|
|
129
|
-
command
|
|
130
|
-
}));
|
|
131
|
-
child.on("close", (code) => resolve({
|
|
132
|
-
ok: code === 0,
|
|
133
|
-
command
|
|
134
|
-
}));
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
/** Whether something is answering HTTP there yet. */
|
|
138
|
-
async function answers(origin) {
|
|
139
|
-
try {
|
|
140
|
-
const controller = new AbortController();
|
|
141
|
-
const timer = setTimeout(() => controller.abort(), 2e3);
|
|
142
|
-
try {
|
|
143
|
-
await fetch(origin, { signal: controller.signal });
|
|
144
|
-
return true;
|
|
145
|
-
} finally {
|
|
146
|
-
clearTimeout(timer);
|
|
147
|
-
}
|
|
148
|
-
} catch {
|
|
149
|
-
return false;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Start the project's server and wait until it answers.
|
|
154
|
-
*
|
|
155
|
-
* The origin is taken from whatever the server prints, since a project may be
|
|
156
|
-
* on any port, and only falls back to probing the common ones. Returns undefined
|
|
157
|
-
* if nothing came up before the timeout, having already stopped the process.
|
|
158
|
-
*/
|
|
159
|
-
async function startServer(cwd, script) {
|
|
160
|
-
const { command: bin, args } = scriptCommand(await detectPackageManager(cwd), script);
|
|
161
|
-
const child = spawn(bin, args, {
|
|
162
|
-
cwd,
|
|
163
|
-
stdio: [
|
|
164
|
-
"ignore",
|
|
165
|
-
"pipe",
|
|
166
|
-
"pipe"
|
|
167
|
-
],
|
|
168
|
-
detached: process.platform !== "win32"
|
|
169
|
-
});
|
|
170
|
-
let announced;
|
|
171
|
-
const watch = (chunk) => {
|
|
172
|
-
const match = /https?:\/\/(?:localhost|127\.0\.0\.1|\[::1\]):(\d{2,5})/.exec(String(chunk));
|
|
173
|
-
if (match && announced === void 0) announced = `http://localhost:${match[1]}`;
|
|
174
|
-
};
|
|
175
|
-
child.stdout?.on("data", watch);
|
|
176
|
-
child.stderr?.on("data", watch);
|
|
177
|
-
let stopped = false;
|
|
178
|
-
const stop = async () => {
|
|
179
|
-
if (stopped) return;
|
|
180
|
-
stopped = true;
|
|
181
|
-
const signal = (name) => {
|
|
182
|
-
try {
|
|
183
|
-
if (child.pid === void 0) return;
|
|
184
|
-
if (process.platform === "win32") child.kill(name);
|
|
185
|
-
else process.kill(-child.pid, name);
|
|
186
|
-
} catch {}
|
|
187
|
-
};
|
|
188
|
-
if (child.exitCode === null && child.signalCode === null) {
|
|
189
|
-
signal("SIGTERM");
|
|
190
|
-
await new Promise((resolve) => {
|
|
191
|
-
const timer = setTimeout(() => {
|
|
192
|
-
signal("SIGKILL");
|
|
193
|
-
resolve();
|
|
194
|
-
}, 5e3);
|
|
195
|
-
child.once("close", () => {
|
|
196
|
-
clearTimeout(timer);
|
|
197
|
-
resolve();
|
|
198
|
-
});
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
child.stdout?.destroy();
|
|
202
|
-
child.stderr?.destroy();
|
|
203
|
-
child.unref();
|
|
204
|
-
};
|
|
205
|
-
const deadline = Date.now() + SERVER_START_TIMEOUT_MS;
|
|
206
|
-
while (Date.now() < deadline) {
|
|
207
|
-
if (child.exitCode !== null) return void 0;
|
|
208
|
-
for (const origin of announced === void 0 ? KNOWN_PORTS.map((port) => `http://localhost:${port}`) : [announced]) if (await answers(origin)) return {
|
|
209
|
-
origin,
|
|
210
|
-
stop
|
|
211
|
-
};
|
|
212
|
-
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
213
|
-
}
|
|
214
|
-
await stop();
|
|
215
|
-
}
|
|
216
|
-
/**
|
|
217
|
-
* Work out what to audit in this project, building or serving it if need be.
|
|
218
|
-
*
|
|
219
|
-
* Returns undefined when there is nothing it can do, leaving the caller to
|
|
220
|
-
* explain — it has better context for the message than this does.
|
|
221
|
-
*/
|
|
222
|
-
async function autoDetectSource(cwd, options = {}) {
|
|
223
|
-
const steps = [];
|
|
224
|
-
const step = (message) => {
|
|
225
|
-
steps.push(message);
|
|
226
|
-
options.onStep?.(message);
|
|
227
|
-
};
|
|
228
|
-
const existing = await findBuildOutput(cwd);
|
|
229
|
-
if (existing !== void 0) {
|
|
230
|
-
step(`Found a build in ${path.relative(cwd, existing) || "."}/`);
|
|
231
|
-
return {
|
|
232
|
-
directory: existing,
|
|
233
|
-
steps
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
|
-
const pkg = await readPackageJson(cwd);
|
|
237
|
-
const { detectFramework } = await import("./frameworks-etFg_O8K.js");
|
|
238
|
-
const detected = await detectFramework(cwd, pkg);
|
|
239
|
-
if (detected !== void 0 && detected.framework.outputs.length === 0) {
|
|
240
|
-
step(`${detected.framework.name} renders on a server and writes no HTML to disk`);
|
|
241
|
-
return { steps };
|
|
242
|
-
}
|
|
243
|
-
if (pkg === void 0) {
|
|
244
|
-
if (detected === void 0 && await holdsTopLevelHtml(cwd)) {
|
|
245
|
-
step("Found hand-written HTML in this folder");
|
|
246
|
-
return {
|
|
247
|
-
directory: cwd,
|
|
248
|
-
steps
|
|
249
|
-
};
|
|
250
|
-
}
|
|
251
|
-
return;
|
|
252
|
-
}
|
|
253
|
-
const scripts = pkg.scripts ?? {};
|
|
254
|
-
if (options.noBuild) return void 0;
|
|
255
|
-
if (scripts["build"] !== void 0) {
|
|
256
|
-
step("No build found; running the project build first");
|
|
257
|
-
const built = await runScript(cwd, "build");
|
|
258
|
-
if (!built.ok) {
|
|
259
|
-
step(`${built.command} failed`);
|
|
260
|
-
return { steps };
|
|
261
|
-
}
|
|
262
|
-
const produced = await findBuildOutput(cwd);
|
|
263
|
-
if (produced !== void 0) {
|
|
264
|
-
step(`Built ${path.relative(cwd, produced) || "."}/`);
|
|
265
|
-
return {
|
|
266
|
-
directory: produced,
|
|
267
|
-
steps
|
|
268
|
-
};
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
const serveScript = [
|
|
272
|
-
"start",
|
|
273
|
-
"preview",
|
|
274
|
-
"serve"
|
|
275
|
-
].find((name) => scripts[name] !== void 0);
|
|
276
|
-
if (serveScript === void 0) return { steps };
|
|
277
|
-
step(`This site renders on a server; starting it with ${serveScript}`);
|
|
278
|
-
const server = await startServer(cwd, serveScript);
|
|
279
|
-
if (server === void 0) {
|
|
280
|
-
step(`Could not start the site with ${serveScript}`);
|
|
281
|
-
return { steps };
|
|
282
|
-
}
|
|
283
|
-
step(`Auditing ${server.origin}`);
|
|
284
|
-
return {
|
|
285
|
-
url: server.origin,
|
|
286
|
-
cleanup: server.stop,
|
|
287
|
-
steps
|
|
288
|
-
};
|
|
289
|
-
}
|
|
290
|
-
//#endregion
|
|
291
|
-
export { runScript as a, readPackageJson as i, detectPackageManager as n, startServer as o, findBuildOutput as r, autoDetectSource as t };
|
package/dist/result-CRmjjoAA.js
DELETED
package/dist/review-a-2ghjQ5.js
DELETED