Ratatoskr/scripts/preview-config.js
Void 7a896c5f93 preview: pretend homeserver for the dev preview, in-page and off by default
src/preview-demo answers a demo.invalid homeserver from fixtures through a guarded fetch;
own-origin requests pass, every other origin is refused (fetch, WebSocket, XHR, beacon).
Built in only with VITE_PREVIEW_DEMO=1 and switched on by previewDemo in config.json
(scripts/preview-config.js --demo, run by the dev workflow). Login prefills 'demo'.
Pose art: 24 downscaled thumbnails in preview-demo/poses, copied into dist by the workflow.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-07 18:49:59 +00:00

28 lines
1.2 KiB
JavaScript

// Preview builds: set the background scene tier in dist/config.json (default 'low'); config.json
// in the repo stays 'off'. With --demo it also switches on the pretend homeserver (src/preview-demo):
// previewDemo true, and the pretend server as the only homeserver. Usage:
// node scripts/preview-config.js [tier] [--demo]
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
const args = process.argv.slice(2);
const demo = args.includes('--demo');
const tier = args.find((a) => !a.startsWith('--')) ?? 'low';
const file = path.join(path.dirname(fileURLToPath(import.meta.url)), '..', 'dist', 'config.json');
const config = JSON.parse(fs.readFileSync(file, 'utf8'));
config.backgroundScene = { ...config.backgroundScene, tier };
if (demo) {
config.previewDemo = true;
config.defaultHomeserver = 0;
config.homeserverList = ['demo.invalid'];
config.allowCustomHomeservers = false;
config.featuredCommunities = {
openAsDefault: false,
spaces: ['#gamecult:demo.invalid'],
rooms: [],
servers: ['demo.invalid'],
};
}
fs.writeFileSync(file, `${JSON.stringify(config, null, 2)}\n`);
console.log(`${file}: backgroundScene.tier = ${tier}${demo ? ', previewDemo on' : ''}`);