-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathgo
More file actions
executable file
·125 lines (109 loc) · 3.1 KB
/
Copy pathgo
File metadata and controls
executable file
·125 lines (109 loc) · 3.1 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#! /bin/bash
function help {
echo "Usage"
echo "./go init ........................... Installs all dependencies and makes Noob ready for development"
echo "./go install_idm .................... Installs the IDM service"
echo "./go reset_db [development|test] .... Drops and creates database according to environment argument"
echo "./go start .......................... Starts the server in dev mode"
echo "./go test ............ Runs reset_db test, then runs test scripts"
}
function reset_db {
env=${1:-test}
dbname=noob-${env}
dropdb ${dbname}
createdb ${dbname}
NODE_ENV=${env} npm run migrate
}
function test {
reset_db test
NODE_ENV=test npm run test
}
function init {
echo "Initializing: add initialization steps here"
npm install
reset_db development
reset_db test
}
function start {
npm run start:dev
}
function add_env_var_to_shell {
if [ $SHELL = "/bin/bash" ] ; then
echo "${1}" >> ~/.bashrc
elif [ $SHELL = "/bin/zsh" ]; then
echo "${1}" >> ~/.zshrc
fi
}
function source_shell_profile {
if [ $SHELL = "/bin/bash" ] ; then
source ~/.bashrc
elif [ $SHELL = "/bin/zsh" ]; then
source ~/.zshrc
fi
}
function install_idm {
PROJECT_HOME="${PWD}"
IDM_HOME="${PWD}/../idm"
if ! [ -d ${IDM_HOME} ]; then
echo "cloning IDM github repo"
git clone git@github.com:LearnersGuild/idm.git ${IDM_HOME}
else
echo "IDM github already exists. Skipping"
fi
if ! [ $NODE_ENV ]; then
add_env_var_to_shell "export NODE_ENV=development"
fi
echo "installing rethinkdb.."
brew install rethinkdb
brew services start rethinkdb
echo "...done installing rethinkdb"
echo "installing redis..."
brew install redis
brew services start redis
echo "...done installing redis"
if ! [ -f "../idm/.env.development" ]; then
echo "creating a .env.development file for idm"
cp idm/.env.template ../idm/.env.development
fi
echo "Going to login to npmjs.org. "
echo "If you dont remember the password, goto npmjs.org to reset password or create new account"
if ! [ -f "${HOME}/.npmrc" ]; then
npm login
fi
add_env_var_to_shell "export NPM_AUTH_TOKEN=$(cat ${HOME}/.npmrc | grep _authToken | cut -d '=' -f2)"
source_shell_profile
cd ${IDM_HOME}
echo "installing npm packages"
npm install
echo "going to create db"
npm run db:create
echo "running migrations"
npm run db:migrate -- up
echo "Install Mehserve"
npm install mehserve -g
mkdir -p ~/.mehserve
echo 9001 > ~/.mehserve/idm.learnersguild
echo 3000 > ~/.mehserve/noob.learnersguild
mehserve install
echo "!!!! IMPORTANT !!!!"
echo "paste the 5 commands above for successfull mehserve configuration"
}
if [ -z "${1}" ] ; then
init
echo "Additional commands you can run -"
help
exit 0
fi
case $1 in
init) init $@
;;
install_idm | install-idm) install_idm $@
;;
reset_db) shift; reset_db $@
;;
test) shift; test $@
;;
start) start
;;
*) help
esac