Skip to content

Commit 1811963

Browse files
committed
chore: add build script for font info generation
1 parent b27ad8a commit 1811963

File tree

4 files changed

+187
-0
lines changed

4 files changed

+187
-0
lines changed

build/build.eva.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
const fs = require('fs')
2+
const path = require('path')
3+
4+
const outputLocation = '../src/component/utils/eva-icons.js'
5+
let icons = []
6+
let blacklisted = [
7+
]
8+
9+
const location = require.resolve('@quasar/extras/eva-icons/eva-icons.css')
10+
const fileContents = fs.readFileSync(location, 'utf8')
11+
12+
fileContents
13+
.split('\n')
14+
.forEach(line => {
15+
if (line.startsWith('.')) {
16+
const pos = line.indexOf(':before')
17+
if (pos > 0) {
18+
line = line.slice(1, pos - 1)
19+
if (blacklisted.includes(line) === false) {
20+
icons.push(line)
21+
}
22+
}
23+
}
24+
})
25+
26+
let output = 'export default [\n'
27+
icons.forEach((icon, index) => {
28+
if (index !== 0) output += ',\n'
29+
output += ` { name: '${icon}' }`
30+
})
31+
output += '\n]\n'
32+
33+
fs.writeFileSync(path.resolve(__dirname, outputLocation), output, 'utf8')
34+
console.log(`Ion Icons generation: Done - count: ${icons.length}`)

build/build.fontawesome.js

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
This generator is a bit different from the rest. Fontawesome uses
3+
a prefix (ex: 'fab', 'fas', etc) to determine which font file to
4+
use. However, this information is not in the css file that we will
5+
be parsing. So, we open the old fontawesome-v5.js file (which was
6+
made for web, not node), read it in, make adjustments, and eval it
7+
(yeah I know, eval bad). Then we make a map of fonts and the
8+
prefixes to we can add the prefix back. If it's a new font, we make
9+
the prefix '---' so we can search the file for it and hand-curate
10+
the prefix manually. Then, we have a fiished file.
11+
*/
12+
const fs = require('fs')
13+
const path = require('path')
14+
15+
const inputLocation = '../src/component/utils/fontawesome-v5.js'
16+
const outputLocation = '../src/component/utils/fontawesome-v5.js'
17+
let oldIcons = {}
18+
let icons = []
19+
let blacklisted = [
20+
'fa-font-awesome-logo-full'
21+
]
22+
23+
let fa = fs.readFileSync(path.resolve(__dirname, inputLocation), 'utf8')
24+
fa = fa.split('\n')
25+
fa.shift()
26+
fa.unshift('[')
27+
fa = fa.join('\n')
28+
// eslint-disable-next-line no-eval
29+
fa = eval(fa)
30+
fa.forEach(f => {
31+
let names = f.name.split(' ')
32+
oldIcons[names[1]] = names[0]
33+
})
34+
35+
const location = require.resolve('@quasar/extras/fontawesome-v5/fontawesome-v5.css')
36+
const fileContents = fs.readFileSync(location, 'utf8')
37+
38+
fileContents
39+
.split('\n')
40+
.forEach(line => {
41+
if (line.startsWith('.')) {
42+
const pos = line.indexOf(':before')
43+
if (pos > 0) {
44+
line = line.slice(1, pos)
45+
if (blacklisted.includes(line) === false) {
46+
if (oldIcons[line]) {
47+
icons.push(oldIcons[line] + ' ' + line)
48+
} else {
49+
icons.push('--- ' + line)
50+
}
51+
}
52+
}
53+
}
54+
})
55+
56+
let output = 'export default [\n'
57+
icons.forEach((icon, index) => {
58+
if (index !== 0) output += ',\n'
59+
output += ` { name: '${icon}' }`
60+
})
61+
output += '\n]\n'
62+
63+
fs.writeFileSync(path.resolve(__dirname, outputLocation), output, 'utf8')
64+
console.log(`Fontawesome v5 Icons generation: Done - count: ${icons.length}`)

build/build.ion.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
const fs = require('fs')
2+
const path = require('path')
3+
4+
const outputLocation = '../src/component/utils/ionicons-v4.js'
5+
let icons = []
6+
let blacklisted = [
7+
'ionicons'
8+
]
9+
10+
const location = require.resolve('@quasar/extras/ionicons-v4/ionicons-v4.css')
11+
const fileContents = fs.readFileSync(location, 'utf8')
12+
13+
fileContents
14+
.split('\n')
15+
.forEach(line => {
16+
if (line.startsWith('.')) {
17+
const pos = line.indexOf(':before')
18+
if (pos > 0) {
19+
line = line.slice(1, pos)
20+
if (blacklisted.includes(line) === false) {
21+
icons.push(line)
22+
}
23+
}
24+
}
25+
})
26+
27+
let output = 'export default [\n'
28+
icons.forEach((icon, index) => {
29+
if (index !== 0) output += ',\n'
30+
output += ` { name: '${icon}' }`
31+
})
32+
output += '\n]\n'
33+
34+
fs.writeFileSync(path.resolve(__dirname, outputLocation), output, 'utf8')
35+
console.log(`Ion Icons generation: Done - count: ${icons.length}`)

build/build.mdi-v4.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
const fs = require('fs')
2+
const path = require('path')
3+
4+
const outputLocation = '../src/component/utils/mdi-v4.js'
5+
let icons = []
6+
let blacklisted = [
7+
'md',
8+
'mdi-blank',
9+
'mdi-18px.mdi-set, .mdi-18px.md',
10+
'mdi-24px.mdi-set, .mdi-24px.md',
11+
'mdi-36px.mdi-set, .mdi-36px.md',
12+
'mdi-48px.mdi-set, .mdi-48px.md',
13+
'mdi-dar',
14+
'mdi-dark.mdi-inactiv',
15+
'mdi-ligh',
16+
'mdi-light.mdi-inactiv',
17+
'mdi-rotate-4',
18+
'mdi-rotate-9',
19+
'mdi-rotate-13',
20+
'mdi-rotate-18',
21+
'mdi-rotate-22',
22+
'mdi-rotate-27',
23+
'mdi-rotate-31',
24+
'mdi-flip-',
25+
'mdi-spi'
26+
]
27+
28+
const location = require.resolve('@quasar/extras/mdi-v4/mdi-v4.css')
29+
const fileContents = fs.readFileSync(location, 'utf8')
30+
31+
fileContents
32+
.split('\n')
33+
.forEach(line => {
34+
if (line.startsWith('.')) {
35+
const pos = line.indexOf(':before')
36+
if (pos > 0) {
37+
line = line.slice(1, pos - 1)
38+
if (blacklisted.includes(line) === false) {
39+
// console.log(`${line}`)
40+
icons.push(line)
41+
}
42+
}
43+
}
44+
})
45+
46+
let output = 'export default [\n'
47+
icons.forEach((icon, index) => {
48+
if (index !== 0) output += ',\n'
49+
output += ` { name: '${icon}' }`
50+
})
51+
output += '\n]\n'
52+
53+
fs.writeFileSync(path.resolve(__dirname, outputLocation), output, 'utf8')
54+
console.log(`MDI Icons generation: Done - count: ${icons.length}`)

0 commit comments

Comments
 (0)