hypertwist/Content/Browser/scripts/verify-browser-shell.mjs
2026-06-11 17:45:34 +00:00

46 lines
1.4 KiB
JavaScript

import { existsSync, readFileSync } from 'node:fs';
import path from 'node:path';
import process from 'node:process';
const browserRoot = path.resolve(import.meta.dirname, '..');
const shellPath = path.join(browserRoot, 'index.html');
const bootstrapPath = path.join(browserRoot, 'src', 'browser-runtime-bootstrap.js');
const fallbackPath = path.join(browserRoot, 'src', 'browser-spatial-runtime-fallback.js');
const failures = [];
function assert(condition, message)
{
if (!condition)
{
failures.push(message);
}
}
assert(existsSync(shellPath), `Missing authoritative browser shell: ${shellPath}`);
assert(existsSync(bootstrapPath), `Missing bootstrap runtime script: ${bootstrapPath}`);
assert(existsSync(fallbackPath), `Missing clean-checkout fallback runtime: ${fallbackPath}`);
if (existsSync(shellPath))
{
const shellHtml = readFileSync(shellPath, 'utf8');
assert(
shellHtml.includes('./src/browser-runtime-bootstrap.js'),
'The authoritative browser shell must load the bootstrap runtime script.'
);
assert(
!shellHtml.includes('browser-spatial-runtime.ts'),
'The authoritative browser shell must not point directly at a TypeScript source entrypoint.'
);
}
if (failures.length > 0)
{
for (const failure of failures)
{
console.error(failure);
}
process.exit(1);
}
console.log('HyperTwist browser shell verification passed.');