react-native-update-cli 2.15.0 → 2.15.2
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 +18 -0
- package/README.zh-CN.md +18 -0
- package/cli.json +16 -0
- package/lib/bundle-runner.d.ts +31 -2
- package/lib/bundle-runner.js +200 -21
- package/lib/bundle.js +19 -7
- package/lib/provider.js +3 -1
- package/lib/types.d.ts +2 -0
- package/lib/utils/index.d.ts +1 -1
- package/lib/utils/index.js +29 -16
- package/package.json +3 -3
- package/src/bundle-runner.ts +325 -36
- package/src/bundle.ts +40 -10
- package/src/diff.ts +1 -1
- package/src/provider.ts +2 -0
- package/src/types.ts +2 -0
- package/src/utils/index.ts +31 -18
package/README.md
CHANGED
|
@@ -134,6 +134,24 @@ export PUSHY_REGISTRY=https://your-api-endpoint.com
|
|
|
134
134
|
export NO_INTERACTIVE=true
|
|
135
135
|
```
|
|
136
136
|
|
|
137
|
+
## Sentry Sourcemaps
|
|
138
|
+
|
|
139
|
+
When `ios/sentry.properties` or `android/sentry.properties` exists, `bundle` uploads sourcemaps for OTA packages. The default matching path is Sentry Debug IDs; the CLI no longer infers release/dist from the native package.
|
|
140
|
+
|
|
141
|
+
React Native projects should use `@sentry/react-native/metro` in `metro.config.js` so the generated bundle and sourcemap share the same Debug ID. For Hermes, the CLI copies the packager sourcemap Debug ID to the composed Hermes sourcemap and uploads with:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
sentry-cli sourcemaps upload --debug-id-reference
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
For older self-hosted Sentry versions or older `@sentry/cli` versions without Debug ID support, pass explicit legacy release/dist values:
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
npx pushy bundle --platform android --name "4.1" --sentry-release "com.example@1.0.0+10+pushy:4.1" --sentry-dist "pushy:4.1"
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
In legacy mode, the app runtime must report exactly the same Sentry `release` and `dist` values.
|
|
154
|
+
|
|
137
155
|
## Configuration
|
|
138
156
|
|
|
139
157
|
Create `update.json` in your React Native project:
|
package/README.zh-CN.md
CHANGED
|
@@ -134,6 +134,24 @@ export PUSHY_REGISTRY=https://your-api-endpoint.com
|
|
|
134
134
|
export NO_INTERACTIVE=true
|
|
135
135
|
```
|
|
136
136
|
|
|
137
|
+
## Sentry Sourcemap
|
|
138
|
+
|
|
139
|
+
当项目存在 `ios/sentry.properties` 或 `android/sentry.properties` 时,`bundle` 会为 OTA 包上传 sourcemap。默认使用 Sentry Debug ID 匹配,不再根据原生包推导 release/dist。
|
|
140
|
+
|
|
141
|
+
React Native 项目需要在 `metro.config.js` 中接入 `@sentry/react-native/metro`,确保生成的 bundle 和 sourcemap 带有相同 Debug ID。Hermes 场景下 CLI 会把 packager sourcemap 的 Debug ID 复制到合成后的 Hermes sourcemap,并使用:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
sentry-cli sourcemaps upload --debug-id-reference
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
旧版 self-hosted Sentry 或旧版 `@sentry/cli` 不支持 Debug ID 时,可以显式指定 legacy release/dist:
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
npx pushy bundle --platform android --name "4.1" --sentry-release "com.example@1.0.0+10+pushy:4.1" --sentry-dist "pushy:4.1"
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
这种 legacy 模式要求 App 运行时上报到 Sentry 的 `release` 和 `dist` 与上传参数完全一致。
|
|
154
|
+
|
|
137
155
|
## 配置文件
|
|
138
156
|
|
|
139
157
|
在 React Native 项目中创建 `update.json`:
|
package/cli.json
CHANGED
|
@@ -297,6 +297,22 @@
|
|
|
297
297
|
},
|
|
298
298
|
"dryRun": {
|
|
299
299
|
"default": false
|
|
300
|
+
},
|
|
301
|
+
"sentry-release": {
|
|
302
|
+
"hasValue": true,
|
|
303
|
+
"description": "Sentry release for source map upload"
|
|
304
|
+
},
|
|
305
|
+
"sentryRelease": {
|
|
306
|
+
"hasValue": true,
|
|
307
|
+
"description": "Sentry release for source map upload"
|
|
308
|
+
},
|
|
309
|
+
"sentry-dist": {
|
|
310
|
+
"hasValue": true,
|
|
311
|
+
"description": "Sentry dist for source map upload"
|
|
312
|
+
},
|
|
313
|
+
"sentryDist": {
|
|
314
|
+
"hasValue": true,
|
|
315
|
+
"description": "Sentry dist for source map upload"
|
|
300
316
|
}
|
|
301
317
|
}
|
|
302
318
|
},
|
package/lib/bundle-runner.d.ts
CHANGED
|
@@ -19,11 +19,40 @@ type ResolvedExpoCli = {
|
|
|
19
19
|
cliPath: string;
|
|
20
20
|
usingExpo: boolean;
|
|
21
21
|
};
|
|
22
|
+
type SentryUploadArtifacts = {
|
|
23
|
+
bundlePath: string;
|
|
24
|
+
sourcemapPath: string;
|
|
25
|
+
};
|
|
26
|
+
type BuildSentrySourcemapsUploadArgsOptions = {
|
|
27
|
+
sentryCliPath: string;
|
|
28
|
+
bundlePath: string;
|
|
29
|
+
sourcemapPath: string;
|
|
30
|
+
release?: string;
|
|
31
|
+
dist?: string;
|
|
32
|
+
stripPrefix?: string;
|
|
33
|
+
debugIdReference?: boolean;
|
|
34
|
+
useStandaloneSourcemapsCommand?: boolean;
|
|
35
|
+
};
|
|
36
|
+
export interface SentryUploadOptions {
|
|
37
|
+
sentryRelease?: string;
|
|
38
|
+
sentryDist?: string;
|
|
39
|
+
}
|
|
40
|
+
type SentryUploadMode = {
|
|
41
|
+
type: 'debug-id';
|
|
42
|
+
debugId: string;
|
|
43
|
+
} | {
|
|
44
|
+
type: 'release';
|
|
45
|
+
release: string;
|
|
46
|
+
dist?: string;
|
|
47
|
+
};
|
|
22
48
|
export declare function hasProjectDependency(dependencyName: string, projectRoot?: string): boolean;
|
|
23
49
|
export declare function resolveExpoCli(projectRoot?: string): ResolvedExpoCli;
|
|
24
50
|
export declare function runReactNativeBundleCommand({ bundleName, dev, entryFile, outputFolder, platform, sourcemapOutput, config, forceHermes, cli, isSentry, }: RunBundleCommandOptions): Promise<void>;
|
|
25
51
|
export declare function resolveHermesCommand(projectRoot?: string): string;
|
|
26
52
|
export declare function copyDebugidForSentry(bundleName: string, outputFolder: string, sourcemapOutput: string): Promise<void>;
|
|
27
|
-
export declare function
|
|
28
|
-
export declare function
|
|
53
|
+
export declare function prepareSentryUploadArtifacts(bundleName: string, outputFolder: string, platform: string): SentryUploadArtifacts;
|
|
54
|
+
export declare function readSourcemapDebugId(sourcemapPath: string): string | undefined;
|
|
55
|
+
export declare function resolveSentryUploadMode(sourcemapPath: string, options?: SentryUploadOptions): SentryUploadMode;
|
|
56
|
+
export declare function buildSentrySourcemapsUploadArgs({ sentryCliPath, bundlePath, sourcemapPath, release, dist, stripPrefix, debugIdReference, useStandaloneSourcemapsCommand, }: BuildSentrySourcemapsUploadArgsOptions): string[];
|
|
57
|
+
export declare function uploadSourcemapForSentry(bundleName: string, outputFolder: string, sourcemapOutput: string, platform?: string, sentryOptions?: SentryUploadOptions): Promise<void>;
|
|
29
58
|
export {};
|
package/lib/bundle-runner.js
CHANGED
|
@@ -18,12 +18,21 @@ _export(exports, {
|
|
|
18
18
|
get hasProjectDependency () {
|
|
19
19
|
return hasProjectDependency;
|
|
20
20
|
},
|
|
21
|
+
get prepareSentryUploadArtifacts () {
|
|
22
|
+
return prepareSentryUploadArtifacts;
|
|
23
|
+
},
|
|
24
|
+
get readSourcemapDebugId () {
|
|
25
|
+
return readSourcemapDebugId;
|
|
26
|
+
},
|
|
21
27
|
get resolveExpoCli () {
|
|
22
28
|
return resolveExpoCli;
|
|
23
29
|
},
|
|
24
30
|
get resolveHermesCommand () {
|
|
25
31
|
return resolveHermesCommand;
|
|
26
32
|
},
|
|
33
|
+
get resolveSentryUploadMode () {
|
|
34
|
+
return resolveSentryUploadMode;
|
|
35
|
+
},
|
|
27
36
|
get runReactNativeBundleCommand () {
|
|
28
37
|
return runReactNativeBundleCommand;
|
|
29
38
|
},
|
|
@@ -92,6 +101,7 @@ const dependencyFields = [
|
|
|
92
101
|
'peerDependencies',
|
|
93
102
|
'optionalDependencies'
|
|
94
103
|
];
|
|
104
|
+
const ANDROID_SENTRY_BUNDLE_NAME = 'index.android.bundle';
|
|
95
105
|
function hasProjectDependency(dependencyName, projectRoot = process.cwd()) {
|
|
96
106
|
try {
|
|
97
107
|
const packageJson = JSON.parse(_fsextra.readFileSync(_path.default.join(projectRoot, 'package.json'), 'utf8'));
|
|
@@ -327,6 +337,10 @@ function assertSuccessfulSyncProcess(result, command) {
|
|
|
327
337
|
throw new Error(`${command} failed with ${result.status === null ? `signal ${result.signal}` : `exit code ${result.status}`}`);
|
|
328
338
|
}
|
|
329
339
|
}
|
|
340
|
+
function normalizeString(value) {
|
|
341
|
+
const normalized = value == null ? void 0 : value.trim();
|
|
342
|
+
return normalized ? normalized : undefined;
|
|
343
|
+
}
|
|
330
344
|
function resolveHermesCommand(projectRoot = process.cwd()) {
|
|
331
345
|
const osBin = getHermesOSBin();
|
|
332
346
|
if (!osBin) {
|
|
@@ -450,20 +464,103 @@ async function copyDebugidForSentry(bundleName, outputFolder, sourcemapOutput) {
|
|
|
450
464
|
}
|
|
451
465
|
_fsextra.removeSync(_path.default.join(outputFolder, `${bundleName}.txt.map`));
|
|
452
466
|
}
|
|
453
|
-
function
|
|
467
|
+
function prepareSentryUploadArtifacts(bundleName, outputFolder, platform) {
|
|
468
|
+
const bundlePath = _path.default.join(outputFolder, bundleName);
|
|
469
|
+
const sourcemapPath = _path.default.join(outputFolder, `${bundleName}.map`);
|
|
470
|
+
if (platform !== 'android' || bundleName === ANDROID_SENTRY_BUNDLE_NAME) {
|
|
471
|
+
return {
|
|
472
|
+
bundlePath,
|
|
473
|
+
sourcemapPath
|
|
474
|
+
};
|
|
475
|
+
}
|
|
476
|
+
const androidBundlePath = _path.default.join(outputFolder, ANDROID_SENTRY_BUNDLE_NAME);
|
|
477
|
+
const androidSourcemapPath = _path.default.join(outputFolder, `${ANDROID_SENTRY_BUNDLE_NAME}.map`);
|
|
478
|
+
_fsextra.copyFileSync(bundlePath, androidBundlePath);
|
|
479
|
+
const sourcemap = JSON.parse(_fsextra.readFileSync(sourcemapPath, 'utf8'));
|
|
480
|
+
sourcemap.file = ANDROID_SENTRY_BUNDLE_NAME;
|
|
481
|
+
_fsextra.writeFileSync(androidSourcemapPath, JSON.stringify(sourcemap));
|
|
482
|
+
return {
|
|
483
|
+
bundlePath: androidBundlePath,
|
|
484
|
+
sourcemapPath: androidSourcemapPath
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
function readSourcemapDebugId(sourcemapPath) {
|
|
488
|
+
try {
|
|
489
|
+
var _sourcemap_debugId;
|
|
490
|
+
const sourcemap = JSON.parse(_fsextra.readFileSync(sourcemapPath, 'utf8'));
|
|
491
|
+
const debugId = (_sourcemap_debugId = sourcemap.debugId) != null ? _sourcemap_debugId : sourcemap.debug_id;
|
|
492
|
+
return typeof debugId === 'string' ? normalizeString(debugId) : undefined;
|
|
493
|
+
} catch (unused) {
|
|
494
|
+
return undefined;
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
function resolveSentryReleaseFromValues(releaseValue, distValue) {
|
|
498
|
+
const release = normalizeString(releaseValue);
|
|
499
|
+
if (!release) {
|
|
500
|
+
return undefined;
|
|
501
|
+
}
|
|
502
|
+
return {
|
|
503
|
+
release,
|
|
504
|
+
dist: normalizeString(distValue)
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
function resolveSentryUploadMode(sourcemapPath, options = {}) {
|
|
508
|
+
const optionRelease = resolveSentryReleaseFromValues(options.sentryRelease, options.sentryDist);
|
|
509
|
+
if (optionRelease) {
|
|
510
|
+
return {
|
|
511
|
+
type: 'release',
|
|
512
|
+
...optionRelease
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
const debugId = readSourcemapDebugId(sourcemapPath);
|
|
516
|
+
if (debugId) {
|
|
517
|
+
return {
|
|
518
|
+
type: 'debug-id',
|
|
519
|
+
debugId
|
|
520
|
+
};
|
|
521
|
+
}
|
|
522
|
+
const environmentRelease = resolveSentryReleaseFromValues(process.env.SENTRY_RELEASE, process.env.SENTRY_DIST);
|
|
523
|
+
if (environmentRelease) {
|
|
524
|
+
return {
|
|
525
|
+
type: 'release',
|
|
526
|
+
...environmentRelease
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
throw new Error('[pushy/sentry] Generated source map does not contain a Debug ID. ' + 'Add @sentry/react-native/metro to metro.config.js so the OTA bundle can be matched by Debug ID, ' + 'or set --sentry-release/--sentry-dist (or SENTRY_RELEASE/SENTRY_DIST) for legacy release matching.');
|
|
530
|
+
}
|
|
531
|
+
function buildSentrySourcemapsUploadArgs({ sentryCliPath, bundlePath, sourcemapPath, release, dist, stripPrefix = process.cwd(), debugIdReference = false, useStandaloneSourcemapsCommand = true }) {
|
|
454
532
|
const uploadArgs = [
|
|
455
533
|
'--strip-prefix',
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
534
|
+
stripPrefix,
|
|
535
|
+
bundlePath,
|
|
536
|
+
sourcemapPath
|
|
459
537
|
];
|
|
538
|
+
if (debugIdReference) {
|
|
539
|
+
if (!useStandaloneSourcemapsCommand) {
|
|
540
|
+
throw new Error('[pushy/sentry] Debug ID upload requires sentry-cli sourcemaps upload.');
|
|
541
|
+
}
|
|
542
|
+
return [
|
|
543
|
+
sentryCliPath,
|
|
544
|
+
'sourcemaps',
|
|
545
|
+
'upload',
|
|
546
|
+
'--debug-id-reference',
|
|
547
|
+
...uploadArgs
|
|
548
|
+
];
|
|
549
|
+
}
|
|
550
|
+
if (!release) {
|
|
551
|
+
throw new Error('[pushy/sentry] Legacy Sentry sourcemap upload requires a release.');
|
|
552
|
+
}
|
|
460
553
|
if (!useStandaloneSourcemapsCommand) {
|
|
461
554
|
return [
|
|
462
555
|
sentryCliPath,
|
|
463
556
|
'releases',
|
|
464
557
|
'files',
|
|
465
|
-
|
|
558
|
+
release,
|
|
466
559
|
'upload-sourcemaps',
|
|
560
|
+
...dist ? [
|
|
561
|
+
'--dist',
|
|
562
|
+
dist
|
|
563
|
+
] : [],
|
|
467
564
|
...uploadArgs
|
|
468
565
|
];
|
|
469
566
|
}
|
|
@@ -472,7 +569,11 @@ function buildSentrySourcemapsUploadArgs(sentryCliPath, bundleName, outputFolder
|
|
|
472
569
|
'sourcemaps',
|
|
473
570
|
'upload',
|
|
474
571
|
'--release',
|
|
475
|
-
|
|
572
|
+
release,
|
|
573
|
+
...dist ? [
|
|
574
|
+
'--dist',
|
|
575
|
+
dist
|
|
576
|
+
] : [],
|
|
476
577
|
...uploadArgs
|
|
477
578
|
];
|
|
478
579
|
}
|
|
@@ -487,7 +588,45 @@ function supportsStandaloneSentrySourcemapsUpload(sentryCliPath) {
|
|
|
487
588
|
});
|
|
488
589
|
return !result.error && result.status === 0;
|
|
489
590
|
}
|
|
490
|
-
|
|
591
|
+
function supportsSentryDebugIdReference(sentryCliPath) {
|
|
592
|
+
const result = (0, _runtime.spawnJavaScriptSync)([
|
|
593
|
+
sentryCliPath,
|
|
594
|
+
'sourcemaps',
|
|
595
|
+
'upload',
|
|
596
|
+
'--help'
|
|
597
|
+
], {
|
|
598
|
+
encoding: 'utf8'
|
|
599
|
+
});
|
|
600
|
+
return !result.error && result.status === 0 && typeof result.stdout === 'string' && result.stdout.includes('--debug-id-reference');
|
|
601
|
+
}
|
|
602
|
+
function runSentryCli(args) {
|
|
603
|
+
return (0, _runtime.spawnJavaScriptSync)(args, {
|
|
604
|
+
stdio: 'inherit'
|
|
605
|
+
});
|
|
606
|
+
}
|
|
607
|
+
function uploadSourcemapsWithRelease({ sentryCliPath, bundlePath, sourcemapPath, release, dist, useStandaloneSourcemapsCommand }) {
|
|
608
|
+
assertSuccessfulSyncProcess(runSentryCli([
|
|
609
|
+
sentryCliPath,
|
|
610
|
+
'releases',
|
|
611
|
+
'set-commits',
|
|
612
|
+
release,
|
|
613
|
+
'--auto'
|
|
614
|
+
]), sentryCliPath);
|
|
615
|
+
console.log((0, _i18n.t)('sentryReleaseCreated', {
|
|
616
|
+
version: release
|
|
617
|
+
}));
|
|
618
|
+
console.log((0, _i18n.t)('uploadingSourcemap'));
|
|
619
|
+
assertSuccessfulSyncProcess(runSentryCli(buildSentrySourcemapsUploadArgs({
|
|
620
|
+
sentryCliPath,
|
|
621
|
+
bundlePath,
|
|
622
|
+
sourcemapPath,
|
|
623
|
+
release,
|
|
624
|
+
dist,
|
|
625
|
+
useStandaloneSourcemapsCommand
|
|
626
|
+
})), sentryCliPath);
|
|
627
|
+
}
|
|
628
|
+
async function uploadSourcemapForSentry(bundleName, outputFolder, sourcemapOutput, platform = '', sentryOptions = {}) {
|
|
629
|
+
var _resolveSentryReleaseFromValues;
|
|
491
630
|
if (!sourcemapOutput) {
|
|
492
631
|
return;
|
|
493
632
|
}
|
|
@@ -505,20 +644,60 @@ async function uploadSourcemapForSentry(bundleName, outputFolder, sourcemapOutpu
|
|
|
505
644
|
if (!_fsextra.existsSync(sentryCliPath)) {
|
|
506
645
|
return;
|
|
507
646
|
}
|
|
508
|
-
|
|
647
|
+
const { bundlePath, sourcemapPath } = prepareSentryUploadArtifacts(bundleName, outputFolder, platform);
|
|
648
|
+
const uploadMode = resolveSentryUploadMode(sourcemapPath, sentryOptions);
|
|
649
|
+
const useStandaloneSourcemapsCommand = supportsStandaloneSentrySourcemapsUpload(sentryCliPath);
|
|
650
|
+
if (uploadMode.type === 'release') {
|
|
651
|
+
uploadSourcemapsWithRelease({
|
|
652
|
+
sentryCliPath,
|
|
653
|
+
bundlePath,
|
|
654
|
+
sourcemapPath,
|
|
655
|
+
release: uploadMode.release,
|
|
656
|
+
dist: uploadMode.dist,
|
|
657
|
+
useStandaloneSourcemapsCommand
|
|
658
|
+
});
|
|
659
|
+
return;
|
|
660
|
+
}
|
|
661
|
+
console.log((0, _i18n.t)('uploadingSourcemap'));
|
|
662
|
+
if (!useStandaloneSourcemapsCommand || !supportsSentryDebugIdReference(sentryCliPath)) {
|
|
663
|
+
var _resolveSentryReleaseFromValues1;
|
|
664
|
+
const explicitRelease = (_resolveSentryReleaseFromValues1 = resolveSentryReleaseFromValues(sentryOptions.sentryRelease, sentryOptions.sentryDist)) != null ? _resolveSentryReleaseFromValues1 : resolveSentryReleaseFromValues(process.env.SENTRY_RELEASE, process.env.SENTRY_DIST);
|
|
665
|
+
if (!explicitRelease) {
|
|
666
|
+
throw new Error('[pushy/sentry] sentry-cli does not support Debug ID source map upload. ' + 'Upgrade @sentry/cli, or set --sentry-release/--sentry-dist for legacy release matching.');
|
|
667
|
+
}
|
|
668
|
+
uploadSourcemapsWithRelease({
|
|
669
|
+
sentryCliPath,
|
|
670
|
+
bundlePath,
|
|
671
|
+
sourcemapPath,
|
|
672
|
+
release: explicitRelease.release,
|
|
673
|
+
dist: explicitRelease.dist,
|
|
674
|
+
useStandaloneSourcemapsCommand
|
|
675
|
+
});
|
|
676
|
+
return;
|
|
677
|
+
}
|
|
678
|
+
console.log(`[pushy/sentry] Using source map Debug ID: ${uploadMode.debugId}`);
|
|
679
|
+
const debugIdResult = runSentryCli(buildSentrySourcemapsUploadArgs({
|
|
509
680
|
sentryCliPath,
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
], {
|
|
515
|
-
stdio: 'inherit'
|
|
516
|
-
}), sentryCliPath);
|
|
517
|
-
console.log((0, _i18n.t)('sentryReleaseCreated', {
|
|
518
|
-
version
|
|
681
|
+
bundlePath,
|
|
682
|
+
sourcemapPath,
|
|
683
|
+
debugIdReference: true,
|
|
684
|
+
useStandaloneSourcemapsCommand
|
|
519
685
|
}));
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
686
|
+
if (debugIdResult.status === 0 && !debugIdResult.error) {
|
|
687
|
+
return;
|
|
688
|
+
}
|
|
689
|
+
const explicitRelease = (_resolveSentryReleaseFromValues = resolveSentryReleaseFromValues(sentryOptions.sentryRelease, sentryOptions.sentryDist)) != null ? _resolveSentryReleaseFromValues : resolveSentryReleaseFromValues(process.env.SENTRY_RELEASE, process.env.SENTRY_DIST);
|
|
690
|
+
if (!explicitRelease) {
|
|
691
|
+
assertSuccessfulSyncProcess(debugIdResult, sentryCliPath);
|
|
692
|
+
return;
|
|
693
|
+
}
|
|
694
|
+
console.warn('[pushy/sentry] Debug ID source map upload failed; falling back to explicit release/dist upload.');
|
|
695
|
+
uploadSourcemapsWithRelease({
|
|
696
|
+
sentryCliPath,
|
|
697
|
+
bundlePath,
|
|
698
|
+
sourcemapPath,
|
|
699
|
+
release: explicitRelease.release,
|
|
700
|
+
dist: explicitRelease.dist,
|
|
701
|
+
useStandaloneSourcemapsCommand
|
|
702
|
+
});
|
|
524
703
|
}
|
package/lib/bundle.js
CHANGED
|
@@ -25,6 +25,10 @@ function _interop_require_default(obj) {
|
|
|
25
25
|
default: obj
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
+
function getAliasedOptionalStringOption(options, key, alias) {
|
|
29
|
+
var _getOptionalStringOption;
|
|
30
|
+
return (_getOptionalStringOption = (0, _options.getOptionalStringOption)(options, key)) != null ? _getOptionalStringOption : (0, _options.getOptionalStringOption)(options, alias);
|
|
31
|
+
}
|
|
28
32
|
function normalizeBundleOptions(translatedOptions, platform) {
|
|
29
33
|
return {
|
|
30
34
|
bundleName: (0, _options.getStringOption)(translatedOptions, 'bundleName', 'index.bundlejs'),
|
|
@@ -46,15 +50,17 @@ function normalizeBundleOptions(translatedOptions, platform) {
|
|
|
46
50
|
maxPackageVersion: (0, _options.getOptionalStringOption)(translatedOptions, 'maxPackageVersion'),
|
|
47
51
|
packageVersionRange: (0, _options.getOptionalStringOption)(translatedOptions, 'packageVersionRange'),
|
|
48
52
|
rollout: (0, _options.getOptionalStringOption)(translatedOptions, 'rollout'),
|
|
49
|
-
dryRun: (0, _options.getBooleanOption)(translatedOptions, 'dryRun', false)
|
|
53
|
+
dryRun: (0, _options.getBooleanOption)(translatedOptions, 'dryRun', false),
|
|
54
|
+
sentryRelease: getAliasedOptionalStringOption(translatedOptions, 'sentry-release', 'sentryRelease'),
|
|
55
|
+
sentryDist: getAliasedOptionalStringOption(translatedOptions, 'sentry-dist', 'sentryDist')
|
|
50
56
|
};
|
|
51
57
|
}
|
|
52
|
-
async function uploadSentryArtifactsIfNeeded(shouldUpload, bundleName, intermediaDir, sourcemapOutput,
|
|
58
|
+
async function uploadSentryArtifactsIfNeeded(shouldUpload, bundleName, intermediaDir, sourcemapOutput, platform, sentryOptions) {
|
|
53
59
|
if (!shouldUpload) {
|
|
54
60
|
return;
|
|
55
61
|
}
|
|
56
62
|
await (0, _bundlerunner.copyDebugidForSentry)(bundleName, intermediaDir, sourcemapOutput);
|
|
57
|
-
await (0, _bundlerunner.uploadSourcemapForSentry)(bundleName, intermediaDir, sourcemapOutput,
|
|
63
|
+
await (0, _bundlerunner.uploadSourcemapForSentry)(bundleName, intermediaDir, sourcemapOutput, platform, sentryOptions);
|
|
58
64
|
}
|
|
59
65
|
async function publishBundleVersion(outputPath, platform, payload) {
|
|
60
66
|
return _versions.versionCommands.publish({
|
|
@@ -102,7 +108,7 @@ const bundleCommands = {
|
|
|
102
108
|
});
|
|
103
109
|
await (0, _bundlepack.packBundle)(_path.default.resolve(normalized.intermediaDir), realOutput);
|
|
104
110
|
if (normalized.name) {
|
|
105
|
-
|
|
111
|
+
await publishBundleVersion(realOutput, platform, {
|
|
106
112
|
name: normalized.name,
|
|
107
113
|
description: normalized.description,
|
|
108
114
|
metaInfo: normalized.metaInfo,
|
|
@@ -114,14 +120,20 @@ const bundleCommands = {
|
|
|
114
120
|
rollout: normalized.rollout,
|
|
115
121
|
dryRun: normalized.dryRun
|
|
116
122
|
});
|
|
117
|
-
await uploadSentryArtifactsIfNeeded(bundleParams.sentry, normalized.bundleName, normalized.intermediaDir, sourcemapOutput,
|
|
123
|
+
await uploadSentryArtifactsIfNeeded(bundleParams.sentry, normalized.bundleName, normalized.intermediaDir, sourcemapOutput, platform, {
|
|
124
|
+
sentryRelease: normalized.sentryRelease,
|
|
125
|
+
sentryDist: normalized.sentryDist
|
|
126
|
+
});
|
|
118
127
|
return;
|
|
119
128
|
}
|
|
120
129
|
if (!(0, _options.getBooleanOption)(options, 'no-interactive', false)) {
|
|
121
130
|
const v = await (0, _utils.question)((0, _i18n.t)('uploadBundlePrompt'));
|
|
122
131
|
if (v.toLowerCase() === 'y') {
|
|
123
|
-
|
|
124
|
-
await uploadSentryArtifactsIfNeeded(bundleParams.sentry, normalized.bundleName, normalized.intermediaDir, sourcemapOutput,
|
|
132
|
+
await publishBundleVersion(realOutput, platform, {});
|
|
133
|
+
await uploadSentryArtifactsIfNeeded(bundleParams.sentry, normalized.bundleName, normalized.intermediaDir, sourcemapOutput, platform, {
|
|
134
|
+
sentryRelease: normalized.sentryRelease,
|
|
135
|
+
sentryDist: normalized.sentryDist
|
|
136
|
+
});
|
|
125
137
|
}
|
|
126
138
|
}
|
|
127
139
|
}
|
package/lib/provider.js
CHANGED
|
@@ -105,7 +105,9 @@ class CLIProviderImpl {
|
|
|
105
105
|
taro: options.taro || false,
|
|
106
106
|
expo: options.expo || false,
|
|
107
107
|
rncli: options.rncli || false,
|
|
108
|
-
hermes: options.hermes || false
|
|
108
|
+
hermes: options.hermes || false,
|
|
109
|
+
sentryRelease: options.sentryRelease,
|
|
110
|
+
sentryDist: options.sentryDist
|
|
109
111
|
});
|
|
110
112
|
const { bundleCommands } = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./bundle")));
|
|
111
113
|
await bundleCommands.bundle(context);
|
package/lib/types.d.ts
CHANGED
package/lib/utils/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { checkPlugins } from './check-plugin';
|
|
2
2
|
export declare function isNonInteractive(): boolean;
|
|
3
3
|
export declare function question(query: string, password?: boolean): Promise<string>;
|
|
4
|
-
export declare function translateOptions<T extends Record<string, unknown>>(options: T): T & Record<string, unknown>;
|
|
4
|
+
export declare function translateOptions<T extends Record<string, unknown>>(options: T, map?: Record<string, string>): T & Record<string, unknown>;
|
|
5
5
|
export declare function getApkInfo(fn: string): Promise<{
|
|
6
6
|
versionName: string;
|
|
7
7
|
buildTime: number;
|
package/lib/utils/index.js
CHANGED
|
@@ -69,24 +69,37 @@ async function question(query, password) {
|
|
|
69
69
|
replace: password ? '*' : undefined
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
|
-
function translateOptions(options) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
72
|
+
function translateOptions(options, map) {
|
|
73
|
+
if (!map) {
|
|
74
|
+
// Existing logic for template replacement if no map is provided
|
|
75
|
+
const ret = {};
|
|
76
|
+
for(const key in options){
|
|
77
|
+
const value = options[key];
|
|
78
|
+
if (typeof value === 'string') {
|
|
79
|
+
ret[key] = value.replace(/\$\{(\w+)\}/g, (placeholder, name)=>{
|
|
80
|
+
var _options_name;
|
|
81
|
+
const replacement = (_options_name = options[name]) != null ? _options_name : process.env[name];
|
|
82
|
+
if (typeof replacement === 'string' || typeof replacement === 'number' || typeof replacement === 'boolean') {
|
|
83
|
+
return String(replacement);
|
|
84
|
+
}
|
|
85
|
+
return placeholder;
|
|
86
|
+
});
|
|
87
|
+
} else {
|
|
88
|
+
ret[key] = value;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return ret;
|
|
92
|
+
}
|
|
93
|
+
const result = {
|
|
94
|
+
...options
|
|
95
|
+
};
|
|
96
|
+
for (const [key, value] of Object.entries(map)){
|
|
97
|
+
if (result[key] !== undefined) {
|
|
98
|
+
result[value] = result[key];
|
|
99
|
+
delete result[key];
|
|
87
100
|
}
|
|
88
101
|
}
|
|
89
|
-
return
|
|
102
|
+
return result;
|
|
90
103
|
}
|
|
91
104
|
async function getApkInfo(fn) {
|
|
92
105
|
const appInfoParser = new _appinfoparser.default(fn);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-update-cli",
|
|
3
|
-
"version": "2.15.
|
|
3
|
+
"version": "2.15.2",
|
|
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",
|
|
@@ -91,8 +91,8 @@
|
|
|
91
91
|
},
|
|
92
92
|
"devDependencies": {
|
|
93
93
|
"@biomejs/biome": "^2.4.12",
|
|
94
|
-
"@swc/cli": "0.8.1",
|
|
95
|
-
"@swc/core": "^1.15.
|
|
94
|
+
"@swc/cli": "^0.8.1",
|
|
95
|
+
"@swc/core": "^1.15.41",
|
|
96
96
|
"@types/bun": "^1.3.12",
|
|
97
97
|
"@types/filesize-parser": "^1.5.3",
|
|
98
98
|
"@types/fs-extra": "^11.0.4",
|
package/src/bundle-runner.ts
CHANGED
|
@@ -55,6 +55,40 @@ type ResolvedExpoCli = {
|
|
|
55
55
|
usingExpo: boolean;
|
|
56
56
|
};
|
|
57
57
|
|
|
58
|
+
type SentryUploadArtifacts = {
|
|
59
|
+
bundlePath: string;
|
|
60
|
+
sourcemapPath: string;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
type BuildSentrySourcemapsUploadArgsOptions = {
|
|
64
|
+
sentryCliPath: string;
|
|
65
|
+
bundlePath: string;
|
|
66
|
+
sourcemapPath: string;
|
|
67
|
+
release?: string;
|
|
68
|
+
dist?: string;
|
|
69
|
+
stripPrefix?: string;
|
|
70
|
+
debugIdReference?: boolean;
|
|
71
|
+
useStandaloneSourcemapsCommand?: boolean;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const ANDROID_SENTRY_BUNDLE_NAME = 'index.android.bundle';
|
|
75
|
+
|
|
76
|
+
export interface SentryUploadOptions {
|
|
77
|
+
sentryRelease?: string;
|
|
78
|
+
sentryDist?: string;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
type SentryUploadMode =
|
|
82
|
+
| {
|
|
83
|
+
type: 'debug-id';
|
|
84
|
+
debugId: string;
|
|
85
|
+
}
|
|
86
|
+
| {
|
|
87
|
+
type: 'release';
|
|
88
|
+
release: string;
|
|
89
|
+
dist?: string;
|
|
90
|
+
};
|
|
91
|
+
|
|
58
92
|
export function hasProjectDependency(
|
|
59
93
|
dependencyName: string,
|
|
60
94
|
projectRoot = process.cwd(),
|
|
@@ -376,6 +410,11 @@ function assertSuccessfulSyncProcess(
|
|
|
376
410
|
}
|
|
377
411
|
}
|
|
378
412
|
|
|
413
|
+
function normalizeString(value: string | undefined): string | undefined {
|
|
414
|
+
const normalized = value?.trim();
|
|
415
|
+
return normalized ? normalized : undefined;
|
|
416
|
+
}
|
|
417
|
+
|
|
379
418
|
export function resolveHermesCommand(projectRoot = process.cwd()): string {
|
|
380
419
|
const osBin = getHermesOSBin();
|
|
381
420
|
if (!osBin) {
|
|
@@ -557,27 +596,150 @@ export async function copyDebugidForSentry(
|
|
|
557
596
|
fs.removeSync(path.join(outputFolder, `${bundleName}.txt.map`));
|
|
558
597
|
}
|
|
559
598
|
|
|
560
|
-
export function
|
|
561
|
-
sentryCliPath: string,
|
|
599
|
+
export function prepareSentryUploadArtifacts(
|
|
562
600
|
bundleName: string,
|
|
563
601
|
outputFolder: string,
|
|
564
|
-
|
|
602
|
+
platform: string,
|
|
603
|
+
): SentryUploadArtifacts {
|
|
604
|
+
const bundlePath = path.join(outputFolder, bundleName);
|
|
605
|
+
const sourcemapPath = path.join(outputFolder, `${bundleName}.map`);
|
|
606
|
+
|
|
607
|
+
if (platform !== 'android' || bundleName === ANDROID_SENTRY_BUNDLE_NAME) {
|
|
608
|
+
return {
|
|
609
|
+
bundlePath,
|
|
610
|
+
sourcemapPath,
|
|
611
|
+
};
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
const androidBundlePath = path.join(outputFolder, ANDROID_SENTRY_BUNDLE_NAME);
|
|
615
|
+
const androidSourcemapPath = path.join(
|
|
616
|
+
outputFolder,
|
|
617
|
+
`${ANDROID_SENTRY_BUNDLE_NAME}.map`,
|
|
618
|
+
);
|
|
619
|
+
fs.copyFileSync(bundlePath, androidBundlePath);
|
|
620
|
+
|
|
621
|
+
const sourcemap = JSON.parse(
|
|
622
|
+
fs.readFileSync(sourcemapPath, 'utf8'),
|
|
623
|
+
) as Record<string, unknown>;
|
|
624
|
+
sourcemap.file = ANDROID_SENTRY_BUNDLE_NAME;
|
|
625
|
+
fs.writeFileSync(androidSourcemapPath, JSON.stringify(sourcemap));
|
|
626
|
+
|
|
627
|
+
return {
|
|
628
|
+
bundlePath: androidBundlePath,
|
|
629
|
+
sourcemapPath: androidSourcemapPath,
|
|
630
|
+
};
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
export function readSourcemapDebugId(
|
|
634
|
+
sourcemapPath: string,
|
|
635
|
+
): string | undefined {
|
|
636
|
+
try {
|
|
637
|
+
const sourcemap = JSON.parse(
|
|
638
|
+
fs.readFileSync(sourcemapPath, 'utf8'),
|
|
639
|
+
) as Record<string, unknown>;
|
|
640
|
+
const debugId = sourcemap.debugId ?? sourcemap.debug_id;
|
|
641
|
+
return typeof debugId === 'string' ? normalizeString(debugId) : undefined;
|
|
642
|
+
} catch {
|
|
643
|
+
return undefined;
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
function resolveSentryReleaseFromValues(
|
|
648
|
+
releaseValue: string | undefined,
|
|
649
|
+
distValue: string | undefined,
|
|
650
|
+
): { release: string; dist?: string } | undefined {
|
|
651
|
+
const release = normalizeString(releaseValue);
|
|
652
|
+
if (!release) {
|
|
653
|
+
return undefined;
|
|
654
|
+
}
|
|
655
|
+
return {
|
|
656
|
+
release,
|
|
657
|
+
dist: normalizeString(distValue),
|
|
658
|
+
};
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
export function resolveSentryUploadMode(
|
|
662
|
+
sourcemapPath: string,
|
|
663
|
+
options: SentryUploadOptions = {},
|
|
664
|
+
): SentryUploadMode {
|
|
665
|
+
const optionRelease = resolveSentryReleaseFromValues(
|
|
666
|
+
options.sentryRelease,
|
|
667
|
+
options.sentryDist,
|
|
668
|
+
);
|
|
669
|
+
if (optionRelease) {
|
|
670
|
+
return {
|
|
671
|
+
type: 'release',
|
|
672
|
+
...optionRelease,
|
|
673
|
+
};
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
const debugId = readSourcemapDebugId(sourcemapPath);
|
|
677
|
+
if (debugId) {
|
|
678
|
+
return {
|
|
679
|
+
type: 'debug-id',
|
|
680
|
+
debugId,
|
|
681
|
+
};
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
const environmentRelease = resolveSentryReleaseFromValues(
|
|
685
|
+
process.env.SENTRY_RELEASE,
|
|
686
|
+
process.env.SENTRY_DIST,
|
|
687
|
+
);
|
|
688
|
+
if (environmentRelease) {
|
|
689
|
+
return {
|
|
690
|
+
type: 'release',
|
|
691
|
+
...environmentRelease,
|
|
692
|
+
};
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
throw new Error(
|
|
696
|
+
'[pushy/sentry] Generated source map does not contain a Debug ID. ' +
|
|
697
|
+
'Add @sentry/react-native/metro to metro.config.js so the OTA bundle can be matched by Debug ID, ' +
|
|
698
|
+
'or set --sentry-release/--sentry-dist (or SENTRY_RELEASE/SENTRY_DIST) for legacy release matching.',
|
|
699
|
+
);
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
export function buildSentrySourcemapsUploadArgs({
|
|
703
|
+
sentryCliPath,
|
|
704
|
+
bundlePath,
|
|
705
|
+
sourcemapPath,
|
|
706
|
+
release,
|
|
707
|
+
dist,
|
|
708
|
+
stripPrefix = process.cwd(),
|
|
709
|
+
debugIdReference = false,
|
|
565
710
|
useStandaloneSourcemapsCommand = true,
|
|
566
|
-
): string[] {
|
|
567
|
-
const uploadArgs = [
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
711
|
+
}: BuildSentrySourcemapsUploadArgsOptions): string[] {
|
|
712
|
+
const uploadArgs = ['--strip-prefix', stripPrefix, bundlePath, sourcemapPath];
|
|
713
|
+
|
|
714
|
+
if (debugIdReference) {
|
|
715
|
+
if (!useStandaloneSourcemapsCommand) {
|
|
716
|
+
throw new Error(
|
|
717
|
+
'[pushy/sentry] Debug ID upload requires sentry-cli sourcemaps upload.',
|
|
718
|
+
);
|
|
719
|
+
}
|
|
720
|
+
return [
|
|
721
|
+
sentryCliPath,
|
|
722
|
+
'sourcemaps',
|
|
723
|
+
'upload',
|
|
724
|
+
'--debug-id-reference',
|
|
725
|
+
...uploadArgs,
|
|
726
|
+
];
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
if (!release) {
|
|
730
|
+
throw new Error(
|
|
731
|
+
'[pushy/sentry] Legacy Sentry sourcemap upload requires a release.',
|
|
732
|
+
);
|
|
733
|
+
}
|
|
573
734
|
|
|
574
735
|
if (!useStandaloneSourcemapsCommand) {
|
|
575
736
|
return [
|
|
576
737
|
sentryCliPath,
|
|
577
738
|
'releases',
|
|
578
739
|
'files',
|
|
579
|
-
|
|
740
|
+
release,
|
|
580
741
|
'upload-sourcemaps',
|
|
742
|
+
...(dist ? ['--dist', dist] : []),
|
|
581
743
|
...uploadArgs,
|
|
582
744
|
];
|
|
583
745
|
}
|
|
@@ -587,7 +749,8 @@ export function buildSentrySourcemapsUploadArgs(
|
|
|
587
749
|
'sourcemaps',
|
|
588
750
|
'upload',
|
|
589
751
|
'--release',
|
|
590
|
-
|
|
752
|
+
release,
|
|
753
|
+
...(dist ? ['--dist', dist] : []),
|
|
591
754
|
...uploadArgs,
|
|
592
755
|
];
|
|
593
756
|
}
|
|
@@ -602,11 +765,70 @@ function supportsStandaloneSentrySourcemapsUpload(sentryCliPath: string) {
|
|
|
602
765
|
return !result.error && result.status === 0;
|
|
603
766
|
}
|
|
604
767
|
|
|
768
|
+
function supportsSentryDebugIdReference(sentryCliPath: string) {
|
|
769
|
+
const result = spawnJavaScriptSync(
|
|
770
|
+
[sentryCliPath, 'sourcemaps', 'upload', '--help'],
|
|
771
|
+
{
|
|
772
|
+
encoding: 'utf8',
|
|
773
|
+
},
|
|
774
|
+
);
|
|
775
|
+
return (
|
|
776
|
+
!result.error &&
|
|
777
|
+
result.status === 0 &&
|
|
778
|
+
typeof result.stdout === 'string' &&
|
|
779
|
+
result.stdout.includes('--debug-id-reference')
|
|
780
|
+
);
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
function runSentryCli(args: string[]): SyncProcessResult {
|
|
784
|
+
return spawnJavaScriptSync(args, {
|
|
785
|
+
stdio: 'inherit',
|
|
786
|
+
});
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
function uploadSourcemapsWithRelease({
|
|
790
|
+
sentryCliPath,
|
|
791
|
+
bundlePath,
|
|
792
|
+
sourcemapPath,
|
|
793
|
+
release,
|
|
794
|
+
dist,
|
|
795
|
+
useStandaloneSourcemapsCommand,
|
|
796
|
+
}: {
|
|
797
|
+
sentryCliPath: string;
|
|
798
|
+
bundlePath: string;
|
|
799
|
+
sourcemapPath: string;
|
|
800
|
+
release: string;
|
|
801
|
+
dist?: string;
|
|
802
|
+
useStandaloneSourcemapsCommand: boolean;
|
|
803
|
+
}): void {
|
|
804
|
+
assertSuccessfulSyncProcess(
|
|
805
|
+
runSentryCli([sentryCliPath, 'releases', 'set-commits', release, '--auto']),
|
|
806
|
+
sentryCliPath,
|
|
807
|
+
);
|
|
808
|
+
console.log(t('sentryReleaseCreated', { version: release }));
|
|
809
|
+
|
|
810
|
+
console.log(t('uploadingSourcemap'));
|
|
811
|
+
assertSuccessfulSyncProcess(
|
|
812
|
+
runSentryCli(
|
|
813
|
+
buildSentrySourcemapsUploadArgs({
|
|
814
|
+
sentryCliPath,
|
|
815
|
+
bundlePath,
|
|
816
|
+
sourcemapPath,
|
|
817
|
+
release,
|
|
818
|
+
dist,
|
|
819
|
+
useStandaloneSourcemapsCommand,
|
|
820
|
+
}),
|
|
821
|
+
),
|
|
822
|
+
sentryCliPath,
|
|
823
|
+
);
|
|
824
|
+
}
|
|
825
|
+
|
|
605
826
|
export async function uploadSourcemapForSentry(
|
|
606
827
|
bundleName: string,
|
|
607
828
|
outputFolder: string,
|
|
608
829
|
sourcemapOutput: string,
|
|
609
|
-
|
|
830
|
+
platform = '',
|
|
831
|
+
sentryOptions: SentryUploadOptions = {},
|
|
610
832
|
): Promise<void> {
|
|
611
833
|
if (!sourcemapOutput) {
|
|
612
834
|
return;
|
|
@@ -626,31 +848,98 @@ export async function uploadSourcemapForSentry(
|
|
|
626
848
|
return;
|
|
627
849
|
}
|
|
628
850
|
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
stdio: 'inherit',
|
|
634
|
-
},
|
|
635
|
-
),
|
|
636
|
-
sentryCliPath,
|
|
851
|
+
const { bundlePath, sourcemapPath } = prepareSentryUploadArtifacts(
|
|
852
|
+
bundleName,
|
|
853
|
+
outputFolder,
|
|
854
|
+
platform,
|
|
637
855
|
);
|
|
638
|
-
|
|
856
|
+
const uploadMode = resolveSentryUploadMode(sourcemapPath, sentryOptions);
|
|
857
|
+
const useStandaloneSourcemapsCommand =
|
|
858
|
+
supportsStandaloneSentrySourcemapsUpload(sentryCliPath);
|
|
859
|
+
|
|
860
|
+
if (uploadMode.type === 'release') {
|
|
861
|
+
uploadSourcemapsWithRelease({
|
|
862
|
+
sentryCliPath,
|
|
863
|
+
bundlePath,
|
|
864
|
+
sourcemapPath,
|
|
865
|
+
release: uploadMode.release,
|
|
866
|
+
dist: uploadMode.dist,
|
|
867
|
+
useStandaloneSourcemapsCommand,
|
|
868
|
+
});
|
|
869
|
+
return;
|
|
870
|
+
}
|
|
639
871
|
|
|
640
872
|
console.log(t('uploadingSourcemap'));
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
)
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
873
|
+
if (
|
|
874
|
+
!useStandaloneSourcemapsCommand ||
|
|
875
|
+
!supportsSentryDebugIdReference(sentryCliPath)
|
|
876
|
+
) {
|
|
877
|
+
const explicitRelease =
|
|
878
|
+
resolveSentryReleaseFromValues(
|
|
879
|
+
sentryOptions.sentryRelease,
|
|
880
|
+
sentryOptions.sentryDist,
|
|
881
|
+
) ??
|
|
882
|
+
resolveSentryReleaseFromValues(
|
|
883
|
+
process.env.SENTRY_RELEASE,
|
|
884
|
+
process.env.SENTRY_DIST,
|
|
885
|
+
);
|
|
886
|
+
if (!explicitRelease) {
|
|
887
|
+
throw new Error(
|
|
888
|
+
'[pushy/sentry] sentry-cli does not support Debug ID source map upload. ' +
|
|
889
|
+
'Upgrade @sentry/cli, or set --sentry-release/--sentry-dist for legacy release matching.',
|
|
890
|
+
);
|
|
891
|
+
}
|
|
892
|
+
uploadSourcemapsWithRelease({
|
|
893
|
+
sentryCliPath,
|
|
894
|
+
bundlePath,
|
|
895
|
+
sourcemapPath,
|
|
896
|
+
release: explicitRelease.release,
|
|
897
|
+
dist: explicitRelease.dist,
|
|
898
|
+
useStandaloneSourcemapsCommand,
|
|
899
|
+
});
|
|
900
|
+
return;
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
console.log(
|
|
904
|
+
`[pushy/sentry] Using source map Debug ID: ${uploadMode.debugId}`,
|
|
905
|
+
);
|
|
906
|
+
const debugIdResult = runSentryCli(
|
|
907
|
+
buildSentrySourcemapsUploadArgs({
|
|
908
|
+
sentryCliPath,
|
|
909
|
+
bundlePath,
|
|
910
|
+
sourcemapPath,
|
|
911
|
+
debugIdReference: true,
|
|
912
|
+
useStandaloneSourcemapsCommand,
|
|
913
|
+
}),
|
|
914
|
+
);
|
|
915
|
+
|
|
916
|
+
if (debugIdResult.status === 0 && !debugIdResult.error) {
|
|
917
|
+
return;
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
const explicitRelease =
|
|
921
|
+
resolveSentryReleaseFromValues(
|
|
922
|
+
sentryOptions.sentryRelease,
|
|
923
|
+
sentryOptions.sentryDist,
|
|
924
|
+
) ??
|
|
925
|
+
resolveSentryReleaseFromValues(
|
|
926
|
+
process.env.SENTRY_RELEASE,
|
|
927
|
+
process.env.SENTRY_DIST,
|
|
928
|
+
);
|
|
929
|
+
if (!explicitRelease) {
|
|
930
|
+
assertSuccessfulSyncProcess(debugIdResult, sentryCliPath);
|
|
931
|
+
return;
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
console.warn(
|
|
935
|
+
'[pushy/sentry] Debug ID source map upload failed; falling back to explicit release/dist upload.',
|
|
655
936
|
);
|
|
937
|
+
uploadSourcemapsWithRelease({
|
|
938
|
+
sentryCliPath,
|
|
939
|
+
bundlePath,
|
|
940
|
+
sourcemapPath,
|
|
941
|
+
release: explicitRelease.release,
|
|
942
|
+
dist: explicitRelease.dist,
|
|
943
|
+
useStandaloneSourcemapsCommand,
|
|
944
|
+
});
|
|
656
945
|
}
|
package/src/bundle.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { packBundle } from './bundle-pack';
|
|
|
4
4
|
import {
|
|
5
5
|
copyDebugidForSentry,
|
|
6
6
|
runReactNativeBundleCommand,
|
|
7
|
+
type SentryUploadOptions,
|
|
7
8
|
uploadSourcemapForSentry,
|
|
8
9
|
} from './bundle-runner';
|
|
9
10
|
import type { Platform } from './types';
|
|
@@ -41,6 +42,8 @@ type NormalizedBundleOptions = {
|
|
|
41
42
|
packageVersionRange?: string;
|
|
42
43
|
rollout?: string;
|
|
43
44
|
dryRun: boolean;
|
|
45
|
+
sentryRelease?: string;
|
|
46
|
+
sentryDist?: string;
|
|
44
47
|
};
|
|
45
48
|
|
|
46
49
|
type PublishBundlePayload = {
|
|
@@ -56,6 +59,17 @@ type PublishBundlePayload = {
|
|
|
56
59
|
dryRun?: boolean;
|
|
57
60
|
};
|
|
58
61
|
|
|
62
|
+
function getAliasedOptionalStringOption(
|
|
63
|
+
options: Record<string, unknown>,
|
|
64
|
+
key: string,
|
|
65
|
+
alias: string,
|
|
66
|
+
): string | undefined {
|
|
67
|
+
return (
|
|
68
|
+
getOptionalStringOption(options, key) ??
|
|
69
|
+
getOptionalStringOption(options, alias)
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
59
73
|
function normalizeBundleOptions(
|
|
60
74
|
translatedOptions: Record<string, unknown>,
|
|
61
75
|
platform: string,
|
|
@@ -105,6 +119,16 @@ function normalizeBundleOptions(
|
|
|
105
119
|
),
|
|
106
120
|
rollout: getOptionalStringOption(translatedOptions, 'rollout'),
|
|
107
121
|
dryRun: getBooleanOption(translatedOptions, 'dryRun', false),
|
|
122
|
+
sentryRelease: getAliasedOptionalStringOption(
|
|
123
|
+
translatedOptions,
|
|
124
|
+
'sentry-release',
|
|
125
|
+
'sentryRelease',
|
|
126
|
+
),
|
|
127
|
+
sentryDist: getAliasedOptionalStringOption(
|
|
128
|
+
translatedOptions,
|
|
129
|
+
'sentry-dist',
|
|
130
|
+
'sentryDist',
|
|
131
|
+
),
|
|
108
132
|
};
|
|
109
133
|
}
|
|
110
134
|
|
|
@@ -113,7 +137,8 @@ async function uploadSentryArtifactsIfNeeded(
|
|
|
113
137
|
bundleName: string,
|
|
114
138
|
intermediaDir: string,
|
|
115
139
|
sourcemapOutput: string,
|
|
116
|
-
|
|
140
|
+
platform: Platform,
|
|
141
|
+
sentryOptions: SentryUploadOptions,
|
|
117
142
|
): Promise<void> {
|
|
118
143
|
if (!shouldUpload) {
|
|
119
144
|
return;
|
|
@@ -124,7 +149,8 @@ async function uploadSentryArtifactsIfNeeded(
|
|
|
124
149
|
bundleName,
|
|
125
150
|
intermediaDir,
|
|
126
151
|
sourcemapOutput,
|
|
127
|
-
|
|
152
|
+
platform,
|
|
153
|
+
sentryOptions,
|
|
128
154
|
);
|
|
129
155
|
}
|
|
130
156
|
|
|
@@ -199,7 +225,7 @@ export const bundleCommands = {
|
|
|
199
225
|
await packBundle(path.resolve(normalized.intermediaDir), realOutput);
|
|
200
226
|
|
|
201
227
|
if (normalized.name) {
|
|
202
|
-
|
|
228
|
+
await publishBundleVersion(realOutput, platform, {
|
|
203
229
|
name: normalized.name,
|
|
204
230
|
description: normalized.description,
|
|
205
231
|
metaInfo: normalized.metaInfo,
|
|
@@ -216,7 +242,11 @@ export const bundleCommands = {
|
|
|
216
242
|
normalized.bundleName,
|
|
217
243
|
normalized.intermediaDir,
|
|
218
244
|
sourcemapOutput,
|
|
219
|
-
|
|
245
|
+
platform,
|
|
246
|
+
{
|
|
247
|
+
sentryRelease: normalized.sentryRelease,
|
|
248
|
+
sentryDist: normalized.sentryDist,
|
|
249
|
+
},
|
|
220
250
|
);
|
|
221
251
|
return;
|
|
222
252
|
}
|
|
@@ -224,17 +254,17 @@ export const bundleCommands = {
|
|
|
224
254
|
if (!getBooleanOption(options, 'no-interactive', false)) {
|
|
225
255
|
const v = await question(t('uploadBundlePrompt'));
|
|
226
256
|
if (v.toLowerCase() === 'y') {
|
|
227
|
-
|
|
228
|
-
realOutput,
|
|
229
|
-
platform,
|
|
230
|
-
{},
|
|
231
|
-
);
|
|
257
|
+
await publishBundleVersion(realOutput, platform, {});
|
|
232
258
|
await uploadSentryArtifactsIfNeeded(
|
|
233
259
|
bundleParams.sentry,
|
|
234
260
|
normalized.bundleName,
|
|
235
261
|
normalized.intermediaDir,
|
|
236
262
|
sourcemapOutput,
|
|
237
|
-
|
|
263
|
+
platform,
|
|
264
|
+
{
|
|
265
|
+
sentryRelease: normalized.sentryRelease,
|
|
266
|
+
sentryDist: normalized.sentryDist,
|
|
267
|
+
},
|
|
238
268
|
);
|
|
239
269
|
}
|
|
240
270
|
}
|
package/src/diff.ts
CHANGED
package/src/provider.ts
CHANGED
|
@@ -90,6 +90,8 @@ export class CLIProviderImpl implements CLIProvider {
|
|
|
90
90
|
expo: options.expo || false,
|
|
91
91
|
rncli: options.rncli || false,
|
|
92
92
|
hermes: options.hermes || false,
|
|
93
|
+
sentryRelease: options.sentryRelease,
|
|
94
|
+
sentryDist: options.sentryDist,
|
|
93
95
|
});
|
|
94
96
|
|
|
95
97
|
const { bundleCommands } = await import('./bundle');
|
package/src/types.ts
CHANGED
package/src/utils/index.ts
CHANGED
|
@@ -103,27 +103,40 @@ export async function question(query: string, password?: boolean) {
|
|
|
103
103
|
|
|
104
104
|
export function translateOptions<T extends Record<string, unknown>>(
|
|
105
105
|
options: T,
|
|
106
|
+
map?: Record<string, string>,
|
|
106
107
|
): T & Record<string, unknown> {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
108
|
+
if (!map) {
|
|
109
|
+
// Existing logic for template replacement if no map is provided
|
|
110
|
+
const ret: Record<string, unknown> = {};
|
|
111
|
+
for (const key in options) {
|
|
112
|
+
const value = options[key];
|
|
113
|
+
if (typeof value === 'string') {
|
|
114
|
+
ret[key] = value.replace(/\$\{(\w+)\}/g, (placeholder, name) => {
|
|
115
|
+
const replacement = options[name] ?? process.env[name];
|
|
116
|
+
if (
|
|
117
|
+
typeof replacement === 'string' ||
|
|
118
|
+
typeof replacement === 'number' ||
|
|
119
|
+
typeof replacement === 'boolean'
|
|
120
|
+
) {
|
|
121
|
+
return String(replacement);
|
|
122
|
+
}
|
|
123
|
+
return placeholder;
|
|
124
|
+
});
|
|
125
|
+
} else {
|
|
126
|
+
ret[key] = value;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return ret as T & Record<string, unknown>;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const result: Record<string, unknown> = { ...options };
|
|
133
|
+
for (const [key, value] of Object.entries(map)) {
|
|
134
|
+
if (result[key] !== undefined) {
|
|
135
|
+
result[value] = result[key];
|
|
136
|
+
delete result[key];
|
|
124
137
|
}
|
|
125
138
|
}
|
|
126
|
-
return
|
|
139
|
+
return result as T;
|
|
127
140
|
}
|
|
128
141
|
|
|
129
142
|
export async function getApkInfo(fn: string) {
|