1
0
Fork 0
This repository has been archived on 2023-03-28. You can view files and clone it, but cannot push or open issues or pull requests.
lpr-partynest/script/setup

44 lines
1.1 KiB
Plaintext
Raw Permalink Normal View History

2019-04-27 12:13:37 +00:00
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'fileutils'
APP_ROOT = File.expand_path('..', __dir__).freeze
def system!(*args)
system(*args) or abort "\n== Command #{args} failed =="
end
2019-04-27 12:45:16 +00:00
postgres_user = ENV['POSTGRES_USER'].to_s.strip
postgres_user = nil if postgres_user.empty?
postgres_db = ENV['POSTGRES_DB'].to_s.strip
postgres_db = nil if postgres_db.empty?
2019-04-27 12:13:37 +00:00
FileUtils.chdir APP_ROOT do
puts '== Update RubyGems =='
system! 'gem update --system'
puts '== Update Bundler =='
2020-01-17 09:02:40 +00:00
system! "gem install bundler -v '~> 2.0' --conservative"
2019-04-27 12:13:37 +00:00
puts '== Installing gems =='
2020-01-17 09:02:40 +00:00
system 'bundle check' or system! 'bundle install'
2019-04-27 12:13:37 +00:00
puts '== Install JavaScript dependencies =='
2020-01-17 09:02:40 +00:00
system! 'bundle exec rake yarn:install'
2019-04-27 12:13:37 +00:00
2020-01-17 08:57:04 +00:00
puts '== Preparing database =='
if postgres_user && postgres_db
2019-04-27 12:45:16 +00:00
system! "psql -U #{postgres_user} -c 'CREATE DATABASE #{postgres_db};'"
2019-04-27 12:13:37 +00:00
end
2020-01-17 09:02:40 +00:00
system! 'bundle exec rake db:prepare'
2020-01-17 09:24:57 +00:00
system! 'bundle exec rake db:prepare RAILS_ENV=test'
2019-04-27 12:13:37 +00:00
puts '== Removing old logs and tempfiles =='
2020-01-17 09:02:40 +00:00
system! 'bundle exec rake log:clear tmp:clear'
2019-04-27 12:13:37 +00:00
puts '== Restarting application server =='
2020-01-17 09:02:40 +00:00
system! 'bundle exec rake restart'
2019-04-27 12:13:37 +00:00
end