Files
Frost/scripts/check-example.mjs

32 lines
1.1 KiB
JavaScript

import { readFile } from "node:fs/promises";
import { resolve } from "node:path";
import { fileURLToPath } from "node:url";
const root = fileURLToPath(new URL("..", import.meta.url));
const html = await readFile(resolve(root, "examples/index.html"), "utf8");
const required = [
"frost-md:grid-cols-2",
"frost-hover:shadow",
"frost-navbar",
"frost-breadcrumbs",
"frost-tabs",
"frost-accordion",
"frost-table",
"frost-spinner",
"id=\"theme-toggle\"",
"id=\"menu-trigger\"",
"id=\"component-search\"",
"data-component=\"buttons\"",
"data-component=\"modal\"",
"data-copy-html",
"catalog-a11y",
];
const errors = required.filter((value) => !html.includes(value)).map((value) => `examples/index.html: missing demo marker ${value}`);
if (!html.includes("aria-selected") || !html.includes("aria-expanded")) errors.push("examples/index.html: interactive ARIA state markers are missing");
if (errors.length) {
console.error(errors.join("\n"));
process.exitCode = 1;
} else {
console.log(`Checked ${required.length} catalog, component, and interaction markers in examples/index.html.`);
}