diff options
Diffstat (limited to 'bin/setup')
| -rwxr-xr-x | bin/setup | 34 |
1 files changed, 20 insertions, 14 deletions
| @@ -1,29 +1,35 @@ | |||
| 1 | #!/usr/bin/env ruby | 1 | #!/usr/bin/env ruby |
| 2 | require 'pathname' | 2 | require "fileutils" |
| 3 | 3 | ||
| 4 | # path to your application root. | 4 | APP_ROOT = File.expand_path("..", __dir__) |
| 5 | APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) | ||
| 6 | 5 | ||
| 7 | Dir.chdir APP_ROOT do | 6 | def system!(*args) |
| 8 | # This script is a starting point to setup your application. | 7 | system(*args, exception: true) |
| 9 | # Add necessary setup steps to this file: | 8 | end |
| 9 | |||
| 10 | FileUtils.chdir APP_ROOT do | ||
| 11 | # This script is a way to set up or update your development environment automatically. | ||
| 12 | # This script is idempotent, so that you can run it at any time and get an expectable outcome. | ||
| 13 | # Add necessary setup steps to this file. | ||
| 10 | 14 | ||
| 11 | puts "== Installing dependencies ==" | 15 | puts "== Installing dependencies ==" |
| 12 | system "gem install bundler --conservative" | 16 | system("bundle check") || system!("bundle install") |
| 13 | system "bundle check || bundle install" | ||
| 14 | 17 | ||
| 15 | # puts "\n== Copying sample files ==" | 18 | # puts "\n== Copying sample files ==" |
| 16 | # unless File.exist?("config/database.yml") | 19 | # unless File.exist?("config/database.yml") |
| 17 | # system "cp config/database.yml.sample config/database.yml" | 20 | # FileUtils.cp "config/database.yml.sample", "config/database.yml" |
| 18 | # end | 21 | # end |
| 19 | 22 | ||
| 20 | puts "\n== Preparing database ==" | 23 | puts "\n== Preparing database ==" |
| 21 | system "bin/rake db:setup" | 24 | system! "bin/rails db:prepare" |
| 25 | system! "bin/rails db:reset" if ARGV.include?("--reset") | ||
| 22 | 26 | ||
| 23 | puts "\n== Removing old logs and tempfiles ==" | 27 | puts "\n== Removing old logs and tempfiles ==" |
| 24 | system "rm -f log/*" | 28 | system! "bin/rails log:clear tmp:clear" |
| 25 | system "rm -rf tmp/cache" | ||
| 26 | 29 | ||
| 27 | puts "\n== Restarting application server ==" | 30 | unless ARGV.include?("--skip-server") |
| 28 | system "touch tmp/restart.txt" | 31 | puts "\n== Starting development server ==" |
| 32 | STDOUT.flush # flush the output before exec(2) so that it displays | ||
| 33 | exec "bin/dev" | ||
| 34 | end | ||
| 29 | end | 35 | end |
