diff options
Diffstat (limited to 'bin/setup')
-rwxr-xr-x | bin/setup | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/bin/setup b/bin/setup index 78c4e86..ec47b79 100755 --- a/bin/setup +++ b/bin/setup | |||
@@ -1,38 +1,33 @@ | |||
1 | #!/usr/bin/env ruby | 1 | #!/usr/bin/env ruby |
2 | require 'pathname' | 2 | require "fileutils" |
3 | require 'fileutils' | ||
4 | include FileUtils | ||
5 | 3 | ||
6 | # path to your application root. | 4 | # path to your application root. |
7 | APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) | 5 | APP_ROOT = File.expand_path("..", __dir__) |
8 | 6 | ||
9 | def system!(*args) | 7 | def system!(*args) |
10 | system(*args) || abort("\n== Command #{args} failed ==") | 8 | system(*args) || abort("\n== Command #{args} failed ==") |
11 | end | 9 | end |
12 | 10 | ||
13 | chdir APP_ROOT do | 11 | FileUtils.chdir APP_ROOT do |
14 | # This script is a starting point to setup your application. | 12 | # This script is a way to set up or update your development environment automatically. |
13 | # This script is idempotent, so that you can run it at any time and get an expectable outcome. | ||
15 | # Add necessary setup steps to this file. | 14 | # Add necessary setup steps to this file. |
16 | 15 | ||
17 | puts '== Installing dependencies ==' | 16 | puts "== Installing dependencies ==" |
18 | system! 'gem install bundler --conservative' | 17 | system! "gem install bundler --conservative" |
19 | system('bundle check') || system!('bundle install') | 18 | system("bundle check") || system!("bundle install") |
20 | |||
21 | # Install JavaScript dependencies if using Yarn | ||
22 | # system('bin/yarn') | ||
23 | |||
24 | 19 | ||
25 | # puts "\n== Copying sample files ==" | 20 | # puts "\n== Copying sample files ==" |
26 | # unless File.exist?('config/database.yml') | 21 | # unless File.exist?("config/database.yml") |
27 | # cp 'config/database.yml.sample', 'config/database.yml' | 22 | # FileUtils.cp "config/database.yml.sample", "config/database.yml" |
28 | # end | 23 | # end |
29 | 24 | ||
30 | puts "\n== Preparing database ==" | 25 | puts "\n== Preparing database ==" |
31 | system! 'bin/rails db:setup' | 26 | system! "bin/rails db:prepare" |
32 | 27 | ||
33 | puts "\n== Removing old logs and tempfiles ==" | 28 | puts "\n== Removing old logs and tempfiles ==" |
34 | system! 'bin/rails log:clear tmp:clear' | 29 | system! "bin/rails log:clear tmp:clear" |
35 | 30 | ||
36 | puts "\n== Restarting application server ==" | 31 | puts "\n== Restarting application server ==" |
37 | system! 'bin/rails restart' | 32 | system! "bin/rails restart" |
38 | end | 33 | end |