1
0
Fork 0

Add "script/setup"

This commit is contained in:
Alex Kotov 2019-04-27 17:13:37 +05:00
parent 553b4fbbd5
commit 9fc1f7308f
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
3 changed files with 44 additions and 58 deletions

View File

@ -1,33 +1,6 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'fileutils'
SCRIPT = File.expand_path(File.join('..', 'script', 'setup'), __dir__).freeze
APP_ROOT = File.expand_path('..', __dir__).freeze
def system!(*args)
system(*args) or abort "\n== Command #{args} failed =="
end
FileUtils.chdir APP_ROOT do
puts '== Update RubyGems =='
system! 'gem update --system'
puts '== Update Bundler =='
system! "gem install bundler -v '~> 2.0'"
puts '== Installing gems =='
system 'bundle check' or system! 'bundle install'
puts '== Install JavaScript dependencies =='
system! 'bin/rake yarn:install'
puts '== Preparing database =='
system! 'bin/rails db:setup'
puts '== Removing old logs and tempfiles =='
system! 'bin/rails log:clear tmp:clear'
puts '== Restarting application server =='
system! 'bin/rails restart'
end
system SCRIPT, '--initial'

View File

@ -1,33 +1,6 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'fileutils'
SCRIPT = File.expand_path(File.join('..', 'script', 'setup'), __dir__).freeze
APP_ROOT = File.expand_path('..', __dir__).freeze
def system!(*args)
system(*args) or abort "\n== Command #{args} failed =="
end
FileUtils.chdir APP_ROOT do
puts '== Update RubyGems =='
system! 'gem update --system'
puts '== Update Bundler =='
system! "gem install bundler -v '~> 2.0'"
puts '== Installing gems =='
system 'bundle check' or system! 'bundle install'
puts '== Install JavaScript dependencies =='
system! 'bin/rake yarn:install'
puts '== Updating database =='
system! 'bin/rails db:migrate'
puts '== Removing old logs and tempfiles =='
system! 'bin/rails log:clear tmp:clear'
puts '== Restarting application server =='
system! 'bin/rails restart'
end
system SCRIPT

40
script/setup Executable file
View File

@ -0,0 +1,40 @@
#!/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
initial = !!ARGV.delete('--initial')
FileUtils.chdir APP_ROOT do
puts '== Update RubyGems =='
system! 'gem update --system'
puts '== Update Bundler =='
system! "gem install bundler -v '~> 2.0'"
puts '== Installing gems =='
system 'bundle check' or system! 'bundle install'
puts '== Install JavaScript dependencies =='
system! 'bin/rake yarn:install'
if initial
puts '== Preparing database =='
system! 'bin/rails db:setup'
else
puts '== Updating database =='
system! 'bin/rails db:migrate'
end
puts '== Removing old logs and tempfiles =='
system! 'bin/rails log:clear tmp:clear'
puts '== Restarting application server =='
system! 'bin/rails restart'
end