-
Notifications
You must be signed in to change notification settings - Fork 100
/
Copy pathfind-token.sh
70 lines (59 loc) · 1.73 KB
/
find-token.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
69
70
#!/bin/sh
# Searches for app token within source files.
JSON_APP_TOKEN=$(
grep "app_token" -r -A 1 -m 1 --exclude-dir={node_modules,ios,android} --include=instabug.json ./ |
sed 's/[[:space:]]//g' |
grep -o ":[\"\'][0-9a-zA-Z]*[\"\']" |
cut -d ":" -f 2 |
cut -d "\"" -f 2 |
cut -d "'" -f 2
)
if [ ! -z "${JSON_APP_TOKEN}" ]; then
echo $JSON_APP_TOKEN
exit 0
fi
INIT_APP_TOKEN=$(
grep "Instabug.init({" -r -A 6 -m 1 --exclude-dir={node_modules,ios,android} --include=\*.{js,ts,jsx,tsx} ./ |
grep "token[[:space:]]*:[[:space:]]*[\"\'][0-9a-zA-Z]*[\"\']" |
grep -o "[\"\'][0-9a-zA-Z]*[\"\']" |
cut -d "\"" -f 2 |
cut -d "'" -f 2
)
if [ ! -z "${INIT_APP_TOKEN}" ]; then
echo $INIT_APP_TOKEN
exit 0
fi
START_APP_TOKEN=$(
grep "Instabug.start(" -r -A 1 -m 1 --exclude-dir={node_modules,ios,android} --include=\*.{js,ts,jsx,tsx} ./ |
grep -o "[\"\'][0-9a-zA-Z]*[\"\']" |
cut -d "\"" -f 2 |
cut -d "'" -f 2
)
if [ ! -z "${START_APP_TOKEN}" ]; then
echo $START_APP_TOKEN
exit 0
fi
ENV_APP_TOKEN=$(
grep "INSTABUG_APP_TOKEN" -r -A 1 -m 1 --exclude-dir={node_modules,ios,android} --include=\*.env ./ |
sed 's/[[:space:]]//g' |
grep -o "INSTABUG_APP_TOKEN=.*" |
cut -d "=" -f 2
)
if [ ! -z "${ENV_APP_TOKEN}" ]; then
echo $ENV_APP_TOKEN
exit 0
fi
CONSTANTS_APP_TOKEN=$(
grep "INSTABUG_APP_TOKEN" -r -A 1 -m 1 --exclude-dir={node_modules,ios,android} --include=\*.{js,ts,jsx,tsx} ./ |
sed 's/[[:space:]]//g' |
grep -o "=[\"\'][0-9a-zA-Z]*[\"\']" |
cut -d "=" -f 2 |
cut -d "\"" -f 2 |
cut -d "'" -f 2
)
if [ ! -z "${CONSTANTS_APP_TOKEN}" ]; then
echo $CONSTANTS_APP_TOKEN
exit 0
fi
echo "Couldn't find Instabug's app token"
exit 1