mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-11-15 14:08:49 +00:00
Merge branch 'main' of https://github.com/lucide-icons/lucide into sponsor-page
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { readSvgDirectory, toCamelCase } from '@lucide/helpers';
|
||||
import { getIconMetaData } from '@lucide/build-icons';
|
||||
import { toCamelCase } from '@lucide/helpers';
|
||||
|
||||
const currentDir = process.cwd();
|
||||
const ICONS_DIR = path.resolve(currentDir, '../icons');
|
||||
const icons = await readSvgDirectory(ICONS_DIR, '.json');
|
||||
const iconMetaData = await getIconMetaData(ICONS_DIR);
|
||||
|
||||
const iconDetailsDirectory = path.resolve(currentDir, '.vitepress/data', 'iconDetails');
|
||||
|
||||
@@ -18,18 +19,27 @@ if (!fs.existsSync(iconDetailsDirectory)) {
|
||||
|
||||
const indexFile = path.resolve(iconDetailsDirectory, `index.ts`);
|
||||
|
||||
const writeIconFiles = icons.map(async (iconFileName) => {
|
||||
const iconName = path.basename(iconFileName, '.json');
|
||||
const writeIconFiles = Object.entries(iconMetaData).map(async ([iconName, metaData]) => {
|
||||
const location = path.resolve(iconDetailsDirectory, `${iconName}.ts`);
|
||||
const {
|
||||
tags,
|
||||
categories,
|
||||
contributors,
|
||||
aliases,
|
||||
deprecated,
|
||||
deprecationReason,
|
||||
toBeRemovedInVersion,
|
||||
} = metaData;
|
||||
|
||||
const contents = `\
|
||||
import iconNode from '../iconNodes/${iconName}.node.json' with { type: 'json' };
|
||||
import metaData from '../../../../icons/${iconName}.json' with { type: 'json' };
|
||||
import releaseData from '../releaseMetadata/${iconName}.json' with { type: 'json' };
|
||||
import popularity from '../iconPopularity/${iconName}.json' with { type: 'json' };
|
||||
import { IconMetaData, IconNode } from '~/.vitepress/theme/types';
|
||||
|
||||
const { tags, categories, contributors, aliases, deprecated, deprecationReason, toBeRemovedInVersion }: IconMetaData = metaData;
|
||||
const metaData: IconMetaData = ${JSON.stringify({ tags, categories, contributors, aliases, deprecated, deprecationReason, toBeRemovedInVersion })};
|
||||
|
||||
const { tags, categories, contributors, aliases, deprecated, deprecationReason, toBeRemovedInVersion } = metaData;
|
||||
|
||||
const iconDetails = {
|
||||
name: '${iconName}',
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { readSvgDirectory, toCamelCase } from '@lucide/helpers';
|
||||
import { readAllMetadata } from '@lucide/helpers';
|
||||
|
||||
const currentDir = process.cwd();
|
||||
const ICONS_DIR = path.resolve(currentDir, '../icons');
|
||||
const iconJsonFiles = await readSvgDirectory(ICONS_DIR, '.json');
|
||||
|
||||
const location = path.resolve(currentDir, '.vitepress/data', 'iconMetaData.ts');
|
||||
|
||||
@@ -12,29 +11,15 @@ if (fs.existsSync(location)) {
|
||||
fs.unlinkSync(location);
|
||||
}
|
||||
|
||||
const iconMetaIndexFileImports = [];
|
||||
const iconMetaIndexFileExports = [];
|
||||
|
||||
iconJsonFiles.forEach((iconJsonFile) => {
|
||||
const iconName = path.basename(iconJsonFile, '.json');
|
||||
|
||||
iconMetaIndexFileImports.push(
|
||||
`import ${toCamelCase(iconName)}Metadata from '../../../icons/${iconName}.json' with { type: 'json' };`,
|
||||
);
|
||||
iconMetaIndexFileExports.push(` '${iconName}': ${toCamelCase(iconName)}Metadata,`);
|
||||
});
|
||||
// The docs read this index raw and never re-resolve, so resolve the
|
||||
// `$extends:<icon-name>` markers here and bake the inherited
|
||||
// tags/categories/contributors into the generated file.
|
||||
const iconMetaData = await readAllMetadata(ICONS_DIR);
|
||||
|
||||
try {
|
||||
await fs.promises.writeFile(
|
||||
location,
|
||||
`\
|
||||
${iconMetaIndexFileImports.join('\n')}
|
||||
|
||||
|
||||
export default {
|
||||
${iconMetaIndexFileExports.join('\n')}
|
||||
}
|
||||
`,
|
||||
`export default ${JSON.stringify(iconMetaData, null, 2)};\n`,
|
||||
'utf-8',
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user