From 11078dddbb94c620bff13a7c656390392b2007f8 Mon Sep 17 00:00:00 2001 From: Javan Makhmali Date: Mon, 23 May 2016 09:37:16 -0400 Subject: [PATCH 1/2] Build action_cable.js with Blade --- Gemfile | 2 +- Gemfile.lock | 16 ++++---- actioncable/Rakefile | 40 ++----------------- .../javascripts/action_cable.coffee.erb | 7 +--- actioncable/blade.yml | 6 +++ 5 files changed, 21 insertions(+), 50 deletions(-) diff --git a/Gemfile b/Gemfile index 75adda01af..776d39d569 100644 --- a/Gemfile +++ b/Gemfile @@ -64,7 +64,7 @@ group :cable do gem 'redis', require: false gem 'faye-websocket', require: false - gem 'blade', '~> 0.5.1', require: false + gem 'blade', '~> 0.5.5', require: false end # Add your own local bundler stuff. diff --git a/Gemfile.lock b/Gemfile.lock index 6761292398..4a9ac10244 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -116,15 +116,16 @@ GEM bcrypt (3.1.11-x86-mingw32) beaneater (1.0.0) benchmark-ips (2.6.1) - blade (0.5.1) + blade (0.5.5) activesupport (>= 3.0.0) blade-qunit_adapter (~> 1.20.0) - coffee-script (~> 2.4.0) - coffee-script-source (~> 1.10.0) + coffee-script + coffee-script-source curses (~> 1.0.0) - eventmachine (~> 1.2.0) - faye (~> 1.1.1) - sprockets (~> 3.6.0) + eventmachine + faye + sprockets (>= 3.0) + sprockets-export (~> 0.9.1) thin (~> 1.6.0) thor (~> 0.19.1) useragent (~> 0.16.7) @@ -284,6 +285,7 @@ GEM sprockets (3.6.0) concurrent-ruby (~> 1.0) rack (> 1, < 3) + sprockets-export (0.9.1) sprockets-rails (3.0.4) actionpack (>= 4.0) activesupport (>= 4.0) @@ -331,7 +333,7 @@ DEPENDENCIES backburner bcrypt (~> 3.1.11) benchmark-ips - blade (~> 0.5.1) + blade (~> 0.5.5) byebug coffee-rails! dalli (>= 2.2.1) diff --git a/actioncable/Rakefile b/actioncable/Rakefile index 58c18dd457..aa62265ac9 100644 --- a/actioncable/Rakefile +++ b/actioncable/Rakefile @@ -1,15 +1,14 @@ require 'rake/testtask' require 'pathname' -require 'sprockets' -require 'coffee-script' require 'action_cable' +require 'blade' dir = File.dirname(__FILE__) task :default => :test task :package => "assets:compile" -task "package:clean" => "assets:clean" +task "package:clean" Rake::TestTask.new do |t| t.libs << "test" @@ -27,44 +26,13 @@ namespace :test do end task :javascript do - require 'blade' Blade.start(interface: :runner) end end namespace :assets do - root_path = Pathname.new(dir) - destination_path = root_path.join("lib/assets/compiled") - - desc "Compile dist/action_cable.js" + desc "Compile Action Cable assets" task :compile do - puts 'Compiling Action Cable assets...' - - precompile_list = %w(action_cable.js) - - environment = Sprockets::Environment.new - environment.gzip = false - Pathname.glob(root_path.join("app/assets/*/")) do |subdir| - environment.append_path subdir - end - - compile_path = root_path.join("tmp/sprockets") - compile_path.rmtree if compile_path.exist? - compile_path.mkpath - - manifest = Sprockets::Manifest.new(environment.index, compile_path) - manifest.compile(precompile_list) - - destination_path.rmtree if destination_path.exist? - manifest.assets.each do |path, fingerprint_path| - destination_path.join(path).dirname.mkpath - FileUtils.cp(compile_path.join(fingerprint_path), destination_path.join(path)) - end - - puts 'Done' - end - - task :clean do - destination_path.rmtree if destination_path.exist? + Blade.build end end diff --git a/actioncable/app/assets/javascripts/action_cable.coffee.erb b/actioncable/app/assets/javascripts/action_cable.coffee.erb index 32f9f517f4..210a3ae17e 100644 --- a/actioncable/app/assets/javascripts/action_cable.coffee.erb +++ b/actioncable/app/assets/javascripts/action_cable.coffee.erb @@ -1,3 +1,4 @@ +#= export ActionCable #= require_self #= require ./action_cable/consumer @@ -33,9 +34,3 @@ if @debugging messages.push(Date.now()) console.log("[ActionCable]", messages...) - -# NOTE: We expose ActionCable as a browser global so we can reference it -# internally without concern for how the module is loaded. -window?.ActionCable = @ActionCable - -module?.exports = @ActionCable diff --git a/actioncable/blade.yml b/actioncable/blade.yml index 7980f3d101..9cdb318c97 100644 --- a/actioncable/blade.yml +++ b/actioncable/blade.yml @@ -5,3 +5,9 @@ load_paths: logical_paths: - test.js + +build: + logical_paths: + - action_cable.js + path: lib/assets/compiled + clean: true From d12209cad2d8961f396a6e7cbd0ee9437b9751ef Mon Sep 17 00:00:00 2001 From: Javan Makhmali Date: Mon, 23 May 2016 17:05:44 -0400 Subject: [PATCH 2/2] Remove package:clean task MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduced in d6f2000a67cc63aa67414c75ce77de671824ec52 and was only used by Action Cable. Now handled by Action Cable’s assets:compile task. --- actioncable/Rakefile | 1 - actionmailer/Rakefile | 1 - actionpack/Rakefile | 1 - actionview/Rakefile | 1 - activejob/Rakefile | 1 - activemodel/Rakefile | 1 - activerecord/Rakefile | 1 - activesupport/Rakefile | 1 - railties/Rakefile | 1 - tasks/release.rb | 1 - 10 files changed, 10 deletions(-) diff --git a/actioncable/Rakefile b/actioncable/Rakefile index aa62265ac9..b0e9c0a4a8 100644 --- a/actioncable/Rakefile +++ b/actioncable/Rakefile @@ -8,7 +8,6 @@ dir = File.dirname(__FILE__) task :default => :test task :package => "assets:compile" -task "package:clean" Rake::TestTask.new do |t| t.libs << "test" diff --git a/actionmailer/Rakefile b/actionmailer/Rakefile index 54e6cff48d..416c9ee33a 100644 --- a/actionmailer/Rakefile +++ b/actionmailer/Rakefile @@ -4,7 +4,6 @@ desc "Default Task" task default: [ :test ] task :package -task "package:clean" # Run the unit tests Rake::TestTask.new { |t| diff --git a/actionpack/Rakefile b/actionpack/Rakefile index 37a269cffd..4a05c067a9 100644 --- a/actionpack/Rakefile +++ b/actionpack/Rakefile @@ -6,7 +6,6 @@ desc "Default Task" task :default => :test task :package -task "package:clean" # Run the unit tests Rake::TestTask.new do |t| diff --git a/actionview/Rakefile b/actionview/Rakefile index d41030c650..f0f9bda3e4 100644 --- a/actionview/Rakefile +++ b/actionview/Rakefile @@ -4,7 +4,6 @@ desc "Default Task" task :default => :test task :package -task "package:clean" # Run the unit tests diff --git a/activejob/Rakefile b/activejob/Rakefile index f32c4d2fb2..e47f17b740 100644 --- a/activejob/Rakefile +++ b/activejob/Rakefile @@ -8,7 +8,6 @@ task default: :test task test: 'test:default' task :package -task "package:clean" namespace :test do desc 'Run all adapter tests' diff --git a/activemodel/Rakefile b/activemodel/Rakefile index 9982d49bcb..036815a987 100644 --- a/activemodel/Rakefile +++ b/activemodel/Rakefile @@ -5,7 +5,6 @@ dir = File.dirname(__FILE__) task :default => :test task :package -task "package:clean" Rake::TestTask.new do |t| t.libs << "test" diff --git a/activerecord/Rakefile b/activerecord/Rakefile index 46df733cfe..012db35765 100644 --- a/activerecord/Rakefile +++ b/activerecord/Rakefile @@ -21,7 +21,6 @@ desc 'Run mysql2, sqlite, and postgresql tests by default' task :default => :test task :package -task "package:clean" desc 'Run mysql2, sqlite, and postgresql tests' task :test do diff --git a/activesupport/Rakefile b/activesupport/Rakefile index 33ee62aa1b..7b56e36abf 100644 --- a/activesupport/Rakefile +++ b/activesupport/Rakefile @@ -3,7 +3,6 @@ require 'rake/testtask' task :default => :test task :package -task "package:clean" Rake::TestTask.new do |t| t.libs << 'test' diff --git a/railties/Rakefile b/railties/Rakefile index 3421d9b464..db23bbabaa 100644 --- a/railties/Rakefile +++ b/railties/Rakefile @@ -3,7 +3,6 @@ require 'rake/testtask' task :default => :test task :package -task "package:clean" desc "Run all unit tests" task :test => 'test:isolated' diff --git a/tasks/release.rb b/tasks/release.rb index e54b03eafa..4a1ed04478 100644 --- a/tasks/release.rb +++ b/tasks/release.rb @@ -13,7 +13,6 @@ directory "pkg" task :clean do rm_f gem - sh "cd #{framework} && bundle exec rake package:clean" unless framework == "rails" end task :update_versions do