42 lines
1.7 KiB
TypeScript
42 lines
1.7 KiB
TypeScript
import { existsSync } from "node:fs";
|
|
import { readFile, stat } from "node:fs/promises";
|
|
import { join } from "node:path";
|
|
|
|
const requiredOutputs = [
|
|
join(process.cwd(), "dist", "theme-github-dev.css"),
|
|
join(process.cwd(), "dist", "theme-github-dev-dark.css"),
|
|
join(process.cwd(), ".gitea", "custom", "public", "assets", "css", "theme-github-dev.css"),
|
|
join(process.cwd(), ".gitea", "custom", "public", "assets", "css", "theme-github-dev-dark.css"),
|
|
join(process.cwd(), ".gitea", "custom", "templates", "repo", "view_content.tmpl"),
|
|
join(process.cwd(), ".gitea", "custom", "templates", "repo", "view_list.tmpl"),
|
|
join(process.cwd(), ".gitea", "custom", "templates", "repo", "commits_list.tmpl"),
|
|
join(process.cwd(), ".gitea", "custom", "templates", "repo", "commit_sign_badge.tmpl"),
|
|
join(process.cwd(), ".gitea", "custom", "options", "locale", "locale_zh-CN.json"),
|
|
];
|
|
|
|
for (const output of requiredOutputs) {
|
|
if (!existsSync(output)) {
|
|
throw new Error(`missing output: ${output}`);
|
|
}
|
|
|
|
const file = await stat(output);
|
|
if (file.size === 0) {
|
|
throw new Error(`empty output: ${output}`);
|
|
}
|
|
}
|
|
|
|
const zhCnLocalePath = join(process.cwd(), ".gitea", "custom", "options", "locale", "locale_zh-CN.json");
|
|
const zhCnLocale = JSON.parse(await readFile(zhCnLocalePath, "utf8")) as Record<string, string>;
|
|
|
|
for (const key of ["explore_title", "repo.code", "repo.issues", "repo.pulls", "gitea-github-theme.verifed"]) {
|
|
if (!zhCnLocale[key]) {
|
|
throw new Error(`zh-CN locale output is missing required key: ${key}`);
|
|
}
|
|
}
|
|
|
|
if (Object.keys(zhCnLocale).length < 1000) {
|
|
throw new Error("zh-CN locale output looks incomplete; do not overwrite the full locale with a tiny partial file");
|
|
}
|
|
|
|
console.log("theme outputs verified");
|