#!/usr/bin/env node const { execSync } = require('child_process'); const fs = require('fs'); const path = require('path'); console.log('๐Ÿงช Testing build locally...\n'); // Clean previous build console.log('๐Ÿงน Cleaning previous build...'); try { execSync('rm -rf .next', { stdio: 'inherit' }); } catch (e) { // Ignore if doesn't exist } // Run build console.log('\n๐Ÿ”จ Running build...'); try { execSync('npm run build', { stdio: 'inherit' }); } catch (e) { console.error('โŒ Build failed!'); process.exit(1); } // Check for required files console.log('\n๐Ÿ” Checking build output...'); const checks = [ { path: 'out/index.html', name: 'Static HTML output' }, { path: '.next/static', name: 'Static directory' }, ]; let allPassed = true; for (const check of checks) { if (fs.existsSync(check.path)) { console.log(`โœ… ${check.name}: Found`); } else { console.error(`โŒ ${check.name}: Missing at ${check.path}`); allPassed = false; } } if (!allPassed) { console.error('\nโŒ Build test failed! Do not push.'); process.exit(1); } else { console.log('\nโœ… All build tests passed!'); }