Merge pull request #523 from heygen-com/fix/cli-validate-smoke-ci

fix: validate CLI smoke paths
This commit is contained in:
Miguel Ángel
2026-04-28 22:44:54 +02:00
committed by GitHub
3 changed files with 116 additions and 5 deletions
+5
View File
@@ -82,6 +82,11 @@ async function main() {
cpSync(layoutAuditScript, join(DIST, "commands", "layout-audit.browser.js"));
}
const contrastAuditScript = join(CLI_ROOT, "src", "commands", "contrast-audit.browser.js");
if (existsSync(contrastAuditScript)) {
cpSync(contrastAuditScript, join(DIST, "commands", "contrast-audit.browser.js"));
}
copyMdFiles(join(CLI_ROOT, "src", "docs"), join(DIST, "docs"));
console.log("[build-copy] done");
+14 -5
View File
@@ -27,10 +27,6 @@ interface ContrastEntry {
bg: string;
}
// esbuild's text loader inlines this at build time — no runtime file read.
// @ts-expect-error — .browser.js files use esbuild text loader, not TS module resolution
import CONTRAST_AUDIT_SCRIPT from "./contrast-audit.browser.js";
const CONTRAST_SAMPLES = 5;
const SEEK_SETTLE_MS = 150;
@@ -64,7 +60,7 @@ async function runContrastAudit(page: import("puppeteer-core").Page): Promise<Co
const duration = await getCompositionDuration(page);
if (duration <= 0) return [];
await page.addScriptTag({ content: CONTRAST_AUDIT_SCRIPT });
await page.addScriptTag({ content: loadContrastAuditScript() });
const results: ContrastEntry[] = [];
for (let i = 0; i < CONTRAST_SAMPLES; i++) {
@@ -86,6 +82,19 @@ async function runContrastAudit(page: import("puppeteer-core").Page): Promise<Co
return results;
}
function loadContrastAuditScript(): string {
const candidates = [
join(__dirname, "contrast-audit.browser.js"),
join(__dirname, "commands", "contrast-audit.browser.js"),
];
for (const candidate of candidates) {
if (existsSync(candidate)) return readFileSync(candidate, "utf-8");
}
throw new Error("Missing contrast audit browser script");
}
async function validateInBrowser(
projectDir: string,
opts: { timeout?: number; contrast?: boolean },