@varlet/icons 1.27.20 → 2.0.0-alpha.1663499244572

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.
Files changed (3) hide show
  1. package/LICENCE +21 -21
  2. package/lib/index.js +112 -112
  3. package/package.json +1 -1
package/LICENCE CHANGED
@@ -1,21 +1,21 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2020 varlet
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 varlet
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/lib/index.js CHANGED
@@ -1,112 +1,112 @@
1
- #!/usr/bin/env node
2
-
3
- const webfont = require('webfont').default
4
- const commander = require('commander')
5
- const { writeFile, ensureDir, removeSync, readdirSync } = require('fs-extra')
6
- const { resolve } = require('path')
7
-
8
- const CWD = process.cwd()
9
- const SVG_DIR = resolve(CWD, 'svg')
10
- const DIST_DIR = resolve(CWD, 'dist')
11
- const FONTS_DIR = resolve(DIST_DIR, 'fonts')
12
- const CSS_DIR = resolve(DIST_DIR, 'css')
13
- const formats = ['ttf', 'woff', 'woff2']
14
-
15
- const config = require(resolve(CWD, 'varlet-icons.config.js'))
16
-
17
- async function build() {
18
- const { base64, publicPath, namespace, fontName, fileName, fontWeight = 'normal', fontStyle = 'normal' } = config
19
-
20
- const { ttf, woff, woff2 } = await webfont({
21
- files: `${SVG_DIR}/*.svg`,
22
- fontName,
23
- formats,
24
- fontHeight: 512,
25
- descent: 64,
26
- })
27
-
28
- removeSync(DIST_DIR)
29
-
30
- await Promise.all([ensureDir(FONTS_DIR), ensureDir(CSS_DIR)])
31
-
32
- const icons = readdirSync(SVG_DIR).map((svgName) => {
33
- const i = svgName.indexOf('-')
34
- const extIndex = svgName.lastIndexOf('.')
35
-
36
- return {
37
- name: svgName.slice(i + 1, extIndex),
38
- pointCode: svgName.slice(1, i),
39
- }
40
- })
41
-
42
- const iconNames = icons.map((iconName) => ` "${iconName.name}"`)
43
-
44
- const indexTemplate = `\
45
- module.exports = [
46
- ${iconNames.join(',\n')}
47
- ]
48
- `
49
-
50
- const indexESMTemplate = `\
51
- export default [
52
- ${iconNames.join(',\n')}
53
- ]
54
- `
55
-
56
- const cssTemplate = `\
57
- @font-face {
58
- font-family: "${fontName}";
59
- src: url("${
60
- base64
61
- ? `data:application/font-woff2;charset=utf-8;base64,${Buffer.from(woff2).toString('base64')}`
62
- : `${publicPath}${fileName}-webfont.woff2`
63
- }") format("woff2"),
64
- url("${
65
- base64
66
- ? `data:application/font-woff;charset=utf-8;base64,${woff.toString('base64')}`
67
- : `${publicPath}${fileName}-webfont.woff`
68
- }") format("woff"),
69
- url("${
70
- base64
71
- ? `data:font/truetype;charset=utf-8;base64,${ttf.toString('base64')}`
72
- : `${publicPath}${fileName}-webfont.ttf`
73
- }") format("truetype");
74
- font-weight: ${fontWeight};
75
- font-style: ${fontStyle};
76
- }
77
-
78
- .${namespace}--set,
79
- .${namespace}--set::before {
80
- position: relative;
81
- display: inline-block;
82
- font: normal normal normal 14px/1 "${fontName}";
83
- font-size: inherit;
84
- text-rendering: auto;
85
- -webkit-font-smoothing: antialiased;
86
- }
87
-
88
- ${icons
89
- .map((icon) => {
90
- return `.${namespace}-${icon.name}::before {
91
- content: "\\${icon.pointCode}";
92
- }`
93
- })
94
- .join('\n\n')}
95
- `
96
-
97
- await Promise.all([
98
- writeFile(resolve(FONTS_DIR, `${fileName}-webfont.ttf`), ttf),
99
- writeFile(resolve(FONTS_DIR, `${fileName}-webfont.woff`), woff),
100
- writeFile(resolve(FONTS_DIR, `${fileName}-webfont.woff2`), woff2),
101
- writeFile(resolve(CSS_DIR, `${fileName}.css`), cssTemplate),
102
- writeFile(resolve(CSS_DIR, `${fileName}.less`), cssTemplate),
103
- writeFile(resolve(DIST_DIR, 'index.js'), indexTemplate),
104
- writeFile(resolve(DIST_DIR, 'index.esm.js'), indexESMTemplate),
105
- ])
106
-
107
- console.log('build success!')
108
- }
109
-
110
- commander.command('build').description('Build varlet icons from svg').action(build)
111
-
112
- commander.parse()
1
+ #!/usr/bin/env node
2
+
3
+ const webfont = require('webfont').default
4
+ const commander = require('commander')
5
+ const { writeFile, ensureDir, removeSync, readdirSync } = require('fs-extra')
6
+ const { resolve } = require('path')
7
+
8
+ const CWD = process.cwd()
9
+ const SVG_DIR = resolve(CWD, 'svg')
10
+ const DIST_DIR = resolve(CWD, 'dist')
11
+ const FONTS_DIR = resolve(DIST_DIR, 'fonts')
12
+ const CSS_DIR = resolve(DIST_DIR, 'css')
13
+ const formats = ['ttf', 'woff', 'woff2']
14
+
15
+ const config = require(resolve(CWD, 'varlet-icons.config.js'))
16
+
17
+ async function build() {
18
+ const { base64, publicPath, namespace, fontName, fileName, fontWeight = 'normal', fontStyle = 'normal' } = config
19
+
20
+ const { ttf, woff, woff2 } = await webfont({
21
+ files: `${SVG_DIR}/*.svg`,
22
+ fontName,
23
+ formats,
24
+ fontHeight: 512,
25
+ descent: 64,
26
+ })
27
+
28
+ removeSync(DIST_DIR)
29
+
30
+ await Promise.all([ensureDir(FONTS_DIR), ensureDir(CSS_DIR)])
31
+
32
+ const icons = readdirSync(SVG_DIR).map((svgName) => {
33
+ const i = svgName.indexOf('-')
34
+ const extIndex = svgName.lastIndexOf('.')
35
+
36
+ return {
37
+ name: svgName.slice(i + 1, extIndex),
38
+ pointCode: svgName.slice(1, i),
39
+ }
40
+ })
41
+
42
+ const iconNames = icons.map((iconName) => ` "${iconName.name}"`)
43
+
44
+ const indexTemplate = `\
45
+ module.exports = [
46
+ ${iconNames.join(',\n')}
47
+ ]
48
+ `
49
+
50
+ const indexESMTemplate = `\
51
+ export default [
52
+ ${iconNames.join(',\n')}
53
+ ]
54
+ `
55
+
56
+ const cssTemplate = `\
57
+ @font-face {
58
+ font-family: "${fontName}";
59
+ src: url("${
60
+ base64
61
+ ? `data:application/font-woff2;charset=utf-8;base64,${Buffer.from(woff2).toString('base64')}`
62
+ : `${publicPath}${fileName}-webfont.woff2`
63
+ }") format("woff2"),
64
+ url("${
65
+ base64
66
+ ? `data:application/font-woff;charset=utf-8;base64,${woff.toString('base64')}`
67
+ : `${publicPath}${fileName}-webfont.woff`
68
+ }") format("woff"),
69
+ url("${
70
+ base64
71
+ ? `data:font/truetype;charset=utf-8;base64,${ttf.toString('base64')}`
72
+ : `${publicPath}${fileName}-webfont.ttf`
73
+ }") format("truetype");
74
+ font-weight: ${fontWeight};
75
+ font-style: ${fontStyle};
76
+ }
77
+
78
+ .${namespace}--set,
79
+ .${namespace}--set::before {
80
+ position: relative;
81
+ display: inline-block;
82
+ font: normal normal normal 14px/1 "${fontName}";
83
+ font-size: inherit;
84
+ text-rendering: auto;
85
+ -webkit-font-smoothing: antialiased;
86
+ }
87
+
88
+ ${icons
89
+ .map((icon) => {
90
+ return `.${namespace}-${icon.name}::before {
91
+ content: "\\${icon.pointCode}";
92
+ }`
93
+ })
94
+ .join('\n\n')}
95
+ `
96
+
97
+ await Promise.all([
98
+ writeFile(resolve(FONTS_DIR, `${fileName}-webfont.ttf`), ttf),
99
+ writeFile(resolve(FONTS_DIR, `${fileName}-webfont.woff`), woff),
100
+ writeFile(resolve(FONTS_DIR, `${fileName}-webfont.woff2`), woff2),
101
+ writeFile(resolve(CSS_DIR, `${fileName}.css`), cssTemplate),
102
+ writeFile(resolve(CSS_DIR, `${fileName}.less`), cssTemplate),
103
+ writeFile(resolve(DIST_DIR, 'index.js'), indexTemplate),
104
+ writeFile(resolve(DIST_DIR, 'index.esm.js'), indexESMTemplate),
105
+ ])
106
+
107
+ console.log('build success!')
108
+ }
109
+
110
+ commander.command('build').description('Build varlet icons from svg').action(build)
111
+
112
+ commander.parse()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@varlet/icons",
3
- "version": "1.27.20",
3
+ "version": "2.0.0-alpha.1663499244572",
4
4
  "description": "Icons of varlet",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",