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.
Files changed (115) hide show
  1. package/README.md +182 -135
  2. package/dist/astro/index.d.ts +1 -3
  3. package/dist/astro/index.js +2 -3
  4. package/dist/audit/runners/worker.js +2 -3
  5. package/dist/{audit-DRjAY2iY.js → audit-DbqNIrt6.js} +85 -219
  6. package/dist/audit-rUhqnm3o.js +1 -0
  7. package/dist/{baseline-BpE7DbDq.js → baseline-CKElWbx4.js} +18 -8
  8. package/dist/baseline-DU0EPiTq.js +1 -0
  9. package/dist/baseline-DYOejLFO.js +1 -0
  10. package/dist/baseline-DvdsFTQy.js +126 -0
  11. package/dist/{cache-D4dOIuOi.js → cache-DIV4G0TI.js} +24 -5
  12. package/dist/{checklist-DDd9jewi.js → checklist-CA0Ri71Z.js} +8 -9
  13. package/dist/cli/index.js +115 -158
  14. package/dist/{collect-Cu1q9NTB.js → collect-CjucwTEF.js} +16 -8
  15. package/dist/{command-3r4fht5f.js → command-C8ZFvcc1.js} +33 -10
  16. package/dist/completeness-Cg-XIKWN.js +1 -0
  17. package/dist/completeness-Dzyvgr4Z.js +72 -0
  18. package/dist/component-CgbeRgJa.js +1 -0
  19. package/dist/{component-ChisoFyY.js → component-ZLd8DA_a.js} +3 -4
  20. package/dist/countries-B_PE6r5R.js +180 -0
  21. package/dist/countries-CCqog6dy.js +28 -0
  22. package/dist/coverage-B9_6yv_8.js +2 -0
  23. package/dist/{coverage-cb5kPp48.js → coverage-C1Z6t9Ct.js} +5 -7
  24. package/dist/{crawl-BHkJmUkA.js → crawl-CkHJJV4w.js} +135 -25
  25. package/dist/{criteria-CnPJKGeb.js → criteria-CacF0HP1.js} +1 -2
  26. package/dist/{load-BaWMa-G_.js → define-BdTPIfqE.js} +46 -99
  27. package/dist/detect-DnFHXpWh.js +49 -0
  28. package/dist/detect-oLDadgee.js +160 -0
  29. package/dist/doctor-q8IebwAb.js +248 -0
  30. package/dist/eleventy/index.d.ts +1 -3
  31. package/dist/eleventy/index.js +2 -3
  32. package/dist/entry-kf94P140.js +173 -0
  33. package/dist/{fingerprint-BjYV_0F7.js → fingerprint-CcoQ1WxQ.js} +1 -2
  34. package/dist/{frameworks-B4ClIJgE.js → frameworks-BboC8eNk.js} +234 -28
  35. package/dist/frameworks-Y-n3NUuG.js +1 -0
  36. package/dist/{fs-BmPtmFke.js → fs-tPD5r0wY.js} +1 -2
  37. package/dist/hosts-B48qR6Vt.js +19 -0
  38. package/dist/{html-BIxxF3FC.js → html-Bjq3Iw3g.js} +56 -14
  39. package/dist/{impact-luGCnN8F.js → impact-BGlJ6j0Y.js} +1 -2
  40. package/dist/{impact-EEB9ZXmC.d.ts → impact-CZjUloYC.d.ts} +0 -2
  41. package/dist/index.d.ts +50 -26
  42. package/dist/index.js +3 -2
  43. package/dist/init-3Ti3ao5Z.js +232 -0
  44. package/dist/issues-WLlepU95.js +120 -0
  45. package/dist/{jsdom-CsW_xVcA.js → jsdom-C4pLIMyP.js} +2 -3
  46. package/dist/jsdom-Zle--VQ1.js +2 -0
  47. package/dist/{json-Bus6YhxB.js → json-B_k4CDmR.js} +5 -6
  48. package/dist/json-IL1JxlTL.js +1 -0
  49. package/dist/load-C3eFEdoH.js +98 -0
  50. package/dist/load-oQQJPNlV.js +1 -0
  51. package/dist/markdown-D-QpPYsz.js +138 -0
  52. package/dist/next-8zDgH0nP.js +119 -0
  53. package/dist/nuxt/index.d.ts +1 -3
  54. package/dist/nuxt/index.js +2 -3
  55. package/dist/pages-CCP1WfYe.js +363 -0
  56. package/dist/{playwright-ukCr_5o3.js → playwright-ky4b_HME.js} +98 -16
  57. package/dist/{pool-B4tEUa2S.js → pool-B3XKdk57.js} +4 -5
  58. package/dist/project-B21NT_aX.js +502 -0
  59. package/dist/project-Dht13sb1.js +1 -0
  60. package/dist/{remediation-C0klJblu.js → remediation-BkE7q7dT.js} +2 -176
  61. package/dist/{render-C1sUZZI_.js → render-ky8cm4QF.js} +50 -24
  62. package/dist/result-DhoT4g0P.js +1 -0
  63. package/dist/{result-B7_zVxAX.js → result-g8dGsrcv.js} +1 -2
  64. package/dist/{review-CdMK2GpQ.js → review-BGjTBFvd.js} +11 -4
  65. package/dist/review-iheEjp7_.js +1 -0
  66. package/dist/{routes-CmdRUuOs.js → routes-BpQeBDmM.js} +4 -5
  67. package/dist/{run-DrS0Komf.js → run-D7tc7IU2.js} +2 -3
  68. package/dist/{run-BK2blxMI.d.ts → run-VXnP4uLp.d.ts} +2 -6
  69. package/dist/{sarif-BNCE0PNT.js → sarif-v66-PjdE.js} +9 -9
  70. package/dist/{schema-DJSF4K05.js → schema-DfC-Ww1w.js} +1 -2
  71. package/dist/setup-BYlqHlo0.js +2 -0
  72. package/dist/setup-Cf82ONw0.js +353 -0
  73. package/dist/shell-BdQYTaBQ.js +89 -0
  74. package/dist/site-CxVyh8IO.js +71 -0
  75. package/dist/start-bdanSxZr.js +100 -0
  76. package/dist/statement/templates/be.de.md +148 -0
  77. package/dist/statement/templates/be.en.md +142 -0
  78. package/dist/statement/templates/be.fr.md +146 -0
  79. package/dist/statement/templates/be.nl.md +147 -0
  80. package/dist/statement/templates/cz.cs.md +138 -0
  81. package/dist/statement/templates/cz.en.md +140 -0
  82. package/dist/statement/templates/dk.da.md +142 -0
  83. package/dist/statement/templates/dk.en.md +142 -0
  84. package/dist/statement/templates/fi.en.md +139 -0
  85. package/dist/statement/templates/fi.fi.md +141 -0
  86. package/dist/statement/templates/ie.en.md +144 -0
  87. package/dist/statement/templates/pl.en.md +143 -0
  88. package/dist/statement/templates/pl.pl.md +144 -0
  89. package/dist/statement/templates/pt.en.md +143 -0
  90. package/dist/statement/templates/pt.pt.md +145 -0
  91. package/dist/statement/templates/se.en.md +148 -0
  92. package/dist/statement/templates/se.sv.md +150 -0
  93. package/dist/{text-BF1LHMiV.js → text-CISDPU49.js} +11 -3
  94. package/dist/{version-B3v4rNoG.js → version-C8aJm8YJ.js} +1 -2
  95. package/dist/vite/index.d.ts +1 -3
  96. package/dist/vite/index.js +2 -3
  97. package/dist/watch-CefxwMsZ.js +121 -0
  98. package/dist/webpack/index.d.ts +1 -3
  99. package/dist/webpack/index.js +2 -3
  100. package/dist/{worksheet-BIxMtbUd.js → worksheet-CcBo9G7s.js} +4 -5
  101. package/dist/workspaces-BBFXOyeV.js +85 -0
  102. package/package.json +16 -14
  103. package/dist/audit-Bwm1xBdJ.js +0 -2
  104. package/dist/baseline-rtnj3RHB.js +0 -2
  105. package/dist/component-DcCn3BJS.js +0 -2
  106. package/dist/coverage-n1X9CkiG.js +0 -3
  107. package/dist/frameworks-etFg_O8K.js +0 -2
  108. package/dist/init-DrFfzjvm.js +0 -119
  109. package/dist/jsdom-BUYuVJJm.js +0 -3
  110. package/dist/json-CrQmoTj6.js +0 -2
  111. package/dist/load-n62iXDq_.js +0 -2
  112. package/dist/project-CzOnkLH6.js +0 -274
  113. package/dist/project-MFrXcw1M.js +0 -2
  114. package/dist/result-CRmjjoAA.js +0 -2
  115. package/dist/review-DIbOTmOM.js +0 -2
