diff --git a/frontend/scripts/axe-run.js b/frontend/scripts/axe-run.js deleted file mode 100644 index ace4117..0000000 --- a/frontend/scripts/axe-run.js +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env node -/** - * A small Axe accessibility runner using Puppeteer and axe-core - * Usage: node ./scripts/axe-run.js - */ -const fs = require("fs"); -const path = require("path"); -const puppeteer = require("puppeteer"); -const axeSource = require("axe-core").source; - -async function run(url) { - const browser = await puppeteer.launch({ - args: ["--no-sandbox", "--disable-setuid-sandbox"], - }); - const page = await browser.newPage(); - await page.goto(url, { waitUntil: "networkidle0" }); - // Inject axe - await page.evaluate(axeSource); - // Run axe with default options - const result = await page.evaluate(async () => await window.axe.run()); - - const outDir = path.resolve(__dirname, "..", "lighthouse"); - if (!fs.existsSync(outDir)) fs.mkdirSync(outDir, { recursive: true }); - const ts = new Date().toISOString().replace(/[:.]/g, "-"); - const jsonPath = path.join(outDir, `axe-${ts}.json`); - fs.writeFileSync(jsonPath, JSON.stringify(result, null, 2)); - await browser.close(); - console.log("Axe report saved to", jsonPath); - console.log("Violations:", result.violations.length); - if (result.violations.length > 0) { - result.violations.forEach((v) => { - console.log("\n", v.id, "-", v.impact, "-", v.help); - v.nodes.forEach((n) => console.log(" - ", n.target.join(", "))); - }); - process.exit(2); - } -} - -const args = process.argv.slice(2); -if (args.length < 1) { - console.error("Usage: node scripts/axe-run.js "); - process.exit(1); -} -run(args[0]).catch((err) => { - console.error(err); - process.exit(1); -}); diff --git a/frontend/scripts/lighthouse-run.js b/frontend/scripts/lighthouse-run.js deleted file mode 100644 index f0605d0..0000000 --- a/frontend/scripts/lighthouse-run.js +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/env node -/* - Lightweight Lighthouse runner for the frontend. This script launches a Chromium instance - (via chrome-launcher) and runs Lighthouse against the given URL. It produces HTML and JSON - reports in ./lighthouse/ and prints a small summary. - - Usage: node ./scripts/lighthouse-run.js [--mobile|--desktop] -*/ -const fs = require("fs"); -const path = require("path"); -const lighthouse = require("lighthouse"); -const chromeLauncher = require("chrome-launcher"); - -async function run(url, opts = {}) { - const chrome = await chromeLauncher.launch({ - chromeFlags: ["--headless=new", "--no-sandbox", "--disable-gpu"], - }); - const options = { - port: chrome.port, - output: "html", - onlyCategories: ["performance", "accessibility", "best-practices", "seo"], - emulatedFormFactor: opts.formFactor || "desktop", - }; - console.log( - `Running Lighthouse on ${url} (${options.emulatedFormFactor})...`, - ); - const runnerResult = await lighthouse(url, options); - const reportHtml = runnerResult.report; - const reportJson = runnerResult.lhr; - - const outDir = path.resolve(__dirname, "..", "lighthouse"); - if (!fs.existsSync(outDir)) fs.mkdirSync(outDir, { recursive: true }); - const ts = new Date().toISOString().replace(/[:.]/g, "-"); - const htmlPath = path.join( - outDir, - `lighthouse-${options.emulatedFormFactor}-${ts}.html`, - ); - const jsonPath = path.join( - outDir, - `lighthouse-${options.emulatedFormFactor}-${ts}.json`, - ); - fs.writeFileSync(htmlPath, reportHtml); - fs.writeFileSync(jsonPath, JSON.stringify(reportJson, null, 2)); - - console.log(`Saved reports: ${htmlPath} and ${jsonPath}`); - console.log("----- Scores -----"); - console.log( - JSON.stringify( - Object.fromEntries( - Object.entries(reportJson.categories).map(([k, v]) => [ - k, - Math.round(v.score * 100), - ]), - ), - null, - 2, - ), - ); - - await chrome.kill(); -} - -const args = process.argv.slice(2); -if (args.length < 1) { - console.error( - "Usage: node scripts/lighthouse-run.js [--mobile|--desktop]", - ); - process.exit(1); -} -const url = args[0]; -const formFactor = args.includes("--mobile") ? "mobile" : "desktop"; -run(url, { formFactor }).catch((err) => { - console.error(err); - process.exit(1); -});