forked from Homebrew/formulae.brew.sh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
92 lines (75 loc) · 2.53 KB
/
Rakefile
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
require "rake"
require "rake/clean"
autoload :Jekyll, 'jekyll'
task default: :formula_and_analytics
desc "Dump macOS formulae data"
task :formulae, [:os, :tap] do |task, args|
args.with_defaults(:os => "mac", :tap => Jekyll.configuration.dig("taps", "core", "name"))
ENV["HOMEBREW_FORCE_HOMEBREW_ON_LINUX"] = "1" if args[:os] == "mac"
ENV["HOMEBREW_NO_COLOR"] = "1"
sh "brew", "ruby", "script/generate.rb", args[:os], args[:tap]
end
CLOBBER.include FileList[%w[_data/formula api/formula formula
_data/formula-linux api/formula-linux formula-linux]]
desc "Dump cask data"
task :cask, [:tap] do |task, args|
args.with_defaults(:tap => Jekyll.configuration.dig("taps", "cask", "name"))
ENV["HOMEBREW_FORCE_HOMEBREW_ON_LINUX"] = "1"
ENV["HOMEBREW_NO_COLOR"] = "1"
sh "brew", "ruby", "script/generate-cask.rb", args[:tap]
end
CLOBBER.include FileList[%w[_data/cask api/cask cask]]
desc "Dump macOS formulae and analytics data"
task formula_and_analytics: %i[formulae data:analytics:mac]
desc "Dump Linux formulae and analytics data"
task linux_formula_and_analytics: %i[data:analytics:linux] do
Rake::Task["formulae"].tap(&:reenable).invoke("linux")
end
desc "Dump all formulae (macOS and Linux)"
task all_formulae: :formulae do
Rake::Task["formulae"].tap(&:reenable).invoke("linux")
end
desc "Build the site"
task build: %i[all_formulae data:analytics cask] do
Jekyll::Commands::Build.process({})
end
CLEAN.include FileList["_site"]
desc "Serve the site"
task :serve do
Jekyll::Commands::Serve.process({})
end
desc "Run html proofer to validate the HTML output."
task html_proofer: :build do
require "html-proofer"
HTMLProofer.check_directory(
"./_site",
parallel: { in_threads: 4 },
favicon: true,
http_status_ignore: [0, 302, 303, 429, 521],
assume_extension: true,
check_external_hash: true,
check_favicon: true,
check_opengraph: true,
check_img_http: true,
disable_external: true,
url_ignore: ["http://formulae.brew.sh"]
).run
end
desc "Run JSON Lint to validate the JSON output."
task jsonlint: :build do
require "jsonlint"
files_to_check = FileList["_site/**/*.json"]
puts "Running JSON Lint on #{files_to_check.flatten.length} files..."
linter = JsonLint::Linter.new
linter.check_all(files_to_check)
if linter.errors?
linter.display_errors
abort "JSON Lint found #{linter.errors_count} errors!"
else
puts "JSON Lint finished successfully."
end
end
task test: %i[html_proofer jsonlint]
task :clean do
sh *%w[git checkout --], *CLOBBER
end