lib/tasks/framework.rake in radiant-0.8.2 vs lib/tasks/framework.rake in radiant-0.9.0.rc2

- old
+ new

@@ -59,12 +59,20 @@ desc "Unlock this application from freeze of gems or edge and return to a fluid use of system gems" task :unfreeze do rm_rf "vendor/radiant" end - desc "Update both configs, scripts and public/javascripts from Radiant" - task :update => [ "update:scripts", "update:javascripts", "update:configs", "update:images", "update:stylesheets" ] + desc "Update configs, scripts, sass, stylesheets and javascripts from Radiant." + task :update do + tasks = %w{scripts javascripts configs initializers images sass stylesheets cached_assets} + tasks = tasks & ENV['ONLY'].split(',') if ENV['ONLY'] + tasks = tasks - ENV['EXCEPT'].split(',') if ENV['EXCEPT'] + tasks.each do |task| + puts "* Updating #{task}" + Rake::Task["radiant:update:#{task}"].invoke + end + end namespace :update do desc "Add new scripts to the instance script/ directory" task :scripts do local_base = "script" @@ -87,17 +95,23 @@ desc "Update your javascripts from your current radiant install" task :javascripts do FileUtils.mkdir_p("#{RAILS_ROOT}/public/javascripts/admin/") copy_javascripts = proc do |project_dir, scripts| - scripts.reject!{|s| File.basename(s) == 'application.js'} if File.exists?(project_dir + 'application.js') + scripts.reject!{|s| File.basename(s) == 'overrides.js'} if File.exists?(project_dir + 'overrides.js') FileUtils.cp(scripts, project_dir) end copy_javascripts[RAILS_ROOT + '/public/javascripts/', Dir["#{File.dirname(__FILE__)}/../../public/javascripts/*.js"]] copy_javascripts[RAILS_ROOT + '/public/javascripts/admin/', Dir["#{File.dirname(__FILE__)}/../../public/javascripts/admin/*.js"]] end + desc "Update the cached assets for the admin UI" + task :cached_assets do + dir = File.join(Rails.root, 'public', 'javascripts', 'admin') + TaskSupport.cache_files(dir, TaskSupport.find_admin_js, 'all.js') + end + desc "Update config/boot.rb from your current radiant install" task :configs do require 'erb' FileUtils.cp("#{File.dirname(__FILE__)}/../generators/instance/templates/instance_boot.rb", RAILS_ROOT + '/config/boot.rb') instances = { @@ -123,13 +137,13 @@ :development => "#{RAILS_ROOT}/config/environments/development.bak", :test => "#{RAILS_ROOT}/config/environments/test.bak", :production => "#{RAILS_ROOT}/config/environments/production.bak" } @warning_start = "** WARNING ** -The following files have been changed in Radiant 0.8.0. Your originals -have been backed up with .bak extensions. Please copy your customizations -to the new files:" +The following files have been changed in Radiant. Your originals have +been backed up with .bak extensions. Please copy your customizations to +the new files:" [:env, :development, :test, :production].each do |env_type| File.open(tmps[env_type], 'w') do |f| app_name = File.basename(File.expand_path(RAILS_ROOT)) f.write ERB.new(File.read(gens[env_type])).result(binding) end @@ -161,11 +175,33 @@ end desc "Update admin stylesheets from your current radiant install" task :stylesheets do project_dir = RAILS_ROOT + '/public/stylesheets/admin/' - stylesheets = Dir["#{File.dirname(__FILE__)}/../../public/stylesheets/admin/*.css"] - FileUtils.cp(stylesheets, project_dir) + + copy_stylesheets = proc do |project_dir, styles| + styles.reject!{|s| File.basename(s) == 'overrides.css'} if File.exists?(project_dir + 'overrides.css') + FileUtils.cp(styles, project_dir) + end + copy_stylesheets[RAILS_ROOT + '/public/stylesheets/admin/',Dir["#{File.dirname(__FILE__)}/../../public/stylesheets/admin/*.css"]] + end + + desc "Update admin sass files from your current radiant install" + task :sass do + copy_sass = proc do |project_dir, sass_files| + sass_files.reject!{|s| File.basename(s) == 'overrides.sass'} if File.exists?(project_dir + 'overrides.sass') || File.exists?(project_dir + '../overrides.css') + FileUtils.mkpath(project_dir) + FileUtils.cp_r(sass_files, project_dir) + end + copy_sass[RAILS_ROOT + '/public/stylesheets/sass/admin/', Dir["#{RADIANT_ROOT}/public/stylesheets/sass/admin/*"]] + end + + desc "Update initializers from your current radiant install" + task :initializers do + project_dir = RAILS_ROOT + '/config/initializers/' + FileUtils.mkpath project_dir + initializers = Dir["#{File.dirname(__FILE__)}/../../config/initializers/*.rb"] + FileUtils.cp(initializers, project_dir) end end end end \ No newline at end of file