react-native-update-cli 1.30.3 → 1.31.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/cli.json +3 -1
- package/lib/api.js +177 -186
- package/lib/app.js +136 -114
- package/lib/bundle.js +535 -559
- package/lib/index.js +46 -49
- package/lib/package.js +132 -136
- package/lib/user.js +43 -41
- package/lib/utils/app-info-parser/apk.js +72 -71
- package/lib/utils/app-info-parser/index.js +28 -30
- package/lib/utils/app-info-parser/ipa.js +72 -80
- package/lib/utils/app-info-parser/resource-finder.js +286 -421
- package/lib/utils/app-info-parser/utils.js +106 -120
- package/lib/utils/app-info-parser/xml-parser/binary.js +539 -637
- package/lib/utils/app-info-parser/xml-parser/manifest.js +193 -215
- package/lib/utils/app-info-parser/zip.js +40 -40
- package/lib/utils/index.js +156 -149
- package/lib/versions.js +226 -178
- package/package.json +10 -9
- package/src/api.js +6 -3
- package/src/bundle.js +11 -10
- package/src/utils/index.js +4 -2
- package/src/versions.js +80 -16
- package/src/.DS_Store +0 -0
- package/src/utils/.DS_Store +0 -0
|
@@ -1,158 +1,144 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
3
2
|
function objectType(o) {
|
|
4
|
-
|
|
3
|
+
return Object.prototype.toString.call(o).slice(8, -1).toLowerCase();
|
|
5
4
|
}
|
|
6
|
-
|
|
7
5
|
function isArray(o) {
|
|
8
|
-
|
|
6
|
+
return objectType(o) === 'array';
|
|
9
7
|
}
|
|
10
|
-
|
|
11
8
|
function isObject(o) {
|
|
12
|
-
|
|
9
|
+
return objectType(o) === 'object';
|
|
13
10
|
}
|
|
14
|
-
|
|
15
11
|
function isPrimitive(o) {
|
|
16
|
-
|
|
12
|
+
return o === null || [
|
|
13
|
+
'boolean',
|
|
14
|
+
'number',
|
|
15
|
+
'string',
|
|
16
|
+
'undefined'
|
|
17
|
+
].includes(objectType(o));
|
|
17
18
|
}
|
|
18
|
-
|
|
19
19
|
function isBrowser() {
|
|
20
|
-
|
|
20
|
+
return typeof process === 'undefined' || Object.prototype.toString.call(process) !== '[object process]';
|
|
21
21
|
}
|
|
22
|
-
|
|
23
22
|
/**
|
|
24
23
|
* map file place with resourceMap
|
|
25
24
|
* @param {Object} apkInfo // json info parsed from .apk file
|
|
26
25
|
* @param {Object} resourceMap // resourceMap
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
26
|
+
*/ function mapInfoResource(apkInfo, resourceMap) {
|
|
27
|
+
iteratorObj(apkInfo);
|
|
28
|
+
return apkInfo;
|
|
29
|
+
function iteratorObj(obj) {
|
|
30
|
+
for(var i in obj){
|
|
31
|
+
if (isArray(obj[i])) {
|
|
32
|
+
iteratorArray(obj[i]);
|
|
33
|
+
} else if (isObject(obj[i])) {
|
|
34
|
+
iteratorObj(obj[i]);
|
|
35
|
+
} else if (isPrimitive(obj[i])) {
|
|
36
|
+
if (isResources(obj[i])) {
|
|
37
|
+
obj[i] = resourceMap[transKeyToMatchResourceMap(obj[i])];
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
40
|
}
|
|
41
|
-
}
|
|
42
41
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
42
|
+
function iteratorArray(array) {
|
|
43
|
+
const l = array.length;
|
|
44
|
+
for(let i = 0; i < l; i++){
|
|
45
|
+
if (isArray(array[i])) {
|
|
46
|
+
iteratorArray(array[i]);
|
|
47
|
+
} else if (isObject(array[i])) {
|
|
48
|
+
iteratorObj(array[i]);
|
|
49
|
+
} else if (isPrimitive(array[i])) {
|
|
50
|
+
if (isResources(array[i])) {
|
|
51
|
+
array[i] = resourceMap[transKeyToMatchResourceMap(array[i])];
|
|
52
|
+
}
|
|
53
|
+
}
|
|
55
54
|
}
|
|
56
|
-
}
|
|
57
55
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
56
|
+
function isResources(attrValue) {
|
|
57
|
+
if (!attrValue) return false;
|
|
58
|
+
if (typeof attrValue !== 'string') {
|
|
59
|
+
attrValue = attrValue.toString();
|
|
60
|
+
}
|
|
61
|
+
return attrValue.indexOf('resourceId:') === 0;
|
|
62
|
+
}
|
|
63
|
+
function transKeyToMatchResourceMap(resourceId) {
|
|
64
|
+
return '@' + resourceId.replace('resourceId:0x', '').toUpperCase();
|
|
64
65
|
}
|
|
65
|
-
return attrValue.indexOf('resourceId:') === 0;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function transKeyToMatchResourceMap(resourceId) {
|
|
69
|
-
return '@' + resourceId.replace('resourceId:0x', '').toUpperCase();
|
|
70
|
-
}
|
|
71
66
|
}
|
|
72
|
-
|
|
73
67
|
/**
|
|
74
68
|
* find .apk file's icon path from json info
|
|
75
69
|
* @param info // json info parsed from .apk file
|
|
76
|
-
*/
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
70
|
+
*/ function findApkIconPath(info) {
|
|
71
|
+
if (!info.application.icon || !info.application.icon.splice) {
|
|
72
|
+
return '';
|
|
73
|
+
}
|
|
74
|
+
const rulesMap = {
|
|
75
|
+
mdpi: 48,
|
|
76
|
+
hdpi: 72,
|
|
77
|
+
xhdpi: 96,
|
|
78
|
+
xxdpi: 144,
|
|
79
|
+
xxxhdpi: 192
|
|
80
|
+
};
|
|
81
|
+
const resultMap = {};
|
|
82
|
+
const maxDpiIcon = {
|
|
83
|
+
dpi: 120,
|
|
84
|
+
icon: ''
|
|
85
|
+
};
|
|
86
|
+
for(const i in rulesMap){
|
|
87
|
+
info.application.icon.some((icon)=>{
|
|
88
|
+
if (icon && icon.indexOf(i) !== -1) {
|
|
89
|
+
resultMap['application-icon-' + rulesMap[i]] = icon;
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
// get the maximal size icon
|
|
94
|
+
if (resultMap['application-icon-' + rulesMap[i]] && rulesMap[i] >= maxDpiIcon.dpi) {
|
|
95
|
+
maxDpiIcon.dpi = rulesMap[i];
|
|
96
|
+
maxDpiIcon.icon = resultMap['application-icon-' + rulesMap[i]];
|
|
97
|
+
}
|
|
103
98
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
return maxDpiIcon.icon;
|
|
99
|
+
if (Object.keys(resultMap).length === 0 || !maxDpiIcon.icon) {
|
|
100
|
+
maxDpiIcon.dpi = 120;
|
|
101
|
+
maxDpiIcon.icon = info.application.icon[0] || '';
|
|
102
|
+
resultMap['applicataion-icon-120'] = maxDpiIcon.icon;
|
|
103
|
+
}
|
|
104
|
+
return maxDpiIcon.icon;
|
|
112
105
|
}
|
|
113
|
-
|
|
114
106
|
/**
|
|
115
107
|
* find .ipa file's icon path from json info
|
|
116
108
|
* @param info // json info parsed from .ipa file
|
|
117
|
-
*/
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
109
|
+
*/ function findIpaIconPath(info) {
|
|
110
|
+
if (info.CFBundleIcons && info.CFBundleIcons.CFBundlePrimaryIcon && info.CFBundleIcons.CFBundlePrimaryIcon.CFBundleIconFiles && info.CFBundleIcons.CFBundlePrimaryIcon.CFBundleIconFiles.length) {
|
|
111
|
+
return info.CFBundleIcons.CFBundlePrimaryIcon.CFBundleIconFiles[info.CFBundleIcons.CFBundlePrimaryIcon.CFBundleIconFiles.length - 1];
|
|
112
|
+
} else if (info.CFBundleIconFiles && info.CFBundleIconFiles.length) {
|
|
113
|
+
return info.CFBundleIconFiles[info.CFBundleIconFiles.length - 1];
|
|
114
|
+
} else {
|
|
115
|
+
return '.app/Icon.png';
|
|
116
|
+
}
|
|
126
117
|
}
|
|
127
|
-
|
|
128
118
|
/**
|
|
129
119
|
* transform buffer to base64
|
|
130
120
|
* @param {Buffer} buffer
|
|
131
|
-
*/
|
|
132
|
-
|
|
133
|
-
return 'data:image/png;base64,' + buffer.toString('base64');
|
|
121
|
+
*/ function getBase64FromBuffer(buffer) {
|
|
122
|
+
return 'data:image/png;base64,' + buffer.toString('base64');
|
|
134
123
|
}
|
|
135
|
-
|
|
136
124
|
/**
|
|
137
125
|
* 去除unicode空字符
|
|
138
126
|
* @param {String} str
|
|
139
|
-
*/
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
return str;
|
|
127
|
+
*/ function decodeNullUnicode(str) {
|
|
128
|
+
if (typeof str === 'string') {
|
|
129
|
+
// eslint-disable-next-line
|
|
130
|
+
str = str.replace(/\u0000/g, '');
|
|
131
|
+
}
|
|
132
|
+
return str;
|
|
146
133
|
}
|
|
147
|
-
|
|
148
134
|
module.exports = {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
};
|
|
135
|
+
isArray,
|
|
136
|
+
isObject,
|
|
137
|
+
isPrimitive,
|
|
138
|
+
isBrowser,
|
|
139
|
+
mapInfoResource,
|
|
140
|
+
findApkIconPath,
|
|
141
|
+
findIpaIconPath,
|
|
142
|
+
getBase64FromBuffer,
|
|
143
|
+
decodeNullUnicode
|
|
144
|
+
};
|