eaa-kit 0.2.0 → 0.2.1

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.
@@ -18,7 +18,7 @@ function eaaKit(options = {}) {
18
18
  logger.info("skipped (enabled: false)");
19
19
  return;
20
20
  }
21
- const { runAuditCommand } = await import("../audit-CqrR9pIO.js");
21
+ const { runAuditCommand } = await import("../audit-B2dIKpJ5.js");
22
22
  const { exitCode } = await runAuditCommand(fileURLToPath(dir), {
23
23
  ...options.failOn ? { failOn: options.failOn } : {},
24
24
  ...options.include ? { include: options.include } : {},
@@ -0,0 +1,2 @@
1
+ import { r as runAuditCommand } from "./audit-DXpKkXsC.js";
2
+ export { runAuditCommand };
@@ -747,7 +747,7 @@ async function crawlPages(url, options) {
747
747
  */
748
748
  async function resolveAutomatically(options) {
749
749
  const cwd = options.cwd ?? process.cwd();
750
- const { autoDetectSource } = await import("./project-CiyzKQud.js");
750
+ const { autoDetectSource } = await import("./project-CufCqIE2.js");
751
751
  const detected = await autoDetectSource(cwd, {
752
752
  ...options.noBuild ? { noBuild: true } : {},
753
753
  onStep: (message) => process.stderr.write(pc.dim(`${message}\n`))
@@ -802,12 +802,13 @@ async function runAuditCommand(dir, options = {}) {
802
802
  process.stderr.write(pc.dim(`Auditing ${pages.length} ${pages.length === 1 ? "page" : "pages"} in ${label}${engineNote}…\n`));
803
803
  const effectiveBaseUrl = options.baseUrl ?? origin;
804
804
  const runnerOptions = {
805
+ cwd: options.cwd ?? process.cwd(),
805
806
  ...effectiveBaseUrl === void 0 ? {} : { baseUrl: effectiveBaseUrl },
806
807
  ...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs }
807
808
  };
808
809
  let audits;
809
810
  if (options.browser) {
810
- const { BrowserUnavailableError, runBrowserAudit } = await import("./playwright-DWux49V3.js");
811
+ const { BrowserUnavailableError, runBrowserAudit } = await import("./playwright-DSRnXmcd.js");
811
812
  try {
812
813
  audits = await runBrowserAudit(options.url === void 0 ? dir : void 0, pages, runnerOptions);
813
814
  } catch (cause) {
package/dist/cli/index.js CHANGED
@@ -4,7 +4,7 @@ import { i as readAuditReport, o as StatementError, t as renderStatement } from
4
4
  import { i as isImpactLevel, n as IMPACT_LEVELS, t as DEFAULT_FAIL_ON } from "../impact-DvgBjupx.js";
5
5
  import { t as TOOL_VERSION } from "../version-B3v4rNoG.js";
6
6
  import { i as buildBaseline, n as DEFAULT_BASELINE_FILE, s as writeBaseline, t as BaselineError } from "../baseline-CgBmzFTr.js";
7
- import { i as resolvePages, n as isOutputFormat, r as runAuditCommand, t as OUTPUT_FORMATS } from "../audit-D4gju2BT.js";
7
+ import { i as resolvePages, n as isOutputFormat, r as runAuditCommand, t as OUTPUT_FORMATS } from "../audit-DXpKkXsC.js";
8
8
  import { mkdir, writeFile } from "node:fs/promises";
9
9
  import path from "node:path";
10
10
  import { Command, InvalidArgumentError } from "commander";
@@ -36,12 +36,13 @@ async function runBaselineCommand(dir, options = {}) {
36
36
  process.stderr.write(pc.dim(`Auditing ${pages.length} ${pages.length === 1 ? "page" : "pages"} in ${label}…\n`));
37
37
  const effectiveBaseUrl = options.baseUrl ?? origin;
38
38
  const runnerOptions = {
39
+ cwd,
39
40
  ...effectiveBaseUrl === void 0 ? {} : { baseUrl: effectiveBaseUrl },
40
41
  ...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs }
41
42
  };
42
43
  let audits;
43
44
  if (options.browser) {
44
- const { BrowserUnavailableError, runBrowserAudit } = await import("../playwright-DWux49V3.js");
45
+ const { BrowserUnavailableError, runBrowserAudit } = await import("../playwright-DSRnXmcd.js");
45
46
  try {
46
47
  audits = await runBrowserAudit(options.url === void 0 ? path.resolve(cwd, dir) : void 0, pages, runnerOptions);
47
48
  } catch (cause) {
@@ -1,4 +1,5 @@
1
1
  import { i as shapeResults, n as failedPage, r as runOptions, t as DEFAULT_TAGS } from "./result-2aZPfM8w.js";
2
+ import { createRequire } from "node:module";
2
3
  import { stat } from "node:fs/promises";
3
4
  import path from "node:path";
4
5
  import { pathToFileURL } from "node:url";
@@ -140,12 +141,18 @@ const DEFAULT_VIEWPORT = {
140
141
  */
141
142
  async function runBrowserAudit(directory, pages, options = {}) {
142
143
  if (pages.length === 0) return [];
143
- const chromium = await loadChromium();
144
+ const chromium = await loadChromium(options.cwd);
144
145
  const tags = options.tags ?? DEFAULT_TAGS;
145
146
  const timeout = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
146
147
  const viewport = options.viewport ?? DEFAULT_VIEWPORT;
147
148
  const server = directory === void 0 ? void 0 : await serveDirectory(directory);
148
- const browser = await chromium.launch({ headless: true });
149
+ let browser;
150
+ try {
151
+ browser = await chromium.launch({ headless: true });
152
+ } catch (cause) {
153
+ await server?.close();
154
+ throw cause;
155
+ }
149
156
  try {
150
157
  const context = await browser.newContext({
151
158
  viewport,
@@ -221,12 +228,16 @@ function reportedUrl(page, baseUrl) {
221
228
  * because "install playwright" and "install the browser binary" are different
222
229
  * problems with different fixes.
223
230
  */
224
- async function loadChromium() {
231
+ async function loadChromium(cwd = process.cwd()) {
225
232
  let module;
226
233
  try {
234
+ const resolved = createRequire(pathToFileURL(path.join(cwd, "package.json")).href).resolve("playwright");
235
+ module = await import(pathToFileURL(resolved).href);
236
+ } catch {}
237
+ if (module === void 0) try {
227
238
  module = await import("playwright");
228
239
  } catch {
229
- throw new BrowserUnavailableError("Browser mode needs Playwright, which is an optional peer dependency.\n Install it with: pnpm add -D playwright\n Then the browser: npx playwright install chromium");
240
+ throw new BrowserUnavailableError("Browser mode needs Playwright, which is an optional peer dependency.\n Install it with: npm i -D playwright\n Then the browser: npx playwright install chromium");
230
241
  }
231
242
  if (!module.chromium) throw new BrowserUnavailableError("Playwright is installed but exports no chromium launcher");
232
243
  return module.chromium;
@@ -85,6 +85,30 @@ async function findBuildOutput(cwd) {
85
85
  }
86
86
  }
87
87
  /**
88
+ * How to invoke a package-manager script on this platform.
89
+ *
90
+ * Not `shell: true` with an argument array: Node deprecated that in DEP0190
91
+ * because the arguments are concatenated rather than escaped, and it prints a
92
+ * warning into the middle of somebody's build output. Windows still needs a
93
+ * shell — npm and pnpm are `.cmd` shims there, which cannot be spawned
94
+ * directly — so cmd.exe is invoked explicitly with one command string instead.
95
+ */
96
+ function scriptCommand(manager, script) {
97
+ if (process.platform !== "win32") return {
98
+ command: manager,
99
+ args: ["run", script]
100
+ };
101
+ return {
102
+ command: process.env["ComSpec"] ?? "cmd.exe",
103
+ args: [
104
+ "/d",
105
+ "/s",
106
+ "/c",
107
+ `${manager} run ${script}`
108
+ ]
109
+ };
110
+ }
111
+ /**
88
112
  * Run one of the project's own scripts and wait for it.
89
113
  *
90
114
  * stdio is inherited so the build's output goes where the user expects it. This
@@ -96,14 +120,14 @@ async function runScript(cwd, script) {
96
120
  const manager = await detectPackageManager(cwd);
97
121
  const command = `${manager} run ${script}`;
98
122
  return new Promise((resolve) => {
99
- const child = spawn(manager, ["run", script], {
123
+ const { command: bin, args } = scriptCommand(manager, script);
124
+ const child = spawn(bin, args, {
100
125
  cwd,
101
126
  stdio: [
102
127
  "ignore",
103
128
  "inherit",
104
129
  "inherit"
105
- ],
106
- shell: process.platform === "win32"
130
+ ]
107
131
  });
108
132
  child.on("error", () => resolve({
109
133
  ok: false,
@@ -138,15 +162,14 @@ async function answers(origin) {
138
162
  * if nothing came up before the timeout, having already stopped the process.
139
163
  */
140
164
  async function startServer(cwd, script) {
141
- const manager = await detectPackageManager(cwd);
142
- const child = spawn(manager, ["run", script], {
165
+ const { command: bin, args } = scriptCommand(await detectPackageManager(cwd), script);
166
+ const child = spawn(bin, args, {
143
167
  cwd,
144
168
  stdio: [
145
169
  "ignore",
146
170
  "pipe",
147
171
  "pipe"
148
172
  ],
149
- shell: process.platform === "win32",
150
173
  detached: process.platform !== "win32"
151
174
  });
152
175
  let announced;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eaa-kit",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Build-time WCAG 2.2 AA auditor and EU accessibility statement generator for static sites (EAA / BFSG / BaFG, DACH-localised).",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1,2 +0,0 @@
1
- import { r as runAuditCommand } from "./audit-D4gju2BT.js";
2
- export { runAuditCommand };