react-native-update-cli 2.15.2 → 2.15.4

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 (59) hide show
  1. package/cli.json +0 -6
  2. package/lib/api.js +25 -4
  3. package/lib/app.js +1 -0
  4. package/lib/bin-cresc.d.ts +1 -0
  5. package/lib/bin-cresc.js +7 -0
  6. package/lib/bin.js +5 -3
  7. package/lib/bundle-pack.d.ts +1 -1
  8. package/lib/bundle-pack.js +8 -7
  9. package/lib/bundle-runner.d.ts +3 -3
  10. package/lib/bundle-runner.js +68 -49
  11. package/lib/bundle.d.ts +26 -0
  12. package/lib/bundle.js +18 -6
  13. package/lib/diff.js +55 -70
  14. package/lib/install.js +30 -3
  15. package/lib/locales/en.d.ts +13 -0
  16. package/lib/locales/en.js +14 -1
  17. package/lib/locales/zh.d.ts +13 -0
  18. package/lib/locales/zh.js +14 -1
  19. package/lib/package.js +8 -2
  20. package/lib/provider.js +9 -3
  21. package/lib/types.d.ts +2 -2
  22. package/lib/utils/app-info-parser/aab.js +4 -4
  23. package/lib/utils/app-info-parser/xml-parser/binary.js +4 -3
  24. package/lib/utils/app-info-parser/xml-parser/manifest.js +3 -1
  25. package/lib/utils/app-info-parser/zip.d.ts +6 -0
  26. package/lib/utils/app-info-parser/zip.js +20 -5
  27. package/lib/utils/check-lockfile.js +5 -1
  28. package/lib/utils/constants.d.ts +1 -1
  29. package/lib/utils/constants.js +2 -1
  30. package/lib/utils/http-helper.js +20 -23
  31. package/lib/utils/index.js +48 -20
  32. package/lib/utils/zip-entries.js +4 -0
  33. package/lib/versions.d.ts +2 -0
  34. package/lib/versions.js +19 -8
  35. package/package.json +5 -5
  36. package/src/api.ts +30 -5
  37. package/src/app.ts +1 -0
  38. package/src/bin-cresc.ts +8 -0
  39. package/src/bin.ts +3 -3
  40. package/src/bundle-pack.ts +12 -7
  41. package/src/bundle-runner.ts +82 -56
  42. package/src/bundle.ts +13 -8
  43. package/src/diff.ts +87 -109
  44. package/src/install.ts +32 -3
  45. package/src/locales/en.ts +16 -0
  46. package/src/locales/zh.ts +15 -0
  47. package/src/package.ts +4 -4
  48. package/src/provider.ts +7 -3
  49. package/src/types.ts +3 -2
  50. package/src/utils/app-info-parser/aab.ts +4 -4
  51. package/src/utils/app-info-parser/xml-parser/binary.ts +4 -5
  52. package/src/utils/app-info-parser/xml-parser/manifest.ts +6 -3
  53. package/src/utils/app-info-parser/zip.ts +22 -5
  54. package/src/utils/check-lockfile.ts +5 -1
  55. package/src/utils/constants.ts +5 -1
  56. package/src/utils/http-helper.ts +16 -23
  57. package/src/utils/index.ts +51 -36
  58. package/src/utils/zip-entries.ts +4 -0
  59. package/src/versions.ts +15 -11
package/cli.json CHANGED
@@ -221,9 +221,6 @@
221
221
  }
222
222
  }
223
223
  },
224
- "build": {
225
- "description": "Bundle javascript and copy assets."
226
- },
227
224
  "bundle": {
228
225
  "description": "Bundle javascript code only and optionally publish.",
229
226
  "options": {
@@ -316,9 +313,6 @@
316
313
  }
317
314
  }
318
315
  },
