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.
@@ -1,37 +1,35 @@
1
- 'use strict';
2
-
1
+ "use strict";
3
2
  const ApkParser = require('./apk');
4
3
  const IpaParser = require('./ipa');
5
- const supportFileTypes = ['ipa', 'apk'];
6
-
4
+ const supportFileTypes = [
5
+ 'ipa',
6
+ 'apk'
7
+ ];
7
8
  class AppInfoParser {
8
- /**
9
+ parse() {
10
+ return this.parser.parse();
11
+ }
12
+ /**
9
13
  * parser for parsing .ipa or .apk file
10
14
  * @param {String | File | Blob} file // file's path in Node, instance of File or Blob in Browser
11
- */
12
- constructor(file) {
13
- if (!file) {
14
- throw new Error('Param miss: file(file\'s path in Node, instance of File or Blob in browser).');
15
- }
16
- const splits = (file.name || file).split('.');
17
- const fileType = splits[splits.length - 1].toLowerCase();
18
- if (!supportFileTypes.includes(fileType)) {
19
- throw new Error('Unsupported file type, only support .ipa or .apk file.');
20
- }
21
- this.file = file;
22
-
23
- switch (fileType) {
24
- case 'ipa':
25
- this.parser = new IpaParser(this.file);
26
- break;
27
- case 'apk':
28
- this.parser = new ApkParser(this.file);
29
- break;
15
+ */ constructor(file){
16
+ if (!file) {
17
+ throw new Error('Param miss: file(file\'s path in Node, instance of File or Blob in browser).');
18
+ }
19
+ const splits = (file.name || file).split('.');
20
+ const fileType = splits[splits.length - 1].toLowerCase();
21
+ if (!supportFileTypes.includes(fileType)) {
22
+ throw new Error('Unsupported file type, only support .ipa or .apk file.');
23
+ }
24
+ this.file = file;
25
+ switch(fileType){
26
+ case 'ipa':
27
+ this.parser = new IpaParser(this.file);
28
+ break;
29
+ case 'apk':
30
+ this.parser = new ApkParser(this.file);
31
+ break;
32
+ }
30
33
  }
31
- }
32
- parse() {
33
- return this.parser.parse();
34
- }
35
34
  }
36
-
37
- module.exports = AppInfoParser;
35
+ module.exports = AppInfoParser;
@@ -1,96 +1,88 @@
1
- 'use strict';
2
-
3
- function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } else { return Array.from(arr); } }
4
-
1
+ "use strict";
5
2
  const parsePlist = require('plist').parse;
6
3
  const parseBplist = require('bplist-parser').parseBuffer;
7
4
  const cgbiToPng = require('cgbi-to-png');
8
-
9
5
  const Zip = require('./zip');
10
6
  const { findIpaIconPath, getBase64FromBuffer, isBrowser } = require('./utils');
11
-
12
7
  const PlistName = new RegExp('payload/[^/]+?.app/info.plist$', 'i');
13
8
  const ProvisionName = /payload\/.+?\.app\/embedded.mobileprovision/;
