buster/packages/sandbox/scripts/validate-env.js

35 lines
875 B
JavaScript
Raw Normal View History

2025-07-19 04:26:46 +08:00
#!/usr/bin/env node
// Load environment variables from .env file
import { config } from 'dotenv';
config();
// Build-time environment validation
console.info('🔍 Validating environment variables...');
const env = {
NODE_ENV: process.env.NODE_ENV || 'development',
2025-07-19 04:32:12 +08:00
DAYTONA_API_KEY: process.env.DAYTONA_API_KEY,
2025-07-19 04:26:46 +08:00
};
let hasErrors = false;
for (const [envKey, value] of Object.entries(env)) {
if (!value) {
console.error(`❌ Missing required environment variable: ${envKey}`);
hasErrors = true;
} else {
console.info(`${envKey} is set`);
}
}
if (hasErrors) {
console.error('');
console.error('❌ Build cannot continue with missing environment variables.');
console.error('Please check your .env file and ensure all required variables are set.');
process.exit(1);
}
console.info('✅ All required environment variables are present');