Files
lucide/scripts/migrateCategoriesToIcons.mjs
Karsa 8c4a41035b Deprecate tags.json (#896)
* 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>
2023-02-16 08:26:29 +01:00

20 lines
733 B
JavaScript

import path from 'path';
import categories from '../categories.json' assert { type: 'json' };
import { mergeArrays, writeFile, readAllMetadata, getCurrentDirPath } from './helpers.mjs';
const currentDir = getCurrentDirPath(import.meta.url)
const ICONS_DIR = path.resolve(currentDir, '../icons');
const icons = readAllMetadata(ICONS_DIR);
Object.keys(categories).forEach(categoryName => {
categories[categoryName].forEach(iconName => {
icons[iconName].categories = mergeArrays(icons[iconName].categories, [categoryName]);
});
});
Object.keys(icons).forEach(iconName => {
const iconContent = JSON.stringify(icons[iconName], null, 2);
writeFile(iconContent, `${iconName}.json`, path.resolve(currentDir, '../icons'));
})