aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2016-02-01 04:31:03 +1030
committerMatthew Draper <matthew@trebex.net>2016-02-01 05:03:03 +1030
commitd6f2000a67cc63aa67414c75ce77de671824ec52 (patch)
tree86ddb70130bc3d40fb0a9aeb125108f47b8e07b1
parentca9603fc35d123d1c8490096dc0447a91f3e3c18 (diff)
downloadrails-d6f2000a67cc63aa67414c75ce77de671824ec52.tar.gz
rails-d6f2000a67cc63aa67414c75ce77de671824ec52.tar.bz2
rails-d6f2000a67cc63aa67414c75ce77de671824ec52.zip
Wrangle the asset build into something that sounds more general
-rw-r--r--actioncable/.gitignore2
-rw-r--r--actioncable/Rakefile35
-rw-r--r--actioncable/app/assets/javascripts/action_cable.coffee.erb (renamed from actioncable/app/assets/javascripts/action_cable/source/index.coffee.erb)2
-rw-r--r--actioncable/app/assets/javascripts/action_cable/connection.coffee (renamed from actioncable/app/assets/javascripts/action_cable/source/connection.coffee)0
-rw-r--r--actioncable/app/assets/javascripts/action_cable/connection_monitor.coffee (renamed from actioncable/app/assets/javascripts/action_cable/source/connection_monitor.coffee)0
-rw-r--r--actioncable/app/assets/javascripts/action_cable/consumer.coffee (renamed from actioncable/app/assets/javascripts/action_cable/source/consumer.coffee)0
-rw-r--r--actioncable/app/assets/javascripts/action_cable/index.js1
-rw-r--r--actioncable/app/assets/javascripts/action_cable/subscription.coffee (renamed from actioncable/app/assets/javascripts/action_cable/source/subscription.coffee)0
-rw-r--r--actioncable/app/assets/javascripts/action_cable/subscriptions.coffee (renamed from actioncable/app/assets/javascripts/action_cable/source/subscriptions.coffee)0
-rw-r--r--actionmailer/Rakefile3
-rw-r--r--actionpack/Rakefile3
-rw-r--r--actionview/Rakefile3
-rw-r--r--activejob/Rakefile3
-rw-r--r--activemodel/Rakefile3
-rw-r--r--activerecord/Rakefile3
-rw-r--r--activesupport/Rakefile4
-rw-r--r--railties/Rakefile3
-rw-r--r--tasks/release.rb3
18 files changed, 51 insertions, 17 deletions
diff --git a/actioncable/.gitignore b/actioncable/.gitignore
index 8ded114548..0a04b29786 100644
--- a/actioncable/.gitignore
+++ b/actioncable/.gitignore
@@ -1,2 +1,2 @@
-/lib/assets/javascripts/action_cable.js
+/lib/assets/compiled
/tmp
diff --git a/actioncable/Rakefile b/actioncable/Rakefile
index 0a036e3e3d..1d77fc7067 100644
--- a/actioncable/Rakefile
+++ b/actioncable/Rakefile
@@ -8,6 +8,9 @@ dir = File.dirname(__FILE__)
task :default => :test
+task :package => "assets:compile"
+task "package:clean" => "assets:clean"
+
Rake::TestTask.new do |t|
t.libs << "test"
t.test_files = Dir.glob("#{dir}/test/**/*_test.rb")
@@ -17,32 +20,38 @@ Rake::TestTask.new do |t|
end
namespace :assets do
+ root_path = Pathname.new(dir)
+ destination_path = root_path.join("lib/assets/compiled")
+
desc "Compile dist/action_cable.js"
task :compile do
puts 'Compiling Action Cable assets...'
- asset_mapping = { "source.js" => "action_cable.js" }
+ precompile_list = %w(action_cable.js)
- root_path = Pathname.new(dir)
- load_path = root_path.join("app/assets/javascripts/action_cable")
- destination_path = root_path.join("lib/assets/javascripts")
+ 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
- environment = Sprockets::Environment.new
- environment.append_path(load_path)
-
manifest = Sprockets::Manifest.new(environment.index, compile_path)
- manifest.compile(asset_mapping.keys)
+ manifest.compile(precompile_list)
- asset_mapping.each do |logical_path, dist_path|
- fingerprint_path = manifest.assets[logical_path]
- FileUtils.cp(compile_path.join(fingerprint_path), destination_path.join(dist_path))
+ 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 '======'
- puts 'Action Cable assets compiled successfully!'
+ puts 'Done'
+ end
+
+ task :clean do
+ destination_path.rmtree if destination_path.exist?
end
end
diff --git a/actioncable/app/assets/javascripts/action_cable/source/index.coffee.erb b/actioncable/app/assets/javascripts/action_cable.coffee.erb
index f4615b7502..18a48c0610 100644
--- a/actioncable/app/assets/javascripts/action_cable/source/index.coffee.erb
+++ b/actioncable/app/assets/javascripts/action_cable.coffee.erb
@@ -1,5 +1,5 @@
#= require_self
-#= require ./consumer
+#= require ./action_cable/consumer
@ActionCable =
INTERNAL: <%= ActionCable::INTERNAL.to_json %>
diff --git a/actioncable/app/assets/javascripts/action_cable/source/connection.coffee b/actioncable/app/assets/javascripts/action_cable/connection.coffee
index fbd7dbd35b..fbd7dbd35b 100644
--- a/actioncable/app/assets/javascripts/action_cable/source/connection.coffee
+++ b/actioncable/app/assets/javascripts/action_cable/connection.coffee
diff --git a/actioncable/app/assets/javascripts/action_cable/source/connection_monitor.coffee b/actioncable/app/assets/javascripts/action_cable/connection_monitor.coffee
index 99b9a1c6d5..99b9a1c6d5 100644
--- a/actioncable/app/assets/javascripts/action_cable/source/connection_monitor.coffee
+++ b/actioncable/app/assets/javascripts/action_cable/connection_monitor.coffee
diff --git a/actioncable/app/assets/javascripts/action_cable/source/consumer.coffee b/actioncable/app/assets/javascripts/action_cable/consumer.coffee
index 717c0641a9..717c0641a9 100644
--- a/actioncable/app/assets/javascripts/action_cable/source/consumer.coffee
+++ b/actioncable/app/assets/javascripts/action_cable/consumer.coffee
diff --git a/actioncable/app/assets/javascripts/action_cable/index.js b/actioncable/app/assets/javascripts/action_cable/index.js
deleted file mode 100644
index e97870c3b0..0000000000
--- a/actioncable/app/assets/javascripts/action_cable/index.js
+++ /dev/null
@@ -1 +0,0 @@
-//= require_tree ./source
diff --git a/actioncable/app/assets/javascripts/action_cable/source/subscription.coffee b/actioncable/app/assets/javascripts/action_cable/subscription.coffee
index 339d676933..339d676933 100644
--- a/actioncable/app/assets/javascripts/action_cable/source/subscription.coffee
+++ b/actioncable/app/assets/javascripts/action_cable/subscription.coffee
diff --git a/actioncable/app/assets/javascripts/action_cable/source/subscriptions.coffee b/actioncable/app/assets/javascripts/action_cable/subscriptions.coffee
index ae041ffa2b..ae041ffa2b 100644
--- a/actioncable/app/assets/javascripts/action_cable/source/subscriptions.coffee
+++ b/actioncable/app/assets/javascripts/action_cable/subscriptions.coffee
diff --git a/actionmailer/Rakefile b/actionmailer/Rakefile
index 7197ea5e27..54e6cff48d 100644
--- a/actionmailer/Rakefile
+++ b/actionmailer/Rakefile
@@ -3,6 +3,9 @@ require 'rake/testtask'
desc "Default Task"
task default: [ :test ]
+task :package
+task "package:clean"
+
# Run the unit tests
Rake::TestTask.new { |t|
t.libs << "test"
diff --git a/actionpack/Rakefile b/actionpack/Rakefile
index 601263bfac..37a269cffd 100644
--- a/actionpack/Rakefile
+++ b/actionpack/Rakefile
@@ -5,6 +5,9 @@ test_files = Dir.glob('test/**/*_test.rb')
desc "Default Task"
task :default => :test
+task :package
+task "package:clean"
+
# Run the unit tests
Rake::TestTask.new do |t|
t.libs << 'test'
diff --git a/actionview/Rakefile b/actionview/Rakefile
index 93be50721d..d41030c650 100644
--- a/actionview/Rakefile
+++ b/actionview/Rakefile
@@ -3,6 +3,9 @@ require 'rake/testtask'
desc "Default Task"
task :default => :test
+task :package
+task "package:clean"
+
# Run the unit tests
desc "Run all unit tests"
diff --git a/activejob/Rakefile b/activejob/Rakefile
index d9648a7f16..2a853b4b6b 100644
--- a/activejob/Rakefile
+++ b/activejob/Rakefile
@@ -6,6 +6,9 @@ ACTIVEJOB_ADAPTERS -= %w(queue_classic) if defined?(JRUBY_VERSION)
task default: :test
task test: 'test:default'
+task :package
+task "package:clean"
+
namespace :test do
desc 'Run all adapter tests'
task :default do
diff --git a/activemodel/Rakefile b/activemodel/Rakefile
index 5a67f0a151..9982d49bcb 100644
--- a/activemodel/Rakefile
+++ b/activemodel/Rakefile
@@ -4,6 +4,9 @@ dir = File.dirname(__FILE__)
task :default => :test
+task :package
+task "package:clean"
+
Rake::TestTask.new do |t|
t.libs << "test"
t.test_files = Dir.glob("#{dir}/test/cases/**/*_test.rb")
diff --git a/activerecord/Rakefile b/activerecord/Rakefile
index 0564dca94a..46df733cfe 100644
--- a/activerecord/Rakefile
+++ b/activerecord/Rakefile
@@ -20,6 +20,9 @@ end
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
tasks = defined?(JRUBY_VERSION) ?
diff --git a/activesupport/Rakefile b/activesupport/Rakefile
index 81c242d4b1..33ee62aa1b 100644
--- a/activesupport/Rakefile
+++ b/activesupport/Rakefile
@@ -1,6 +1,10 @@
require 'rake/testtask'
task :default => :test
+
+task :package
+task "package:clean"
+
Rake::TestTask.new do |t|
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
diff --git a/railties/Rakefile b/railties/Rakefile
index cf130a5f14..3421d9b464 100644
--- a/railties/Rakefile
+++ b/railties/Rakefile
@@ -2,6 +2,9 @@ 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 25ba91cb49..de9c51a140 100644
--- a/tasks/release.rb
+++ b/tasks/release.rb
@@ -13,6 +13,7 @@ directory "pkg"
task :clean do
rm_f gem
+ sh "cd #{framework} && bundle exec rake package:clean" unless framework == "rails"
end
task :update_versions do
@@ -48,7 +49,7 @@ directory "pkg"
task gem => %w(update_versions pkg) do
cmd = ""
cmd << "cd #{framework} && " unless framework == "rails"
- cmd << "bundle exec rake assets:compile && " if framework == "actioncable"
+ cmd << "bundle exec rake package && " unless framework == "rails"
cmd << "gem build #{gemspec} && mv #{framework}-#{version}.gem #{root}/pkg/"
sh cmd
end