Skip to content

Commit

Permalink
chore: upgrade webpack to v5 and node to 22 and fixed workflow (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
imzedi authored Dec 4, 2024
1 parent 7a2addb commit 95d3d04
Show file tree
Hide file tree
Showing 301 changed files with 6,033 additions and 5,926 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/autotag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ name: Create Tag on package.json update

on:
push:
branches:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
token: '${{ secrets.GH_AUTH_TOKEN }}'
fetch-depth: 0
- uses: butlerlogic/action-autotag@master
with:
GITHUB_TOKEN: "${{ secrets.GH_AUTH_TOKEN }}"
tag_prefix: "v"
- uses: actions/checkout@v4
with:
token: "${{ secrets.GH_AUTH_TOKEN }}"
fetch-depth: 0
- uses: butlerlogic/action-autotag@2.1.1
with:
GITHUB_TOKEN: "${{ secrets.GH_AUTH_TOKEN }}"
tag_prefix: "v"
10 changes: 5 additions & 5 deletions .github/workflows/npm-publish-pro.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ name: Publish to NPM PRO
on:
push:
tags:
- '*'
- "*"

jobs:
publish-npm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 10.16.3
node-version: 22.11.0
- name: Install NPM
run: npm ci --progress=false
- name: Set Gemfury Config
Expand All @@ -22,4 +22,4 @@ jobs:
- name: Download & Build Icons
run: npm i @iconscout/unicons@latest && npm run generate
- name: Publish to Gemfury
run: npm publish
run: npm publish
23 changes: 11 additions & 12 deletions .github/workflows/npm-publish-rc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,30 @@ name: Publish to NPM RC
on:
push:
# Sequence of patterns matched against refs/heads
branches:
- 'release-*'
branches:
- "release-*"

jobs:
publish-npm:
runs-on: ubuntu-latest
steps:
- if: github.event_name == 'push'
uses: actions/checkout@v2
- if: github.event_name == 'pull_request'
uses: actions/checkout@v2
- if: github.event_name == 'push'
uses: actions/checkout@v4
- if: github.event_name == 'pull_request'
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- uses: actions/setup-node@v1
- uses: actions/setup-node@v4
with:
node-version: 10.16.3
node-version: 22.11.0
- name: Download & Build Icons
run: npm ci --progress=false && npm i @iconscout/unicons@latest && npm run generate
- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GH_AUTH_TOKEN }}
title: Updated Icons
- name: Publish to NPM
uses: primer/publish@v2.0.0
run: npm publish
env:
GITHUB_TOKEN: ${{ secrets.GH_AUTH_TOKEN }}
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
10 changes: 5 additions & 5 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ name: Publish to NPM
on:
push:
tags:
- '*'
- "*"

jobs:
publish-npm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 10.16.3
node-version: 22.11.0
- name: Download & Build Icons
run: npm ci --progress=false && npm i @iconscout/unicons@latest && npm run generate
- name: Publish to NPM
run: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc && npm publish
env:
NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
22.11.0
119 changes: 71 additions & 48 deletions build/generate.js
Original file line number Diff line number Diff line change
@@ -1,69 +1,92 @@
const path = require('path')
const fs = require('fs-plus')
const cheerio = require('cheerio')
const upperCamelCase = require('uppercamelcase')
const svgr = require('@svgr/core').default
const path = require("path");
const fs = require("fs-plus");
const upperCamelCase = require("uppercamelcase");
const svgr = require("@svgr/core").default;

const iconsComponentPath = path.join(process.cwd(), 'icons')
const iconsIndexPath = path.join(process.cwd(), 'index.js')
const uniconsConfig = require('@iconscout/unicons/json/monochrome.json')
const iconsComponentPath = path.join(process.cwd(), "icons");
const iconsIndexPath = path.join(process.cwd(), "index.js");
const uniconsConfig = require("@iconscout/unicons/json/monochrome.json");

const COLOR_CLASS = {
'class="uim-primary"': 'opacity="1"',
'class="uim-secondary"': 'opacity="0.7"',
'class="uim-tertiary"': 'opacity="0.5"',
'class="uim-quaternary"': 'opacity="0.25"',
'class="uim-quinary"': 'opacity="0"'
}
'class="uim-quinary"': 'opacity="0"',
};

