-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
82 lines (67 loc) · 1.56 KB
/
run.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
# To run
# Requires a unix terminal
# bash ./run.sh ...params
ZR_ENV=development
ZR_PORT=3001
zerista_check_args(){
# Check for ENV override
if [[ "$ENV" || "$RAILS_ENV" ]]; then
ZR_ENV=$ENV
elif [[ "$RAILS_ENV" ]]; then
ZR_ENV=$RAILS_ENV
fi
# Check for port override
if [[ "$PORT" ]]; then
ZR_PORT=PORT
fi
}
# Start the server
# Example => bash ./run.sh
zerista_run_server(){
RAILS_ENV=$ZR_ENV ./bin/bundle exec puma -C config/puma.rb -p $ZR_PORT
}
# Install the gems
# Example => bash ./run.sh bundle
zerista_run_bundler(){
# Allow pulling http gems when doing bundle install
./bin/bundle config git.allow_insecure true
# Disable bundle root warning
./bin/bundle config silence_root_warning true
# Run the install, to install all gems
./bin/bundle install
}
# Setup the database
# Example => bash ./run.sh db
zerista_run_db_setup(){
./bin/rails db:drop
./bin/rails db:create
./bin/rails db:migrate
./bin/rails db:seed
}
# Run any tests
# Example => bash ./run.sh test
zerista_run_tests(){
./bin/bundle exec rspec
}
# Format the code
# Example => bash ./run.sh format
zerista_run_format(){
rubocop -a
}
# Run an action based on passed in param
zerista_run_action(){
if [[ -z "$1" ]]; then
# Default to just running the server
zerista_run_server
elif [[ "$1" == "bundle" ]]; then
zerista_run_bundler
elif [[ "$1" == "db" ]]; then
zerista_run_db_setup
elif [[ "$1" == "test" ]]; then
zerista_run_tests
elif [[ "$1" == "format" ]]; then
zerista_run_format
fi
}
zerista_run_action $@