chore: harden release checks
This commit is contained in:
48
scripts/release-check.ts
Normal file
48
scripts/release-check.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env tsx
|
||||
|
||||
import { execSync } from "node:child_process";
|
||||
|
||||
type PackFile = { path: string };
|
||||
type PackResult = { files?: PackFile[] };
|
||||
|
||||
const requiredPaths = ["dist/discord/send.js", "dist/hooks/gmail.js"];
|
||||
const forbiddenPrefixes = ["dist/Clawdis.app/"];
|
||||
|
||||
function runPackDry(): PackResult[] {
|
||||
const raw = execSync("npm pack --dry-run --json", {
|
||||
encoding: "utf8",
|
||||
stdio: ["ignore", "pipe", "pipe"],
|
||||
});
|
||||
return JSON.parse(raw) as PackResult[];
|
||||
}
|
||||
|
||||
function main() {
|
||||
const results = runPackDry();
|
||||
const files = results.flatMap((entry) => entry.files ?? []);
|
||||
const paths = new Set(files.map((file) => file.path));
|
||||
|
||||
const missing = requiredPaths.filter((path) => !paths.has(path));
|
||||
const forbidden = [...paths].filter((path) =>
|
||||
forbiddenPrefixes.some((prefix) => path.startsWith(prefix)),
|
||||
);
|
||||
|
||||
if (missing.length > 0 || forbidden.length > 0) {
|
||||
if (missing.length > 0) {
|
||||
console.error("release-check: missing files in npm pack:");
|
||||
for (const path of missing) {
|
||||
console.error(` - ${path}`);
|
||||
}
|
||||
}
|
||||
if (forbidden.length > 0) {
|
||||
console.error("release-check: forbidden files in npm pack:");
|
||||
for (const path of forbidden) {
|
||||
console.error(` - ${path}`);
|
||||
}
|
||||
}
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log("release-check: npm pack contents look OK.");
|
||||
}
|
||||
|
||||
main();
|
||||
Reference in New Issue
Block a user