Skip to content

Commit

Permalink
refactor(scripts): Cleaning up scripts (#2092)
Browse files Browse the repository at this point in the history
* cleanup scripts

* Move helpers to package

* Fixes scripts

* Fix scripts

* Formatting

* Fix helpers import paths

* Remove lucide-figma

* Rename helpers package

* Fix build

* formatting

* Adjust main build-icons file

* Add export casing

* Adds `exportModuleNameCasing` fro lab project

* format files

* Bump package version @lucide/build-icons

* Revert changes in icons

* Revert changes in PR yml

* Fix lint issues

* Fix site build

* fix lint errors

* Attempt fix linting

* Fix lint errors
  • Loading branch information
ericfennis authored Jun 28, 2024
1 parent ce79418 commit 077242c
Show file tree
Hide file tree
Showing 113 changed files with 455 additions and 31,739 deletions.
6 changes: 4 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const DEFAULT_ATTRS = require('./scripts/render/default-attrs.json');
const DEFAULT_ATTRS = require('@lucide/build-icons/render/default-attrs.json');

module.exports = {
root: true,
Expand All @@ -15,7 +15,9 @@ module.exports = {
'no-use-before-define': 'off',
'import/no-extraneous-dependencies': [
'error',
{ devDependencies: ['**/*.test.js', '**/*.spec.js', './scripts/**'] },
{
devDependencies: ['**/*.test.js', '**/*.spec.js', '**/scripts/**'],
},
],
'import/extensions': [
'error',
Expand Down
11 changes: 0 additions & 11 deletions docs/.vitepress/data/packageData.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,16 +158,5 @@
"href": "https://www.npmjs.com/package/lucide-static"
}
]
},
"lucide-flutter": {
"order": 9,
"icon": "flutter",
"shields": [
{
"alt": "flutter",
"src": "https://img.shields.io/pub/v/lucide_icons",
"href": "https://img.shields.io/pub/v/lucide_icons"
}
]
}
}
6 changes: 0 additions & 6 deletions docs/.vitepress/lib/fetchPackages.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { promises as fs, constants } from 'fs';
import path from 'path';
import yaml from 'js-yaml';
import { PackageItem } from '../theme/types';

const fileExist = (filePath) =>
Expand All @@ -27,11 +26,6 @@ const fetchPackages = async (): Promise<PackageItem[]> => {
return JSON.parse(await fs.readFile(jsonFilePath, 'utf-8'));
}

const ymlFilePath = path.resolve(filePath, 'pubspec.yaml');
if (await fileExist(ymlFilePath)) {
return yaml.load(await fs.readFile(ymlFilePath, 'utf-8'));
}