@@ -1,4 +1,4 @@
1
- //#region src/audit/criteria.ts
1
+ // src/audit/criteria.ts
2
2
  /**
3
3
  * WCAG 2.2 at Levels A and AA, which is what this tool audits against.
4
4
  *
@@ -282,5 +282,4 @@ const WCAG22_AA_CRITERIA = [
282
282
  level: "AA"
283
283
  }
284
284
  ];
285
- //#endregion
286
285
  export { WCAG22_AA_CRITERIA as t };
@@ -1,19 +1,26 @@
1
- import { n as IMPACT_LEVELS } from "./impact-luGCnN8F.js";
2
- import { _ as union, a as integer, d as optional, f as pipe, g as transform, h as string, i as enumeration, m as safeParse, n as boolean, o as isoDate, r as email, t as array, u as object, v as url, y as withDefault } from "./schema-DJSF4K05.js";
3
- import { r as isFile } from "./fs-BmPtmFke.js";
4
- import { readFile } from "node:fs/promises";
5
- import path from "node:path";
6
- import { pathToFileURL } from "node:url";
7
- //#region src/config/define.ts
8
- /** Countries with their own supervisory body and statute text. */
1
+ import { n as IMPACT_LEVELS } from "./impact-BGlJ6j0Y.js";
2
+ import { _ as union, a as integer, d as optional, f as pipe, g as transform, h as string, i as enumeration, m as safeParse, n as boolean, o as isoDate, r as email, t as array, u as object, v as url, y as withDefault } from "./schema-DfC-Ww1w.js";
3
+ // src/config/define.ts
4
+ /**
5
+ * Countries with their own supervisory body and statute text. What is known
6
+ * about each one is in `countries.ts`.
7
+ */
9
8
  const COUNTRIES = [
10
9
  "AT",
11
- "DE",
10
+ "BE",
12
11
  "CH",
12
+ "CZ",
13
+ "DE",
14
+ "DK",
13
15
  "ES",
16
+ "FI",
14
17
  "FR",
18
+ "IE",
15
19
  "IT",
16
- "NL"
20
+ "NL",
21
+ "PL",
22
+ "PT",
23
+ "SE"
17
24
  ];
