react-native-update-cli 2.8.0 → 2.8.2

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/lib/diff.js ADDED
@@ -0,0 +1,387 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ diffCommands: function() {
13
+ return diffCommands;
14
+ },
15
+ enumZipEntries: function() {
16
+ return _zipentries.enumZipEntries;
17
+ },
18
+ readEntry: function() {
19
+ return _zipentries.readEntry;
20
+ }
21
+ });
22
+ const _path = /*#__PURE__*/ _interop_require_default(require("path"));
23
+ const _fsextra = /*#__PURE__*/ _interop_require_wildcard(require("fs-extra"));
24
+ const _globaldirectory = /*#__PURE__*/ _interop_require_default(require("global-directory"));
25
+ const _yazl = require("yazl");
26
+ const _utils = require("./utils");
27
+ const _constants = require("./utils/constants");
28
+ const _i18n = require("./utils/i18n");
29
+ const _zipentries = require("./utils/zip-entries");
30
+ function _interop_require_default(obj) {
31
+ return obj && obj.__esModule ? obj : {
32
+ default: obj
33
+ };
34
+ }
35
+ function _getRequireWildcardCache(nodeInterop) {
36
+ if (typeof WeakMap !== "function") return null;
37
+ var cacheBabelInterop = new WeakMap();
38
+ var cacheNodeInterop = new WeakMap();
39
+ return (_getRequireWildcardCache = function(nodeInterop) {
40
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
41
+ })(nodeInterop);
42
+ }
43
+ function _interop_require_wildcard(obj, nodeInterop) {
44
+ if (!nodeInterop && obj && obj.__esModule) {
45
+ return obj;
46
+ }
47
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
48
+ return {
49
+ default: obj
50
+ };
51
+ }
52
+ var cache = _getRequireWildcardCache(nodeInterop);
53
+ if (cache && cache.has(obj)) {
54
+ return cache.get(obj);
55
+ }
56
+ var newObj = {
57
+ __proto__: null
58
+ };
59
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
60
+ for(var key in obj){
61
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
62
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
63
+ if (desc && (desc.get || desc.set)) {
64
+ Object.defineProperty(newObj, key, desc);
65
+ } else {
66
+ newObj[key] = obj[key];
67
+ }
68
+ }
69
+ }
70
+ newObj.default = obj;
71
+ if (cache) {
72
+ cache.set(obj, newObj);
73
+ }
74
+ return newObj;
75
+ }
76
+ var _loadDiffModule;
77
+ const { npm, yarn } = _globaldirectory.default;
78
+ const loadDiffModule = (pkgName)=>{
79
+ const resolvePaths = [
80
+ process.cwd(),
81
+ npm.packages,
82
+ yarn.packages
83
+ ];
84
+ try {
85
+ const resolved = require.resolve(pkgName, {
86
+ paths: resolvePaths
87
+ });
88
+ const mod = require(resolved);
89
+ if (mod == null ? void 0 : mod.diff) {
90
+ return mod.diff;
91
+ }
92
+ } catch (e) {}
93
+ return undefined;
94
+ };
95
+ let hdiff;
96
+ hdiff = (_loadDiffModule = loadDiffModule('node-hdiffpatch')) == null ? void 0 : _loadDiffModule.diff;
97
+ let bsdiff;
98
+ let diff;
99
+ bsdiff = loadDiffModule('node-bsdiff');
100
+ function basename(fn) {
101
+ const m = /^(.+\/)[^\/]+\/?$/.exec(fn);
102
+ return m == null ? void 0 : m[1];
103
+ }
104
+ async function diffFromPPK(origin, next, output) {
105
+ _fsextra.ensureDirSync(_path.default.dirname(output));
106
+ const originEntries = {};
107
+ const originMap = {};
108
+ let originSource;
109
+ await (0, _zipentries.enumZipEntries)(origin, (entry, zipFile)=>{
110
+ originEntries[entry.fileName] = entry;
111
+ if (!/\/$/.test(entry.fileName)) {
112
+ // isFile
113
+ originMap[entry.crc32] = entry.fileName;
114
+ if ((0, _constants.isPPKBundleFileName)(entry.fileName)) {
115
+ // This is source.
116
+ return (0, _zipentries.readEntry)(entry, zipFile).then((v)=>originSource = v);
117
+ }
118
+ }
119
+ });
120
+ if (!originSource) {
121
+ throw new Error((0, _i18n.t)('bundleFileNotFound'));
122
+ }
123
+ const copies = {};
124
+ const zipfile = new _yazl.ZipFile();
125
+ const writePromise = new Promise((resolve, reject)=>{
126
+ zipfile.outputStream.on('error', (err)=>{
127
+ throw err;
128
+ });
129
+ zipfile.outputStream.pipe(_fsextra.createWriteStream(output)).on('close', ()=>{
130
+ resolve(void 0);
131
+ });
132
+ });
133
+ const addedEntry = {};
134
+ function addEntry(fn) {
135
+ //console.log(fn);
136
+ if (!fn || addedEntry[fn]) {
137
+ return;
138
+ }
139
+ const base = basename(fn);
140
+ if (base) {
141
+ addEntry(base);
142
+ }
143
+ zipfile.addEmptyDirectory(fn);
144
+ }
145
+ const newEntries = {};
146
+ await (0, _zipentries.enumZipEntries)(next, (entry, nextZipfile)=>{
147
+ newEntries[entry.fileName] = entry;
148
+ if (/\/$/.test(entry.fileName)) {
149
+ // Directory
150
+ if (!originEntries[entry.fileName]) {
151
+ addEntry(entry.fileName);
152
+ }
153
+ } else if ((0, _constants.isPPKBundleFileName)(entry.fileName)) {
154
+ //console.log('Found bundle');
155
+ return (0, _zipentries.readEntry)(entry, nextZipfile).then((newSource)=>{
156
+ //console.log('Begin diff');
157
+ zipfile.addBuffer(diff(originSource, newSource), `${entry.fileName}.patch`);
158
+ //console.log('End diff');
159
+ });
160
+ } else {
161
+ // If same file.
162
+ const originEntry = originEntries[entry.fileName];
163
+ if (originEntry && originEntry.crc32 === entry.crc32) {
164
+ // ignore
165
+ return;
166
+ }
167
+ // If moved from other place
168
+ if (originMap[entry.crc32]) {
169
+ const base = basename(entry.fileName);
170
+ if (!originEntries[base]) {
171
+ addEntry(base);
172
+ }
173
+ copies[entry.fileName] = originMap[entry.crc32];
174
+ return;
175
+ }
176
+ // New file.
177
+ addEntry(basename(entry.fileName));
178
+ return new Promise((resolve, reject)=>{
179
+ nextZipfile.openReadStream(entry, (err, readStream)=>{
180
+ if (err) {
181
+ return reject(err);
182
+ }
183
+ zipfile.addReadStream(readStream, entry.fileName);
184
+ readStream.on('end', ()=>{
185
+ //console.log('add finished');
186
+ resolve(void 0);
187
+ });
188
+ });
189
+ });
190
+ }
191
+ });
192
+ const deletes = {};
193
+ for(const k in originEntries){
194
+ if (!newEntries[k]) {
195
+ console.log((0, _i18n.t)('deleteFile', {
196
+ file: k
197
+ }));
198
+ deletes[k] = 1;
199
+ }
200
+ }
201
+ //console.log({copies, deletes});
202
+ zipfile.addBuffer(Buffer.from(JSON.stringify({
203
+ copies,
204
+ deletes
205
+ })), '__diff.json');
206
+ zipfile.end();
207
+ await writePromise;
208
+ }
209
+ async function diffFromPackage(origin, next, output, originBundleName, transformPackagePath = (v)=>v) {
210
+ _fsextra.ensureDirSync(_path.default.dirname(output));
211
+ const originEntries = {};
212
+ const originMap = {};
213
+ let originSource;
214
+ await (0, _zipentries.enumZipEntries)(origin, (entry, zipFile)=>{
215
+ if (!/\/$/.test(entry.fileName)) {
216
+ const fn = transformPackagePath(entry.fileName);
217
+ if (!fn) {
218
+ return;
219
+ }
220
+ //console.log(fn);
221
+ // isFile
222
+ originEntries[fn] = entry.crc32;
223
+ originMap[entry.crc32] = fn;
224
+ if (fn === originBundleName) {
225
+ // This is source.
226
+ return (0, _zipentries.readEntry)(entry, zipFile).then((v)=>originSource = v);
227
+ }
228
+ }
229
+ });
230
+ if (!originSource) {
231
+ throw new Error((0, _i18n.t)('bundleFileNotFound'));
232
+ }
233
+ const copies = {};
234
+ const zipfile = new _yazl.ZipFile();
235
+ const writePromise = new Promise((resolve, reject)=>{
236
+ zipfile.outputStream.on('error', (err)=>{
237
+ throw err;
238
+ });
239
+ zipfile.outputStream.pipe(_fsextra.createWriteStream(output)).on('close', ()=>{
240
+ resolve(void 0);
241
+ });
242
+ });
243
+ await (0, _zipentries.enumZipEntries)(next, (entry, nextZipfile)=>{
244
+ if (/\/$/.test(entry.fileName)) {
245
+ // Directory
246
+ zipfile.addEmptyDirectory(entry.fileName);
247
+ } else if ((0, _constants.isPPKBundleFileName)(entry.fileName)) {
248
+ //console.log('Found bundle');
249
+ return (0, _zipentries.readEntry)(entry, nextZipfile).then((newSource)=>{
250
+ //console.log('Begin diff');
251
+ zipfile.addBuffer(diff(originSource, newSource), `${entry.fileName}.patch`);
252
+ //console.log('End diff');
253
+ });
254
+ } else {
255
+ // If same file.
256
+ if (originEntries[entry.fileName] === entry.crc32) {
257
+ copies[entry.fileName] = '';
258
+ return;
259
+ }
260
+ // If moved from other place
261
+ if (originMap[entry.crc32]) {
262
+ copies[entry.fileName] = originMap[entry.crc32];
263
+ return;
264
+ }
265
+ return new Promise((resolve, reject)=>{
266
+ nextZipfile.openReadStream(entry, (err, readStream)=>{
267
+ if (err) {
268
+ return reject(err);
269
+ }
270
+ zipfile.addReadStream(readStream, entry.fileName);
271
+ readStream.on('end', ()=>{
272
+ //console.log('add finished');
273
+ resolve(void 0);
274
+ });
275
+ });
276
+ });
277
+ }
278
+ });
279
+ zipfile.addBuffer(Buffer.from(JSON.stringify({
280
+ copies
281
+ })), '__diff.json');
282
+ zipfile.end();
283
+ await writePromise;
284
+ }
285
+ function diffArgsCheck(args, options, diffFn) {
286
+ const [origin, next] = args;
287
+ if (!origin || !next) {
288
+ console.error((0, _i18n.t)('usageDiff', {
289
+ command: diffFn
290
+ }));
291
+ process.exit(1);
292
+ }
293
+ if (options == null ? void 0 : options.customDiff) {
294
+ diff = options.customDiff;
295
+ } else {
296
+ if (diffFn.startsWith('hdiff')) {
297
+ if (!hdiff) {
298
+ console.error((0, _i18n.t)('nodeHdiffpatchRequired', {
299
+ scriptName: _constants.scriptName
300
+ }));
301
+ process.exit(1);
302
+ }
303
+ diff = hdiff;
304
+ } else {
305
+ if (!bsdiff) {
306
+ console.error((0, _i18n.t)('nodeBsdiffRequired', {
307
+ scriptName: _constants.scriptName
308
+ }));
309
+ process.exit(1);
310
+ }
311
+ diff = bsdiff;
312
+ }
313
+ }
314
+ const { output } = (0, _utils.translateOptions)({
315
+ ...options,
316
+ tempDir: _constants.tempDir
317
+ });
318
+ return {
319
+ origin,
320
+ next,
321
+ realOutput: output.replace(/\$\{time\}/g, `${Date.now()}`)
322
+ };
323
+ }
324
+ const diffCommands = {
325
+ async diff ({ args, options }) {
326
+ const { origin, next, realOutput } = diffArgsCheck(args, options, 'diff');
327
+ await diffFromPPK(origin, next, realOutput);
328
+ console.log((0, _i18n.t)('diffPackageGenerated', {
329
+ output: realOutput
330
+ }));
331
+ },
332
+ async hdiff ({ args, options }) {
333
+ const { origin, next, realOutput } = diffArgsCheck(args, options, 'hdiff');
334
+ await diffFromPPK(origin, next, realOutput);
335
+ console.log((0, _i18n.t)('diffPackageGenerated', {
336
+ output: realOutput
337
+ }));
338
+ },
339
+ async diffFromApk ({ args, options }) {
340
+ const { origin, next, realOutput } = diffArgsCheck(args, options, 'diffFromApk');
341
+ await diffFromPackage(origin, next, realOutput, 'assets/index.android.bundle');
342
+ console.log((0, _i18n.t)('diffPackageGenerated', {
343
+ output: realOutput
344
+ }));
345
+ },
346
+ async hdiffFromApk ({ args, options }) {
347
+ const { origin, next, realOutput } = diffArgsCheck(args, options, 'hdiffFromApk');
348
+ await diffFromPackage(origin, next, realOutput, 'assets/index.android.bundle');
349
+ console.log((0, _i18n.t)('diffPackageGenerated', {
350
+ output: realOutput
351
+ }));
352
+ },
353
+ async diffFromApp ({ args, options }) {
354
+ const { origin, next, realOutput } = diffArgsCheck(args, options, 'diffFromApp');
355
+ await diffFromPackage(origin, next, realOutput, 'resources/rawfile/bundle.harmony.js');
356
+ console.log((0, _i18n.t)('diffPackageGenerated', {
357
+ output: realOutput
358
+ }));
359
+ },
360
+ async hdiffFromApp ({ args, options }) {
361
+ const { origin, next, realOutput } = diffArgsCheck(args, options, 'hdiffFromApp');
362
+ await diffFromPackage(origin, next, realOutput, 'resources/rawfile/bundle.harmony.js');
363
+ console.log((0, _i18n.t)('diffPackageGenerated', {
364
+ output: realOutput
365
+ }));
366
+ },
367
+ async diffFromIpa ({ args, options }) {
368
+ const { origin, next, realOutput } = diffArgsCheck(args, options, 'diffFromIpa');
369
+ await diffFromPackage(origin, next, realOutput, 'main.jsbundle', (v)=>{
370
+ const m = /^Payload\/[^/]+\/(.+)$/.exec(v);
371
+ return m == null ? void 0 : m[1];
372
+ });
373
+ console.log((0, _i18n.t)('diffPackageGenerated', {
374
+ output: realOutput
375
+ }));
376
+ },
377
+ async hdiffFromIpa ({ args, options }) {
378
+ const { origin, next, realOutput } = diffArgsCheck(args, options, 'hdiffFromIpa');
379
+ await diffFromPackage(origin, next, realOutput, 'main.jsbundle', (v)=>{
380
+ const m = /^Payload\/[^/]+\/(.+)$/.exec(v);
381
+ return m == null ? void 0 : m[1];
382
+ });
383
+ console.log((0, _i18n.t)('diffPackageGenerated', {
384
+ output: realOutput
385
+ }));
386
+ }
387
+ };
package/lib/index.js CHANGED
@@ -20,6 +20,7 @@ _export(exports, {
20
20
  const _api = require("./api");
21
21
  const _app = require("./app");
22
22
  const _bundle = require("./bundle");
23
+ const _diff = require("./diff");
23
24
  const _install = require("./install");
24
25
  const _modulemanager = require("./module-manager");
25
26
  const _modules = require("./modules");
@@ -45,6 +46,7 @@ function printUsage() {
45
46
  const legacyCommands = {
46
47
  ..._user.userCommands,
47
48
  ..._bundle.bundleCommands,
49
+ ..._diff.diffCommands,
48
50
  ..._app.appCommands,
49
51
  ..._package.packageCommands,
50
52
  ..._versions.versionCommands,
@@ -77,6 +79,7 @@ function printUsage() {
77
79
  const legacyCommands = {
78
80
  ..._user.userCommands,
79
81
  ..._bundle.bundleCommands,
82
+ ..._diff.diffCommands,
80
83
  ..._app.appCommands,
81
84
  ..._package.packageCommands,
82
85
  ..._versions.versionCommands,
@@ -46,7 +46,6 @@ const isPrimitive = (value)=>value === null || [
46
46
  'string',
47
47
  'undefined'
48
48
  ].includes(objectType(value));
49
- const isBrowser = ()=>typeof process === 'undefined' || Object.prototype.toString.call(process) !== '[object process]';
50
49
  /**
51
50
  * map file place with resourceMap
52
51
  * @param {Object} apkInfo // json info parsed from .apk file
@@ -9,8 +9,14 @@ Object.defineProperty(exports, "Zip", {
9
9
  }
10
10
  });
11
11
  const _utils = require("./utils");
12
+ const _path = /*#__PURE__*/ _interop_require_default(require("path"));
13
+ const _zipentries = require("../zip-entries");
14
+ function _interop_require_default(obj) {
15
+ return obj && obj.__esModule ? obj : {
16
+ default: obj
17
+ };
18
+ }
12
19
  const Unzip = require('isomorphic-unzip');
13
- let bundleZipUtils;
14
20
  class Zip {
15
21
  /**
16
22
  * get entries by regexps, the return format is: { <filename>: <Buffer|Blob> }
@@ -44,11 +50,10 @@ class Zip {
44
50
  }
45
51
  async getEntryFromHarmonyApp(regex) {
46
52
  try {
47
- const { enumZipEntries, readEntry } = bundleZipUtils != null ? bundleZipUtils : bundleZipUtils = require('../../bundle');
48
53
  let originSource;
49
- await enumZipEntries(this.file, (entry, zipFile)=>{
54
+ await (0, _zipentries.enumZipEntries)(this.file, (entry, zipFile)=>{
50
55
  if (regex.test(entry.fileName)) {
51
- return readEntry(entry, zipFile).then((value)=>{
56
+ return (0, _zipentries.readEntry)(entry, zipFile).then((value)=>{
52
57
  originSource = value;
53
58
  });
54
59
  }
@@ -59,17 +64,10 @@ class Zip {
59
64
  }
60
65
  }
61
66
  constructor(file){
62
- if ((0, _utils.isBrowser)()) {
63
- if (!(file instanceof window.Blob || typeof file.size !== 'undefined')) {
64
- throw new Error('Param error: [file] must be an instance of Blob or File in browser.');
65
- }
66
- this.file = file;
67
- } else {
68
- if (typeof file !== 'string') {
69
- throw new Error('Param error: [file] must be file path in Node.');
70
- }
71
- this.file = require('path').resolve(file);
67
+ if (typeof file !== 'string') {
68
+ throw new Error('Param error: [file] must be file path in Node.');
72
69
  }
70
+ this.file = _path.default.resolve(file);
73
71
  this.unzip = new Unzip(this.file);
74
72
  }
75
73
  }
@@ -20,7 +20,7 @@ const _fs = require("fs");
20
20
  const _os = require("os");
21
21
  const _path = require("path");
22
22
  const _url = require("url");
23
- const _globaldirs = require("global-dirs");
23
+ const _globaldirectory = /*#__PURE__*/ _interop_require_default(require("global-directory"));
24
24
  const _registryauthtoken = /*#__PURE__*/ _interop_require_default(require("registry-auth-token"));
25
25
  const _registryurl = /*#__PURE__*/ _interop_require_default(require("registry-auth-token/registry-url"));
26
26
  const _gt = /*#__PURE__*/ _interop_require_default(require("semver/functions/gt"));
@@ -30,6 +30,7 @@ function _interop_require_default(obj) {
30
30
  default: obj
31
31
  };
32
32
  }
33
+ const { npm, yarn } = _globaldirectory.default;
33
34
  const ONE_DAY = 1000 * 60 * 60 * 24; // eslint-disable-line @typescript-eslint/naming-convention
34
35
  const isPackageJson = (obj)=>{
35
36
  return obj.dependencies !== undefined || obj.devDependencies !== undefined || obj.peerDependencies !== undefined;
@@ -172,15 +173,15 @@ const getInstalledVersion = (pkgName, location = 'local')=>{
172
173
  try {
173
174
  if (location === 'globalNpm') {
174
175
  var _require;
175
- return (_require = require((0, _path.join)(_globaldirs.npm.packages, pkgName, 'package.json'))) == null ? void 0 : _require.version;
176
+ return (_require = require((0, _path.join)(npm.packages, pkgName, 'package.json'))) == null ? void 0 : _require.version;
176
177
  } else if (location === 'globalYarn') {
177
178
  var _yarnGlobalPkg_dependencies, _require1;
178
179
  // Make sure package is globally installed by Yarn
179
- const yarnGlobalPkg = require((0, _path.resolve)(_globaldirs.yarn.packages, '..', 'package.json'));
180
+ const yarnGlobalPkg = require((0, _path.resolve)(yarn.packages, '..', 'package.json'));
180
181
  if (!(yarnGlobalPkg == null ? void 0 : (_yarnGlobalPkg_dependencies = yarnGlobalPkg.dependencies) == null ? void 0 : _yarnGlobalPkg_dependencies[pkgName])) {
181
182
  return undefined;
182
183
  }
183
- return (_require1 = require((0, _path.join)(_globaldirs.yarn.packages, pkgName, 'package.json'))) == null ? void 0 : _require1.version;
184
+ return (_require1 = require((0, _path.join)(yarn.packages, pkgName, 'package.json'))) == null ? void 0 : _require1.version;
184
185
  } else {
185
186
  /**
186
187
  * Compute the local paths manually as require.resolve() and require.resolve.paths()
@@ -0,0 +1,129 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ enumZipEntries: function() {
13
+ return enumZipEntries;
14
+ },
15
+ readEntry: function() {
16
+ return readEntry;
17
+ }
18
+ });
19
+ const _os = /*#__PURE__*/ _interop_require_default(require("os"));
20
+ const _path = /*#__PURE__*/ _interop_require_default(require("path"));
21
+ const _fsextra = /*#__PURE__*/ _interop_require_wildcard(require("fs-extra"));
22
+ const _yauzl = require("yauzl");
23
+ const _i18n = require("./i18n");
24
+ function _interop_require_default(obj) {
25
+ return obj && obj.__esModule ? obj : {
26
+ default: obj
27
+ };
28
+ }
29
+ function _getRequireWildcardCache(nodeInterop) {
30
+ if (typeof WeakMap !== "function") return null;
31
+ var cacheBabelInterop = new WeakMap();
32
+ var cacheNodeInterop = new WeakMap();
33
+ return (_getRequireWildcardCache = function(nodeInterop) {
34
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
35
+ })(nodeInterop);
36
+ }
37
+ function _interop_require_wildcard(obj, nodeInterop) {
38
+ if (!nodeInterop && obj && obj.__esModule) {
39
+ return obj;
40
+ }
41
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
42
+ return {
43
+ default: obj
44
+ };
45
+ }
46
+ var cache = _getRequireWildcardCache(nodeInterop);
47
+ if (cache && cache.has(obj)) {
48
+ return cache.get(obj);
49
+ }
50
+ var newObj = {
51
+ __proto__: null
52
+ };
53
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
54
+ for(var key in obj){
55
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
56
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
57
+ if (desc && (desc.get || desc.set)) {
58
+ Object.defineProperty(newObj, key, desc);
59
+ } else {
60
+ newObj[key] = obj[key];
61
+ }
62
+ }
63
+ }
64
+ newObj.default = obj;
65
+ if (cache) {
66
+ cache.set(obj, newObj);
67
+ }
68
+ return newObj;
69
+ }
70
+ function readEntry(entry, zipFile) {
71
+ const buffers = [];
72
+ return new Promise((resolve, reject)=>{
73
+ zipFile.openReadStream(entry, (err, stream)=>{
74
+ stream.on('data', (chunk)=>{
75
+ buffers.push(chunk);
76
+ });
77
+ stream.on('end', ()=>{
78
+ resolve(Buffer.concat(buffers));
79
+ });
80
+ stream.on('error', (err)=>{
81
+ reject(err);
82
+ });
83
+ });
84
+ });
85
+ }
86
+ async function enumZipEntries(zipFn, callback, nestedPath = '') {
87
+ return new Promise((resolve, reject)=>{
88
+ (0, _yauzl.open)(zipFn, {
89
+ lazyEntries: true
90
+ }, async (err, zipfile)=>{
91
+ if (err) {
92
+ return reject(err);
93
+ }
94
+ zipfile.on('end', resolve);
95
+ zipfile.on('error', reject);
96
+ zipfile.on('entry', async (entry)=>{
97
+ const fullPath = nestedPath + entry.fileName;
98
+ try {
99
+ if (!entry.fileName.endsWith('/') && entry.fileName.toLowerCase().endsWith('.hap')) {
100
+ const tempDir = _path.default.join(_os.default.tmpdir(), `nested_zip_${Date.now()}`);
101
+ await _fsextra.ensureDir(tempDir);
102
+ const tempZipPath = _path.default.join(tempDir, 'temp.zip');
103
+ await new Promise((res, rej)=>{
104
+ zipfile.openReadStream(entry, async (err, readStream)=>{
105
+ if (err) return rej(err);
106
+ const writeStream = _fsextra.createWriteStream(tempZipPath);
107
+ readStream.pipe(writeStream);
108
+ writeStream.on('finish', ()=>res(void 0));
109
+ writeStream.on('error', rej);
110
+ });
111
+ });
112
+ await enumZipEntries(tempZipPath, callback, `${fullPath}/`);
113
+ await _fsextra.remove(tempDir);
114
+ }
115
+ const result = callback(entry, zipfile, fullPath);
116
+ if (result && typeof result.then === 'function') {
117
+ await result;
118
+ }
119
+ } catch (error) {
120
+ console.error((0, _i18n.t)('processingError', {
121
+ error
122
+ }));
123
+ }
124
+ zipfile.readEntry();
125
+ });
126
+ zipfile.readEntry();
127
+ });
128
+ });
129
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-update-cli",
3
- "version": "2.8.0",
3
+ "version": "2.8.2",
4
4
  "description": "command line tool for react-native-update (remote updates for react native)",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -47,7 +47,7 @@
47
47
  "filesize-parser": "^1.5.1",
48
48
  "form-data": "^4.0.2",
49
49
  "fs-extra": "8",
50
- "global-dirs": "^4.0.0",
50
+ "global-directory": "^4.0.1",
51
51
  "gradle-to-js": "^2.0.1",
52
52
  "i18next": "^24.2.3",
53
53
  "isomorphic-git": "^1.30.1",
@@ -84,12 +84,8 @@
84
84
  "@types/yazl": "^2.4.6",
85
85
  "typescript": "^5.8.3"
86
86
  },
87
- "optionalDependencies": {
88
- "node-hdiffpatch": "^1.2.1"
89
- },
90
87
  "trustedDependencies": [
91
88
  "@biomejs/biome",
92
- "@swc/core",
93
- "node-hdiffpatch"
89
+ "@swc/core"
94
90
  ]
95
91
  }