From da7c09f66ea7d09ac749881caddb3a5d97dff1ce Mon Sep 17 00:00:00 2001 From: Eric Fennis Date: Fri, 17 Sep 2021 15:51:18 +0200 Subject: [PATCH] add paralel jobs --- .github/workflows/release.yml | 19 +++++++++++++----- packages/lucide-preact/package.json | 2 +- packages/lucide-react/package.json | 2 +- packages/lucide-vue-next/package.json | 4 ++-- packages/lucide-vue/babel.config.js | 10 ++++++---- packages/lucide-vue/nuxt.js | 13 ++++++------ packages/lucide-vue/package.json | 2 +- packages/lucide-vue/src/createVueComponent.js | 2 +- .../__snapshots__/lucide-vue.spec.js.snap | 8 ++++---- packages/lucide-vue/tests/lucide-vue.spec.js | 3 +-- packages/lucide/package.json | 2 +- scripts/build/generateIconFiles.js | 20 ++++++++++++------- 12 files changed, 51 insertions(+), 36 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ed9b42e..f57846f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -275,15 +275,24 @@ jobs: - name: "Outline SVG" run: yarn build:outline-icons - - name: Build 'Lucide' + - name: Build Icon Font run: | mkdir build - list=(_200 _300 "" _500 _600) + list=(-200 -300 "" -500 -600) + command='' for name in "${list[@]}" do - fontcustom compile "./converted_icons${name}" -h -n "Lucide${name}" -o ./tmp -F && mv ./tmp/* build + if [ -z "$command" ] + subcommand="(fontcustom compile "./converted_icons${name}" -h -n "lucide${name}" -o ./tmp -F && mv ./tmp/* build)" + then + command="$subcommand"; + else + command="$command & $subcommand"; + fi done + eval $command + - name: 'Upload to Artifacts' uses: actions/upload-artifact@v1 with: @@ -325,10 +334,10 @@ jobs: working-directory: packages/lucide-flutter - name: Move the ttf file - run: mv lucide-font/Lucide.ttf packages/lucide-flutter/assets/Lucide.ttf + run: mv lucide-font/lucide.ttf packages/lucide-flutter/assets/Lucide.ttf - name: Generate exports file - run: dart tool/generate_fonts.dart lucide-font/Lucide-preview.html + run: dart tool/generate_fonts.dart lucide-font/lucide-preview.html working-directory: packages/lucide-flutter - name: Update yaml diff --git a/packages/lucide-preact/package.json b/packages/lucide-preact/package.json index 4272919..ce4e3f5 100644 --- a/packages/lucide-preact/package.json +++ b/packages/lucide-preact/package.json @@ -19,7 +19,7 @@ "typings": "dist/lucide-preact.d.ts", "sideEffects": false, "scripts": { - "build": "yarn clean && yarn build:icons && yarn build:es && yarn build:types && yarn build:bundles", + "build": "yarn clean && yarn build:icons && (yarn build:es & yarn build:types & yarn build:bundles)", "clean": "rm -rf dist && rm -rf stats && rm -rf ./src/icons/*.js", "build:icons": "yarn --cwd ../../ build:icons --output=../packages/lucide-preact/src --templateSrc=../packages/lucide-preact/scripts/exportTemplate --renderUniqueKey", "build:es": "babel src -d dist/esm", diff --git a/packages/lucide-react/package.json b/packages/lucide-react/package.json index 98f2392..8256b03 100644 --- a/packages/lucide-react/package.json +++ b/packages/lucide-react/package.json @@ -19,7 +19,7 @@ "typings": "dist/lucide-react.d.ts", "sideEffects": false, "scripts": { - "build": "yarn clean && yarn build:icons && yarn build:es && yarn build:types && yarn build:bundles", + "build": "yarn clean && yarn build:icons && (yarn build:es & yarn build:types & yarn build:bundles)", "clean": "rm -rf dist && rm -rf stats && rm -rf ./src/icons/*.js", "build:icons": "yarn --cwd ../../ build:icons --output=../packages/lucide-react/src --templateSrc=../packages/lucide-react/scripts/exportTemplate --renderUniqueKey", "build:es": "babel src -d dist/esm", diff --git a/packages/lucide-vue-next/package.json b/packages/lucide-vue-next/package.json index e433b75..eedfefa 100644 --- a/packages/lucide-vue-next/package.json +++ b/packages/lucide-vue-next/package.json @@ -20,9 +20,9 @@ "typings": "dist/lucide-vue-next.d.ts", "sideEffects": false, "scripts": { - "build": "yarn clean && yarn build:icons && yarn build:es && yarn build:types && yarn build:bundles", + "build": "yarn clean && yarn build:icons && (yarn build:es & yarn build:types & yarn build:bundles)", "clean": "rm -rf dist && rm -rf ./src/icons/*.js", - "build:icons": "yarn --cwd ../../ build:icons --output=../packages/lucide-vue-next/src --templateSrc=../packages/lucide-vue-next/scripts/exportTemplate", + "build:icons": "yarn --cwd ../../ build:icons --output=../packages/lucide-vue-next/src --templateSrc=../packages/lucide-vue-next/scripts/exportTemplate --renderUniqueKey", "build:es": "babel src -d dist/esm", "build:types": "yarn --cwd ../../ babel-node packages/lucide-vue-next/scripts/buildTypes.js", "build:bundles": "yarn --cwd ../../ rollup -c packages/lucide-vue-next/rollup.config.js", diff --git a/packages/lucide-vue/babel.config.js b/packages/lucide-vue/babel.config.js index f037a1a..df8be36 100644 --- a/packages/lucide-vue/babel.config.js +++ b/packages/lucide-vue/babel.config.js @@ -1,12 +1,14 @@ +const mainConfig = require('../../babel.config'); + module.exports = { presets: [ [ - '@babel/preset-env', + '@babel/env', { - targets: { - node: 'current', - }, + loose: true, + modules: false, }, ], ], + env: mainConfig.env, }; diff --git a/packages/lucide-vue/nuxt.js b/packages/lucide-vue/nuxt.js index 33e6f54..ba76d25 100644 --- a/packages/lucide-vue/nuxt.js +++ b/packages/lucide-vue/nuxt.js @@ -1,12 +1,11 @@ -import { join } from 'path' - -export default function () { +import { join } from 'path'; +export default function() { this.nuxt.hook('components:dirs', dirs => { dirs.push({ path: join(__dirname, 'dist', 'esm', 'icons'), prefix: 'Icon', - ignore: ['**/index.js'] - }) - }) -} \ No newline at end of file + ignore: ['**/index.js'], + }); + }); +} diff --git a/packages/lucide-vue/package.json b/packages/lucide-vue/package.json index 6cac41f..8693713 100644 --- a/packages/lucide-vue/package.json +++ b/packages/lucide-vue/package.json @@ -19,7 +19,7 @@ "unpkg": "dist/umd/lucide-vue.min.js", "sideEffects": false, "scripts": { - "build": "yarn clean && yarn build:icons && yarn build:es && yarn build:bundles", + "build": "yarn clean && yarn build:icons && (yarn build:es & yarn build:bundles)", "clean": "rm -rf dist && rm -rf stats && rm -rf ./src/icons/*.js", "build:icons": "yarn --cwd ../../ build:icons --output=../packages/lucide-vue/src --templateSrc=../packages/lucide-vue/scripts/exportTemplate", "build:es": "babel src -d dist/esm", diff --git a/packages/lucide-vue/src/createVueComponent.js b/packages/lucide-vue/src/createVueComponent.js index 2abff05..5620a76 100644 --- a/packages/lucide-vue/src/createVueComponent.js +++ b/packages/lucide-vue/src/createVueComponent.js @@ -8,7 +8,7 @@ import defaultAttributes from './defaultAttributes'; * @param {string} string * @returns {string} A kebabized string */ - export const toKebabCase = string => string.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase(); +export const toKebabCase = string => string.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase(); export default (iconName, iconNode) => ({ name: iconName, diff --git a/packages/lucide-vue/tests/__snapshots__/lucide-vue.spec.js.snap b/packages/lucide-vue/tests/__snapshots__/lucide-vue.spec.js.snap index 8588924..90613ab 100644 --- a/packages/lucide-vue/tests/__snapshots__/lucide-vue.spec.js.snap +++ b/packages/lucide-vue/tests/__snapshots__/lucide-vue.spec.js.snap @@ -1,7 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Using lucide icon components should add a class to the element 1`] = ` - + @@ -10,7 +10,7 @@ exports[`Using lucide icon components should add a class to the element 1`] = ` `; exports[`Using lucide icon components should add a style attribute to the element 1`] = ` - + @@ -19,7 +19,7 @@ exports[`Using lucide icon components should add a style attribute to the elemen `; exports[`Using lucide icon components should adjust the size, stroke color and stroke width 1`] = ` - + @@ -28,7 +28,7 @@ exports[`Using lucide icon components should adjust the size, stroke color and s `; exports[`Using lucide icon components should render an component 1`] = ` - + diff --git a/packages/lucide-vue/tests/lucide-vue.spec.js b/packages/lucide-vue/tests/lucide-vue.spec.js index 1a48904..b8093e7 100644 --- a/packages/lucide-vue/tests/lucide-vue.spec.js +++ b/packages/lucide-vue/tests/lucide-vue.spec.js @@ -28,7 +28,7 @@ describe('Using lucide icon components', () => { }) expect(wrapper).toMatchSnapshot(); - expect(String(wrapper.classes())).toBe(String(['lucide-icon', 'my-icon'])) + expect(String(wrapper.classes())).toBe(String(['lucide-icon','lucide','lucide-smile', 'my-icon'])) }); it('should add a style attribute to the element', () => { @@ -36,7 +36,6 @@ describe('Using lucide icon components', () => { attrs: { style: 'position: absolute', } - }) expect(wrapper).toMatchSnapshot(); diff --git a/packages/lucide/package.json b/packages/lucide/package.json index 7352d91..d1be8e3 100644 --- a/packages/lucide/package.json +++ b/packages/lucide/package.json @@ -19,7 +19,7 @@ "typings": "dist/lucide.d.ts", "sideEffects": false, "scripts": { - "build": "yarn clean && yarn build:icons && yarn build:es && yarn build:types && yarn build:bundles", + "build": "yarn clean && yarn build:icons && (yarn build:es & yarn build:types & yarn build:bundles)", "clean": "rm -rf dist && rm -rf stats && rm -rf ./src/icons/*.js", "build:icons": "yarn --cwd ../../ build:icons --output=../packages/lucide/src", "build:es": "babel src -d dist/esm", diff --git a/scripts/build/generateIconFiles.js b/scripts/build/generateIconFiles.js index 1c62fc4..1e5c0aa 100644 --- a/scripts/build/generateIconFiles.js +++ b/scripts/build/generateIconFiles.js @@ -2,6 +2,7 @@ import fs from 'fs'; import path from 'path'; import prettier from 'prettier'; +import { promises } from 'stream'; import { toPascalCase } from '../helpers'; export default function({ iconNodes, outputDirectory, template, showLog = true, iconFileExtention = '.js' }) { @@ -12,7 +13,7 @@ export default function({ iconNodes, outputDirectory, template, showLog = true, fs.mkdirSync(iconsDistDirectory); } - icons.forEach(iconName => { + const writeIconFiles = icons.map(async iconName => { const location = path.join(iconsDistDirectory, `${iconName}${iconFileExtention}`); const componentName = toPascalCase(iconName); @@ -21,11 +22,16 @@ export default function({ iconNodes, outputDirectory, template, showLog = true, const elementTemplate = template({ componentName, iconName, children }); - - fs.writeFileSync(location, prettier.format(elementTemplate, { singleQuote: true, trailingComma: 'all', parser: 'babel' }), 'utf-8'); - - if(showLog) { - console.log('Successfully built', componentName); - } + await fs.promises.writeFile(location, prettier.format(elementTemplate, { singleQuote: true, trailingComma: 'all', parser: 'babel' }), 'utf-8'); }); + + Promise.all(writeIconFiles) + .then(() => { + if(showLog) { + console.log('Successfully built', icons.length, 'icons.'); + } + }) + .catch((error) => { + throw new Error(`Something went wrong generating icon files,\n ${error}`) + }) }