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.
- package/cli.json +0 -6
- package/lib/api.js +25 -4
- package/lib/app.js +1 -0
- package/lib/bin-cresc.d.ts +1 -0
- package/lib/bin-cresc.js +7 -0
- package/lib/bin.js +5 -3
- package/lib/bundle-pack.d.ts +1 -1
- package/lib/bundle-pack.js +8 -7
- package/lib/bundle-runner.d.ts +3 -3
- package/lib/bundle-runner.js +68 -49
- package/lib/bundle.d.ts +26 -0
- package/lib/bundle.js +18 -6
- package/lib/diff.js +55 -70
- package/lib/install.js +30 -3
- package/lib/locales/en.d.ts +13 -0
- package/lib/locales/en.js +14 -1
- package/lib/locales/zh.d.ts +13 -0
- package/lib/locales/zh.js +14 -1
- package/lib/package.js +8 -2
- package/lib/provider.js +9 -3
- package/lib/types.d.ts +2 -2
- package/lib/utils/app-info-parser/aab.js +4 -4
- package/lib/utils/app-info-parser/xml-parser/binary.js +4 -3
- package/lib/utils/app-info-parser/xml-parser/manifest.js +3 -1
- package/lib/utils/app-info-parser/zip.d.ts +6 -0
- package/lib/utils/app-info-parser/zip.js +20 -5
- package/lib/utils/check-lockfile.js +5 -1
- package/lib/utils/constants.d.ts +1 -1
- package/lib/utils/constants.js +2 -1
- package/lib/utils/http-helper.js +20 -23
- package/lib/utils/index.js +48 -20
- package/lib/utils/zip-entries.js +4 -0
- package/lib/versions.d.ts +2 -0
- package/lib/versions.js +19 -8
- package/package.json +5 -5
- package/src/api.ts +30 -5
- package/src/app.ts +1 -0
- package/src/bin-cresc.ts +8 -0
- package/src/bin.ts +3 -3
- package/src/bundle-pack.ts +12 -7
- package/src/bundle-runner.ts +82 -56
- package/src/bundle.ts +13 -8
- package/src/diff.ts +87 -109
- package/src/install.ts +32 -3
- package/src/locales/en.ts +16 -0
- package/src/locales/zh.ts +15 -0
- package/src/package.ts +4 -4
- package/src/provider.ts +7 -3
- package/src/types.ts +3 -2
- package/src/utils/app-info-parser/aab.ts +4 -4
- package/src/utils/app-info-parser/xml-parser/binary.ts +4 -5
- package/src/utils/app-info-parser/xml-parser/manifest.ts +6 -3
- package/src/utils/app-info-parser/zip.ts +22 -5
- package/src/utils/check-lockfile.ts +5 -1
- package/src/utils/constants.ts +5 -1
- package/src/utils/http-helper.ts +16 -23
- package/src/utils/index.ts +51 -36
- package/src/utils/zip-entries.ts +4 -0
- package/src/versions.ts +15 -11
package/lib/versions.js
CHANGED
|
@@ -15,6 +15,9 @@ _export(exports, {
|
|
|
15
15
|
get fetchVersions () {
|
|
16
16
|
return fetchVersions;
|
|
17
17
|
},
|
|
18
|
+
get normalizeDeps () {
|
|
19
|
+
return normalizeDeps;
|
|
20
|
+
},
|
|
18
21
|
get versionCommands () {
|
|
19
22
|
return versionCommands;
|
|
20
23
|
}
|
|
@@ -103,7 +106,9 @@ function toNumericIds(ids) {
|
|
|
103
106
|
return ids.map((id)=>{
|
|
104
107
|
const numericId = Number(id);
|
|
105
108
|
if (!Number.isInteger(numericId) || numericId <= 0) {
|
|
106
|
-
throw new Error(
|
|
109
|
+
throw new Error((0, _i18n.t)('invalidId', {
|
|
110
|
+
id
|
|
111
|
+
}));
|
|
107
112
|
}
|
|
108
113
|
return numericId;
|
|
109
114
|
});
|
|
@@ -295,7 +300,7 @@ async function chooseVersion(appId) {
|
|
|
295
300
|
default:
|
|
296
301
|
{
|
|
297
302
|
const versionId = Number.parseInt(cmd, 10);
|
|
298
|
-
const v = data.find((version)=>version.id === String(versionId));
|
|
303
|
+
const v = data.find((version)=>String(version.id) === String(versionId));
|
|
299
304
|
if (v) {
|
|
300
305
|
return v;
|
|
301
306
|
}
|
|
@@ -309,6 +314,7 @@ const bindVersionToPackages = async ({ appId, versionId, pkgs, rollout, dryRun }
|
|
|
309
314
|
}
|
|
310
315
|
if (rollout !== undefined) {
|
|
311
316
|
console.log(`${(0, _i18n.t)('rolloutConfigSet', {
|
|
317
|
+
version: versionId,
|
|
312
318
|
versions: pkgs.map((pkg)=>pkg.name).join(', '),
|
|
313
319
|
rollout: rollout
|
|
314
320
|
})}`);
|
|
@@ -418,7 +424,7 @@ const versionCommands = {
|
|
|
418
424
|
if (nonInteractive) {
|
|
419
425
|
throw new Error((0, _i18n.t)('versionIdRequired'));
|
|
420
426
|
}
|
|
421
|
-
versionId = (await chooseVersion(String(appId))).id;
|
|
427
|
+
versionId = String((await chooseVersion(String(appId))).id);
|
|
422
428
|
}
|
|
423
429
|
if (versionId === 'null') {
|
|
424
430
|
versionId = null;
|
|
@@ -441,6 +447,10 @@ const versionCommands = {
|
|
|
441
447
|
appId
|
|
442
448
|
}));
|
|
443
449
|
}
|
|
450
|
+
const pkgMap = new Map(allPkgs.map((pkg)=>[
|
|
451
|
+
String(pkg.id),
|
|
452
|
+
pkg
|
|
453
|
+
]));
|
|
444
454
|
let pkgsToBind = [];
|
|
445
455
|
if (minPkgVersion) {
|
|
446
456
|
minPkgVersion = String(minPkgVersion).trim();
|
|
@@ -485,12 +495,12 @@ const versionCommands = {
|
|
|
485
495
|
if (nonInteractive) {
|
|
486
496
|
throw new Error((0, _i18n.t)('packageIdRequired'));
|
|
487
497
|
}
|
|
488
|
-
pkgId = (await (0, _package.choosePackage)(String(appId))).id;
|
|
498
|
+
pkgId = String((await (0, _package.choosePackage)(String(appId))).id);
|
|
489
499
|
}
|
|
490
500
|
if (!pkgId) {
|
|
491
501
|
throw new Error((0, _i18n.t)('packageIdRequired'));
|
|
492
502
|
}
|
|
493
|
-
const pkg =
|
|
503
|
+
const pkg = pkgMap.get(String(pkgId));
|
|
494
504
|
if (pkg) {
|
|
495
505
|
pkgsToBind = [
|
|
496
506
|
pkg
|
|
@@ -511,7 +521,8 @@ const versionCommands = {
|
|
|
511
521
|
}
|
|
512
522
|
await bindVersionToPackages({
|
|
513
523
|
appId: String(appId),
|
|
514
|
-
|
|
524
|
+
// keep null as-is: `--versionId null` means unbinding the version
|
|
525
|
+
versionId: versionId != null ? versionId : null,
|
|
515
526
|
pkgs: pkgsToBind,
|
|
516
527
|
rollout,
|
|
517
528
|
dryRun: options.dryRun
|
|
@@ -532,7 +543,7 @@ const versionCommands = {
|
|
|
532
543
|
if (nonInteractive) {
|
|
533
544
|
throw new Error((0, _i18n.t)('versionIdRequired'));
|
|
534
545
|
}
|
|
535
|
-
versionId = (await chooseVersion(String(appId))).id;
|
|
546
|
+
versionId = String((await chooseVersion(String(appId))).id);
|
|
536
547
|
}
|
|
537
548
|
const updateParams = {};
|
|
538
549
|
if (options.name) updateParams.name = options.name;
|
|
@@ -556,7 +567,7 @@ const versionCommands = {
|
|
|
556
567
|
throw new Error((0, _i18n.t)('versionIdRequired'));
|
|
557
568
|
}
|
|
558
569
|
versionIds = [
|
|
559
|
-
(await chooseVersion(String(appId))).id
|
|
570
|
+
String((await chooseVersion(String(appId))).id)
|
|
560
571
|
];
|
|
561
572
|
}
|
|
562
573
|
try {
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-update-cli",
|
|
3
|
-
"version": "2.15.
|
|
3
|
+
"version": "2.15.4",
|
|
4
4
|
"description": "command line tool for react-native-update (remote updates for react native)",
|
|
5
5
|
"main": "lib/exports.js",
|
|
6
6
|
"types": "lib/exports.d.ts",
|
|
7
7
|
"bin": {
|
|
8
8
|
"pushy": "lib/bin.js",
|
|
9
|
-
"cresc": "lib/bin.js"
|
|
9
|
+
"cresc": "lib/bin-cresc.js"
|
|
10
10
|
},
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"cli.json"
|
|
33
33
|
],
|
|
34
34
|
"scripts": {
|
|
35
|
-
"build": "rm -rf lib && swc src -d lib --strip-leading-paths && bun run typecheck:build && chmod +x lib/bin.js",
|
|
35
|
+
"build": "rm -rf lib && swc src -d lib --strip-leading-paths && bun run typecheck:build && chmod +x lib/bin.js lib/bin-cresc.js",
|
|
36
36
|
"prepublishOnly": "bun run build",
|
|
37
37
|
"typecheck": "tsc --noEmit",
|
|
38
38
|
"typecheck:build": "tsc -p tsconfig.build.json",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"compare-versions": "^6.1.1",
|
|
68
68
|
"filesize-parser": "^1.5.1",
|
|
69
69
|
"form-data": "^4.0.5",
|
|
70
|
-
"fs-extra": "
|
|
70
|
+
"fs-extra": "^11.3.5",
|
|
71
71
|
"global-dirs": "^4.0.0",
|
|
72
72
|
"gradle-to-js": "^2.0.1",
|
|
73
73
|
"i18next": "^26.0.4",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"@xmldom/xmldom": "0.8.13"
|
|
88
88
|
},
|
|
89
89
|
"engines": {
|
|
90
|
-
"node": ">=
|
|
90
|
+
"node": ">= 18.17.0"
|
|
91
91
|
},
|
|
92
92
|
"devDependencies": {
|
|
93
93
|
"@biomejs/biome": "^2.4.12",
|
package/src/api.ts
CHANGED
|
@@ -140,9 +140,13 @@ async function query(url: string, options: RuntimeRequestInit) {
|
|
|
140
140
|
try {
|
|
141
141
|
json = JSON.parse(text);
|
|
142
142
|
} catch (_e) {
|
|
143
|
-
if (resp.status === 200
|
|
144
|
-
|
|
145
|
-
|
|
143
|
+
if (resp.status === 200) {
|
|
144
|
+
// a proxy/gateway likely replaced the response; surface it instead of
|
|
145
|
+
// returning undefined and crashing callers on destructuring
|
|
146
|
+
throw createRequestError(
|
|
147
|
+
`API returned 200 with non-JSON body (${text.length} bytes)`,
|
|
148
|
+
fullUrl,
|
|
149
|
+
resp.status,
|
|
146
150
|
);
|
|
147
151
|
}
|
|
148
152
|
}
|
|
@@ -282,6 +286,27 @@ export async function uploadFile(fn: string, key?: string) {
|
|
|
282
286
|
}
|
|
283
287
|
|
|
284
288
|
export const getAllPackages = async (appId: string) => {
|
|
285
|
-
|
|
286
|
-
|
|
289
|
+
// the server caps limit at 100, so page through with offset
|
|
290
|
+
const limit = 100;
|
|
291
|
+
let offset = 0;
|
|
292
|
+
let allPackages: Package[] | undefined | null;
|
|
293
|
+
while (true) {
|
|
294
|
+
const { data, count } = await get(
|
|
295
|
+
`/app/${appId}/package/list?offset=${offset}&limit=${limit}`,
|
|
296
|
+
);
|
|
297
|
+
const packages = data as Package[] | undefined | null;
|
|
298
|
+
if (allPackages === undefined || allPackages === null) {
|
|
299
|
+
allPackages = packages;
|
|
300
|
+
} else if (packages) {
|
|
301
|
+
allPackages.push(...packages);
|
|
302
|
+
}
|
|
303
|
+
if (!packages || packages.length === 0) {
|
|
304
|
+
break;
|
|
305
|
+
}
|
|
306
|
+
offset += packages.length;
|
|
307
|
+
if (offset >= Number(count || 0)) {
|
|
308
|
+
break;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
return allPackages;
|
|
287
312
|
};
|
package/src/app.ts
CHANGED
package/src/bin-cresc.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
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
|
+
|
|
8
|
+
require('./bin');
|
package/src/bin.ts
CHANGED
|
@@ -78,15 +78,15 @@ async function run() {
|
|
|
78
78
|
const handler = commandHandlers[argv.command];
|
|
79
79
|
await handler(argv);
|
|
80
80
|
} else {
|
|
81
|
-
throw new Error(
|
|
81
|
+
throw new Error(t('unknownCommand', { command: argv.command }));
|
|
82
82
|
}
|
|
83
83
|
} catch (err: any) {
|
|
84
84
|
if (err.status === 401) {
|
|
85
85
|
console.log(t('loginFirst'));
|
|
86
|
-
|
|
86
|
+
process.exit(1);
|
|
87
87
|
}
|
|
88
88
|
console.error(err.stack);
|
|
89
|
-
process.exit(
|
|
89
|
+
process.exit(1);
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
|
package/src/bundle-pack.ts
CHANGED
|
@@ -4,15 +4,20 @@ import { ZipFile as YazlZipFile } from 'yazl';
|
|
|
4
4
|
import { t } from './utils/i18n';
|
|
5
5
|
import { zipOptionsForPayloadFile } from './utils/zip-options';
|
|
6
6
|
|
|
7
|
-
const ignorePackingFileNames = [
|
|
8
|
-
'.',
|
|
9
|
-
'..',
|
|
10
|
-
'index.bundlejs.map',
|
|
11
|
-
'bundle.harmony.js.map',
|
|
12
|
-
];
|
|
13
7
|
const ignorePackingExtensions = ['DS_Store', 'txt.map'];
|
|
14
8
|
|
|
15
|
-
export async function packBundle(
|
|
9
|
+
export async function packBundle(
|
|
10
|
+
dir: string,
|
|
11
|
+
output: string,
|
|
12
|
+
bundleName?: string,
|
|
13
|
+
): Promise<void> {
|
|
14
|
+
const ignorePackingFileNames = [
|
|
15
|
+
'index.bundlejs.map',
|
|
16
|
+
'bundle.harmony.js.map',
|
|
17
|
+
];
|
|
18
|
+
if (bundleName) {
|
|
19
|
+
ignorePackingFileNames.push(`${bundleName}.map`);
|
|
20
|
+
}
|
|
16
21
|
console.log(t('packing'));
|
|
17
22
|
fs.ensureDirSync(path.dirname(output));
|
|
18
23
|
await new Promise<void>((resolve, reject) => {
|
package/src/bundle-runner.ts
CHANGED
|
@@ -241,6 +241,11 @@ export async function runReactNativeBundleCommand({
|
|
|
241
241
|
process.env.SENTRY_PROPERTIES = 'ios/sentry.properties';
|
|
242
242
|
} else if (platform === 'android') {
|
|
243
243
|
process.env.SENTRY_PROPERTIES = 'android/sentry.properties';
|
|
244
|
+
} else if (
|
|
245
|
+
platform === 'harmony' &&
|
|
246
|
+
fs.existsSync('harmony/sentry.properties')
|
|
247
|
+
) {
|
|
248
|
+
process.env.SENTRY_PROPERTIES = 'harmony/sentry.properties';
|
|
244
249
|
}
|
|
245
250
|
}
|
|
246
251
|
|
|
@@ -302,20 +307,24 @@ export async function runReactNativeBundleCommand({
|
|
|
302
307
|
console.error(data.toString().trim());
|
|
303
308
|
});
|
|
304
309
|
|
|
310
|
+
reactNativeBundleProcess.once('error', reject);
|
|
311
|
+
|
|
305
312
|
reactNativeBundleProcess.on('close', async (exitCode) => {
|
|
306
313
|
if (exitCode) {
|
|
307
314
|
reject(new Error(t('bundleCommandError', { code: exitCode })));
|
|
308
315
|
return;
|
|
309
316
|
}
|
|
310
317
|
|
|
311
|
-
|
|
318
|
+
try {
|
|
319
|
+
let hermesEnabled: boolean | undefined = false;
|
|
312
320
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
321
|
+
if (forceHermes) {
|
|
322
|
+
hermesEnabled = true;
|
|
323
|
+
console.log(t('forceHermes'));
|
|
324
|
+
} else if (platform === 'android') {
|
|
325
|
+
const gradleProperties = await new Promise<{
|
|
326
|
+
hermesEnabled?: boolean;
|
|
327
|
+
}>((resolve) => {
|
|
319
328
|
properties.parse(
|
|
320
329
|
'./android/gradle.properties',
|
|
321
330
|
{ path: true },
|
|
@@ -331,42 +340,48 @@ export async function runReactNativeBundleCommand({
|
|
|
331
340
|
resolve(props);
|
|
332
341
|
},
|
|
333
342
|
);
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
|
|
343
|
+
});
|
|
344
|
+
hermesEnabled = gradleProperties.hermesEnabled;
|
|
345
|
+
|
|
346
|
+
if (typeof hermesEnabled !== 'boolean') {
|
|
347
|
+
hermesEnabled = gradleConfig.enableHermes;
|
|
348
|
+
}
|
|
349
|
+
} else if (
|
|
350
|
+
platform === 'ios' &&
|
|
351
|
+
fs.existsSync('ios/Pods/hermes-engine')
|
|
352
|
+
) {
|
|
353
|
+
hermesEnabled = true;
|
|
354
|
+
}
|
|
337
355
|
|
|
338
|
-
if (
|
|
339
|
-
|
|
356
|
+
if (hermesEnabled) {
|
|
357
|
+
await compileHermesByteCode(
|
|
358
|
+
bundleName,
|
|
359
|
+
outputFolder,
|
|
360
|
+
sourcemapOutput,
|
|
361
|
+
!isSentry,
|
|
362
|
+
);
|
|
340
363
|
}
|
|
341
|
-
} else if (
|
|
342
|
-
platform === 'ios' &&
|
|
343
|
-
fs.existsSync('ios/Pods/hermes-engine')
|
|
344
|
-
) {
|
|
345
|
-
hermesEnabled = true;
|
|
346
|
-
}
|
|
347
364
|
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
365
|
+
if (platform === 'harmony') {
|
|
366
|
+
const harmonyRawAssetsPath =
|
|
367
|
+
'harmony/entry/src/main/resources/rawfile/assets';
|
|
368
|
+
fs.ensureDirSync(harmonyRawAssetsPath);
|
|
369
|
+
fs.copySync(outputFolder, harmonyRawAssetsPath, {
|
|
370
|
+
overwrite: true,
|
|
371
|
+
// sourcemaps must not ship inside the native package
|
|
372
|
+
filter: (src) => !src.endsWith('.map'),
|
|
373
|
+
});
|
|
374
|
+
fs.moveSync(
|
|
375
|
+
`${harmonyRawAssetsPath}/bundle.harmony.js`,
|
|
376
|
+
`${harmonyRawAssetsPath}/../bundle.harmony.js`,
|
|
377
|
+
{ overwrite: true },
|
|
378
|
+
);
|
|
379
|
+
}
|
|
356
380
|
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
fs.ensureDirSync(harmonyRawAssetsPath);
|
|
361
|
-
fs.copySync(outputFolder, harmonyRawAssetsPath, { overwrite: true });
|
|
362
|
-
fs.moveSync(
|
|
363
|
-
`${harmonyRawAssetsPath}/bundle.harmony.js`,
|
|
364
|
-
`${harmonyRawAssetsPath}/../bundle.harmony.js`,
|
|
365
|
-
{ overwrite: true },
|
|
366
|
-
);
|
|
381
|
+
resolve();
|
|
382
|
+
} catch (error) {
|
|
383
|
+
reject(error);
|
|
367
384
|
}
|
|
368
|
-
|
|
369
|
-
resolve();
|
|
370
385
|
});
|
|
371
386
|
});
|
|
372
387
|
}
|
|
@@ -418,7 +433,9 @@ function normalizeString(value: string | undefined): string | undefined {
|
|
|
418
433
|
export function resolveHermesCommand(projectRoot = process.cwd()): string {
|
|
419
434
|
const osBin = getHermesOSBin();
|
|
420
435
|
if (!osBin) {
|
|
421
|
-
throw new Error(
|
|
436
|
+
throw new Error(
|
|
437
|
+
t('unsupportedPlatformForHermes', { platform: os.platform() }),
|
|
438
|
+
);
|
|
422
439
|
}
|
|
423
440
|
|
|
424
441
|
const executableName = getHermesExecutableName();
|
|
@@ -529,9 +546,15 @@ async function compileHermesByteCode(
|
|
|
529
546
|
hermesCommand,
|
|
530
547
|
);
|
|
531
548
|
if (sourcemapOutput) {
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
549
|
+
let composerPath: string;
|
|
550
|
+
try {
|
|
551
|
+
// resolve through the project so hoisted node_modules (monorepos) work
|
|
552
|
+
composerPath = require.resolve(
|
|
553
|
+
'react-native/scripts/compose-source-maps.js',
|
|
554
|
+
{ paths: [process.cwd()] },
|
|
555
|
+
);
|
|
556
|
+
} catch {
|
|
557
|
+
console.warn(t('composeSourceMapsNotFound'));
|
|
535
558
|
return;
|
|
536
559
|
}
|
|
537
560
|
console.log(t('composingSourceMap'));
|
|
@@ -571,7 +594,7 @@ export async function copyDebugidForSentry(
|
|
|
571
594
|
},
|
|
572
595
|
);
|
|
573
596
|
} catch {
|
|
574
|
-
console.error(t('
|
|
597
|
+
console.error(t('sentryReactNativeNotFound'));
|
|
575
598
|
return;
|
|
576
599
|
}
|
|
577
600
|
|
|
@@ -596,11 +619,11 @@ export async function copyDebugidForSentry(
|
|
|
596
619
|
fs.removeSync(path.join(outputFolder, `${bundleName}.txt.map`));
|
|
597
620
|
}
|
|
598
621
|
|
|
599
|
-
export function prepareSentryUploadArtifacts(
|
|
622
|
+
export async function prepareSentryUploadArtifacts(
|
|
600
623
|
bundleName: string,
|
|
601
624
|
outputFolder: string,
|
|
602
625
|
platform: string,
|
|
603
|
-
): SentryUploadArtifacts {
|
|
626
|
+
): Promise<SentryUploadArtifacts> {
|
|
604
627
|
const bundlePath = path.join(outputFolder, bundleName);
|
|
605
628
|
const sourcemapPath = path.join(outputFolder, `${bundleName}.map`);
|
|
606
629
|
|
|
@@ -616,13 +639,13 @@ export function prepareSentryUploadArtifacts(
|
|
|
616
639
|
outputFolder,
|
|
617
640
|
`${ANDROID_SENTRY_BUNDLE_NAME}.map`,
|
|
618
641
|
);
|
|
619
|
-
fs.
|
|
642
|
+
await fs.promises.copyFile(bundlePath, androidBundlePath);
|
|
620
643
|
|
|
621
644
|
const sourcemap = JSON.parse(
|
|
622
|
-
fs.
|
|
645
|
+
await fs.promises.readFile(sourcemapPath, 'utf8'),
|
|
623
646
|
) as Record<string, unknown>;
|
|
624
647
|
sourcemap.file = ANDROID_SENTRY_BUNDLE_NAME;
|
|
625
|
-
fs.
|
|
648
|
+
await fs.promises.writeFile(androidSourcemapPath, JSON.stringify(sourcemap));
|
|
626
649
|
|
|
627
650
|
return {
|
|
628
651
|
bundlePath: androidBundlePath,
|
|
@@ -630,12 +653,12 @@ export function prepareSentryUploadArtifacts(
|
|
|
630
653
|
};
|
|
631
654
|
}
|
|
632
655
|
|
|
633
|
-
export function readSourcemapDebugId(
|
|
656
|
+
export async function readSourcemapDebugId(
|
|
634
657
|
sourcemapPath: string,
|
|
635
|
-
): string | undefined {
|
|
658
|
+
): Promise<string | undefined> {
|
|
636
659
|
try {
|
|
637
660
|
const sourcemap = JSON.parse(
|
|
638
|
-
fs.
|
|
661
|
+
await fs.promises.readFile(sourcemapPath, 'utf8'),
|
|
639
662
|
) as Record<string, unknown>;
|
|
640
663
|
const debugId = sourcemap.debugId ?? sourcemap.debug_id;
|
|
641
664
|
return typeof debugId === 'string' ? normalizeString(debugId) : undefined;
|
|
@@ -658,10 +681,10 @@ function resolveSentryReleaseFromValues(
|
|
|
658
681
|
};
|
|
659
682
|
}
|
|
660
683
|
|
|
661
|
-
export function resolveSentryUploadMode(
|
|
684
|
+
export async function resolveSentryUploadMode(
|
|
662
685
|
sourcemapPath: string,
|
|
663
686
|
options: SentryUploadOptions = {},
|
|
664
|
-
): SentryUploadMode {
|
|
687
|
+
): Promise<SentryUploadMode> {
|
|
665
688
|
const optionRelease = resolveSentryReleaseFromValues(
|
|
666
689
|
options.sentryRelease,
|
|
667
690
|
options.sentryDist,
|
|
@@ -673,7 +696,7 @@ export function resolveSentryUploadMode(
|
|
|
673
696
|
};
|
|
674
697
|
}
|
|
675
698
|
|
|
676
|
-
const debugId = readSourcemapDebugId(sourcemapPath);
|
|
699
|
+
const debugId = await readSourcemapDebugId(sourcemapPath);
|
|
677
700
|
if (debugId) {
|
|
678
701
|
return {
|
|
679
702
|
type: 'debug-id',
|
|
@@ -848,12 +871,15 @@ export async function uploadSourcemapForSentry(
|
|
|
848
871
|
return;
|
|
849
872
|
}
|
|
850
873
|
|
|
851
|
-
const { bundlePath, sourcemapPath } = prepareSentryUploadArtifacts(
|
|
874
|
+
const { bundlePath, sourcemapPath } = await prepareSentryUploadArtifacts(
|
|
852
875
|
bundleName,
|
|
853
876
|
outputFolder,
|
|
854
877
|
platform,
|
|
855
878
|
);
|
|
856
|
-
const uploadMode = resolveSentryUploadMode(
|
|
879
|
+
const uploadMode = await resolveSentryUploadMode(
|
|
880
|
+
sourcemapPath,
|
|
881
|
+
sentryOptions,
|
|
882
|
+
);
|
|
857
883
|
const useStandaloneSourcemapsCommand =
|
|
858
884
|
supportsStandaloneSentrySourcemapsUpload(sentryCliPath);
|
|
859
885
|
|
package/src/bundle.ts
CHANGED
|
@@ -70,16 +70,17 @@ function getAliasedOptionalStringOption(
|
|
|
70
70
|
);
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
function normalizeBundleOptions(
|
|
73
|
+
export function normalizeBundleOptions(
|
|
74
74
|
translatedOptions: Record<string, unknown>,
|
|
75
75
|
platform: string,
|
|
76
76
|
): NormalizedBundleOptions {
|
|
77
77
|
return {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
'
|
|
82
|
-
|
|
78
|
+
// harmony bundles always use this fixed name (runReactNativeBundleCommand
|
|
79
|
+
// forces it), so sourcemap paths and Sentry uploads must match
|
|
80
|
+
bundleName:
|
|
81
|
+
platform === 'harmony'
|
|
82
|
+
? 'bundle.harmony.js'
|
|
83
|
+
: getStringOption(translatedOptions, 'bundleName', 'index.bundlejs'),
|
|
83
84
|
entryFile: getStringOption(translatedOptions, 'entryFile', 'index.js'),
|
|
84
85
|
intermediaDir: getStringOption(
|
|
85
86
|
translatedOptions,
|
|
@@ -203,7 +204,7 @@ export const bundleCommands = {
|
|
|
203
204
|
throw new Error(t('platformRequired'));
|
|
204
205
|
}
|
|
205
206
|
|
|
206
|
-
console.log(
|
|
207
|
+
console.log(t('bundlingWithRN', { version: depVersions['react-native'] }));
|
|
207
208
|
|
|
208
209
|
await runReactNativeBundleCommand({
|
|
209
210
|
bundleName: normalized.bundleName,
|
|
@@ -222,7 +223,11 @@ export const bundleCommands = {
|
|
|
222
223
|
isSentry: bundleParams.sentry,
|
|
223
224
|
});
|
|
224
225
|
|
|
225
|
-
await packBundle(
|
|
226
|
+
await packBundle(
|
|
227
|
+
path.resolve(normalized.intermediaDir),
|
|
228
|
+
realOutput,
|
|
229
|
+
normalized.bundleName,
|
|
230
|
+
);
|
|
226
231
|
|
|
227
232
|
if (normalized.name) {
|
|
228
233
|
await publishBundleVersion(realOutput, platform, {
|