import { cpSync, existsSync } from 'node:fs';
import { resolve, dirname } from 'node:path';
import { fileURLToPath } from 'node:url';

const __dirname = dirname(fileURLToPath(import.meta.url));
const distDir = resolve(__dirname, '..', 'dist', 'client');

const source = resolve(distDir, 'sitemap-0.xml');
const target = resolve(distDir, 'sitemap.xml');

if (existsSync(source)) {
  cpSync(source, target);
  console.log('✅ sitemap.xml created');
} else {
  console.error('❌ sitemap-0.xml not found');
}