Convert to conventional Rails style

This commit is contained in:
David Heinemeier Hansson
2025-04-21 15:23:08 +02:00
parent b6584ed655
commit 2bfead0381
+25 -20
View File
@@ -1,26 +1,31 @@
#!/usr/bin/env bash
set -eo pipefail
#!/usr/bin/env ruby
require "fileutils"
# Use application binstubs
export PATH="./bin:$PATH"
APP_ROOT = File.expand_path("..", __dir__)
announce() {
printf "\n--- $@\n"
}
def system!(*args)
system(*args, exception: true)
end
announce "Installing dependencies"
gem install bundler --conservative
bundle check || bundle install
FileUtils.chdir APP_ROOT do
# This script is a way to set up or update your development environment automatically.
# This script is idempotent, so that you can run it at any time and get an expectable outcome.
# Add necessary setup steps to this file.
announce "Preparing database"
if [[ $* == *--reset* ]]; then
rails db:reset
else
rails db:prepare
fi
puts "== Installing dependencies =="
system("gem install bundler --conservative")
system("bundle check") || system!("bundle install")
announce "Removing old logs and tempfiles"
rails log:clear tmp:clear
puts "\n== Preparing database =="
system! "bin/rails db:prepare"
system! "bin/rails db:reset" if ARGV.include?("--reset")
echo
echo "Start developing with bin/dev"
puts "\n== Removing old logs and tempfiles =="
system! "bin/rails log:clear tmp:clear"
unless ARGV.include?("--skip-server")
puts "\n== Starting development server =="
STDOUT.flush # flush the output before exec(2) so that it displays
exec "bin/dev"
end
end