@web-padawan/wc-icons-tool 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/tasks/lumo.js +21 -7
package/package.json
CHANGED
package/tasks/lumo.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { execSync } from 'node:child_process';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
import { readFileSync,
|
|
3
|
+
import { readFileSync, unlinkSync, writeFileSync } from 'node:fs';
|
|
4
|
+
import { dirname } from 'node:path';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
4
6
|
import * as cheerio from 'cheerio';
|
|
5
7
|
|
|
8
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
|
|
6
10
|
function createCopyright() {
|
|
7
11
|
return `/**
|
|
8
12
|
* @license
|
|
@@ -15,17 +19,19 @@ export function generateLumoFont() {
|
|
|
15
19
|
const FONT = `${process.cwd()}/packages/vaadin-lumo-styles/lumo-icons`;
|
|
16
20
|
|
|
17
21
|
// Create SVG font
|
|
18
|
-
const svgIcons2Font = path.normalize(
|
|
22
|
+
const svgIcons2Font = path.normalize(
|
|
23
|
+
`${__dirname}/../node_modules/.bin/svgicons2svgfont`
|
|
24
|
+
);
|
|
19
25
|
execSync(
|
|
20
26
|
`${svgIcons2Font} --fontname=lumo-icons --height=1000 --ascent=850 --descent=150 --normalize --fixedWidth --verbose -o ${FONT}.svg ${process.cwd()}/packages/vaadin-lumo-styles/icons/svg/*.svg`
|
|
21
27
|
);
|
|
22
28
|
|
|
23
29
|
// Convert SVG to TTF
|
|
24
|
-
const svg2TTF = path.normalize(
|
|
30
|
+
const svg2TTF = path.normalize(`${__dirname}/../node_modules/.bin/svg2ttf`);
|
|
25
31
|
execSync(`${svg2TTF} --ts=1 ${FONT}.svg ${FONT}.ttf`);
|
|
26
32
|
|
|
27
33
|
// Convert TTF to WOFF
|
|
28
|
-
const ttf2WOFF = path.normalize(
|
|
34
|
+
const ttf2WOFF = path.normalize(`${__dirname}/../node_modules/.bin/ttf2woff`);
|
|
29
35
|
execSync(`${ttf2WOFF} ${FONT}.ttf ${FONT}.woff`);
|
|
30
36
|
|
|
31
37
|
const content = readFileSync(`${FONT}.svg`, 'utf-8');
|
|
@@ -51,7 +57,9 @@ export function generateLumoFont() {
|
|
|
51
57
|
const outputCSS = `
|
|
52
58
|
@font-face {
|
|
53
59
|
font-family: 'lumo-icons';
|
|
54
|
-
src: url(data:application/font-woff;charset=utf-8;base64,${lumoIconsWoff.toString(
|
|
60
|
+
src: url(data:application/font-woff;charset=utf-8;base64,${lumoIconsWoff.toString(
|
|
61
|
+
'base64'
|
|
62
|
+
)})
|
|
55
63
|
format('woff');
|
|
56
64
|
font-weight: normal;
|
|
57
65
|
font-style: normal;
|
|
@@ -64,11 +72,17 @@ export function generateLumoFont() {
|
|
|
64
72
|
`;
|
|
65
73
|
|
|
66
74
|
// Write the output to src/props/icons.css
|
|
67
|
-
writeFileSync(
|
|
75
|
+
writeFileSync(
|
|
76
|
+
`${process.cwd()}/packages/vaadin-lumo-styles/src/props/icons.css`,
|
|
77
|
+
[createCopyright(), outputCSS.trimStart()].join('\n')
|
|
78
|
+
);
|
|
68
79
|
|
|
69
80
|
// Write the list of glyphs for visual tests
|
|
70
81
|
const list = glyphs.map((g) => g.name);
|
|
71
|
-
writeFileSync(
|
|
82
|
+
writeFileSync(
|
|
83
|
+
`${process.cwd()}/packages/vaadin-lumo-styles/test/glyphs.json`,
|
|
84
|
+
JSON.stringify(list, null, 2)
|
|
85
|
+
);
|
|
72
86
|
|
|
73
87
|
// Cleanup temporary font files
|
|
74
88
|
unlinkSync(`${FONT}.svg`);
|