fork init
Some checks failed
Generate Database / generate (push) Has been cancelled
Repo sync GitHub -> Codeberg / codeberg (push) Has been cancelled

This commit is contained in:
dorkbutt 2025-06-04 21:09:17 -04:00
parent b4f5aba93b
commit 2e6b63ea33
No known key found for this signature in database
11 changed files with 8 additions and 2651 deletions

View file

@ -0,0 +1,49 @@
import { readFile, writeFile } from "fs/promises";
import { join } from "path";
import UglifyCSS from "uglifycss";
console.time("Done");
const uglify = !process.argv.includes("--debug");
console.log("Getting templates...");
const templateLines = (
await readFile(join("../../", "source", "template.css"), "utf8")
)
.replace(/\r/g, "")
.split("\n");
const templates = {
avatar: "",
};
for (const id of Object.keys(templates)) {
const start = templateLines.findIndex(
(x) => x === `/* ${id.toUpperCase()}-TEMPLATE-BEGIN */`
),
end = templateLines.findIndex(
(x) => x === `/* ${id.toUpperCase()}-TEMPLATE-END */`
);
if (start >= 0 && end >= 0)
templates[id] = templateLines.slice(start + 1, end).join("\n");
else throw new Error(`Failed to get template lines for: ${id}`);
}
console.log("Generating import.css...");
const data = JSON.parse(
await readFile(join("../../", "source", "data.json"), "utf8")
);
const dist = [];
for (const [id, img] of Object.entries(data.avatars)) {
dist.push(templates.avatar.replace(/{id}/g, id).replace(/{img}/g, img));
}
await writeFile(
join("../../", "import.css"),
uglify ? UglifyCSS.processString(dist.join("\n")) : dist.join("\n\n")
);
console.timeEnd("Done");