Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UaC9HmtHMdRP8dAbN4wAKj
8 lines
712 B
JavaScript
8 lines
712 B
JavaScript
// Every setting the app syncs must be one the server accepts, or the whole save fails.
|
|
const fs = require('fs'), assert = require('assert');
|
|
const client = fs.readFileSync(__dirname + '/../public/app.js', 'utf8'), server = fs.readFileSync(__dirname + '/../settings.js', 'utf8');
|
|
const list = s => [...s.matchAll(/'([a-z_]+)'/g)].map(m => m[1]);
|
|
const c = list(/const SYNCED = new Set\(\[([^\]]*)\]/.exec(client)[1]), s = new Set(list(/const KEYS = new Set\(\[([^\]]*)\]/.exec(server)[1]));
|
|
const missing = c.filter(k => !s.has(k)); assert.deepStrictEqual(missing, [], 'the server would refuse: ' + missing.join(', '));
|
|
console.log('settings keys: ' + c.length + ' synced settings, all accepted by the server');
|