-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupload_source_map.sh
executable file
·68 lines (55 loc) · 2.09 KB
/
upload_source_map.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
# See also: https://docs.rollbar.com/docs/react-native#source-maps
# SERVERKEY should be defined in a file called upload_source_map_secrets.txt
SERVERKEY=""
source upload_source_map_secrets.txt
VERSION=$(sed 's/.*"version": "\(.*\)".*/\1/;t;d' ./package.json)
function removeDuplicateFiles {
echo "Remove duplicate files (Android)"
rm -rf android/app/src/main/res/drawable-hdpi/
rm -rf android/app/src/main/res/drawable-mdpi/
rm -rf android/app/src/main/res/drawable-xhdpi/
rm -rf android/app/src/main/res/drawable-xxhdpi/
rm -rf android/app/src/main/res/drawable-xxxhdpi/
rm -rf android/app/src/main/res/raw/
}
function uploadSourceMapAndroid {
echo "Uploading source map (Android)"
curl https://api.rollbar.com/api/1/sourcemap \
-F access_token=${SERVERKEY} \
-F version=${VERSION}.android \
-F minified_url=http://reactnativehost/index.android.bundle \
-F [email protected] \
}
function createAndUploadSourceMapAndroid {
echo 'Creating source map (Android)'
npx react-native bundle --platform android --dev false --entry-file index.js --bundle-output \
android/index.android.bundle --assets-dest android/app/src/main/res/ --sourcemap-output \
sourcemap.android.js --sourcemap-sources-root ./ || return
uploadSourceMapAndroid
removeDuplicateFiles
}
function uploadSourceMapIOS {
echo "Uploading source map (iOS)"
curl https://api.rollbar.com/api/1/sourcemap \
-F access_token=${SERVERKEY} \
-F version=${VERSION}.ios \
-F minified_url=http://reactnativehost/main.jsbundle \
-F [email protected] \
}
function createAndUploadSourceMapIOS {
echo "Creating source map (iOS)"
npx react-native bundle --platform ios --entry-file index.js --dev false --bundle-output \
ios/main.jsbundle --assets-dest ios --sourcemap-output sourcemap.ios.js --sourcemap-sources-root ./ || return
uploadSourceMapIOS
}
function cleanUp {
rm sourcemap.android.js
rm sourcemap.ios.js
}
createAndUploadSourceMapAndroid
createAndUploadSourceMapIOS
cleanUp
echo "Done creating and uploading source maps"