28 lines
1.3 KiB
JavaScript
28 lines
1.3 KiB
JavaScript
import { access, readFile, readdir } from "node:fs/promises";
|
|
import { join } from "node:path";
|
|
|
|
const root = new URL("../dist/", import.meta.url);
|
|
const required = ["index.html", "archive/index.html", "method/index.html", "articles/research-publishing-method/index.html", "rss.xml", "sitemap.xml"];
|
|
for (const path of required) await access(new URL(path, root));
|
|
|
|
async function walk(path) {
|
|
const entries = await readdir(path, { withFileTypes: true });
|
|
const found = [];
|
|
for (const entry of entries) {
|
|
const child = join(path, entry.name);
|
|
if (entry.isDirectory()) found.push(...await walk(child));
|
|
else if (/\.(?:html|xml|css|js|svg)$/.test(entry.name)) found.push(child);
|
|
}
|
|
return found;
|
|
}
|
|
|
|
const files = await walk(root.pathname);
|
|
const forbidden = /(?:git\.n\.xiaomi\.com|coro\.doc|\.codex\/sessions|<codex_internal_context|-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----)/;
|
|
for (const file of files) {
|
|
const text = await readFile(file, "utf8");
|
|
if (forbidden.test(text)) throw new Error(`private material found in ${file}`);
|
|
}
|
|
const index = await readFile(new URL("index.html", root), "utf8");
|
|
if (!index.includes("K1412-RESEARCH-BLOG-20260810")) throw new Error("release marker missing");
|
|
console.log(`verified: ${files.length} rendered text assets and release marker`);
|