react-native-update-cli 1.46.2 → 2.0.1

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.
Files changed (68) hide show
  1. package/README.md +603 -1
  2. package/README.zh-CN.md +601 -0
  3. package/cli.json +39 -3
  4. package/lib/api.js +5 -5
  5. package/lib/app.js +1 -1
  6. package/lib/bundle.js +30 -28
  7. package/lib/exports.js +65 -0
  8. package/lib/index.js +100 -9
  9. package/lib/locales/en.js +2 -1
  10. package/lib/locales/zh.js +2 -1
  11. package/lib/module-manager.js +125 -0
  12. package/lib/modules/app-module.js +223 -0
  13. package/lib/modules/bundle-module.js +188 -0
  14. package/lib/modules/index.js +42 -0
  15. package/lib/modules/package-module.js +16 -0
  16. package/lib/modules/user-module.js +402 -0
  17. package/lib/modules/version-module.js +16 -0
  18. package/lib/package.js +40 -9
  19. package/lib/provider.js +341 -0
  20. package/lib/user.js +3 -3
  21. package/lib/utils/app-info-parser/apk.js +1 -1
  22. package/lib/utils/app-info-parser/ipa.js +2 -2
  23. package/lib/utils/app-info-parser/resource-finder.js +35 -35
  24. package/lib/utils/app-info-parser/xml-parser/manifest.js +2 -2
  25. package/lib/utils/app-info-parser/zip.js +3 -6
  26. package/lib/utils/check-plugin.js +1 -1
  27. package/lib/utils/git.js +1 -1
  28. package/lib/utils/i18n.js +3 -1
  29. package/lib/utils/index.js +4 -4
  30. package/lib/utils/latest-version/cli.js +3 -3
  31. package/lib/utils/latest-version/index.js +4 -4
  32. package/lib/versions.js +2 -2
  33. package/package.json +4 -4
  34. package/src/api.ts +7 -7
  35. package/src/app.ts +2 -2
  36. package/src/bundle.ts +44 -32
  37. package/src/exports.ts +30 -0
  38. package/src/index.ts +118 -16
  39. package/src/locales/en.ts +1 -0
  40. package/src/locales/zh.ts +1 -0
  41. package/src/module-manager.ts +149 -0
  42. package/src/modules/app-module.ts +205 -0
  43. package/src/modules/bundle-module.ts +202 -0
  44. package/src/modules/index.ts +19 -0
  45. package/src/modules/package-module.ts +11 -0
  46. package/src/modules/user-module.ts +406 -0
  47. package/src/modules/version-module.ts +8 -0
  48. package/src/package.ts +59 -25
  49. package/src/provider.ts +341 -0
  50. package/src/types.ts +126 -0
  51. package/src/user.ts +4 -3
  52. package/src/utils/app-info-parser/apk.js +62 -52
  53. package/src/utils/app-info-parser/app.js +5 -5
  54. package/src/utils/app-info-parser/ipa.js +69 -57
  55. package/src/utils/app-info-parser/resource-finder.js +50 -54
  56. package/src/utils/app-info-parser/utils.js +59 -54
  57. package/src/utils/app-info-parser/xml-parser/binary.js +366 -354
  58. package/src/utils/app-info-parser/xml-parser/manifest.js +145 -137
  59. package/src/utils/app-info-parser/zip.js +1 -1
  60. package/src/utils/check-plugin.ts +4 -2
  61. package/src/utils/dep-versions.ts +13 -6
  62. package/src/utils/git.ts +1 -1
  63. package/src/utils/i18n.ts +3 -1
  64. package/src/utils/index.ts +8 -10
  65. package/src/utils/latest-version/cli.ts +4 -4
  66. package/src/utils/latest-version/index.ts +17 -17
  67. package/src/utils/plugin-config.ts +3 -3
  68. package/src/versions.ts +3 -3
@@ -1,92 +1,104 @@
1
- const parsePlist = require('plist').parse
2
- const parseBplist = require('bplist-parser').parseBuffer
3
- const cgbiToPng = require('cgbi-to-png')
1
+ const parsePlist = require('plist').parse;
2
+ const parseBplist = require('bplist-parser').parseBuffer;
3
+ const cgbiToPng = require('cgbi-to-png');
4
4
 
