react-native-update-cli 2.9.5 → 2.9.6
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/api.js +19 -15
- package/lib/app.js +8 -8
- package/lib/bundle-runner.js +14 -14
- package/lib/diff.js +6 -85
- package/lib/exports.js +16 -16
- package/lib/index.js +3 -3
- package/lib/module-manager.js +3 -3
- package/lib/modules/app-module.js +1 -1
- package/lib/modules/index.js +7 -7
- package/lib/package.js +8 -8
- package/lib/utils/app-info-parser/aab.js +7 -7
- package/lib/utils/app-info-parser/resource-finder.js +7 -7
- package/lib/utils/app-info-parser/utils.js +10 -10
- package/lib/utils/app-info-parser/xml-parser/binary.js +2 -2
- package/lib/utils/command-result.js +3 -3
- package/lib/utils/constants.js +10 -10
- package/lib/utils/http-helper.js +5 -5
- package/lib/utils/index.js +10 -10
- package/lib/utils/latest-version/cli.js +1 -1
- package/lib/utils/latest-version/index.js +10 -10
- package/lib/utils/options.js +5 -5
- package/lib/utils/plugin-config.js +2 -2
- package/lib/utils/zip-entries.js +28 -11
- package/lib/utils/zip-options.js +7 -7
- package/lib/versions.js +5 -9
- package/package.json +14 -14
- package/src/api.ts +7 -1
- package/src/app.ts +4 -2
- package/src/diff.ts +1 -155
- package/src/utils/zip-entries.ts +26 -8
- package/src/utils/zip-options.ts +2 -6
- package/src/versions.ts +6 -8
package/src/diff.ts
CHANGED
|
@@ -19,41 +19,12 @@ import {
|
|
|
19
19
|
} from './utils/zip-options';
|
|
20
20
|
|
|
21
21
|
type Diff = (oldSource?: Buffer, newSource?: Buffer) => Buffer;
|
|
22
|
-
type HpatchCover = {
|
|
23
|
-
oldPos: number | string | bigint;
|
|
24
|
-
newPos: number | string | bigint;
|
|
25
|
-
len: number | string | bigint;
|
|
26
|
-
};
|
|
27
|
-
type HpatchCompatiblePlan = {
|
|
28
|
-
covers?: HpatchCover[];
|
|
29
|
-
};
|
|
30
|
-
type HdiffWithCoversOptions = {
|
|
31
|
-
mode?: 'replace' | 'merge' | 'native-coalesce';
|
|
32
|
-
};
|
|
33
22
|
type HdiffModule = {
|
|
34
23
|
diff?: Diff;
|
|
35
|
-
diffWithCovers?: (
|
|
36
|
-
oldSource: Buffer,
|
|
37
|
-
newSource: Buffer,
|
|
38
|
-
covers: HpatchCover[],
|
|
39
|
-
options?: HdiffWithCoversOptions,
|
|
40
|
-
) => { diff?: Buffer };
|
|
41
24
|
};
|
|
42
25
|
type BsdiffModule = {
|
|
43
26
|
diff?: Diff;
|
|
44
27
|
};
|
|
45
|
-
type ChiffModule = {
|
|
46
|
-
hpatchCompatiblePlanResult?: (
|
|
47
|
-
oldSource: Buffer,
|
|
48
|
-
newSource: Buffer,
|
|
49
|
-
) => HpatchCompatiblePlan;
|
|
50
|
-
hpatchApproximatePlanResult?: (
|
|
51
|
-
oldSource: Buffer,
|
|
52
|
-
newSource: Buffer,
|
|
53
|
-
) => HpatchCompatiblePlan;
|
|
54
|
-
};
|
|
55
|
-
type ChiffHpatchPolicy = 'off' | 'costed';
|
|
56
|
-
type ChiffHpatchExactPolicy = 'off' | 'on';
|
|
57
28
|
type EntryMap = Record<string, { crc32: number; fileName: string }>;
|
|
58
29
|
type CrcMap = Record<number, string>;
|
|
59
30
|
type CopyMap = Record<string, string>;
|
|
@@ -86,121 +57,6 @@ const loadModule = <T>(pkgName: string): T | undefined => {
|
|
|
86
57
|
|
|
87
58
|
const hdiff = loadModule<HdiffModule>('node-hdiffpatch');
|
|
88
59
|
const bsdiff = loadModule<BsdiffModule>('node-bsdiff');
|
|
89
|
-
const chiff = loadModule<ChiffModule>('@chiff/node');
|
|
90
|
-
|
|
91
|
-
// Structured covers are experimental and can be expensive on real Hermes input.
|
|
92
|
-
// Keep native hdiff as the default unless the server explicitly opts in.
|
|
93
|
-
function resolveChiffHpatchPolicy(policy?: unknown): ChiffHpatchPolicy {
|
|
94
|
-
const value = String(
|
|
95
|
-
policy ?? process.env.RNU_CHIFF_HPATCH_POLICY ?? 'off',
|
|
96
|
-
).toLowerCase();
|
|
97
|
-
if (
|
|
98
|
-
value === 'costed' ||
|
|
99
|
-
value === 'on' ||
|
|
100
|
-
value === 'true' ||
|
|
101
|
-
value === '1'
|
|
102
|
-
) {
|
|
103
|
-
return 'costed';
|
|
104
|
-
}
|
|
105
|
-
return 'off';
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
function resolveChiffHpatchMinNativeBytes(value?: unknown): number {
|
|
109
|
-
const raw = value ?? process.env.RNU_CHIFF_HPATCH_MIN_NATIVE_BYTES ?? 4096;
|
|
110
|
-
const parsed = Number(raw);
|
|
111
|
-
if (!Number.isFinite(parsed) || parsed < 0) {
|
|
112
|
-
return 4096;
|
|
113
|
-
}
|
|
114
|
-
return Math.floor(parsed);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function resolveChiffHpatchExactPolicy(policy?: unknown): ChiffHpatchExactPolicy {
|
|
118
|
-
const value = String(
|
|
119
|
-
policy ?? process.env.RNU_CHIFF_HPATCH_EXACT_COVERS ?? 'off',
|
|
120
|
-
).toLowerCase();
|
|
121
|
-
if (value === 'on' || value === 'true' || value === '1') {
|
|
122
|
-
return 'on';
|
|
123
|
-
}
|
|
124
|
-
return 'off';
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function createChiffAwareHdiff(
|
|
128
|
-
hdiffModule: HdiffModule,
|
|
129
|
-
chiffModule: ChiffModule | undefined,
|
|
130
|
-
policy: ChiffHpatchPolicy,
|
|
131
|
-
minNativeBytes: number,
|
|
132
|
-
exactPolicy: ChiffHpatchExactPolicy,
|
|
133
|
-
): Diff {
|
|
134
|
-
const baseDiff = hdiffModule.diff;
|
|
135
|
-
if (!baseDiff) {
|
|
136
|
-
throw new Error(t('nodeHdiffpatchRequired', { scriptName }));
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
if (policy === 'off') {
|
|
140
|
-
return baseDiff;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
return (oldSource?: Buffer, newSource?: Buffer) => {
|
|
144
|
-
const nativeDiff = baseDiff(oldSource, newSource);
|
|
145
|
-
if (!oldSource || !newSource || !hdiffModule.diffWithCovers) {
|
|
146
|
-
return nativeDiff;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
let bestDiff = nativeDiff;
|
|
150
|
-
const tryDiffWithCovers = (
|
|
151
|
-
covers: HpatchCover[],
|
|
152
|
-
mode: 'replace' | 'merge' | 'native-coalesce',
|
|
153
|
-
) => {
|
|
154
|
-
try {
|
|
155
|
-
const result = hdiffModule.diffWithCovers?.(
|
|
156
|
-
oldSource,
|
|
157
|
-
newSource,
|
|
158
|
-
covers,
|
|
159
|
-
{ mode },
|
|
160
|
-
);
|
|
161
|
-
if (
|
|
162
|
-
Buffer.isBuffer(result?.diff) &&
|
|
163
|
-
result.diff.length < bestDiff.length
|
|
164
|
-
) {
|
|
165
|
-
bestDiff = result.diff;
|
|
166
|
-
}
|
|
167
|
-
} catch {}
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
tryDiffWithCovers([], 'native-coalesce');
|
|
171
|
-
|
|
172
|
-
if (nativeDiff.length < minNativeBytes) {
|
|
173
|
-
return bestDiff;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
try {
|
|
177
|
-
const approximatePlan = chiffModule?.hpatchApproximatePlanResult?.(
|
|
178
|
-
oldSource,
|
|
179
|
-
newSource,
|
|
180
|
-
);
|
|
181
|
-
if (Array.isArray(approximatePlan?.covers)) {
|
|
182
|
-
tryDiffWithCovers(approximatePlan.covers, 'merge');
|
|
183
|
-
}
|
|
184
|
-
} catch {}
|
|
185
|
-
|
|
186
|
-
if (
|
|
187
|
-
exactPolicy === 'off' ||
|
|
188
|
-
!chiffModule?.hpatchCompatiblePlanResult
|
|
189
|
-
) {
|
|
190
|
-
return bestDiff;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
try {
|
|
194
|
-
const plan = chiffModule.hpatchCompatiblePlanResult(oldSource, newSource);
|
|
195
|
-
if (Array.isArray(plan.covers)) {
|
|
196
|
-
tryDiffWithCovers(plan.covers, 'replace');
|
|
197
|
-
tryDiffWithCovers(plan.covers, 'merge');
|
|
198
|
-
}
|
|
199
|
-
} catch {}
|
|
200
|
-
|
|
201
|
-
return bestDiff;
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
60
|
|
|
205
61
|
function basename(fn: string): string | undefined {
|
|
206
62
|
const m = /^(.+\/)[^\/]+\/?$/.exec(fn);
|
|
@@ -473,10 +329,6 @@ async function diffFromPackage(
|
|
|
473
329
|
type DiffCommandOptions = {
|
|
474
330
|
customDiff?: Diff;
|
|
475
331
|
customHdiffModule?: HdiffModule;
|
|
476
|
-
customChiffModule?: ChiffModule;
|
|
477
|
-
chiffHpatchPolicy?: ChiffHpatchPolicy;
|
|
478
|
-
chiffHpatchMinNativeBytes?: number | string;
|
|
479
|
-
chiffHpatchExactCovers?: ChiffHpatchExactPolicy | boolean | string | number;
|
|
480
332
|
[key: string]: any;
|
|
481
333
|
};
|
|
482
334
|
|
|
@@ -493,13 +345,7 @@ function resolveDiffImplementation(
|
|
|
493
345
|
if (!hdiffModule?.diff) {
|
|
494
346
|
throw new Error(t('nodeHdiffpatchRequired', { scriptName }));
|
|
495
347
|
}
|
|
496
|
-
return
|
|
497
|
-
hdiffModule,
|
|
498
|
-
options.customChiffModule ?? chiff,
|
|
499
|
-
resolveChiffHpatchPolicy(options.chiffHpatchPolicy),
|
|
500
|
-
resolveChiffHpatchMinNativeBytes(options.chiffHpatchMinNativeBytes),
|
|
501
|
-
resolveChiffHpatchExactPolicy(options.chiffHpatchExactCovers),
|
|
502
|
-
);
|
|
348
|
+
return hdiffModule.diff;
|
|
503
349
|
}
|
|
504
350
|
|
|
505
351
|
if (!bsdiff?.diff) {
|
package/src/utils/zip-entries.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
}
|
package/src/utils/zip-options.ts
CHANGED
|
@@ -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;
|
|
@@ -108,11 +108,7 @@ function hasAlreadyCompressedMagic(bytes: Buffer): boolean {
|
|
|
108
108
|
if (startsWith(bytes, Buffer.from('ID3', 'ascii'))) {
|
|
109
109
|
return true;
|
|
110
110
|
}
|
|
111
|
-
if (
|
|
112
|
-
bytes[0] === 0xff &&
|
|
113
|
-
bytes.length >= 2 &&
|
|
114
|
-
(bytes[1] & 0xe0) === 0xe0
|
|
115
|
-
) {
|
|
111
|
+
if (bytes[0] === 0xff && bytes.length >= 2 && (bytes[1] & 0xe0) === 0xe0) {
|
|
116
112
|
return true;
|
|
117
113
|
}
|
|
118
114
|
if (
|
package/src/versions.ts
CHANGED
|
@@ -485,7 +485,8 @@ export const versionCommands = {
|
|
|
485
485
|
update: async ({ options }: { options: VersionCommandOptions }) => {
|
|
486
486
|
const platform = await getPlatform(options.platform);
|
|
487
487
|
const appId = options.appId || (await getSelectedApp(platform)).appId;
|
|
488
|
-
let versionId =
|
|
488
|
+
let versionId =
|
|
489
|
+
options.versionId || (await chooseVersion(String(appId))).id;
|
|
489
490
|
if (versionId === 'null') {
|
|
490
491
|
versionId = undefined;
|
|
491
492
|
}
|
|
@@ -498,12 +499,8 @@ export const versionCommands = {
|
|
|
498
499
|
let rollout: number | undefined = undefined;
|
|
499
500
|
|
|
500
501
|
if (options.rollout !== undefined) {
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
} catch (e) {
|
|
504
|
-
throw new Error(t('rolloutRangeError'));
|
|
505
|
-
}
|
|
506
|
-
if (rollout < 1 || rollout > 100) {
|
|
502
|
+
rollout = Number.parseInt(options.rollout, 10);
|
|
503
|
+
if (Number.isNaN(rollout) || rollout < 1 || rollout > 100) {
|
|
507
504
|
throw new Error(t('rolloutRangeError'));
|
|
508
505
|
}
|
|
509
506
|
}
|
|
@@ -596,7 +593,8 @@ export const versionCommands = {
|
|
|
596
593
|
}) => {
|
|
597
594
|
const platform = await getPlatform(options.platform);
|
|
598
595
|
const { appId } = await getSelectedApp(platform);
|
|
599
|
-
const versionId =
|
|
596
|
+
const versionId =
|
|
597
|
+
options.versionId || (await chooseVersion(String(appId))).id;
|
|
600
598
|
|
|
601
599
|
const updateParams: Record<string, string> = {};
|
|
602
600
|
if (options.name) updateParams.name = options.name;
|