- Change from server-side rendering to static export - Fetch data at build time and save as JSON - Remove API routes and tests, use static JSON file - Switch back to WEB platform from WEB_COMPUTE - Update build test for static export - Exclude out directory from security scan - Much simpler and more reliable approach
48 lines
1.1 KiB
JavaScript
Executable File
48 lines
1.1 KiB
JavaScript
Executable File
#!/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!');
|
|
} |