@rokkit/icons 1.0.0-next.114 → 1.0.0-next.116
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 +3 -2
- package/src/convert.js +32 -21
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rokkit/icons",
|
|
3
|
-
"version": "1.0.0-next.
|
|
3
|
+
"version": "1.0.0-next.116",
|
|
4
4
|
"description": "A minimal icon set for use in applications.",
|
|
5
5
|
"author": "Jerry Thomas <me@jerrythomas.name>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"./components.json": "./lib/components.json",
|
|
41
41
|
"./auth.json": "./lib/auth.json",
|
|
42
42
|
"./app.json": "./lib/app.json",
|
|
43
|
-
".": "./lib/base.json"
|
|
43
|
+
".": "./lib/base.json",
|
|
44
|
+
"./utils": "./src/convert.js"
|
|
44
45
|
}
|
|
45
46
|
}
|
package/src/convert.js
CHANGED
|
@@ -7,7 +7,14 @@ import {
|
|
|
7
7
|
exportJSONPackage
|
|
8
8
|
} from '@iconify/tools'
|
|
9
9
|
import fs from 'fs'
|
|
10
|
+
import { pick } from 'ramda'
|
|
11
|
+
import pkg from '../package.json' with { type: 'json' }
|
|
10
12
|
|
|
13
|
+
const PACKAGE_INFO = {
|
|
14
|
+
namespace: '@rokkit',
|
|
15
|
+
version: pkg.version,
|
|
16
|
+
homepage: 'https://github.com/jerrythomas/rokkit'
|
|
17
|
+
}
|
|
11
18
|
/**
|
|
12
19
|
* Clean up and optimise SVG icon
|
|
13
20
|
*
|
|
@@ -39,20 +46,8 @@ export function cleanAndOptimizeIcon(svg, color) {
|
|
|
39
46
|
*/
|
|
40
47
|
export function processIcons(iconSet, color) {
|
|
41
48
|
iconSet.forEach((name) => {
|
|
42
|
-
// There should not be any type other than icon
|
|
43
|
-
// if (type !== 'icon') {
|
|
44
|
-
// return
|
|
45
|
-
// }
|
|
46
|
-
|
|
47
49
|
const svg = iconSet.toSVG(name)
|
|
48
|
-
// Since we are processing from within the list, there is no need to check for invalid icons
|
|
49
|
-
// if (!svg) {
|
|
50
|
-
// // Invalid icon
|
|
51
|
-
// iconSet.remove(name)
|
|
52
|
-
// return
|
|
53
|
-
// }
|
|
54
50
|
|
|
55
|
-
// Clean up and optimise icons
|
|
56
51
|
try {
|
|
57
52
|
cleanAndOptimizeIcon(svg, color)
|
|
58
53
|
} catch (err) {
|
|
@@ -62,20 +57,18 @@ export function processIcons(iconSet, color) {
|
|
|
62
57
|
return
|
|
63
58
|
}
|
|
64
59
|
|
|
65
|
-
// Update icon
|
|
66
60
|
iconSet.fromSVG(name, svg)
|
|
67
61
|
})
|
|
68
62
|
}
|
|
69
63
|
|
|
70
64
|
/**
|
|
71
|
-
* Convert icons
|
|
65
|
+
* Convert individual icons into a json bundle
|
|
72
66
|
*
|
|
73
67
|
* @param {string} folder Folder with icons
|
|
74
68
|
* @param {string} prefix Prefix for icon set
|
|
75
69
|
* @param {boolean} color True if color should be preserved
|
|
76
70
|
*/
|
|
77
|
-
export async function
|
|
78
|
-
// Import icons
|
|
71
|
+
export async function bundle(folder, prefix, color = false, location = '.') {
|
|
79
72
|
const iconSet = await importDirectory(folder, { prefix })
|
|
80
73
|
|
|
81
74
|
// Validate, clean up, fix palette and optimise
|
|
@@ -83,15 +76,33 @@ export async function convert(folder, prefix, color = false) {
|
|
|
83
76
|
|
|
84
77
|
// Export
|
|
85
78
|
const collection = JSON.stringify(iconSet.export(), null, 2)
|
|
86
|
-
fs.writeFileSync(
|
|
79
|
+
fs.writeFileSync(`${location}/${prefix}.json`, collection, 'utf8')
|
|
80
|
+
return iconSet
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Convert icons
|
|
84
|
+
*
|
|
85
|
+
* @param {string} folder Folder with icons
|
|
86
|
+
* @param {string} prefix Prefix for icon set
|
|
87
|
+
* @param {boolean} color True if color should be preserved
|
|
88
|
+
*/
|
|
89
|
+
export async function convert(folder, prefix, color = false) {
|
|
90
|
+
// Import icons
|
|
91
|
+
// const iconSet = await importDirectory(folder, { prefix })
|
|
92
|
+
|
|
93
|
+
// // Validate, clean up, fix palette and optimise
|
|
94
|
+
// processIcons(iconSet, color)
|
|
95
|
+
|
|
96
|
+
// // Export
|
|
97
|
+
// const collection = JSON.stringify(iconSet.export(), null, 2)
|
|
98
|
+
// fs.writeFileSync(`./lib/${prefix}.json`, collection, 'utf8')
|
|
99
|
+
const iconSet = await bundle(folder, prefix, color, './lib')
|
|
87
100
|
const target = `./lib/${iconSet.prefix}`
|
|
88
101
|
await exportJSONPackage(iconSet, {
|
|
89
102
|
target,
|
|
90
103
|
package: {
|
|
91
|
-
name:
|
|
92
|
-
version
|
|
93
|
-
bugs: 'https://github.com/jerrythomas/rokkit/issues',
|
|
94
|
-
homepage: 'https://github.com/jerrythomas/rokkit'
|
|
104
|
+
name: `${PACKAGE_INFO.namespace}/${iconSet.prefix}`,
|
|
105
|
+
...pick(['version', 'homepage'], PACKAGE_INFO)
|
|
95
106
|
},
|
|
96
107
|
cleanup: true
|
|
97
108
|
})
|