// Clear Directories
fs.removeSync(iconsComponentPath)
fs.mkdirSync(iconsComponentPath)
fs.removeSync(iconsComponentPath);
fs.mkdirSync(iconsComponentPath);

const indexJs = []

const icon = uniconsConfig[0]
const indexJs = [];

const babelTransform = (component) => {
return new Promise ((resolve, reject) => {
require("@babel/core").transform(component, {
plugins: [
["@babel/plugin-transform-react-jsx", {
useBuiltIns: true
}]
],
}, function(err, result) {
if (err) {
reject(err)
} else {
resolve(result.code)
return new Promise((resolve, reject) => {
require("@babel/core").transform(
component,
{
plugins: [
[
"@babel/plugin-transform-react-jsx",
{
useBuiltIns: true,
},
],
],
},
function (err, result) {
if (err) {
reject(err);
} else {
resolve(result.code);
}
}
});
})
}
);
});
};

uniconsConfig.forEach(icon => {
const baseName = `uim-${icon.name}`
const location = path.join(iconsComponentPath, `${baseName}.js`)
const name = upperCamelCase(baseName)
let svgFile = fs.readFileSync(path.resolve('node_modules/@iconscout/unicons', icon.svg), 'utf-8')
uniconsConfig.forEach((icon) => {
const baseName = `uim-${icon.name}`;
const location = path.join(iconsComponentPath, `${baseName}.js`);
const name = upperCamelCase(baseName);
let svgFile = fs.readFileSync(
path.resolve("node_modules/@iconscout/unicons", icon.svg),
"utf-8"
);

Object.keys(COLOR_CLASS).forEach(key => {
svgFile = svgFile.replace(new RegExp(key, 'g'), COLOR_CLASS[key])
})
Object.keys(COLOR_CLASS).forEach((key) => {
svgFile = svgFile.replace(new RegExp(key, "g"), COLOR_CLASS[key]);
});

svgr(svgFile, { svgo: false, expandProps: 'start', svgProps: { width: "{props.size || '1em'}", height: "{props.size || '1em'}", fill: 'currentColor', className: "{`ui-svg-inline ${props.className || ''}`}" } }, { componentName: name }).then(template => {
babelTransform(template).then(code => {
svgr(
svgFile,
{
svgo: false,
expandProps: "start",
svgProps: {
width: "{props.size || '1em'}",
height: "{props.size || '1em'}",
fill: "currentColor",
className: "{`ui-svg-inline ${props.className || ''}`}",
},
},
{ componentName: name }
).then((template) => {
babelTransform(template).then((code) => {
// Add CSS in reactComponent
reactComponent = code.replace(`import * as React from "react";`, `import * as React from "react";\nimport "../utils/style.css";`)
fs.writeFileSync(location, reactComponent, 'utf-8')
})
})
reactComponent = code.replace(
`import * as React from "react";`,
`import * as React from "react";\nimport "../utils/style.css";`
);
fs.writeFileSync(location, reactComponent, "utf-8");
});
});

// Add it to index.js
indexJs.push(`export { default as ${name} } from './icons/${baseName}'`)
})
indexJs.push(`export { default as ${name} } from './icons/${baseName}'`);
});

fs.writeFileSync(iconsIndexPath, indexJs.join('\n'), 'utf-8')
fs.writeFileSync(iconsIndexPath, indexJs.join("\n"), "utf-8");

console.log(`Generated ${uniconsConfig.length} icon components.`)
console.log(`Generated ${uniconsConfig.length} icon components.`);
3 changes: 1 addition & 2 deletions icons/uim-500px.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions icons/uim-adobe-alt.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as React from "react";
import "../utils/style.css";

function UimAdobeAlt(props) {
return /*#__PURE__*/React.createElement("svg", Object.assign({}, props, {
xmlns: "http://www.w3.org/2000/svg",
viewBox: "0 0 24 24",
width: props.size || '1em',
height: props.size || '1em',
Expand All @@ -14,5 +14,4 @@ function UimAdobeAlt(props) {
"data-name": "Brand Logos"
}));
}

export default UimAdobeAlt;
3 changes: 1 addition & 2 deletions icons/uim-adobe.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as React from "react";
import "../utils/style.css";

function UimAdobe(props) {
return /*#__PURE__*/React.createElement("svg", Object.assign({}, props, {
xmlns: "http://www.w3.org/2000/svg",
viewBox: "0 0 24 24",
width: props.size || '1em',
height: props.size || '1em',
Expand All @@ -14,5 +14,4 @@ function UimAdobe(props) {
"data-name": "Brand Logos"
}));
}

export default UimAdobe;
3 changes: 1 addition & 2 deletions icons/uim-airplay.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as React from "react";
import "../utils/style.css";

function UimAirplay(props) {
return /*#__PURE__*/React.createElement("svg", Object.assign({}, props, {
xmlns: "http://www.w3.org/2000/svg",
viewBox: "0 0 24 24",
width: props.size || '1em',
height: props.size || '1em',
Expand All @@ -20,5 +20,4 @@ function UimAirplay(props) {
d: "M16 21H8a1 1 0 0 1-.832-1.555l4-6a1.038 1.038 0 0 1 1.664 0l4 6A1 1 0 0 1 16 21Z"
}));
}

export default UimAirplay;
3 changes: 1 addition & 2 deletions icons/uim-align-alt.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as React from "react";
import "../utils/style.css";

function UimAlignAlt(props) {
return /*#__PURE__*/React.createElement("svg", Object.assign({}, props, {
xmlns: "http://www.w3.org/2000/svg",
viewBox: "0 0 24 24",
width: props.size || '1em',
height: props.size || '1em',
Expand All @@ -13,5 +13,4 @@ function UimAlignAlt(props) {
d: "M10 5H7a1 1 0 0 1 0-2h3a1 1 0 0 1 0 2zm0 4H3a1 1 0 0 1 0-2h7a1 1 0 0 1 0 2zm0 4H3a1 1 0 0 1 0-2h7a1 1 0 0 1 0 2zm0 4H3a1 1 0 0 1 0-2h7a1 1 0 0 1 0 2zm0 4H3a1 1 0 0 1 0-2h7a1 1 0 0 1 0 2zM21 5h-7a1 1 0 0 1 0-2h7a1 1 0 0 1 0 2zm0 4h-7a1 1 0 0 1 0-2h7a1 1 0 0 1 0 2zm0 4h-7a1 1 0 0 1 0-2h7a1 1 0 0 1 0 2zm0 4h-7a1 1 0 0 1 0-2h7a1 1 0 0 1 0 2zm-4 4h-3a1 1 0 0 1 0-2h3a1 1 0 0 1 0 2z"
}));
}

export default UimAlignAlt;
3 changes: 1 addition & 2 deletions icons/uim-align-center-justify.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as React from "react";
import "../utils/style.css";

function UimAlignCenterJustify(props) {
return /*#__PURE__*/React.createElement("svg", Object.assign({}, props, {
xmlns: "http://www.w3.org/2000/svg",
viewBox: "0 0 24 24",
width: props.size || '1em',
height: props.size || '1em',
Expand All @@ -13,5 +13,4 @@ function UimAlignCenterJustify(props) {
d: "M21 5H3a1 1 0 0 1 0-2h18a1 1 0 0 1 0 2zm0 4H3a1 1 0 0 1 0-2h18a1 1 0 0 1 0 2zm0 4H3a1 1 0 0 1 0-2h18a1 1 0 0 1 0 2zm0 4H3a1 1 0 0 1 0-2h18a1 1 0 0 1 0 2zm-4 4H7a1 1 0 0 1 0-2h10a1 1 0 0 1 0 2z"
}));
}

export default UimAlignCenterJustify;
3 changes: 1 addition & 2 deletions icons/uim-align-center.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as React from "react";
import "../utils/style.css";

function UimAlignCenter(props) {
return /*#__PURE__*/React.createElement("svg", Object.assign({}, props, {
xmlns: "http://www.w3.org/2000/svg",
viewBox: "0 0 24 24",
width: props.size || '1em',
height: props.size || '1em',
Expand All @@ -13,5 +13,4 @@ function UimAlignCenter(props) {
d: "M21 7H3a1 1 0 0 1 0-2h18a1 1 0 0 1 0 2zm-4 4H7a1 1 0 0 1 0-2h10a1 1 0 0 1 0 2zm4 4H3a1 1 0 0 1 0-2h18a1 1 0 0 1 0 2zm-4 4H7a1 1 0 0 1 0-2h10a1 1 0 0 1 0 2z"
}));
}

export default UimAlignCenter;
Loading

0 comments on commit 95d3d04

Please sign in to comment.