Set once (GET/PUT /api/identity, venue.name + venue.identity); every colour field offers the venue's colours first (VenueColoursProvider in @xenia/ui); signage screens get the identity and the venue's time zone with their venue and are told on a change; logos are protected in the media library; wifiQr() for the join-the-network code. Plan 6R.14, F-111. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
56 lines
2.8 KiB
JavaScript
56 lines
2.8 KiB
JavaScript
// Plan step 6.1: the manager's pages on the v2 rules (v2.json `paths`) keep them. Texts are
|
|
// keys in @xenia/i18n (namespace `manager`), so no Greek letter in their source; colours are
|
|
// @xenia/ui tokens, so no colour value in their code. Each phase 6 step adds what it converted
|
|
// to v2.json; at the end (6.14) the list is `src`.
|
|
// Colours the venue picks for its screens (signage slides, a device's colour setting) are data,
|
|
// not styling: the files in DATA hold such defaults.
|
|
import { test } from 'node:test'
|
|
import assert from 'node:assert/strict'
|
|
import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs'
|
|
import path from 'node:path'
|
|
import { fileURLToPath } from 'node:url'
|
|
|
|
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
|
|
const v2 = JSON.parse(readFileSync(path.join(ROOT, 'v2.json'), 'utf8'))
|
|
const DATA = new Set([
|
|
'src/pages/signage/signageLogic.js', 'src/pages/signage/SignageFields.jsx', 'src/pages/signage/SlideEditor.jsx',
|
|
'src/pages/signage/MenuEditor.jsx', 'src/pages/platform/DeviceConfigFields.jsx', 'src/pages/products/categoryColours.js',
|
|
'src/pages/Settings/sections/venueColours.js', 'src/pages/Settings/sections/identityLogic.js',
|
|
])
|
|
const GREEK = /[Ͱ-Ͽἀ-]/
|
|
const COLOUR = [
|
|
/(^|[^\w&])#[0-9a-fA-F]{3}(?:[0-9a-fA-F]{3})?(?:[0-9a-fA-F]{2})?\b/,
|
|
/\brgba?\(\s*\d/,
|
|
/\bhsla?\(\s*\d/,
|
|
/['"](white|black)['"]/,
|
|
]
|
|
|
|
const walk = p => (statSync(p).isDirectory() ? readdirSync(p).flatMap(n => walk(path.join(p, n))) : (/\.(jsx?|css)$/.test(p) ? [p] : []))
|
|
const files = () => v2.paths.flatMap(rel => walk(path.join(ROOT, rel))).map(f => path.relative(ROOT, f).split(path.sep).join('/'))
|
|
|
|
test('every v2 path exists (v2.json is current)', () => {
|
|
assert.deepEqual(v2.paths.filter(p => !existsSync(path.join(ROOT, p))), [])
|
|
assert.deepEqual(v2.strict.filter(p => !v2.paths.some(q => p === q || p.startsWith(`${q}/`))), [], 'strict paths must be v2 paths')
|
|
})
|
|
|
|
test('no Greek text in v2 pages (texts are i18n keys)', () => {
|
|
const hits = []
|
|
for (const rel of files()) {
|
|
readFileSync(path.join(ROOT, rel), 'utf8').split('\n').forEach((line, i) => {
|
|
if (GREEK.test(line)) hits.push(`${rel}:${i + 1}: ${line.trim().slice(0, 80)}`)
|
|
})
|
|
}
|
|
assert.deepEqual(hits, [], `Greek text found — make it a key in the manager namespace:\n${hits.join('\n')}`)
|
|
})
|
|
|
|
test('no colour literal in v2 pages (tokens only)', () => {
|
|
const hits = []
|
|
for (const rel of files()) {
|
|
if (DATA.has(rel)) continue
|
|
readFileSync(path.join(ROOT, rel), 'utf8').split('\n').forEach((line, i) => {
|
|
if (COLOUR.some(re => re.test(line))) hits.push(`${rel}:${i + 1}: ${line.trim().slice(0, 90)}`)
|
|
})
|
|
}
|
|
assert.deepEqual(hits, [], `colour values in page code — use a token (var(--x-…) / @xenia/ui):\n${hits.join('\n')}`)
|
|
})
|