Skip to content
代码片段 群组 项目
setup 1.0 KB
更新 更旧
Valery Sizov's avatar
Valery Sizov 已提交
#!/usr/bin/env ruby
Heinrich Lee Yu's avatar
Heinrich Lee Yu 已提交
require 'fileutils'
Valery Sizov's avatar
Valery Sizov 已提交

# path to your application root.
Heinrich Lee Yu's avatar
Heinrich Lee Yu 已提交
APP_ROOT = File.expand_path('..', __dir__)
def system!(*args)
  system(*args) || abort("\n== Command #{args} failed ==")
FileUtils.chdir APP_ROOT do
  # This script is a way to setup or update your development environment automatically.
  # This script is idempotent, so that you can run it at anytime and get an expectable outcome.
Heinrich Lee Yu's avatar
Heinrich Lee Yu 已提交
  # Add necessary setup steps to this file.

  puts '== Installing dependencies =='
  system! 'gem install bundler --conservative'
  system('bundle check') || system!('bundle install')
  # Install JavaScript dependencies
Heinrich Lee Yu's avatar
Heinrich Lee Yu 已提交
  # system('bin/yarn')
Valery Sizov's avatar
Valery Sizov 已提交

  # puts "\n== Copying sample files =="
Heinrich Lee Yu's avatar
Heinrich Lee Yu 已提交
  # unless File.exist?('config/database.yml')
  #   FileUtils.cp 'config/database.yml.sample', 'config/database.yml'
Valery Sizov's avatar
Valery Sizov 已提交
  # end

  puts "\n== Preparing database =="
  system! 'bin/rails db:prepare'
Valery Sizov's avatar
Valery Sizov 已提交

  puts "\n== Removing old logs and tempfiles =="
Heinrich Lee Yu's avatar
Heinrich Lee Yu 已提交
  system! 'bin/rails log:clear tmp:clear'
Valery Sizov's avatar
Valery Sizov 已提交

  puts "\n== Restarting application server =="
Heinrich Lee Yu's avatar
Heinrich Lee Yu 已提交
  system! 'bin/rails restart'
Valery Sizov's avatar
Valery Sizov 已提交
end