18
25
  /**
19
26
  * Languages a statement can be rendered in.
@@ -24,12 +31,18 @@ const COUNTRIES = [
24
31
  * ones a country has when asked for one it does not.
25
32
  */
26
33
  const STATEMENT_LOCALES = [
34
+ "cs",
35
+ "da",
27
36
  "de",
28
37
  "en",
29
38
  "es",
39
+ "fi",
30
40
  "fr",
31
41
  "it",
32
- "nl"
42
+ "nl",
43
+ "pl",
44
+ "pt",
45
+ "sv"
33
46
  ];
34
47
  /**
35
48
  * Wording follows the EU model statement: fully, partially, or not conformant
@@ -70,6 +83,20 @@ const knownIssueObject = object({
70
83
  */
71
84
  const knownIssueSchema = union([pipe(transform(string({ min: 1 }), (description) => ({ description })), knownIssueObject), knownIssueObject], "expected a description, or an object with one");
72
85
  /**
86
+ * What a crawl does when its entry URL redirects to another site.
87
+ *
88
+ * `ask` puts the question to whoever is at the terminal and, with nobody there,
89
+ * stops. `follow` goes on to the new address, and every report says so. `stop`
90
+ * never goes on, not even to the same site at another address. A redirect
91
+ * within the same host, give or take `www.` and http or https, is followed
92
+ * under `ask` and `follow` without a question, and is still reported.
93
+ */
94
+ const REDIRECT_MODES = [
95
+ "ask",
96
+ "follow",
97
+ "stop"
98
+ ];
99
+ /**
73
100
  * Defaults for `eaa-kit audit` and `eaa-kit baseline`, so a project says once
74
101
  * what every invocation would otherwise repeat.
75
102
  *
@@ -96,6 +123,8 @@ const auditSchema = object({
96
123
  ignoreRobots: optional(boolean()),
97
124
  /** Where the site lists its pages, when that is not /sitemap.xml. */
98
125
  sitemap: optional(string({ min: 1 })),
126
+ /** What to do when the entry URL redirects to another site. */
127
+ redirects: optional(enumeration(REDIRECT_MODES)),
99
128
  maxPages: optional(integer({ min: 1 })),
100
129
  /** 0 audits the entry page alone. */
101
130
  maxDepth: optional(integer({ min: 0 })),
@@ -105,7 +134,8 @@ const auditSchema = object({
105
134
  "console",
106
135
  "json",
107
136
  "sarif",
108
- "html"
137
+ "html",
138
+ "markdown"
109
139
  ])),
110
140
  /** Write the report here instead of stdout. */
111
141
  output: optional(string({ min: 1 })),
@@ -203,10 +233,12 @@ function defineConfig(config) {
203
233
  }
204
234
  var ConfigError = class extends Error {
205
235
  issues;
236
+ next;
206
237
  name = "ConfigError";
207
- constructor(message, issues = []) {
238
+ constructor(message, issues = [], next) {
208
239
  super(message);
209
240
  this.issues = issues;
241
+ this.next = next;
210
242
  }
211
243
  };
212
244
  /** Validate an already-loaded config object. */
@@ -232,89 +264,4 @@ function parse(schema, value, source) {
232
264
  });
233
265
  throw new ConfigError(`${source} is not valid`, issues);
234
266
  }
