eaa-kit 0.7.0 → 0.9.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 (66) hide show
  1. package/README.md +30 -8
  2. package/dist/astro/index.js +1 -1
  3. package/dist/audit-CJDCQaFY.js +2 -0
  4. package/dist/{audit-DRjAY2iY.js → audit-J2jeLo-y.js} +38 -198
  5. package/dist/{baseline-rtnj3RHB.js → baseline-477B1CZ_.js} +1 -1
  6. package/dist/baseline-D9ihb-wk.js +2 -0
  7. package/dist/{baseline-BpE7DbDq.js → baseline-DrFh7joZ.js} +14 -3
  8. package/dist/baseline-wyJsSIFQ.js +127 -0
  9. package/dist/{checklist-DDd9jewi.js → checklist-Gx2g3LFC.js} +6 -6
  10. package/dist/cli/index.js +83 -143
  11. package/dist/{collect-Cu1q9NTB.js → collect-BJYk7_pJ.js} +1 -1
  12. package/dist/{command-3r4fht5f.js → command-BGGMf4vn.js} +30 -4
  13. package/dist/countries-DRTBubeE.js +25 -0
  14. package/dist/countries-Dg0BdytB.js +156 -0
  15. package/dist/{coverage-n1X9CkiG.js → coverage-GvaMpV64.js} +1 -1
  16. package/dist/{coverage-cb5kPp48.js → coverage-zdzgSKjz.js} +1 -1
  17. package/dist/{crawl-BHkJmUkA.js → crawl-DwdqiljK.js} +5 -3
  18. package/dist/{load-BaWMa-G_.js → define-Ctf2uOEh.js} +41 -94
  19. package/dist/eleventy/index.js +1 -1
  20. package/dist/entry-CjqjrUBY.js +174 -0
  21. package/dist/{html-BIxxF3FC.js → html-whingnfj.js} +6 -4
  22. package/dist/index.d.ts +42 -5
  23. package/dist/index.js +3 -2
  24. package/dist/init-CPbFVMuk.js +293 -0
  25. package/dist/{json-CrQmoTj6.js → json-CyLmvF5P.js} +1 -1
  26. package/dist/{json-Bus6YhxB.js → json-SGCgxSPT.js} +1 -1
  27. package/dist/load-CH-ltdlq.js +99 -0
  28. package/dist/load-D7lBeOsq.js +2 -0
  29. package/dist/nuxt/index.js +1 -1
  30. package/dist/pages-DxY5Z0gl.js +300 -0
  31. package/dist/{project-MFrXcw1M.js → project-BLFdCbOq.js} +1 -1
  32. package/dist/{project-CzOnkLH6.js → project-v2PoRw70.js} +18 -1
  33. package/dist/{remediation-C0klJblu.js → remediation-Bbs4KcX1.js} +18 -1
  34. package/dist/{render-C1sUZZI_.js → render-C6zYfaba.js} +29 -5
  35. package/dist/{review-CdMK2GpQ.js → review-Bz0fO9_I.js} +9 -1
  36. package/dist/{review-DIbOTmOM.js → review-a-2ghjQ5.js} +1 -1
  37. package/dist/{routes-CmdRUuOs.js → routes-CSctpS1P.js} +1 -1
  38. package/dist/{run-DrS0Komf.js → run-DzVEOkiF.js} +1 -1
  39. package/dist/{sarif-BNCE0PNT.js → sarif-9BAgNiOa.js} +3 -2
  40. package/dist/site-BHMtf3q2.js +72 -0
  41. package/dist/start-DzOM0p6I.js +101 -0
  42. package/dist/statement/templates/be.de.md +148 -0
  43. package/dist/statement/templates/be.en.md +142 -0
  44. package/dist/statement/templates/be.fr.md +146 -0
  45. package/dist/statement/templates/be.nl.md +147 -0
  46. package/dist/statement/templates/cz.cs.md +137 -0
  47. package/dist/statement/templates/cz.en.md +139 -0
  48. package/dist/statement/templates/dk.da.md +141 -0
  49. package/dist/statement/templates/dk.en.md +141 -0
  50. package/dist/statement/templates/fi.en.md +139 -0
  51. package/dist/statement/templates/fi.fi.md +141 -0
  52. package/dist/statement/templates/ie.en.md +144 -0
  53. package/dist/statement/templates/pl.en.md +143 -0
  54. package/dist/statement/templates/pl.pl.md +144 -0
  55. package/dist/statement/templates/pt.en.md +142 -0
  56. package/dist/statement/templates/pt.pt.md +145 -0
  57. package/dist/statement/templates/se.en.md +139 -0
  58. package/dist/statement/templates/se.sv.md +142 -0
  59. package/dist/vite/index.js +1 -1
  60. package/dist/watch-B2RoUbo0.js +122 -0
  61. package/dist/webpack/index.js +1 -1
  62. package/dist/{worksheet-BIxMtbUd.js → worksheet-B_kQ1pxq.js} +1 -1
  63. package/package.json +2 -2
  64. package/dist/audit-Bwm1xBdJ.js +0 -2
  65. package/dist/init-DrFfzjvm.js +0 -119
  66. package/dist/load-n62iXDq_.js +0 -2
