2019-01-29 20:13:52 +00:00
|
|
|
#!/usr/bin/env ruby
|
2019-02-01 17:54:16 +00:00
|
|
|
require 'fileutils'
|
2020-06-02 22:12:06 +00:00
|
|
|
require 'securerandom'
|
2019-01-29 20:13:52 +00:00
|
|
|
|
|
|
|
# path to your application root.
|
2020-05-20 20:36:31 +00:00
|
|
|
APP_ROOT = File.expand_path('..', __dir__)
|
2019-01-29 20:13:52 +00:00
|
|
|
|
2019-02-01 17:54:16 +00:00
|
|
|
def system!(*args)
|
|
|
|
system(*args) || abort("\n== Command #{args} failed ==")
|
|
|
|
end
|
|
|
|
|
2020-05-20 20:36:31 +00:00
|
|
|
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.
|
2019-02-01 17:54:16 +00:00
|
|
|
# Add necessary setup steps to this file.
|
2019-01-29 20:13:52 +00:00
|
|
|
|
2020-06-02 22:12:06 +00:00
|
|
|
puts '== Installing dependencies (Ruby) =='
|
2019-02-01 17:54:16 +00:00
|
|
|
system! 'gem install bundler --conservative'
|
|
|
|
system('bundle check') || system!('bundle install')
|
2019-01-29 20:13:52 +00:00
|
|
|
|
2020-06-02 22:12:06 +00:00
|
|
|
puts "\n== Installing dependencies (JS) =="
|
|
|
|
system!('yarn -s')
|
|
|
|
|
|
|
|
puts "\n== Copying env file =="
|
|
|
|
unless File.exist?('.env')
|
|
|
|
FileUtils.cp '.env.template', '.env'
|
|
|
|
end
|
|
|
|
|
|
|
|
puts "\n== Create new secrets =="
|
|
|
|
File.write('.env', File.read('.env').gsub(/-- secret string --/) { SecureRandom.hex(64) })
|
2019-01-29 20:13:52 +00:00
|
|
|
|
|
|
|
puts "\n== Preparing database =="
|
2020-05-20 20:36:31 +00:00
|
|
|
system! 'bin/rails db:prepare'
|
2019-01-29 20:13:52 +00:00
|
|
|
|
|
|
|
puts "\n== Removing old logs and tempfiles =="
|
2019-02-01 17:54:16 +00:00
|
|
|
system! 'bin/rails log:clear tmp:clear'
|
2019-01-29 20:13:52 +00:00
|
|
|
|
|
|
|
puts "\n== Restarting application server =="
|
2019-02-01 17:54:16 +00:00
|
|
|
system! 'bin/rails restart'
|
2019-01-29 20:13:52 +00:00
|
|
|
end
|