#!/usr/bin/env ruby require "fileutils" APP_ROOT = File.expand_path("..", __dir__) def system!(*args) system(*args, exception: true) end if ENV["RAILS_ENV"] == "production" puts "RAILS_ENV is production; bailing out" exit end FileUtils.chdir APP_ROOT do puts "== Installing dependencies ==" system "mise install" system("bundle check") || system!("bundle install") puts "\n== Preparing database ==" if ARGV.include?("--reset") system "rm -rf ./storage/{db,files}" system! "bin/rails db:reset" end system! "bin/rails db:prepare" puts "\n== Removing old logs and tempfiles ==" system! "bin/rails log:clear tmp:clear" puts "\n== Restarting services ==" system! "bin/rails restart" end