319
- "release": {
320
- "description": "Push builded file to server."
321
- },
322
316
  "hdiff": {
323
317
  "description": "Create hdiff patch",
324
318
  "options": {
package/lib/api.js CHANGED
@@ -154,8 +154,10 @@ async function query(url, options) {
154
154
  try {
155
155
  json = JSON.parse(text);
156
156
  } catch (_e) {
157
- if (resp.status === 200 && text) {
158
- console.warn(`Warning: API returned 200 with non-JSON body (${text.length} bytes)`);
157
+ if (resp.status === 200) {
158
+ // a proxy/gateway likely replaced the response; surface it instead of
159
+ // returning undefined and crashing callers on destructuring
160
+ throw createRequestError(`API returned 200 with non-JSON body (${text.length} bytes)`, fullUrl, resp.status);
159
161
  }
160
162
  }
161
163
  if (resp.status !== 200) {
@@ -275,6 +277,25 @@ async function uploadFile(fn, key) {
275
277
  };
276
278
  }
277
279
  const getAllPackages = async (appId)=>{
278
- const { data } = await get(`/app/${appId}/package/list?limit=1000`);
279
- return data;
280
+ // the server caps limit at 100, so page through with offset
281
+ const limit = 100;
282
+ let offset = 0;
283
+ let allPackages;
284
+ while(true){
285
+ const { data, count } = await get(`/app/${appId}/package/list?offset=${offset}&limit=${limit}`);
286
+ const packages = data;
287
+ if (allPackages === undefined || allPackages === null) {
288
+ allPackages = packages;
289
+ } else if (packages) {
290
+ allPackages.push(...packages);
291
+ }
292
+ if (!packages || packages.length === 0) {
293
+ break;
294
+ }
295
+ offset += packages.length;
296
+ if (offset >= Number(count || 0)) {
297
+ break;
298
+ }
299
+ }
300
+ return allPackages;
280
301
  };
package/lib/app.js CHANGED
@@ -161,6 +161,7 @@ function getAppCommands() {
161
161
  const id = args[0] || (await chooseApp(platform)).id;
162
162
  if (!id) {
163
163
  console.log((0, _i18n.t)('cancelled'));
164
+ return;
164
165
  }
165
166
  await (0, _api.doDelete)(`/app/${id}`);
166
167
  console.log((0, _i18n.t)('operationSuccess'));
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ // Dedicated entry for the `cresc` bin so brand detection does not depend on
4
+ // process.argv[1], which on Windows npm shims always points to the js file
5
+ // instead of the invoked command name.
6
+ process.env.RNU_BRAND = 'cresc';
7
+ require('./bin');
package/lib/bin.js CHANGED
@@ -59,15 +59,17 @@ async function run() {
59
59
  const handler = commandHandlers[argv.command];
60
60
  await handler(argv);
61
61
  } else {
62
- throw new Error(`Unknown command: ${argv.command}`);
62
+ throw new Error((0, _i18n.t)('unknownCommand', {
63
+ command: argv.command
64
+ }));
63
65
  }
64
66
  } catch (err) {
65
67
  if (err.status === 401) {
66
68
  console.log((0, _i18n.t)('loginFirst'));
67
- return;
69
+ process.exit(1);
68
70
  }
69
71
  console.error(err.stack);
70
- process.exit(-1);
72
+ process.exit(1);
71
73
  }
72
74
  }
73
75
  run();
@@ -1 +1 @@
1
- export declare function packBundle(dir: string, output: string): Promise<void>;
1
+ export declare function packBundle(dir: string, output: string, bundleName?: string): Promise<void>;
@@ -59,17 +59,18 @@ function _interop_require_wildcard(obj, nodeInterop) {
59
59
  }
60
60
  return newObj;
61
61
  }
62
- const ignorePackingFileNames = [
63
- '.',
64
- '..',
65
- 'index.bundlejs.map',
66
- 'bundle.harmony.js.map'
67
- ];
68
62
  const ignorePackingExtensions = [
69
63
  'DS_Store',
70
64
  'txt.map'
71
65
  ];
72
- async function packBundle(dir, output) {
66
+ async function packBundle(dir, output, bundleName) {
67
+ const ignorePackingFileNames = [
68
+ 'index.bundlejs.map',
69
+ 'bundle.harmony.js.map'
70
+ ];
71
+ if (bundleName) {
72
+ ignorePackingFileNames.push(`${bundleName}.map`);
73
+ }
73
74
  console.log((0, _i18n.t)('packing'));
74
75
  _fsextra.ensureDirSync(_path.default.dirname(output));
75
76
  await new Promise((resolve, reject)=>{
@@ -50,9 +50,9 @@ export declare function resolveExpoCli(projectRoot?: string): ResolvedExpoCli;
50
50
  export declare function runReactNativeBundleCommand({ bundleName, dev, entryFile, outputFolder, platform, sourcemapOutput, config, forceHermes, cli, isSentry, }: RunBundleCommandOptions): Promise<void>;
51
51
  export declare function resolveHermesCommand(projectRoot?: string): string;
52
52
  export declare function copyDebugidForSentry(bundleName: string, outputFolder: string, sourcemapOutput: string): Promise<void>;
53
- export declare function prepareSentryUploadArtifacts(bundleName: string, outputFolder: string, platform: string): SentryUploadArtifacts;
54
- export declare function readSourcemapDebugId(sourcemapPath: string): string | undefined;
55
- export declare function resolveSentryUploadMode(sourcemapPath: string, options?: SentryUploadOptions): SentryUploadMode;
53
+ export declare function prepareSentryUploadArtifacts(bundleName: string, outputFolder: string, platform: string): Promise<SentryUploadArtifacts>;
54
+ export declare function readSourcemapDebugId(sourcemapPath: string): Promise<string | undefined>;
55
+ export declare function resolveSentryUploadMode(sourcemapPath: string, options?: SentryUploadOptions): Promise<SentryUploadMode>;
56
56
  export declare function buildSentrySourcemapsUploadArgs({ sentryCliPath, bundlePath, sourcemapPath, release, dist, stripPrefix, debugIdReference, useStandaloneSourcemapsCommand, }: BuildSentrySourcemapsUploadArgsOptions): string[];
57
57
  export declare function uploadSourcemapForSentry(bundleName: string, outputFolder: string, sourcemapOutput: string, platform?: string, sentryOptions?: SentryUploadOptions): Promise<void>;
58
58
  export {};
@@ -225,6 +225,8 @@ async function runReactNativeBundleCommand({ bundleName, dev, entryFile, outputF
225
225
  process.env.SENTRY_PROPERTIES = 'ios/sentry.properties';
226
226
  } else if (platform === 'android') {
227
227
  process.env.SENTRY_PROPERTIES = 'android/sentry.properties';
228
+ } else if (platform === 'harmony' && _fsextra.existsSync('harmony/sentry.properties')) {
229
+ process.env.SENTRY_PROPERTIES = 'harmony/sentry.properties';
228
230
  }
229
231
  }
230
232
  let bundleCommand = 'bundle';
@@ -266,6 +268,7 @@ async function runReactNativeBundleCommand({ bundleName, dev, entryFile, outputF
266
268
  reactNativeBundleProcess.stderr.on('data', (data)=>{
267
269
  console.error(data.toString().trim());
268
270
  });
271
+ reactNativeBundleProcess.once('error', reject);
269
272
  reactNativeBundleProcess.on('close', async (exitCode)=>{
270
273
  if (exitCode) {
271
274
  reject(new Error((0, _i18n.t)('bundleCommandError', {
@@ -273,44 +276,50 @@ async function runReactNativeBundleCommand({ bundleName, dev, entryFile, outputF
273
276
  })));
274
277
  return;
275
278
  }
276
- let hermesEnabled = false;
277
- if (forceHermes) {
278
- hermesEnabled = true;
279
- console.log((0, _i18n.t)('forceHermes'));
280
- } else if (platform === 'android') {
281
- const gradleProperties = await new Promise((resolve)=>{
282
- properties.parse('./android/gradle.properties', {
283
- path: true
284
- }, (error, props = {})=>{
285
- if (error) {
286
- console.error(error);
287
- resolve({});
288
- return;
289
- }
290
- resolve(props);
279
+ try {
280
+ let hermesEnabled = false;
281
+ if (forceHermes) {
282
+ hermesEnabled = true;
283
+ console.log((0, _i18n.t)('forceHermes'));
284
+ } else if (platform === 'android') {
285
+ const gradleProperties = await new Promise((resolve)=>{
286
+ properties.parse('./android/gradle.properties', {
287
+ path: true
288
+ }, (error, props = {})=>{
289
+ if (error) {
290
+ console.error(error);
291
+ resolve({});
292
+ return;
293
+ }
294
+ resolve(props);
295
+ });
291
296
  });
292
- });
293
- hermesEnabled = gradleProperties.hermesEnabled;
294
- if (typeof hermesEnabled !== 'boolean') {
295
- hermesEnabled = gradleConfig.enableHermes;
297
+ hermesEnabled = gradleProperties.hermesEnabled;
298
+ if (typeof hermesEnabled !== 'boolean') {
299
+ hermesEnabled = gradleConfig.enableHermes;
300
+ }
301
+ } else if (platform === 'ios' && _fsextra.existsSync('ios/Pods/hermes-engine')) {
302
+ hermesEnabled = true;
296
303
  }
297
- } else if (platform === 'ios' && _fsextra.existsSync('ios/Pods/hermes-engine')) {
298
- hermesEnabled = true;
299
- }
300
- if (hermesEnabled) {
301
- await compileHermesByteCode(bundleName, outputFolder, sourcemapOutput, !isSentry);
302
- }
303
- if (platform === 'harmony') {
304
- const harmonyRawAssetsPath = 'harmony/entry/src/main/resources/rawfile/assets';
305
- _fsextra.ensureDirSync(harmonyRawAssetsPath);
306
- _fsextra.copySync(outputFolder, harmonyRawAssetsPath, {
307
- overwrite: true
308
- });
309
- _fsextra.moveSync(`${harmonyRawAssetsPath}/bundle.harmony.js`, `${harmonyRawAssetsPath}/../bundle.harmony.js`, {
310
- overwrite: true
311
- });
304
+ if (hermesEnabled) {
305
+ await compileHermesByteCode(bundleName, outputFolder, sourcemapOutput, !isSentry);
306
+ }
307
+ if (platform === 'harmony') {
308
+ const harmonyRawAssetsPath = 'harmony/entry/src/main/resources/rawfile/assets';
309
+ _fsextra.ensureDirSync(harmonyRawAssetsPath);
310
+ _fsextra.copySync(outputFolder, harmonyRawAssetsPath, {
311
+ overwrite: true,
312
+ // sourcemaps must not ship inside the native package
313
+ filter: (src)=>!src.endsWith('.map')
314
+ });
315
+ _fsextra.moveSync(`${harmonyRawAssetsPath}/bundle.harmony.js`, `${harmonyRawAssetsPath}/../bundle.harmony.js`, {
316
+ overwrite: true
317
+ });
318
+ }
319
+ resolve();
320
+ } catch (error) {
321
+ reject(error);
312
322
  }
313
- resolve();
314
323
  });
315
324
  });
316
325
  }
@@ -344,7 +353,9 @@ function normalizeString(value) {
344
353
  function resolveHermesCommand(projectRoot = process.cwd()) {
345
354
  const osBin = getHermesOSBin();
346
355
  if (!osBin) {
347
- throw new Error(`Unsupported platform for Hermes: ${_os.default.platform()}`);
356
+ throw new Error((0, _i18n.t)('unsupportedPlatformForHermes', {
357
+ platform: _os.default.platform()
358
+ }));
348
359
  }
349
360
  const executableName = getHermesExecutableName();
350
361
  const candidates = [];
@@ -418,8 +429,16 @@ async function compileHermesByteCode(bundleName, outputFolder, sourcemapOutput,
418
429
  stdio: 'ignore'
419
430
  }), hermesCommand);
420
431
  if (sourcemapOutput) {
421
- const composerPath = 'node_modules/react-native/scripts/compose-source-maps.js';
422
- if (!_fsextra.existsSync(composerPath)) {
432
+ let composerPath;
433
+ try {
434
+ // resolve through the project so hoisted node_modules (monorepos) work
435
+ composerPath = require.resolve('react-native/scripts/compose-source-maps.js', {
436
+ paths: [
437
+ process.cwd()
438
+ ]
439
+ });
440
+ } catch (unused) {
441
+ console.warn((0, _i18n.t)('composeSourceMapsNotFound'));
423
442
  return;
424
443
  }
425
444
  console.log((0, _i18n.t)('composingSourceMap'));
@@ -447,7 +466,7 @@ async function copyDebugidForSentry(bundleName, outputFolder, sourcemapOutput) {
447
466
  ]
448
467
  });
449
468
  } catch (unused) {
450
- console.error((0, _i18n.t)('sentryCliNotFound'));
469
+ console.error((0, _i18n.t)('sentryReactNativeNotFound'));
451
470
  return;
452
471
  }
453
472
  if (!_fsextra.existsSync(copyDebugidPath)) {
@@ -464,7 +483,7 @@ async function copyDebugidForSentry(bundleName, outputFolder, sourcemapOutput) {
464
483
  }
465
484
  _fsextra.removeSync(_path.default.join(outputFolder, `${bundleName}.txt.map`));
466
485
  }
467
- function prepareSentryUploadArtifacts(bundleName, outputFolder, platform) {
486
+ async function prepareSentryUploadArtifacts(bundleName, outputFolder, platform) {
468
487
  const bundlePath = _path.default.join(outputFolder, bundleName);
469
488
  const sourcemapPath = _path.default.join(outputFolder, `${bundleName}.map`);
470
489
  if (platform !== 'android' || bundleName === ANDROID_SENTRY_BUNDLE_NAME) {
@@ -475,19 +494,19 @@ function prepareSentryUploadArtifacts(bundleName, outputFolder, platform) {
475
494
  }
476
495
  const androidBundlePath = _path.default.join(outputFolder, ANDROID_SENTRY_BUNDLE_NAME);
477
496
  const androidSourcemapPath = _path.default.join(outputFolder, `${ANDROID_SENTRY_BUNDLE_NAME}.map`);
478
- _fsextra.copyFileSync(bundlePath, androidBundlePath);
479
- const sourcemap = JSON.parse(_fsextra.readFileSync(sourcemapPath, 'utf8'));
497
+ await _fsextra.promises.copyFile(bundlePath, androidBundlePath);
498
+ const sourcemap = JSON.parse(await _fsextra.promises.readFile(sourcemapPath, 'utf8'));
480
499
  sourcemap.file = ANDROID_SENTRY_BUNDLE_NAME;
481
- _fsextra.writeFileSync(androidSourcemapPath, JSON.stringify(sourcemap));
500
+ await _fsextra.promises.writeFile(androidSourcemapPath, JSON.stringify(sourcemap));
482
501
  return {
483
502
  bundlePath: androidBundlePath,
484
503
  sourcemapPath: androidSourcemapPath
485
504
  };
486
505
  }
487
- function readSourcemapDebugId(sourcemapPath) {
506
+ async function readSourcemapDebugId(sourcemapPath) {
488
507
  try {
489
508
  var _sourcemap_debugId;
490
- const sourcemap = JSON.parse(_fsextra.readFileSync(sourcemapPath, 'utf8'));
509
+ const sourcemap = JSON.parse(await _fsextra.promises.readFile(sourcemapPath, 'utf8'));
491
510
  const debugId = (_sourcemap_debugId = sourcemap.debugId) != null ? _sourcemap_debugId : sourcemap.debug_id;
492
511
  return typeof debugId === 'string' ? normalizeString(debugId) : undefined;
493
512
  } catch (unused) {
@@ -504,7 +523,7 @@ function resolveSentryReleaseFromValues(releaseValue, distValue) {
504
523
  dist: normalizeString(distValue)
505
524
  };
506
525
  }
507
- function resolveSentryUploadMode(sourcemapPath, options = {}) {
526
+ async function resolveSentryUploadMode(sourcemapPath, options = {}) {
508
527
  const optionRelease = resolveSentryReleaseFromValues(options.sentryRelease, options.sentryDist);
509
528
  if (optionRelease) {
510
529
  return {
@@ -512,7 +531,7 @@ function resolveSentryUploadMode(sourcemapPath, options = {}) {
512
531
  ...optionRelease
513
532
  };
514
533
  }
515
- const debugId = readSourcemapDebugId(sourcemapPath);
534
+ const debugId = await readSourcemapDebugId(sourcemapPath);
516
535
  if (debugId) {
517
536
  return {
518
537
  type: 'debug-id',
@@ -644,8 +663,8 @@ async function uploadSourcemapForSentry(bundleName, outputFolder, sourcemapOutpu
644
663
  if (!_fsextra.existsSync(sentryCliPath)) {
645
664
  return;
646
665
  }
647
- const { bundlePath, sourcemapPath } = prepareSentryUploadArtifacts(bundleName, outputFolder, platform);
648
- const uploadMode = resolveSentryUploadMode(sourcemapPath, sentryOptions);
666
+ const { bundlePath, sourcemapPath } = await prepareSentryUploadArtifacts(bundleName, outputFolder, platform);
667
+ const uploadMode = await resolveSentryUploadMode(sourcemapPath, sentryOptions);
649
668
  const useStandaloneSourcemapsCommand = supportsStandaloneSentrySourcemapsUpload(sentryCliPath);
650
669
  if (uploadMode.type === 'release') {
651
670
  uploadSourcemapsWithRelease({
package/lib/bundle.d.ts CHANGED
@@ -1,6 +1,32 @@
1
+ type NormalizedBundleOptions = {
2
+ bundleName: string;
3
+ entryFile: string;
4
+ intermediaDir: string;
5
+ output: string;
6
+ dev: string;
7
+ sourcemap: boolean;
8
+ taro: boolean;
9
+ expo: boolean;
10
+ rncli: boolean;
11
+ hermes: boolean;
12
+ name?: string;
13
+ description?: string;
14
+ metaInfo?: string;
15
+ packageId?: string;
16
+ packageVersion?: string;
17
+ minPackageVersion?: string;
18
+ maxPackageVersion?: string;
19
+ packageVersionRange?: string;
20
+ rollout?: string;
21
+ dryRun: boolean;
22
+ sentryRelease?: string;
23
+ sentryDist?: string;
24
+ };
25
+ export declare function normalizeBundleOptions(translatedOptions: Record<string, unknown>, platform: string): NormalizedBundleOptions;
1
26
  export declare const bundleCommands: {
2
27
  bundle: ({ options, }: {
3
28
  args?: string[];
4
29
  options: Record<string, unknown>;
5
30
  }) => Promise<void>;
6
31
  };
32
+ export {};
package/lib/bundle.js CHANGED
@@ -2,10 +2,18 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- Object.defineProperty(exports, "bundleCommands", {
6
- enumerable: true,
7
- get: function() {
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
+ });
10
+ }
11
+ _export(exports, {
12
+ get bundleCommands () {
8
13
  return bundleCommands;
14
+ },
15
+ get normalizeBundleOptions () {
16
+ return normalizeBundleOptions;
9
17
  }
10
18
  });
11
19
  const _path = /*#__PURE__*/ _interop_require_default(require("path"));
@@ -31,7 +39,9 @@ function getAliasedOptionalStringOption(options, key, alias) {
31
39
  }
32
40
  function normalizeBundleOptions(translatedOptions, platform) {
33
41
  return {
34
- bundleName: (0, _options.getStringOption)(translatedOptions, 'bundleName', 'index.bundlejs'),
42
+ // harmony bundles always use this fixed name (runReactNativeBundleCommand
43
+ // forces it), so sourcemap paths and Sentry uploads must match
44
+ bundleName: platform === 'harmony' ? 'bundle.harmony.js' : (0, _options.getStringOption)(translatedOptions, 'bundleName', 'index.bundlejs'),
35
45
  entryFile: (0, _options.getStringOption)(translatedOptions, 'entryFile', 'index.js'),
36
46
  intermediaDir: (0, _options.getStringOption)(translatedOptions, 'intermediaDir', `${_constants.tempDir}/intermedia/${platform}`),
37
47
  output: (0, _options.getStringOption)(translatedOptions, 'output', `${_constants.tempDir}/output/${platform}.\${time}.ppk`),
@@ -90,7 +100,9 @@ const bundleCommands = {
90
100
  if (!platform) {
91
101
  throw new Error((0, _i18n.t)('platformRequired'));
92
102
  }
93
- console.log(`Bundling with react-native: ${_depversions.depVersions['react-native']}`);
103
+ console.log((0, _i18n.t)('bundlingWithRN', {
104
+ version: _depversions.depVersions['react-native']
105
+ }));
94
106
  await (0, _bundlerunner.runReactNativeBundleCommand)({
95
107
  bundleName: normalized.bundleName,
96
108
  dev: normalized.dev,
@@ -106,7 +118,7 @@ const bundleCommands = {
106
118
  },
107
119
  isSentry: bundleParams.sentry
108
120
  });
109
- await (0, _bundlepack.packBundle)(_path.default.resolve(normalized.intermediaDir), realOutput);
121
+ await (0, _bundlepack.packBundle)(_path.default.resolve(normalized.intermediaDir), realOutput, normalized.bundleName);
110
122
  if (normalized.name) {
111
123
  await publishBundleVersion(realOutput, platform, {
112
124
  name: normalized.name,
package/lib/diff.js CHANGED
@@ -75,8 +75,10 @@ function _interop_require_wildcard(obj, nodeInterop) {
75
75
  return newObj;
76
76
  }
77
77
  const loadModule = (pkgName)=>{
78
+ const nodePathDirs = (process.env.NODE_PATH || '').split(_path.default.delimiter).filter(Boolean);
78
79
  const resolvePaths = [
79
80
  '.',
81
+ ...nodePathDirs,
80
82
  _globaldirs.npm.packages,
81
83
  _globaldirs.yarn.packages
82
84
  ];
@@ -93,8 +95,49 @@ function basename(fn) {
93
95
  const m = /^(.+\/)[^/]+\/?$/.exec(fn);
94
96
  return m == null ? void 0 : m[1];
95
97
  }
96
- async function diffFromPPK(origin, next, output, diffFn) {
98
+ function createOutputZip(output) {
97
99
  _fsextra.ensureDirSync(_path.default.dirname(output));
100
+ const zipfile = new _yazl.ZipFile();
101
+ const writePromise = new Promise((resolve, reject)=>{
102
+ zipfile.outputStream.on('error', reject);
103
+ zipfile.outputStream.pipe(_fsextra.createWriteStream(output)).on('close', ()=>{
104
+ resolve(void 0);
105
+ });
106
+ });
107
+ return {
108
+ zipfile,
109
+ writePromise
110
+ };
111
+ }
112
+ async function addBundlePatch(zipfile, entry, nextZipfile, diffFn, originSource) {
113
+ const newSource = await (0, _zipentries.readEntry)(entry, nextZipfile);
114
+ zipfile.addBuffer(diffFn(originSource, newSource), `${entry.fileName}.patch`, (0, _zipoptions.zipOptionsForPatchEntry)());
115
+ }
116
+ async function addFileFromZipEntry(zipfile, entry, nextZipfile) {
117
+ const entryPrefix = await (0, _zipentries.readEntryPrefix)(entry, nextZipfile, _zipoptions.ZIP_ENTRY_SNIFF_BYTES);
118
+ await new Promise((resolve, reject)=>{
119
+ nextZipfile.openReadStream(entry, (err, readStream)=>{
120
+ if (err) {
121
+ return reject(err);
122
+ }
123
+ if (!readStream) {
124
+ return reject(new Error(`Unable to read zip entry: ${entry.fileName}`));
125
+ }
126
+ zipfile.addReadStream(readStream, entry.fileName, (0, _zipoptions.zipOptionsForPayloadEntry)(entry.fileName, entryPrefix));
127
+ readStream.on('error', reject);
128
+ readStream.on('end', ()=>{
129
+ resolve(void 0);
130
+ });
131
+ });
132
+ });
133
+ }
134
+ function finishDiffZip(zipfile, writePromise, manifest) {
135
+ const diffManifest = Buffer.from(JSON.stringify(manifest));
136
+ zipfile.addBuffer(diffManifest, '__diff.json', (0, _zipoptions.zipOptionsForManifestEntry)(diffManifest.length));
137
+ zipfile.end();
138
+ return writePromise;
139
+ }
140
+ async function diffFromPPK(origin, next, output, diffFn) {
98
141
  const originEntries = {};
99
142
  const originMap = {};
100
143
  let originSource;
@@ -113,13 +156,7 @@ async function diffFromPPK(origin, next, output, diffFn) {
113
156
  throw new Error((0, _i18n.t)('bundleFileNotFound'));
114
157
  }
115
158
  const copies = {};
116
- const zipfile = new _yazl.ZipFile();
117
- const writePromise = new Promise((resolve, reject)=>{
118
- zipfile.outputStream.on('error', reject);
119
- zipfile.outputStream.pipe(_fsextra.createWriteStream(output)).on('close', ()=>{
120
- resolve(void 0);
121
- });
122
- });
159
+ const { zipfile, writePromise } = createOutputZip(output);
123
160
  const addedEntry = {};
124
161
  function addEntry(fn) {
125
162
  //console.log(fn);
@@ -142,11 +179,7 @@ async function diffFromPPK(origin, next, output, diffFn) {
142
179
  addEntry(entry.fileName);
143
180
  }
144
181
  } else if ((0, _constants.isPPKBundleFileName)(entry.fileName)) {
145
- //console.log('Found bundle');
146
- const newSource = await (0, _zipentries.readEntry)(entry, nextZipfile);
147
- //console.log('Begin diff');
148
- zipfile.addBuffer(diffFn(originSource, newSource), `${entry.fileName}.patch`, (0, _zipoptions.zipOptionsForPatchEntry)());
149
- //console.log('End diff');
182
+ await addBundlePatch(zipfile, entry, nextZipfile, diffFn, originSource);
150
183
  } else {
151
184
  // If same file.
152
185
  const originEntry = originEntries[entry.fileName];
@@ -169,22 +202,7 @@ async function diffFromPPK(origin, next, output, diffFn) {
169
202
  if (basePath) {
170
203
  addEntry(basePath);
171
204
  }
172
- const entryPrefix = await (0, _zipentries.readEntryPrefix)(entry, nextZipfile, _zipoptions.ZIP_ENTRY_SNIFF_BYTES);
173
- await new Promise((resolve, reject)=>{
174
- nextZipfile.openReadStream(entry, (err, readStream)=>{
175
- if (err) {
176
- return reject(err);
177
- }
178
- if (!readStream) {
179
- return reject(new Error(`Unable to read zip entry: ${entry.fileName}`));
180
- }
181
- zipfile.addReadStream(readStream, entry.fileName, (0, _zipoptions.zipOptionsForPayloadEntry)(entry.fileName, entryPrefix));
182
- readStream.on('end', ()=>{
183
- //console.log('add finished');
184
- resolve(void 0);
185
- });
186
- });
187
- });
205
+ await addFileFromZipEntry(zipfile, entry, nextZipfile);
188
206
  }
189
207
  });
190
208
  const deletes = {};
@@ -196,17 +214,12 @@ async function diffFromPPK(origin, next, output, diffFn) {
196
214
  deletes[k] = 1;
197
215
  }
198
216
  }
199
- //console.log({copies, deletes});
200
- const diffManifest = Buffer.from(JSON.stringify({
217
+ await finishDiffZip(zipfile, writePromise, {
201
218
  copies,
202
219
  deletes
203
- }));
204
- zipfile.addBuffer(diffManifest, '__diff.json', (0, _zipoptions.zipOptionsForManifestEntry)(diffManifest.length));
205
- zipfile.end();
206
- await writePromise;
220
+ });
207
221
  }
208
222
  async function diffFromPackage(origin, next, output, diffFn, originBundleName, transformPackagePath = (v)=>v) {
209
- _fsextra.ensureDirSync(_path.default.dirname(output));
210
223
  const originEntries = {};
211
224
  const originMap = {};
212
225
  let originSource;
@@ -236,23 +249,13 @@ async function diffFromPackage(origin, next, output, diffFn, originBundleName, t
236
249
  throw new Error((0, _i18n.t)('bundleFileNotFound'));
237
250
  }
238
251
  const copies = {};
239
- const zipfile = new _yazl.ZipFile();
240
- const writePromise = new Promise((resolve, reject)=>{
241
- zipfile.outputStream.on('error', reject);
242
- zipfile.outputStream.pipe(_fsextra.createWriteStream(output)).on('close', ()=>{
243
- resolve(void 0);
244
- });
245
- });
252
+ const { zipfile, writePromise } = createOutputZip(output);
246
253
  await (0, _zipentries.enumZipEntries)(next, async (entry, nextZipfile)=>{
247
254
  if (/\/$/.test(entry.fileName)) {
248
255
  // Directory
249
256
  zipfile.addEmptyDirectory(entry.fileName);
250
257
  } else if ((0, _constants.isPPKBundleFileName)(entry.fileName)) {
251
- //console.log('Found bundle');
252
- const newSource = await (0, _zipentries.readEntry)(entry, nextZipfile);
253
- //console.log('Begin diff');
254
- zipfile.addBuffer(diffFn(originSource, newSource), `${entry.fileName}.patch`, (0, _zipoptions.zipOptionsForPatchEntry)());
255
- //console.log('End diff');
258
+ await addBundlePatch(zipfile, entry, nextZipfile, diffFn, originSource);
256
259
  } else {
257
260
  // If same file.
258
261
  if (originEntries[entry.fileName] === entry.crc32) {
@@ -269,31 +272,13 @@ async function diffFromPackage(origin, next, output, diffFn, originBundleName, t
269
272
  copiesCrc[entry.fileName] = entry.crc32;
270
273
  return;
271
274
  }
272
- const entryPrefix = await (0, _zipentries.readEntryPrefix)(entry, nextZipfile, _zipoptions.ZIP_ENTRY_SNIFF_BYTES);
273
- await new Promise((resolve, reject)=>{
274
- nextZipfile.openReadStream(entry, (err, readStream)=>{
275
- if (err) {
276
- return reject(err);
277
- }
278
- if (!readStream) {
279
- return reject(new Error(`Unable to read zip entry: ${entry.fileName}`));
280
- }
281
- zipfile.addReadStream(readStream, entry.fileName, (0, _zipoptions.zipOptionsForPayloadEntry)(entry.fileName, entryPrefix));
282
- readStream.on('end', ()=>{
283
- //console.log('add finished');
284
- resolve(void 0);
285
- });
286
- });
287
- });
275
+ await addFileFromZipEntry(zipfile, entry, nextZipfile);
288
276
  }
289
277
  });
290
- const diffManifest = Buffer.from(JSON.stringify({
278
+ await finishDiffZip(zipfile, writePromise, {
291
279
  copies,
292
280
  copiesCrc
293
- }));
294
- zipfile.addBuffer(diffManifest, '__diff.json', (0, _zipoptions.zipOptionsForManifestEntry)(diffManifest.length));
295
- zipfile.end();
296
- await writePromise;
281
+ });
297
282
  }
298
283
  function resolveDiffImplementation(options) {
299
284
  var _options_customHdiffModule;
@@ -321,7 +306,7 @@ function diffArgsCheck(args, options, diffFnName) {
321
306
  tempDir: _constants.tempDir
322
307
  });
323
308
  if (typeof output !== 'string') {
324
- throw new Error('Output path is required.');
309
+ throw new Error((0, _i18n.t)('outputPathRequired'));
325
310
  }
326
311
  return {
327
312
  origin,