-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
86 lines (70 loc) · 2.42 KB
/
setup.sh
File metadata and controls
86 lines (70 loc) · 2.42 KB
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
83
84
85
86
#!/bin/env bash
ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
FRONT_DIR="$ROOT_DIR/front"
API_DIR="$ROOT_DIR/api"
FRONT_ENV="$FRONT_DIR/app/config/.env"
FRONT_SETUP="$FRONT_DIR/scripts/setup.sh"
API_SETUP="$API_DIR/setup.sh"
source "$FRONT_DIR"/scripts/utils.sh
get_password && echo || exit
color_echo blue "\nInstalling prompt utility fzy..."
if [ "$OS" = "Linux" ]; then
echo "$PASSWORD" | sudo -S apt install fzy
elif [ "$OS" = "Mac" ]; then
brew install fzy
else
color_echo red "\nUnsupported OS: $OS"
exit 1
fi
INSTALL_MODE="full_install"
choose_install_mode() {
color_echo blue "Do you want to run a full install or a quick install (skips defining basic env variables, perfect for dev)?"
options=("quick install" "full install")
answer=$(printf "%s\n" "${options[@]}" | fzy)
INSTALL_MODE="${answer/ /_}" # "quick_install" or "full_install", will default to "full_install"
export INSTALL_MODE="$INSTALL_MODE"
echo ""
color_echo cyan "Running a $answer! 🚀"
echo ""
}
choose_install_mode
if [ ! -d "$API_DIR" ]; then
git submodule init
git submodule update
else
color_echo blue "Do you want to init the api/ submodule (⚠️ this will checkout from your current API branch to a detached head, resetting all changes made to the API)?"
options=("yes" "no")
answer=$(printf "%s\n" "${options[@]}" | fzy)
if [ "$answer" = "yes" ]; then
git submodule init
git submodule update
fi
fi
echo_title "AIKON BUNDLE INSTALL"
color_echo green "Front installation..."
cd "$FRONT_DIR";
if ! bash "$FRONT_SETUP"; then
color_echo red "AIKON setup encountered an error"
exit 1
fi
color_echo green "API installation..."
source "$FRONT_ENV"
cd "$API_DIR"
if ! bash "$API_SETUP"; then
color_echo red "API setup encountered an error"
exit 1
fi
# replace API_URL in aikon/.env by localhost:api/.env.dev => $API_PORT
api_port=$(grep "API_PORT" "$API_DIR/.env.dev" | cut -d'=' -f2)
api_url=localhost:$(echo "$api_port" | tr -d '"')
sed_repl_inplace "s~^API_URL=.*~API_URL=$api_url~" "$FRONT_ENV"
echo_title "🎉 FRONT & API ARE SET UP! 🎉"
color_echo blue "\nYou can now run the app and API with: "
color_echo green " $ bash run.sh"
color_echo blue '\nConnect to app using:'
echo -e " 👤 $POSTGRES_USER"
echo -e " 🔑 $POSTGRES_PASSWORD"
echo ""
cd $ROOT_DIR
# remove exported variables from shell
fresh_shell