-
Notifications
You must be signed in to change notification settings - Fork 573
Expand file tree
/
Copy pathRakefile
More file actions
62 lines (50 loc) · 1.86 KB
/
Rakefile
File metadata and controls
62 lines (50 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# frozen_string_literal: true
require "rubygems"
require "bundler/setup"
Bundler::GemHelper.install_tasks
# See https://github.com/simplecov-ruby/simplecov/issues/171
desc "Set permissions on all files so they are compatible with both user-local and system-wide installs"
task :fix_permissions do
system 'bash -c "find lib/ -type f -exec chmod 644 {} \; && find . -type d -exec chmod 755 {} \;"'
end
# Enforce proper permissions on each build
Rake::Task[:build].prerequisites.unshift :fix_permissions
require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:spec)
begin
require "rubocop/rake_task"
RuboCop::RakeTask.new
rescue LoadError
task :rubocop do
warn "Rubocop is disabled"
end
end
require "cucumber/rake/task"
Cucumber::Rake::Task.new do |t|
t.cucumber_opts = %w[--retry 3 --no-strict-flaky]
end
task test: %i[spec cucumber]
task default: %i[rubocop spec cucumber]
namespace :assets do
desc "Compile frontend assets (HTML, JS, CSS) using esbuild"
task :compile do
frontend = File.expand_path("html_frontend", __dir__)
outdir = File.expand_path("lib/simplecov/formatter/html_formatter/public", __dir__)
puts "Compiling assets..."
# JS: esbuild bundles TypeScript + highlight.js and minifies
sh "cd #{frontend} && esbuild src/app.ts --bundle --minify --target=es2015 --outfile=#{outdir}/application.js"
# CSS: concatenate in order and minify
css = %w[
assets/stylesheets/reset.css
assets/stylesheets/plugins/highlight.css
assets/stylesheets/screen.css
].map { |f| File.read(File.join(frontend, f)) }.join("\n")
IO.popen(%w[esbuild --minify --loader=css], "r+") do |io|
io.write(css)
io.close_write
File.write("#{outdir}/application.css", io.read)
end
# HTML: copy static index.html
FileUtils.cp(File.join(frontend, "src/index.html"), File.join(outdir, "index.html"))
end
end