Files

69 lines
2.3 KiB
TypeScript

import { join, resolve } from "node:path";
const root = resolve(import.meta.dir, "..");
const cssDir = join(root, ".gitea-data", "gitea", "public", "assets", "css");
const templatesDir = join(root, ".gitea-data", "gitea", "templates");
const themeChecks = [
{
file: "theme-banana-modern-light.css",
checks: [
["metadata block", "gitea-theme-meta-info"],
["display name", '--theme-display-name:"banana Modern Light"'],
["light mode", "--is-dark-theme:false"],
["primary color", "--color-primary:#f3cb00"]
]
},
{
file: "theme-banana-modern-dark.css",
checks: [
["metadata block", "gitea-theme-meta-info"],
["display name", '--theme-display-name:"banana Modern Dark"'],
["dark mode", "--is-dark-theme:true"],
["primary color", "--color-primary:#fde047"]
]
},
{
file: "theme-banana-modern-auto.css",
checks: [
["metadata block", "gitea-theme-meta-info"],
["display name", '--theme-display-name:"banana Modern Auto"'],
["light import", '@import "./theme-banana-modern-light.css?v='],
["dark import", '@import "./theme-banana-modern-dark.css?v=']
]
}
] as const;
const failures: string[] = [];
for (const theme of themeChecks) {
const themeFile = join(cssDir, theme.file);
const css = await Bun.file(themeFile).text();
for (const [name, needle] of theme.checks) {
if (!css.includes(needle)) {
failures.push(`${theme.file}: missing ${name}`);
}
}
}
const footerTemplate = await Bun.file(join(templatesDir, "base", "footer_content.tmpl")).text();
if (!footerTemplate.includes("hide Gitea's default page footer")) {
failures.push("templates/base/footer_content.tmpl: missing footer override");
}
const navbarTemplate = await Bun.file(join(templatesDir, "base", "head_navbar.tmpl")).text();
if (navbarTemplate.includes("{{if not .IsSigned}}")) {
failures.push("templates/base/head_navbar.tmpl: signed-out help link block is still present");
}
if (!navbarTemplate.includes("{{ctx.Locale.Tr \"help\"}}")) {
failures.push("templates/base/head_navbar.tmpl: signed-in help menu item is missing");
}
if (failures.length > 0) {
for (const failure of failures) console.error(failure);
process.exit(1);
}
console.log(`verified ${themeChecks.length} Banana modern themes in ${cssDir}`);
console.log(`verified template overrides in ${templatesDir}`);