mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-11-13 13:48:26 +00:00
* Deprecates tags.json and icons.json * Removed tags.json dependency from Figma plugin * Add JSON descriptor information to readme * Restore packages/index.tsx * Update packages/lucide-figma/src/api/fetchIcons.ts Add multiple fetches to `Promise.all` * Added caching to API endpoints * Updates pnpm-lock.yaml * Add tags to static * Trigger site build * Added prebuild script to generate api caches at build time * Migrated NextCache function from arrow to regular to simplify markup * test if contents are read from cache * Add cache clear to prebuild * removes debug object --------- Co-authored-by: Karsa <karsa@karsa.org> Co-authored-by: Eric Fennis <eric.fennis@gmail.com>
52 lines
1.6 KiB
JavaScript
52 lines
1.6 KiB
JavaScript
import path from 'path';
|
|
import { readSvgDirectory, getCurrentDirPath, readAllMetadata } from './helpers.mjs';
|
|
|
|
const currentDir = getCurrentDirPath(import.meta.url)
|
|
const ICONS_DIR = path.resolve(currentDir, '../icons');
|
|
const icons = readAllMetadata(ICONS_DIR);
|
|
const CATEGORIES_DIR = path.resolve(currentDir, '../categories');
|
|
const categories = readAllMetadata(CATEGORIES_DIR);
|
|
|
|
console.log(`Read all icons`);
|
|
|
|
const svgFiles = readSvgDirectory(ICONS_DIR);
|
|
const iconNames = svgFiles.map(icon => icon.split('.')[0]);
|
|
|
|
let error = false;
|
|
|
|
iconNames.forEach(iconName => {
|
|
if (typeof icons[iconName] === 'undefined') {
|
|
console.error(`'${iconName}.svg' does not have a matching JSON file.`);
|
|
error = true;
|
|
}
|
|
});
|
|
|
|
Object.keys(icons).forEach(iconName => {
|
|
const icon = icons[iconName];
|
|
if (iconNames.indexOf(iconName) === -1) {
|
|
console.error(`'${iconName}.svg' does not exist.`);
|
|
error = true;
|
|
}
|
|
icon.categories.forEach(categoryName => {
|
|
if (typeof categories[categoryName] === 'undefined') {
|
|
console.error(`Icon '${iconName}' refers to the non-existing category '${categoryName}'.`);
|
|
error = true;
|
|
}
|
|
});
|
|
});
|
|
|
|
Object.keys(categories).forEach(categoryName => {
|
|
const category = categories[categoryName];
|
|
if (!category.icon) {
|
|
console.error(`Category '${categoryName}' does not use an icon '${category.icon}'.`);
|
|
error = true;
|
|
} else if (typeof icons[category.icon] === 'undefined') {
|
|
console.error(`Category '${categoryName}' uses the non-existing icon '${category.icon}'.`);
|
|
error = true;
|
|
}
|
|
});
|
|
|
|
if (error) {
|
|
throw new Error('At least one error in icon JSONs prevents from committing changes.');
|
|
}
|