return null;
}),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import fetchPackages from '../../../lib/fetchPackages';
export default {
async load() {
const packages = await fetchPackages();

return {
packages: packages
.filter((p) => p.name in packageData)
.filter((p) => p?.name != null && p.name in packageData)
.map((pData) => ({
...pData,
...packageData[pData.name],
Expand Down
3 changes: 2 additions & 1 deletion docs/.vitepress/theme/components/packages/PackageList.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<script setup lang="ts">
import { data } from './PackageList.data'
import GridSection from '../base/GridSection.vue'
import PackageListItem from "./PackageListItem.vue";</script>
import PackageListItem from "./PackageListItem.vue";
</script>

<template>
<GridSection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const props = defineProps<{
<img v-if="packageData.iconDark" :src="packageData.iconDark" alt="" class="package-icon dark" :class="packageData.iconClass" />
</div>
<div class="package-title">
<h2 class="title">{{ props.packageData.name }}</h2>
<h2 class="title">{{ props.packageData?.name }}</h2>
<a v-for="shield in props.packageData.shields" :href="shield.href" class="package-shield" rel="noreferrer noopener">
<img :src="shield.src" :alt="shield.href" />
</a>
Expand Down
16 changes: 9 additions & 7 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
"docs:build": "pnpm run /^prebuild:.*/ && vitepress build",
"docs:preview": "vitepress preview",
"build:docs": "vitepress build",
"prebuild:iconNodes": "node ../scripts/writeIconNodes.mjs",
"prebuild:metaJson": "node ../scripts/writeIconMetaIndex.mjs",
"prebuild:releaseJson": "node ../scripts/writeReleaseMetadata.mjs",
"prebuild:iconNodes": "node ./scripts/writeIconNodes.mjs",
"prebuild:metaJson": "node ./scripts/writeIconMetaIndex.mjs",
"prebuild:releaseJson": "node ./scripts/writeReleaseMetadata.mjs",
"prebuild:categoriesJson": "node ./scripts/writeCategoriesMetadata.mjs",
"prebuild:relatedIcons": "node ../scripts/writeIconRelatedIcons.mjs",
"prebuild:iconDetails": "node ../scripts/writeIconDetails.mjs",
"postbuild:vercelJson": "node ../scripts/writeVercelOutput.mjs",
"prebuild:relatedIcons": "node ./scripts/writeIconRelatedIcons.mjs",
"prebuild:iconDetails": "node ./scripts/writeIconDetails.mjs",
"postbuild:vercelJson": "node ./scripts/writeVercelOutput.mjs",
"dev": "npx nitropack dev",
"prebuild:api": "npx nitropack prepare",
"build:api": "npx nitropack build",
Expand All @@ -25,6 +25,9 @@
"author": "Eric Fennis",
"license": "ISC",
"devDependencies": {
"@lucide/build-icons": "workspace:*",
"@lucide/helpers": "workspace:*",
"@lucide/shared": "workspace:*",
"@rollup/plugin-replace": "^5.0.2",
"@types/semver": "^7.5.3",
"h3": "^1.8.0",
Expand All @@ -41,7 +44,6 @@
"@vueuse/core": "^10.7.2",
"element-to-path": "^1.2.1",
"fuse.js": "^6.5.3",
"js-yaml": "^4.1.0",
"jszip": "^3.7.0",
"lodash": "^4.17.20",
"lodash-es": "^4.17.21",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import fs from 'fs';
import path from 'path';
import renderIconsObject from './render/renderIconsObject.mjs';
import { readSvgDirectory, toCamelCase } from './helpers.mjs';
import { readSvgDirectory, toCamelCase } from '@lucide/helpers';

const currentDir = process.cwd();
const ICONS_DIR = path.resolve(currentDir, '../icons');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from 'fs';
import path from 'path';
import { readSvgDirectory, toCamelCase } from './helpers.mjs';
import { readSvgDirectory, toCamelCase } from '@lucide/helpers';

const currentDir = process.cwd();
const ICONS_DIR = path.resolve(currentDir, '../icons');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from 'fs';
import path from 'path';
import renderIconsObject from './render/renderIconsObject.mjs';
import { readSvgDirectory, toCamelCase } from './helpers.mjs';
import { renderIconsObject } from '@lucide/build-icons';
import { readSvgDirectory, toCamelCase } from '@lucide/helpers';

const currentDir = process.cwd();
const ICONS_DIR = path.resolve(currentDir, '../icons');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from 'fs';
import path from 'path';
import { readSvgDirectory } from './helpers.mjs';
import { readSvgDirectory } from '@lucide/helpers';

const currentDir = process.cwd();
const ICONS_DIR = path.resolve(currentDir, '../icons');
Expand All @@ -19,13 +19,6 @@ const categoryWeight = 3;
const MAX_RELATED_ICONS = 4 * 17; // grid of 4x17 icons, = 68 icons

const arrayMatches = (a, b) => {
// let matches = 0;
// for (let i = 0; i < a.length; ++i) {
// if (b.indexOf(a[i]) != -1) {
// matches++;
// }
// }
// return matches;
return a.filter((item) => b.includes(item)).length;
};

Expand Down Expand Up @@ -53,7 +46,6 @@ const getRelatedIcons = (currentIcon, icons) => {
};

const iconsMetaDataPromises = svgFiles.map(async (iconName) => {
// eslint-disable-next-line import/no-dynamic-require, global-require
const metaData = JSON.parse(fs.readFileSync(`../icons/${iconName}`));

const name = iconName.replace('.json', '');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import fs from 'fs';
import path from 'path';
import { simpleGit } from 'simple-git';
import semver from 'semver';
import { readSvgDirectory } from './helpers.mjs';
import { readSvgDirectory } from '@lucide/helpers';

const DATE_OF_FORK = '2020-06-08T16:39:52+0100';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import path from 'path';
import fs from 'fs';
// eslint-disable-next-line import/no-named-as-default, import/no-named-as-default-member
import getIconMetaData from '../tools/build-icons/utils/getIconMetaData.mjs';
import { getCurrentDirPath } from './helpers.mjs';
import { getIconMetaData } from '@lucide/build-icons';
import { getCurrentDirPath } from '@lucide/helpers';

const currentDir = process.cwd();
const scriptDir = getCurrentDirPath(import.meta.url);
Expand Down
15 changes: 7 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,15 @@
"lucide-vue-next": "pnpm --filter lucide-vue-next",
"lucide-svelte": "pnpm --filter lucide-svelte",
"lucide-static": "pnpm --filter lucide-static",
"build:icons": "node ./scripts/buildIcons.mjs --templateSrc ./packages/lucide/scripts/exportTemplate.mjs",
"build:outline-icons": "pnpm --filter outline-svg start",
"build:font": "pnpm --filter docs prebuild:releaseJson && pnpm --filter build-font start",
"generate:supersprite": "node ./scripts/generateSuperSVG.mjs",
"optimize": "node ./scripts/optimizeSvgs.mjs",
"addjsons": "node scripts/addMissingIconJsonFiles.mjs",
"checkIcons": "node scripts/checkIconsAndCategories.mjs --presets @babel/env",
"tags2icons": "node scripts/migrateTagsToIcons.mjs --presets @babel/env",
"icons2tags": "node scripts/migrateIconsToTags.mjs --presets @babel/env",
"icons2categories": "node scripts/migrateIconsToCategories.mjs --presets @babel/env",
"categories2icons": "node scripts/migrateCategoriesToIcons.mjs --presets @babel/env",
"checkIcons": "node scripts/checkIconsAndCategories.mjs",
"tags2icons": "node scripts/migrateTagsToIcons.mjs",
"icons2tags": "node scripts/migrateIconsToTags.mjs",
"icons2categories": "node scripts/migrateIconsToCategories.mjs",
"categories2icons": "node scripts/migrateCategoriesToIcons.mjs",
"generate:changelog": "node ./scripts/generateChangelog.mjs",
"generate:contributors": "node ./scripts/updateContributors.mjs icons/*.svg",
"generate:nextJSAliases": "node ./scripts/generateNextJSAliases.mjs",
Expand All @@ -42,6 +40,8 @@
"renamePattern": "node scripts/rename/renamePattern.mjs"
},
"devDependencies": {
"@lucide/build-icons": "workspace:*",
"@lucide/helpers": "workspace:*",
"@html-eslint/eslint-plugin": "^0.19.1",
"@html-eslint/parser": "^0.19.1",
"@octokit/rest": "^19.0.13",
Expand All @@ -60,7 +60,6 @@
"husky": "^8.0.3",
"lint-staged": "^13.3.0",
"minimist": "^1.2.8",
"node-fetch": "^3.3.2",
"p-memoize": "^7.1.1",
"prettier": "3.2.4",
"semver": "^7.5.4",
Expand Down
25 changes: 0 additions & 25 deletions packages/lucide-figma/README.md

This file was deleted.

Binary file removed packages/lucide-figma/cover.png
Binary file not shown.
Binary file removed packages/lucide-figma/icon.png
Binary file not shown.
26 changes: 0 additions & 26 deletions packages/lucide-figma/manifest.json

This file was deleted.

30 changes: 0 additions & 30 deletions packages/lucide-figma/package.json

This file was deleted.

Loading

0 comments on commit 077242c

Please sign in to comment.