// Stamps public/version.json with the current LOCAL date-time.
// Run automatically before every build — see package.json "build" script.
//   Output example: { "version": "2026-07-09 08:27:45" }
import { writeFileSync } from 'fs';

const d = new Date();
const p = (n) => String(n).padStart(2, '0');
const version =
  `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())} ` +
  `${p(d.getHours())}:${p(d.getMinutes())}:${p(d.getSeconds())}`;

writeFileSync('public/version.json', JSON.stringify({ version }) + '\n');
console.log('version.json stamped:', version);
