1
1
#! /bin/sh
2
2
3
3
# Searches for app token within source files.
4
+ JSON_APP_TOKEN=$(
5
+ grep " app_token" -r -A 1 -m 1 --exclude-dir={node_modules,ios,android} --include=instabug.json ./ |
6
+ sed ' s/[[:space:]]//g' |
7
+ grep -o " :[\" \'][0-9a-zA-Z]*[\" \']" |
8
+ cut -d " :" -f 2 |
9
+ cut -d " \" " -f 2 |
10
+ cut -d " '" -f 2
11
+ )
12
+
13
+ if [ ! -z " ${JSON_APP_TOKEN} " ]; then
14
+ echo $JSON_APP_TOKEN
15
+ exit 0
16
+ fi
4
17
5
18
INIT_APP_TOKEN=$(
6
19
grep " Instabug.init({" -r -A 6 -m 1 --exclude-dir={node_modules,ios,android} --include=\* .{js,ts,jsx,tsx} ./ |
7
- grep " token:[[:space:]]*[\" \'][0-9a-zA-Z]*[\" \']" |
20
+ grep " token[[:space:]]* :[[:space:]]*[\" \'][0-9a-zA-Z]*[\" \']" |
8
21
grep -o " [\" \'][0-9a-zA-Z]*[\" \']" |
9
22
cut -d " \" " -f 2 |
10
23
cut -d " '" -f 2
11
- )
24
+ )
12
25
13
26
if [ ! -z " ${INIT_APP_TOKEN} " ]; then
14
27
echo $INIT_APP_TOKEN
@@ -20,12 +33,38 @@ START_APP_TOKEN=$(
20
33
grep -o " [\" \'][0-9a-zA-Z]*[\" \']" |
21
34
cut -d " \" " -f 2 |
22
35
cut -d " '" -f 2
23
- )
36
+ )
24
37
25
38
if [ ! -z " ${START_APP_TOKEN} " ]; then
26
39
echo $START_APP_TOKEN
27
40
exit 0
28
41
fi
29
42
43
+ ENV_APP_TOKEN=$(
44
+ grep " INSTABUG_APP_TOKEN" -r -A 1 -m 1 --exclude-dir={node_modules,ios,android} --include=\* .env ./ |
45
+ sed ' s/[[:space:]]//g' |
46
+ grep -o " INSTABUG_APP_TOKEN=.*" |
47
+ cut -d " =" -f 2
48
+ )
49
+
50
+ if [ ! -z " ${ENV_APP_TOKEN} " ]; then
51
+ echo $ENV_APP_TOKEN
52
+ exit 0
53
+ fi
54
+
55
+ CONSTANTS_APP_TOKEN=$(
56
+ grep " INSTABUG_APP_TOKEN" -r -A 1 -m 1 --exclude-dir={node_modules,ios,android} --include=\* .{js,ts,jsx,tsx} ./ |
57
+ sed ' s/[[:space:]]//g' |
58
+ grep -o " =[\" \'][0-9a-zA-Z]*[\" \']" |
59
+ cut -d " =" -f 2 |
60
+ cut -d " \" " -f 2 |
61
+ cut -d " '" -f 2
62
+ )
63
+
64
+ if [ ! -z " ${CONSTANTS_APP_TOKEN} " ]; then
65
+ echo $CONSTANTS_APP_TOKEN
66
+ exit 0
67
+ fi
68
+
30
69
echo " Couldn't find Instabug's app token"
31
70
exit 1
0 commit comments