mirror of
https://github.com/lucide-icons/lucide.git
synced 2025-12-16 17:27:43 +01:00
feat(icons): add deprecationReason and alias deprecation feature (#1960)
* feat(icons): add deprecationReason and alias deprecation feature * chore(tools): run prettier. again. * fix(scripts): overall alias as object support * fix(icon.schema.json): add dependentRequired on deprecated properties * fix(icon.schema.json): remove unicode for now * fix(icon.schema.json): use const true for deprecated * fix(build): convert deprecation reason to enum * fix(build): fix linting of icon.schema.json * fix(build): renamed gracePeriod => toBeRemovedInVersion * fix(build): fix aliases map in related icons generation * fix(build): deprecate aliases using numbers * feat(icon-schema): separate deprecation reason enumerations, extract removal notice * fix(icon-schema): fix linting * Update tools/build-icons/utils/deprecationReasonTemplate.mjs * fix(icons): add deprecation reason to some more icons * fix(docs): fix linting issue --------- Co-authored-by: Karsa <karsa@sztaki.hu> Co-authored-by: Jakob Guddas <github@jguddas.de>
This commit is contained in:
@@ -23,7 +23,7 @@ function getAllCategoryFiles() {
|
||||
|
||||
const categoriesFile = path.resolve(dataDirectory, `categoriesData.json`);
|
||||
|
||||
const categoriesData = getAllCategoryFiles()
|
||||
const categoriesData = getAllCategoryFiles();
|
||||
|
||||
fs.promises
|
||||
.writeFile(categoriesFile, JSON.stringify(categoriesData, null, 2), 'utf-8')
|
||||
@@ -33,4 +33,3 @@ fs.promises
|
||||
.catch((error) => {
|
||||
throw new Error(`Something went wrong generating the categoriesData.json file,\n ${error}`);
|
||||
});
|
||||
|
||||
|
||||
@@ -21,7 +21,32 @@
|
||||
"aliases": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"deprecated": {
|
||||
"const": true
|
||||
},
|
||||
"deprecationReason": {
|
||||
"$ref": "#/$defs/aliasDeprecationReasons"
|
||||
},
|
||||
"toBeRemovedInVersion": {
|
||||
"$ref": "#/$defs/versionNumber",
|
||||
"description": "The version this icon will be removed in."
|
||||
}
|
||||
},
|
||||
"dependentRequired": {
|
||||
"deprecated": ["deprecationReason", "toBeRemovedInVersion"]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"uniqueItems": true
|
||||
},
|
||||
@@ -49,8 +74,31 @@
|
||||
"uniqueItems": true
|
||||
},
|
||||
"deprecated": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
"const": true
|
||||
},
|
||||
"deprecationReason": {
|
||||
"$ref": "#/$defs/iconDeprecationReasons"
|
||||
},
|
||||
"toBeRemovedInVersion": {
|
||||
"$ref": "#/$defs/versionNumber",
|
||||
"description": "The version this icon will be removed in."
|
||||
}
|
||||
},
|
||||
"dependentRequired": {
|
||||
"deprecated": ["deprecationReason", "toBeRemovedInVersion"]
|
||||
},
|
||||
"$defs": {
|
||||
"iconDeprecationReasons": {
|
||||
"type": "string",
|
||||
"enum": ["icon.brand"]
|
||||
},
|
||||
"aliasDeprecationReasons": {
|
||||
"type": "string",
|
||||
"enum": ["alias.typo", "alias.name"]
|
||||
},
|
||||
"versionNumber": {
|
||||
"type": "string",
|
||||
"pattern": "v[0-9]+(\\.[0-9]+)+"
|
||||
}
|
||||
},
|
||||
"description": "A JSON Schema for icons defined by Lucide Icons."
|
||||
|
||||
@@ -33,6 +33,11 @@
|
||||
"account"
|
||||
],
|
||||
"aliases": [
|
||||
"between-horizonal-end"
|
||||
{
|
||||
"name": "between-horizonal-end",
|
||||
"deprecated": true,
|
||||
"deprecationReason": "alias.typo",
|
||||
"toBeRemovedInVersion": "v1.0"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -33,6 +33,11 @@
|
||||
"account"
|
||||
],
|
||||
"aliases": [
|
||||
"between-horizonal-start"
|
||||
{
|
||||
"name": "between-horizonal-start",
|
||||
"deprecated": true,
|
||||
"deprecationReason": "alias.typo",
|
||||
"toBeRemovedInVersion": "v1.0"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
{
|
||||
"$schema": "../icon.schema.json",
|
||||
"deprecated": true,
|
||||
"deprecationReason": "icon.brand",
|
||||
"toBeRemovedInVersion": "v1.0",
|
||||
"contributors": [
|
||||
"colebemis",
|
||||
"ericfennis"
|
||||
|
||||
@@ -13,6 +13,11 @@
|
||||
"shapes"
|
||||
],
|
||||
"aliases": [
|
||||
"user-circle-2"
|
||||
{
|
||||
"name": "user-circle-2",
|
||||
"deprecated": true,
|
||||
"deprecationReason": "alias.name",
|
||||
"toBeRemovedInVersion": "v1.0"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -15,6 +15,11 @@
|
||||
"development"
|
||||
],
|
||||
"aliases": [
|
||||
"code-2"
|
||||
{
|
||||
"name": "code-2",
|
||||
"deprecated": true,
|
||||
"deprecationReason": "alias.name",
|
||||
"toBeRemovedInVersion": "v1.0"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
{
|
||||
"$schema": "../icon.schema.json",
|
||||
"deprecated": true,
|
||||
"deprecationReason": "icon.brand",
|
||||
"toBeRemovedInVersion": "v1.0",
|
||||
"contributors": [
|
||||
"colebemis",
|
||||
"ericfennis"
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
{
|
||||
"$schema": "../icon.schema.json",
|
||||
"deprecated": true,
|
||||
"deprecationReason": "icon.brand",
|
||||
"toBeRemovedInVersion": "v1.0",
|
||||
"contributors": [
|
||||
"colebemis",
|
||||
"csandman",
|
||||
|
||||
@@ -19,6 +19,11 @@
|
||||
"social"
|
||||
],
|
||||
"aliases": [
|
||||
"contact-2"
|
||||
{
|
||||
"name": "contact-2",
|
||||
"deprecated": true,
|
||||
"deprecationReason": "alias.name",
|
||||
"toBeRemovedInVersion": "v1.0"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
{
|
||||
"$schema": "../icon.schema.json",
|
||||
"deprecated": true,
|
||||
"deprecationReason": "icon.brand",
|
||||
"toBeRemovedInVersion": "v1.0",
|
||||
"contributors": [
|
||||
"ahtohbi4"
|
||||
],
|
||||
|
||||
@@ -17,6 +17,11 @@
|
||||
"navigation"
|
||||
],
|
||||
"aliases": [
|
||||
"globe-2"
|
||||
{
|
||||
"name": "globe-2",
|
||||
"deprecated": true,
|
||||
"deprecationReason": "alias.name",
|
||||
"toBeRemovedInVersion": "v1.0"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
{
|
||||
"$schema": "../icon.schema.json",
|
||||
"deprecated": true,
|
||||
"deprecationReason": "icon.brand",
|
||||
"toBeRemovedInVersion": "v1.0",
|
||||
"contributors": [
|
||||
"colebemis",
|
||||
"csandman",
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
{
|
||||
"$schema": "../icon.schema.json",
|
||||
"deprecated": true,
|
||||
"deprecationReason": "icon.brand",
|
||||
"toBeRemovedInVersion": "v1.0",
|
||||
"contributors": [
|
||||
"colebemis",
|
||||
"csandman",
|
||||
|
||||
@@ -15,6 +15,11 @@
|
||||
"files"
|
||||
],
|
||||
"aliases": [
|
||||
"file-cog-2"
|
||||
{
|
||||
"name": "file-cog-2",
|
||||
"deprecated": true,
|
||||
"deprecationReason": "alias.name",
|
||||
"toBeRemovedInVersion": "v1.0"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
{
|
||||
"$schema": "../icon.schema.json",
|
||||
"aliases": [
|
||||
"folder-cog-2"
|
||||
],
|
||||
"contributors": [
|
||||
"karsa-mistmere"
|
||||
],
|
||||
@@ -17,5 +14,13 @@
|
||||
],
|
||||
"categories": [
|
||||
"files"
|
||||
],
|
||||
"aliases": [
|
||||
{
|
||||
"name": "folder-cog-2",
|
||||
"deprecated": true,
|
||||
"deprecationReason": "alias.name",
|
||||
"toBeRemovedInVersion": "v1.0"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
{
|
||||
"$schema": "../icon.schema.json",
|
||||
"deprecated": true,
|
||||
"deprecationReason": "icon.brand",
|
||||
"toBeRemovedInVersion": "v1.0",
|
||||
"contributors": [
|
||||
"colebemis",
|
||||
"csandman",
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
{
|
||||
"$schema": "../icon.schema.json",
|
||||
"deprecated": true,
|
||||
"deprecationReason": "icon.brand",
|
||||
"toBeRemovedInVersion": "v1.0",
|
||||
"contributors": [
|
||||
"colebemis",
|
||||
"csandman",
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
{
|
||||
"$schema": "../icon.schema.json",
|
||||
"deprecated": true,
|
||||
"deprecationReason": "icon.brand",
|
||||
"toBeRemovedInVersion": "v1.0",
|
||||
"contributors": [
|
||||
"colebemis",
|
||||
"csandman",
|
||||
|
||||
@@ -19,6 +19,11 @@
|
||||
"food-beverage"
|
||||
],
|
||||
"aliases": [
|
||||
"ice-cream-2"
|
||||
{
|
||||
"name": "ice-cream-2",
|
||||
"deprecated": true,
|
||||
"deprecationReason": "alias.name",
|
||||
"toBeRemovedInVersion": "v1.0"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
{
|
||||
"$schema": "../icon.schema.json",
|
||||
"deprecated": true,
|
||||
"deprecationReason": "icon.brand",
|
||||
"toBeRemovedInVersion": "v1.0",
|
||||
"contributors": [
|
||||
"colebemis",
|
||||
"csandman",
|
||||
|
||||
@@ -12,6 +12,11 @@
|
||||
"devices"
|
||||
],
|
||||
"aliases": [
|
||||
"laptop-2"
|
||||
{
|
||||
"name": "laptop-2",
|
||||
"deprecated": true,
|
||||
"deprecationReason": "alias.name",
|
||||
"toBeRemovedInVersion": "v1.0"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -22,6 +22,11 @@
|
||||
"multimedia"
|
||||
],
|
||||
"aliases": [
|
||||
"mic-2"
|
||||
{
|
||||
"name": "mic-2",
|
||||
"deprecated": true,
|
||||
"deprecationReason": "alias.name",
|
||||
"toBeRemovedInVersion": "v1.0"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -26,6 +26,11 @@
|
||||
"tools"
|
||||
],
|
||||
"aliases": [
|
||||
"edit-3"
|
||||
{
|
||||
"name": "edit-3",
|
||||
"deprecated": true,
|
||||
"deprecationReason": "alias.name",
|
||||
"toBeRemovedInVersion": "v1.0"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -26,6 +26,11 @@
|
||||
"tools"
|
||||
],
|
||||
"aliases": [
|
||||
"edit-2"
|
||||
{
|
||||
"name": "edit-2",
|
||||
"deprecated": true,
|
||||
"deprecationReason": "alias.name",
|
||||
"toBeRemovedInVersion": "v1.0"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
{
|
||||
"$schema": "../icon.schema.json",
|
||||
"deprecated": true,
|
||||
"deprecationReason": "icon.brand",
|
||||
"toBeRemovedInVersion": "v1.0",
|
||||
"contributors": [
|
||||
"colebemis",
|
||||
"csandman",
|
||||
|
||||
@@ -17,6 +17,11 @@
|
||||
"connectivity"
|
||||
],
|
||||
"aliases": [
|
||||
"send-horizonal"
|
||||
{
|
||||
"name": "send-horizonal",
|
||||
"deprecated": true,
|
||||
"deprecationReason": "alias.typo",
|
||||
"toBeRemovedInVersion": "v1.0"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
{
|
||||
"$schema": "../icon.schema.json",
|
||||
"deprecated": true,
|
||||
"deprecationReason": "icon.brand",
|
||||
"toBeRemovedInVersion": "v1.0",
|
||||
"contributors": [
|
||||
"colebemis",
|
||||
"ashygee",
|
||||
|
||||
@@ -13,6 +13,11 @@
|
||||
"shapes"
|
||||
],
|
||||
"aliases": [
|
||||
"user-square-2"
|
||||
{
|
||||
"name": "user-square-2",
|
||||
"deprecated": true,
|
||||
"deprecationReason": "alias.name",
|
||||
"toBeRemovedInVersion": "v1.0"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
{
|
||||
"$schema": "../icon.schema.json",
|
||||
"deprecated": true,
|
||||
"deprecationReason": "icon.brand",
|
||||
"toBeRemovedInVersion": "v1.0",
|
||||
"contributors": [
|
||||
"bdbch",
|
||||
"csandman",
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
{
|
||||
"$schema": "../icon.schema.json",
|
||||
"deprecated": true,
|
||||
"deprecationReason": "icon.brand",
|
||||
"toBeRemovedInVersion": "v1.0",
|
||||
"contributors": [
|
||||
"ahtohbi4",
|
||||
"johnletey"
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
{
|
||||
"$schema": "../icon.schema.json",
|
||||
"deprecated": true,
|
||||
"deprecationReason": "icon.brand",
|
||||
"toBeRemovedInVersion": "v1.0",
|
||||
"contributors": [
|
||||
"colebemis",
|
||||
"csandman",
|
||||
|
||||
@@ -14,6 +14,11 @@
|
||||
"maps"
|
||||
],
|
||||
"aliases": [
|
||||
"school-2"
|
||||
{
|
||||
"name": "school-2",
|
||||
"deprecated": true,
|
||||
"deprecationReason": "alias.name",
|
||||
"toBeRemovedInVersion": "v1.0"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -16,6 +16,11 @@
|
||||
"account"
|
||||
],
|
||||
"aliases": [
|
||||
"user-check-2"
|
||||
{
|
||||
"name": "user-check-2",
|
||||
"deprecated": true,
|
||||
"deprecationReason": "alias.name",
|
||||
"toBeRemovedInVersion": "v1.0"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -13,6 +13,11 @@
|
||||
"account"
|
||||
],
|
||||
"aliases": [
|
||||
"user-cog-2"
|
||||
{
|
||||
"name": "user-cog-2",
|
||||
"deprecated": true,
|
||||
"deprecationReason": "alias.name",
|
||||
"toBeRemovedInVersion": "v1.0"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -13,6 +13,11 @@
|
||||
"account"
|
||||
],
|
||||
"aliases": [
|
||||
"user-minus-2"
|
||||
{
|
||||
"name": "user-minus-2",
|
||||
"deprecated": true,
|
||||
"deprecationReason": "alias.name",
|
||||
"toBeRemovedInVersion": "v1.0"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -14,6 +14,11 @@
|
||||
"account"
|
||||
],
|
||||
"aliases": [
|
||||
"user-plus-2"
|
||||
{
|
||||
"name": "user-plus-2",
|
||||
"deprecated": true,
|
||||
"deprecationReason": "alias.name",
|
||||
"toBeRemovedInVersion": "v1.0"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -14,6 +14,11 @@
|
||||
"account"
|
||||
],
|
||||
"aliases": [
|
||||
"user-x-2"
|
||||
{
|
||||
"name": "user-x-2",
|
||||
"deprecated": true,
|
||||
"deprecationReason": "alias.name",
|
||||
"toBeRemovedInVersion": "v1.0"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -12,6 +12,11 @@
|
||||
"account"
|
||||
],
|
||||
"aliases": [
|
||||
"user-2"
|
||||
{
|
||||
"name": "user-2",
|
||||
"deprecated": true,
|
||||
"deprecationReason": "alias.name",
|
||||
"toBeRemovedInVersion": "v1.0"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -11,6 +11,11 @@
|
||||
"account"
|
||||
],
|
||||
"aliases": [
|
||||
"users-2"
|
||||
{
|
||||
"name": "users-2",
|
||||
"deprecated": true,
|
||||
"deprecationReason": "alias.name",
|
||||
"toBeRemovedInVersion": "v1.0"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -12,6 +12,11 @@
|
||||
"money"
|
||||
],
|
||||
"aliases": [
|
||||
"wallet-2"
|
||||
{
|
||||
"name": "wallet-2",
|
||||
"deprecated": true,
|
||||
"deprecationReason": "alias.name",
|
||||
"toBeRemovedInVersion": "v1.0"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -15,6 +15,11 @@
|
||||
"photography"
|
||||
],
|
||||
"aliases": [
|
||||
"wand-2"
|
||||
{
|
||||
"name": "wand-2",
|
||||
"deprecated": true,
|
||||
"deprecationReason": "alias.name",
|
||||
"toBeRemovedInVersion": "v1.0"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
{
|
||||
"$schema": "../icon.schema.json",
|
||||
"deprecated": true,
|
||||
"deprecationReason": "icon.brand",
|
||||
"toBeRemovedInVersion": "v1.0",
|
||||
"contributors": [
|
||||
"colebemis",
|
||||
"csandman",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* eslint-disable import/no-extraneous-dependencies */
|
||||
import base64SVG from '@lucide/build-icons/utils/base64SVG.mjs';
|
||||
|
||||
export default ({ componentName, iconName, children, getSvg, deprecated }) => {
|
||||
export default ({ componentName, iconName, children, getSvg, deprecated, deprecationReason }) => {
|
||||
const svgContents = getSvg();
|
||||
const svgBase64 = base64SVG(svgContents);
|
||||
|
||||
@@ -17,7 +17,7 @@ import { LucideIconData } from './types';
|
||||
*
|
||||
* @param {Object} props - Lucide icons props and any valid SVG attribute
|
||||
* @returns {FunctionalComponent} Vue component
|
||||
* ${deprecated ? '@deprecated' : ''}
|
||||
* ${deprecated ? `@deprecated ${deprecationReason}` : ''}
|
||||
*/
|
||||
const ${componentName}: LucideIconData = ${JSON.stringify(children)}; //eslint-disable-line no-shadow-restricted-names
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* eslint-disable import/no-extraneous-dependencies */
|
||||
import base64SVG from '@lucide/build-icons/utils/base64SVG.mjs';
|
||||
|
||||
export default ({ componentName, iconName, children, getSvg, deprecated }) => {
|
||||
export default ({ componentName, iconName, children, getSvg, deprecated, deprecationReason }) => {
|
||||
const svgContents = getSvg();
|
||||
const svgBase64 = base64SVG(svgContents);
|
||||
|
||||
@@ -17,7 +17,7 @@ import createLucideIcon from '../createLucideIcon';
|
||||
*
|
||||
* @param {Object} props - Lucide icons props and any valid SVG attribute
|
||||
* @returns {JSX.Element} JSX Element
|
||||
* ${deprecated ? '@deprecated' : ''}
|
||||
* ${deprecated ? `@deprecated ${deprecationReason}` : ''}
|
||||
*/
|
||||
const ${componentName} = createLucideIcon('${componentName}', ${JSON.stringify(children)});
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* eslint-disable import/no-extraneous-dependencies */
|
||||
import base64SVG from '@lucide/build-icons/utils/base64SVG.mjs';
|
||||
|
||||
export default ({ componentName, iconName, children, getSvg, deprecated }) => {
|
||||
export default ({ componentName, iconName, children, getSvg, deprecated, deprecationReason }) => {
|
||||
const svgContents = getSvg();
|
||||
const svgBase64 = base64SVG(svgContents);
|
||||
|
||||
@@ -17,7 +17,7 @@ import createLucideIcon from '../createLucideIcon';
|
||||
*
|
||||
* @param {Object} props - Lucide icons props and any valid SVG attribute
|
||||
* @returns {JSX.Element} JSX Element
|
||||
* ${deprecated ? '@deprecated' : ''}
|
||||
* ${deprecated ? `@deprecated ${deprecationReason}` : ''}
|
||||
*/
|
||||
const ${componentName} = createLucideIcon('${componentName}', ${JSON.stringify(children)});
|
||||
|
||||
|
||||
@@ -40,7 +40,6 @@
|
||||
"copy:license": "cp ../../LICENSE ./LICENSE",
|
||||
"clean": "rm -rf dist && rm -rf stats && rm -rf ./src/icons/*.ts && rm -f dynamicIconImports.*",
|
||||
"build:icons": "build-icons --output=./src --templateSrc=./scripts/exportTemplate.mjs --renderUniqueKey --withAliases --withDynamicImports --separateAliasesFile --aliasesFileExtension=.ts --iconFileExtension=.ts --exportFileName=index.ts",
|
||||
"build:types": "node ./scripts/buildTypes.mjs",
|
||||
"build:bundles": "rollup -c ./rollup.config.mjs",
|
||||
"typecheck": "tsc",
|
||||
"typecheck:watch": "tsc -w",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* eslint-disable import/no-extraneous-dependencies */
|
||||
import base64SVG from '@lucide/build-icons/utils/base64SVG.mjs';
|
||||
|
||||
export default ({ componentName, iconName, children, getSvg, deprecated }) => {
|
||||
export default ({ componentName, iconName, children, getSvg, deprecated, deprecationReason }) => {
|
||||
const svgContents = getSvg();
|
||||
const svgBase64 = base64SVG(svgContents);
|
||||
|
||||
@@ -17,7 +17,7 @@ import createLucideIcon from '../createLucideIcon';
|
||||
*
|
||||
* @param {Object} props - Lucide icons props and any valid SVG attribute
|
||||
* @returns {JSX.Element} JSX Element
|
||||
* ${deprecated ? '@deprecated' : ''}
|
||||
* ${deprecated ? `@deprecated ${deprecationReason}` : ''}
|
||||
*/
|
||||
const ${componentName} = createLucideIcon('${componentName}', ${JSON.stringify(children)});
|
||||
|
||||
|
||||
@@ -11,5 +11,7 @@ export default async function getAliasesEntryNames() {
|
||||
|
||||
const aliases = iconWithAliases.flatMap(({ aliases }) => aliases);
|
||||
|
||||
return aliases.map((alias) => path.join('src/icons', `${alias}.ts`));
|
||||
return aliases
|
||||
.map((alias) => (typeof alias === 'string' ? alias : alias.name))
|
||||
.map((alias) => path.join('src/icons', `${alias}.ts`));
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* eslint-disable import/no-extraneous-dependencies */
|
||||
import base64SVG from '@lucide/build-icons/utils/base64SVG.mjs';
|
||||
|
||||
export default ({ componentName, iconName, children, getSvg, deprecated }) => {
|
||||
export default ({ componentName, iconName, children, getSvg, deprecated, deprecationReason }) => {
|
||||
const svgContents = getSvg();
|
||||
const svgBase64 = base64SVG(svgContents);
|
||||
|
||||
@@ -20,7 +20,7 @@ const iconNode: IconNode = ${JSON.stringify(children)};
|
||||
*
|
||||
* @param {Object} props - Lucide icons props and any valid SVG attribute
|
||||
* @returns {JSX.Element} JSX Element
|
||||
* ${deprecated ? '@deprecated' : ''}
|
||||
* ${deprecated ? `@deprecated ${deprecationReason}` : ''}
|
||||
*/
|
||||
const ${componentName} = (props: LucideProps) => (
|
||||
<Icon {...props} name="${componentName}" iconNode={iconNode} />
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* eslint-disable import/no-extraneous-dependencies */
|
||||
import base64SVG from '@lucide/build-icons/utils/base64SVG.mjs';
|
||||
|
||||
export default ({ componentName, iconName, children, getSvg, deprecated }) => {
|
||||
export default ({ componentName, iconName, children, getSvg, deprecated, deprecationReason }) => {
|
||||
let svgContents = getSvg();
|
||||
const svgBase64 = base64SVG(svgContents);
|
||||
|
||||
@@ -21,7 +21,7 @@ export default ({ componentName, iconName, children, getSvg, deprecated }) => {
|
||||
* @see https://lucide.dev/guide/packages/lucide-static - Documentation
|
||||
*
|
||||
* @returns {String}
|
||||
* ${deprecated ? '@deprecated' : ''}
|
||||
* ${deprecated ? `@deprecated ${deprecationReason}` : ''}
|
||||
*/
|
||||
const ${componentName}: string = \`\
|
||||
${svgContents}\
|
||||
|
||||
@@ -1,96 +0,0 @@
|
||||
import path from 'path';
|
||||
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||
import { getAliases } from '@lucide/build-icons';
|
||||
import {
|
||||
writeFile,
|
||||
readSvgDirectory,
|
||||
resetFile,
|
||||
toPascalCase,
|
||||
getCurrentDirPath,
|
||||
} from '../../../scripts/helpers.mjs';
|
||||
|
||||
const currentDir = getCurrentDirPath(import.meta.url);
|
||||
const targetDirectory = path.join(currentDir, '../dist');
|
||||
|
||||
const writeDeclarationFile = (typesFile, directory, content) => {
|
||||
resetFile(typesFile, directory);
|
||||
writeFile(content, typesFile, directory);
|
||||
};
|
||||
|
||||
const getComponentImport = (componentName) =>
|
||||
`export declare class ${componentName} extends SvelteComponent<IconProps, IconEvents, {}> {}\n`;
|
||||
|
||||
const ICONS_DIR = path.resolve(currentDir, '../../../icons');
|
||||
const TYPES_FILE = 'lucide-svelte.d.ts';
|
||||
|
||||
// Declare type definitions
|
||||
let declarationFileContent = `\
|
||||
/// <reference types="svelte" />
|
||||
/// <reference types="svelte-check/dist/src/svelte-jsx" />
|
||||
import { SvelteComponent } from "svelte";
|
||||
|
||||
interface IconProps extends Partial<svelte.JSX.SVGProps<SVGSVGElement>> {
|
||||
color?: string
|
||||
size?: number|string
|
||||
strokeWidth?: number|string
|
||||
absoluteStrokeWidth?: boolean
|
||||
class?: string
|
||||
}
|
||||
|
||||
interface IconEvents {
|
||||
[evt: string]: CustomEvent<any>;
|
||||
}
|
||||
|
||||
export type Icon = SvelteComponent<IconProps, IconEvents, {}>
|
||||
|
||||
// Generated icons
|
||||
`;
|
||||
|
||||
const svgFiles = readSvgDirectory(ICONS_DIR);
|
||||
|
||||
svgFiles.forEach((svgFile) => {
|
||||
const iconName = path.basename(svgFile, '.svg');
|
||||
const componentName = toPascalCase(iconName);
|
||||
|
||||
declarationFileContent += getComponentImport(componentName);
|
||||
});
|
||||
|
||||
const aliases = await getAliases(ICONS_DIR);
|
||||
|
||||
declarationFileContent += `\n
|
||||
|
||||
// Generated icon aliases
|
||||
`;
|
||||
|
||||
let aliasesCount = 0;
|
||||
|
||||
svgFiles.forEach((svgFile) => {
|
||||
const iconName = path.basename(svgFile, '.svg');
|
||||
const componentName = toPascalCase(iconName);
|
||||
const iconAliases = aliases[iconName]?.aliases;
|
||||
|
||||
declarationFileContent += `// ${componentName} aliases\n`;
|
||||
declarationFileContent += getComponentImport(`${componentName}Icon`);
|
||||
declarationFileContent += getComponentImport(`Lucide${componentName}`);
|
||||
|
||||
aliasesCount += 1;
|
||||
if (iconAliases != null && Array.isArray(iconAliases)) {
|
||||
iconAliases.forEach((alias) => {
|
||||
const componentNameAlias = toPascalCase(alias);
|
||||
declarationFileContent += getComponentImport(componentNameAlias);
|
||||
|
||||
aliasesCount += 1;
|
||||
});
|
||||
}
|
||||
|
||||
declarationFileContent += '\n';
|
||||
});
|
||||
|
||||
writeDeclarationFile(TYPES_FILE, targetDirectory, declarationFileContent);
|
||||
console.log(
|
||||
`Generated ${TYPES_FILE} file with`,
|
||||
svgFiles.length,
|
||||
'icons and with',
|
||||
aliasesCount,
|
||||
'aliases',
|
||||
);
|
||||
@@ -2,7 +2,7 @@
|
||||
import base64SVG from '@lucide/build-icons/utils/base64SVG.mjs';
|
||||
import { getJSBanner } from './license.mjs';
|
||||
|
||||
export default ({ iconName, children, componentName, getSvg, deprecated }) => {
|
||||
export default ({ iconName, children, componentName, getSvg, deprecated, deprecationReason }) => {
|
||||
const svgContents = getSvg();
|
||||
const svgBase64 = base64SVG(svgContents);
|
||||
|
||||
@@ -25,7 +25,7 @@ const iconNode: IconNode = ${JSON.stringify(children)};
|
||||
*
|
||||
* @param {Object} props - Lucide icons props and any valid SVG attribute
|
||||
* @returns {FunctionalComponent} Svelte component
|
||||
* ${deprecated ? '@deprecated' : ''}
|
||||
* ${deprecated ? `@deprecated ${deprecationReason}` : ''}
|
||||
*/
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* eslint-disable import/no-extraneous-dependencies */
|
||||
import base64SVG from '@lucide/build-icons/utils/base64SVG.mjs';
|
||||
|
||||
export default ({ componentName, iconName, children, getSvg, deprecated }) => {
|
||||
export default ({ componentName, iconName, children, getSvg, deprecated, deprecationReason }) => {
|
||||
const svgContents = getSvg();
|
||||
const svgBase64 = base64SVG(svgContents);
|
||||
|
||||
@@ -17,7 +17,7 @@ import createLucideIcon from '../createLucideIcon';
|
||||
*
|
||||
* @param {Object} props - Lucide icons props and any valid SVG attribute
|
||||
* @returns {FunctionalComponent} Vue component
|
||||
* ${deprecated ? '@deprecated' : ''}
|
||||
* ${deprecated ? `@deprecated ${deprecationReason}` : ''}
|
||||
*/
|
||||
const ${componentName} = createLucideIcon('${componentName}Icon', ${JSON.stringify(children)});
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* eslint-disable import/no-extraneous-dependencies */
|
||||
import base64SVG from '@lucide/build-icons/utils/base64SVG.mjs';
|
||||
|
||||
export default ({ componentName, iconName, children, getSvg, deprecated }) => {
|
||||
export default ({ componentName, iconName, children, getSvg, deprecated, deprecationReason }) => {
|
||||
const svgContents = getSvg();
|
||||
const svgBase64 = base64SVG(svgContents);
|
||||
|
||||
@@ -17,7 +17,7 @@ import createLucideIcon from '../createLucideIcon';
|
||||
*
|
||||
* @param {Object} props - Lucide icons props and any valid SVG attribute
|
||||
* @returns {Component} Vue Component
|
||||
* ${deprecated ? '@deprecated' : ''}
|
||||
* ${deprecated ? `@deprecated ${deprecationReason}` : ''}
|
||||
*/
|
||||
const ${componentName} = createLucideIcon('${componentName}Icon', ${JSON.stringify(children)});
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* eslint-disable import/no-extraneous-dependencies */
|
||||
import base64SVG from '@lucide/build-icons/utils/base64SVG.mjs';
|
||||
|
||||
export default ({ componentName, iconName, children, getSvg, deprecated }) => {
|
||||
export default ({ componentName, iconName, children, getSvg, deprecated, deprecationReason }) => {
|
||||
const svgContents = getSvg();
|
||||
const svgBase64 = base64SVG(svgContents);
|
||||
|
||||
@@ -17,7 +17,7 @@ import type { IconNode } from '../types';
|
||||
* @see https://lucide.dev/guide/packages/lucide - Documentation
|
||||
*
|
||||
* @returns {Array}
|
||||
* ${deprecated ? '@deprecated' : ''}
|
||||
* ${deprecated ? `@deprecated ${deprecationReason}` : ''}
|
||||
*/
|
||||
const ${componentName}: IconNode = [
|
||||
'svg',
|
||||
|
||||
@@ -22,6 +22,8 @@ const iconSvgTemplate = `<svg
|
||||
|
||||
const iconJsonTemplate = `{
|
||||
"$schema": "../icon.schema.json",
|
||||
"contributors": [
|
||||
],
|
||||
"tags": [
|
||||
],
|
||||
"categories": [
|
||||
|
||||
@@ -46,7 +46,9 @@ export async function renameIcon(ICONS_DIR, oldName, newName, logInfo = true, ad
|
||||
const json = fs.readFileSync(newJsonPath, 'utf8');
|
||||
const jsonData = JSON.parse(json);
|
||||
if (Array.isArray(jsonData.aliases)) {
|
||||
jsonData.aliases = jsonData.aliases.filter((name) => name !== newName);
|
||||
jsonData.aliases = jsonData.aliases.filter(
|
||||
(alias) => (typeof alias === 'string' ? alias : alias.name) !== newName,
|
||||
);
|
||||
jsonData.aliases.push(oldName);
|
||||
} else {
|
||||
jsonData.aliases = [oldName];
|
||||
|
||||
@@ -30,7 +30,10 @@ const arrayMatches = (a, b) => {
|
||||
};
|
||||
|
||||
const nameParts = (icon) =>
|
||||
[icon.name, ...(icon.aliases ?? [])]
|
||||
[
|
||||
icon.name,
|
||||
...(icon.aliases?.map((alias) => (typeof alias === 'string' ? alias : alias.name)) ?? []),
|
||||
]
|
||||
.join('-')
|
||||
.split('-')
|
||||
.filter((word) => word.length > 2);
|
||||
|
||||
@@ -145,7 +145,7 @@ try {
|
||||
const iconName = path.basename(iconJsonFile, '.json');
|
||||
const metaDir = path.resolve(releaseMetaDataDirectory, `${iconName}.json`);
|
||||
|
||||
if (iconName in newReleaseMetaData === false) {
|
||||
if (!(iconName in newReleaseMetaData)) {
|
||||
console.error(`Could not find release metadata for icon '${iconName}'.`);
|
||||
}
|
||||
|
||||
@@ -159,14 +159,16 @@ try {
|
||||
const aliases = iconMetaData.aliases ?? [];
|
||||
|
||||
if (aliases.length) {
|
||||
aliases.forEach((alias) => {
|
||||
if (alias in newReleaseMetaData === false) {
|
||||
return;
|
||||
}
|
||||
aliases
|
||||
.map((alias) => (typeof alias === 'string' ? alias : alias.name))
|
||||
.forEach((alias) => {
|
||||
if (!(alias in newReleaseMetaData)) {
|
||||
return;
|
||||
}
|
||||
|
||||
contents.createdRelease =
|
||||
newReleaseMetaData[alias].createdRelease ?? defaultReleaseMetaData.createdRelease;
|
||||
});
|
||||
contents.createdRelease =
|
||||
newReleaseMetaData[alias].createdRelease ?? defaultReleaseMetaData.createdRelease;
|
||||
});
|
||||
}
|
||||
|
||||
const output = JSON.stringify(contents, null, 2);
|
||||
|
||||
@@ -1,9 +1,21 @@
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import { toPascalCase, resetFile, appendFile } from '../../../scripts/helpers.mjs';
|
||||
import { deprecationReasonTemplate } from '../utils/deprecationReasonTemplate.mjs';
|
||||
|
||||
const getImportString = (componentName, iconName, aliasImportFileExtension = '') =>
|
||||
`export { default as ${componentName} } from './icons/${iconName}${aliasImportFileExtension}';\n`;
|
||||
const getImportString = (
|
||||
componentName,
|
||||
iconName,
|
||||
aliasImportFileExtension,
|
||||
deprecated,
|
||||
deprecationReason = '',
|
||||
) =>
|
||||
deprecated
|
||||
? `export {\n` +
|
||||
` /** @deprecated ${deprecationReason} */\n` +
|
||||
` default as ${componentName}\n` +
|
||||
`} from './icons/${iconName}${aliasImportFileExtension}';\n`
|
||||
: `export { default as ${componentName} } from './icons/${iconName}${aliasImportFileExtension}';\n`;
|
||||
|
||||
export default async function generateAliasesFile({
|
||||
iconNodes,
|
||||
@@ -27,7 +39,15 @@ export default async function generateAliasesFile({
|
||||
await Promise.all(
|
||||
icons.map(async (iconName, index) => {
|
||||
const componentName = toPascalCase(iconName);
|
||||
const iconAliases = iconMetaData[iconName]?.aliases;
|
||||
const iconAliases = iconMetaData[iconName]?.aliases?.map((alias) => {
|
||||
if (typeof alias === 'string') {
|
||||
return {
|
||||
name: alias,
|
||||
deprecated: false,
|
||||
};
|
||||
}
|
||||
return alias;
|
||||
});
|
||||
|
||||
let importString = '';
|
||||
|
||||
@@ -51,11 +71,18 @@ export default async function generateAliasesFile({
|
||||
if (iconAliases != null && Array.isArray(iconAliases)) {
|
||||
await Promise.all(
|
||||
iconAliases.map(async (alias) => {
|
||||
const componentNameAlias = toPascalCase(alias);
|
||||
const componentNameAlias = toPascalCase(alias.name);
|
||||
const deprecationReason = alias.deprecated
|
||||
? deprecationReasonTemplate(alias.deprecationReason, {
|
||||
componentName: toPascalCase(iconName),
|
||||
iconName,
|
||||
toBeRemovedInVersion: alias.toBeRemovedInVersion,
|
||||
})
|
||||
: '';
|
||||
|
||||
if (separateAliasesFile) {
|
||||
const output = `export { default } from "./${iconName}"`;
|
||||
const location = path.join(iconsDistDirectory, `${alias}${iconFileExtension}`);
|
||||
const location = path.join(iconsDistDirectory, `${alias.name}${iconFileExtension}`);
|
||||
|
||||
await fs.promises.writeFile(location, output, 'utf-8');
|
||||
}
|
||||
@@ -65,12 +92,14 @@ export default async function generateAliasesFile({
|
||||
return;
|
||||
}
|
||||
|
||||
const exportFileIcon = separateAliasesFile ? alias : iconName;
|
||||
const exportFileIcon = separateAliasesFile ? alias.name : iconName;
|
||||
|
||||
importString += getImportString(
|
||||
componentNameAlias,
|
||||
exportFileIcon,
|
||||
aliasImportFileExtension,
|
||||
alias.deprecated,
|
||||
deprecationReason,
|
||||
);
|
||||
|
||||
if (!aliasNamesOnly) {
|
||||
@@ -78,12 +107,16 @@ export default async function generateAliasesFile({
|
||||
`${componentNameAlias}Icon`,
|
||||
exportFileIcon,
|
||||
aliasImportFileExtension,
|
||||
alias.deprecated,
|
||||
deprecationReason,
|
||||
);
|
||||
|
||||
importString += getImportString(
|
||||
`Lucide${componentNameAlias}`,
|
||||
exportFileIcon,
|
||||
aliasImportFileExtension,
|
||||
alias.deprecated,
|
||||
deprecationReason,
|
||||
);
|
||||
}
|
||||
}),
|
||||
|
||||
@@ -2,6 +2,7 @@ import fs from 'fs';
|
||||
import path from 'path';
|
||||
import prettier from 'prettier';
|
||||
import { readSvg, toPascalCase } from '../../../scripts/helpers.mjs';
|
||||
import { deprecationReasonTemplate } from '../utils/deprecationReasonTemplate.mjs';
|
||||
|
||||
export default ({
|
||||
iconNodes,
|
||||
@@ -28,9 +29,23 @@ export default ({
|
||||
children = children.map(({ name, attributes }) => [name, attributes]);
|
||||
|
||||
const getSvg = () => readSvg(`${iconName}.svg`, iconsDir);
|
||||
const { deprecated = false } = iconMetaData[iconName];
|
||||
const { deprecated = false, toBeRemovedInVersion = null } = iconMetaData[iconName];
|
||||
const deprecationReason = deprecated
|
||||
? deprecationReasonTemplate(iconMetaData[iconName].deprecationReason, {
|
||||
componentName,
|
||||
iconName,
|
||||
toBeRemovedInVersion,
|
||||
})
|
||||
: '';
|
||||
|
||||
const elementTemplate = template({ componentName, iconName, children, getSvg, deprecated });
|
||||
const elementTemplate = template({
|
||||
componentName,
|
||||
iconName,
|
||||
children,
|
||||
getSvg,
|
||||
deprecated,
|
||||
deprecationReason,
|
||||
});
|
||||
const output = pretty
|
||||
? prettier.format(elementTemplate, {
|
||||
singleQuote: true,
|
||||
|
||||
17
tools/build-icons/utils/deprecationReasonTemplate.mjs
Normal file
17
tools/build-icons/utils/deprecationReasonTemplate.mjs
Normal file
@@ -0,0 +1,17 @@
|
||||
export function deprecationReasonTemplate(
|
||||
deprecationReason,
|
||||
{ componentName, iconName, toBeRemovedInVersion },
|
||||
) {
|
||||
const removalNotice = toBeRemovedInVersion
|
||||
? ` This ${deprecationReason.startsWith('icon') ? 'icon' : 'alias'} will be removed in ${toBeRemovedInVersion}`
|
||||
: '';
|
||||
|
||||
switch (deprecationReason) {
|
||||
case 'alias.typo':
|
||||
return `Renamed because of typo, use {@link ${componentName}} instead.${removalNotice}`;
|
||||
case 'alias.naming':
|
||||
return `The name of this icon was changed because it didn't meet our guidelines anymore, use {@link ${componentName}} instead.${removalNotice}`;
|
||||
case 'icon.brand':
|
||||
return `Brand icons have been deprecated and are due to be removed, please refer to https://github.com/lucide-icons/lucide/issues/670. We recommend using https://simpleicons.org/?q=${iconName} instead.${removalNotice}`;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user