From c7375fd1625d592b2c342c8bc6092bc49d922f91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mehmet=20Emin=20=C4=B0NA=C3=87?= Date: Tue, 21 Jul 2015 22:18:13 +0300 Subject: [PATCH] Added bin/update script to update application automatically use system! fix changelog use bundle check first and use rake use system instead system! for bundle check --- guides/source/getting_started.md | 2 +- railties/CHANGELOG.md | 4 +++ .../generators/rails/app/templates/bin/update | 28 +++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 railties/lib/rails/generators/rails/app/templates/bin/update diff --git a/guides/source/getting_started.md b/guides/source/getting_started.md index dbbedc49ab..d51a27812a 100644 --- a/guides/source/getting_started.md +++ b/guides/source/getting_started.md @@ -166,7 +166,7 @@ of the files and folders that Rails created by default: | File/Folder | Purpose | | ----------- | ------- | |app/|Contains the controllers, models, views, helpers, mailers and assets for your application. You'll focus on this folder for the remainder of this guide.| -|bin/|Contains the rails script that starts your app and can contain other scripts you use to setup, deploy or run your application.| +|bin/|Contains the rails script that starts your app and can contain other scripts you use to setup, update, deploy or run your application.| |config/|Configure your application's routes, database, and more. This is covered in more detail in [Configuring Rails Applications](configuring.html).| |config.ru|Rack configuration for Rack based servers used to start the application.| |db/|Contains your current database schema, as well as the database migrations.| diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md index 734fe8bc7a..0f1aab9839 100644 --- a/railties/CHANGELOG.md +++ b/railties/CHANGELOG.md @@ -1,3 +1,7 @@ +* Add `bin/update` script to update development environment automatically. + + *Mehmet Emin İNAÇ* + * Fix STATS_DIRECTORIES already defined warning when running rake from within the top level directory of an engine that has a test app. diff --git a/railties/lib/rails/generators/rails/app/templates/bin/update b/railties/lib/rails/generators/rails/app/templates/bin/update new file mode 100644 index 0000000000..9830e6b29a --- /dev/null +++ b/railties/lib/rails/generators/rails/app/templates/bin/update @@ -0,0 +1,28 @@ +require 'pathname' +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +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' or system! 'bundle install' + + puts "\n== Updating database ==" + system! 'bin/rake db:migrate' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rake log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rake restart' +end