react-native-update-cli 2.22.7 → 2.22.9
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 +1 -1
- package/README.zh-CN.md +1 -1
- package/cli.json +5 -0
- package/lib/api.d.ts +7 -0
- package/lib/api.js +106 -38
- package/lib/app.js +3 -2
- package/lib/bin.js +16 -2
- package/lib/bundle-runner.d.ts +11 -4
- package/lib/bundle-runner.js +176 -90
- package/lib/bundle.d.ts +1 -0
- package/lib/bundle.js +2 -0
- package/lib/diff.d.ts +9 -0
- package/lib/diff.js +162 -120
- package/lib/locales/en.d.ts +1 -0
- package/lib/locales/en.js +1 -0
- package/lib/locales/zh.d.ts +1 -0
- package/lib/locales/zh.js +1 -0
- package/lib/native-package.d.ts +5 -1
- package/lib/native-package.js +145 -84
- package/lib/package.d.ts +7 -3
- package/lib/package.js +22 -12
- package/lib/types.d.ts +2 -0
- package/lib/utils/dep-versions.d.ts +7 -0
- package/lib/utils/dep-versions.js +66 -31
- package/lib/utils/hbcTransform.d.ts +21 -0
- package/lib/utils/hbcTransform.js +146 -5
- package/lib/utils/hermes-base.d.ts +21 -4
- package/lib/utils/hermes-base.js +146 -37
- package/lib/utils/http-helper.d.ts +6 -1
- package/lib/utils/http-helper.js +23 -11
- package/lib/utils/index.d.ts +30 -1
- package/lib/utils/index.js +98 -24
- package/lib/utils/latest-version/index.d.ts +11 -8
- package/lib/utils/latest-version/index.js +91 -25
- package/lib/utils/zip-entries.js +20 -15
- package/lib/utils/zip-options.d.ts +2 -0
- package/lib/utils/zip-options.js +9 -4
- package/lib/utils/zip-range.d.ts +47 -15
- package/lib/utils/zip-range.js +192 -83
- package/lib/utils/zip-raw-writer.d.ts +47 -0
- package/lib/utils/zip-raw-writer.js +204 -0
- package/lib/versions.js +19 -9
- package/package.json +10 -12
- package/src/api.ts +126 -46
- package/src/app.ts +3 -2
- package/src/bin.ts +17 -2
- package/src/bundle-runner.ts +225 -113
- package/src/bundle.ts +3 -0
- package/src/diff.ts +210 -153
- package/src/locales/en.ts +2 -0
- package/src/locales/zh.ts +2 -0
- package/src/native-package.ts +186 -96
- package/src/package.ts +26 -13
- package/src/types.ts +2 -0
- package/src/utils/dep-versions.ts +76 -33
- package/src/utils/hbcTransform.ts +194 -5
- package/src/utils/hermes-base.ts +156 -45
- package/src/utils/http-helper.ts +24 -13
- package/src/utils/index.ts +136 -26
- package/src/utils/latest-version/index.ts +109 -33
- package/src/utils/zip-entries.ts +18 -16
- package/src/utils/zip-options.ts +8 -3
- package/src/utils/zip-range.ts +244 -88
- package/src/utils/zip-raw-writer.ts +247 -0
- package/src/versions.ts +17 -7
package/src/native-package.ts
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
} from 'yauzl';
|
|
9
9
|
import { ZipFile as YazlZipFile } from 'yazl';
|
|
10
10
|
import type { Platform } from './types';
|
|
11
|
+
import { fitsRawZip, RawZipWriter } from './utils/zip-raw-writer';
|
|
11
12
|
|
|
12
13
|
export type NativePackageEntry = {
|
|
13
14
|
diffPath: string;
|
|
@@ -66,28 +67,115 @@ export function resolveNativePackageEntry(
|
|
|
66
67
|
return nativePackageRules[platform].resolveEntry(entryName);
|
|
67
68
|
}
|
|
68
69
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
entry: Entry
|
|
72
|
-
|
|
73
|
-
): Promise<void
|
|
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> {
|
|
74
172
|
return new Promise((resolve, reject) => {
|
|
75
|
-
|
|
76
|
-
if (error) {
|
|
77
|
-
reject(error);
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
if (!readStream) {
|
|
81
|
-
reject(new Error(`Unable to read zip entry: ${entry.fileName}`));
|
|
173
|
+
openZipFile(source, { lazyEntries: true }, (error, zipFile) => {
|
|
174
|
+
if (error || !zipFile) {
|
|
175
|
+
reject(error ?? new Error(`Unable to open zip file: ${source}`));
|
|
82
176
|
return;
|
|
83
177
|
}
|
|
84
|
-
|
|
85
|
-
readStream.once('error', reject);
|
|
86
|
-
readStream.once('end', () => resolve());
|
|
87
|
-
outputZip.addReadStream(readStream, entry.fileName, {
|
|
88
|
-
compress: entry.compressionMethod !== 0,
|
|
89
|
-
mtime: entry.getLastModDate(),
|
|
90
|
-
});
|
|
178
|
+
resolve(zipFile);
|
|
91
179
|
});
|
|
92
180
|
});
|
|
93
181
|
}
|
|
@@ -117,114 +205,110 @@ function extractEntryToFile(
|
|
|
117
205
|
});
|
|
118
206
|
}
|
|
119
207
|
|
|
208
|
+
export interface SlimPackageOptions {
|
|
209
|
+
/** re-deflate through yazl even when a raw copy would do (tests) */
|
|
210
|
+
repack?: boolean;
|
|
211
|
+
}
|
|
212
|
+
|
|
120
213
|
async function filterNativePackageArchive(
|
|
121
214
|
source: string,
|
|
122
215
|
output: string,
|
|
123
216
|
platform: Platform,
|
|
217
|
+
options: SlimPackageOptions,
|
|
124
218
|
): Promise<{ bundles: number; entries: number }> {
|
|
125
219
|
await fs.ensureDir(path.dirname(output));
|
|
126
220
|
const scratchDir = await fs.mkdtemp(
|
|
127
221
|
path.join(os.tmpdir(), 'rnu-native-package-entry-'),
|
|
128
222
|
);
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
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);
|
|
137
232
|
let includedEntries = 0;
|
|
138
233
|
let includedBundles = 0;
|
|
139
234
|
let nestedArchiveIndex = 0;
|
|
140
235
|
|
|
141
236
|
try {
|
|
142
237
|
await new Promise<void>((resolve, reject) => {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
238
|
+
let settled = false;
|
|
239
|
+
const fail = (error: unknown) => {
|
|
240
|
+
if (settled) {
|
|
146
241
|
return;
|
|
147
242
|
}
|
|
243
|
+
settled = true;
|
|
244
|
+
sourceZip.close();
|
|
245
|
+
reject(error);
|
|
246
|
+
};
|
|
148
247
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
248
|
+
sourceZip.once('error', fail);
|
|
249
|
+
sourceZip.once('end', () => {
|
|
250
|
+
if (!settled) {
|
|
154
251
|
settled = true;
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
resolve();
|
|
252
|
+
resolve();
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
sourceZip.on('entry', async (entry) => {
|
|
256
|
+
try {
|
|
257
|
+
if (entry.fileName.endsWith('/')) {
|
|
258
|
+
sourceZip.readEntry();
|
|
259
|
+
return;
|
|
164
260
|
}
|
|
165
|
-
});
|
|
166
|
-
sourceZip.on('entry', async (entry) => {
|
|
167
|
-
try {
|
|
168
|
-
if (entry.fileName.endsWith('/')) {
|
|
169
|
-
sourceZip.readEntry();
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
// Harmony .app packages contain one or more nested .hap archives.
|
|
174
|
-
// Rebuild those archives recursively and keep their outer path so
|
|
175
|
-
// the slim package has the same nesting as the original package.
|
|
176
|
-
if (
|
|
177
|
-
platform === 'harmony' &&
|
|
178
|
-
entry.fileName.toLowerCase().endsWith('.hap')
|
|
179
|
-
) {
|
|
180
|
-
const index = nestedArchiveIndex++;
|
|
181
|
-
const nestedSource = path.join(scratchDir, `${index}.source.hap`);
|
|
182
|
-
const nestedOutput = path.join(scratchDir, `${index}.slim.hap`);
|
|
183
|
-
await extractEntryToFile(sourceZip, entry, nestedSource);
|
|
184
|
-
const nestedResult = await filterNativePackageArchive(
|
|
185
|
-
nestedSource,
|
|
186
|
-
nestedOutput,
|
|
187
|
-
platform,
|
|
188
|
-
);
|
|
189
|
-
if (nestedResult.entries > 0) {
|
|
190
|
-
outputZip.addFile(nestedOutput, entry.fileName, {
|
|
191
|
-
compress: entry.compressionMethod !== 0,
|
|
192
|
-
mtime: entry.getLastModDate(),
|
|
193
|
-
});
|
|
194
|
-
includedEntries += nestedResult.entries;
|
|
195
|
-
includedBundles += nestedResult.bundles;
|
|
196
|
-
}
|
|
197
|
-
sourceZip.readEntry();
|
|
198
|
-
return;
|
|
199
|
-
}
|
|
200
261
|
|
|
201
|
-
|
|
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,
|
|
202
276
|
platform,
|
|
203
|
-
|
|
277
|
+
options,
|
|
204
278
|
);
|
|
205
|
-
if (
|
|
206
|
-
await
|
|
207
|
-
includedEntries +=
|
|
208
|
-
|
|
209
|
-
includedBundles += 1;
|
|
210
|
-
}
|
|
279
|
+
if (nestedResult.entries > 0) {
|
|
280
|
+
await sink.addFile(nestedOutput, entry.fileName, entry);
|
|
281
|
+
includedEntries += nestedResult.entries;
|
|
282
|
+
includedBundles += nestedResult.bundles;
|
|
211
283
|
}
|
|
212
284
|
sourceZip.readEntry();
|
|
213
|
-
|
|
214
|
-
fail(error);
|
|
285
|
+
return;
|
|
215
286
|
}
|
|
216
|
-
});
|
|
217
287
|
|
|
218
|
-
|
|
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
|
+
}
|
|
219
303
|
});
|
|
304
|
+
|
|
305
|
+
sourceZip.readEntry();
|
|
220
306
|
});
|
|
221
307
|
|
|
222
|
-
|
|
223
|
-
await writePromise;
|
|
308
|
+
await sink.end();
|
|
224
309
|
return { bundles: includedBundles, entries: includedEntries };
|
|
225
310
|
} catch (error) {
|
|
226
|
-
|
|
227
|
-
await writePromise.catch(() => {});
|
|
311
|
+
await sink.abort();
|
|
228
312
|
throw error;
|
|
229
313
|
} finally {
|
|
230
314
|
await fs.remove(scratchDir);
|
|
@@ -239,8 +323,14 @@ export async function createSlimNativePackage(
|
|
|
239
323
|
source: string,
|
|
240
324
|
output: string,
|
|
241
325
|
platform: Platform,
|
|
326
|
+
options: SlimPackageOptions = {},
|
|
242
327
|
): Promise<void> {
|
|
243
|
-
const result = await filterNativePackageArchive(
|
|
328
|
+
const result = await filterNativePackageArchive(
|
|
329
|
+
source,
|
|
330
|
+
output,
|
|
331
|
+
platform,
|
|
332
|
+
options,
|
|
333
|
+
);
|
|
244
334
|
if (result.bundles === 0) {
|
|
245
335
|
await fs.remove(output);
|
|
246
336
|
throw new Error(`Bundle entry not found in native package: ${source}`);
|
package/src/package.ts
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import * as fs from 'fs-extra';
|
|
2
2
|
import os from 'os';
|
|
3
3
|
import path from 'path';
|
|
4
|
-
import Table from 'tty-table';
|
|
5
4
|
import { doDelete, getAllPackages, post, uploadFile } from './api';
|
|
6
5
|
import { getPlatform, getSelectedApp } from './app';
|
|
7
6
|
import { createSlimNativePackage } from './native-package';
|
|
8
|
-
import type { Platform } from './types';
|
|
7
|
+
import type { Package, Platform } from './types';
|
|
9
8
|
import {
|
|
10
9
|
getAabInfo,
|
|
11
10
|
getApkInfo,
|
|
12
11
|
getAppInfo,
|
|
13
12
|
getIpaInfo,
|
|
13
|
+
loadTtyTable,
|
|
14
14
|
question,
|
|
15
15
|
} from './utils';
|
|
16
|
-
import {
|
|
17
|
-
import { depVersions } from './utils/dep-versions';
|
|
16
|
+
import { getDepVersions } from './utils/dep-versions';
|
|
18
17
|
import { getCommitInfo } from './utils/git';
|
|
19
18
|
import { bundleEntryMatcher, cachePut } from './utils/hermes-base';
|
|
20
19
|
import { t } from './utils/i18n';
|
|
@@ -61,6 +60,13 @@ type NativeUploadConfig = {
|
|
|
61
60
|
) => string | number | undefined;
|
|
62
61
|
};
|
|
63
62
|
|
|
63
|
+
// the AAB parser drags in protobufjs; load it only for the aab commands
|
|
64
|
+
function createAabParser(source: string) {
|
|
65
|
+
const { AabParser } =
|
|
66
|
+
require('./utils/app-info-parser/aab') as typeof import('./utils/app-info-parser/aab');
|
|
67
|
+
return new AabParser(source);
|
|
68
|
+
}
|
|
69
|
+
|
|
64
70
|
export function normalizeUploadBuildTime(value: unknown): string {
|
|
65
71
|
return String(value);
|
|
66
72
|
}
|
|
@@ -169,8 +175,9 @@ async function uploadNativePackage(
|
|
|
169
175
|
);
|
|
170
176
|
if (bundleFile) {
|
|
171
177
|
// keep the embedded bundle locally so a later `bundle` can use it as
|
|
172
|
-
// hermes base without downloading it back (see hermes-base.ts)
|
|
173
|
-
|
|
178
|
+
// hermes base without downloading it back (see hermes-base.ts); getInfo
|
|
179
|
+
// already hashed the bundle, so pass that hash instead of hashing twice
|
|
180
|
+
await cachePut(bundleFile, undefined, bundleHash).catch(() => {});
|
|
174
181
|
}
|
|
175
182
|
const normalizedBuildTime = config.normalizeBuildTime
|
|
176
183
|
? config.normalizeBuildTime(buildTime)
|
|
@@ -186,7 +193,7 @@ async function uploadNativePackage(
|
|
|
186
193
|
// Old servers strip unknown fields, so this is forward-compatible.
|
|
187
194
|
...(bundleHash ? { bundleHash } : {}),
|
|
188
195
|
...bundleLocation,
|
|
189
|
-
deps:
|
|
196
|
+
deps: getDepVersions(),
|
|
190
197
|
commit: await getCommitInfo(),
|
|
191
198
|
});
|
|
192
199
|
console.log(
|
|
@@ -201,8 +208,12 @@ async function uploadNativePackage(
|
|
|
201
208
|
}
|
|
202
209
|
}
|
|
203
210
|
|
|
204
|
-
|
|
205
|
-
|
|
211
|
+
/**
|
|
212
|
+
* Print the app's native packages. Pass `packages` when the caller already
|
|
213
|
+
* fetched them (every page of the list), to skip fetching them again.
|
|
214
|
+
*/
|
|
215
|
+
export async function listPackage(appId: string, packages?: Package[]) {
|
|
216
|
+
const allPkgs = packages ?? (await getAllPackages(appId)) ?? [];
|
|
206
217
|
|
|
207
218
|
const header = [
|
|
208
219
|
{ value: t('nativePackageId') },
|
|
@@ -230,13 +241,15 @@ export async function listPackage(appId: string) {
|
|
|
230
241
|
rows.push([pkg.id, output]);
|
|
231
242
|
}
|
|
232
243
|
|
|
244
|
+
// tty-table is ~25 ms to load; only pay for it when a table is rendered
|
|
245
|
+
const Table = loadTtyTable();
|
|
233
246
|
console.log(Table(header, rows).render());
|
|
234
247
|
console.log(t('totalPackages', { count: allPkgs.length }));
|
|
235
248
|
return allPkgs;
|
|
236
249
|
}
|
|
237
250
|
|
|
238
|
-
export async function choosePackage(appId: string) {
|
|
239
|
-
const list = await listPackage(appId);
|
|
251
|
+
export async function choosePackage(appId: string, packages?: Package[]) {
|
|
252
|
+
const list = await listPackage(appId, packages);
|
|
240
253
|
const packageMap = new Map(list?.map((v) => [v.id.toString(), v]));
|
|
241
254
|
|
|
242
255
|
while (true) {
|
|
@@ -302,7 +315,7 @@ export const packageCommands = {
|
|
|
302
315
|
const includeAllSplits = parseBooleanOption(options.includeAllSplits);
|
|
303
316
|
const splits = parseCsvOption(options.splits);
|
|
304
317
|
|
|
305
|
-
const parser =
|
|
318
|
+
const parser = createAabParser(source);
|
|
306
319
|
try {
|
|
307
320
|
await parser.extractApk(output, {
|
|
308
321
|
includeAllSplits,
|
|
@@ -381,7 +394,7 @@ export const packageCommands = {
|
|
|
381
394
|
const includeAllSplits = parseBooleanOption(options.includeAllSplits);
|
|
382
395
|
const splits = parseCsvOption(options.splits);
|
|
383
396
|
|
|
384
|
-
const parser =
|
|
397
|
+
const parser = createAabParser(source);
|
|
385
398
|
await parser.extractApk(output, {
|
|
386
399
|
includeAllSplits,
|
|
387
400
|
splits,
|
package/src/types.ts
CHANGED
|
@@ -61,6 +61,8 @@ export interface BundleOptions {
|
|
|
61
61
|
hermesBase?: string;
|
|
62
62
|
/** run the disassembly equivalence check after a base compile (default true) */
|
|
63
63
|
verifyHermesBase?: boolean;
|
|
64
|
+
/** pass --reset-cache to Metro (default true); false reuses its transform cache */
|
|
65
|
+
resetCache?: boolean;
|
|
64
66
|
sentryRelease?: string;
|
|
65
67
|
sentryDist?: string;
|
|
66
68
|
}
|
|
@@ -1,40 +1,83 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
// Installed versions of every dependency/devDependency of the project in cwd.
|
|
2
|
+
// Resolving them means reading one package.json per dependency, so this is
|
|
3
|
+
// done lazily (on first use) and memoized rather than at import time, which
|
|
4
|
+
// used to cost every command ~3-30 ms before it even parsed its arguments.
|
|
5
|
+
|
|
6
|
+
let cached: Record<string, string> | undefined;
|
|
7
|
+
|
|
8
|
+
function readDepVersions(): Record<string, string> {
|
|
9
|
+
let currentPackage: {
|
|
10
|
+
dependencies?: Record<string, string>;
|
|
11
|
+
devDependencies?: Record<string, string>;
|
|
12
|
+
} | null = null;
|
|
13
|
+
try {
|
|
14
|
+
currentPackage = require(`${process.cwd()}/package.json`);
|
|
15
|
+
} catch (_e) {
|
|
16
|
+
// console.warn('No package.json file were found');
|
|
17
|
+
}
|
|
7
18
|
|
|
8
|
-
const
|
|
19
|
+
const versions: Record<string, string> = {};
|
|
20
|
+
if (currentPackage) {
|
|
21
|
+
const depKeys = currentPackage.dependencies
|
|
22
|
+
? Object.keys(currentPackage.dependencies)
|
|
23
|
+
: [];
|
|
24
|
+
const devDepKeys = currentPackage.devDependencies
|
|
25
|
+
? Object.keys(currentPackage.devDependencies)
|
|
26
|
+
: [];
|
|
27
|
+
const dedupedDeps = [...new Set([...depKeys, ...devDepKeys])];
|
|
9
28
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
29
|
+
for (const dep of dedupedDeps) {
|
|
30
|
+
try {
|
|
31
|
+
const packageJsonPath = require.resolve(`${dep}/package.json`, {
|
|
32
|
+
paths: [process.cwd()],
|
|
33
|
+
});
|
|
34
|
+
versions[dep] = require(packageJsonPath).version;
|
|
35
|
+
} catch (_e) {}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// sorted keys: the object is sent to the server as-is and diffed
|
|
40
|
+
return Object.keys(versions)
|
|
41
|
+
.sort()
|
|
42
|
+
.reduce(
|
|
43
|
+
(obj, key) => {
|
|
44
|
+
obj[key] = versions[key];
|
|
45
|
+
return obj;
|
|
46
|
+
},
|
|
47
|
+
{} as Record<string, string>,
|
|
48
|
+
);
|
|
49
|
+
}
|
|
18
50
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
});
|
|
24
|
-
const version = require(packageJsonPath).version;
|
|
25
|
-
_depVersions[dep] = version;
|
|
26
|
-
} catch (_e) {}
|
|
51
|
+
/** Installed versions of the cwd project's dependencies, keys sorted. */
|
|
52
|
+
export function getDepVersions(): Record<string, string> {
|
|
53
|
+
if (!cached) {
|
|
54
|
+
cached = readDepVersions();
|
|
27
55
|
}
|
|
56
|
+
return cached;
|
|
28
57
|
}
|
|
29
58
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
59
|
+
/**
|
|
60
|
+
* Same data as `getDepVersions()` but as a lazily populated object, for the
|
|
61
|
+
* remaining property-access call sites (`depVersions['react-native']`).
|
|
62
|
+
* Nothing is resolved until the first property access.
|
|
63
|
+
*/
|
|
64
|
+
export const depVersions: Record<string, string> = new Proxy(
|
|
65
|
+
{} as Record<string, string>,
|
|
66
|
+
{
|
|
67
|
+
get: (_target, key) =>
|
|
68
|
+
typeof key === 'string' ? getDepVersions()[key] : undefined,
|
|
69
|
+
has: (_target, key) => typeof key === 'string' && key in getDepVersions(),
|
|
70
|
+
ownKeys: () => Object.keys(getDepVersions()),
|
|
71
|
+
getOwnPropertyDescriptor: (_target, key) => {
|
|
72
|
+
if (typeof key !== 'string' || !(key in getDepVersions())) {
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
value: getDepVersions()[key],
|
|
77
|
+
writable: false,
|
|
78
|
+
enumerable: true,
|
|
79
|
+
configurable: true,
|
|
80
|
+
};
|
|
36
81
|
},
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
// console.log({ depVersions });
|
|
82
|
+
},
|
|
83
|
+
);
|