feat: Simplification of UI and icons creation

This commit is contained in:
gauvainboiche
2026-10-08 16:52:21 +02:00
parent a88b8f5f14
commit 2f7c307f0e
22 changed files with 1099 additions and 408 deletions
+8 -18
View File
@@ -1,35 +1,25 @@
// Icon list tooling.
//
// npm run icons print the exhaustive list as Markdown
// npm run icons -- --write refresh the list inside README.md
// npm run icons print the work list
// npm run icons -- --write write it to ICONS.txt
// npm run icons -- --manifest print a theme.json "assets" skeleton (every key -> img/<key>.svg)
import { readFileSync, writeFileSync } from 'node:fs';
import { writeFileSync } from 'node:fs';
import { fileURLToPath } from 'node:url';
import { assetsSkeleton, renderMarkdown } from './icon-keys.js';
import { loadContext } from './context.js';
import { assetsSkeleton, renderText } from './icon-keys.js';
export const README = fileURLToPath(new URL('../README.md', import.meta.url));
export const START = '<!-- icons:start (generated by `npm run icons -- --write`, do not edit by hand) -->';
export const END = '<!-- icons:end -->';
/** README text with the generated list refreshed between the markers. */
export function withIconList(readme, ctx) {
const start = readme.indexOf(START);
const end = readme.indexOf(END);
if (start < 0 || end < start) throw new Error('README.md has no icon list markers');
return `${readme.slice(0, start + START.length)}\n\n${renderMarkdown(ctx)}\n\n${readme.slice(end)}`;
}
export const ICONS_FILE = fileURLToPath(new URL('../ICONS.txt', import.meta.url));
if (process.argv[1] === fileURLToPath(import.meta.url)) {
const ctx = loadContext();
const args = process.argv.slice(2);
if (args.includes('--write')) {
writeFileSync(README, withIconList(readFileSync(README, 'utf8'), ctx));
console.log('README.md updated');
writeFileSync(ICONS_FILE, renderText(ctx));
console.log('ICONS.txt updated');
} else if (args.includes('--manifest')) {
console.log(JSON.stringify({ assets: assetsSkeleton(ctx) }, null, 2));
} else {
console.log(renderMarkdown(ctx));
process.stdout.write(renderText(ctx));
}
}