-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRakefile
More file actions
68 lines (56 loc) 路 2.29 KB
/
Copy pathRakefile
File metadata and controls
68 lines (56 loc) 路 2.29 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
63
64
65
66
67
68
# frozen_string_literal: true
require "rspec/core/rake_task"
require "rubocop/rake_task"
RSpec::Core::RakeTask.new(:spec)
RuboCop::RakeTask.new(:rubocop) do |task|
task.patterns = ["Gemfile", "Rakefile", "lib/**/*.rb", "spec/**/*.rb"]
end
task default: [:rubocop, :spec]
namespace :repology do
desc "Build data/repology.json from the Repology API"
task :build do
require_relative "lib/repology_index"
limit = ENV["REPOLOGY_PAGE_LIMIT"]&.to_i
RepologyIndex.new(page_limit: limit).write("data/repology.json")
end
desc "Re-apply select_ecosystems and overrides.yml skips to data/repology.json without re-crawling"
task :trim do
require_relative "lib/repology_index"
result = RepologyIndex.trim("data/repology.json")
puts "trimmed to #{result["formulae"].size} formulae, " \
"ecosystems: #{result["meta"]["osv_distros"].join(", ")}"
end
end
namespace :advisories do
desc "Concatenate advisories/*.json into data/advisories.json indexed by formula"
task :concat do
require_relative "lib/advisory_index"
AdvisoryIndex.write("advisories", "data/advisories.json")
end
desc "Summarize data/advisories.json changes against HEAD as Markdown"
task :summary do
require "json"
require "open3"
require_relative "lib/advisory_change_summary"
before_json, status = Open3.capture2("git", "show", "HEAD:data/advisories.json")
abort "could not read data/advisories.json from HEAD" unless status.success?
before = JSON.parse(before_json)
after = JSON.parse(File.read("data/advisories.json"))
puts AdvisoryChangeSummary.render(before, after)
end
desc "Delete uncomparable and rejected matched candidates named as untracked paths on standard input"
task :filter do
require_relative "lib/advisory_filter"
paths = $stdin.read.split("\0").reject(&:empty?)
counts = AdvisoryFilter.run(paths, "advisories")
puts counts.map { |key, count| "#{key}=#{count}" }.join(" ")
end
desc "Partition advisory paths from standard input into stable formula shards"
task :shard do
require_relative "lib/advisory_shard"
output_dir = ENV.fetch("SHARD_OUTPUT")
paths = $stdin.read.split("\0").reject(&:empty?)
counts = AdvisoryShard.write(paths, output_dir)
puts counts.map { |key, count| "#{key}=#{count}" }.join(" ")
end
end