Prepare Frost 1.0.0 release candidate
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
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 packageJson = JSON.parse(await readFile(resolve(root, "package.json"), "utf8"));
|
||||
const suppliedTag = process.argv[2] ?? process.env.GITEA_REF_NAME ?? process.env.GITHUB_REF_NAME;
|
||||
const expectedTag = `v${packageJson.version}`;
|
||||
|
||||
if (!suppliedTag) {
|
||||
console.error("Release tag is required as an argument or through GITEA_REF_NAME/GITHUB_REF_NAME.");
|
||||
process.exitCode = 1;
|
||||
} else if (suppliedTag !== expectedTag) {
|
||||
console.error(`Release tag ${suppliedTag} does not match package version ${packageJson.version}; expected ${expectedTag}.`);
|
||||
process.exitCode = 1;
|
||||
} else {
|
||||
const channel = packageJson.version.includes("-") ? "next" : "latest";
|
||||
console.log(channel);
|
||||
}
|
||||
@@ -14,6 +14,13 @@ if (packageLock.name !== packageJson.name) errors.push(`package-lock.json: packa
|
||||
if (packageLock.version !== packageJson.version) errors.push(`package-lock.json: version ${packageLock.version} does not match ${packageJson.version}`);
|
||||
if (packageLock.packages?.[""]?.name !== packageJson.name) errors.push("package-lock.json: root package name is stale");
|
||||
if (packageLock.packages?.[""]?.version !== packageJson.version) errors.push("package-lock.json: root package version is stale");
|
||||
if (packageJson.publishConfig?.access !== "public") errors.push("package.json: publishConfig.access must be public");
|
||||
for (const requiredFile of ["README.md", "CHANGELOG.md", "MIGRATION.md", "SUPPORT.md", "public-api.json"]) {
|
||||
if (!packageJson.files?.includes(requiredFile)) errors.push(`package.json: files must include ${requiredFile}`);
|
||||
}
|
||||
for (const browser of ["Chrome >= 111", "Edge >= 111", "Firefox >= 113", "Safari >= 16.4"]) {
|
||||
if (!packageJson.browserslist?.includes(browser)) errors.push(`package.json: browserslist is missing ${browser}`);
|
||||
}
|
||||
|
||||
const releases = [...changelog.matchAll(/^##\s+\[?(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)\]?\s*$/gm)].map((match) => ({ version: match[1], index: match.index }));
|
||||
if (!releases.length) errors.push("CHANGELOG.md: no release headings found");
|
||||
|
||||
@@ -71,6 +71,11 @@ for (const exportPath of ["./core", "./utility-layer", "./component-layer"]) {
|
||||
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"));
|
||||
|
||||
@@ -17,16 +17,18 @@ for (const match of combinedCss.matchAll(/\.(frost-[A-Za-z0-9_-]+(?:\\:[A-Za-z0-
|
||||
}
|
||||
|
||||
const customProperties = new Set(combinedCss.match(/--frost-[a-z0-9-]+/g) ?? []);
|
||||
const keyframes = new Set([...combinedCss.matchAll(/@keyframes\s+([A-Za-z0-9_-]+)/g)].map((match) => match[1]));
|
||||
const entryCss = await readFile(resolve(root, "frost.css"), "utf8");
|
||||
const layerDeclaration = entryCss.match(/@layer\s+([^;]+);/);
|
||||
const layers = layerDeclaration ? layerDeclaration[1].split(",").map((layer) => layer.trim()) : [];
|
||||
const packageExports = Object.fromEntries(sortLexically(Object.keys(packageJson.exports)).map((key) => [key, packageJson.exports[key]]));
|
||||
|
||||
const currentManifest = {
|
||||
schemaVersion: 1,
|
||||
schemaVersion: 2,
|
||||
packageVersion: packageJson.version,
|
||||
classes: sortLexically(classes),
|
||||
customProperties: sortLexically(customProperties),
|
||||
keyframes: sortLexically(keyframes),
|
||||
layers,
|
||||
exports: packageExports,
|
||||
};
|
||||
@@ -50,6 +52,9 @@ const findBreakingChanges = (baseline, current) => {
|
||||
for (const property of baseline.customProperties ?? []) {
|
||||
if (!current.customProperties.includes(property)) changes.push(`removed custom property ${property}`);
|
||||
}
|
||||
for (const keyframe of baseline.keyframes ?? []) {
|
||||
if (!current.keyframes.includes(keyframe)) changes.push(`removed keyframes ${keyframe}`);
|
||||
}
|
||||
for (const [key, target] of Object.entries(baseline.exports ?? {})) {
|
||||
if (!(key in current.exports)) changes.push(`removed package export ${key}`);
|
||||
else if (current.exports[key] !== target) changes.push(`changed package export ${key}: ${target} -> ${current.exports[key]}`);
|
||||
@@ -76,7 +81,7 @@ if (!command) {
|
||||
const next = serialize(currentManifest);
|
||||
const previous = existingManifest ? serialize(existingManifest) : null;
|
||||
if (next !== previous) await writeFile(manifestPath, next);
|
||||
console.log(`Public API manifest contains ${currentManifest.classes.length} classes, ${currentManifest.customProperties.length} custom properties, and ${Object.keys(currentManifest.exports).length} exports.`);
|
||||
console.log(`Public API manifest contains ${currentManifest.classes.length} classes, ${currentManifest.customProperties.length} custom properties, ${currentManifest.keyframes.length} keyframes, and ${Object.keys(currentManifest.exports).length} exports.`);
|
||||
}
|
||||
} else if (!existingManifest) {
|
||||
console.error("public-api.json is missing. Run npm run generate:api.");
|
||||
@@ -85,11 +90,12 @@ if (!command) {
|
||||
const additions = [
|
||||
...currentManifest.classes.filter((value) => !existingManifest.classes.includes(value)).map((value) => `added class .${value}`),
|
||||
...currentManifest.customProperties.filter((value) => !existingManifest.customProperties.includes(value)).map((value) => `added custom property ${value}`),
|
||||
...currentManifest.keyframes.filter((value) => !(existingManifest.keyframes ?? []).includes(value)).map((value) => `added keyframes ${value}`),
|
||||
...Object.keys(currentManifest.exports).filter((value) => !(value in existingManifest.exports)).map((value) => `added package export ${value}`),
|
||||
];
|
||||
console.error(["public-api.json does not match the current CSS/package surface.", ...breakingChanges.map((change) => `BREAKING: ${change}`), ...additions.map((change) => `NEW: ${change}`), "Run npm run generate:api and commit the result."].join("\n"));
|
||||
process.exitCode = 1;
|
||||
} else {
|
||||
console.log(`Public API contract is current: ${currentManifest.classes.length} classes, ${currentManifest.customProperties.length} custom properties, ${Object.keys(currentManifest.exports).length} exports.`);
|
||||
console.log(`Public API contract is current: ${currentManifest.classes.length} classes, ${currentManifest.customProperties.length} custom properties, ${currentManifest.keyframes.length} keyframes, ${Object.keys(currentManifest.exports).length} exports.`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,12 +5,13 @@ import { basename, join, resolve, sep } from "node:path";
|
||||
import { createRequire } from "node:module";
|
||||
import { promisify } from "node:util";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import postcss from "postcss";
|
||||
import postcssImport from "postcss-import";
|
||||
|
||||
const execFileAsync = promisify(execFile);
|
||||
const root = fileURLToPath(new URL("..", import.meta.url));
|
||||
const packageJson = JSON.parse(await readFile(resolve(root, "package.json"), "utf8"));
|
||||
const temporaryRoot = await mkdtemp(join(tmpdir(), "frost-consumer-"));
|
||||
const fixture = join(temporaryRoot, "fixture");
|
||||
const npmCli = process.env.npm_execpath;
|
||||
|
||||
const runNpm = async (arguments_, options = {}) => {
|
||||
@@ -29,7 +30,7 @@ try {
|
||||
const path = target.replace(/^\.\//, "");
|
||||
if (!packedPaths.has(path)) throw new Error(`Tarball is missing export target ${target}`);
|
||||
}
|
||||
for (const required of ["public-api.json", "dist/frost.css", "dist/frost.min.css", "dist/utility-layer.css", "dist/component-layer.css"]) {
|
||||
for (const required of ["public-api.json", "SUPPORT.md", "MIGRATION.md", "dist/frost.css", "dist/frost.min.css", "dist/utility-layer.css", "dist/component-layer.css"]) {
|
||||
if (!packedPaths.has(required)) throw new Error(`Tarball is missing required file ${required}`);
|
||||
}
|
||||
const forbidden = [...packedPaths].filter((path) => /^(?:examples|tests|\.gitea|node_modules)\//.test(path));
|
||||
@@ -52,8 +53,20 @@ try {
|
||||
if (!metadata.isFile() || metadata.size === 0) throw new Error(`${specifier} resolved to an empty or non-file target`);
|
||||
}
|
||||
|
||||
const consumerCss = join(temporaryRoot, "consumer.css");
|
||||
await writeFile(consumerCss, `@import "${packageJson.name}";\n.consumer-smoke { color: var(--frost-color-text); }\n`);
|
||||
const bundledConsumer = await postcss([
|
||||
postcssImport({
|
||||
resolve: (specifier) => requireFromFixture.resolve(specifier),
|
||||
}),
|
||||
]).process(await readFile(consumerCss, "utf8"), { from: consumerCss });
|
||||
if (/@import\b/.test(bundledConsumer.css)) throw new Error("Bundled default export left unresolved CSS imports in the consumer build");
|
||||
for (const marker of [".frost-button", "@layer frost.forced-colors", "@media (forced-colors: active)", ".consumer-smoke"]) {
|
||||
if (!bundledConsumer.css.includes(marker)) throw new Error(`Bundled consumer output is missing ${marker}`);
|
||||
}
|
||||
|
||||
const tarballMetadata = await stat(tarball);
|
||||
console.log(`Installed ${basename(tarball)} (${tarballMetadata.size} bytes) and resolved all ${Object.keys(packageJson.exports).length} package exports from an isolated consumer.`);
|
||||
console.log(`Installed ${basename(tarball)} (${tarballMetadata.size} bytes), resolved all ${Object.keys(packageJson.exports).length} exports, and bundled the default CSS from an isolated consumer.`);
|
||||
} finally {
|
||||
if (!resolve(temporaryRoot).startsWith(resolve(tmpdir()) + sep)) throw new Error("Refusing to remove a temporary directory outside the system temp root");
|
||||
await rm(temporaryRoot, { recursive: true, force: true });
|
||||
|
||||
Reference in New Issue
Block a user