Add backup task; this will protect likely modified files from overwriting by the Rails 3 generator
This commit is contained in:
parent
87f2c7f762
commit
9d59bbc0fd
@ -4,6 +4,8 @@ require 'gemfile_generator'
|
||||
require 'application_checker'
|
||||
require 'new_configuration_generator'
|
||||
|
||||
require 'fileutils'
|
||||
|
||||
namespace :rails do
|
||||
namespace :upgrade do
|
||||
desc "Runs a battery of checks on your Rails 2.x app and generates a report on required upgrades for Rails 3"
|
||||
@ -35,5 +37,39 @@ namespace :rails do
|
||||
|
||||
puts new_config
|
||||
end
|
||||
|
||||
CLEAR = "\e[0m"
|
||||
CYAN = "\e[36m"
|
||||
WHITE = "\e[37m"
|
||||
|
||||
desc "Backs up your likely modified files so you can run the Rails 3 generator on your app with little risk"
|
||||
task :backup do
|
||||
files = [".gitignore",
|
||||
"app/controllers/application_controller.rb",
|
||||
"app/helpers/application_helper.rb",
|
||||
"config/routes.rb",
|
||||
"config/environment.rb",
|
||||
"config/environments/*",
|
||||
"config/database.yml",
|
||||
"doc/README_FOR_APP",
|
||||
"test/test_helper.rb"]
|
||||
|
||||
puts
|
||||
files.each do |f|
|
||||
if File.exist?(f)
|
||||
puts "#{CYAN}* #{CLEAR}backing up #{WHITE}#{f}#{CLEAR} to #{WHITE}#{f}.rails2#{CLEAR}"
|
||||
FileUtils.cp(f, "#{f}.rails2")
|
||||
end
|
||||
end
|
||||
|
||||
puts
|
||||
puts "This is a list of the files analyzed and backed up (if they existed);\nyou will probably not want the generator to replace them since\nyou probably modified them (but now they're safe if you accidentally do!)."
|
||||
puts
|
||||
|
||||
files.each do |f|
|
||||
puts "#{CYAN}- #{CLEAR}#{f}"
|
||||
end
|
||||
puts
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user