Skip to content

Commit

Permalink
Update scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
simonepozzobon committed Nov 21, 2022
1 parent 049cc6f commit 8a0b917
Show file tree
Hide file tree
Showing 1,208 changed files with 10,442 additions and 1,257 deletions.
63 changes: 34 additions & 29 deletions build/generate.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,35 @@
const path = require('path')
const fs = require('fs-plus')
const cheerio = require('cheerio')
const upperCamelCase = require('uppercamelcase')
const path = require("path");
const fs = require("fs-plus");
const cheerio = require("cheerio");
const upperCamelCase = require("uppercamelcase");

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

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

const indexJs = []
const indexJs = [];

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

let data = svgFile.replace(/<svg[^>]+>/gi, '').replace(/<\/svg>/gi, '')
// Get Path Content from SVG
const $ = cheerio.load(data, {
xmlMode: true
})
const svgPath = $('path').attr('d')
let data = svgFile.replace(/<svg[^>]+>/gi, "").replace(/<\/svg>/gi, "");
// Get Path Content from SVG
const $ = cheerio.load(data, {
xmlMode: true,
});
const svgPath = $("path").attr("d");

const template = `<template>
const template = `<template>
<svg
v-bind="$attrs"
:width="size"
Expand All @@ -46,21 +49,23 @@ uniconsConfig.forEach(icon => {
import '../utils/style.css'
export default {
name: "${name}",
props: {
size: {
type: String,
default: '1em'
}
}
}
</script>`
</script>`;

fs.writeFileSync(location, template, 'utf-8')
fs.writeFileSync(location, template, "utf-8");

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

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.`);
1 change: 1 addition & 0 deletions icons/uil-0-plus.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import '../utils/style.css'
export default {
name: "Uil0Plus",
props: {
size: {
type: String,
Expand Down
1 change: 1 addition & 0 deletions icons/uil-10-plus.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import '../utils/style.css'
export default {
name: "Uil10Plus",
props: {
size: {
type: String,
Expand Down
1 change: 1 addition & 0 deletions icons/uil-12-plus.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import '../utils/style.css'
export default {
name: "Uil12Plus",
props: {
size: {
type: String,
Expand Down
1 change: 1 addition & 0 deletions icons/uil-13-plus.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import '../utils/style.css'
export default {
name: "Uil13Plus",
props: {
size: {
type: String,
Expand Down
1 change: 1 addition & 0 deletions icons/uil-16-plus.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import '../utils/style.css'
export default {
name: "Uil16Plus",
props: {
size: {
type: String,
Expand Down
1 change: 1 addition & 0 deletions icons/uil-17-plus.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import '../utils/style.css'
export default {
name: "Uil17Plus",
props: {
size: {
type: String,
Expand Down
1 change: 1 addition & 0 deletions icons/uil-18-plus.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import '../utils/style.css'
export default {
name: "Uil18Plus",
props: {
size: {
type: String,
Expand Down
1 change: 1 addition & 0 deletions icons/uil-21-plus.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import '../utils/style.css'
export default {
name: "Uil21Plus",
props: {
size: {
type: String,
Expand Down
1 change: 1 addition & 0 deletions icons/uil-3-plus.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import '../utils/style.css'
export default {
name: "Uil3Plus",
props: {
size: {
type: String,
Expand Down
1 change: 1 addition & 0 deletions icons/uil-500px.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import '../utils/style.css'
export default {
name: "Uil500px",
props: {
size: {
type: String,
Expand Down
1 change: 1 addition & 0 deletions icons/uil-6-plus.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import '../utils/style.css'
export default {
name: "Uil6Plus",
props: {
size: {
type: String,
Expand Down
1 change: 1 addition & 0 deletions icons/uil-abacus.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import '../utils/style.css'
export default {
name: "UilAbacus",
props: {
size: {
type: String,
Expand Down
1 change: 1 addition & 0 deletions icons/uil-accessible-icon-alt.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import '../utils/style.css'
export default {
name: "UilAccessibleIconAlt",
props: {
size: {
type: String,
Expand Down
1 change: 1 addition & 0 deletions icons/uil-adjust-alt.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import '../utils/style.css'
export default {
name: "UilAdjustAlt",
props: {
size: {
type: String,
Expand Down
1 change: 1 addition & 0 deletions icons/uil-adjust-circle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import '../utils/style.css'
export default {
name: "UilAdjustCircle",
props: {
size: {
type: String,
Expand Down
1 change: 1 addition & 0 deletions icons/uil-adjust-half.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import '../utils/style.css'
export default {
name: "UilAdjustHalf",
props: {
size: {
type: String,
Expand Down
1 change: 1 addition & 0 deletions icons/uil-adjust.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import '../utils/style.css'
export default {
name: "UilAdjust",
props: {
size: {
type: String,
Expand Down
1 change: 1 addition & 0 deletions icons/uil-adobe-alt.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import '../utils/style.css'
export default {
name: "UilAdobeAlt",
props: {
size: {
type: String,
Expand Down
1 change: 1 addition & 0 deletions icons/uil-adobe.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import '../utils/style.css'
export default {
name: "UilAdobe",
props: {
size: {
type: String,
Expand Down
1 change: 1 addition & 0 deletions icons/uil-airplay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import '../utils/style.css'
export default {
name: "UilAirplay",
props: {
size: {
type: String,
Expand Down
1 change: 1 addition & 0 deletions icons/uil-align-alt.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import '../utils/style.css'
export default {
name: "UilAlignAlt",
props: {
size: {
type: String,
Expand Down
1 change: 1 addition & 0 deletions icons/uil-align-center-alt.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import '../utils/style.css'
export default {
name: "UilAlignCenterAlt",
props: {
size: {
type: String,
Expand Down
1 change: 1 addition & 0 deletions icons/uil-align-center-h.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import '../utils/style.css'
export default {
name: "UilAlignCenterH",
props: {
size: {
type: String,
Expand Down
1 change: 1 addition & 0 deletions icons/uil-align-center-justify.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import '../utils/style.css'
export default {
name: "UilAlignCenterJustify",
props: {
size: {
type: String,
Expand Down
1 change: 1 addition & 0 deletions icons/uil-align-center-v.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import '../utils/style.css'
export default {
name: "UilAlignCenterV",
props: {
size: {
type: String,
Expand Down
1 change: 1 addition & 0 deletions icons/uil-align-center.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import '../utils/style.css'
export default {
name: "UilAlignCenter",
props: {
size: {
type: String,
Expand Down
1 change: 1 addition & 0 deletions icons/uil-align-justify.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import '../utils/style.css'
export default {
name: "UilAlignJustify",
props: {
size: {
type: String,
Expand Down
1 change: 1 addition & 0 deletions icons/uil-align-left-justify.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import '../utils/style.css'
export default {
name: "UilAlignLeftJustify",
props: {
size: {
type: String,
Expand Down
1 change: 1 addition & 0 deletions icons/uil-align-left.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import '../utils/style.css'
export default {
name: "UilAlignLeft",
props: {
size: {
type: String,
Expand Down
1 change: 1 addition & 0 deletions icons/uil-align-letter-right.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import '../utils/style.css'
export default {
name: "UilAlignLetterRight",
props: {
size: {
type: String,
Expand Down
1 change: 1 addition & 0 deletions icons/uil-align-right-justify.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import '../utils/style.css'
export default {
name: "UilAlignRightJustify",
props: {
size: {
type: String,
Expand Down
1 change: 1 addition & 0 deletions icons/uil-align-right.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import '../utils/style.css'
export default {
name: "UilAlignRight",
props: {
size: {
type: String,
Expand Down
1 change: 1 addition & 0 deletions icons/uil-align.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import '../utils/style.css'
export default {
name: "UilAlign",
props: {
size: {
type: String,
Expand Down
1 change: 1 addition & 0 deletions icons/uil-amazon.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import '../utils/style.css'
export default {
name: "UilAmazon",
props: {
size: {
type: String,
Expand Down
1 change: 1 addition & 0 deletions icons/uil-ambulance.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import '../utils/style.css'
export default {
name: "UilAmbulance",
props: {
size: {
type: String,
Expand Down
1 change: 1 addition & 0 deletions icons/uil-analysis.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import '../utils/style.css'
export default {
name: "UilAnalysis",
props: {
size: {
type: String,
Expand Down
1 change: 1 addition & 0 deletions icons/uil-analytics.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import '../utils/style.css'
export default {
name: "UilAnalytics",
props: {
size: {
type: String,
Expand Down
1 change: 1 addition & 0 deletions icons/uil-anchor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import '../utils/style.css'
export default {
name: "UilAnchor",
props: {
size: {
type: String,
Expand Down
Loading

0 comments on commit 8a0b917

Please sign in to comment.