react-native-update-cli 2.15.0 → 2.15.1
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 +24 -0
- package/lib/bundle-runner.d.ts +17 -2
- package/lib/bundle-runner.js +52 -10
- package/lib/bundle.js +20 -5
- package/lib/provider.js +4 -1
- package/lib/types.d.ts +3 -0
- package/lib/utils/index.d.ts +1 -1
- package/lib/utils/index.js +29 -16
- package/lib/utils/sentry-release.d.ts +15 -0
- package/lib/utils/sentry-release.js +262 -0
- package/package.json +3 -3
- package/src/bundle-runner.ts +89 -20
- package/src/bundle.ts +46 -0
- package/src/diff.ts +1 -1
- package/src/provider.ts +3 -0
- package/src/types.ts +3 -0
- package/src/utils/index.ts +31 -18
- package/src/utils/sentry-release.ts +381 -0
package/src/bundle-runner.ts
CHANGED
|
@@ -9,6 +9,10 @@ import {
|
|
|
9
9
|
spawnJavaScript,
|
|
10
10
|
spawnJavaScriptSync,
|
|
11
11
|
} from './utils/runtime';
|
|
12
|
+
import {
|
|
13
|
+
resolveSentryReleaseAndDist,
|
|
14
|
+
type SentryReleaseOptions,
|
|
15
|
+
} from './utils/sentry-release';
|
|
12
16
|
|
|
13
17
|
const g2js = require('gradle-to-js/lib/parser');
|
|
14
18
|
const properties = require('properties');
|
|
@@ -55,6 +59,23 @@ type ResolvedExpoCli = {
|
|
|
55
59
|
usingExpo: boolean;
|
|
56
60
|
};
|
|
57
61
|
|
|
62
|
+
type SentryUploadArtifacts = {
|
|
63
|
+
bundlePath: string;
|
|
64
|
+
sourcemapPath: string;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
type BuildSentrySourcemapsUploadArgsOptions = {
|
|
68
|
+
sentryCliPath: string;
|
|
69
|
+
bundlePath: string;
|
|
70
|
+
sourcemapPath: string;
|
|
71
|
+
release: string;
|
|
72
|
+
dist?: string;
|
|
73
|
+
stripPrefix?: string;
|
|
74
|
+
useStandaloneSourcemapsCommand?: boolean;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const ANDROID_SENTRY_BUNDLE_NAME = 'index.android.bundle';
|
|
78
|
+
|
|
58
79
|
export function hasProjectDependency(
|
|
59
80
|
dependencyName: string,
|
|
60
81
|
projectRoot = process.cwd(),
|
|
@@ -557,27 +578,59 @@ export async function copyDebugidForSentry(
|
|
|
557
578
|
fs.removeSync(path.join(outputFolder, `${bundleName}.txt.map`));
|
|
558
579
|
}
|
|
559
580
|
|
|
560
|
-
export function
|
|
561
|
-
sentryCliPath: string,
|
|
581
|
+
export function prepareSentryUploadArtifacts(
|
|
562
582
|
bundleName: string,
|
|
563
583
|
outputFolder: string,
|
|
564
|
-
|
|
584
|
+
platform: string,
|
|
585
|
+
): SentryUploadArtifacts {
|
|
586
|
+
const bundlePath = path.join(outputFolder, bundleName);
|
|
587
|
+
const sourcemapPath = path.join(outputFolder, `${bundleName}.map`);
|
|
588
|
+
|
|
589
|
+
if (platform !== 'android' || bundleName === ANDROID_SENTRY_BUNDLE_NAME) {
|
|
590
|
+
return {
|
|
591
|
+
bundlePath,
|
|
592
|
+
sourcemapPath,
|
|
593
|
+
};
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
const androidBundlePath = path.join(outputFolder, ANDROID_SENTRY_BUNDLE_NAME);
|
|
597
|
+
const androidSourcemapPath = path.join(
|
|
598
|
+
outputFolder,
|
|
599
|
+
`${ANDROID_SENTRY_BUNDLE_NAME}.map`,
|
|
600
|
+
);
|
|
601
|
+
fs.copyFileSync(bundlePath, androidBundlePath);
|
|
602
|
+
|
|
603
|
+
const sourcemap = JSON.parse(
|
|
604
|
+
fs.readFileSync(sourcemapPath, 'utf8'),
|
|
605
|
+
) as Record<string, unknown>;
|
|
606
|
+
sourcemap.file = ANDROID_SENTRY_BUNDLE_NAME;
|
|
607
|
+
fs.writeFileSync(androidSourcemapPath, JSON.stringify(sourcemap));
|
|
608
|
+
|
|
609
|
+
return {
|
|
610
|
+
bundlePath: androidBundlePath,
|
|
611
|
+
sourcemapPath: androidSourcemapPath,
|
|
612
|
+
};
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
export function buildSentrySourcemapsUploadArgs({
|
|
616
|
+
sentryCliPath,
|
|
617
|
+
bundlePath,
|
|
618
|
+
sourcemapPath,
|
|
619
|
+
release,
|
|
620
|
+
dist,
|
|
621
|
+
stripPrefix = process.cwd(),
|
|
565
622
|
useStandaloneSourcemapsCommand = true,
|
|
566
|
-
): string[] {
|
|
567
|
-
const uploadArgs = [
|
|
568
|
-
'--strip-prefix',
|
|
569
|
-
path.join(process.cwd(), outputFolder),
|
|
570
|
-
path.join(outputFolder, bundleName),
|
|
571
|
-
path.join(outputFolder, `${bundleName}.map`),
|
|
572
|
-
];
|
|
623
|
+
}: BuildSentrySourcemapsUploadArgsOptions): string[] {
|
|
624
|
+
const uploadArgs = ['--strip-prefix', stripPrefix, bundlePath, sourcemapPath];
|
|
573
625
|
|
|
574
626
|
if (!useStandaloneSourcemapsCommand) {
|
|
575
627
|
return [
|
|
576
628
|
sentryCliPath,
|
|
577
629
|
'releases',
|
|
578
630
|
'files',
|
|
579
|
-
|
|
631
|
+
release,
|
|
580
632
|
'upload-sourcemaps',
|
|
633
|
+
...(dist ? ['--dist', dist] : []),
|
|
581
634
|
...uploadArgs,
|
|
582
635
|
];
|
|
583
636
|
}
|
|
@@ -587,7 +640,8 @@ export function buildSentrySourcemapsUploadArgs(
|
|
|
587
640
|
'sourcemaps',
|
|
588
641
|
'upload',
|
|
589
642
|
'--release',
|
|
590
|
-
|
|
643
|
+
release,
|
|
644
|
+
...(dist ? ['--dist', dist] : []),
|
|
591
645
|
...uploadArgs,
|
|
592
646
|
];
|
|
593
647
|
}
|
|
@@ -607,6 +661,8 @@ export async function uploadSourcemapForSentry(
|
|
|
607
661
|
outputFolder: string,
|
|
608
662
|
sourcemapOutput: string,
|
|
609
663
|
version: string,
|
|
664
|
+
platform = '',
|
|
665
|
+
sentryOptions: SentryReleaseOptions = {},
|
|
610
666
|
): Promise<void> {
|
|
611
667
|
if (!sourcemapOutput) {
|
|
612
668
|
return;
|
|
@@ -626,27 +682,40 @@ export async function uploadSourcemapForSentry(
|
|
|
626
682
|
return;
|
|
627
683
|
}
|
|
628
684
|
|
|
685
|
+
const { release, dist } = await resolveSentryReleaseAndDist(
|
|
686
|
+
platform,
|
|
687
|
+
version,
|
|
688
|
+
sentryOptions,
|
|
689
|
+
);
|
|
690
|
+
const { bundlePath, sourcemapPath } = prepareSentryUploadArtifacts(
|
|
691
|
+
bundleName,
|
|
692
|
+
outputFolder,
|
|
693
|
+
platform,
|
|
694
|
+
);
|
|
695
|
+
|
|
629
696
|
assertSuccessfulSyncProcess(
|
|
630
697
|
spawnJavaScriptSync(
|
|
631
|
-
[sentryCliPath, 'releases', 'set-commits',
|
|
698
|
+
[sentryCliPath, 'releases', 'set-commits', release, '--auto'],
|
|
632
699
|
{
|
|
633
700
|
stdio: 'inherit',
|
|
634
701
|
},
|
|
635
702
|
),
|
|
636
703
|
sentryCliPath,
|
|
637
704
|
);
|
|
638
|
-
console.log(t('sentryReleaseCreated', { version }));
|
|
705
|
+
console.log(t('sentryReleaseCreated', { version: release }));
|
|
639
706
|
|
|
640
707
|
console.log(t('uploadingSourcemap'));
|
|
641
708
|
assertSuccessfulSyncProcess(
|
|
642
709
|
spawnJavaScriptSync(
|
|
643
|
-
buildSentrySourcemapsUploadArgs(
|
|
710
|
+
buildSentrySourcemapsUploadArgs({
|
|
644
711
|
sentryCliPath,
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
712
|
+
bundlePath,
|
|
713
|
+
sourcemapPath,
|
|
714
|
+
release,
|
|
715
|
+
dist,
|
|
716
|
+
useStandaloneSourcemapsCommand:
|
|
717
|
+
supportsStandaloneSentrySourcemapsUpload(sentryCliPath),
|
|
718
|
+
}),
|
|
650
719
|
{
|
|
651
720
|
stdio: 'inherit',
|
|
652
721
|
},
|
package/src/bundle.ts
CHANGED
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
getOptionalStringOption,
|
|
19
19
|
getStringOption,
|
|
20
20
|
} from './utils/options';
|
|
21
|
+
import type { SentryReleaseOptions } from './utils/sentry-release';
|
|
21
22
|
import { versionCommands } from './versions';
|
|
22
23
|
|
|
23
24
|
type NormalizedBundleOptions = {
|
|
@@ -41,6 +42,9 @@ type NormalizedBundleOptions = {
|
|
|
41
42
|
packageVersionRange?: string;
|
|
42
43
|
rollout?: string;
|
|
43
44
|
dryRun: boolean;
|
|
45
|
+
sentryRelease?: string;
|
|
46
|
+
sentryDist?: string;
|
|
47
|
+
sentryFlavor?: string;
|
|
44
48
|
};
|
|
45
49
|
|
|
46
50
|
type PublishBundlePayload = {
|
|
@@ -56,6 +60,17 @@ type PublishBundlePayload = {
|
|
|
56
60
|
dryRun?: boolean;
|
|
57
61
|
};
|
|
58
62
|
|
|
63
|
+
function getAliasedOptionalStringOption(
|
|
64
|
+
options: Record<string, unknown>,
|
|
65
|
+
key: string,
|
|
66
|
+
alias: string,
|
|
67
|
+
): string | undefined {
|
|
68
|
+
return (
|
|
69
|
+
getOptionalStringOption(options, key) ??
|
|
70
|
+
getOptionalStringOption(options, alias)
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
59
74
|
function normalizeBundleOptions(
|
|
60
75
|
translatedOptions: Record<string, unknown>,
|
|
61
76
|
platform: string,
|
|
@@ -105,6 +120,21 @@ function normalizeBundleOptions(
|
|
|
105
120
|
),
|
|
106
121
|
rollout: getOptionalStringOption(translatedOptions, 'rollout'),
|
|
107
122
|
dryRun: getBooleanOption(translatedOptions, 'dryRun', false),
|
|
123
|
+
sentryRelease: getAliasedOptionalStringOption(
|
|
124
|
+
translatedOptions,
|
|
125
|
+
'sentry-release',
|
|
126
|
+
'sentryRelease',
|
|
127
|
+
),
|
|
128
|
+
sentryDist: getAliasedOptionalStringOption(
|
|
129
|
+
translatedOptions,
|
|
130
|
+
'sentry-dist',
|
|
131
|
+
'sentryDist',
|
|
132
|
+
),
|
|
133
|
+
sentryFlavor: getAliasedOptionalStringOption(
|
|
134
|
+
translatedOptions,
|
|
135
|
+
'sentry-flavor',
|
|
136
|
+
'sentryFlavor',
|
|
137
|
+
),
|
|
108
138
|
};
|
|
109
139
|
}
|
|
110
140
|
|
|
@@ -114,6 +144,8 @@ async function uploadSentryArtifactsIfNeeded(
|
|
|
114
144
|
intermediaDir: string,
|
|
115
145
|
sourcemapOutput: string,
|
|
116
146
|
versionName: string,
|
|
147
|
+
platform: Platform,
|
|
148
|
+
sentryOptions: SentryReleaseOptions,
|
|
117
149
|
): Promise<void> {
|
|
118
150
|
if (!shouldUpload) {
|
|
119
151
|
return;
|
|
@@ -125,6 +157,8 @@ async function uploadSentryArtifactsIfNeeded(
|
|
|
125
157
|
intermediaDir,
|
|
126
158
|
sourcemapOutput,
|
|
127
159
|
versionName,
|
|
160
|
+
platform,
|
|
161
|
+
sentryOptions,
|
|
128
162
|
);
|
|
129
163
|
}
|
|
130
164
|
|
|
@@ -217,6 +251,12 @@ export const bundleCommands = {
|
|
|
217
251
|
normalized.intermediaDir,
|
|
218
252
|
sourcemapOutput,
|
|
219
253
|
versionName,
|
|
254
|
+
platform,
|
|
255
|
+
{
|
|
256
|
+
sentryRelease: normalized.sentryRelease,
|
|
257
|
+
sentryDist: normalized.sentryDist,
|
|
258
|
+
sentryFlavor: normalized.sentryFlavor,
|
|
259
|
+
},
|
|
220
260
|
);
|
|
221
261
|
return;
|
|
222
262
|
}
|
|
@@ -235,6 +275,12 @@ export const bundleCommands = {
|
|
|
235
275
|
normalized.intermediaDir,
|
|
236
276
|
sourcemapOutput,
|
|
237
277
|
versionName,
|
|
278
|
+
platform,
|
|
279
|
+
{
|
|
280
|
+
sentryRelease: normalized.sentryRelease,
|
|
281
|
+
sentryDist: normalized.sentryDist,
|
|
282
|
+
sentryFlavor: normalized.sentryFlavor,
|
|
283
|
+
},
|
|
238
284
|
);
|
|
239
285
|
}
|
|
240
286
|
}
|
package/src/diff.ts
CHANGED
package/src/provider.ts
CHANGED
|
@@ -90,6 +90,9 @@ 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,
|
|
95
|
+
sentryFlavor: options.sentryFlavor,
|
|
93
96
|
});
|
|
94
97
|
|
|
95
98
|
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) {
|