react-native-update-cli 2.9.5 → 2.9.7

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 (55) hide show
  1. package/lib/api.js +22 -19
  2. package/lib/app.js +9 -9
  3. package/lib/bundle-pack.js +1 -1
  4. package/lib/bundle-runner.js +16 -16
  5. package/lib/diff.js +14 -91
  6. package/lib/exports.d.ts +8 -8
  7. package/lib/exports.js +23 -23
  8. package/lib/index.d.ts +2 -2
  9. package/lib/index.js +3 -3
  10. package/lib/module-manager.js +3 -3
  11. package/lib/modules/app-module.js +1 -1
  12. package/lib/modules/index.d.ts +3 -3
  13. package/lib/modules/index.js +7 -7
  14. package/lib/package.js +9 -9
  15. package/lib/utils/app-info-parser/aab.js +8 -8
  16. package/lib/utils/app-info-parser/ipa.js +1 -1
  17. package/lib/utils/app-info-parser/resource-finder.js +7 -7
  18. package/lib/utils/app-info-parser/utils.d.ts +1 -1
  19. package/lib/utils/app-info-parser/utils.js +10 -10
  20. package/lib/utils/app-info-parser/xml-parser/binary.js +2 -2
  21. package/lib/utils/command-result.js +3 -3
  22. package/lib/utils/constants.js +10 -10
  23. package/lib/utils/git.js +1 -1
  24. package/lib/utils/http-helper.js +5 -5
  25. package/lib/utils/index.js +13 -13
  26. package/lib/utils/latest-version/cli.js +2 -2
  27. package/lib/utils/latest-version/index.d.ts +1 -1
  28. package/lib/utils/latest-version/index.js +12 -12
  29. package/lib/utils/options.js +5 -5
  30. package/lib/utils/plugin-config.js +2 -2
  31. package/lib/utils/zip-entries.js +28 -11
  32. package/lib/utils/zip-options.d.ts +2 -1
  33. package/lib/utils/zip-options.js +17 -8
  34. package/lib/versions.d.ts +1 -1
  35. package/lib/versions.js +9 -13
  36. package/package.json +22 -19
  37. package/src/api.ts +11 -6
  38. package/src/app.ts +5 -4
  39. package/src/bundle-pack.ts +1 -1
  40. package/src/bundle-runner.ts +2 -2
  41. package/src/diff.ts +9 -161
  42. package/src/exports.ts +17 -20
  43. package/src/index.ts +2 -2
  44. package/src/modules/index.ts +3 -3
  45. package/src/package.ts +1 -1
  46. package/src/utils/app-info-parser/aab.ts +1 -1
  47. package/src/utils/app-info-parser/ipa.ts +1 -1
  48. package/src/utils/app-info-parser/utils.ts +5 -5
  49. package/src/utils/git.ts +1 -1
  50. package/src/utils/index.ts +4 -5
  51. package/src/utils/latest-version/cli.ts +4 -4
  52. package/src/utils/latest-version/index.ts +5 -6
  53. package/src/utils/zip-entries.ts +26 -8
  54. package/src/utils/zip-options.ts +7 -7
  55. package/src/versions.ts +11 -18
@@ -1,16 +1,15 @@
1
- import os from 'os';
2
- import path from 'path';
3
1
  import chalk from 'chalk';
4
2
  import { satisfies } from 'compare-versions';
5
3
  import fs from 'fs-extra';
4
+ import os from 'os';
5
+ import path from 'path';
6
6
  import type { Root as ProtobufRoot } from 'protobufjs';
7
- import { type Entry as YauzlEntry, open as openZipFile } from 'yauzl';
7
+ import { read } from 'read';
8
+ import { open as openZipFile, type Entry as YauzlEntry } from 'yauzl';
8
9
  import pkg from '../../package.json';
9
10
  import latestVersion from '../utils/latest-version';
10
11
  import AppInfoParser from './app-info-parser';
11
12
  import { checkPlugins } from './check-plugin';
12
-
13
- import { read } from 'read';
14
13
  import { IS_CRESC, tempDir } from './constants';
15
14
  import { depVersions } from './dep-versions';
16
15
  import { t } from './i18n';
