-
Notifications
You must be signed in to change notification settings - Fork 58
/
symbolicate-stracktrace.sh
executable file
·66 lines (55 loc) · 1.89 KB
/
symbolicate-stracktrace.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
# Exit if any command fails
set -uo pipefail
# Function to prompt for single line input
function prompt_single_line_input {
local input
read -r input
echo "$input"
}
# Function to prompt for input with multiline support
function prompt_multiline_input {
local input=""
local line
while IFS= read -r line; do
# Check if the line is empty (only contains whitespace)
if [[ -z "${line}" ]]; then
break
fi
input+="$line"$'\n'
done
# Remove the trailing newline from the last line
input=${input%$'\n'}
echo "$input"
}
# Prompt platform
printf "Enter the platform: "
PLATFORM=$(prompt_single_line_input)
if [[ -z "$PLATFORM" || "$PLATFORM" != "android" && "$PLATFORM" != "ios" ]]; then
echo "\x1b[31mPlatform is required. The accepted values are 'android' and 'ios'.\x1b[0m"
exit
fi
# Prompt Gutenberg Mobile version
printf "Enter the Gutenberg Mobile version: "
VERSION=$(prompt_single_line_input)
if [[ -z "$VERSION" ]]; then
echo "\x1b[31mGutenberg Mobile version is required.\x1b[0m"
exit
fi
# Prompt stack trace
echo "Enter the stack trace (Press Enter on an empty line to finish):"
STACKTRACE=$(prompt_multiline_input)
if [[ -z "$STACKTRACE" ]]; then
echo "\x1b[31mStacktrace is required.\x1b[0m"
exit
fi
TEMPMAP=$(mktemp)
DOWNLOAD_URL="https://github.com/wordpress-mobile/gutenberg-mobile/releases/download/v$VERSION/$PLATFORM-App.js.map"
echo "Downloading source maps for version $VERSION ($PLATFORM)..."
wget -q -O $TEMPMAP $DOWNLOAD_URL
if [ $? -ne 0 ]; then
echo "\x1b[31mCan't find source map\x1b[0m '$DOWNLOAD_URL'.\n\x1b[33mPlease verify that the GitHub release for version '$VERSION' has the source maps attached:\x1b[0m https://github.com/wordpress-mobile/gutenberg-mobile/releases/tag/v$VERSION"
exit
else
echo "Symbolicated stack trace:\n"
npx metro-symbolicate $TEMPMAP <<< "$STACKTRACE"
fi