/** * Generate health check JSON file at build time */ import { writeFileSync, readFileSync } from 'fs'; import { join } from 'path'; // Read version from package.json let version = '0.1.0'; try { const packageJsonPath = join(process.cwd(), 'package.json'); const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8')); version = packageJson.version || process.env.npm_package_version || '0.1.0'; } catch (error) { console.warn('Failed to read version from package.json, using fallback:', error); version = process.env.npm_package_version || '0.1.0'; } const healthz = { status: 'ok', service: 'aitherboard', version: version, buildTime: new Date().toISOString(), gitCommit: process.env.GIT_COMMIT || 'unknown', timestamp: Date.now() }; const outputPath = join(process.cwd(), 'public', 'healthz.json'); writeFileSync(outputPath, JSON.stringify(healthz, null, 2)); console.log('Generated healthz.json');