@@ -1,5 +1,3 @@
1
- import { existsSync, readFileSync } from 'fs';
2
- import { dirname } from 'path';
3
1
  import {
4
2
  blue,
5
3
  bold,
@@ -14,13 +12,15 @@ import {
14
12
  underline,
15
13
  yellow,
16
14
  } from '@colors/colors/safe';
15
+ import { existsSync, readFileSync } from 'fs';
16
+ import { dirname } from 'path';
17
17
  import semverDiff from 'semver/functions/diff';
18
18
  import semverMajor from 'semver/functions/major';
19
19
  import latestVersion, {
20
+ type LatestVersionOptions,
21
+ type LatestVersionPackage,
20
22
  type Package,
21
23
  type PackageJson,
22
- type LatestVersionPackage,
23
- type LatestVersionOptions,
24
24
  } from '.';
25
25
 
26
26
  interface TableColumn {
@@ -1,4 +1,5 @@
1
1
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
2
+ import { npm, yarn } from 'global-dirs';
2
3
  import type {
3
4
  Agent,
4
5
  RequestOptions as HttpRequestOptions,
@@ -7,13 +8,11 @@ import type {
7
8
  import type { RequestOptions as HttpsRequestOptions } from 'https';
8
9
  import { homedir } from 'os';
9
10
  import { dirname, join, parse, resolve as pathResolve } from 'path';
10
- import { URL } from 'url';
11
- import { npm, yarn } from 'global-dirs';
12
-
13
11
  import registryAuthToken from 'registry-auth-token';
14
12
  import getRegistryUrl from 'registry-auth-token/registry-url';
15
13
  import gt from 'semver/functions/gt';
16
14
  import maxSatisfying from 'semver/ranges/max-satisfying';
15
+ import { URL } from 'url';
17
16
 
18
17
  interface RegistryVersions {
19
18
  /**
@@ -486,13 +485,13 @@ const latestVersion: LatestVersion = async (
486
485
 
487
486
  export type {
488
487
  LatestVersion,
488
+ LatestVersionOptions,
489
+ LatestVersionPackage,
489
490
  Package,
490
- PackageRange,
491
491
  PackageJson,
492
492
  PackageJsonDependencies,
493
+ PackageRange,
493
494
  RegistryVersions,
494
- LatestVersionPackage,
495
495
  RequestOptions,
496
- LatestVersionOptions,
497
496
  };
498
497
  export default latestVersion;
@@ -1,10 +1,10 @@
1
+ import * as fs from 'fs-extra';
1
2
  import os from 'os';
2
3
  import path from 'path';
3
- import * as fs from 'fs-extra';
4
4
  import {
5
5
  type Entry,
6
- type ZipFile as YauzlZipFile,
7
6
  open as openZipFile,
7
+ type ZipFile as YauzlZipFile,
8
8
  } from 'yauzl';
9
9
  import { t } from './i18n';
10
10
 
@@ -15,6 +15,12 @@ export function readEntry(
15
15
  const buffers: Buffer[] = [];
16
16
  return new Promise((resolve, reject) => {
17
17
  zipFile.openReadStream(entry, (err, stream) => {
18
+ if (err) {
19
+ return reject(err);
20
+ }
21
+ if (!stream) {
22
+ return reject(new Error(`Unable to read zip entry: ${entry.fileName}`));
23
+ }
18
24
  stream.on('data', (chunk: Buffer) => {
19
25
  buffers.push(chunk);
20
26
  });
@@ -50,24 +56,33 @@ export function readEntryPrefix(
50
56
  }
51
57
 
52
58
  let settled = false;
59
+ let expectedDestroyError: Error | undefined;
53
60
  const cleanup = () => {
54
61
  stream.off('data', onData);
55
62
  stream.off('end', onEnd);
56
63
  stream.off('error', onError);
57
64
  };
58
- const finish = () => {
65
+ const finish = (destroyStream = false) => {
59
66
  if (settled) {
60
67
  return;
61
68
  }
62
69
  settled = true;
63
- cleanup();
70
+ stream.off('data', onData);
71
+ stream.off('end', onEnd);
72
+ if (!destroyStream) {
73
+ stream.off('error', onError);
74
+ }
64
75
  resolve(Buffer.concat(buffers, length));
76
+
77
+ if (destroyStream) {
78
+ expectedDestroyError = new Error('zip entry prefix read complete');
79
+ stream.destroy(expectedDestroyError);
80
+ }
65
81
  };
66
82
  const onData = (chunk: Buffer) => {
67
83
  const remaining = maxBytes - length;
68
84
  if (remaining <= 0) {
69
- finish();
70
- stream.destroy();
85
+ finish(true);
71
86
  return;
72
87
  }
73
88
 
@@ -76,12 +91,15 @@ export function readEntryPrefix(
76
91
  buffers.push(slice);
77
92
  length += slice.length;
78
93
  if (length >= maxBytes) {
79
- finish();
80
- stream.destroy();
94
+ finish(true);
81
95
  }
82
96
  };
83
97
  const onEnd = () => finish();
84
98
  const onError = (error: Error) => {
99
+ if (settled && error === expectedDestroyError) {
100
+ cleanup();
101
+ return;
102
+ }
85
103
  if (settled) {
86
104
  return;
87
105
  }
@@ -1,5 +1,5 @@
1
- import path from 'path';
2
1
  import * as fs from 'fs';
2
+ import path from 'path';
3
3
 
4
4
  export type ZipEntryOptions = {
5
5
  compress?: boolean;
@@ -7,6 +7,7 @@ export type ZipEntryOptions = {
7
7
  };
8
8
 
9
9
  export const ZIP_ENTRY_SNIFF_BYTES = 64;
10
+ export const MANIFEST_COMPRESSION_THRESHOLD_BYTES = 256;
10
11
 
11
12
  const alreadyCompressedExtensions = new Set([
12
13
  '.7z',
@@ -108,11 +109,7 @@ function hasAlreadyCompressedMagic(bytes: Buffer): boolean {
108
109
  if (startsWith(bytes, Buffer.from('ID3', 'ascii'))) {
109
110
  return true;
110
111
  }
111
- if (
112
- bytes[0] === 0xff &&
113
- bytes.length >= 2 &&
114
- (bytes[1] & 0xe0) === 0xe0
115
- ) {
112
+ if (bytes[0] === 0xff && bytes.length >= 2 && (bytes[1] & 0xe0) === 0xe0) {
116
113
  return true;
117
114
  }
118
115
  if (
@@ -140,7 +137,10 @@ export function zipOptionsForPatchEntry(): ZipEntryOptions {
140
137
  return { compress: false };
141
138
  }
142
139
 
143
- export function zipOptionsForManifestEntry(): ZipEntryOptions {
140
+ export function zipOptionsForManifestEntry(byteLength = 0): ZipEntryOptions {
141
+ if (byteLength >= MANIFEST_COMPRESSION_THRESHOLD_BYTES) {
142
+ return { compressionLevel: 9 };
143
+ }
144
144
  return { compress: false };
145
145
  }
146
146
 
package/src/versions.ts CHANGED
@@ -1,15 +1,14 @@
1
- import { doDelete, get, getAllPackages, post, put, uploadFile } from './api';
2
- import { question, saveToLocal } from './utils';
3
- import { t } from './utils/i18n';
4
-
5
1
  import chalk from 'chalk';
6
2
  import { satisfies } from 'compare-versions';
7
3
  import Table from 'tty-table';
4
+ import { doDelete, get, getAllPackages, post, put, uploadFile } from './api';
8
5
  import { getPlatform, getSelectedApp } from './app';
9
6
  import { choosePackage } from './package';
10
7
  import type { Package, Platform, Version } from './types';
8
+ import { question, saveToLocal } from './utils';
11
9
  import { depVersions } from './utils/dep-versions';
12
10
  import { getCommitInfo } from './utils/git';
11
+ import { t } from './utils/i18n';
13
12
 
14
13
  interface VersionCommandOptions {
15
14
  appId?: string;
@@ -485,7 +484,8 @@ export const versionCommands = {
485
484
  update: async ({ options }: { options: VersionCommandOptions }) => {
486
485
  const platform = await getPlatform(options.platform);
487
486
  const appId = options.appId || (await getSelectedApp(platform)).appId;
488
- let versionId = options.versionId || (await chooseVersion(String(appId))).id;
487
+ let versionId =
488
+ options.versionId || (await chooseVersion(String(appId))).id;
489
489
  if (versionId === 'null') {
490
490
  versionId = undefined;
491
491
  }
@@ -495,15 +495,11 @@ export const versionCommands = {
495
495
  let minPkgVersion = options.minPackageVersion;
496
496
  let maxPkgVersion = options.maxPackageVersion;
497
497
  let packageVersionRange = options.packageVersionRange;
498
- let rollout: number | undefined = undefined;
498
+ let rollout: number | undefined;
499
499
 
500
500
  if (options.rollout !== undefined) {
501
- try {
502
- rollout = Number.parseInt(options.rollout);
503
- } catch (e) {
504
- throw new Error(t('rolloutRangeError'));
505
- }
506
- if (rollout < 1 || rollout > 100) {
501
+ rollout = Number.parseInt(options.rollout, 10);
502
+ if (Number.isNaN(rollout) || rollout < 1 || rollout > 100) {
507
503
  throw new Error(t('rolloutRangeError'));
508
504
  }
509
505
  }
@@ -596,7 +592,8 @@ export const versionCommands = {
596
592
  }) => {
597
593
  const platform = await getPlatform(options.platform);
598
594
  const { appId } = await getSelectedApp(platform);
599
- const versionId = options.versionId || (await chooseVersion(String(appId))).id;
595
+ const versionId =
596
+ options.versionId || (await chooseVersion(String(appId))).id;
600
597
 
601
598
  const updateParams: Record<string, string> = {};
602
599
  if (options.name) updateParams.name = options.name;
@@ -606,11 +603,7 @@ export const versionCommands = {
606
603
  await put(`/app/${String(appId)}/version/${versionId}`, updateParams);
607
604
  console.log(t('operationSuccess'));
608
605
  },
609
- deleteVersion: async ({
610
- options,
611
- }: {
612
- options: VersionCommandOptions;
613
- }) => {
606
+ deleteVersion: async ({ options }: { options: VersionCommandOptions }) => {
614
607
  let appId = options.appId;
615
608
  if (!appId) {
616
609
  const platform = await getPlatform(options.platform);