react-native-update-cli 1.30.4 → 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.
@@ -1,158 +1,144 @@
1
- 'use strict';
2
-
1
+ "use strict";
3
2
  function objectType(o) {
4
- return Object.prototype.toString.call(o).slice(8, -1).toLowerCase();
3
+ return Object.prototype.toString.call(o).slice(8, -1).toLowerCase();
5
4
  }
6
-
7
5
  function isArray(o) {
8
- return objectType(o) === 'array';
6
+ return objectType(o) === 'array';
9
7
  }
10
-
11
8
  function isObject(o) {
12
- return objectType(o) === 'object';
9
+ return objectType(o) === 'object';
13
10
  }
14
-
15
11
  function isPrimitive(o) {
16
- return o === null || ['boolean', 'number', 'string', 'undefined'].includes(objectType(o));
12
+ return o === null || [
13
+ 'boolean',
14
+ 'number',
15
+ 'string',
16
+ 'undefined'
17
+ ].includes(objectType(o));
17
18
  }
18
-
19
19
  function isBrowser() {
20
- return typeof process === 'undefined' || Object.prototype.toString.call(process) !== '[object process]';
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
- function mapInfoResource(apkInfo, resourceMap) {
29
- iteratorObj(apkInfo);
30
- return apkInfo;
31
- function iteratorObj(obj) {
32
- for (var i in obj) {
33
- if (isArray(obj[i])) {
34
- iteratorArray(obj[i]);
35
- } else if (isObject(obj[i])) {
36
- iteratorObj(obj[i]);
37
- } else if (isPrimitive(obj[i])) {
38
- if (isResources(obj[i])) {
39
- obj[i] = resourceMap[transKeyToMatchResourceMap(obj[i])];
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
- function iteratorArray(array) {
46
- const l = array.length;
47
- for (let i = 0; i < l; i++) {
48
- if (isArray(array[i])) {
49
- iteratorArray(array[i]);
50
- } else if (isObject(array[i])) {
51
- iteratorObj(array[i]);
52
- } else if (isPrimitive(array[i])) {
53
- if (isResources(array[i])) {
54
- array[i] = resourceMap[transKeyToMatchResourceMap(array[i])];
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
- function isResources(attrValue) {
61
- if (!attrValue) return false;
62
- if (typeof attrValue !== 'string') {
63
- attrValue = attrValue.toString();
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
- function findApkIconPath(info) {
78
- if (!info.application.icon || !info.application.icon.splice) {
79
- return '';
80
- }
81
- const rulesMap = {
82
- mdpi: 48,
83
- hdpi: 72,
84
- xhdpi: 96,
85
- xxdpi: 144,
86
- xxxhdpi: 192
87
- };
88
- const resultMap = {};
89
- const maxDpiIcon = { dpi: 120, icon: '' };
90
-
91
- for (const i in rulesMap) {
92
- info.application.icon.some(icon => {
93
- if (icon && icon.indexOf(i) !== -1) {
94
- resultMap['application-icon-' + rulesMap[i]] = icon;
95
- return true;
96
- }
97
- });
98
-
99
- // get the maximal size icon
100
- if (resultMap['application-icon-' + rulesMap[i]] && rulesMap[i] >= maxDpiIcon.dpi) {
101
- maxDpiIcon.dpi = rulesMap[i];
102
- maxDpiIcon.icon = resultMap['application-icon-' + rulesMap[i]];
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
- if (Object.keys(resultMap).length === 0 || !maxDpiIcon.icon) {
107
- maxDpiIcon.dpi = 120;
108
- maxDpiIcon.icon = info.application.icon[0] || '';
109
- resultMap['applicataion-icon-120'] = maxDpiIcon.icon;
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
- function findIpaIconPath(info) {
119
- if (info.CFBundleIcons && info.CFBundleIcons.CFBundlePrimaryIcon && info.CFBundleIcons.CFBundlePrimaryIcon.CFBundleIconFiles && info.CFBundleIcons.CFBundlePrimaryIcon.CFBundleIconFiles.length) {
120
- return info.CFBundleIcons.CFBundlePrimaryIcon.CFBundleIconFiles[info.CFBundleIcons.CFBundlePrimaryIcon.CFBundleIconFiles.length - 1];
121
- } else if (info.CFBundleIconFiles && info.CFBundleIconFiles.length) {
122
- return info.CFBundleIconFiles[info.CFBundleIconFiles.length - 1];
123
- } else {
124
- return '.app/Icon.png';
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
- function getBase64FromBuffer(buffer) {
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
- function decodeNullUnicode(str) {
141
- if (typeof str === 'string') {
142
- // eslint-disable-next-line
143
- str = str.replace(/\u0000/g, '');
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
- isArray,
150
- isObject,
151
- isPrimitive,
152
- isBrowser,
153
- mapInfoResource,
154
- findApkIconPath,
155
- findIpaIconPath,
156
- getBase64FromBuffer,
157
- decodeNullUnicode
158
- };
135
+ isArray,
136
+ isObject,
137
+ isPrimitive,
138
+ isBrowser,
139
+ mapInfoResource,
140
+ findApkIconPath,
141
+ findIpaIconPath,
142
+ getBase64FromBuffer,
143
+ decodeNullUnicode
144
+ };