31 lines
1.1 KiB
JavaScript
31 lines
1.1 KiB
JavaScript
import { readdirSync, readFileSync, statSync } from "node:fs";
|
|
import { join } from "node:path";
|
|
|
|
let files = 0,
|
|
size = 0;
|
|
function inspect(directory) {
|
|
for (const name of readdirSync(directory)) {
|
|
const path = join(directory, name);
|
|
if (statSync(path).isDirectory()) {
|
|
inspect(path);
|
|
continue;
|
|
}
|
|
if (!/\.(html|js|css|svg)$/.test(name))
|
|
throw new Error(`Unexpected production asset: ${path}`);
|
|
if (/reference|vendor|binjgb/i.test(path))
|
|
throw new Error(`Reference tool in production: ${path}`);
|
|
const bytes = readFileSync(path),
|
|
text = bytes.toString("utf8");
|
|
if (/Binjgb|_emulator_|binjgb\.wasm|\.reference\/pokecrystal/.test(text))
|
|
throw new Error(`Reference dependency in production: ${path}`);
|
|
if (/data:(image|audio|application\/octet-stream)[^,]*;base64,/i.test(text))
|
|
throw new Error(`Embedded binary asset in production: ${path}`);
|
|
files++;
|
|
size += bytes.length;
|
|
}
|
|
}
|
|
inspect("dist");
|
|
console.log(
|
|
`Native release verified: ${files} HTML/JS/CSS/SVG files, ${size} bytes; no emulator, ROM, extracted binary assets or reference checkout.`,
|
|
);
|