Initial curated projectbrain source from 8a7b1e0651dbdab97d744cbd2e653ab3970ac6c5
This commit is contained in:
commit
5aa3e8d685
700 files changed
+132801
No files matched your search
@@ -0,0 +1,74 @@
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
|
||||
const archiveDir = process.env.PROJECTBRAIN_PROOF_ARCHIVE_DIR ?? "checkpoints/release-proof";
|
||||
const limitArg = process.argv.find((arg) => arg.startsWith("--limit="));
|
||||
const limit = Number.parseInt(limitArg?.slice("--limit=".length) ?? process.env.PROJECTBRAIN_PROOF_INDEX_LIMIT ?? "10", 10);
|
||||
|
||||
const parseField = (text, label) => {
|
||||
const match = text.match(new RegExp(`^${label}:\\s*(.+)$`, "m"));
|
||||
return match?.[1]?.trim() ?? "unknown";
|
||||
};
|
||||
|
||||
const displayPath = (filePath) => filePath.split(path.sep).join("/");
|
||||
|
||||
const parseProof = (filePath) => {
|
||||
const text = fs.readFileSync(filePath, "utf8");
|
||||
const stat = fs.statSync(filePath);
|
||||
|
||||
return {
|
||||
filePath,
|
||||
displayPath: displayPath(filePath),
|
||||
fileName: path.basename(filePath),
|
||||
modifiedAt: stat.mtime.toISOString(),
|
||||
generated: parseField(text, "Generated"),
|
||||
commit: parseField(text, "Commit"),
|
||||
baseUrl: parseField(text, "Base URL"),
|
||||
project: parseField(text, "Project"),
|
||||
verdict: parseField(text, "Verdict"),
|
||||
smokeExecution: text.match(/^- Smoke execution:\s*(.+)$/m)?.[1]?.trim() ?? "unknown",
|
||||
};
|
||||
};
|
||||
|
||||
const listProofFiles = () => {
|
||||
if (!fs.existsSync(archiveDir)) return [];
|
||||
|
||||
return fs.readdirSync(archiveDir)
|
||||
.filter((fileName) => fileName.endsWith(".md"))
|
||||
.map((fileName) => path.join(archiveDir, fileName))
|
||||
.filter((filePath) => fs.statSync(filePath).isFile());
|
||||
};
|
||||
|
||||
const proofs = listProofFiles()
|
||||
.map(parseProof)
|
||||
.sort((a, b) => Date.parse(b.generated) - Date.parse(a.generated) || b.fileName.localeCompare(a.fileName));
|
||||
|
||||
const latestPassing = proofs.find((proof) => proof.verdict === "PASS");
|
||||
const selectedProofs = proofs.slice(0, Number.isFinite(limit) && limit > 0 ? limit : 10);
|
||||
|
||||
const lines = [
|
||||
"# ProjectBrain Release Proof Index",
|
||||
"",
|
||||
`Archive: ${archiveDir}`,
|
||||
`Proof snapshots: ${proofs.length}`,
|
||||
`Latest passing proof: ${latestPassing ? latestPassing.displayPath : "none"}`,
|
||||
"",
|
||||
];
|
||||
|
||||
if (!proofs.length) {
|
||||
lines.push("No release proof snapshots found.");
|
||||
lines.push("");
|
||||
lines.push("Create one with:");
|
||||
lines.push("");
|
||||
lines.push("```bash");
|
||||
lines.push("PROJECTBRAIN_PROOF_WRITE=1 pnpm run release:proof-report");
|
||||
lines.push("```");
|
||||
} else {
|
||||
lines.push("| Generated | Verdict | Commit | Project | Smoke | File |");
|
||||
lines.push("| --- | --- | --- | --- | --- | --- |");
|
||||
for (const proof of selectedProofs) {
|
||||
lines.push(`| ${proof.generated} | ${proof.verdict} | ${proof.commit} | ${proof.project} | ${proof.smokeExecution} | ${proof.displayPath} |`);
|
||||
}
|
||||
}
|
||||
|
||||
console.log(lines.join("\n"));
|
||||
Reference in new issue
Block a user