@quasar/icongenie 4.0.0 → 5.0.0
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/README.md +7 -1
- package/bin/icongenie.js +22 -22
- package/lib/cmd/generate.js +36 -41
- package/lib/cmd/help.js +1 -1
- package/lib/cmd/profile.js +34 -38
- package/lib/cmd/verify.js +18 -17
- package/lib/generators/icns.js +7 -3
- package/lib/generators/ico.js +7 -3
- package/lib/generators/index.js +0 -1
- package/lib/generators/png.js +7 -6
- package/lib/generators/splashscreen.js +6 -12
- package/lib/generators/svg.js +3 -4
- package/lib/modes/index.js +1 -8
- package/lib/modes/{quasar-app-v2 → v2}/bex.js +1 -2
- package/lib/modes/{quasar-app-v1 → v2}/capacitor.js +28 -35
- package/lib/modes/{quasar-app-v1 → v2}/cordova.js +40 -47
- package/lib/modes/v2/electron.js +32 -0
- package/lib/modes/{quasar-app-v1 → v2}/index.js +0 -1
- package/lib/modes/v2/pwa.js +71 -0
- package/lib/modes/{quasar-app-v2 → v2}/spa.js +1 -2
- package/lib/modes/{quasar-app-v1 → v2}/ssr.js +1 -2
- package/lib/mount/index.js +4 -7
- package/lib/mount/mount-cordova.js +71 -63
- package/lib/mount/mount-tag.js +3 -6
- package/lib/runner/generate.js +57 -55
- package/lib/runner/profile.js +18 -26
- package/lib/runner/verify.js +29 -27
- package/lib/utils/app-paths.js +8 -9
- package/lib/utils/default-params.js +0 -1
- package/lib/utils/filter-argv-params.js +3 -4
- package/lib/utils/get-argv.js +47 -0
- package/lib/utils/get-assets-files.js +9 -12
- package/lib/utils/get-compression.js +31 -19
- package/lib/utils/get-file-size.js +5 -6
- package/lib/utils/get-files-options.js +18 -21
- package/lib/utils/get-png-size.js +7 -11
- package/lib/utils/get-profile-content.js +3 -7
- package/lib/utils/get-profile-files.js +10 -13
- package/lib/utils/get-square-icon.js +5 -4
- package/lib/utils/logger.js +6 -7
- package/lib/utils/merge-objects.js +5 -6
- package/lib/utils/node-version-check.js +11 -11
- package/lib/utils/package-json.js +1 -5
- package/lib/utils/parse-argv.js +63 -74
- package/lib/utils/spawn-sync.js +10 -10
- package/lib/utils/validate-profile-object.js +34 -27
- package/package.json +46 -48
- package/samples/icongenie-profile.json +9 -17
- package/.editorconfig +0 -13
- package/.eslintignore +0 -1
- package/.eslintrc.cjs +0 -50
- package/lib/modes/quasar-app-v1/bex.js +0 -9
- package/lib/modes/quasar-app-v1/electron.js +0 -24
- package/lib/modes/quasar-app-v1/pwa.js +0 -74
- package/lib/modes/quasar-app-v1/spa.js +0 -17
- package/lib/modes/quasar-app-v2/capacitor.js +0 -155
- package/lib/modes/quasar-app-v2/cordova.js +0 -159
- package/lib/modes/quasar-app-v2/electron.js +0 -24
- package/lib/modes/quasar-app-v2/index.js +0 -45
- package/lib/modes/quasar-app-v2/pwa.js +0 -74
- package/lib/modes/quasar-app-v2/ssr.js +0 -4
package/lib/runner/verify.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
import { existsSync } from 'node:fs'
|
|
3
2
|
import { green, red, underline } from 'kolorist'
|
|
4
3
|
|
|
@@ -14,7 +13,7 @@ import { mergeObjects } from '../utils/merge-objects.js'
|
|
|
14
13
|
import { getProfileContent } from '../utils/get-profile-content.js'
|
|
15
14
|
import { validateProfileObject } from '../utils/validate-profile-object.js'
|
|
16
15
|
|
|
17
|
-
function getFileStatus
|
|
16
|
+
function getFileStatus(file) {
|
|
18
17
|
if (!existsSync(file.absoluteName)) {
|
|
19
18
|
return red('ERROR: missing!')
|
|
20
19
|
}
|
|
@@ -27,53 +26,55 @@ function getFileStatus (file) {
|
|
|
27
26
|
}
|
|
28
27
|
|
|
29
28
|
if (width !== file.width || height !== file.height) {
|
|
30
|
-
return red(`ERROR: incorrect resolution! ${
|
|
29
|
+
return red(`ERROR: incorrect resolution! ${width}x${height}`)
|
|
31
30
|
}
|
|
32
31
|
}
|
|
33
32
|
|
|
34
33
|
return green('SIZE OK')
|
|
35
34
|
}
|
|
36
35
|
|
|
37
|
-
function printMode
|
|
38
|
-
console.log(` ${
|
|
36
|
+
function printMode(modeName, files) {
|
|
37
|
+
console.log(` ${green(underline(`Mode ${modeName.toUpperCase()}`))} \n`)
|
|
39
38
|
|
|
40
39
|
files.forEach(file => {
|
|
41
|
-
console.log(
|
|
40
|
+
console.log(
|
|
41
|
+
` ${getFileStatus(file)} - ${(file.generator + ':').padEnd(13, ' ')} ${file.relativeName} ${verifyMount(file)}`
|
|
42
|
+
)
|
|
42
43
|
})
|
|
43
44
|
|
|
44
45
|
console.log()
|
|
45
46
|
}
|
|
46
47
|
|
|
47
|
-
function printBanner
|
|
48
|
+
function printBanner(assetsOf, params) {
|
|
48
49
|
console.log(` VERIFYING with the following options:
|
|
49
50
|
================
|
|
50
|
-
Root folder..... ${
|
|
51
|
-
Assets of....... ${
|
|
52
|
-
Assets filter... ${
|
|
51
|
+
Root folder..... ${green(appDir)}
|
|
52
|
+
Assets of....... ${green(assetsOf)}
|
|
53
|
+
Assets filter... ${!params.filter ? 'none' : green(params.filter)}
|
|
53
54
|
================
|
|
54
55
|
`)
|
|
55
56
|
}
|
|
56
57
|
|
|
57
|
-
function parseAssets
|
|
58
|
+
function parseAssets(assets, include) {
|
|
58
59
|
const filesMap = []
|
|
59
|
-
|
|
60
|
+
const assetsOf = []
|
|
60
61
|
|
|
61
62
|
if (include) {
|
|
62
|
-
const embeddedModes = include.filter(
|
|
63
|
-
|
|
63
|
+
const embeddedModes = include.filter(mode =>
|
|
64
|
+
existsSync(resolveDir(modes[mode].folder))
|
|
64
65
|
)
|
|
65
66
|
|
|
66
67
|
embeddedModes.forEach(mode => {
|
|
67
68
|
filesMap.push({
|
|
68
69
|
name: mode,
|
|
69
|
-
files: getAssetsFiles(modes[
|
|
70
|
+
files: getAssetsFiles(modes[mode].assets)
|
|
70
71
|
})
|
|
71
72
|
})
|
|
72
73
|
|
|
73
|
-
assetsOf
|
|
74
|
+
assetsOf.push(...embeddedModes)
|
|
74
75
|
}
|
|
75
76
|
|
|
76
|
-
if (assets && assets.length
|
|
77
|
+
if (assets && assets.length !== 0) {
|
|
77
78
|
filesMap.push({
|
|
78
79
|
name: 'profile assets',
|
|
79
80
|
files: getAssetsFiles(assets)
|
|
@@ -88,12 +89,14 @@ function parseAssets (assets, include) {
|
|
|
88
89
|
}
|
|
89
90
|
}
|
|
90
91
|
|
|
91
|
-
function verifyProfile
|
|
92
|
+
function verifyProfile(profile) {
|
|
92
93
|
const params = profile.params
|
|
93
94
|
const { assetsOf, filesMap } = parseAssets(profile.assets, params.include)
|
|
94
95
|
|
|
95
96
|
if (assetsOf.length === 0) {
|
|
96
|
-
warn(
|
|
97
|
+
warn(
|
|
98
|
+
`No assets to generate! No mode/include specified, filter too specific or the respective Quasar mode(s) are not installed`
|
|
99
|
+
)
|
|
97
100
|
return
|
|
98
101
|
}
|
|
99
102
|
|
|
@@ -104,20 +107,20 @@ function verifyProfile (profile) {
|
|
|
104
107
|
? entry.files.filter(file => file.generator === params.filter)
|
|
105
108
|
: entry.files
|
|
106
109
|
|
|
107
|
-
if (files.length
|
|
110
|
+
if (files.length !== 0) {
|
|
108
111
|
printMode(entry.name, files)
|
|
109
112
|
}
|
|
110
113
|
})
|
|
111
114
|
}
|
|
112
115
|
|
|
113
|
-
export function verify
|
|
116
|
+
export function verify(argv) {
|
|
114
117
|
const profile = {
|
|
115
118
|
params: {},
|
|
116
119
|
assets: []
|
|
117
120
|
}
|
|
118
121
|
|
|
119
122
|
if (argv.profile) {
|
|
120
|
-
parseArgv(argv, [
|
|
123
|
+
parseArgv(argv, ['profile'])
|
|
121
124
|
|
|
122
125
|
const userProfile = getProfileContent(argv.profile)
|
|
123
126
|
|
|
@@ -125,14 +128,13 @@ export function verify (argv) {
|
|
|
125
128
|
const { profile: _, ...params } = argv
|
|
126
129
|
|
|
127
130
|
profile.params = mergeObjects(userProfile.params, params)
|
|
128
|
-
parseArgv(profile.params, [
|
|
131
|
+
parseArgv(profile.params, ['include'])
|
|
129
132
|
}
|
|
130
133
|
if (userProfile.assets) {
|
|
131
134
|
profile.assets = userProfile.assets
|
|
132
135
|
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
parseArgv(argv, [ 'mode' ])
|
|
136
|
+
} else {
|
|
137
|
+
parseArgv(argv, ['mode'])
|
|
136
138
|
|
|
137
139
|
const { mode, ...params } = argv
|
|
138
140
|
|
|
@@ -140,7 +142,7 @@ export function verify (argv) {
|
|
|
140
142
|
profile.params.include = mode
|
|
141
143
|
}
|
|
142
144
|
|
|
143
|
-
parseArgv(profile.params, [
|
|
145
|
+
parseArgv(profile.params, ['filter'])
|
|
144
146
|
|
|
145
147
|
// final thorough validation
|
|
146
148
|
validateProfileObject(profile)
|
package/lib/utils/app-paths.js
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
|
|
2
1
|
import { existsSync } from 'node:fs'
|
|
3
|
-
import {
|
|
2
|
+
import { join, normalize, sep } from 'node:path'
|
|
4
3
|
|
|
5
4
|
import { fatal } from './logger.js'
|
|
6
5
|
|
|
7
|
-
function getAppInfo
|
|
6
|
+
function getAppInfo() {
|
|
8
7
|
let appDir = process.cwd()
|
|
9
8
|
|
|
10
|
-
while (appDir.length && appDir
|
|
9
|
+
while (appDir.length !== 0 && appDir.at(-1) !== sep) {
|
|
11
10
|
if (
|
|
12
|
-
existsSync(join(appDir, 'quasar.config.js'))
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
existsSync(join(appDir, 'quasar.config.js')) ||
|
|
12
|
+
existsSync(join(appDir, 'quasar.config.mjs')) ||
|
|
13
|
+
existsSync(join(appDir, 'quasar.config.ts')) ||
|
|
14
|
+
existsSync(join(appDir, 'quasar.config.cjs')) ||
|
|
15
|
+
existsSync(join(appDir, 'quasar.conf.js')) // legacy
|
|
17
16
|
) {
|
|
18
17
|
return appDir
|
|
19
18
|
}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
export function filterArgvParams (argv) {
|
|
1
|
+
export function filterArgvParams(argv) {
|
|
3
2
|
const params = {}
|
|
4
3
|
|
|
5
4
|
Object.keys(argv).forEach(key => {
|
|
6
5
|
if (key.length > 1 && key !== 'help') {
|
|
7
6
|
// kebab to camel case
|
|
8
|
-
const prop = key.
|
|
7
|
+
const prop = key.replaceAll(/(-\w)/g, m => m[1].toUpperCase())
|
|
9
8
|
|
|
10
|
-
params[
|
|
9
|
+
params[prop] = argv[key]
|
|
11
10
|
}
|
|
12
11
|
})
|
|
13
12
|
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { parseArgs } from 'node:util'
|
|
2
|
+
import { warn } from './logger.js'
|
|
3
|
+
|
|
4
|
+
function kebabToCamelCase(str) {
|
|
5
|
+
return str
|
|
6
|
+
.split('-')
|
|
7
|
+
.map((part, index) =>
|
|
8
|
+
index === 0 ? part : part.charAt(0).toUpperCase() + part.slice(1)
|
|
9
|
+
)
|
|
10
|
+
.join('')
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function parseValues(values) {
|
|
14
|
+
return Object.keys(values).reduce((acc, key) => {
|
|
15
|
+
acc[kebabToCamelCase(key)] = values[key]
|
|
16
|
+
return acc
|
|
17
|
+
}, {})
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function getArgv(options, { strict = true } = {}) {
|
|
21
|
+
try {
|
|
22
|
+
const { values, positionals } = parseArgs({
|
|
23
|
+
options,
|
|
24
|
+
strict,
|
|
25
|
+
allowPositionals: true
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
return { ...parseValues(values), _: positionals }
|
|
29
|
+
} catch (err) {
|
|
30
|
+
return {
|
|
31
|
+
help: true,
|
|
32
|
+
_: [],
|
|
33
|
+
|
|
34
|
+
// Should be handled if (argv.help) in the caller
|
|
35
|
+
__warn() {
|
|
36
|
+
console.error(err)
|
|
37
|
+
warn(
|
|
38
|
+
err?.code === 'ERR_PARSE_ARGS_UNKNOWN_OPTION'
|
|
39
|
+
? err.message
|
|
40
|
+
: 'Unknown error while parsing arguments'
|
|
41
|
+
)
|
|
42
|
+
warn()
|
|
43
|
+
process.exit(1)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
|
|
2
1
|
import { join } from 'node:path'
|
|
3
2
|
|
|
4
3
|
import { appDir } from './app-paths.js'
|
|
5
4
|
|
|
6
5
|
const tagRegex = /\{(.*?)\}/g
|
|
7
6
|
|
|
8
|
-
export function getAssetsFiles
|
|
7
|
+
export function getAssetsFiles(assets) {
|
|
9
8
|
const list = []
|
|
10
9
|
|
|
11
10
|
assets.forEach(({ sizes, ...props }) => {
|
|
@@ -13,23 +12,18 @@ export function getAssetsFiles (assets) {
|
|
|
13
12
|
sizes.forEach(size => {
|
|
14
13
|
const isArray = Array.isArray(size)
|
|
15
14
|
|
|
16
|
-
const [
|
|
17
|
-
? size
|
|
18
|
-
: [ size, size ]
|
|
15
|
+
const [width, height] = isArray ? size : [size, size]
|
|
19
16
|
|
|
20
|
-
const replacer = isArray
|
|
21
|
-
? `${ width }x${ height }`
|
|
22
|
-
: width
|
|
17
|
+
const replacer = isArray ? `${width}x${height}` : width
|
|
23
18
|
|
|
24
19
|
list.push({
|
|
25
20
|
...props,
|
|
26
|
-
name: props.name.
|
|
21
|
+
name: props.name.replaceAll('{size}', replacer),
|
|
27
22
|
width,
|
|
28
23
|
height
|
|
29
24
|
})
|
|
30
25
|
})
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
26
|
+
} else {
|
|
33
27
|
list.push(props)
|
|
34
28
|
}
|
|
35
29
|
})
|
|
@@ -42,7 +36,10 @@ export function getAssetsFiles (assets) {
|
|
|
42
36
|
}
|
|
43
37
|
|
|
44
38
|
if (tag) {
|
|
45
|
-
file.tag = tag.replace(
|
|
39
|
+
file.tag = tag.replace(
|
|
40
|
+
tagRegex,
|
|
41
|
+
(_, p) => file[p === 'size' ? 'width' : p]
|
|
42
|
+
)
|
|
46
43
|
}
|
|
47
44
|
|
|
48
45
|
return file
|
|
@@ -1,47 +1,59 @@
|
|
|
1
|
-
|
|
2
1
|
import { dirname } from 'node:path'
|
|
3
2
|
|
|
4
3
|
import imagemin from 'imagemin'
|
|
5
4
|
import pngquant from 'imagemin-pngquant'
|
|
6
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
BEZIER,
|
|
7
|
+
BICUBIC,
|
|
8
|
+
BICUBIC2,
|
|
9
|
+
BILINEAR,
|
|
10
|
+
HERMITE,
|
|
11
|
+
NEAREST_NEIGHBOR
|
|
12
|
+
} from 'png2icons'
|
|
7
13
|
|
|
8
|
-
export function getIcoCompression
|
|
14
|
+
export function getIcoCompression(quality) {
|
|
9
15
|
switch (quality) {
|
|
10
16
|
case 1:
|
|
11
|
-
case 2:
|
|
12
|
-
return NEAREST_NEIGHBOR
|
|
17
|
+
case 2: {
|
|
18
|
+
return NEAREST_NEIGHBOR
|
|
19
|
+
} // fastest, mediocre to OK quality
|
|
13
20
|
case 3:
|
|
14
|
-
case 4:
|
|
15
|
-
return BILINEAR
|
|
21
|
+
case 4: {
|
|
22
|
+
return BILINEAR
|
|
23
|
+
} // fast, quality OK
|
|
16
24
|
case 5:
|
|
17
|
-
case 6:
|
|
18
|
-
return BICUBIC2
|
|
25
|
+
case 6: {
|
|
26
|
+
return BICUBIC2
|
|
27
|
+
} // fast, good to very good quality
|
|
19
28
|
case 7:
|
|
20
|
-
case 8:
|
|
21
|
-
return BICUBIC
|
|
29
|
+
case 8: {
|
|
30
|
+
return BICUBIC
|
|
31
|
+
} // slower, good to very good quality
|
|
22
32
|
case 9:
|
|
23
|
-
case 10:
|
|
24
|
-
return BEZIER
|
|
33
|
+
case 10: {
|
|
34
|
+
return BEZIER
|
|
35
|
+
} // quite slow, high quality
|
|
25
36
|
case 11:
|
|
26
|
-
case 12:
|
|
27
|
-
return HERMITE
|
|
37
|
+
case 12: {
|
|
38
|
+
return HERMITE
|
|
39
|
+
} // quite slow, high quality
|
|
28
40
|
}
|
|
29
41
|
}
|
|
30
42
|
|
|
31
|
-
export function getPngCompression
|
|
43
|
+
export function getPngCompression(quality) {
|
|
32
44
|
if (quality === 12) {
|
|
33
45
|
return () => {}
|
|
34
46
|
}
|
|
35
47
|
|
|
36
48
|
const plugins = [
|
|
37
49
|
pngquant({
|
|
38
|
-
quality: [
|
|
50
|
+
quality: [0.6, 0.8],
|
|
39
51
|
speed: 12 - quality // 1 - 11
|
|
40
52
|
})
|
|
41
53
|
]
|
|
42
54
|
|
|
43
|
-
return
|
|
44
|
-
return imagemin([
|
|
55
|
+
return function minifyFile(filename) {
|
|
56
|
+
return imagemin([filename], {
|
|
45
57
|
destination: dirname(filename),
|
|
46
58
|
plugins
|
|
47
59
|
})
|
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
|
|
2
1
|
import { statSync } from 'node:fs'
|
|
3
2
|
|
|
4
|
-
const units = [
|
|
3
|
+
const units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB']
|
|
5
4
|
|
|
6
|
-
function humanStorageSize
|
|
5
|
+
function humanStorageSize(bytes) {
|
|
7
6
|
let u = 0
|
|
8
7
|
|
|
9
|
-
while (parseInt(bytes, 10) >= 1024 && u < units.length - 1) {
|
|
8
|
+
while (Number.parseInt(bytes, 10) >= 1024 && u < units.length - 1) {
|
|
10
9
|
bytes /= 1024
|
|
11
10
|
++u
|
|
12
11
|
}
|
|
13
12
|
|
|
14
|
-
return `${
|
|
13
|
+
return `${bytes.toFixed(1)}${units[u]}`
|
|
15
14
|
}
|
|
16
15
|
|
|
17
|
-
export function getFileSize
|
|
16
|
+
export function getFileSize(filename) {
|
|
18
17
|
return humanStorageSize(statSync(filename).size)
|
|
19
18
|
}
|
|
@@ -1,26 +1,25 @@
|
|
|
1
|
-
|
|
2
1
|
import sharp from 'sharp'
|
|
3
2
|
|
|
4
|
-
import {
|
|
3
|
+
import { getIcoCompression, getPngCompression } from './get-compression.js'
|
|
5
4
|
|
|
6
|
-
function getRgbColor
|
|
5
|
+
function getRgbColor(color) {
|
|
7
6
|
let hex = color.replace(/^#/, '')
|
|
8
7
|
|
|
9
8
|
if (hex.length === 3) {
|
|
10
|
-
hex = hex[
|
|
9
|
+
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2]
|
|
11
10
|
}
|
|
12
11
|
|
|
13
|
-
const num = parseInt(hex, 16)
|
|
12
|
+
const num = Number.parseInt(hex, 16)
|
|
14
13
|
|
|
15
14
|
return {
|
|
16
15
|
r: num >> 16,
|
|
17
|
-
g: num >> 8 & 255,
|
|
16
|
+
g: (num >> 8) & 255,
|
|
18
17
|
b: num & 255,
|
|
19
18
|
alpha: 1
|
|
20
19
|
}
|
|
21
20
|
}
|
|
22
21
|
|
|
23
|
-
export async function getFilesOptions
|
|
22
|
+
export async function getFilesOptions({
|
|
24
23
|
quality,
|
|
25
24
|
padding,
|
|
26
25
|
|
|
@@ -32,29 +31,27 @@ export async function getFilesOptions ({
|
|
|
32
31
|
|
|
33
32
|
...opts
|
|
34
33
|
}) {
|
|
35
|
-
const qualityLevel = parseInt(quality, 10)
|
|
34
|
+
const qualityLevel = Number.parseInt(quality, 10)
|
|
36
35
|
const sharpIcon = sharp(icon).withMetadata()
|
|
37
36
|
const sharpBackground = background
|
|
38
37
|
? sharp(background).withMetadata()
|
|
39
38
|
: sharp({
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
39
|
+
create: {
|
|
40
|
+
width: 12,
|
|
41
|
+
height: 12,
|
|
42
|
+
channels: 4,
|
|
43
|
+
background: { r: 0, g: 0, b: 0, alpha: 0 }
|
|
44
|
+
}
|
|
45
|
+
})
|
|
47
46
|
|
|
48
47
|
if (opts.skipTrim !== true) {
|
|
49
48
|
sharpIcon.trim()
|
|
50
49
|
}
|
|
51
50
|
|
|
52
51
|
const computedPadding = padding
|
|
53
|
-
?
|
|
54
|
-
padding
|
|
55
|
-
|
|
56
|
-
: { horiz: padding[ 0 ], vert: padding[ 1 ] }
|
|
57
|
-
)
|
|
52
|
+
? padding.length === 1
|
|
53
|
+
? { horiz: padding[0], vert: padding[0] }
|
|
54
|
+
: { horiz: padding[0], vert: padding[1] }
|
|
58
55
|
: { horiz: 0, vert: 0 }
|
|
59
56
|
|
|
60
57
|
return {
|
|
@@ -66,7 +63,7 @@ export async function getFilesOptions ({
|
|
|
66
63
|
|
|
67
64
|
compression: {
|
|
68
65
|
ico: getIcoCompression(qualityLevel),
|
|
69
|
-
png: getPngCompression(qualityLevel)
|
|
66
|
+
png: getPngCompression(qualityLevel)
|
|
70
67
|
},
|
|
71
68
|
|
|
72
69
|
padding: computedPadding,
|
|
@@ -1,25 +1,21 @@
|
|
|
1
|
-
|
|
2
1
|
import { readChunkSync } from 'read-chunk'
|
|
3
2
|
import isPng from 'is-png'
|
|
4
3
|
|
|
5
4
|
// "fried" png's - http://www.jongware.com/pngdefry.html
|
|
6
5
|
const friedChunk = 'CgBI'
|
|
7
6
|
|
|
8
|
-
function getSize
|
|
9
|
-
const offset =
|
|
10
|
-
? [
|
|
11
|
-
: [ 20, 16 ]
|
|
7
|
+
function getSize(buffer) {
|
|
8
|
+
const offset =
|
|
9
|
+
buffer.toString('ascii', 12, 16) === friedChunk ? [36, 32] : [20, 16]
|
|
12
10
|
|
|
13
11
|
return {
|
|
14
|
-
height: buffer.readUInt32BE(offset[
|
|
15
|
-
width: buffer.readUInt32BE(offset[
|
|
12
|
+
height: buffer.readUInt32BE(offset[0]),
|
|
13
|
+
width: buffer.readUInt32BE(offset[1])
|
|
16
14
|
}
|
|
17
15
|
}
|
|
18
16
|
|
|
19
|
-
export function getPngSize
|
|
17
|
+
export function getPngSize(file) {
|
|
20
18
|
const buffer = readChunkSync(file, { startPosition: 0, length: 40 })
|
|
21
19
|
|
|
22
|
-
return isPng(buffer) !== true
|
|
23
|
-
? { width: 0, height: 0 }
|
|
24
|
-
: getSize(buffer)
|
|
20
|
+
return isPng(buffer) !== true ? { width: 0, height: 0 } : getSize(buffer)
|
|
25
21
|
}
|
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
|
|
2
1
|
import { resolve } from 'node:path'
|
|
3
2
|
import { readFileSync } from 'node:fs'
|
|
4
3
|
|
|
5
4
|
import { warn } from './logger.js'
|
|
6
5
|
import { appDir } from './app-paths.js'
|
|
7
6
|
|
|
8
|
-
export function getProfileContent
|
|
7
|
+
export function getProfileContent(profileFile) {
|
|
9
8
|
const file = resolve(appDir, profileFile)
|
|
10
9
|
|
|
11
10
|
try {
|
|
12
|
-
return JSON.parse(
|
|
13
|
-
|
|
14
|
-
)
|
|
15
|
-
}
|
|
16
|
-
catch (err) {
|
|
11
|
+
return JSON.parse(readFileSync(file, 'utf8'))
|
|
12
|
+
} catch (err) {
|
|
17
13
|
warn(`Specified profile file has a syntax error`)
|
|
18
14
|
console.error(err)
|
|
19
15
|
process.exit(1)
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
|
|
2
1
|
import { basename } from 'node:path'
|
|
3
|
-
import
|
|
2
|
+
import { globSync } from 'tinyglobby'
|
|
4
3
|
import { lstatSync } from 'node:fs'
|
|
5
4
|
|
|
6
5
|
import { warn } from '../utils/logger.js'
|
|
7
6
|
|
|
8
|
-
function parseFolder
|
|
9
|
-
const profileFiles =
|
|
7
|
+
function parseFolder(folder) {
|
|
8
|
+
const profileFiles = globSync(`icongenie-*.json`, {
|
|
10
9
|
cwd: folder,
|
|
11
10
|
deep: 1,
|
|
12
11
|
absolute: true
|
|
@@ -15,19 +14,17 @@ function parseFolder (folder) {
|
|
|
15
14
|
const numberOfFiles = profileFiles.length
|
|
16
15
|
|
|
17
16
|
if (numberOfFiles === 0) {
|
|
18
|
-
warn(`No icongenie-*.json files detected in "${
|
|
17
|
+
warn(`No icongenie-*.json files detected in "${folder}" folder!`)
|
|
19
18
|
process.exit(1)
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
console.log(` Detected ${
|
|
23
|
-
console.log(` * ${
|
|
21
|
+
console.log(` Detected ${numberOfFiles} JSON profile file(s):\n`)
|
|
22
|
+
console.log(` * ${folder}`)
|
|
24
23
|
|
|
25
24
|
profileFiles.forEach((file, index) => {
|
|
26
|
-
const prefix = index + 1 < profileFiles.length
|
|
27
|
-
? `├──`
|
|
28
|
-
: `└──`
|
|
25
|
+
const prefix = index + 1 < profileFiles.length ? `├──` : `└──`
|
|
29
26
|
|
|
30
|
-
console.log(` ${
|
|
27
|
+
console.log(` ${prefix} ${basename(file)}`)
|
|
31
28
|
})
|
|
32
29
|
|
|
33
30
|
console.log()
|
|
@@ -35,8 +32,8 @@ function parseFolder (folder) {
|
|
|
35
32
|
return profileFiles
|
|
36
33
|
}
|
|
37
34
|
|
|
38
|
-
export function getProfileFiles
|
|
35
|
+
export function getProfileFiles(profileParam) {
|
|
39
36
|
return lstatSync(profileParam).isDirectory()
|
|
40
37
|
? parseFolder(profileParam)
|
|
41
|
-
: [
|
|
38
|
+
: [profileParam]
|
|
42
39
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
2
1
|
import { warn } from '../utils/logger.js'
|
|
3
2
|
|
|
4
|
-
export function getSquareIcon
|
|
3
|
+
export function getSquareIcon({
|
|
5
4
|
file,
|
|
6
5
|
icon,
|
|
7
6
|
size,
|
|
@@ -25,8 +24,10 @@ export function getSquareIcon ({
|
|
|
25
24
|
corrections.push('height')
|
|
26
25
|
}
|
|
27
26
|
|
|
28
|
-
if (corrections.length
|
|
29
|
-
warn(
|
|
27
|
+
if (corrections.length !== 0) {
|
|
28
|
+
warn(
|
|
29
|
+
`Correction on padding for ${file.relativeName} due to padding exceeding file's dimension of ${size}x${size}px`
|
|
30
|
+
)
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
img.resize({
|
package/lib/utils/logger.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
import { green, red } from 'kolorist'
|
|
3
2
|
|
|
4
3
|
const banner = '*'
|
|
@@ -6,15 +5,15 @@ const banner = '*'
|
|
|
6
5
|
const logBanner = green(banner)
|
|
7
6
|
const warnBanner = red(banner)
|
|
8
7
|
|
|
9
|
-
export function log
|
|
10
|
-
console.log(msg ? ` ${
|
|
8
|
+
export function log(msg) {
|
|
9
|
+
console.log(msg ? ` ${logBanner} ${msg}` : '')
|
|
11
10
|
}
|
|
12
11
|
|
|
13
|
-
export function warn
|
|
14
|
-
console.warn(msg ? ` ${
|
|
12
|
+
export function warn(msg) {
|
|
13
|
+
console.warn(msg ? ` ${warnBanner} ⚠️ ${msg}\n` : '')
|
|
15
14
|
}
|
|
16
15
|
|
|
17
|
-
export function fatal
|
|
18
|
-
console.error(msg ? ` ${
|
|
16
|
+
export function fatal(msg) {
|
|
17
|
+
console.error(msg ? ` ${warnBanner} ⚠️ ${msg}` : '')
|
|
19
18
|
process.exit(1)
|
|
20
19
|
}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
export function mergeObjects () {
|
|
1
|
+
export function mergeObjects(...args) {
|
|
3
2
|
const base = {}
|
|
4
3
|
|
|
5
|
-
for (let i = 0; i <
|
|
6
|
-
const obj =
|
|
4
|
+
for (let i = 0; i < args.length; i++) {
|
|
5
|
+
const obj = args[i]
|
|
7
6
|
|
|
8
7
|
Object.keys(obj).forEach(key => {
|
|
9
|
-
if (obj[
|
|
10
|
-
base[
|
|
8
|
+
if (obj[key] !== void 0) {
|
|
9
|
+
base[key] = obj[key]
|
|
11
10
|
}
|
|
12
11
|
})
|
|
13
12
|
}
|