archivo del paquete→ .shtukbase/packages/shtukbase-icons/checks/s01_style.ts
checks/s01_style.ts
32 líneas, 1.8 KB.
El archivo tal como está en el paquete: el código y sus comentarios no se traducen.
- // SBI-R01: every drawing of the Shtukbase icon set keeps the set's style (the flat form, the canvas, the palette, no
- // plate, no outline of its own, lines that survive at 16 px), and the rendered set in /assets/icons/set is fresh: each
- // file there is its drawing rendered in the held style, so the outline is the style's and nothing else.
- import { fmOf, iconStyle, settings } from '../../icons/lib/iconlib.ts';
- import { checkFlat } from '../lib/style-check.ts';
- import { BASE_STYLE, outDir, readText, registry, renderIcon, setStyles, styleById } from '../lib/sbicons.ts';
- const root = process.cwd();
- const fm = fmOf(root, '/norms/rules/shtukbase-icons/SBI-R01.md');
- const active = !Object.keys(fm).length || String(fm.status ?? 'active').trim() === 'active';
- const mode = String(fm.mode ?? 'enforce').trim();
- const out: string[] = [];
- if (active) {
- try {
- const reg = registry(root);
- const held = iconStyle(root, settings(root));
- const style = held && setStyles(root).some((s) => s.page === held.page) ? held : styleById(root, BASE_STYLE);
- const dir = outDir(root);
- for (const rec of reg.icons) {
- const svg = readText(root, rec.file);
- if (svg === null) continue; // ICN-R04 reports a record without its file
- for (const f of checkFlat(svg, style.rawPalette)) out.push(`${rec.file}: ${f}`);
- const built = readText(root, `${dir}/${rec.name}.svg`);
- if (built !== null && built !== renderIcon(root, rec, style)) out.push(`${dir}/${rec.name}.svg: not the drawing in style ${style.id} (edited by hand or stale) → run: shtuk run shtukbase-icons build`);
- }
- } catch (e) {
- out.push((e as Error).message);
- }
- }
- const soft = mode !== 'enforce';
- if (out.length) console.log(out.map((f) => (soft ? `(${mode}) ${f}` : f)).join('\n'));
- process.exitCode = active && out.length && !soft ? 1 : 0;