aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib
diff options
context:
space:
mode:
authorDavid Stosik <david.stosik+git-noreply@gmail.com>2018-06-15 16:24:58 +0900
committerKasper Timm Hansen <kaspth@gmail.com>2019-04-17 00:45:17 +0200
commit6f73a31c0ca4438c164152695152a9c947eae912 (patch)
tree523190f85182b1eacebb9cd569d64f095ab7c3f0 /railties/lib
parent7424d2fd2e3bd21386916316b41c8936c13069a3 (diff)
downloadrails-6f73a31c0ca4438c164152695152a9c947eae912.tar.gz
rails-6f73a31c0ca4438c164152695152a9c947eae912.tar.bz2
rails-6f73a31c0ca4438c164152695152a9c947eae912.zip
Factorize bin/update in bin/setup, and make bin/setup idempotent
`bin/setup` and `bin/update` are currently almost the same file. The only thing that keeps them apart is that one is running `bin/rails db:setup` and the other `bin/rails db:migrate`. I'm suggesting here that they should be a unique script, which needs to be idempotent. - New to a project, need to get started? `bin/setup` - Need to install new dependencies that were added recently? `bin/setup`. Before deprecating `bin/update`, I'm suggesting we just have it call `bin/setup`.
Diffstat (limited to 'railties/lib')
-rw-r--r--railties/lib/rails/generators/rails/app/templates/bin/setup.tt5
-rw-r--r--railties/lib/rails/generators/rails/app/templates/bin/update.tt33
2 files changed, 3 insertions, 35 deletions
diff --git a/railties/lib/rails/generators/rails/app/templates/bin/setup.tt b/railties/lib/rails/generators/rails/app/templates/bin/setup.tt
index 3f73bae3da..5928deb6aa 100644
--- a/railties/lib/rails/generators/rails/app/templates/bin/setup.tt
+++ b/railties/lib/rails/generators/rails/app/templates/bin/setup.tt
@@ -8,7 +8,8 @@ def system!(*args)
end
FileUtils.chdir APP_ROOT do
- # This script is a starting point to setup your application.
+ # This script is a way to setup or update your development environment automatically.
+ # This script is idempotent, so that you can run it at anytime and get an expectable outcome.
# Add necessary setup steps to this file.
puts '== Installing dependencies =='
@@ -27,7 +28,7 @@ FileUtils.chdir APP_ROOT do
# end
puts "\n== Preparing database =="
- system! 'bin/rails db:setup'
+ system! 'bin/rails db:prepare'
<% end -%>
puts "\n== Removing old logs and tempfiles =="
diff --git a/railties/lib/rails/generators/rails/app/templates/bin/update.tt b/railties/lib/rails/generators/rails/app/templates/bin/update.tt
deleted file mode 100644
index 03b77d0d46..0000000000
--- a/railties/lib/rails/generators/rails/app/templates/bin/update.tt
+++ /dev/null
@@ -1,33 +0,0 @@
-require 'fileutils'
-
-# path to your application root.
-APP_ROOT = File.expand_path('..', __dir__)
-
-def system!(*args)
- system(*args) || abort("\n== Command #{args} failed ==")
-end
-
-FileUtils.chdir APP_ROOT do
- # This script is a way to update your development environment automatically.
- # Add necessary update steps to this file.
-
- puts '== Installing dependencies =='
- system! 'gem install bundler --conservative'
- system('bundle check') || system!('bundle install')
-<% unless options.skip_javascript? -%>
-
- # Install JavaScript dependencies
- # system('bin/yarn')
-<% end -%>
-<% unless options.skip_active_record? -%>
-
- puts "\n== Updating database =="
- system! 'rails db:migrate'
-<% end -%>
-
- puts "\n== Removing old logs and tempfiles =="
- system! 'rails log:clear tmp:clear'
-
- puts "\n== Restarting application server =="
- system! 'rails restart'
-end