235
- //#endregion
236
- //#region src/config/load.ts
237
- /** Checked in this order, first match wins. */
238
- const CONFIG_FILENAMES = [
239
- "eaa.config.ts",
240
- "eaa.config.mts",
241
- "eaa.config.js",
242
- "eaa.config.mjs",
243
- "eaa.config.json"
244
- ];
245
- /**
246
- * Find and load `eaa.config.{ts,mts,js,mjs,json}`.
247
- *
248
- * TypeScript configs are imported directly: Node strips types natively from
249
- * 22.18 onwards, which is below this package's floor, so no bundler or loader
250
- * dependency is needed. The failure mode that remains is a project with no
251
- * package.json at all, where Node cannot tell ESM from CommonJS; the error says
252
- * so rather than surfacing "Unexpected token 'export'".
253
- */
254
- async function loadConfig(options = {}) {
255
- const cwd = path.resolve(options.cwd ?? process.cwd());
256
- const file = options.path ? path.resolve(cwd, options.path) : await findConfigFile(cwd);
257
- if (!file) throw new ConfigError(`No config file found in ${cwd} or its parent directories`, CONFIG_FILENAMES.map((name) => `looked for ${name}`));
258
- if (!await isFile(file)) throw new ConfigError(`Config file not found: ${file}`);
259
- return {
260
- config: parseConfig(await readConfigFile(file), path.basename(file)),
261
- path: file
262
- };
263
- }
264
- /**
265
- * Find the config file and read its `audit` block, for the commands that take
266
- * defaults from it.
267
- *
268
- * Returns undefined when there is no config file at all. That is not an error
269
- * here as it is for `statement`: `eaa-kit audit` has always run against a
270
- * project that has never heard of a config file, and it must keep doing so. An
271
- * explicit path that is not there is still an error, because somebody named it.
272
- */
273
- async function loadAuditConfig(options = {}) {
274
- const cwd = path.resolve(options.cwd ?? process.cwd());
275
- const file = options.path ? path.resolve(cwd, options.path) : await findConfigFile(cwd);
276
- if (!file) return void 0;
277
- if (!await isFile(file)) throw new ConfigError(`Config file not found: ${file}`);
278
- return {
279
- audit: parseAuditConfig(await readConfigFile(file), path.basename(file)),
280
- path: file
281
- };
282
- }
283
- function readConfigFile(file) {
284
- return file.endsWith(".json") ? importJson(file) : importModule(file);
285
- }
286
- /** Walks up from `cwd`, so the CLI works from a subdirectory of the project. */
287
- async function findConfigFile(cwd) {
288
- let directory = path.resolve(cwd);
289
- while (true) {
290
- for (const name of CONFIG_FILENAMES) {
291
- const candidate = path.join(directory, name);
292
- if (await isFile(candidate)) return candidate;
293
- }
294
- const parent = path.dirname(directory);
295
- if (parent === directory) return void 0;
296
- directory = parent;
297
- }
298
- }
299
- async function importJson(file) {
300
- const raw = await readFile(file, "utf8");
301
- try {
302
- return JSON.parse(raw);
303
- } catch (cause) {
304
- throw new ConfigError(`${path.basename(file)} is not valid JSON`, [cause instanceof Error ? cause.message : String(cause)]);
305
- }
306
- }
307
- async function importModule(file) {
308
- let module;
309
- try {
310
- module = await import(`${pathToFileURL(file).href}?t=${Date.now()}`);
311
- } catch (cause) {
312
- const message = cause instanceof Error ? cause.message : String(cause);
313
- 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;
314
- throw new ConfigError(`Could not load ${path.basename(file)}`, [hint]);
315
- }
316
- if (module.default === void 0) throw new ConfigError(`${path.basename(file)} has no default export`, ["Expected: export default defineConfig({ … })"]);
317
- return module.default;
318
- }
319
- //#endregion
320
- export { ASSESSMENT_METHODS as a, ConfigError as c, configSchema as d, defineConfig as f, loadConfig as i, ISSUE_REASONS as l, findConfigFile as n, COMPLIANCE_STATUSES as o, parseConfig as p, loadAuditConfig as r, COUNTRIES as s, CONFIG_FILENAMES as t, STATEMENT_LOCALES as u };
267
+ export { ISSUE_REASONS as a, configSchema as c, parseConfig as d, ConfigError as i, defineConfig as l, COMPLIANCE_STATUSES as n, REDIRECT_MODES as o, COUNTRIES as r, STATEMENT_LOCALES as s, ASSESSMENT_METHODS as t, parseAuditConfig as u };
@@ -0,0 +1,49 @@
1
+ import path from "node:path";
2
+ import pc from "picocolors";
3
+ // src/cli/detect.ts
4
+ async function runDetectCommand(dir, options = {}) {
5
+ const { detectProject } = await import("./detect-oLDadgee.js");
6
+ const detection = await detectProject(path.resolve(dir ?? "."));
7
+ return options.json ? `${JSON.stringify(detection, null, 2)}\n` : formatDetection(detection, options);
8
+ }
9
+ function formatDetection(detection, options = {}) {
10
+ const colors = pc.createColors(options.color ?? pc.isColorSupported);
11
+ const lines = [];
12
+ const row = (label, value, why) => {
13
+ lines.push(`${label.padEnd(16)} ${value}${why === void 0 ? "" : ` ${colors.dim(`(${why})`)}`}`);
14
+ };
15
+ const framework = detection.framework;
16
+ row("Framework", framework?.name ?? "none recognised", framework === void 0 ? void 0 : framework.evidence.join("; "));
17
+ if (detection.packageManager !== void 0) row("Package manager", detection.packageManager.name, detection.packageManager.evidence);
18
+ if (detection.workspace !== void 0) row("Monorepo", detection.workspace.sites.map((site) => `${site.dir} (${site.framework})`).join(", "), detection.workspace.evidence);
19
+ const inner = detection.site ?? detection;
20
+ if (inner.site === void 0 && detection.site !== void 0) row("Site framework", inner.framework?.name ?? "none recognised", inner.framework?.evidence.join("; "));
21
+ if (inner.directory !== void 0) row("Build output", `${inner.directory}/`);
22
+ if (inner.next !== void 0) {
23
+ const { pages, dynamic } = inner.next;
24
+ row("Next.js pages", `${pages} listed by the build`, dynamic.length === 0 ? void 0 : `not listed, rendered on request: ${dynamic.join(", ")}`);
25
+ }
26
+ lines.push("");
27
+ lines.push(`${colors.bold("An audit would")} ${detection.summary}.`);
28
+ const next = nextCommand(detection);
29
+ if (next !== void 0) lines.push(` ${colors.cyan("→")} ${colors.bold(next)}`);
30
+ return `${lines.join("\n")}\n`;
31
+ }
32
+ /** The command to type next, given what was found. */
33
+ function nextCommand(detection) {
34
+ const inner = detection.site ?? detection;
35
+ if (detection.plan === "choose-site") {
36
+ const first = detection.workspace?.sites[0]?.dir;
37
+ return first === void 0 ? void 0 : `cd ${first} && npx eaa-kit detect`;
38
+ }
39
+ if (inner.appShell) return "npx eaa-kit audit --browser";
40
+ switch (inner.plan) {
41
+ case "audit-build":
42
+ case "build":
43
+ case "build-and-serve":
44
+ case "serve": return "npx eaa-kit";
45
+ case "url": return "npx eaa-kit audit --url http://localhost:8000";
46
+ default: return inner.build ?? "npx eaa-kit audit ./path/to/build";
47
+ }
48
+ }
49
+ export { runDetectCommand };
@@ -0,0 +1,160 @@
1
+ import { i as toPosix } from "./fs-tPD5r0wY.js";
2
+ import { i as detectFramework } from "./frameworks-BboC8eNk.js";
3
+ import { i as findPackageManager, o as readPackageJson, r as findBuildOutput } from "./project-B21NT_aX.js";
4
+ import path from "node:path";
5
+ // src/audit/detect.ts
6
+ async function detectProject(cwd) {
7
+ const pkg = await readPackageJson(cwd);
8
+ const manager = await findPackageManager(cwd);
9
+ const detected = await detectFramework(cwd, pkg);
10
+ const { candidateOutputs } = await import("./frameworks-Y-n3NUuG.js");
11
+ const base = {
12
+ ...detected === void 0 ? {} : { framework: {
13
+ id: detected.framework.id,
14
+ name: detected.framework.name,
15
+ evidence: detected.evidence
16
+ } },
17
+ ...pkg === void 0 ? {} : { packageManager: {
18
+ name: manager.manager,
19
+ evidence: manager.evidence
20
+ } },
21
+ plan: "nothing",
22
+ summary: "",
23
+ outputs: await candidateOutputs(cwd, pkg)
24
+ };
25
+ const run = (script) => `${manager.manager} ${manager.manager === "deno" ? "task" : "run"} ${script}`;
26
+ const relative = (dir) => toPosix(path.relative(cwd, dir)) || ".";
27
+ const existing = await findBuildOutput(cwd);
28
+ if (existing !== void 0) return {
29
+ ...base,
30
+ plan: "audit-build",
31
+ directory: relative(existing),
32
+ summary: `audit the build already in ${relative(existing)}/`
33
+ };
34
+ if (detected === void 0) {
35
+ const { findWorkspaceSites } = await import("./workspaces-BBFXOyeV.js");
36
+ const workspace = await findWorkspaceSites(cwd);
37
+ const sites = workspace?.sites ?? [];
38
+ if (workspace !== void 0 && sites.length > 0) {
39
+ const listed = {
40
+ evidence: workspace.evidence,
41
+ sites: sites.map((site) => ({
42
+ dir: site.dir,
43
+ framework: site.framework.framework.name
44
+ }))
45
+ };
46
+ const only = sites[0];
47
+ if (sites.length === 1 && only !== void 0) {
48
+ const inner = await detectProject(path.join(cwd, only.dir));
49
+ return {
50
+ ...base,
51
+ plan: inner.plan,
52
+ workspace: listed,
53
+ site: inner,
54
+ summary: `go into ${only.dir}/, this monorepo's one site, and ${inner.summary}`
55
+ };
56
+ }
57
+ return {
58
+ ...base,
59
+ plan: "choose-site",
60
+ workspace: listed,
61
+ summary: `do nothing until a site is chosen: this monorepo has ${sites.length}`
62
+ };
63
+ }
64
+ }
65
+ if (detected !== void 0 && detected.framework.outputs.length === 0) return {
66
+ ...base,
67
+ plan: "url",
68
+ ...detected.framework.serveCommand === void 0 ? {} : { serveCommand: detected.framework.serveCommand },
69
+ summary: `do nothing on its own: ${detected.framework.name} renders on a server, so start the site and audit it with --url`
70
+ };
71
+ if (pkg === void 0) {
72
+ const { glob } = await import("tinyglobby");
73
+ const html = await glob(["*.html", "*.htm"], {
74
+ cwd,
75
+ onlyFiles: true,
76
+ dot: false
77
+ });
78
+ if (detected === void 0 && html.length > 0) return {
79
+ ...base,
80
+ plan: "audit-build",
81
+ directory: ".",
82
+ summary: "audit the hand-written HTML in this folder"
83
+ };
84
+ const command = detected?.framework.buildCommand;
85
+ if (command !== void 0) return {
86
+ ...base,
87
+ build: command,
88
+ summary: `do nothing yet: build the site with ${command} first`
89
+ };
90
+ return {
91
+ ...base,
92
+ summary: "do nothing: there is no build, no package.json and no HTML here"
93
+ };
94
+ }
95
+ const scripts = pkg.scripts ?? {};
96
+ const isNext = detected?.framework.id === "next";
97
+ const nextFacts = isNext ? await readNext(cwd) : void 0;
98
+ const servesAfterBuild = isNext && nextFacts?.output !== "export";
99
+ const serveScript = servesAfterBuild ? scripts["start"] !== void 0 ? run("start") : "next start" : [
100
+ "start",
101
+ "preview",
102
+ "serve"
103
+ ].filter((name) => scripts[name] !== void 0).map(run)[0];
104
+ const withNext = nextFacts === void 0 ? {} : { next: nextFacts };
105
+ if (scripts["build"] !== void 0) {
106
+ const expected = base.outputs[0];
107
+ if (servesAfterBuild) return {
108
+ ...base,
109
+ ...withNext,
110
+ plan: "build-and-serve",
111
+ build: run("build"),
112
+ ...serveScript === void 0 ? {} : { serve: serveScript },
113
+ summary: `run ${run("build")}, start the site with ${serveScript}, and crawl the pages its build lists`
114
+ };
115
+ const shell = await sourceIsShell(cwd);
116
+ return {
117
+ ...base,
118
+ ...withNext,
119
+ plan: "build",
120
+ build: run("build"),
121
+ ...expected === void 0 ? {} : { directory: expected },
122
+ ...serveScript === void 0 ? {} : { serve: serveScript },
123
+ ...shell ? { appShell: true } : {},
124
+ summary: (expected === void 0 ? `run ${run("build")} and audit what it writes` : `run ${run("build")} and audit what it writes, expected in ${expected}/`) + (shell ? ", which is an empty app shell until JavaScript runs: add --browser" : "")
125
+ };
126
+ }
127
+ if (serveScript !== void 0) return {
128
+ ...base,
129
+ ...withNext,
130
+ plan: "serve",
131
+ serve: serveScript,
132
+ summary: `start the site with ${serveScript} and crawl it`
133
+ };
134
+ return {
135
+ ...base,
136
+ summary: "do nothing: there is no build, and no script to build or serve one"
137
+ };
138
+ }
139
+ async function readNext(cwd) {
140
+ const { nextRoutes, readNextConfig } = await import("./next-8zDgH0nP.js");
141
+ const config = await readNextConfig(cwd);
142
+ const routes = await nextRoutes(cwd);
143
+ return {
144
+ ...config.output === void 0 ? {} : { output: config.output },
145
+ ...config.basePath === void 0 ? {} : { basePath: config.basePath },
146
+ pages: routes?.pages.length ?? 0,
147
+ dynamic: routes?.dynamic ?? []
148
+ };
149
+ }
150
+ /** Whether the index.html a Vite-style build starts from is an empty shell. */
151
+ async function sourceIsShell(cwd) {
152
+ const { readFile } = await import("node:fs/promises");
153
+ const { isAppShell } = await import("./shell-BdQYTaBQ.js");
154
+ try {
155
+ return isAppShell(await readFile(path.join(cwd, "index.html"), "utf8"));
156
+ } catch {
157
+ return false;
158
+ }
159
+ }
160
+ export { detectProject };
@@ -0,0 +1,248 @@
1
+ import { t as exists } from "./fs-tPD5r0wY.js";
2
+ import { createRequire } from "node:module";
3
+ import path from "node:path";
4
+ import pc from "picocolors";
5
+ import { spawn } from "node:child_process";
6
+ // src/cli/doctor.ts
7
+ async function runDoctor(cwd, environment = {}) {
8
+ const nodeVersion = environment.nodeVersion ?? process.versions.node;
9
+ const onPath = environment.onPath ?? canRun;
10
+ const chromium = environment.chromium ?? chromiumCheck;
11
+ const checks = [];
12
+ const engines = createRequire(import.meta.url)("eaa-kit/package.json").engines.node;
13
+ checks.push(nodeSatisfies(nodeVersion, engines) ? {
14
+ label: "Node.js",
15
+ status: "ok",
16
+ detail: nodeVersion
17
+ } : {
18
+ label: "Node.js",
19
+ status: "fail",
20
+ detail: `${nodeVersion} is not supported; this needs ${engines}`,
21
+ fix: "install Node.js 22 LTS or newer from https://nodejs.org"
22
+ });
23
+ const { detectProject } = await import("./detect-oLDadgee.js");
24
+ const detection = await detectProject(cwd);
25
+ const inner = detection.site ?? detection;
26
+ const manager = detection.packageManager;
27
+ if (manager !== void 0) {
28
+ const found = await onPath(manager.name);
29
+ checks.push(found ? {
30
+ label: "Package manager",
31
+ status: "ok",
32
+ detail: `${manager.name} (${manager.evidence})`
33
+ } : {
34
+ label: "Package manager",
35
+ status: inner.build === void 0 && inner.serve === void 0 ? "warn" : "fail",
36
+ detail: `${manager.name} is what this project uses (${manager.evidence}), and it is not installed`,
37
+ fix: manager.name === "pnpm" || manager.name === "yarn" ? "corepack enable" : manager.name === "bun" ? "npm i -g bun" : manager.name === "deno" ? "npm i -g deno" : "install Node.js, which includes npm"
38
+ });
39
+ }
40
+ checks.push(siteCheck(detection));
41
+ checks.push(await configCheck(cwd));
42
+ checks.push(await ciCheck(cwd));
43
+ checks.push(await baselineCheck(cwd));
44
+ checks.push({
45
+ label: "Browser mode",
46
+ ...await chromium(cwd)
47
+ });
48
+ return {
49
+ checks,
50
+ exitCode: checks.some((item) => item.status === "fail") ? 2 : 0
51
+ };
52
+ }
53
+ function siteCheck(detection) {
54
+ const inner = detection.site ?? detection;
55
+ const label = "Site";
56
+ const name = inner.framework?.name;
57
+ switch (detection.plan) {
58
+ case "nothing": return {
59
+ label,
60
+ status: "fail",
61
+ detail: `nothing to audit: an audit would ${detection.summary}`,
62
+ fix: inner.build ?? "npx eaa-kit audit ./path/to/build"
63
+ };
64
+ case "choose-site": return {
65
+ label,
66
+ status: "warn",
67
+ detail: `a monorepo with ${detection.workspace?.sites.length ?? 0} sites`,
68
+ fix: `cd ${detection.workspace?.sites[0]?.dir ?? "<site>"} && npx eaa-kit doctor`
69
+ };
70
+ case "url": return {
71
+ label,
72
+ status: "warn",
73
+ detail: `${name} renders on a server; audit it running, with --url`,
74
+ fix: "npx eaa-kit audit --url http://localhost:8000"
75
+ };
76
+ default: return {
77
+ label,
78
+ status: inner.appShell ? "warn" : "ok",
79
+ detail: `${name ?? "HTML"}: an audit would ${detection.summary}`,
80
+ ...inner.appShell ? { fix: "npx eaa-kit audit --browser" } : {}
81
+ };
82
+ }
83
+ }
84
+ async function configCheck(cwd) {
85
+ const { findConfigFile, loadConfig } = await import("./load-oQQJPNlV.js");
86
+ const file = await findConfigFile(cwd);
87
+ if (file === void 0) return {
88
+ label: "Config",
89
+ status: "warn",
90
+ detail: "none: audits run on defaults, and statements cannot be written",
91
+ fix: "npx eaa-kit init"
92
+ };
93
+ const shown = path.relative(cwd, file) || path.basename(file);
94
+ try {
95
+ await loadConfig({
96
+ cwd,
97
+ path: file
98
+ });
99
+ return {
100
+ label: "Config",
101
+ status: "ok",
102
+ detail: shown
103
+ };
104
+ } catch (cause) {
105
+ const issues = cause.issues ?? [];
106
+ return {
107
+ label: "Config",
108
+ status: "fail",
109
+ detail: `${shown}: ${[cause.message, ...issues].join("; ")}`,
110
+ fix: "npx eaa-kit init --force"
111
+ };
112
+ }
113
+ }
114
+ /** Where the CI systems `init` knows about keep their pipelines. */
115
+ async function ciCheck(cwd) {
116
+ const { findGitRoot } = await import("./setup-BYlqHlo0.js");
117
+ const root = await findGitRoot(cwd) ?? cwd;
118
+ const { glob } = await import("tinyglobby");
119
+ const { readFile } = await import("node:fs/promises");
120
+ const candidates = [
121
+ ...(await glob([".github/workflows/*.{yml,yaml}"], {
122
+ cwd: root,
123
+ dot: true
124
+ })).sort(),
125
+ ".gitlab-ci.yml",
126
+ ".gitlab/eaa-kit.gitlab-ci.yml",
127
+ "bitbucket-pipelines.yml"
128
+ ];
129
+ for (const file of candidates) try {
130
+ if ((await readFile(path.join(root, file), "utf8")).includes("eaa-kit")) return {
131
+ label: "CI",
132
+ status: "ok",
133
+ detail: file
134
+ };
135
+ } catch {}
136
+ return {
137
+ label: "CI",
138
+ status: "warn",
139
+ detail: "no pipeline runs eaa-kit, so nothing stops a barrier being merged",
140
+ fix: "npx eaa-kit init"
141
+ };
142
+ }
143
+ async function baselineCheck(cwd) {
144
+ const { DEFAULT_BASELINE_FILE, readBaseline } = await import("./baseline-DYOejLFO.js");
145
+ if (!await exists(path.join(cwd, DEFAULT_BASELINE_FILE))) return {
146
+ label: "Baseline",
147
+ status: "warn",
148
+ detail: "none: CI fails on every barrier the site has today, not only new ones",
149
+ fix: "npx eaa-kit init"
150
+ };
151
+ try {
152
+ const baseline = await readBaseline(DEFAULT_BASELINE_FILE, cwd);
153
+ const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
154
+ const expired = baseline.entries.filter((entry) => entry.expiresOn !== void 0 && entry.expiresOn < today).length;
155
+ const count = `${baseline.entries.length} ${baseline.entries.length === 1 ? "entry" : "entries"}`;
156
+ if (expired > 0) return {
157
+ label: "Baseline",
158
+ status: "warn",
159
+ detail: `${DEFAULT_BASELINE_FILE}: ${expired} ${expired === 1 ? "entry has" : "entries have"} expired and no longer suppress anything`,
160
+ fix: "npx eaa-kit baseline"
161
+ };
162
+ return {
163
+ label: "Baseline",
164
+ status: "ok",
165
+ detail: `${DEFAULT_BASELINE_FILE}, ${count}`
166
+ };
167
+ } catch (cause) {
168
+ return {
169
+ label: "Baseline",
170
+ status: "fail",
171
+ detail: cause.message,
172
+ fix: "npx eaa-kit baseline"
173
+ };
174
+ }
175
+ }
176
+ async function chromiumCheck(cwd) {
177
+ const { loadChromium } = await import("./playwright-ky4b_HME.js");
178
+ let launcher;
179
+ try {
180
+ launcher = await loadChromium(cwd);
181
+ } catch {
182
+ return {
183
+ status: "skip",
184
+ detail: "optional, for --browser: Playwright is not installed",
185
+ fix: "npm i -D playwright && npx playwright install chromium"
186
+ };
187
+ }
188
+ const executable = launcher.executablePath?.();
189
+ if (executable !== void 0 && !await exists(executable)) return {
190
+ status: "warn",
191
+ detail: "Playwright is installed, but the Chromium it drives is not",
192
+ fix: "npx playwright install chromium"
193
+ };
194
+ return {
195
+ status: "ok",
196
+ detail: "Playwright and Chromium are installed, for --browser"
197
+ };
198
+ }
199
+ /** Whether `command --version` runs. */
200
+ async function canRun(command) {
201
+ return new Promise((resolve) => {
202
+ const child = spawn(command, ["--version"], {
203
+ stdio: "ignore",
204
+ shell: process.platform === "win32"
205
+ });
206
+ child.on("error", () => resolve(false));
207
+ child.on("close", (code) => resolve(code === 0));
208
+ });
209
+ }
210
+ /**
211
+ * Whether a Node version satisfies an `engines` range of the forms this
212
+ * package uses: `^x.y.z`, `>=x.y.z`, joined with `||`. Not a semver library,
213
+ * because one range is all it has to read.
214
+ */
215
+ function nodeSatisfies(version, range) {
216
+ const parse = (value) => value.replace(/^v/, "").split(".").map((part) => Number.parseInt(part, 10) || 0);
217
+ const compare = (a, b) => {
218
+ for (let i = 0; i < 3; i++) {
219
+ const diff = (a[i] ?? 0) - (b[i] ?? 0);
220
+ if (diff !== 0) return diff;
221
+ }
222
+ return 0;
223
+ };
224
+ const have = parse(version);
225
+ return range.split("||").some((alternative) => {
226
+ const clause = alternative.trim();
227
+ if (clause.startsWith("^")) {
228
+ const want = parse(clause.slice(1));
229
+ return have[0] === want[0] && compare(have, want) >= 0;
230
+ }
231
+ if (clause.startsWith(">=")) return compare(have, parse(clause.slice(2))) >= 0;
232
+ return compare(have, parse(clause)) === 0;
233
+ });
234
+ }
235
+ function formatDoctor(result, color = pc.isColorSupported) {
236
+ const colors = pc.createColors(color);
237
+ const mark = {
238
+ ok: colors.green("✓"),
239
+ warn: colors.yellow("!"),
240
+ fail: colors.red("✗"),
241
+ skip: colors.dim("–")
242
+ };
243
+ const lines = result.checks.flatMap((item) => [`${mark[item.status]} ${item.label.padEnd(16)} ${item.detail}`, ...item.fix === void 0 || item.status === "ok" ? [] : [` ${" ".repeat(16)} ${colors.cyan("→")} ${colors.bold(item.fix)}`]]);
244
+ const failed = result.checks.filter((item) => item.status === "fail").length;
245
+ lines.push("", failed === 0 ? "Nothing stops an audit from running here." : `${failed} ${failed === 1 ? "problem stops" : "problems stop"} an audit from running here.`);
246
+ return `${lines.join("\n")}\n`;
247
+ }
248
+ export { formatDoctor, runDoctor };
@@ -1,5 +1,4 @@
1
- import { n as IntegrationOptions, t as BuildAuditError } from "../run-BK2blxMI.js";
2
- //#region src/eleventy/index.d.ts
1
+ import { n as IntegrationOptions, t as BuildAuditError } from "../run-VXnP4uLp.js";
3
2
  /** What `eleventy.after` is given. Only two of its fields are read. */
4
3
  interface EleventyAfterEvent {
5
4
  dir: {
@@ -24,5 +23,4 @@ type EaaKitEleventyOptions = IntegrationOptions;
24
23
  * would be the one people got wrong.
25
24
  */
26
25
  declare function eaaKit(eleventyConfig: EleventyConfigLike, options?: EaaKitEleventyOptions): void;
27
- //#endregion
28
26
  export { BuildAuditError, EaaKitEleventyOptions, EleventyAfterEvent, EleventyConfigLike, eaaKit as default };