summaryrefslogtreecommitdiffhomepage
path: root/bin/setup
diff options
context:
space:
mode:
authorAdam Malczewski <[email protected]>2026-03-30 19:03:22 +0900
committerAdam Malczewski <[email protected]>2026-03-30 19:03:22 +0900
commit952c6b565832dd0dbcef7a9a80edc871f79e15a8 (patch)
tree698db27a35f8f40356a0381a32a02767481dc6a9 /bin/setup
downloaddispatch-api-952c6b565832dd0dbcef7a9a80edc871f79e15a8.tar.gz
dispatch-api-952c6b565832dd0dbcef7a9a80edc871f79e15a8.zip
Diffstat (limited to 'bin/setup')
-rwxr-xr-xbin/setup35
1 files changed, 35 insertions, 0 deletions
diff --git a/bin/setup b/bin/setup
new file mode 100755
index 0000000..81be011
--- /dev/null
+++ b/bin/setup
@@ -0,0 +1,35 @@
+#!/usr/bin/env ruby
+require "fileutils"
+
+APP_ROOT = File.expand_path("..", __dir__)
+
+def system!(*args)
+ system(*args, exception: true)
+end
+
+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.
+
+ puts "== Installing dependencies =="
+ system("bundle check") || system!("bundle install")
+
+ # puts "\n== Copying sample files =="
+ # unless File.exist?("config/database.yml")
+ # FileUtils.cp "config/database.yml.sample", "config/database.yml"
+ # end
+
+ puts "\n== Preparing database =="
+ system! "bin/rails db:prepare"
+ system! "bin/rails db:reset" if ARGV.include?("--reset")
+
+ 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