5
- const Zip = require('./zip')
6
- const { findIpaIconPath, getBase64FromBuffer, isBrowser } = require('./utils')
5
+ const Zip = require('./zip');
6
+ const { findIpaIconPath, getBase64FromBuffer, isBrowser } = require('./utils');
7
7
 
8
- const PlistName = new RegExp('payload/[^/]+?.app/info.plist$', 'i')
9
- const ProvisionName = /payload\/.+?\.app\/embedded.mobileprovision/
8
+ const PlistName = /payload\/[^\/]+?.app\/info.plist$/i;
9
+ const ProvisionName = /payload\/.+?\.app\/embedded.mobileprovision/;
10
10
 
11
11
  class IpaParser extends Zip {
12
12
  /**
13
13
  * parser for parsing .ipa file
14
14
  * @param {String | File | Blob} file // file's path in Node, instance of File or Blob in Browser
15
15
  */
16
- constructor (file) {
17
- super(file)
16
+ constructor(file) {
17
+ super(file);
18
18
  if (!(this instanceof IpaParser)) {
19
- return new IpaParser(file)
19
+ return new IpaParser(file);
20
20
  }
21
21
  }
22
- parse () {
22
+ parse() {
23
23
  return new Promise((resolve, reject) => {
24
- this.getEntries([PlistName, ProvisionName]).then(buffers => {
25
- if (!buffers[PlistName]) {
26
- throw new Error('Info.plist can\'t be found.')
27
- }
28
- const plistInfo = this._parsePlist(buffers[PlistName])
29
- // parse mobile provision
30
- const provisionInfo = this._parseProvision(buffers[ProvisionName])
31
- plistInfo.mobileProvision = provisionInfo
32
-
33
- // find icon path and parse icon
34
- const iconRegex = new RegExp(findIpaIconPath(plistInfo).toLowerCase())
35
- this.getEntry(iconRegex).then(iconBuffer => {
36
- try {
37
- // In general, the ipa file's icon has been specially processed, should be converted
38
- plistInfo.icon = iconBuffer ? getBase64FromBuffer(cgbiToPng.revert(iconBuffer)) : null
39
- } catch (err) {
40
- if (isBrowser()) {
41
- // Normal conversion in other cases
42
- plistInfo.icon = iconBuffer ? getBase64FromBuffer(window.btoa(String.fromCharCode(...iconBuffer))) : null
43
- } else {
44
- plistInfo.icon = null
45
- console.warn('[Warning] failed to parse icon: ', err)
46
- }
24
+ this.getEntries([PlistName, ProvisionName])
25
+ .then((buffers) => {
26
+ if (!buffers[PlistName]) {
27
+ throw new Error("Info.plist can't be found.");
47
28
  }
48
- resolve(plistInfo)
49
- }).catch(e => {
50
- reject(e)
29
+ const plistInfo = this._parsePlist(buffers[PlistName]);
30
+ // parse mobile provision
31
+ const provisionInfo = this._parseProvision(buffers[ProvisionName]);
32
+ plistInfo.mobileProvision = provisionInfo;
33
+
34
+ // find icon path and parse icon
35
+ const iconRegex = new RegExp(
36
+ findIpaIconPath(plistInfo).toLowerCase(),
37
+ );
38
+ this.getEntry(iconRegex)
39
+ .then((iconBuffer) => {
40
+ try {
41
+ // In general, the ipa file's icon has been specially processed, should be converted
42
+ plistInfo.icon = iconBuffer
43
+ ? getBase64FromBuffer(cgbiToPng.revert(iconBuffer))
44
+ : null;
45
+ } catch (err) {
46
+ if (isBrowser()) {
47
+ // Normal conversion in other cases
48
+ plistInfo.icon = iconBuffer
49
+ ? getBase64FromBuffer(
50
+ window.btoa(String.fromCharCode(...iconBuffer)),
51
+ )
52
+ : null;
53
+ } else {
54
+ plistInfo.icon = null;
55
+ console.warn('[Warning] failed to parse icon: ', err);
56
+ }
57
+ }
58
+ resolve(plistInfo);
59
+ })
60
+ .catch((e) => {
61
+ reject(e);
62
+ });
51
63
  })
52
- }).catch(e => {
53
- reject(e)
54
- })
55
- })
64
+ .catch((e) => {
65
+ reject(e);
66
+ });
67
+ });
56
68
  }
57
69
  /**
58
70
  * Parse plist
59
71
  * @param {Buffer} buffer // plist file's buffer
60
72
  */
61
- _parsePlist (buffer) {
62
- let result
63
- const bufferType = buffer[0]
73
+ _parsePlist(buffer) {
74
+ let result;
75
+ const bufferType = buffer[0];
64
76
  if (bufferType === 60 || bufferType === '<' || bufferType === 239) {
65
- result = parsePlist(buffer.toString())
77
+ result = parsePlist(buffer.toString());
66
78
  } else if (bufferType === 98) {
67
- result = parseBplist(buffer)[0]
79
+ result = parseBplist(buffer)[0];
68
80
  } else {
69
- throw new Error('Unknown plist buffer type.')
81
+ throw new Error('Unknown plist buffer type.');
70
82
  }
71
- return result
83
+ return result;
72
84
  }
73
85
  /**
74
86
  * parse provision
75
87
  * @param {Buffer} buffer // provision file's buffer
76
88
  */
77
- _parseProvision (buffer) {
78
- let info = {}
89
+ _parseProvision(buffer) {
90
+ let info = {};
79
91
  if (buffer) {
80
- let content = buffer.toString('utf-8')
81
- const firstIndex = content.indexOf('<?xml')
82
- const endIndex = content.indexOf('</plist>')
83
- content = content.slice(firstIndex, endIndex + 8)
92
+ let content = buffer.toString('utf-8');
93
+ const firstIndex = content.indexOf('<?xml');
94
+ const endIndex = content.indexOf('</plist>');
95
+ content = content.slice(firstIndex, endIndex + 8);
84
96
  if (content) {
85
- info = parsePlist(content)
97
+ info = parsePlist(content);
86
98
  }
87
99
  }
88
- return info
100
+ return info;
89
101
  }
90
102
  }
91
103
 
92
- module.exports = IpaParser
104
+ module.exports = IpaParser;
@@ -4,7 +4,7 @@
4
4
  * Decode binary file `resources.arsc` from a .apk file to a JavaScript Object.
5
5
  */
6
6
 
7
- var ByteBuffer = require("bytebuffer");
7
+ var ByteBuffer = require('bytebuffer');
8
8
 
9
9
  var DEBUG = false;
10
10
 
@@ -39,13 +39,13 @@ function ResourceFinder() {
39
39
  * @param len length
40
40
  * @returns {Buffer}
41
41
  */
42
- ResourceFinder.readBytes = function(bb, len) {
42
+ ResourceFinder.readBytes = (bb, len) => {
43
43
  var uint8Array = new Uint8Array(len);
44
44
  for (var i = 0; i < len; i++) {
45
45
  uint8Array[i] = bb.readUint8();
46
46
  }
47
47
 
48
- return ByteBuffer.wrap(uint8Array, "binary", true);
48
+ return ByteBuffer.wrap(uint8Array, 'binary', true);
49
49
  };
50
50
 
51
51
  //
@@ -54,8 +54,8 @@ ResourceFinder.readBytes = function(bb, len) {
54
54
  * @param {ByteBuffer} bb
55
55
  * @return {Map<String, Set<String>>}
56
56
  */
57
- ResourceFinder.prototype.processResourceTable = function(resourceBuffer) {
58
- const bb = ByteBuffer.wrap(resourceBuffer, "binary", true);
57
+ ResourceFinder.prototype.processResourceTable = function (resourceBuffer) {
58
+ const bb = ByteBuffer.wrap(resourceBuffer, 'binary', true);
59
59
 
60
60
  // Resource table structure
61
61
  var type = bb.readShort(),
@@ -65,10 +65,10 @@ ResourceFinder.prototype.processResourceTable = function(resourceBuffer) {
65
65
  buffer,
66
66
  bb2;
67
67
  if (type != RES_TABLE_TYPE) {
68
- throw new Error("No RES_TABLE_TYPE found!");
68
+ throw new Error('No RES_TABLE_TYPE found!');
69
69
  }
70
70
  if (size != bb.limit) {
71
- throw new Error("The buffer size not matches to the resource table size.");
71
+ throw new Error('The buffer size not matches to the resource table size.');
72
72
  }
73
73
  bb.offset = headerSize;
74
74
 
@@ -90,14 +90,14 @@ ResourceFinder.prototype.processResourceTable = function(resourceBuffer) {
90
90
  if (realStringPoolCount == 0) {
91
91
  // Only the first string pool is processed.
92
92
  if (DEBUG) {
93
- console.log("Processing the string pool ...");
93
+ console.log('Processing the string pool ...');
94
94
  }
95
95
 
96
96
  buffer = new ByteBuffer(s);
97
97
  bb.offset = pos;
98
98
  bb.prependTo(buffer);
99
99
 
100
- bb2 = ByteBuffer.wrap(buffer, "binary", true);
100
+ bb2 = ByteBuffer.wrap(buffer, 'binary', true);
101
101
 
102
102
  bb2.LE();
103
103
  this.valueStringPool = this.processStringPool(bb2);
@@ -106,30 +106,30 @@ ResourceFinder.prototype.processResourceTable = function(resourceBuffer) {
106
106
  } else if (t == RES_TABLE_PACKAGE_TYPE) {
107
107
  // Process the package
108
108
  if (DEBUG) {
109
- console.log("Processing the package " + realPackageCount + " ...");
109
+ console.log('Processing the package ' + realPackageCount + ' ...');
110
110
  }
111
111
 
112
112
  buffer = new ByteBuffer(s);
113
113
  bb.offset = pos;
114
114
  bb.prependTo(buffer);
115
115
 
116
- bb2 = ByteBuffer.wrap(buffer, "binary", true);
116
+ bb2 = ByteBuffer.wrap(buffer, 'binary', true);
117
117
  bb2.LE();
118
118
  this.processPackage(bb2);
119
119
 
120
120
  realPackageCount++;
121
121
  } else {
122
- throw new Error("Unsupported type");
122
+ throw new Error('Unsupported type');
123
123
  }
124
124
  bb.offset = pos + s;
125
125
  if (!bb.remaining()) break;
126
126
  }
127
127
 
128
128
  if (realStringPoolCount != 1) {
129
- throw new Error("More than 1 string pool found!");
129
+ throw new Error('More than 1 string pool found!');
130
130
  }
131
131
  if (realPackageCount != packageCount) {
132
- throw new Error("Real package count not equals the declared count.");
132
+ throw new Error('Real package count not equals the declared count.');
133
133
  }
134
134
 
135
135
  return this.responseMap;
@@ -139,7 +139,7 @@ ResourceFinder.prototype.processResourceTable = function(resourceBuffer) {
139
139
  *
140
140
  * @param {ByteBuffer} bb
141
141
  */
142
- ResourceFinder.prototype.processPackage = function(bb) {
142
+ ResourceFinder.prototype.processPackage = function (bb) {
143
143
  // Package structure
144
144
  var type = bb.readShort(),
145
145
  headerSize = bb.readShort(),
@@ -159,12 +159,12 @@ ResourceFinder.prototype.processPackage = function(bb) {
159
159
 
160
160
  if (typeStrings != headerSize) {
161
161
  throw new Error(
162
- "TypeStrings must immediately following the package structure header."
162
+ 'TypeStrings must immediately following the package structure header.',
163
163
  );
164
164
  }
165
165
 
166
166
  if (DEBUG) {
167
- console.log("Type strings:");
167
+ console.log('Type strings:');
168
168
  }
169
169
 
170
170
  var lastPosition = bb.offset;
@@ -175,7 +175,7 @@ ResourceFinder.prototype.processPackage = function(bb) {
175
175
 
176
176
  // Key strings
177
177
  if (DEBUG) {
178
- console.log("Key strings:");
178
+ console.log('Key strings:');
179
179
  }
180
180
 
181
181
  bb.offset = keyStrings;
@@ -237,7 +237,7 @@ ResourceFinder.prototype.processPackage = function(bb) {
237
237
  *
238
238
  * @param {ByteBuffer} bb
239
239
  */
240
- ResourceFinder.prototype.processType = function(bb) {
240
+ ResourceFinder.prototype.processType = function (bb) {
241
241
  var type = bb.readShort(),
242
242
  headerSize = bb.readShort(),
243
243
  size = bb.readInt(),
@@ -255,7 +255,7 @@ ResourceFinder.prototype.processType = function(bb) {
255
255
  bb.offset = headerSize;
256
256
 
257
257
  if (headerSize + entryCount * 4 != entriesStart) {
258
- throw new Error("HeaderSize, entryCount and entriesStart are not valid.");
258
+ throw new Error('HeaderSize, entryCount and entriesStart are not valid.');
259
259
  }
260
260
 
261
261
  // Start to get entry indices
@@ -279,11 +279,11 @@ ResourceFinder.prototype.processType = function(bb) {
279
279
  value_dataType,
280
280
  value_data;
281
281
  try {
282
- entry_size = bb.readShort()
283
- entry_flag = bb.readShort()
284
- entry_key = bb.readInt()
282
+ entry_size = bb.readShort();
283
+ entry_flag = bb.readShort();
284
+ entry_key = bb.readInt();
285
285
  } catch (e) {
286
- break
286
+ break;
287
287
  }
288
288
 
289
289
  // Get the value (simple) or map (complex)
@@ -303,11 +303,11 @@ ResourceFinder.prototype.processType = function(bb) {
303
303
 
304
304
  if (DEBUG) {
305
305
  console.log(
306
- "Entry 0x" + idStr + ", key: " + keyStr + ", simple value type: "
306
+ 'Entry 0x' + idStr + ', key: ' + keyStr + ', simple value type: ',
307
307
  );
308
308
  }
309
309
 
310
- var key = parseInt(idStr, 16);
310
+ var key = Number.parseInt(idStr, 16);
311
311
 
312
312
  var entryArr = this.entryMap[key];
313
313
  if (entryArr == null) {
@@ -321,20 +321,20 @@ ResourceFinder.prototype.processType = function(bb) {
321
321
  data = this.valueStringPool[value_data];
322
322
 
323
323
  if (DEBUG) {
324
- console.log(", data: " + this.valueStringPool[value_data] + "");
324
+ console.log(', data: ' + this.valueStringPool[value_data] + '');
325
325
  }
326
326
  } else if (value_dataType == TYPE_REFERENCE) {
327
327
  var hexIndex = Number(value_data).toString(16);
328
328
 
329
329
  refKeys[idStr] = value_data;
330
330
  } else {
331
- data = "" + value_data;
331
+ data = '' + value_data;
332
332
  if (DEBUG) {
333
- console.log(", data: " + value_data + "");
333
+ console.log(', data: ' + value_data + '');
334
334
  }
335
335
  }
336
336
 
337
- this.putIntoMap("@" + idStr, data);
337
+ this.putIntoMap('@' + idStr, data);
338
338
  } else {
339
339
  // Complex case
340
340
  var entry_parent = bb.readInt();
@@ -350,26 +350,22 @@ ResourceFinder.prototype.processType = function(bb) {
350
350
 
351
351
  if (DEBUG) {
352
352
  console.log(
353
- "Entry 0x" +
353
+ 'Entry 0x' +
354
354
  Number(resource_id).toString(16) +
355
- ", key: " +
355
+ ', key: ' +
356
356
  this.keyStringPool[entry_key] +
357
- ", complex value, not printed."
357
+ ', complex value, not printed.',
358
358
  );
359
359
  }
360
360
  }
361
361
  }
362
362
 
363
363
  for (var refK in refKeys) {
364
- var values = this.responseMap[
365
- "@" +
366
- Number(refKeys[refK])
367
- .toString(16)
368
- .toUpperCase()
369
- ];
364
+ var values =
365
+ this.responseMap['@' + Number(refKeys[refK]).toString(16).toUpperCase()];
370
366
  if (values != null && Object.keys(values).length < 1000) {
371
367
  for (var value in values) {
372
- this.putIntoMap("@" + refK, values[value]);
368
+ this.putIntoMap('@' + refK, values[value]);
373
369
  }
374
370
  }
375
371
  }
@@ -380,7 +376,7 @@ ResourceFinder.prototype.processType = function(bb) {
380
376
  * @param {ByteBuffer} bb
381
377
  * @return {Array}
382
378
  */
383
- ResourceFinder.prototype.processStringPool = function(bb) {
379
+ ResourceFinder.prototype.processStringPool = (bb) => {
384
380
  // String pool structure
385
381
  //
386
382
  var type = bb.readShort(),
@@ -407,7 +403,7 @@ ResourceFinder.prototype.processStringPool = function(bb) {
407
403
  var pos = stringsStart + offsets[i];
408
404
  bb.offset = pos;
409
405
 
410
- strings[i] = "";
406
+ strings[i] = '';
411
407
 
412
408
  if (isUTF_8) {
413
409
  u16len = bb.readUint8();
@@ -424,15 +420,15 @@ ResourceFinder.prototype.processStringPool = function(bb) {
424
420
  if (u8len > 0) {
425
421
  buffer = ResourceFinder.readBytes(bb, u8len);
426
422
  try {
427
- strings[i] = ByteBuffer.wrap(buffer, "utf8", true).toString("utf8");
423
+ strings[i] = ByteBuffer.wrap(buffer, 'utf8', true).toString('utf8');
428
424
  } catch (e) {
429
425
  if (DEBUG) {
430
426
  console.error(e);
431
- console.log("Error when turning buffer to utf-8 string.");
427
+ console.log('Error when turning buffer to utf-8 string.');
432
428
  }
433
429
  }
434
430
  } else {
435
- strings[i] = "";
431
+ strings[i] = '';
436
432
  }
437
433
  } else {
438
434
  u16len = bb.readUint16();
@@ -445,18 +441,18 @@ ResourceFinder.prototype.processStringPool = function(bb) {
445
441
  var len = u16len * 2;
446
442
  buffer = ResourceFinder.readBytes(bb, len);
447
443
  try {
448
- strings[i] = ByteBuffer.wrap(buffer, "utf8", true).toString("utf8");
444
+ strings[i] = ByteBuffer.wrap(buffer, 'utf8', true).toString('utf8');
449
445
  } catch (e) {
450
446
  if (DEBUG) {
451
447
  console.error(e);
452
- console.log("Error when turning buffer to utf-8 string.");
448
+ console.log('Error when turning buffer to utf-8 string.');
453
449
  }
454
450
  }
455
451
  }
456
452
  }
457
453
 
458
454
  if (DEBUG) {
459
- console.log("Parsed value: {0}", strings[i]);
455
+ console.log('Parsed value: {0}', strings[i]);
460
456
  }
461
457
  }
462
458
 
@@ -467,7 +463,7 @@ ResourceFinder.prototype.processStringPool = function(bb) {
467
463
  *
468
464
  * @param {ByteBuffer} bb
469
465
  */
470
- ResourceFinder.prototype.processTypeSpec = function(bb) {
466
+ ResourceFinder.prototype.processTypeSpec = function (bb) {
471
467
  var type = bb.readShort(),
472
468
  headerSize = bb.readShort(),
473
469
  size = bb.readInt(),
@@ -477,7 +473,7 @@ ResourceFinder.prototype.processTypeSpec = function(bb) {
477
473
  entryCount = bb.readInt();
478
474
 
479
475
  if (DEBUG) {
480
- console.log("Processing type spec " + this.typeStringPool[id - 1] + "...");
476
+ console.log('Processing type spec ' + this.typeStringPool[id - 1] + '...');
481
477
  }
482
478
 
483
479
  var flags = new Array(entryCount);
@@ -487,12 +483,12 @@ ResourceFinder.prototype.processTypeSpec = function(bb) {
487
483
  }
488
484
  };
489
485
 
490
- ResourceFinder.prototype.putIntoMap = function(resId, value) {
486
+ ResourceFinder.prototype.putIntoMap = function (resId, value) {
491
487
  if (this.responseMap[resId.toUpperCase()] == null) {
492
- this.responseMap[resId.toUpperCase()] = []
488
+ this.responseMap[resId.toUpperCase()] = [];
493
489
  }
494
- if(value){
495
- this.responseMap[resId.toUpperCase()].push(value)
490
+ if (value) {
491
+ this.responseMap[resId.toUpperCase()].push(value);
496
492
  }
497
493
  };
498
494