// Static copy of the alert preview (views/alerts_preview.ejs) with the default looks, for viewing without a server: // node tools/preview/export.js // Writes /index.html plus the overlay code under /alerts/. No channel data: defaults only. const fs = require('fs'), path = require('path'), ejs = require('ejs'); const root = path.join(__dirname, '..', '..'); const out = path.resolve(process.argv[2] || 'alert-preview'); const theme = require(path.join(root, 'src', 'theme.js')); // DEFAULT only (no database needed) const SAMPLES = require(path.join(root, 'src', 'alerts.js')).SAMPLES; const themes = { defaults: { label: 'Defaults (Card)', theme: theme.DEFAULT }, optional: { label: 'Polaroid / Cassette / Letter', theme: theme.merge(theme.DEFAULT, { style: 'polaroid', redeemStyle: 'cassette', ttsStyle: 'letter' }) }, }; fs.mkdirSync(path.join(out, 'alerts', 'art'), { recursive: true }); for (const f of ['card', 'polaroid', 'cassette', 'fx']) for (const ext of ['js', 'css']) fs.copyFileSync(path.join(root, 'public', 'alerts', `${f}.${ext}`), path.join(out, 'alerts', `${f}.${ext}`)); fs.copyFileSync(path.join(root, 'public', 'alerts', 'art', 'placeholder.svg'), path.join(out, 'alerts', 'art', 'placeholder.svg')); const html = ejs.render(fs.readFileSync(path.join(root, 'views', 'alerts_preview.ejs'), 'utf8'), { base: 'alerts/', themes, start: 'defaults', samples: SAMPLES }); fs.writeFileSync(path.join(out, 'index.html'), html); console.log(`alert preview written to ${out}/index.html`);