class AbtionScripts::Update

Public Class Methods

description() click to toggle source
# File lib/abtion_scripts/update.rb, line 10
def self.description
  "Updates your dev environment automatically"
end
help() click to toggle source
# File lib/abtion_scripts/update.rb, line 2
  def self.help
    <<-EOF
abtion update

This script is a way to update your development environment automatically.
EOF
  end

Public Instance Methods

run() click to toggle source
# File lib/abtion_scripts/update.rb, line 14
def run
  pull_git
  install_dependencies
  update_db
  remove_old_logs
  restart_servers
end

Private Instance Methods

install_dependencies() click to toggle source
# File lib/abtion_scripts/update.rb, line 30
def install_dependencies
  step "Installing dependencies" do
    if bundler?
      system! 'command -v bundler > /dev/null || gem install bundler --conservative'
      system! 'bundle install'
    end

    if yarn?
      system! "yarn install"
    end
  end
end
pull_git() click to toggle source
# File lib/abtion_scripts/update.rb, line 24
def pull_git
  step "Pulling from git" do
    system! "git pull --rebase"
  end
end
remove_old_logs() click to toggle source
# File lib/abtion_scripts/update.rb, line 51
def remove_old_logs
  if rails?
    step "Removing old logs and tempfiles" do
      system! 'rake log:clear tmp:clear'
    end
  end
end
restart_rails() click to toggle source
# File lib/abtion_scripts/update.rb, line 63
def restart_rails
  step "Attempting to restart Rails" do
    output = `bin/rails restart`

    if $?.exitstatus > 0
      puts colorize(
        :light_red,
        "skipping restart, not supported in this version of Rails (needs >= 6)"
      )
    else
      puts output
    end
  end
end
restart_servers() click to toggle source
# File lib/abtion_scripts/update.rb, line 59
def restart_servers
  restart_rails if rails?
end
update_db() click to toggle source
# File lib/abtion_scripts/update.rb, line 43
def update_db
  if rails?
    step "Updating database" do
      system! 'rake db:migrate db:test:prepare'
    end
  end
end