Update editor, themes, menus, backgrounds, and release tooling
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
import { readdir, readFile } from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
const root = fileURLToPath(new URL('../', import.meta.url));
|
||||
export const projects = ['RuneStone', 'RuneStone_ProjectManagement', 'RuneStone_Terminal', 'RuneStone_BG_Slideshow', 'RuneStone_LocalAutocomplete', 'RuneStone_Git', 'RuneStone_PDFViewer', 'RuneStone_TableFormulas', 'RuneStone_CSVViewer'];
|
||||
const patterns = {
|
||||
action: /\b(?:showActionMenu|actionMenu)\s*\(/g,
|
||||
svelteMenu: /<ContextMenu\b/g,
|
||||
nativeChoice: /<select\b|(?:createElement|el)\(\s*['"]select['"]/g,
|
||||
picker: /rs-picker(?:[\s"']|$)|role=['"]listbox['"]|setAttribute\(\s*['"]role['"],\s*['"]listbox['"]/g,
|
||||
localPopup: /(?:class|className)\s*=\s*['"][^'"\n]*(?:menu|picker|popup)|\.popover\s*=/g,
|
||||
};
|
||||
async function files(dir) {
|
||||
const entries = await readdir(dir, { withFileTypes: true });
|
||||
const results = await Promise.all(entries.filter(entry => !entry.isSymbolicLink()).map(entry => entry.isDirectory()
|
||||
? files(path.join(dir, entry.name)) : /\.(svelte|[cm]?[jt]s)$/.test(entry.name) ? [path.join(dir, entry.name)] : []));
|
||||
return results.flat();
|
||||
}
|
||||
export async function discover() {
|
||||
const surfaces = {}, missing = [];
|
||||
for (const project of projects) {
|
||||
const base = project === 'RuneStone' ? root : path.resolve(root, '..', project);
|
||||
let sources;
|
||||
try { sources = await files(path.join(base, 'src')); } catch (error) { if (error.code === 'ENOENT') { missing.push(project); continue; } throw error; }
|
||||
for (const file of sources) {
|
||||
const source = await readFile(file, 'utf8');
|
||||
const counts = Object.fromEntries(Object.entries(patterns).map(([name, pattern]) => [name, [...source.matchAll(pattern)].length]).filter(([, count]) => count));
|
||||
if (Object.keys(counts).length) surfaces[`${project}/${path.relative(base, file).replaceAll('\\', '/')}`] = counts;
|
||||
}
|
||||
}
|
||||
return { surfaces, missing };
|
||||
}
|
||||
export async function checkInventory() {
|
||||
const { surfaces, missing } = await discover();
|
||||
const inventory = JSON.parse(await readFile(path.join(root, 'docs/menu-surfaces.json'), 'utf8'));
|
||||
const failures = missing.map(project => `Missing checkout: ${project}`);
|
||||
for (const [file, counts] of Object.entries(surfaces)) {
|
||||
const entry = inventory.surfaces[file];
|
||||
if (!entry) failures.push(`Unreviewed surface: ${file}`);
|
||||
else if (JSON.stringify(counts) !== JSON.stringify(entry.counts)) failures.push(`Changed entry points: ${file}`);
|
||||
else if (!entry.design || !entry.check) failures.push(`Missing design or check: ${file}`);
|
||||
}
|
||||
for (const file of Object.keys(inventory.surfaces)) if (!(file in surfaces)) failures.push(`Stale inventory: ${file}`);
|
||||
for (const name of ['actionMenu.ts', 'managedActionMenu.ts', 'IconButton.svelte']) {
|
||||
try {
|
||||
const host = await readFile(path.join(root, 'src/lib/ui', name), 'utf8');
|
||||
const terminal = await readFile(path.resolve(root, '../RuneStone_Terminal/vendor/runestone/ui', name), 'utf8');
|
||||
if (host.replaceAll('\r\n', '\n') !== terminal.replaceAll('\r\n', '\n')) failures.push(`Terminal shared snapshot differs: ${name}`);
|
||||
} catch (error) { failures.push(`Cannot check Terminal snapshot ${name}: ${error.code}`); }
|
||||
}
|
||||
if (failures.length) { console.error(failures.join('\n')); return false; }
|
||||
console.log(`PASS: ${Object.keys(surfaces).length} source files across ${projects.length} projects match the reviewed menu inventory. Runtime checks remain separate.`);
|
||||
return true;
|
||||
}
|
||||
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
||||
if (process.argv.includes('--discover')) console.log(JSON.stringify(await discover(), null, 2));
|
||||
else if (!await checkInventory()) process.exitCode = 1;
|
||||
}
|
||||
Reference in New Issue
Block a user