@@ -0,0 +1,293 @@
1
+ import { t as DEFAULT_FAIL_ON } from "./impact-luGCnN8F.js";
2
+ import { r as COUNTRIES } from "./define-Ctf2uOEh.js";
3
+ import { t as exists } from "./fs-BmPtmFke.js";
4
+ import { t as CONFIG_FILENAMES } from "./load-CH-ltdlq.js";
5
+ import { t as TOOL_VERSION } from "./version-B3v4rNoG.js";
6
+ import { n as DEFAULT_BASELINE_FILE } from "./baseline-DrFh7joZ.js";
7
+ import { c as nextStep, d as warn, l as note, o as fail } from "./command-BGGMf4vn.js";
8
+ import { i as readPackageJson, n as detectPackageManager } from "./project-v2PoRw70.js";
9
+ import { n as countryForLocale, r as findCountry, t as COUNTRY_INFO } from "./countries-Dg0BdytB.js";
10
+ import { mkdir, readFile, stat, writeFile } from "node:fs/promises";
11
+ import path from "node:path";
12
+ import pc from "picocolors";
13
+ import { createInterface } from "node:readline/promises";
14
+ //#region src/cli/setup.ts
15
+ /**
16
+ * The CI half of `eaa-kit init`: a GitHub Actions workflow written for this
17
+ * project rather than copied from the docs and edited until it works.
18
+ *
19
+ * Everything in it is read from the project. The package manager comes from
20
+ * the lockfile, the build from the `build` script, the directory from what
21
+ * `init` found, and the baseline from whether one was just recorded. Anything
22
+ * it cannot read is left to the action's own detection rather than guessed,
23
+ * because a workflow that fails on its first push teaches somebody to switch
24
+ * it off.
25
+ */
26
+ /** Where the workflow goes, relative to the repository root. */
27
+ const WORKFLOW_FILE = path.join(".github", "workflows", "accessibility.yml");
28
+ /** The repository this project is in, found the way git finds it: upwards. */
29
+ async function findGitRoot(cwd) {
30
+ let current = path.resolve(cwd);
31
+ for (;;) try {
32
+ await stat(path.join(current, ".git"));
33
+ return current;
34
+ } catch {
35
+ const parent = path.dirname(current);
36
+ if (parent === current) return void 0;
37
+ current = parent;
38
+ }
39
+ }
40
+ /** The branch HEAD points at, which is the one worth auditing on push. */
41
+ async function currentBranch(root) {
42
+ try {
43
+ const head = await readFile(path.join(root, ".git", "HEAD"), "utf8");
44
+ return /^ref: refs\/heads\/(.+)$/m.exec(head)?.[1]?.trim();
45
+ } catch {
46
+ return;
47
+ }
48
+ }
49
+ /**
50
+ * The workflow, as text. YAML is written by hand rather than through a
51
+ * library: it is one fixed shape with a few values in it, and the comments in
52
+ * it are the documentation somebody reads when it first fails.
53
+ */
54
+ async function workflowFor(inputs) {
55
+ const pkg = await readPackageJson(inputs.cwd);
56
+ const manager = pkg === void 0 ? void 0 : await detectPackageManager(inputs.cwd);
57
+ const branch = await currentBranch(inputs.root) ?? "main";
58
+ const workingDirectory = toPosix(path.relative(inputs.root, inputs.cwd));
59
+ const directory = inputs.site === void 0 ? "" : toPosix(path.relative(inputs.cwd, inputs.site)) || ".";
60
+ const setup = [];
61
+ if (manager === "pnpm") setup.push(" - uses: pnpm/action-setup@v4", ...typeof pkg?.packageManager === "string" ? [] : [" with:", " version: 10"]);
62
+ if (manager === "bun") setup.push(" - uses: oven-sh/setup-bun@v2");
63
+ const install = manager === void 0 ? void 0 : {
64
+ npm: "npm ci",
65
+ pnpm: "pnpm install --frozen-lockfile",
66
+ yarn: "yarn install --frozen-lockfile",
67
+ bun: "bun install --frozen-lockfile"
68
+ }[manager];
69
+ const build = manager !== void 0 && pkg?.scripts?.["build"] !== void 0 ? `${manager} run build` : void 0;
70
+ const withLines = [
71
+ ...workingDirectory === "" ? [] : [`working-directory: ${workingDirectory}`],
72
+ ...install === void 0 ? [] : [`install-command: ${install}`],
73
+ ...build === void 0 ? [] : [`build-command: ${build}`],
74
+ `directory: ${directory === "" ? "''" : directory}`,
75
+ `fail-on: ${inputs.failOn}`,
76
+ ...inputs.baseline === void 0 ? [] : [`baseline: ${toPosix(inputs.baseline)}`]
77
+ ].map((line) => ` ${line}`);
78
+ return [
79
+ "# Written by eaa-kit init. Audits the built site against WCAG 2.2 AA on every",
80
+ "# push and pull request, uploads what it finds to GitHub code scanning, and",
81
+ "# fails the job on barriers at or above fail-on.",
82
+ "#",
83
+ "# The inputs are documented at",
84
+ "# https://github.com/likeBloodMoon/eaa-kit/blob/master/docs/integrations.md#github-actions",
85
+ "name: Accessibility",
86
+ "",
87
+ "on:",
88
+ " push:",
89
+ ` branches: [${branch}]`,
90
+ " pull_request:",
91
+ "",
92
+ "permissions:",
93
+ " contents: read",
94
+ " # Required by the SARIF upload to code scanning.",
95
+ " security-events: write",
96
+ "",
97
+ "jobs:",
98
+ " audit:",
99
+ " runs-on: ubuntu-latest",
100
+ " steps:",
101
+ " - uses: actions/checkout@v4",
102
+ ...setup,
103
+ " - uses: actions/setup-node@v4",
104
+ " with:",
105
+ " node-version: 22",
106
+ ` - uses: likeBloodMoon/eaa-kit@v${TOOL_VERSION}`,
107
+ " with:",
108
+ ...withLines,
109
+ ""
110
+ ].join("\n");
111
+ }
112
+ function toPosix(value) {
113
+ return value.split(path.sep).join("/");
114
+ }
115
+ //#endregion
116
+ //#region src/cli/init.ts
117
+ /**
118
+ * Everything the project already says about itself.
119
+ *
120
+ * A guess that is wrong is worse than an empty field somebody has to fill, so
121
+ * this only reads what a project states outright.
122
+ */
123
+ async function detectDefaults(cwd) {
124
+ const detected = {};
125
+ try {
126
+ const pkg = JSON.parse(await readFile(path.join(cwd, "package.json"), "utf8"));
127
+ if (typeof pkg.name === "string" && pkg.name !== "") detected.name = pkg.name.replace(/^@[^/]+\//, "");
128
+ if (typeof pkg.homepage === "string" && /^https?:\/\//.test(pkg.homepage)) detected.url = pkg.homepage;
129
+ } catch {}
130
+ const site = await builtSite(cwd);
131
+ if (site !== void 0) {
132
+ const { readSiteFacts } = await import("./site-BHMtf3q2.js");
133
+ const facts = await readSiteFacts(site);
134
+ if (facts.url !== void 0) detected.url = facts.url;
135
+ if (facts.title !== void 0 && detected.name === void 0) detected.name = facts.title;
136
+ if (facts.lang !== void 0) {
137
+ detected.locale = facts.lang;
138
+ const country = countryForLocale(facts.lang);
139
+ if (country !== void 0) detected.country = country;
140
+ }
141
+ }
142
+ return detected;
143
+ }
144
+ /** The built site's directory, from the same search `audit` makes, without building. */
145
+ async function builtSite(cwd) {
146
+ const { autoDetectSource } = await import("./project-BLFdCbOq.js");
147
+ const found = await autoDetectSource(cwd, { noBuild: true });
148
+ await found?.cleanup?.();
149
+ return found?.directory;
150
+ }
151
+ /** Whether a config is already there, so init never overwrites one silently. */
152
+ async function existingConfig(cwd) {
153
+ for (const name of CONFIG_FILENAMES) if (await exists(path.join(cwd, name))) return name;
154
+ }
155
+ /** Reads answers, showing what each will be if the reader just hits enter. */
156
+ function terminalPrompt() {
157
+ const rl = createInterface({
158
+ input: process.stdin,
159
+ output: process.stderr
160
+ });
161
+ return {
162
+ ask: async (question, fallback) => {
163
+ const shown = fallback === "" ? "" : pc.dim(` (${fallback})`);
164
+ const answer = (await rl.question(`${question}${shown}: `)).trim();
165
+ return answer === "" ? fallback : answer;
166
+ },
167
+ close: () => rl.close()
168
+ };
169
+ }
170
+ async function runInitCommand(options = {}) {
171
+ const cwd = options.cwd ?? process.cwd();
172
+ const target = path.resolve(cwd, options.output ?? "eaa.config.json");
173
+ const already = await existingConfig(cwd);
174
+ if (already !== void 0 && !options.force) {
175
+ warn(`${already} already exists, and init never overwrites one without being told to.`);
176
+ nextStep({
177
+ command: "eaa-kit init --force",
178
+ why: `start ${already} again from scratch`
179
+ });
180
+ return { exitCode: 1 };
181
+ }
182
+ const detected = await detectDefaults(cwd);
183
+ const terminal = options.ask === void 0 && !options.yes && process.stdin.isTTY === true ? terminalPrompt() : void 0;
184
+ const rl = options.ask ?? terminal?.ask;
185
+ const ask = async (question, fallback) => rl === void 0 ? fallback : rl(question, fallback);
186
+ if (rl !== void 0) process.stderr.write(`${pc.bold("eaa-kit init")}\n${pc.dim("Everything here is a claim you are making. Press enter to take a default.\n\n")}`);
187
+ const name = await ask("Site name", detected.name ?? "");
188
+ const url = await ask("Site URL", detected.url ?? "https://example.com");
189
+ const country = await askCountry(ask, rl !== void 0, detected.country);
190
+ const locale = await ask("Language of the site", detected.locale !== void 0 && detected.country === country ? detected.locale : COUNTRY_INFO[country].siteLocale);
191
+ const legalName = await ask("Legal entity answerable for the site", name);
192
+ const email = await ask("Feedback email", "");
193
+ const feedbackUrl = await ask("Feedback or contact form URL (optional)", "");
194
+ const site = options.baseline === false ? void 0 : await builtSite(cwd);
195
+ const recordBaseline = site !== void 0 && isYes(await ask("Record a baseline of the barriers the site has today, so CI fails only on new ones? (y/n)", "y"));
196
+ const root = options.ci === false ? void 0 : await findGitRoot(cwd);
197
+ const workflowPath = root === void 0 ? void 0 : path.join(root, WORKFLOW_FILE);
198
+ const writeWorkflow = workflowPath !== void 0 && !await exists(workflowPath) && isYes(await ask("Add a GitHub Actions workflow that audits every push? (y/n)", "y"));
199
+ terminal?.close();
200
+ let baseline;
201
+ if (recordBaseline && site !== void 0) {
202
+ const { runBaselineCommand } = await import("./baseline-D9ihb-wk.js");
203
+ if ((await runBaselineCommand(path.relative(cwd, site) || ".", { cwd })).exitCode === 0) baseline = DEFAULT_BASELINE_FILE;
204
+ } else if (await exists(path.join(cwd, "eaa-baseline.json"))) baseline = DEFAULT_BASELINE_FILE;
205
+ const config = {
206
+ site: {
207
+ name,
208
+ url,
209
+ locale
210
+ },
211
+ provider: {
212
+ legalName,
213
+ email,
214
+ ...feedbackUrl === "" ? {} : { feedbackUrl }
215
+ },
216
+ compliance: {
217
+ status: "partially-compliant",
218
+ assessedOn: (/* @__PURE__ */ new Date()).toISOString().slice(0, 10),
219
+ assessmentMethod: "self-assessment",
220
+ knownIssues: []
221
+ },
222
+ enforcement: { country },
223
+ audit: {
224
+ failOn: DEFAULT_FAIL_ON,
225
+ ...baseline === void 0 ? {} : { baseline }
226
+ }
227
+ };
228
+ try {
229
+ await writeFile(target, `${JSON.stringify(config, null, 2)}\n`, "utf8");
230
+ } catch (cause) {
231
+ const reason = cause instanceof Error ? cause.message : String(cause);
232
+ fail(`Could not write ${path.basename(target)}: ${reason}`);
233
+ return { exitCode: 2 };
234
+ }
235
+ process.stderr.write(`Wrote ${path.relative(cwd, target) || path.basename(target)}\n`);
236
+ const missing = [name === "" ? "site.name" : void 0, email === "" ? "provider.email" : void 0].filter((field) => field !== void 0);
237
+ if (missing.length > 0) {
238
+ const [verb, pronoun] = missing.length === 1 ? ["is", "it"] : ["are", "them"];
239
+ warn(`${missing.join(" and ")} ${verb} empty and required. Fill ${pronoun} in before generating a statement.`);
240
+ }
241
+ note("Read it before publishing anything from it: status is partially-compliant,\nwhich is the honest default before an audit has run.");
242
+ if (writeWorkflow && root !== void 0 && workflowPath !== void 0) {
243
+ const workflow = await workflowFor({
244
+ cwd,
245
+ root,
246
+ ...site === void 0 ? {} : { site },
247
+ ...baseline === void 0 ? {} : { baseline },
248
+ failOn: DEFAULT_FAIL_ON
249
+ });
250
+ try {
251
+ await mkdir(path.dirname(workflowPath), { recursive: true });
252
+ await writeFile(workflowPath, workflow, "utf8");
253
+ process.stderr.write(`Wrote ${path.relative(cwd, workflowPath)}\n`);
254
+ } catch (cause) {
255
+ warn(`Could not write ${WORKFLOW_FILE}: ${cause instanceof Error ? cause.message : String(cause)}`);
256
+ }
257
+ }
258
+ note(`\nNext: eaa-kit statement${writeWorkflow ? " · commit and push to run the workflow" : " · eaa-kit audit"}`);
259
+ return {
260
+ file: target,
261
+ exitCode: 0
262
+ };
263
+ }
264
+ function isYes(answer) {
265
+ return /^y(es)?$/i.test(answer.trim());
266
+ }
267
+ /** How often an answer that is not a country is asked again before giving up on it. */
268
+ const COUNTRY_ATTEMPTS = 3;
269
+ /**
270
+ * The country whose law the statement is written under.
271
+ *
272
+ * An answer that is not a country is asked again, with the list. It used to
273
+ * become Austria without a word, which is how somebody who typed `pl` got an
274
+ * Austrian legal document. Once the attempts run out the default is used,
275
+ * because a typo should not throw away every other answer, but it is said out
276
+ * loud, so the file is not left looking like the answer somebody gave.
277
+ */
278
+ async function askCountry(ask, interactive, suggested) {
279
+ const fallback = suggested ?? "AT";
280
+ const choices = COUNTRIES.map((code) => `${code} ${COUNTRY_INFO[code].name}`).join(", ");
281
+ if (interactive) process.stderr.write(pc.dim(`Countries: ${choices}\n`));
282
+ let answer = "";
283
+ for (let attempt = 0; attempt < COUNTRY_ATTEMPTS; attempt += 1) {
284
+ answer = await ask("Country whose law applies", fallback);
285
+ const country = findCountry(answer);
286
+ if (country !== void 0) return country;
287
+ warn(`${answer} is not one of the countries a statement can be written for: ${COUNTRIES.join(", ")}`);
288
+ }
289
+ warn(`enforcement.country is set to ${fallback} because ${answer} was not recognised. Change it before generating a statement.`);
290
+ return fallback;
291
+ }
292
+ //#endregion
293
+ export { existingConfig, runInitCommand };
@@ -1,2 +1,2 @@
1
- import { r as serialiseJsonReport, t as buildJsonReport } from "./json-Bus6YhxB.js";
1
+ import { r as serialiseJsonReport, t as buildJsonReport } from "./json-SGCgxSPT.js";
2
2
  export { buildJsonReport, serialiseJsonReport };
@@ -2,7 +2,7 @@ import { a as impactLabel, i as countAtOrAbove, s as isImpactLevel } from "./imp
2
2
  import { t as TOOL_VERSION } from "./version-B3v4rNoG.js";
3
3
  import { t as elementFingerprint } from "./fingerprint-BjYV_0F7.js";
4
4
  import { m as uniqueRuleOutcomes, u as runEngine } from "./result-B7_zVxAX.js";
5
- import { t as buildCoverage } from "./coverage-cb5kPp48.js";
5
+ import { t as buildCoverage } from "./coverage-zdzgSKjz.js";
6
6
  import axe from "axe-core";
7
7
  /**
8
8
  * Build the machine-readable report.
@@ -0,0 +1,99 @@
1
+ import { d as parseConfig, i as ConfigError, u as parseAuditConfig } from "./define-Ctf2uOEh.js";
2
+ import { r as isFile } from "./fs-BmPtmFke.js";
3
+ import { readFile } from "node:fs/promises";
4
+ import path from "node:path";
5
+ import { pathToFileURL } from "node:url";
6
+ //#region src/config/load.ts
7
+ /** Checked in this order, first match wins. */
8
+ const CONFIG_FILENAMES = [
9
+ "eaa.config.ts",
10
+ "eaa.config.mts",
11
+ "eaa.config.js",
12
+ "eaa.config.mjs",
13
+ "eaa.config.json"
14
+ ];
15
+ /**
16
+ * Find and load `eaa.config.{ts,mts,js,mjs,json}`.
17
+ *
18
+ * TypeScript configs are imported directly: Node strips types natively from
19
+ * 22.18 onwards, which is below this package's floor, so no bundler or loader
20
+ * dependency is needed. The failure mode that remains is a project with no
21
+ * package.json at all, where Node cannot tell ESM from CommonJS; the error says
22
+ * so rather than surfacing "Unexpected token 'export'".
23
+ */
24
+ async function loadConfig(options = {}) {
25
+ const cwd = path.resolve(options.cwd ?? process.cwd());
26
+ const file = options.path ? path.resolve(cwd, options.path) : await findConfigFile(cwd);
27
+ if (!file) throw new ConfigError(`No config file found in ${cwd} or its parent directories`, CONFIG_FILENAMES.map((name) => `looked for ${name}`), {
28
+ command: "eaa-kit init",
29
+ why: "write one, filled in from what the site already states"
30
+ });
31
+ if (!await isFile(file)) throw new ConfigError(`Config file not found: ${file}`, [], {
32
+ command: `eaa-kit init --output ${path.relative(cwd, file) || path.basename(file)}`,
33
+ why: "write it there"
34
+ });
35
+ return {
36
+ config: parseConfig(await readConfigFile(file), path.basename(file)),
37
+ path: file
38
+ };
39
+ }
40
+ /**
41
+ * Find the config file and read its `audit` block, for the commands that take
42
+ * defaults from it.
43
+ *
44
+ * Returns undefined when there is no config file at all. That is not an error
45
+ * here as it is for `statement`: `eaa-kit audit` has always run against a
46
+ * project that has never heard of a config file, and it must keep doing so. An
47
+ * explicit path that is not there is still an error, because somebody named it.
48
+ */
49
+ async function loadAuditConfig(options = {}) {
50
+ const cwd = path.resolve(options.cwd ?? process.cwd());
51
+ const file = options.path ? path.resolve(cwd, options.path) : await findConfigFile(cwd);
52
+ if (!file) return void 0;
53
+ if (!await isFile(file)) throw new ConfigError(`Config file not found: ${file}`, [], {
54
+ command: `eaa-kit init --output ${path.relative(cwd, file) || path.basename(file)}`,
55
+ why: "write it there"
56
+ });
57
+ return {
58
+ audit: parseAuditConfig(await readConfigFile(file), path.basename(file)),
59
+ path: file
60
+ };
61
+ }
62
+ function readConfigFile(file) {
63
+ return file.endsWith(".json") ? importJson(file) : importModule(file);
64
+ }
65
+ /** Walks up from `cwd`, so the CLI works from a subdirectory of the project. */
66
+ async function findConfigFile(cwd) {
67
+ let directory = path.resolve(cwd);
68
+ while (true) {
69
+ for (const name of CONFIG_FILENAMES) {
70
+ const candidate = path.join(directory, name);
71
+ if (await isFile(candidate)) return candidate;
72
+ }
73
+ const parent = path.dirname(directory);
74
+ if (parent === directory) return void 0;
75
+ directory = parent;
76
+ }
77
+ }
78
+ async function importJson(file) {
79
+ const raw = await readFile(file, "utf8");
80
+ try {
81
+ return JSON.parse(raw);
82
+ } catch (cause) {
83
+ throw new ConfigError(`${path.basename(file)} is not valid JSON`, [cause instanceof Error ? cause.message : String(cause)]);
84
+ }
85
+ }
86
+ async function importModule(file) {
87
+ let module;
88
+ try {
89
+ module = await import(`${pathToFileURL(file).href}?t=${Date.now()}`);
90
+ } catch (cause) {
91
+ const message = cause instanceof Error ? cause.message : String(cause);
92
+ const hint = message.includes("Unexpected token") ? "If the project has no package.json, Node cannot tell ESM from CommonJS. Add one with \"type\": \"module\", or use eaa.config.json." : message;
93
+ throw new ConfigError(`Could not load ${path.basename(file)}`, [hint]);
94
+ }
95
+ if (module.default === void 0) throw new ConfigError(`${path.basename(file)} has no default export`, ["Expected: export default defineConfig({ … })"]);
96
+ return module.default;
97
+ }
98
+ //#endregion
99
+ export { loadConfig as i, findConfigFile as n, loadAuditConfig as r, CONFIG_FILENAMES as t };
@@ -0,0 +1,2 @@
1
+ import { r as loadAuditConfig } from "./load-CH-ltdlq.js";
2
+ export { loadAuditConfig };
@@ -1,4 +1,4 @@
1
- import { n as auditBuild, r as stderrLogger, t as BuildAuditError } from "../run-DrS0Komf.js";
1
+ import { n as auditBuild, r as stderrLogger, t as BuildAuditError } from "../run-DzVEOkiF.js";
2
2
  import path from "node:path";
3
3
  //#region src/nuxt/index.ts
4
4
  function eaaKitModule(options = {}, nuxt) {