#!/usr/bin/env node /** * Generates build-info.ts with auto-incrementing build number and timestamp. * Run before each build: node scripts/generate-build-info.js */ const fs = require('fs'); const path = require('path'); const BUILD_INFO_PATH = path.join(__dirname, '..', 'constants', 'build-info.ts'); // Read current build number let buildNumber = 0; try { const existing = fs.readFileSync(BUILD_INFO_PATH, 'utf8'); const match = existing.match(/BUILD_NUMBER\s*=\s*(\d+)/); if (match) { buildNumber = parseInt(match[1], 10); } } catch { // First build } buildNumber++; const now = new Date(); const timestamp = now.toISOString(); // Short format for UI: "Jan 28, 08:15" const shortDate = now.toLocaleDateString('en-US', { month: 'short', day: 'numeric' }); const shortTime = now.toLocaleTimeString('en-US', { hour: '2-digit', minute: '2-digit', hour12: false }); const content = `// Auto-generated by scripts/generate-build-info.js // DO NOT EDIT MANUALLY export const BUILD_NUMBER = ${buildNumber}; export const BUILD_TIMESTAMP = '${timestamp}'; export const BUILD_DISPLAY = 'build ${buildNumber} ยท ${shortDate}, ${shortTime}'; `; fs.writeFileSync(BUILD_INFO_PATH, content, 'utf8'); console.log(`Build info generated: #${buildNumber} at ${timestamp}`);