14
-
15
9
  class IpaParser extends Zip {
16
- /**
17
- * parser for parsing .ipa file
18
- * @param {String | File | Blob} file // file's path in Node, instance of File or Blob in Browser
19
- */
20
- constructor(file) {
21
- super(file);
22
- if (!(this instanceof IpaParser)) {
23
- return new IpaParser(file);
24
- }
25
- }
26
- parse() {
27
- return new Promise((resolve, reject) => {
28
- this.getEntries([PlistName, ProvisionName]).then(buffers => {
29
- if (!buffers[PlistName]) {
30
- throw new Error('Info.plist can\'t be found.');
31
- }
32
- const plistInfo = this._parsePlist(buffers[PlistName]);
33
- // parse mobile provision
34
- const provisionInfo = this._parseProvision(buffers[ProvisionName]);
35
- plistInfo.mobileProvision = provisionInfo;
36
-
37
- // find icon path and parse icon
38
- const iconRegex = new RegExp(findIpaIconPath(plistInfo).toLowerCase());
39
- this.getEntry(iconRegex).then(iconBuffer => {
40
- try {
41
- // In general, the ipa file's icon has been specially processed, should be converted
42
- plistInfo.icon = iconBuffer ? getBase64FromBuffer(cgbiToPng.revert(iconBuffer)) : null;
43
- } catch (err) {
44
- if (isBrowser()) {
45
- // Normal conversion in other cases
46
- plistInfo.icon = iconBuffer ? getBase64FromBuffer(window.btoa(String.fromCharCode.apply(String, _toConsumableArray(iconBuffer)))) : null;
47
- } else {
48
- plistInfo.icon = null;
49
- console.warn('[Warning] failed to parse icon: ', err);
50
- }
51
- }
52
- resolve(plistInfo);
53
- }).catch(e => {
54
- reject(e);
10
+ parse() {
11
+ return new Promise((resolve, reject)=>{
12
+ this.getEntries([
13
+ PlistName,
14
+ ProvisionName
15
+ ]).then((buffers)=>{
16
+ if (!buffers[PlistName]) {
17
+ throw new Error('Info.plist can\'t be found.');
18
+ }
19
+ const plistInfo = this._parsePlist(buffers[PlistName]);
20
+ // parse mobile provision
21
+ const provisionInfo = this._parseProvision(buffers[ProvisionName]);
22
+ plistInfo.mobileProvision = provisionInfo;
23
+ // find icon path and parse icon
24
+ const iconRegex = new RegExp(findIpaIconPath(plistInfo).toLowerCase());
25
+ this.getEntry(iconRegex).then((iconBuffer)=>{
26
+ try {
27
+ // In general, the ipa file's icon has been specially processed, should be converted
28
+ plistInfo.icon = iconBuffer ? getBase64FromBuffer(cgbiToPng.revert(iconBuffer)) : null;
29
+ } catch (err) {
30
+ if (isBrowser()) {
31
+ // Normal conversion in other cases
32
+ plistInfo.icon = iconBuffer ? getBase64FromBuffer(window.btoa(String.fromCharCode(...iconBuffer))) : null;
33
+ } else {
34
+ plistInfo.icon = null;
35
+ console.warn('[Warning] failed to parse icon: ', err);
36
+ }
37
+ }
38
+ resolve(plistInfo);
39
+ }).catch((e)=>{
40
+ reject(e);
41
+ });
42
+ }).catch((e)=>{
43
+ reject(e);
44
+ });
55
45
  });
56
- }).catch(e => {
57
- reject(e);
58
- });
59
- });
60
- }
61
- /**
46
+ }
47
+ /**
62
48
  * Parse plist
63
49
  * @param {Buffer} buffer // plist file's buffer
64
- */
65
- _parsePlist(buffer) {
66
- let result;
67
- const bufferType = buffer[0];
68
- if (bufferType === 60 || bufferType === '<' || bufferType === 239) {
69
- result = parsePlist(buffer.toString());
70
- } else if (bufferType === 98) {
71
- result = parseBplist(buffer)[0];
72
- } else {
73
- throw new Error('Unknown plist buffer type.');
50
+ */ _parsePlist(buffer) {
51
+ let result;
52
+ const bufferType = buffer[0];
53
+ if (bufferType === 60 || bufferType === '<' || bufferType === 239) {
54
+ result = parsePlist(buffer.toString());
55
+ } else if (bufferType === 98) {
56
+ result = parseBplist(buffer)[0];
57
+ } else {
58
+ throw new Error('Unknown plist buffer type.');
59
+ }
60
+ return result;
74
61
  }
75
- return result;
76
- }
77
- /**
62
+ /**
78
63
  * parse provision
79
64
  * @param {Buffer} buffer // provision file's buffer
80
- */
81
- _parseProvision(buffer) {
82
- let info = {};
83
- if (buffer) {
84
- let content = buffer.toString('utf-8');
85
- const firstIndex = content.indexOf('<?xml');
86
- const endIndex = content.indexOf('</plist>');
87
- content = content.slice(firstIndex, endIndex + 8);
88
- if (content) {
89
- info = parsePlist(content);
90
- }
65
+ */ _parseProvision(buffer) {
66
+ let info = {};
67
+ if (buffer) {
68
+ let content = buffer.toString('utf-8');
69
+ const firstIndex = content.indexOf('<?xml');
70
+ const endIndex = content.indexOf('</plist>');
71
+ content = content.slice(firstIndex, endIndex + 8);
72
+ if (content) {
73
+ info = parsePlist(content);
74
+ }
75
+ }
76
+ return info;
77
+ }
78
+ /**
79
+ * parser for parsing .ipa file
80
+ * @param {String | File | Blob} file // file's path in Node, instance of File or Blob in Browser
81
+ */ constructor(file){
82
+ super(file);
83
+ if (!(this instanceof IpaParser)) {
84
+ return new IpaParser(file);
85
+ }
91
86
  }
92
- return info;
93
- }
94
87
  }
95
-
96
- module.exports = IpaParser;
88
+ module.exports = IpaParser;