main
1#!/usr/bin/env ruby
2require 'fileutils'
3include FileUtils
4
5# path to your application root.
6APP_ROOT = File.expand_path('..', __dir__)
7
8def system!(*args)
9 system(*args) || abort("\n== Command #{args} failed ==")
10end
11
12chdir APP_ROOT do
13 # This script is a starting point to setup your application.
14 # Add necessary setup steps to this file.
15
16 puts '== Installing dependencies =='
17 system! 'gem install bundler --conservative'
18 system('bundle check') || system!('bundle install')
19
20 # Install JavaScript dependencies if using Yarn
21 system('bin/yarn')
22
23 puts "\n== Copying sample files =="
24 unless File.exist?('config/database.yml')
25 cp 'config/database.yml.sample', 'config/database.yml'
26 end
27
28 puts "\n== Preparing database =="
29 system! 'bin/rails db:setup'
30
31 puts "\n== Removing old logs and tempfiles =="
32 system! 'bin/rails log:clear tmp:clear'
33
34 puts "\n== Restarting application server =="
35 system! 'bin/rails restart'
36end