Skip to content

Commit ee9a7df

Browse files
feat: fix find token script
1 parent 2b094ca commit ee9a7df

File tree

1 file changed

+42
-3
lines changed

1 file changed

+42
-3
lines changed

scripts/find-token.sh

+42-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,27 @@
11
#!/bin/sh
22

33
# 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
417

518
INIT_APP_TOKEN=$(
619
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]*[\"\']" |
821
grep -o "[\"\'][0-9a-zA-Z]*[\"\']" |
922
cut -d "\"" -f 2 |
1023
cut -d "'" -f 2
11-
)
24+
)
1225

1326
if [ ! -z "${INIT_APP_TOKEN}" ]; then
1427
echo $INIT_APP_TOKEN
@@ -20,12 +33,38 @@ START_APP_TOKEN=$(
2033
grep -o "[\"\'][0-9a-zA-Z]*[\"\']" |
2134
cut -d "\"" -f 2 |
2235
cut -d "'" -f 2
23-
)
36+
)
2437

2538
if [ ! -z "${START_APP_TOKEN}" ]; then
2639
echo $START_APP_TOKEN
2740
exit 0
2841
fi
2942

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+
3069
echo "Couldn't find Instabug's app token"
3170
exit 1

0 commit comments

Comments
 (0)