Files
mp-silma-ai-aide/scripts/verify-dist.mjs
T
2026-07-17 14:16:54 -05:00

34 lines
998 B
JavaScript

import { existsSync, readFileSync } from "node:fs";
import { join } from "node:path";
const distDir = "dist";
const manifestPath = join(distDir, "manifest.json");
function fail(message) {
console.error(message);
process.exitCode = 1;
}
if (!existsSync(distDir)) {
fail("Missing dist/ output directory. Run vite build first.");
} else if (!existsSync(manifestPath)) {
fail("Missing dist/manifest.json. The built folder is not loadable as a Chrome extension.");
} else {
const manifest = JSON.parse(readFileSync(manifestPath, "utf8"));
const popup = manifest.action?.default_popup;
if (manifest.manifest_version !== 3) {
fail("dist/manifest.json must be a Manifest V3 extension manifest.");
}
if (!popup) {
fail("dist/manifest.json is missing action.default_popup.");
} else if (!existsSync(join(distDir, popup))) {
fail(`dist/${popup} does not exist.`);
}
}
if (!process.exitCode) {
console.log("dist/ is ready to load as an unpacked Chrome extension.");
}