// Sync único do HTML do Shivão pra todos os destinos.
// Fonte de verdade: app/diario-bordo.html
// Destinos: server/public/index.html (Express) + mobile/www/index.html (Capacitor)
import { copyFile, mkdir } from 'node:fs/promises';
import { dirname, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';

const __dirname = dirname(fileURLToPath(import.meta.url));
const root = resolve(__dirname, '..');

const src = resolve(root, 'app/diario-bordo.html');
const targets = [
  resolve(root, 'server/public/index.html'),
  resolve(root, 'mobile/www/index.html'),
];

async function sync() {
  for (const t of targets) {
    await mkdir(dirname(t), { recursive: true });
    await copyFile(src, t);
    console.log(`✓ ${src} → ${t}`);
  }
}

sync().catch(e => { console.error(e); process.exit(1); });
