Files
Fretux 50fe5ec2e9
CI / Test and package (push) Successful in 1m29s
Release and RC / Verify and publish (push) Failing after 6m12s
Prepare Frost 1.0.0 release candidate
2026-11-21 14:48:53 +01:00

86 lines
4.4 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 cssFiles = [
"frost.css",
"core.css",
"utility-layer.css",
"component-layer.css",
"tokens.css",
"base.css",
"accessibility.css",
"forced-colors.css",
"layout.css",
"controls.css",
"components.css",
"utilities.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]}`); }
}
const layerSources = {
"core.css": ["tokens.css", "base.css", "accessibility.css", "forced-colors.css"],
"utility-layer.css": ["core.css", "layout.css", "utilities.css"],
"component-layer.css": ["core.css", "layout.css", "controls.css", "components.css"],
};
for (const [file, requiredImports] of Object.entries(layerSources)) {
const source = await readFile(resolve(root, file), "utf8");
for (const requiredImport of requiredImports) {
if (!source.includes(`./${requiredImport}`)) errors.push(`${file}: missing layer import ${requiredImport}`);
}
}
const utilityLayerSource = await readFile(resolve(root, "utility-layer.css"), "utf8");
const componentLayerSource = await readFile(resolve(root, "component-layer.css"), "utf8");
if (utilityLayerSource.includes("./controls.css") || utilityLayerSource.includes("./components.css")) errors.push("utility-layer.css: component layer leaked into utility entry point");
if (componentLayerSource.includes("./utilities.css")) errors.push("component-layer.css: utility layer leaked into component entry point");
const utilitySource = await readFile(resolve(root, "utilities.css"), "utf8");
for (const utility of ["frost-flex", "frost-grid", "frost-gap-4", "frost-p-4", "frost-md\\:grid-cols-2", "frost-hover\\:bg-soft"]) {
if (!utilitySource.includes(`.${utility}`)) errors.push(`utilities.css: missing public utility ${utility}`);
}
const componentsSource = await readFile(resolve(root, "components.css"), "utf8");
for (const component of ["frost-navbar", "frost-breadcrumbs", "frost-tabs", "frost-accordion", "frost-pagination", "frost-table", "frost-spinner"]) {
if (!componentsSource.includes(`.${component}`)) errors.push(`components.css: missing public component ${component}`);
}
const packageJson = JSON.parse(await readFile(resolve(root, "package.json"), "utf8"));
for (const exportPath of ["./utilities", "./components", "./tokens"]) {
if (!packageJson.exports[exportPath]) errors.push(`package.json: missing export ${exportPath}`);
}
for (const exportPath of ["./core", "./utility-layer", "./component-layer"]) {
if (!packageJson.exports[exportPath]) errors.push(`package.json: missing layer export ${exportPath}`);
}
for (const exportPath of ["./forced-colors", "./forced-colors.css"]) {
if (!packageJson.exports[exportPath]) errors.push(`package.json: missing forced-colors export ${exportPath}`);
}
if (packageJson.style !== "./dist/frost.css") errors.push("package.json: style must point to the built dist/frost.css bundle");
if (packageJson.exports["."] !== "./dist/frost.css") errors.push("package.json: default export must point to the built dist/frost.css bundle");
for (const exportPath of ["./bundle", "./bundle.css", "./bundle.min", "./bundle.min.css", "./dist/frost.css", "./dist/frost.min.css", "./dist/utility-layer.css", "./dist/utility-layer.min.css", "./dist/component-layer.css", "./dist/component-layer.min.css"]) {
if (!packageJson.exports[exportPath]) errors.push(`package.json: missing bundled export ${exportPath}`);
}
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.`);
}