2019-01-05 08:43:11 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require "bundler/setup"
|
|
|
|
require "bundler/gem_tasks"
|
|
|
|
require "rake/testtask"
|
|
|
|
|
2019-01-09 02:36:33 +08:00
|
|
|
task :package
|
|
|
|
|
2024-05-24 00:16:37 +08:00
|
|
|
ENV["RAILS_MINITEST_PLUGIN"] = "true"
|
|
|
|
|
2019-01-05 08:43:11 +08:00
|
|
|
Rake::TestTask.new do |t|
|
|
|
|
t.libs << "test"
|
2019-05-14 00:44:06 +08:00
|
|
|
t.test_files = FileList["test/**/*_test.rb"].exclude("test/system/**/*", "test/dummy/**/*")
|
|
|
|
t.verbose = true
|
|
|
|
end
|
|
|
|
|
|
|
|
Rake::TestTask.new "test:system" do |t|
|
|
|
|
t.libs << "test"
|
|
|
|
t.test_files = FileList["test/system/**/*_test.rb"]
|
2019-01-05 08:43:11 +08:00
|
|
|
t.verbose = true
|
|
|
|
end
|
|
|
|
|
2022-09-26 14:32:11 +08:00
|
|
|
namespace :test do
|
|
|
|
task :isolated do
|
|
|
|
FileList["test/**/*_test.rb"].exclude("test/system/**/*", "test/dummy/**/*").all? do |file|
|
|
|
|
sh(Gem.ruby, "-w", "-Ilib", "-Itest", file)
|
|
|
|
end || raise("Failures")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-10-25 12:17:48 +08:00
|
|
|
task :vendor_trix do
|
2023-10-27 22:46:16 +08:00
|
|
|
require "importmap-rails"
|
2023-10-25 12:17:48 +08:00
|
|
|
require "importmap/packager"
|
|
|
|
|
|
|
|
packager = Importmap::Packager.new(vendor_path: "app/assets/javascripts")
|
|
|
|
imports = packager.import("trix", from: "unpkg")
|
|
|
|
imports.each do |package, url|
|
|
|
|
url.gsub!("esm.min.js", "umd.js")
|
|
|
|
puts %(Vendoring "#{package}" to #{packager.vendor_path}/#{package}.js via download from #{url})
|
|
|
|
packager.download(package, url)
|
|
|
|
|
|
|
|
css_url = url.gsub("umd.js", "css")
|
|
|
|
puts %(Vendoring "#{package}" to #{packager.vendor_path}/#{package}.css via download from #{css_url})
|
|
|
|
|
|
|
|
response = Net::HTTP.get_response(URI(css_url))
|
|
|
|
if response.code == "200"
|
|
|
|
File.open(Pathname.new("app/assets/stylesheets/trix.css"), "w+") do |file|
|
|
|
|
file.write response.body
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-01-05 08:43:11 +08:00
|
|
|
task default: :test
|