Files
ai-for-dummies/scripts/audit-ui.mjs
T
2026-09-04 04:18:15 +00:00

19 lines
1.5 KiB
JavaScript

import { readFileSync } from 'node:fs';
const read = (path) => readFileSync(new URL(`../${path}`, import.meta.url), 'utf8');
const pages = ['index.html','full-guide/index.html','summary/index.html','models/index.html','agents/index.html','skills/index.html','rules/index.html','skills-review/index.html','hands-on/starter/index.html','hands-on/rules/index.html'];
for (const page of pages) {
const html = read(page);
if (!html.includes('name="viewport"')) throw new Error(`${page} lacks a viewport declaration`);
if (html.match(/<(script|link)[^>]+(src|href)="https?:[^\"]+"/i)) throw new Error(`${page} has an external runtime dependency`);
}
const shared = read('chapters.css');
const skills = read('skills/styles.css');
const guide = read('full-guide/index.html');
const guideAudit = read('full-guide/audit.css');
for (const token of ['@media(max-width:800px)','@media(max-width:520px)']) if (!shared.includes(token)) throw new Error(`shared chapter CSS lacks ${token}`);
for (const token of ['minmax(0,1.3fr)','overflow-wrap:anywhere','@media(max-width:800px)','prefers-reduced-motion']) if (!skills.includes(token)) throw new Error(`skills package CSS lacks ${token}`);
if (!guide.includes('href="audit.css"')) throw new Error('full guide does not load its responsive audit overrides');
for (const token of ['.handoff table','.route-table button','overflow-wrap:anywhere']) if (!guideAudit.includes(token)) throw new Error(`full guide audit CSS lacks ${token}`);
console.log('responsive UI audit passed');