From 7ba6b759106ba0cc4fdc67c2277e398c3d407d75 Mon Sep 17 00:00:00 2001 From: Yves Senn Date: Tue, 20 May 2014 10:14:20 +0200 Subject: `bin/setup` script to bootstrap applications. --- guides/source/getting_started.md | 2 +- railties/CHANGELOG.md | 4 ++++ .../rails/generators/rails/app/templates/bin/setup | 28 ++++++++++++++++++++++ railties/test/generators/app_generator_test.rb | 1 + 4 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 railties/lib/rails/generators/rails/app/templates/bin/setup diff --git a/guides/source/getting_started.md b/guides/source/getting_started.md index 530232f3f3..d9619bbc21 100644 --- a/guides/source/getting_started.md +++ b/guides/source/getting_started.md @@ -163,7 +163,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 deploy or run your application.| +|bin/|Contains the rails script that starts your app and can contain other scripts you use to setup, 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 8a41f160fa..b328619646 100644 --- a/railties/CHANGELOG.md +++ b/railties/CHANGELOG.md @@ -1,3 +1,7 @@ +* Add `bin/setup` script to bootstrap an application. + + *Yves Senn* + * Replace double quotes with single quotes while adding an entry into Gemfile. *Alexander Belaev* diff --git a/railties/lib/rails/generators/rails/app/templates/bin/setup b/railties/lib/rails/generators/rails/app/templates/bin/setup new file mode 100644 index 0000000000..3d5f443406 --- /dev/null +++ b/railties/lib/rails/generators/rails/app/templates/bin/setup @@ -0,0 +1,28 @@ +require 'pathname' + +# path to your application root. +APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) + +Dir.chdir APP_ROOT do + # This script is a starting point to setup your application. + # Add necessary setup steps to this file: + + puts "== Installing dependencies ==" + system "gem install bundler --conservative" + system "bundle install" + + # puts "\n== Copying sample files ==" + # unless File.exists?("config/database.yml") + # system "cp config/database.yml.sample config/database.yml" + # end + + puts "\n== Preparing database ==" + system "bin/rake db:setup" + + puts "\n== Removing old logs and tempfiles ==" + system "rm -f log/*" + system "rm -rf tmp/cache" + + puts "\n== Restarting application server ==" + system "touch tmp/restart.txt" +end diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index 1cbbf62459..74cff08676 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -21,6 +21,7 @@ DEFAULT_APP_FILES = %w( bin/bundle bin/rails bin/rake + bin/setup config/environments config/initializers config/locales -- cgit v1.2.3