setup 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #!/usr/bin/env ruby
  2. require "fileutils"
  3. # path to your application root.
  4. APP_ROOT = File.expand_path('..', __dir__)
  5. def system!(*args)
  6. system(*args) || abort("\n== Command #{args} failed ==")
  7. end
  8. FileUtils.chdir APP_ROOT do
  9. # This script is a way to set up or update your development environment automatically.
  10. # This script is idempotent, so that you can run it at any time and get an expectable outcome.
  11. # Add necessary setup steps to this file.
  12. puts '== Installing dependencies =='
  13. system! 'gem install bundler --conservative'
  14. system('bundle check') || system!('bundle install')
  15. # Install JavaScript dependencies
  16. system! 'bin/yarn'
  17. # puts "\n== Copying sample files =="
  18. # unless File.exist?('config/database.yml')
  19. # FileUtils.cp 'config/database.yml.sample', 'config/database.yml'
  20. # end
  21. puts "\n== Preparing database =="
  22. system! 'bin/rails db:prepare'
  23. puts "\n== Removing old logs and tempfiles =="
  24. system! 'bin/rails log:clear tmp:clear'
  25. puts "\n== Restarting application server =="
  26. system! 'bin/rails restart'
  27. end