@quasar/icongenie 2.5.3 → 3.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/.eslintignore +1 -0
- package/.eslintrc.cjs +50 -0
- package/bin/{icongenie → icongenie.js} +11 -11
- package/lib/cmd/generate.js +26 -21
- package/lib/cmd/help.js +3 -1
- package/lib/cmd/profile.js +19 -15
- package/lib/cmd/verify.js +16 -13
- package/lib/generators/icns.js +5 -4
- package/lib/generators/ico.js +5 -4
- package/lib/generators/index.js +13 -6
- package/lib/generators/png.js +3 -2
- package/lib/generators/splashscreen.js +3 -2
- package/lib/generators/svg.js +6 -5
- package/lib/modes/index.js +8 -5
- package/lib/modes/quasar-app-v1/bex.js +2 -1
- package/lib/modes/quasar-app-v1/capacitor.js +11 -10
- package/lib/modes/quasar-app-v1/cordova.js +14 -13
- package/lib/modes/quasar-app-v1/electron.js +2 -1
- package/lib/modes/quasar-app-v1/index.js +16 -8
- package/lib/modes/quasar-app-v1/pwa.js +6 -5
- package/lib/modes/quasar-app-v1/spa.js +2 -1
- package/lib/modes/quasar-app-v1/ssr.js +3 -2
- package/lib/modes/quasar-app-v2/bex.js +2 -1
- package/lib/modes/quasar-app-v2/capacitor.js +11 -10
- package/lib/modes/quasar-app-v2/cordova.js +14 -13
- package/lib/modes/quasar-app-v2/electron.js +2 -1
- package/lib/modes/quasar-app-v2/index.js +16 -8
- package/lib/modes/quasar-app-v2/pwa.js +6 -5
- package/lib/modes/quasar-app-v2/spa.js +2 -1
- package/lib/modes/quasar-app-v2/ssr.js +3 -2
- package/lib/mount/index.js +5 -4
- package/lib/mount/mount-cordova.js +38 -30
- package/lib/mount/mount-tag.js +3 -2
- package/lib/runner/generate.js +37 -36
- package/lib/runner/profile.js +12 -11
- package/lib/runner/verify.js +23 -22
- package/lib/utils/app-paths.js +18 -18
- package/lib/utils/default-params.js +2 -1
- package/lib/utils/filter-argv-params.js +4 -3
- package/lib/utils/get-assets-files.js +6 -5
- package/lib/utils/get-compression.js +6 -6
- package/lib/utils/get-file-size.js +5 -4
- package/lib/utils/get-files-options.js +7 -6
- package/lib/utils/get-png-size.js +8 -7
- package/lib/utils/get-profile-content.js +9 -5
- package/lib/utils/get-profile-files.js +10 -9
- package/lib/utils/get-square-icon.js +5 -4
- package/lib/utils/logger.js +8 -7
- package/lib/utils/merge-objects.js +5 -4
- package/lib/utils/node-version-check.js +6 -6
- package/lib/utils/package-json.js +6 -0
- package/lib/utils/parse-argv.js +43 -45
- package/lib/utils/spawn-sync.js +6 -5
- package/lib/utils/validate-profile-object.js +12 -8
- package/package.json +24 -14
|
@@ -1,13 +1,14 @@
|
|
|
1
|
+
|
|
1
2
|
const iosIconRegex = /icon-(\d+\.?\d?)@?(\d+)?x?\.png/
|
|
2
3
|
|
|
3
4
|
function getAndroidIcon (entry) {
|
|
4
5
|
return {
|
|
5
6
|
generator: 'png',
|
|
6
|
-
name: `${entry[0]}.png`,
|
|
7
|
+
name: `${ entry[ 0 ] }.png`,
|
|
7
8
|
folder: 'src-cordova/res/android',
|
|
8
|
-
sizes: [ entry[1] ],
|
|
9
|
+
sizes: [ entry[ 1 ] ],
|
|
9
10
|
platform: 'cordova-android',
|
|
10
|
-
density: entry[0]
|
|
11
|
+
density: entry[ 0 ]
|
|
11
12
|
}
|
|
12
13
|
}
|
|
13
14
|
|
|
@@ -17,24 +18,24 @@ function getAndroidSplashscreens (entries) {
|
|
|
17
18
|
entries.forEach(entry => {
|
|
18
19
|
list.push({
|
|
19
20
|
generator: 'splashscreen',
|
|
20
|
-
name: `splash-land-${entry[0]}.png`,
|
|
21
|
+
name: `splash-land-${ entry[ 0 ] }.png`,
|
|
21
22
|
folder: 'src-cordova/res/screen/android',
|
|
22
23
|
sizes: [
|
|
23
|
-
[ entry[1], entry[2] ]
|
|
24
|
+
[ entry[ 1 ], entry[ 2 ] ]
|
|
24
25
|
],
|
|
25
26
|
platform: 'cordova-android',
|
|
26
|
-
density: `land-${entry[0]}`
|
|
27
|
+
density: `land-${ entry[ 0 ] }`
|
|
27
28
|
})
|
|
28
29
|
|
|
29
30
|
list.push({
|
|
30
31
|
generator: 'splashscreen',
|
|
31
|
-
name: `splash-port-${entry[0]}.png`,
|
|
32
|
+
name: `splash-port-${ entry[ 0 ] }.png`,
|
|
32
33
|
folder: 'src-cordova/res/screen/android',
|
|
33
34
|
sizes: [
|
|
34
|
-
[ entry[2], entry[1] ]
|
|
35
|
+
[ entry[ 2 ], entry[ 1 ] ]
|
|
35
36
|
],
|
|
36
37
|
platform: 'cordova-android',
|
|
37
|
-
density: `port-${entry[0]}`
|
|
38
|
+
density: `port-${ entry[ 0 ] }`
|
|
38
39
|
})
|
|
39
40
|
})
|
|
40
41
|
|
|
@@ -42,7 +43,7 @@ function getAndroidSplashscreens (entries) {
|
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
function getIosIcon (name) {
|
|
45
|
-
const [,size,multiplier] = name.match(iosIconRegex)
|
|
46
|
+
const [ ,size,multiplier ] = name.match(iosIconRegex)
|
|
46
47
|
|
|
47
48
|
return {
|
|
48
49
|
generator: 'png',
|
|
@@ -61,16 +62,16 @@ function getIosIcon (name) {
|
|
|
61
62
|
function getIosSplashscreen (entry) {
|
|
62
63
|
return {
|
|
63
64
|
generator: 'splashscreen',
|
|
64
|
-
name: entry[0],
|
|
65
|
+
name: entry[ 0 ],
|
|
65
66
|
folder: 'src-cordova/res/screen/ios',
|
|
66
67
|
sizes: [
|
|
67
|
-
[ entry[1], entry[2] ]
|
|
68
|
+
[ entry[ 1 ], entry[ 2 ] ]
|
|
68
69
|
],
|
|
69
70
|
platform: 'cordova-ios'
|
|
70
71
|
}
|
|
71
72
|
}
|
|
72
73
|
|
|
73
|
-
|
|
74
|
+
export default [
|
|
74
75
|
/***************
|
|
75
76
|
*** Android ***
|
|
76
77
|
***************/
|
|
@@ -1,37 +1,45 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
2
|
+
import spaAssets from './spa.js'
|
|
3
|
+
import pwaAssets from './pwa.js'
|
|
4
|
+
import ssrAssets from './ssr.js'
|
|
5
|
+
import bexAssets from './bex.js'
|
|
6
|
+
import cordovaAssets from './cordova.js'
|
|
7
|
+
import capacitorAssets from './capacitor.js'
|
|
8
|
+
import electronAssets from './electron.js'
|
|
9
|
+
|
|
10
|
+
export const modes = {
|
|
3
11
|
spa: {
|
|
4
12
|
folder: '/src',
|
|
5
|
-
assets:
|
|
13
|
+
assets: spaAssets
|
|
6
14
|
},
|
|
7
15
|
|
|
8
16
|
pwa: {
|
|
9
17
|
folder: '/src-pwa',
|
|
10
|
-
assets:
|
|
18
|
+
assets: pwaAssets
|
|
11
19
|
},
|
|
12
20
|
|
|
13
21
|
ssr: {
|
|
14
22
|
folder: '/src-ssr',
|
|
15
|
-
assets:
|
|
23
|
+
assets: ssrAssets
|
|
16
24
|
},
|
|
17
25
|
|
|
18
26
|
bex: {
|
|
19
27
|
folder: '/src-bex',
|
|
20
|
-
assets:
|
|
28
|
+
assets: bexAssets
|
|
21
29
|
},
|
|
22
30
|
|
|
23
31
|
cordova: {
|
|
24
32
|
folder: '/src-cordova',
|
|
25
|
-
assets:
|
|
33
|
+
assets: cordovaAssets
|
|
26
34
|
},
|
|
27
35
|
|
|
28
36
|
capacitor: {
|
|
29
37
|
folder: '/src-capacitor',
|
|
30
|
-
assets:
|
|
38
|
+
assets: capacitorAssets
|
|
31
39
|
},
|
|
32
40
|
|
|
33
41
|
electron: {
|
|
34
42
|
folder: '/src-electron',
|
|
35
|
-
assets:
|
|
43
|
+
assets: electronAssets
|
|
36
44
|
}
|
|
37
45
|
}
|
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
import spaEntries from './spa.js'
|
|
2
3
|
|
|
3
4
|
/* def: width, height, pixel-ratio */
|
|
4
5
|
function getAppleLaunch (def) {
|
|
5
|
-
const media = `(device-width: ${def[0] / def[2]}px) and (device-height: ${def[1] / def[2]}px) and (-webkit-device-pixel-ratio: ${def[2]})`
|
|
6
|
+
const media = `(device-width: ${ def[ 0 ] / def[ 2 ] }px) and (device-height: ${ def[ 1 ] / def[ 2 ] }px) and (-webkit-device-pixel-ratio: ${ def[ 2 ] })`
|
|
6
7
|
|
|
7
8
|
return {
|
|
8
9
|
generator: 'splashscreen',
|
|
9
10
|
name: 'apple-launch-{size}.png',
|
|
10
11
|
folder: 'src/statics/icons',
|
|
11
12
|
sizes: [
|
|
12
|
-
[ def[0], def[1] ]
|
|
13
|
+
[ def[ 0 ], def[ 1 ] ]
|
|
13
14
|
],
|
|
14
|
-
tag: `${def[3]}\n<link rel="apple-touch-startup-image" media="${media}" href="statics/icons/{name}">`
|
|
15
|
+
tag: `${ def[ 3 ] }\n<link rel="apple-touch-startup-image" media="${ media }" href="statics/icons/{name}">`
|
|
15
16
|
}
|
|
16
17
|
}
|
|
17
18
|
|
|
18
|
-
|
|
19
|
+
export default [
|
|
19
20
|
...spaEntries,
|
|
20
21
|
|
|
21
22
|
{
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
|
|
1
2
|
const iosIconRegex = /AppIcon-(\d+\.?\d?)x?(\d+\.?\d?)?@?(\d+)?x?-?\d?\.png/
|
|
2
3
|
|
|
3
4
|
function getAndroidIcons (entries) {
|
|
@@ -6,25 +7,25 @@ function getAndroidIcons (entries) {
|
|
|
6
7
|
entries.forEach(entry => {
|
|
7
8
|
const icon = {
|
|
8
9
|
generator: 'png',
|
|
9
|
-
folder: `src-capacitor/android/app/src/main/res/mipmap-${entry[0]}`
|
|
10
|
+
folder: `src-capacitor/android/app/src/main/res/mipmap-${ entry[ 0 ] }`
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
list.push({
|
|
13
14
|
...icon,
|
|
14
15
|
name: 'ic_launcher_foreground.png',
|
|
15
|
-
sizes: [ entry[2] ]
|
|
16
|
+
sizes: [ entry[ 2 ] ]
|
|
16
17
|
})
|
|
17
18
|
|
|
18
19
|
list.push({
|
|
19
20
|
...icon,
|
|
20
21
|
name: 'ic_launcher_round.png',
|
|
21
|
-
sizes: [ entry[1] ]
|
|
22
|
+
sizes: [ entry[ 1 ] ]
|
|
22
23
|
})
|
|
23
24
|
|
|
24
25
|
list.push({
|
|
25
26
|
...icon,
|
|
26
27
|
name: 'ic_launcher.png',
|
|
27
|
-
sizes: [ entry[1] ]
|
|
28
|
+
sizes: [ entry[ 1 ] ]
|
|
28
29
|
})
|
|
29
30
|
})
|
|
30
31
|
|
|
@@ -42,17 +43,17 @@ function getAndroidSplashscreen (entries) {
|
|
|
42
43
|
|
|
43
44
|
list.push({
|
|
44
45
|
...icon,
|
|
45
|
-
folder: `src-capacitor/android/app/src/main/res/drawable-land-${entry[0]}`,
|
|
46
|
+
folder: `src-capacitor/android/app/src/main/res/drawable-land-${ entry[ 0 ] }`,
|
|
46
47
|
sizes: [
|
|
47
|
-
[ entry[1], entry[2] ]
|
|
48
|
+
[ entry[ 1 ], entry[ 2 ] ]
|
|
48
49
|
]
|
|
49
50
|
})
|
|
50
51
|
|
|
51
52
|
list.push({
|
|
52
53
|
...icon,
|
|
53
|
-
folder: `src-capacitor/android/app/src/main/res/drawable-port-${entry[0]}`,
|
|
54
|
+
folder: `src-capacitor/android/app/src/main/res/drawable-port-${ entry[ 0 ] }`,
|
|
54
55
|
sizes: [
|
|
55
|
-
[ entry[2], entry[1] ]
|
|
56
|
+
[ entry[ 2 ], entry[ 1 ] ]
|
|
56
57
|
]
|
|
57
58
|
})
|
|
58
59
|
})
|
|
@@ -61,7 +62,7 @@ function getAndroidSplashscreen (entries) {
|
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
function getIosIcon (name) {
|
|
64
|
-
const [,size,,multiplier] = name.match(iosIconRegex)
|
|
65
|
+
const [ ,size,,multiplier ] = name.match(iosIconRegex)
|
|
65
66
|
|
|
66
67
|
return {
|
|
67
68
|
generator: 'png',
|
|
@@ -76,7 +77,7 @@ function getIosIcon (name) {
|
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
79
|
|
|
79
|
-
|
|
80
|
+
export default [
|
|
80
81
|
/***************
|
|
81
82
|
*** Android ***
|
|
82
83
|
***************/
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
+
|
|
1
2
|
const iosIconRegex = /icon-(\d+\.?\d?)@?(\d+)?x?\.png/
|
|
2
3
|
|
|
3
4
|
function getAndroidIcon (entry) {
|
|
4
5
|
return {
|
|
5
6
|
generator: 'png',
|
|
6
|
-
name: `${entry[0]}.png`,
|
|
7
|
+
name: `${ entry[ 0 ] }.png`,
|
|
7
8
|
folder: 'src-cordova/res/android',
|
|
8
|
-
sizes: [ entry[1] ],
|
|
9
|
+
sizes: [ entry[ 1 ] ],
|
|
9
10
|
platform: 'cordova-android',
|
|
10
|
-
density: entry[0]
|
|
11
|
+
density: entry[ 0 ]
|
|
11
12
|
}
|
|
12
13
|
}
|
|
13
14
|
|
|
@@ -17,24 +18,24 @@ function getAndroidSplashscreens (entries) {
|
|
|
17
18
|
entries.forEach(entry => {
|
|
18
19
|
list.push({
|
|
19
20
|
generator: 'splashscreen',
|
|
20
|
-
name: `splash-land-${entry[0]}.png`,
|
|
21
|
+
name: `splash-land-${ entry[ 0 ] }.png`,
|
|
21
22
|
folder: 'src-cordova/res/screen/android',
|
|
22
23
|
sizes: [
|
|
23
|
-
[ entry[1], entry[2] ]
|
|
24
|
+
[ entry[ 1 ], entry[ 2 ] ]
|
|
24
25
|
],
|
|
25
26
|
platform: 'cordova-android',
|
|
26
|
-
density: `land-${entry[0]}`
|
|
27
|
+
density: `land-${ entry[ 0 ] }`
|
|
27
28
|
})
|
|
28
29
|
|
|
29
30
|
list.push({
|
|
30
31
|
generator: 'splashscreen',
|
|
31
|
-
name: `splash-port-${entry[0]}.png`,
|
|
32
|
+
name: `splash-port-${ entry[ 0 ] }.png`,
|
|
32
33
|
folder: 'src-cordova/res/screen/android',
|
|
33
34
|
sizes: [
|
|
34
|
-
[ entry[2], entry[1] ]
|
|
35
|
+
[ entry[ 2 ], entry[ 1 ] ]
|
|
35
36
|
],
|
|
36
37
|
platform: 'cordova-android',
|
|
37
|
-
density: `port-${entry[0]}`
|
|
38
|
+
density: `port-${ entry[ 0 ] }`
|
|
38
39
|
})
|
|
39
40
|
})
|
|
40
41
|
|
|
@@ -42,7 +43,7 @@ function getAndroidSplashscreens (entries) {
|
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
function getIosIcon (name) {
|
|
45
|
-
const [,size,multiplier] = name.match(iosIconRegex)
|
|
46
|
+
const [ ,size,multiplier ] = name.match(iosIconRegex)
|
|
46
47
|
|
|
47
48
|
return {
|
|
48
49
|
generator: 'png',
|
|
@@ -61,16 +62,16 @@ function getIosIcon (name) {
|
|
|
61
62
|
function getIosSplashscreen (entry) {
|
|
62
63
|
return {
|
|
63
64
|
generator: 'splashscreen',
|
|
64
|
-
name: entry[0],
|
|
65
|
+
name: entry[ 0 ],
|
|
65
66
|
folder: 'src-cordova/res/screen/ios',
|
|
66
67
|
sizes: [
|
|
67
|
-
[ entry[1], entry[2] ]
|
|
68
|
+
[ entry[ 1 ], entry[ 2 ] ]
|
|
68
69
|
],
|
|
69
70
|
platform: 'cordova-ios'
|
|
70
71
|
}
|
|
71
72
|
}
|
|
72
73
|
|
|
73
|
-
|
|
74
|
+
export default [
|
|
74
75
|
/***************
|
|
75
76
|
*** Android ***
|
|
76
77
|
***************/
|
|
@@ -1,37 +1,45 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
2
|
+
import spaAssets from './spa.js'
|
|
3
|
+
import pwaAssets from './pwa.js'
|
|
4
|
+
import ssrAssets from './ssr.js'
|
|
5
|
+
import bexAssets from './bex.js'
|
|
6
|
+
import cordovaAssets from './cordova.js'
|
|
7
|
+
import capacitorAssets from './capacitor.js'
|
|
8
|
+
import electronAssets from './electron.js'
|
|
9
|
+
|
|
10
|
+
export const modes = {
|
|
3
11
|
spa: {
|
|
4
12
|
folder: '/src',
|
|
5
|
-
assets:
|
|
13
|
+
assets: spaAssets
|
|
6
14
|
},
|
|
7
15
|
|
|
8
16
|
pwa: {
|
|
9
17
|
folder: '/src-pwa',
|
|
10
|
-
assets:
|
|
18
|
+
assets: pwaAssets
|
|
11
19
|
},
|
|
12
20
|
|
|
13
21
|
ssr: {
|
|
14
22
|
folder: '/src-ssr',
|
|
15
|
-
assets:
|
|
23
|
+
assets: ssrAssets
|
|
16
24
|
},
|
|
17
25
|
|
|
18
26
|
bex: {
|
|
19
27
|
folder: '/src-bex',
|
|
20
|
-
assets:
|
|
28
|
+
assets: bexAssets
|
|
21
29
|
},
|
|
22
30
|
|
|
23
31
|
cordova: {
|
|
24
32
|
folder: '/src-cordova',
|
|
25
|
-
assets:
|
|
33
|
+
assets: cordovaAssets
|
|
26
34
|
},
|
|
27
35
|
|
|
28
36
|
capacitor: {
|
|
29
37
|
folder: '/src-capacitor',
|
|
30
|
-
assets:
|
|
38
|
+
assets: capacitorAssets
|
|
31
39
|
},
|
|
32
40
|
|
|
33
41
|
electron: {
|
|
34
42
|
folder: '/src-electron',
|
|
35
|
-
assets:
|
|
43
|
+
assets: electronAssets
|
|
36
44
|
}
|
|
37
45
|
}
|
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
import spaEntries from './spa.js'
|
|
2
3
|
|
|
3
4
|
/* def: width, height, pixel-ratio */
|
|
4
5
|
function getAppleLaunch (def) {
|
|
5
|
-
const media = `(device-width: ${def[0] / def[2]}px) and (device-height: ${def[1] / def[2]}px) and (-webkit-device-pixel-ratio: ${def[2]})`
|
|
6
|
+
const media = `(device-width: ${ def[ 0 ] / def[ 2 ] }px) and (device-height: ${ def[ 1 ] / def[ 2 ] }px) and (-webkit-device-pixel-ratio: ${ def[ 2 ] })`
|
|
6
7
|
|
|
7
8
|
return {
|
|
8
9
|
generator: 'splashscreen',
|
|
9
10
|
name: 'apple-launch-{size}.png',
|
|
10
11
|
folder: 'public/icons',
|
|
11
12
|
sizes: [
|
|
12
|
-
[ def[0], def[1] ]
|
|
13
|
+
[ def[ 0 ], def[ 1 ] ]
|
|
13
14
|
],
|
|
14
|
-
tag: `${def[3]}\n<link rel="apple-touch-startup-image" media="${media}" href="icons/{name}">`
|
|
15
|
+
tag: `${ def[ 3 ] }\n<link rel="apple-touch-startup-image" media="${ media }" href="icons/{name}">`
|
|
15
16
|
}
|
|
16
17
|
}
|
|
17
18
|
|
|
18
|
-
|
|
19
|
+
export default [
|
|
19
20
|
...spaEntries,
|
|
20
21
|
|
|
21
22
|
{
|
package/lib/mount/index.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
const { mountCordova, isCordovaFile, verifyCordova } = require('./mount-cordova')
|
|
2
|
-
const { mountTag } = require('./mount-tag')
|
|
3
1
|
|
|
4
|
-
|
|
2
|
+
import { mountCordova, isCordovaFile, verifyCordova } from './mount-cordova.js'
|
|
3
|
+
import { mountTag } from './mount-tag.js'
|
|
4
|
+
|
|
5
|
+
export function mount (files) {
|
|
5
6
|
mountCordova(files)
|
|
6
7
|
mountTag(files)
|
|
7
8
|
}
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
export function verifyMount (file) {
|
|
10
11
|
return isCordovaFile(file)
|
|
11
12
|
? verifyCordova(file)
|
|
12
13
|
: ''
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
const { readFileSync, writeFileSync, existsSync } = require('fs')
|
|
2
|
-
const elementTree = require('elementtree')
|
|
3
|
-
const { relative } = require('path')
|
|
4
|
-
const { red, green } = require('kolorist')
|
|
5
1
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
import { readFileSync, writeFileSync, existsSync } from 'node:fs'
|
|
3
|
+
import elementTree from 'elementtree'
|
|
4
|
+
import { relative } from 'node:path'
|
|
5
|
+
import { red, green } from 'kolorist'
|
|
6
|
+
|
|
7
|
+
import { resolveDir } from '../utils/app-paths.js'
|
|
8
|
+
import { log, warn } from '../utils/logger.js'
|
|
9
|
+
import { spawnSync } from '../utils/spawn-sync.js'
|
|
9
10
|
|
|
10
11
|
const cordovaConfigXml = resolveDir('src-cordova/config.xml')
|
|
11
12
|
const srcCordovaDir = resolveDir('src-cordova')
|
|
@@ -15,18 +16,18 @@ const generatorList = [ 'png', 'splashscreen' ]
|
|
|
15
16
|
|
|
16
17
|
function getNode (root, tag, selector) {
|
|
17
18
|
return (
|
|
18
|
-
root.find(`${tag}${selector}`)
|
|
19
|
-
elementTree.SubElement(root, tag)
|
|
19
|
+
root.find(`${ tag }${ selector }`)
|
|
20
|
+
|| elementTree.SubElement(root, tag)
|
|
20
21
|
)
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
function hasNode (root, tag, selector) {
|
|
24
|
-
return root.find(`${tag}${selector}`)
|
|
25
|
+
return root.find(`${ tag }${ selector }`)
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
function isCordovaFile (file) {
|
|
28
|
-
return platformList.includes(file.platform)
|
|
29
|
-
generatorList.includes(file.generator)
|
|
28
|
+
export function isCordovaFile (file) {
|
|
29
|
+
return platformList.includes(file.platform)
|
|
30
|
+
&& generatorList.includes(file.generator)
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
function getCordovaFiles (files) {
|
|
@@ -52,7 +53,14 @@ function updateConfigXml (cordovaFiles, hasSplashscreen) {
|
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
const androidNode = getNode(rootNode, 'platform', '[@name="android"]')
|
|
56
|
+
if (androidNode.get('name') === void 0) {
|
|
57
|
+
androidNode.set('name', 'android')
|
|
58
|
+
}
|
|
59
|
+
|
|
55
60
|
const iosNode = getNode(rootNode, 'platform', '[@name="ios"]')
|
|
61
|
+
if (iosNode.get('name') === void 0) {
|
|
62
|
+
iosNode.set('name', 'ios')
|
|
63
|
+
}
|
|
56
64
|
|
|
57
65
|
cordovaFiles.forEach(file => {
|
|
58
66
|
const isAndroid = file.platform === 'cordova-android'
|
|
@@ -67,7 +75,7 @@ function updateConfigXml (cordovaFiles, hasSplashscreen) {
|
|
|
67
75
|
const entry = getNode(
|
|
68
76
|
node,
|
|
69
77
|
'splash',
|
|
70
|
-
isAndroid ? `[@density="${file.density}"]` : `[@src="${src}"]`
|
|
78
|
+
isAndroid ? `[@density="${ file.density }"]` : `[@src="${ src }"]`
|
|
71
79
|
)
|
|
72
80
|
|
|
73
81
|
entry.set('src', src)
|
|
@@ -84,8 +92,8 @@ function updateConfigXml (cordovaFiles, hasSplashscreen) {
|
|
|
84
92
|
node,
|
|
85
93
|
'icon',
|
|
86
94
|
isAndroid
|
|
87
|
-
? `[@density="${file.density}"]`
|
|
88
|
-
: `[@width="${file.width}"][@height="${file.height}"]`
|
|
95
|
+
? `[@density="${ file.density }"]`
|
|
96
|
+
: `[@width="${ file.width }"][@height="${ file.height }"]`
|
|
89
97
|
)
|
|
90
98
|
|
|
91
99
|
entry.set('src', src)
|
|
@@ -108,8 +116,8 @@ function hasDeepProp (target /* , param1, param2, ... */) {
|
|
|
108
116
|
let obj = target
|
|
109
117
|
|
|
110
118
|
for (let i = 1; i < arguments.length; i++) {
|
|
111
|
-
const prop = arguments[i]
|
|
112
|
-
obj = obj[prop]
|
|
119
|
+
const prop = arguments[ i ]
|
|
120
|
+
obj = obj[ prop ]
|
|
113
121
|
|
|
114
122
|
if (obj === void 0) {
|
|
115
123
|
return false
|
|
@@ -127,11 +135,13 @@ function installSplashscreenPlugin () {
|
|
|
127
135
|
return
|
|
128
136
|
}
|
|
129
137
|
|
|
130
|
-
const pkg =
|
|
138
|
+
const pkg = JSON.parse(
|
|
139
|
+
readFileSync(pkgPath, 'utf8')
|
|
140
|
+
)
|
|
131
141
|
|
|
132
142
|
if (
|
|
133
|
-
hasDeepProp(pkg, 'dependencies', 'cordova-plugin-splashscreen')
|
|
134
|
-
hasDeepProp(pkg, 'cordova', 'plugins', 'cordova-plugin-splashscreen')
|
|
143
|
+
hasDeepProp(pkg, 'dependencies', 'cordova-plugin-splashscreen')
|
|
144
|
+
|| hasDeepProp(pkg, 'cordova', 'plugins', 'cordova-plugin-splashscreen')
|
|
135
145
|
) {
|
|
136
146
|
// it's already installed, so nothing to do
|
|
137
147
|
return
|
|
@@ -150,7 +160,7 @@ function installSplashscreenPlugin () {
|
|
|
150
160
|
console.log()
|
|
151
161
|
}
|
|
152
162
|
|
|
153
|
-
|
|
163
|
+
export function mountCordova (files) {
|
|
154
164
|
if (existsSync(cordovaConfigXml)) {
|
|
155
165
|
const cordovaFiles = getCordovaFiles(files)
|
|
156
166
|
|
|
@@ -166,15 +176,13 @@ module.exports.mountCordova = function mountCordova (files) {
|
|
|
166
176
|
}
|
|
167
177
|
}
|
|
168
178
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
module.exports.verifyCordova = function verifyCordova (file) {
|
|
179
|
+
export function verifyCordova (file) {
|
|
172
180
|
if (isCordovaFile(file) && existsSync(cordovaConfigXml)) {
|
|
173
181
|
const doc = elementTree.parse(readFileSync(cordovaConfigXml, 'utf-8'))
|
|
174
182
|
const isAndroid = file.platform === 'cordova-android'
|
|
175
183
|
|
|
176
184
|
const node = doc.getroot()
|
|
177
|
-
.find(`platform[@name="${isAndroid ? 'android' : 'ios'}"]`)
|
|
185
|
+
.find(`platform[@name="${ isAndroid ? 'android' : 'ios' }"]`)
|
|
178
186
|
|
|
179
187
|
// verify that the platform is installed
|
|
180
188
|
if (!node) {
|
|
@@ -185,8 +193,8 @@ module.exports.verifyCordova = function verifyCordova (file) {
|
|
|
185
193
|
|
|
186
194
|
if (file.generator === 'splashscreen') {
|
|
187
195
|
const selector = isAndroid
|
|
188
|
-
? `[@density="${file.density}"]`
|
|
189
|
-
: `[@src="${src}"]`
|
|
196
|
+
? `[@density="${ file.density }"]`
|
|
197
|
+
: `[@src="${ src }"]`
|
|
190
198
|
|
|
191
199
|
if (!hasNode(node, 'splash', selector)) {
|
|
192
200
|
return red('ERROR: no entry for it in src-cordova/config.xml')
|
|
@@ -194,8 +202,8 @@ module.exports.verifyCordova = function verifyCordova (file) {
|
|
|
194
202
|
}
|
|
195
203
|
else {
|
|
196
204
|
const selector = isAndroid
|
|
197
|
-
? `[@density="${file.density}"]`
|
|
198
|
-
: `[@width="${file.width}"][@height="${file.height}"]`
|
|
205
|
+
? `[@density="${ file.density }"]`
|
|
206
|
+
: `[@width="${ file.width }"][@height="${ file.height }"]`
|
|
199
207
|
|
|
200
208
|
if (!hasNode(node, 'icon', selector)) {
|
|
201
209
|
return red('ERROR: no entry for it in src-cordova/config.xml')
|
package/lib/mount/mount-tag.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
const { log } = require('../utils/logger')
|
|
2
1
|
|
|
3
|
-
|
|
2
|
+
import { log } from '../utils/logger.js'
|
|
3
|
+
|
|
4
|
+
export function mountTag (files) {
|
|
4
5
|
const tagFiles = files.filter(file => file.tag)
|
|
5
6
|
|
|
6
7
|
if (tagFiles.length === 0) {
|