-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathstart.sh
executable file
·82 lines (66 loc) · 1.73 KB
/
start.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
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash
#########################################################################################################
# A script to spin up the code sample, to be run from a terminal
# Open source libraries are useed by the SPA and API, with AWS Cognito as the default Authorization Server
#########################################################################################################
cd "$(dirname "${BASH_SOURCE[0]}")"
#
# Get the platform
#
case "$(uname -s)" in
Darwin)
PLATFORM="MACOS"
;;
MINGW64*)
PLATFORM="WINDOWS"
;;
Linux)
PLATFORM="LINUX"
;;
esac
#
# Run the SPA and API
#
if [ "$PLATFORM" == 'MACOS' ]; then
open -a Terminal ./spa/start.sh
open -a Terminal ./api/start.sh
elif [ "$PLATFORM" == 'WINDOWS' ]; then
GIT_BASH="C:\Program Files\Git\git-bash.exe"
"$GIT_BASH" -c ./spa/start.sh &
"$GIT_BASH" -c ./api/start.sh &
elif [ "$PLATFORM" == 'LINUX' ]; then
gnome-terminal -- ./spa/start.sh
gnome-terminal -- ./api/start.sh
fi
#
# Set URLs to wait for
#
SPA_URL='http://localhost/spa'
API_URL='http://api.authsamples-dev.com/api'
#
# Wait for the API to come up
#
echo "Waiting for API to become available ..."
while [ "$(curl -k -s -o /dev/null -w ''%{http_code}'' "$API_URL/companies")" != "401" ]; do
sleep 2
done
#
# Wait for the SPA's Javascript bundles to be built
#
echo "Waiting for SPA to become available ..."
SPA_BUNDLE='./spa/dist/app.bundle.js'
while [ ! -f "$SPA_BUNDLE" ]; do
sleep 2
done
#
# Run the SPA in the default browser, then sign in with these credentials:
# - guestuser@example.com
# - Password1
#
if [ "$PLATFORM" == 'MACOS' ]; then
open $SPA_URL
elif [ "$PLATFORM" == 'WINDOWS' ]; then
start $SPA_URL
elif [ "$PLATFORM" == 'LINUX' ]; then
xdg-open $SPA_URL
fi