mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-11-10 13:18:25 +00:00
* feat(metadata): reusable tag groups with `$group:` A `$group:<group-name>` marker in `tags` is replaced in place with the tags of `groups/<group-name>.json`: a small set of tags for what a variant suffix means, such as `-minus` → remove, delete. - Read groups in `readGroups` and resolve markers next to `$extends:`, failing on unknown groups and on `$group:` outside `tags` - Add `group.schema.json` and lint, spell-check and format `groups/*.json` - `pnpm checkIcons` also fails on literals a group already provides, and warns about icons that list a group's tags by hand and unused groups - Add the `minus`, `plus` and `x` groups and use them in `alarm-clock-minus`, `file-minus`, `file-plus` and `file-x` Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Fix group checker * Apply batched suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * feat(metadata): reusable tag groups with `$group:` A `$group:<group-name>` marker in `tags` is replaced in place with the tags of `groups/<group-name>.json`: a small set of tags for what a variant suffix means, such as `-minus` → remove, delete. - Read groups in `readGroups` and resolve markers next to `$extends:`, failing on unknown groups and on `$group:` outside `tags` - Add `group.schema.json` and lint, spell-check and format `groups/*.json` - `pnpm checkIcons` also fails on literals a group already provides, and warns about icons that list a group's tags by hand and unused groups - Add the `minus`, `plus` and `x` groups and use them in `alarm-clock-minus`, `file-minus`, `file-plus` and `file-x` Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Fix group checker * Apply batched suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * feat(metadata): reusable tag groups with `$group:` A `$group:<group-name>` marker in `tags` is replaced in place with the tags of `groups/<group-name>.json`: a small set of tags for what a variant suffix means, such as `-minus` → remove, delete. - Read groups in `readGroups` and resolve markers next to `$extends:`, failing on unknown groups and on `$group:` outside `tags` - Add `group.schema.json` and lint, spell-check and format `groups/*.json` - `pnpm checkIcons` also fails on literals a group already provides, and warns about icons that list a group's tags by hand and unused groups - Add the `minus`, `plus` and `x` groups and use them in `alarm-clock-minus`, `file-minus`, `file-plus` and `file-x` Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Fix group checker * Apply batched suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * feat(metadata): reusable tag groups with `$group:` A `$group:<group-name>` marker in `tags` is replaced in place with the tags of `groups/<group-name>.json`: a small set of tags for what a variant suffix means, such as `-minus` → remove, delete. - Read groups in `readGroups` and resolve markers next to `$extends:`, failing on unknown groups and on `$group:` outside `tags` - Add `group.schema.json` and lint, spell-check and format `groups/*.json` - `pnpm checkIcons` also fails on literals a group already provides, and warns about icons that list a group's tags by hand and unused groups - Add the `minus`, `plus` and `x` groups and use them in `alarm-clock-minus`, `file-minus`, `file-plus` and `file-x` Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Fix group checker * Apply batched suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
58 lines
2.1 KiB
TypeScript
58 lines
2.1 KiB
TypeScript
/**
|
|
* Spell checks icon and category metadata with cspell and reports every unknown word as a GitHub
|
|
* Actions annotation (`::error file=…,line=…`), so it shows up inline in the PR diff.
|
|
*
|
|
* Words that are correct but unknown to cspell go in `.cspell/custom-words.txt`.
|
|
*/
|
|
import process from 'process';
|
|
import { spawnSync } from 'child_process';
|
|
import { fileURLToPath } from 'url';
|
|
|
|
const PATTERNS = ['icons/*.json', 'categories/*.json', 'groups/*.json'];
|
|
|
|
// cspell only exports its bin for `import`, so resolve it the ESM way.
|
|
const cspellBin = fileURLToPath(import.meta.resolve('cspell/bin.mjs'));
|
|
|
|
const cspell = spawnSync(
|
|
process.execPath,
|
|
[cspellBin, '--no-color', '--no-progress', '--no-summary', ...PATTERNS],
|
|
{ encoding: 'utf-8', maxBuffer: 64 * 1024 * 1024 },
|
|
);
|
|
|
|
/** Escape data for a workflow command, see https://github.com/actions/toolkit/blob/main/packages/core/src/command.ts */
|
|
const escapeData = (value: string) =>
|
|
value.replaceAll('%', '%25').replaceAll('\r', '%0D').replaceAll('\n', '%0A');
|
|
const escapeProperty = (value: string) =>
|
|
escapeData(value).replaceAll(':', '%3A').replaceAll(',', '%2C');
|
|
|
|
const issue = /^(.+?):(\d+):(\d+) - Unknown word \((.+?)\)(?: fix: \((.+?)\))?/;
|
|
let problems = 0;
|
|
|
|
for (const line of cspell.stdout.split('\n')) {
|
|
const match = line.match(issue);
|
|
if (!match) continue;
|
|
|
|
const [, file, lineNumber, column, word, fix] = match;
|
|
const suggestion = fix ? ` Did you mean "${fix}"?` : '';
|
|
const message = `Unknown word "${word}".${suggestion} Fix the typo or add the word to .cspell/custom-words.txt.`;
|
|
|
|
console.log(line);
|
|
console.log(
|
|
`::error file=${escapeProperty(file)},line=${lineNumber},col=${column},endColumn=${Number(column) + word.length},title=cspell::${escapeData(message)}`,
|
|
);
|
|
problems++;
|
|
}
|
|
|
|
if (cspell.status !== 0 && problems === 0) {
|
|
process.stderr.write(cspell.stderr);
|
|
console.log(`::error title=cspell::${escapeData(cspell.stderr.trim() || 'cspell failed.')}`);
|
|
process.exit(cspell.status ?? 1);
|
|
}
|
|
|
|
if (problems > 0) {
|
|
console.log(`\n${problems} spelling issue(s) found.`);
|
|
process.exit(1);
|
|
}
|
|
|
|
console.log('No spelling issues found.');
|