const fs = require('fs'); const path = require('path'); const root = path.resolve(__dirname, '..'); const templatePath = path.join(root, 'shared-html', 'index.template.html'); const template = fs.readFileSync(templatePath, 'utf8'); const updaterMarkup = ``; const variants = { web: { styles_href: '/static/styles.css', lucide_src: '/static/vendor/lucide.min.js', app_src: '/static/app.js?v=20260227-shared-core-1', web_downloads: `
Desktop downloads: Windows Linux (RPM)
`, desktop_updater: updaterMarkup, outPath: path.join(root, 'static', 'index.html'), }, desktop: { styles_href: '../static/styles.css', lucide_src: '../static/vendor/lucide.min.js', app_src: 'app.js?v=20260227-shared-core-1', web_downloads: '', desktop_updater: updaterMarkup, outPath: path.join(root, 'desktop', 'index.html'), }, }; for (const variant of Object.values(variants)) { let output = template; for (const [key, value] of Object.entries(variant)) { if (key === 'outPath') continue; const token = `{{${key}}}`; if (value === '') { output = output.replace(new RegExp(`^[ \\t]*\\{\\{${key}\\}\\}[ \\t]*\\n?`, 'm'), ''); continue; } output = output.replaceAll(token, value); } if (/\{\{[a-z_]+\}\}/i.test(output)) { throw new Error(`Unresolved template placeholders remain in ${variant.outPath}`); } fs.writeFileSync( variant.outPath, `\n${output}`, 'utf8' ); }