import { copyFileSync, readdirSync, writeFileSync } from 'node:fs';
import { resolve } from 'node:path';

const source = resolve(process.cwd(), 'public/app-config.example.js');
const destination = resolve(process.cwd(), 'dist/app-config.js');

// Vite copies public/app-config.js verbatim. That file is intentionally ignored
// because developers may keep local AMap credentials in it. Never let those
// machine-local values enter a production archive; the API renders the real
// runtime configuration at /app-config.js on the server.
copyFileSync(source, destination);

const assets = readdirSync(resolve(process.cwd(), 'dist/assets')).sort();
writeFileSync(resolve(process.cwd(), 'dist/.release-assets'), `${assets.join('\n')}\n`);
