1
0
Fork 0

Improve "bin/setup" and "bin/update"

This commit is contained in:
Alex Kotov 2019-04-27 17:02:25 +05:00
parent 37f7e98830
commit 553b4fbbd5
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
2 changed files with 35 additions and 36 deletions

View File

@ -1,36 +1,33 @@
#!/usr/bin/env ruby
require 'fileutils'
include FileUtils
# frozen_string_literal: true
# path to your application root.
APP_ROOT = File.expand_path('..', __dir__)
require 'fileutils'
APP_ROOT = File.expand_path('..', __dir__).freeze
def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
system(*args) or abort "\n== Command #{args} failed =="
end
chdir APP_ROOT do
# This script is a starting point to setup your application.
# Add necessary setup steps to this file.
FileUtils.chdir APP_ROOT do
puts '== Update RubyGems =='
system! 'gem update --system'
puts '== Installing dependencies =='
system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install')
puts '== Update Bundler =='
system! "gem install bundler -v '~> 2.0'"
# Install JavaScript dependencies if using Yarn
# system('bin/yarn')
puts '== Installing gems =='
system 'bundle check' or system! 'bundle install'
# puts "\n== Copying sample files =="
# unless File.exist?('config/database.yml')
# cp 'config/database.yml.sample', 'config/database.yml'
# end
puts '== Install JavaScript dependencies =='
system! 'bin/rake yarn:install'
puts "\n== Preparing database =="
puts '== Preparing database =='
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'
puts "\n== Restarting application server =="
puts '== Restarting application server =='
system! 'bin/rails restart'
end

View File

@ -1,31 +1,33 @@
#!/usr/bin/env ruby
require 'fileutils'
include FileUtils
# frozen_string_literal: true
# path to your application root.
APP_ROOT = File.expand_path('..', __dir__)
require 'fileutils'
APP_ROOT = File.expand_path('..', __dir__).freeze
def system!(*args)
system(*args) || abort("\n== Command #{args} failed ==")
system(*args) or abort "\n== Command #{args} failed =="
end
chdir APP_ROOT do
# This script is a way to update your development environment automatically.
# Add necessary update steps to this file.
FileUtils.chdir APP_ROOT do
puts '== Update RubyGems =='
system! 'gem update --system'
puts '== Installing dependencies =='
system! 'gem install bundler --conservative'
system('bundle check') || system!('bundle install')
puts '== Update Bundler =='
system! "gem install bundler -v '~> 2.0'"
# Install JavaScript dependencies if using Yarn
# system('bin/yarn')
puts '== Installing gems =='
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'
puts "\n== Removing old logs and tempfiles =="
puts '== Removing old logs and tempfiles =='
system! 'bin/rails log:clear tmp:clear'
puts "\n== Restarting application server =="
puts '== Restarting application server =='
system! 'bin/rails restart'
end