import * as fs from 'node:fs'; import * as path from 'node:path'; import { fileURLToPath } from 'node:url'; // Get the current file's directory const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); // Get the Bang URL from environment or use a default for local development const bangUrl = process.env.VITE_BANG_URL || 'https://bang.gbrown.org'; // Create the OpenSearch XML content const openSearchXml = ` Bang! A better default search engine with bangs UTF-8 ${bangUrl}/bang.svg ${bangUrl} `; // Ensure the public directory exists const publicDir = path.resolve(__dirname, '../public'); if (!fs.existsSync(publicDir)) { fs.mkdirSync(publicDir, { recursive: true }); } // Write the OpenSearch XML file fs.writeFileSync(path.join(publicDir, 'opensearch.xml'), openSearchXml); console.log('OpenSearch XML file generated successfully!');