const { copyFileSync, existsSync } = require('node:fs');
const { join } = require('node:path');

const projectRoot = join(__dirname, '..');
const legacyBundle = join(projectRoot, 'dist', 'legacy', 'src', 'main.js');
const legacyShim = join(projectRoot, 'scripts', 'legacy-main.js');
const legacyEntry = join(projectRoot, 'dist', 'main.js');

if (!existsSync(legacyBundle)) {
  throw new Error(`Legacy monolith bundle not found: ${legacyBundle}`);
}

copyFileSync(legacyShim, legacyEntry);
