react-native-update-cli 2.24.1 → 2.25.0
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/README.md +11 -4
- package/README.zh-CN.md +11 -4
- package/cli.json +7 -1
- package/lib/api.d.ts +2 -0
- package/lib/api.js +63 -18
- package/lib/app.js +25 -3
- package/lib/bin.js +39 -45
- package/lib/bundle-runner.d.ts +27 -0
- package/lib/bundle-runner.js +240 -21
- package/lib/bundle.d.ts +1 -1
- package/lib/bundle.js +19 -6
- package/lib/commands.d.ts +6 -0
- package/lib/commands.js +65 -0
- package/lib/locales/en.d.ts +5 -14
- package/lib/locales/en.js +5 -14
- package/lib/locales/zh.d.ts +5 -13
- package/lib/locales/zh.js +5 -13
- package/lib/package.js +4 -0
- package/lib/provider.d.ts +1 -1
- package/lib/provider.js +3 -1
- package/lib/symbolicate.js +11 -3
- package/lib/types.d.ts +1 -0
- package/lib/user.js +6 -0
- package/lib/utils/add-gitignore.js +7 -1
- package/lib/utils/dep-versions.d.ts +7 -0
- package/lib/utils/dep-versions.js +78 -26
- package/lib/utils/git.js +9 -6
- package/lib/utils/hermes-base.js +2 -1
- package/lib/utils/i18n.d.ts +5 -0
- package/lib/utils/i18n.js +14 -1
- package/lib/utils/index.d.ts +2 -1
- package/lib/utils/index.js +9 -4
- package/lib/utils/latest-version/index.js +8 -0
- package/lib/utils/runtime.d.ts +21 -0
- package/lib/utils/runtime.js +138 -5
- package/lib/utils/slim-sourcemap.d.ts +11 -0
- package/lib/utils/slim-sourcemap.js +22 -0
- package/lib/utils/zip-range.js +3 -2
- package/lib/versions.js +16 -15
- package/package.json +4 -2
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -17
- package/src/api.ts +0 -470
- package/src/app.ts +0 -241
- package/src/auto-update.ts +0 -647
- package/src/bin-cresc.ts +0 -8
- package/src/bin.ts +0 -115
- package/src/bundle-pack.ts +0 -61
- package/src/bundle-runner.ts +0 -1430
- package/src/bundle.ts +0 -371
- package/src/cache.ts +0 -20
- package/src/diff.ts +0 -1010
- package/src/exports.ts +0 -17
- package/src/index.ts +0 -1
- package/src/install.ts +0 -50
- package/src/locales/en.ts +0 -257
- package/src/locales/zh.ts +0 -234
- package/src/native-package.ts +0 -338
- package/src/package.ts +0 -482
- package/src/provider.ts +0 -294
- package/src/symbolicate.ts +0 -159
- package/src/types.ts +0 -150
- package/src/user.ts +0 -39
- package/src/utils/add-gitignore.ts +0 -35
- package/src/utils/app-info-parser/aab.ts +0 -241
- package/src/utils/app-info-parser/apk.ts +0 -92
- package/src/utils/app-info-parser/app.ts +0 -7
- package/src/utils/app-info-parser/index.ts +0 -54
- package/src/utils/app-info-parser/ipa.ts +0 -109
- package/src/utils/app-info-parser/resource-finder.ts +0 -508
- package/src/utils/app-info-parser/utils.ts +0 -161
- package/src/utils/app-info-parser/xml-parser/binary.ts +0 -693
- package/src/utils/app-info-parser/xml-parser/manifest.ts +0 -228
- package/src/utils/app-info-parser/zip.ts +0 -108
- package/src/utils/check-lockfile.ts +0 -93
- package/src/utils/check-plugin.ts +0 -38
- package/src/utils/command-result.ts +0 -24
- package/src/utils/constants.ts +0 -25
- package/src/utils/dep-versions.ts +0 -83
- package/src/utils/git.ts +0 -71
- package/src/utils/hbcTransform.ts +0 -649
- package/src/utils/hermes-base.ts +0 -1137
- package/src/utils/http-helper.ts +0 -152
- package/src/utils/i18n.ts +0 -39
- package/src/utils/index.ts +0 -698
- package/src/utils/latest-version/index.ts +0 -573
- package/src/utils/options.ts +0 -78
- package/src/utils/plugin-config.ts +0 -32
- package/src/utils/runtime.ts +0 -187
- package/src/utils/slim-sourcemap.ts +0 -83
- package/src/utils/zip-entries.ts +0 -209
- package/src/utils/zip-options.ts +0 -178
- package/src/utils/zip-range.ts +0 -727
- package/src/utils/zip-raw-writer.ts +0 -247
- package/src/versions.ts +0 -894
package/src/native-package.ts
DELETED
|
@@ -1,338 +0,0 @@
|
|
|
1
|
-
import * as fs from 'fs-extra';
|
|
2
|
-
import os from 'os';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
import {
|
|
5
|
-
type Entry,
|
|
6
|
-
open as openZipFile,
|
|
7
|
-
type ZipFile as YauzlZipFile,
|
|
8
|
-
} from 'yauzl';
|
|
9
|
-
import { ZipFile as YazlZipFile } from 'yazl';
|
|
10
|
-
import type { Platform } from './types';
|
|
11
|
-
import { fitsRawZip, RawZipWriter } from './utils/zip-raw-writer';
|
|
12
|
-
|
|
13
|
-
export type NativePackageEntry = {
|
|
14
|
-
diffPath: string;
|
|
15
|
-
kind: 'bundle' | 'resource';
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
type NativePackageRule = {
|
|
19
|
-
resolveEntry: (entryName: string) => NativePackageEntry | undefined;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const nativePackageRules: Record<Platform, NativePackageRule> = {
|
|
23
|
-
android: {
|
|
24
|
-
resolveEntry: (entryName) => {
|
|
25
|
-
if (entryName === 'assets/index.android.bundle') {
|
|
26
|
-
return { diffPath: entryName, kind: 'bundle' };
|
|
27
|
-
}
|
|
28
|
-
if (entryName.startsWith('assets/') || entryName.startsWith('res/')) {
|
|
29
|
-
return { diffPath: entryName, kind: 'resource' };
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
ios: {
|
|
34
|
-
resolveEntry: (entryName) => {
|
|
35
|
-
const match = /^Payload\/[^/]+\.app\/(.+)$/.exec(entryName);
|
|
36
|
-
const appPath = match?.[1];
|
|
37
|
-
if (appPath === 'main.jsbundle') {
|
|
38
|
-
return { diffPath: appPath, kind: 'bundle' };
|
|
39
|
-
}
|
|
40
|
-
if (appPath?.startsWith('assets/')) {
|
|
41
|
-
return { diffPath: appPath, kind: 'resource' };
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
harmony: {
|
|
46
|
-
resolveEntry: (entryName) => {
|
|
47
|
-
if (entryName === 'resources/rawfile/bundle.harmony.js') {
|
|
48
|
-
return { diffPath: entryName, kind: 'bundle' };
|
|
49
|
-
}
|
|
50
|
-
if (entryName.startsWith('resources/rawfile/assets/')) {
|
|
51
|
-
return { diffPath: entryName, kind: 'resource' };
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Resolve an archive entry that can be used as a native-package diff origin.
|
|
59
|
-
* Upload extraction and diff indexing deliberately share this function so a
|
|
60
|
-
* file cannot be removed from the uploaded baseline while still being
|
|
61
|
-
* considered by the local diff implementation (or vice versa).
|
|
62
|
-
*/
|
|
63
|
-
export function resolveNativePackageEntry(
|
|
64
|
-
platform: Platform,
|
|
65
|
-
entryName: string,
|
|
66
|
-
): NativePackageEntry | undefined {
|
|
67
|
-
return nativePackageRules[platform].resolveEntry(entryName);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/** Where the kept entries go: a raw copy (default) or a yazl repack. */
|
|
71
|
-
interface SlimSink {
|
|
72
|
-
copyEntry(sourceZip: YauzlZipFile, entry: Entry): Promise<void>;
|
|
73
|
-
/** add a local file under `fileName`, dated like `like` */
|
|
74
|
-
addFile(filePath: string, fileName: string, like: Entry): Promise<void>;
|
|
75
|
-
end(): Promise<void>;
|
|
76
|
-
abort(): Promise<void>;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Copies each entry's stored bytes, CRC and sizes verbatim (yauzl hands out
|
|
81
|
-
* the raw file data with `decodeFileData: false`), so slimming a package is
|
|
82
|
-
* bound by disk I/O rather than by deflating every asset again.
|
|
83
|
-
*/
|
|
84
|
-
class RawCopySink implements SlimSink {
|
|
85
|
-
private readonly writer: RawZipWriter;
|
|
86
|
-
constructor(output: string) {
|
|
87
|
-
this.writer = new RawZipWriter(output);
|
|
88
|
-
}
|
|
89
|
-
copyEntry(sourceZip: YauzlZipFile, entry: Entry): Promise<void> {
|
|
90
|
-
return new Promise((resolve, reject) => {
|
|
91
|
-
sourceZip.openReadStream(
|
|
92
|
-
entry,
|
|
93
|
-
{ decodeFileData: false },
|
|
94
|
-
(error, readStream) => {
|
|
95
|
-
if (error || !readStream) {
|
|
96
|
-
reject(
|
|
97
|
-
error ?? new Error(`Unable to read zip entry: ${entry.fileName}`),
|
|
98
|
-
);
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
this.writer.addRawEntry(entry, readStream).then(resolve, reject);
|
|
102
|
-
},
|
|
103
|
-
);
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
addFile(filePath: string, fileName: string, like: Entry): Promise<void> {
|
|
107
|
-
// a nested slim archive is a zip of deflated entries: storing it as-is
|
|
108
|
-
// loses nothing and skips another pass over its bytes
|
|
109
|
-
return this.writer.addStoredFile(filePath, fileName, like);
|
|
110
|
-
}
|
|
111
|
-
end(): Promise<void> {
|
|
112
|
-
return this.writer.end();
|
|
113
|
-
}
|
|
114
|
-
abort(): Promise<void> {
|
|
115
|
-
return this.writer.abort();
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/** Re-deflates every kept entry through yazl; only for sources that need zip64. */
|
|
120
|
-
class RepackSink implements SlimSink {
|
|
121
|
-
private readonly outputZip = new YazlZipFile();
|
|
122
|
-
private readonly writePromise: Promise<void>;
|
|
123
|
-
constructor(readonly output: string) {
|
|
124
|
-
this.writePromise = new Promise<void>((resolve, reject) => {
|
|
125
|
-
this.outputZip.outputStream.once('error', reject);
|
|
126
|
-
this.outputZip.outputStream
|
|
127
|
-
.pipe(fs.createWriteStream(output))
|
|
128
|
-
.once('error', reject)
|
|
129
|
-
.once('close', () => resolve());
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
copyEntry(sourceZip: YauzlZipFile, entry: Entry): Promise<void> {
|
|
133
|
-
return new Promise((resolve, reject) => {
|
|
134
|
-
sourceZip.openReadStream(entry, (error, readStream) => {
|
|
135
|
-
if (error || !readStream) {
|
|
136
|
-
reject(
|
|
137
|
-
error ?? new Error(`Unable to read zip entry: ${entry.fileName}`),
|
|
138
|
-
);
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
readStream.once('error', reject);
|
|
142
|
-
readStream.once('end', () => resolve());
|
|
143
|
-
this.outputZip.addReadStream(readStream, entry.fileName, {
|
|
144
|
-
compress: entry.compressionMethod !== 0,
|
|
145
|
-
mtime: entry.getLastModDate(),
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
async addFile(
|
|
151
|
-
filePath: string,
|
|
152
|
-
fileName: string,
|
|
153
|
-
like: Entry,
|
|
154
|
-
): Promise<void> {
|
|
155
|
-
this.outputZip.addFile(filePath, fileName, {
|
|
156
|
-
compress: like.compressionMethod !== 0,
|
|
157
|
-
mtime: like.getLastModDate(),
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
async end(): Promise<void> {
|
|
161
|
-
this.outputZip.end();
|
|
162
|
-
await this.writePromise;
|
|
163
|
-
}
|
|
164
|
-
async abort(): Promise<void> {
|
|
165
|
-
this.outputZip.end();
|
|
166
|
-
await this.writePromise.catch(() => {});
|
|
167
|
-
await fs.remove(this.output).catch(() => {});
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
function openZip(source: string): Promise<YauzlZipFile> {
|
|
172
|
-
return new Promise((resolve, reject) => {
|
|
173
|
-
openZipFile(source, { lazyEntries: true }, (error, zipFile) => {
|
|
174
|
-
if (error || !zipFile) {
|
|
175
|
-
reject(error ?? new Error(`Unable to open zip file: ${source}`));
|
|
176
|
-
return;
|
|
177
|
-
}
|
|
178
|
-
resolve(zipFile);
|
|
179
|
-
});
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
function extractEntryToFile(
|
|
184
|
-
sourceZip: YauzlZipFile,
|
|
185
|
-
entry: Entry,
|
|
186
|
-
outputPath: string,
|
|
187
|
-
): Promise<void> {
|
|
188
|
-
return new Promise((resolve, reject) => {
|
|
189
|
-
sourceZip.openReadStream(entry, (error, readStream) => {
|
|
190
|
-
if (error) {
|
|
191
|
-
reject(error);
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
if (!readStream) {
|
|
195
|
-
reject(new Error(`Unable to read zip entry: ${entry.fileName}`));
|
|
196
|
-
return;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
const writeStream = fs.createWriteStream(outputPath);
|
|
200
|
-
readStream.once('error', reject);
|
|
201
|
-
writeStream.once('error', reject);
|
|
202
|
-
writeStream.once('close', () => resolve());
|
|
203
|
-
readStream.pipe(writeStream);
|
|
204
|
-
});
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
export interface SlimPackageOptions {
|
|
209
|
-
/** re-deflate through yazl even when a raw copy would do (tests) */
|
|
210
|
-
repack?: boolean;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
async function filterNativePackageArchive(
|
|
214
|
-
source: string,
|
|
215
|
-
output: string,
|
|
216
|
-
platform: Platform,
|
|
217
|
-
options: SlimPackageOptions,
|
|
218
|
-
): Promise<{ bundles: number; entries: number }> {
|
|
219
|
-
await fs.ensureDir(path.dirname(output));
|
|
220
|
-
const scratchDir = await fs.mkdtemp(
|
|
221
|
-
path.join(os.tmpdir(), 'rnu-native-package-entry-'),
|
|
222
|
-
);
|
|
223
|
-
const sourceZip = await openZip(source);
|
|
224
|
-
// a subset of the source never outgrows it, so the source's own size and
|
|
225
|
-
// entry count decide whether plain (non-zip64) headers are enough
|
|
226
|
-
const rawCopy =
|
|
227
|
-
!options.repack &&
|
|
228
|
-
fitsRawZip((await fs.stat(source)).size, sourceZip.entryCount);
|
|
229
|
-
const sink: SlimSink = rawCopy
|
|
230
|
-
? new RawCopySink(output)
|
|
231
|
-
: new RepackSink(output);
|
|
232
|
-
let includedEntries = 0;
|
|
233
|
-
let includedBundles = 0;
|
|
234
|
-
let nestedArchiveIndex = 0;
|
|
235
|
-
|
|
236
|
-
try {
|
|
237
|
-
await new Promise<void>((resolve, reject) => {
|
|
238
|
-
let settled = false;
|
|
239
|
-
const fail = (error: unknown) => {
|
|
240
|
-
if (settled) {
|
|
241
|
-
return;
|
|
242
|
-
}
|
|
243
|
-
settled = true;
|
|
244
|
-
sourceZip.close();
|
|
245
|
-
reject(error);
|
|
246
|
-
};
|
|
247
|
-
|
|
248
|
-
sourceZip.once('error', fail);
|
|
249
|
-
sourceZip.once('end', () => {
|
|
250
|
-
if (!settled) {
|
|
251
|
-
settled = true;
|
|
252
|
-
resolve();
|
|
253
|
-
}
|
|
254
|
-
});
|
|
255
|
-
sourceZip.on('entry', async (entry) => {
|
|
256
|
-
try {
|
|
257
|
-
if (entry.fileName.endsWith('/')) {
|
|
258
|
-
sourceZip.readEntry();
|
|
259
|
-
return;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
// Harmony .app packages contain one or more nested .hap archives.
|
|
263
|
-
// Rebuild those archives recursively and keep their outer path so
|
|
264
|
-
// the slim package has the same nesting as the original package.
|
|
265
|
-
if (
|
|
266
|
-
platform === 'harmony' &&
|
|
267
|
-
entry.fileName.toLowerCase().endsWith('.hap')
|
|
268
|
-
) {
|
|
269
|
-
const index = nestedArchiveIndex++;
|
|
270
|
-
const nestedSource = path.join(scratchDir, `${index}.source.hap`);
|
|
271
|
-
const nestedOutput = path.join(scratchDir, `${index}.slim.hap`);
|
|
272
|
-
await extractEntryToFile(sourceZip, entry, nestedSource);
|
|
273
|
-
const nestedResult = await filterNativePackageArchive(
|
|
274
|
-
nestedSource,
|
|
275
|
-
nestedOutput,
|
|
276
|
-
platform,
|
|
277
|
-
options,
|
|
278
|
-
);
|
|
279
|
-
if (nestedResult.entries > 0) {
|
|
280
|
-
await sink.addFile(nestedOutput, entry.fileName, entry);
|
|
281
|
-
includedEntries += nestedResult.entries;
|
|
282
|
-
includedBundles += nestedResult.bundles;
|
|
283
|
-
}
|
|
284
|
-
sourceZip.readEntry();
|
|
285
|
-
return;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
const resolvedEntry = resolveNativePackageEntry(
|
|
289
|
-
platform,
|
|
290
|
-
entry.fileName,
|
|
291
|
-
);
|
|
292
|
-
if (resolvedEntry) {
|
|
293
|
-
await sink.copyEntry(sourceZip, entry);
|
|
294
|
-
includedEntries += 1;
|
|
295
|
-
if (resolvedEntry.kind === 'bundle') {
|
|
296
|
-
includedBundles += 1;
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
sourceZip.readEntry();
|
|
300
|
-
} catch (error) {
|
|
301
|
-
fail(error);
|
|
302
|
-
}
|
|
303
|
-
});
|
|
304
|
-
|
|
305
|
-
sourceZip.readEntry();
|
|
306
|
-
});
|
|
307
|
-
|
|
308
|
-
await sink.end();
|
|
309
|
-
return { bundles: includedBundles, entries: includedEntries };
|
|
310
|
-
} catch (error) {
|
|
311
|
-
await sink.abort();
|
|
312
|
-
throw error;
|
|
313
|
-
} finally {
|
|
314
|
-
await fs.remove(scratchDir);
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
/**
|
|
319
|
-
* Repack a native package with only the bundle and resources required by
|
|
320
|
-
* package-origin diffs. Entry names and nested Harmony HAP structure are kept.
|
|
321
|
-
*/
|
|
322
|
-
export async function createSlimNativePackage(
|
|
323
|
-
source: string,
|
|
324
|
-
output: string,
|
|
325
|
-
platform: Platform,
|
|
326
|
-
options: SlimPackageOptions = {},
|
|
327
|
-
): Promise<void> {
|
|
328
|
-
const result = await filterNativePackageArchive(
|
|
329
|
-
source,
|
|
330
|
-
output,
|
|
331
|
-
platform,
|
|
332
|
-
options,
|
|
333
|
-
);
|
|
334
|
-
if (result.bundles === 0) {
|
|
335
|
-
await fs.remove(output);
|
|
336
|
-
throw new Error(`Bundle entry not found in native package: ${source}`);
|
|
337
|
-
}
|
|
338
|
-
}
|