mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-11-12 13:38:32 +00:00
Remove script
This commit is contained in:
@@ -8,7 +8,6 @@ const filenamesToAjvOption = (filenames) => filenames.map((filename) => `-d ${fi
|
||||
const config = {
|
||||
'icons/*.svg': [
|
||||
'node ./scripts/optimizeStagedSvgs.mts',
|
||||
'node ./scripts/generateNextJSAliases.mts',
|
||||
],
|
||||
'icons/*.json': (filenames) => [
|
||||
`ajv --spec=draft2020 -s icon.schema.json ${filenamesToAjvOption(filenames)}`,
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
"generate:changelog": "node ./scripts/generateChangelog.mts",
|
||||
"generate:sponsors": "node scripts/updateSponsors.mts",
|
||||
"generate:contributors": "node ./scripts/updateContributors.mts icons/*.svg",
|
||||
"generate:nextJSAliases": "node ./scripts/generateNextJSAliases.mts",
|
||||
"suggest:metadata": "node ./scripts/suggestMetaData.mts",
|
||||
"suggest:metadata:watch": "node --env-file .env --watch ./scripts/suggestMetaData.mts",
|
||||
"postinstall": "husky install",
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
import path from 'path';
|
||||
import { promises as fs } from 'fs';
|
||||
import { getCurrentDirPath, readSvgDirectory } from '../tools/build-helpers/helpers.ts';
|
||||
|
||||
// This is a special case convertion NextJS uses for their modularize imports. We try to follow the same convention, to generate the same imports.
|
||||
function pascalToKebabNextJSFlavour(str: string) {
|
||||
return str
|
||||
.replace(/([a-z])([A-Z])/g, '$1-$2')
|
||||
.replace(/([A-Z]+)([A-Z][a-z])/g, '$1-$2')
|
||||
.replace(/([a-z])-?([0-9]+|[A-Z])/g, '$1-$2')
|
||||
.replace(/([0-9]+)-?([a-zA-Z])/g, '$1-$2')
|
||||
.replace(/([0-9])-([0-9])/g, '$1$2')
|
||||
.split('-')
|
||||
.map((word) => word.toLowerCase())
|
||||
.join('-');
|
||||
}
|
||||
|
||||
const currentDir = getCurrentDirPath(import.meta.url);
|
||||
const ICONS_DIR = path.resolve(currentDir, '../icons');
|
||||
|
||||
const svgFiles = await readSvgDirectory(ICONS_DIR);
|
||||
|
||||
const iconNames = svgFiles.map((icon) => icon.split('.')[0]).reverse();
|
||||
|
||||
console.log('Creating aliases for NextJS imports: ');
|
||||
|
||||
Promise.all(
|
||||
iconNames.map(async (iconName) => {
|
||||
const pascalCaseName = iconName.replace(/-([a-z])/g, (g) => g[1].toUpperCase());
|
||||
|
||||
const iconNameKebabCaseNextjsFlavour = pascalToKebabNextJSFlavour(pascalCaseName);
|
||||
|
||||
if (iconName !== iconNameKebabCaseNextjsFlavour) {
|
||||
console.log(iconName, '➡️', iconNameKebabCaseNextjsFlavour);
|
||||
|
||||
const metaJson = await fs.readFile(path.resolve(ICONS_DIR, `${iconName}.json`), 'utf-8');
|
||||
const iconMetaData = JSON.parse(metaJson);
|
||||
|
||||
const aliases = iconMetaData.aliases ?? [];
|
||||
if (!aliases.includes(iconNameKebabCaseNextjsFlavour)) {
|
||||
aliases.push(iconNameKebabCaseNextjsFlavour);
|
||||
}
|
||||
|
||||
let output = JSON.stringify({ ...iconMetaData, aliases }, null, 2);
|
||||
output = `${output}\n`;
|
||||
fs.writeFile(path.resolve(ICONS_DIR, `${iconName}.json`), output, 'utf-8');
|
||||
}
|
||||
}),
|
||||
);
|
||||
Reference in New Issue
Block a user