Files
bitvid/scripts/verify-dist-deploy-artifact.mjs
T
google-labs-jules[bot]andPR0M3TH3AN 6a284e0b2d fix: Ensure version info visibility and build robustness
- Moved `<!-- VERSION_INFO -->` out of `.fade-in` container in `index.html` to prevent visibility issues if JS fails.
- Added verification in `scripts/build-dist.mjs` to ensure `dist/components` exists and is not empty.
- Added logging to `scripts/build-dist.mjs` for version injection status.
- Updated `scripts/verify-dist-deploy-artifact.mjs` regex to accommodate HTML structure change.

Co-authored-by: PR0M3TH3AN <[email protected]>
2026-02-11 14:15:52 +00:00

51 lines
1.7 KiB
JavaScript

#!/usr/bin/env node
import fs from 'node:fs';
import path from 'node:path';
const DIST_DIR = 'dist';
const INDEX_PATH = path.join(DIST_DIR, 'index.html');
const MANIFEST_PATH = path.join(DIST_DIR, 'asset-manifest.json');
const VERSION_MARKUP_PATTERN = /seed\.\s*zap\.\s*subscribe\.\s*<\/h2>[\s\S]*?v:\s*[a-f0-9]{8}\s*•\s*\d{4}-\d{2}-\d{2}/i;
function readUtf8(filePath) {
if (!fs.existsSync(filePath)) {
throw new Error(`Missing required file: ${filePath}`);
}
return fs.readFileSync(filePath, 'utf8');
}
function assert(condition, message) {
if (!condition) {
throw new Error(message);
}
}
function main() {
const indexHtml = readUtf8(INDEX_PATH);
assert(
VERSION_MARKUP_PATTERN.test(indexHtml),
'dist/index.html is missing version markup under the slogan (expected: v: <8-char-hash> • <date>).'
);
const manifest = JSON.parse(readUtf8(MANIFEST_PATH));
const cssHashedPath = manifest['css/tailwind.generated.css'];
const jsHashedPath = manifest['js/index.js'];
assert(cssHashedPath, 'dist/asset-manifest.json is missing css/tailwind.generated.css.');
assert(jsHashedPath, 'dist/asset-manifest.json is missing js/index.js.');
assert(
indexHtml.includes(`href="${cssHashedPath}"`) || indexHtml.includes(`href='${cssHashedPath}'`),
`dist/index.html does not reference manifest CSS asset: ${cssHashedPath}`
);
assert(
indexHtml.includes(`src="${jsHashedPath}"`) || indexHtml.includes(`src='${jsHashedPath}'`),
`dist/index.html does not reference manifest JS asset: ${jsHashedPath}`
);
console.log('Deployment artifact verification passed: version markup and hashed asset references are present in dist/index.html.');
}
main();