Spaces:
Runtime error
Runtime error
Download scripts/verify-build.mjs from RalphThings/yue2-studio: direct link, hf CLI and curl.
- Browser
- Download file 1.59 kB
-
https://huggingface.co/spaces/RalphThings/yue2-studio/resolve/main/scripts/verify-build.mjs
- Command line
-
hf download hf://spaces/RalphThings/yue2-studio/scripts/verify-build.mjs
-
curl -L -o verify-build.mjs https://huggingface.co/spaces/RalphThings/yue2-studio/resolve/main/scripts/verify-build.mjs
1.59 kB
| /** | |
| * Asserts the build produced a real stylesheet. | |
| * | |
| * An unstyled page is a miserable thing to debug from a container log, because | |
| * every process reports success. Failing the image build instead turns it into | |
| * one obvious line. | |
| */ | |
| import { readdirSync, readFileSync, statSync } from "node:fs"; | |
| import { join } from "node:path"; | |
| const root = ".next/static"; | |
| function walk(dir) { | |
| const out = []; | |
| for (const entry of readdirSync(dir, { withFileTypes: true })) { | |
| const path = join(dir, entry.name); | |
| if (entry.isDirectory()) out.push(...walk(path)); | |
| else out.push(path); | |
| } | |
| return out; | |
| } | |
| let files; | |
| try { | |
| files = walk(root); | |
| } catch { | |
| console.error(`verify-build: ${root} does not exist. The build did not emit assets.`); | |
| process.exit(1); | |
| } | |
| const sheets = files.filter((f) => f.endsWith(".css")); | |
| if (sheets.length === 0) { | |
| console.error("verify-build: no stylesheet in the build output."); | |
| process.exit(1); | |
| } | |
| const biggest = sheets | |
| .map((f) => ({ f, size: statSync(f).size })) | |
| .sort((a, b) => b.size - a.size)[0]; | |
| if (biggest.size < 2000) { | |
| console.error(`verify-build: ${biggest.f} is only ${biggest.size} bytes, so Tailwind emitted nothing.`); | |
| process.exit(1); | |
| } | |
| const css = readFileSync(biggest.f, "utf8"); | |
| for (const token of ["--color-citron", "--color-void"]) { | |
| if (!css.includes(token)) { | |
| console.error(`verify-build: ${token} missing from ${biggest.f}. The theme did not compile.`); | |
| process.exit(1); | |
| } | |
| } | |
| console.log(`verify-build: ok, ${biggest.f} is ${biggest.size} bytes with the theme tokens.`); | |