Stabilize Frost and prepare npm package
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
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 cssFiles = [
|
||||
"frost.css",
|
||||
"tokens.css",
|
||||
"base.css",
|
||||
"accessibility.css",
|
||||
"layout.css",
|
||||
"controls.css",
|
||||
"components.css",
|
||||
];
|
||||
|
||||
const errors = [];
|
||||
|
||||
for (const file of cssFiles) {
|
||||
const source = await readFile(resolve(root, file), "utf8");
|
||||
const opens = (source.match(/\{/g) ?? []).length;
|
||||
const closes = (source.match(/\}/g) ?? []).length;
|
||||
if (opens !== closes) errors.push(`${file}: unbalanced braces`);
|
||||
if (/transition\s*:\s*all\b/.test(source)) errors.push(`${file}: transition: all is not allowed`);
|
||||
if (/(?:^|[;{])\s*--(?!frost-)[a-z0-9-]+\s*:/.test(source)) errors.push(`${file}: found an unprefixed public custom property`);
|
||||
}
|
||||
|
||||
const entry = await readFile(resolve(root, "frost.css"), "utf8");
|
||||
for (const match of entry.matchAll(/@import\s+url\("([^"]+)"\)/g)) {
|
||||
try { await readFile(resolve(root, match[1]), "utf8"); }
|
||||
catch { errors.push(`frost.css: missing import ${match[1]}`); }
|
||||
}
|
||||
|
||||
if (errors.length) {
|
||||
console.error(errors.join("\n"));
|
||||
process.exitCode = 1;
|
||||
} else {
|
||||
console.log(`Checked ${cssFiles.length} CSS files; imports, braces, transitions, and public token prefixes look valid.`);
|
||||
}
|
||||
Reference in New Issue
Block a user