Files
gitea-themes/scripts/verify-docker.ts
T

50 lines
1.5 KiB
TypeScript

const baseUrl = process.env.GITEA_PREVIEW_URL ?? "http://localhost:3000";
async function waitFor(url: string) {
const deadline = Date.now() + 60_000;
let lastError: unknown;
while (Date.now() < deadline) {
try {
const response = await fetch(url);
if (response.ok) {
return response;
}
lastError = new Error(`${url} returned ${response.status}`);
} catch (error) {
lastError = error;
}
await Bun.sleep(1000);
}
throw lastError;
}
const home = await waitFor(baseUrl);
const html = await home.text();
const lightTheme = await waitFor(`${baseUrl}/assets/css/theme-github-dev.css`);
const darkTheme = await waitFor(`${baseUrl}/assets/css/theme-github-dev-dark.css`);
if (!html.includes("/assets/css/theme-github-dev-dark.css")) {
throw new Error("Gitea page is not loading the custom theme-github-dev-dark.css file");
}
const lightCss = await lightTheme.text();
const darkCss = await darkTheme.text();
if (!lightCss.includes("--color-primary: #0969da")) {
throw new Error("light theme css is reachable but does not contain migrated GitHub tokens");
}
if (!darkCss.includes("--color-body: #0d1117")) {
throw new Error("dark theme css is reachable but does not contain GitHub dark tokens");
}
if (!darkCss.includes(".ui.primary.button")) {
throw new Error("dark theme css is reachable but does not contain migrated GitHub component styles");
}
console.log(`docker preview verified: ${home.status} ${baseUrl}`);