2017-08-14 13:08:09 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-02-13 00:14:23 -05:00
|
|
|
namespace :app do
|
2013-07-13 08:30:58 -04:00
|
|
|
desc "Update configs and some other initially generated files (or use just update:configs or update:bin)"
|
2016-06-18 21:27:37 -04:00
|
|
|
task update: [ "update:configs", "update:bin", "update:upgrade_guide_info" ]
|
2005-11-07 13:09:31 -05:00
|
|
|
|
2011-07-23 05:07:25 -04:00
|
|
|
desc "Applies the template supplied by LOCATION=(/path/to/template) or URL"
|
2014-03-08 09:51:49 -05:00
|
|
|
task template: :environment do
|
2009-04-20 12:01:32 -04:00
|
|
|
template = ENV["LOCATION"]
|
2011-07-23 05:07:25 -04:00
|
|
|
raise "No LOCATION value given. Please set LOCATION either as path to a file or a URL" if template.blank?
|
2009-04-20 12:01:32 -04:00
|
|
|
template = File.expand_path(template) if template !~ %r{\A[A-Za-z][A-Za-z0-9+\-\.]*://}
|
2017-10-21 09:08:33 -04:00
|
|
|
require "rails/generators"
|
|
|
|
require "rails/generators/rails/app/app_generator"
|
2017-08-12 07:31:46 -04:00
|
|
|
generator = Rails::Generators::AppGenerator.new [Rails.root], {}, { destination_root: Rails.root }
|
2014-02-14 14:38:26 -05:00
|
|
|
generator.apply template, verbose: false
|
2008-12-06 21:40:23 -05:00
|
|
|
end
|
|
|
|
|
2010-05-14 17:54:13 -04:00
|
|
|
namespace :templates do
|
2010-06-09 16:19:03 -04:00
|
|
|
# desc "Copy all the templates from rails to the application directory for customization. Already existing local copies will be overwritten"
|
2010-05-14 17:54:13 -04:00
|
|
|
task :copy do
|
2017-05-15 10:17:28 -04:00
|
|
|
generators_lib = File.expand_path("../generators", __dir__)
|
2010-05-14 17:54:13 -04:00
|
|
|
project_templates = "#{Rails.root}/lib/templates"
|
|
|
|
|
|
|
|
default_templates = { "erb" => %w{controller mailer scaffold},
|
2012-06-09 03:45:18 -04:00
|
|
|
"rails" => %w{controller helper scaffold_controller assets} }
|
2010-05-14 17:54:13 -04:00
|
|
|
|
|
|
|
default_templates.each do |type, names|
|
|
|
|
local_template_type_dir = File.join(project_templates, type)
|
2016-04-11 10:53:21 -04:00
|
|
|
mkdir_p local_template_type_dir, verbose: false
|
2010-05-14 17:54:13 -04:00
|
|
|
|
|
|
|
names.each do |name|
|
|
|
|
dst_name = File.join(local_template_type_dir, name)
|
|
|
|
src_name = File.join(generators_lib, type, name, "templates")
|
2016-04-11 10:53:21 -04:00
|
|
|
cp_r src_name, dst_name, verbose: false
|
2010-05-14 17:54:13 -04:00
|
|
|
end
|
|
|
|
end
|
2015-05-27 19:48:24 -04:00
|
|
|
end
|
2010-05-14 17:54:13 -04:00
|
|
|
end
|
|
|
|
|
2006-02-26 23:38:39 -05:00
|
|
|
namespace :update do
|
2017-10-21 09:08:33 -04:00
|
|
|
require "rails/app_updater"
|
2006-04-07 14:21:52 -04:00
|
|
|
|
2010-06-09 16:19:03 -04:00
|
|
|
# desc "Update config/boot.rb from your current rails install"
|
2009-12-01 16:27:59 -05:00
|
|
|
task :configs do
|
2017-06-25 16:46:12 -04:00
|
|
|
Rails::AppUpdater.invoke_from_app_generator :create_boot_file
|
|
|
|
Rails::AppUpdater.invoke_from_app_generator :update_config_files
|
2009-12-01 16:27:59 -05:00
|
|
|
end
|
|
|
|
|
2013-01-06 18:13:47 -05:00
|
|
|
# desc "Adds new executables to the application bin/ directory"
|
|
|
|
task :bin do
|
2017-06-25 16:46:12 -04:00
|
|
|
Rails::AppUpdater.invoke_from_app_generator :update_bin_files
|
2009-07-16 05:17:19 -04:00
|
|
|
end
|
2016-06-18 21:27:37 -04:00
|
|
|
|
|
|
|
task :upgrade_guide_info do
|
2017-06-25 16:46:12 -04:00
|
|
|
Rails::AppUpdater.invoke_from_app_generator :display_upgrade_guide_info
|
2016-06-18 21:27:37 -04:00
|
|
|
end
|
2005-11-07 13:09:31 -05:00
|
|
|
end
|
2006-03-13 13:45:40 -05:00
|
|
|
end
|