Stabilize Frost and prepare npm package

This commit is contained in:
2026-10-29 21:57:42 +01:00
parent f5cd37254c
commit 94ec8bb573
9 changed files with 167 additions and 3 deletions
+38
View File
@@ -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.`);
}
+15
View File
@@ -0,0 +1,15 @@
import { gzipSync } from "node:zlib";
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 files = ["tokens.css", "base.css", "accessibility.css", "layout.css", "controls.css", "components.css"];
const source = (await Promise.all(files.map((file) => readFile(resolve(root, file), "utf8")))).join("\n");
const rawBytes = Buffer.byteLength(source);
const gzipBytes = gzipSync(source).byteLength;
console.log(`Combined CSS: ${rawBytes} bytes raw, ${gzipBytes} bytes gzip`);
if (gzipBytes > 10 * 1024) {
console.error("Warning: Frost exceeds the 10 KB gzip budget.");
process.exitCode = 1;
}