archivo del paquete→ .shtukbase/packages/icons/checks/i02_budget.ts
checks/i02_budget.ts
35 líneas, 2.1 KB.
El archivo tal como está en el paquete: el código y sus comentarios no se traducen.
- // ICN-R02: the icon budget. A page carries only what its tier allows; a picture drawn for a page (bespoke) needs the tier
- // `bespoke`, and a collection holds at most `icons.max` bespoke files. Tiers: none < kind < pick < bespoke.
- import { Icons, finish, isGlyph, isSvgPath, norm, ownIcons, SETTINGS_PAGE } from '../lib/iconlib.ts';
- const ic = new Icons();
- const n = norm(ic.root, 'ICN-R02');
- const out: string[] = [];
- const bespoke = new Map<string, Set<string>>(); // group -> distinct bespoke files
- if (n.active) {
- for (const p of ic.pages()) {
- const { icon, art } = ownIcons(p);
- const at = `${p.id} (tier ${p.tier}: ${p.why})`;
- const files: string[] = [];
- if (icon && isSvgPath(icon)) files.push(ic.resolve(p.id, icon));
- if (art && isSvgPath(art)) files.push(ic.resolve(p.id, art));
- const own = files.filter((f) => !ic.inSet(f));
- if (p.tier === 'none' && (icon || art)) out.push(`${at}: the page carries an icon, the tier shows none → remove icon and art`);
- else if (p.tier === 'kind' && (icon || art)) out.push(`${at}: the page carries its own icon, the collection gives one icon to all → remove icon and art (set icons.item on the collection)`);
- else if (p.tier === 'pick') {
- if (art) out.push(`${at}: art is a bespoke picture → remove art, or raise the tier to bespoke in the collection`);
- if (icon && !isGlyph(icon) && own.length) out.push(`${at}: icon ${own[0]} is drawn for the page, the tier allows an emoji or an icon from ${ic.s.set}/ → pick one`);
- }
- if (p.tier === 'bespoke' && own.length) {
- const g = p.coll ?? (ic.s.heroes.includes(p.id) ? '' : '(pages outside collections)');
- if (g) for (const f of own) (bespoke.get(g) ?? bespoke.set(g, new Set()).get(g)!).add(f);
- }
- }
- const colls = ic.collections();
- for (const [g, files] of bespoke) {
- const max = colls[g]?.max ?? ic.s.max;
- if (files.size > max) out.push(`${g}${colls[g] ? '.md' : ''}: ${files.size} bespoke icon files, the budget is ${max} → reuse files, move pages to the shared set, or raise icons.max (${colls[g] ? 'the collection' : SETTINGS_PAGE}) with the owner`);
- }
- }
- finish(n, out);