mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Wrangle the asset build into something that sounds more general
This commit is contained in:
parent
ca9603fc35
commit
d6f2000a67
18 changed files with 51 additions and 17 deletions
2
actioncable/.gitignore
vendored
2
actioncable/.gitignore
vendored
|
@ -1,2 +1,2 @@
|
||||||
/lib/assets/javascripts/action_cable.js
|
/lib/assets/compiled
|
||||||
/tmp
|
/tmp
|
||||||
|
|
|
@ -8,6 +8,9 @@ dir = File.dirname(__FILE__)
|
||||||
|
|
||||||
task :default => :test
|
task :default => :test
|
||||||
|
|
||||||
|
task :package => "assets:compile"
|
||||||
|
task "package:clean" => "assets:clean"
|
||||||
|
|
||||||
Rake::TestTask.new do |t|
|
Rake::TestTask.new do |t|
|
||||||
t.libs << "test"
|
t.libs << "test"
|
||||||
t.test_files = Dir.glob("#{dir}/test/**/*_test.rb")
|
t.test_files = Dir.glob("#{dir}/test/**/*_test.rb")
|
||||||
|
@ -17,32 +20,38 @@ Rake::TestTask.new do |t|
|
||||||
end
|
end
|
||||||
|
|
||||||
namespace :assets do
|
namespace :assets do
|
||||||
|
root_path = Pathname.new(dir)
|
||||||
|
destination_path = root_path.join("lib/assets/compiled")
|
||||||
|
|
||||||
desc "Compile dist/action_cable.js"
|
desc "Compile dist/action_cable.js"
|
||||||
task :compile do
|
task :compile do
|
||||||
puts 'Compiling Action Cable assets...'
|
puts 'Compiling Action Cable assets...'
|
||||||
|
|
||||||
asset_mapping = { "source.js" => "action_cable.js" }
|
precompile_list = %w(action_cable.js)
|
||||||
|
|
||||||
root_path = Pathname.new(dir)
|
environment = Sprockets::Environment.new
|
||||||
load_path = root_path.join("app/assets/javascripts/action_cable")
|
environment.gzip = false
|
||||||
destination_path = root_path.join("lib/assets/javascripts")
|
Pathname.glob(root_path.join("app/assets/*/")) do |subdir|
|
||||||
|
environment.append_path subdir
|
||||||
|
end
|
||||||
|
|
||||||
compile_path = root_path.join("tmp/sprockets")
|
compile_path = root_path.join("tmp/sprockets")
|
||||||
compile_path.rmtree if compile_path.exist?
|
compile_path.rmtree if compile_path.exist?
|
||||||
compile_path.mkpath
|
compile_path.mkpath
|
||||||
|
|
||||||
environment = Sprockets::Environment.new
|
|
||||||
environment.append_path(load_path)
|
|
||||||
|
|
||||||
manifest = Sprockets::Manifest.new(environment.index, compile_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|
|
destination_path.rmtree if destination_path.exist?
|
||||||
fingerprint_path = manifest.assets[logical_path]
|
manifest.assets.each do |path, fingerprint_path|
|
||||||
FileUtils.cp(compile_path.join(fingerprint_path), destination_path.join(dist_path))
|
destination_path.join(path).dirname.mkpath
|
||||||
|
FileUtils.cp(compile_path.join(fingerprint_path), destination_path.join(path))
|
||||||
end
|
end
|
||||||
|
|
||||||
puts '======'
|
puts 'Done'
|
||||||
puts 'Action Cable assets compiled successfully!'
|
end
|
||||||
|
|
||||||
|
task :clean do
|
||||||
|
destination_path.rmtree if destination_path.exist?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#= require_self
|
#= require_self
|
||||||
#= require ./consumer
|
#= require ./action_cable/consumer
|
||||||
|
|
||||||
@ActionCable =
|
@ActionCable =
|
||||||
INTERNAL: <%= ActionCable::INTERNAL.to_json %>
|
INTERNAL: <%= ActionCable::INTERNAL.to_json %>
|
|
@ -1 +0,0 @@
|
||||||
//= require_tree ./source
|
|
|
@ -3,6 +3,9 @@ require 'rake/testtask'
|
||||||
desc "Default Task"
|
desc "Default Task"
|
||||||
task default: [ :test ]
|
task default: [ :test ]
|
||||||
|
|
||||||
|
task :package
|
||||||
|
task "package:clean"
|
||||||
|
|
||||||
# Run the unit tests
|
# Run the unit tests
|
||||||
Rake::TestTask.new { |t|
|
Rake::TestTask.new { |t|
|
||||||
t.libs << "test"
|
t.libs << "test"
|
||||||
|
|
|
@ -5,6 +5,9 @@ test_files = Dir.glob('test/**/*_test.rb')
|
||||||
desc "Default Task"
|
desc "Default Task"
|
||||||
task :default => :test
|
task :default => :test
|
||||||
|
|
||||||
|
task :package
|
||||||
|
task "package:clean"
|
||||||
|
|
||||||
# Run the unit tests
|
# Run the unit tests
|
||||||
Rake::TestTask.new do |t|
|
Rake::TestTask.new do |t|
|
||||||
t.libs << 'test'
|
t.libs << 'test'
|
||||||
|
|
|
@ -3,6 +3,9 @@ require 'rake/testtask'
|
||||||
desc "Default Task"
|
desc "Default Task"
|
||||||
task :default => :test
|
task :default => :test
|
||||||
|
|
||||||
|
task :package
|
||||||
|
task "package:clean"
|
||||||
|
|
||||||
# Run the unit tests
|
# Run the unit tests
|
||||||
|
|
||||||
desc "Run all unit tests"
|
desc "Run all unit tests"
|
||||||
|
|
|
@ -6,6 +6,9 @@ ACTIVEJOB_ADAPTERS -= %w(queue_classic) if defined?(JRUBY_VERSION)
|
||||||
task default: :test
|
task default: :test
|
||||||
task test: 'test:default'
|
task test: 'test:default'
|
||||||
|
|
||||||
|
task :package
|
||||||
|
task "package:clean"
|
||||||
|
|
||||||
namespace :test do
|
namespace :test do
|
||||||
desc 'Run all adapter tests'
|
desc 'Run all adapter tests'
|
||||||
task :default do
|
task :default do
|
||||||
|
|
|
@ -4,6 +4,9 @@ dir = File.dirname(__FILE__)
|
||||||
|
|
||||||
task :default => :test
|
task :default => :test
|
||||||
|
|
||||||
|
task :package
|
||||||
|
task "package:clean"
|
||||||
|
|
||||||
Rake::TestTask.new do |t|
|
Rake::TestTask.new do |t|
|
||||||
t.libs << "test"
|
t.libs << "test"
|
||||||
t.test_files = Dir.glob("#{dir}/test/cases/**/*_test.rb")
|
t.test_files = Dir.glob("#{dir}/test/cases/**/*_test.rb")
|
||||||
|
|
|
@ -20,6 +20,9 @@ end
|
||||||
desc 'Run mysql2, sqlite, and postgresql tests by default'
|
desc 'Run mysql2, sqlite, and postgresql tests by default'
|
||||||
task :default => :test
|
task :default => :test
|
||||||
|
|
||||||
|
task :package
|
||||||
|
task "package:clean"
|
||||||
|
|
||||||
desc 'Run mysql2, sqlite, and postgresql tests'
|
desc 'Run mysql2, sqlite, and postgresql tests'
|
||||||
task :test do
|
task :test do
|
||||||
tasks = defined?(JRUBY_VERSION) ?
|
tasks = defined?(JRUBY_VERSION) ?
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
require 'rake/testtask'
|
require 'rake/testtask'
|
||||||
|
|
||||||
task :default => :test
|
task :default => :test
|
||||||
|
|
||||||
|
task :package
|
||||||
|
task "package:clean"
|
||||||
|
|
||||||
Rake::TestTask.new do |t|
|
Rake::TestTask.new do |t|
|
||||||
t.libs << 'test'
|
t.libs << 'test'
|
||||||
t.pattern = 'test/**/*_test.rb'
|
t.pattern = 'test/**/*_test.rb'
|
||||||
|
|
|
@ -2,6 +2,9 @@ require 'rake/testtask'
|
||||||
|
|
||||||
task :default => :test
|
task :default => :test
|
||||||
|
|
||||||
|
task :package
|
||||||
|
task "package:clean"
|
||||||
|
|
||||||
desc "Run all unit tests"
|
desc "Run all unit tests"
|
||||||
task :test => 'test:isolated'
|
task :test => 'test:isolated'
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ directory "pkg"
|
||||||
|
|
||||||
task :clean do
|
task :clean do
|
||||||
rm_f gem
|
rm_f gem
|
||||||
|
sh "cd #{framework} && bundle exec rake package:clean" unless framework == "rails"
|
||||||
end
|
end
|
||||||
|
|
||||||
task :update_versions do
|
task :update_versions do
|
||||||
|
@ -48,7 +49,7 @@ directory "pkg"
|
||||||
task gem => %w(update_versions pkg) do
|
task gem => %w(update_versions pkg) do
|
||||||
cmd = ""
|
cmd = ""
|
||||||
cmd << "cd #{framework} && " unless framework == "rails"
|
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/"
|
cmd << "gem build #{gemspec} && mv #{framework}-#{version}.gem #{root}/pkg/"
|
||||||
sh cmd
|
sh cmd
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue