Improve "bin/setup" and "bin/update"
This commit is contained in:
parent
37f7e98830
commit
553b4fbbd5
2 changed files with 35 additions and 36 deletions
37
bin/setup
37
bin/setup
|
@ -1,36 +1,33 @@
|
||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby
|
||||||
require 'fileutils'
|
# frozen_string_literal: true
|
||||||
include FileUtils
|
|
||||||
|
|
||||||
# path to your application root.
|
require 'fileutils'
|
||||||
APP_ROOT = File.expand_path('..', __dir__)
|
|
||||||
|
APP_ROOT = File.expand_path('..', __dir__).freeze
|
||||||
|
|
||||||
def system!(*args)
|
def system!(*args)
|
||||||
system(*args) || abort("\n== Command #{args} failed ==")
|
system(*args) or abort "\n== Command #{args} failed =="
|
||||||
end
|
end
|
||||||
|
|
||||||
chdir APP_ROOT do
|
FileUtils.chdir APP_ROOT do
|
||||||
# This script is a starting point to setup your application.
|
puts '== Update RubyGems =='
|
||||||
# Add necessary setup steps to this file.
|
system! 'gem update --system'
|
||||||
|
|
||||||
puts '== Installing dependencies =='
|
puts '== Update Bundler =='
|
||||||
system! 'gem install bundler --conservative'
|
system! "gem install bundler -v '~> 2.0'"
|
||||||
system('bundle check') || system!('bundle install')
|
|
||||||
|
|
||||||
# Install JavaScript dependencies if using Yarn
|
puts '== Installing gems =='
|
||||||
# system('bin/yarn')
|
system 'bundle check' or system! 'bundle install'
|
||||||
|
|
||||||
# puts "\n== Copying sample files =="
|
puts '== Install JavaScript dependencies =='
|
||||||
# unless File.exist?('config/database.yml')
|
system! 'bin/rake yarn:install'
|
||||||
# cp 'config/database.yml.sample', 'config/database.yml'
|
|
||||||
# end
|
|
||||||
|
|
||||||
puts "\n== Preparing database =="
|
puts '== Preparing database =='
|
||||||
system! 'bin/rails db:setup'
|
system! 'bin/rails db:setup'
|
||||||
|
|
||||||
puts "\n== Removing old logs and tempfiles =="
|
puts '== Removing old logs and tempfiles =='
|
||||||
system! 'bin/rails log:clear tmp:clear'
|
system! 'bin/rails log:clear tmp:clear'
|
||||||
|
|
||||||
puts "\n== Restarting application server =="
|
puts '== Restarting application server =='
|
||||||
system! 'bin/rails restart'
|
system! 'bin/rails restart'
|
||||||
end
|
end
|
||||||
|
|
34
bin/update
34
bin/update
|
@ -1,31 +1,33 @@
|
||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby
|
||||||
require 'fileutils'
|
# frozen_string_literal: true
|
||||||
include FileUtils
|
|
||||||
|
|
||||||
# path to your application root.
|
require 'fileutils'
|
||||||
APP_ROOT = File.expand_path('..', __dir__)
|
|
||||||
|
APP_ROOT = File.expand_path('..', __dir__).freeze
|
||||||
|
|
||||||
def system!(*args)
|
def system!(*args)
|
||||||
system(*args) || abort("\n== Command #{args} failed ==")
|
system(*args) or abort "\n== Command #{args} failed =="
|
||||||
end
|
end
|
||||||
|
|
||||||
chdir APP_ROOT do
|
FileUtils.chdir APP_ROOT do
|
||||||
# This script is a way to update your development environment automatically.
|
puts '== Update RubyGems =='
|
||||||
# Add necessary update steps to this file.
|
system! 'gem update --system'
|
||||||
|
|
||||||
puts '== Installing dependencies =='
|
puts '== Update Bundler =='
|
||||||
system! 'gem install bundler --conservative'
|
system! "gem install bundler -v '~> 2.0'"
|
||||||
system('bundle check') || system!('bundle install')
|
|
||||||
|
|
||||||
# Install JavaScript dependencies if using Yarn
|
puts '== Installing gems =='
|
||||||
# system('bin/yarn')
|
system 'bundle check' or system! 'bundle install'
|
||||||
|
|
||||||
puts "\n== Updating database =="
|
puts '== Install JavaScript dependencies =='
|
||||||
|
system! 'bin/rake yarn:install'
|
||||||
|
|
||||||
|
puts '== Updating database =='
|
||||||
system! 'bin/rails db:migrate'
|
system! 'bin/rails db:migrate'
|
||||||
|
|
||||||
puts "\n== Removing old logs and tempfiles =="
|
puts '== Removing old logs and tempfiles =='
|
||||||
system! 'bin/rails log:clear tmp:clear'
|
system! 'bin/rails log:clear tmp:clear'
|
||||||
|
|
||||||
puts "\n== Restarting application server =="
|
puts '== Restarting application server =='
|
||||||
system! 'bin/rails restart'
|
system! 'bin/rails restart'
|
||||||
end
|
end
|
||||||
|
|
Reference in a new issue