Skip to content

Commit b44ec56

Browse files
committed
Reduce the internal formula API to contain the bare minimum data
1 parent 0b67caf commit b44ec56

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

Library/Homebrew/dev-cmd/generate-cask-api.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,7 @@ def run
7575
Homebrew::API.merge_variations(cask, bottle_tag:)
7676
end
7777

78-
unless args.dry_run?
79-
File.write("api/internal/cask.#{bottle_tag}.json", JSON.pretty_generate(variation_casks))
80-
end
78+
File.write("api/internal/cask.#{bottle_tag}.json", JSON.generate(variation_casks)) unless args.dry_run?
8179
end
8280
end
8381
end

Library/Homebrew/dev-cmd/generate-formula-api.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,19 @@ def run
7070

7171
OnSystem::VALID_OS_ARCH_TAGS.each do |bottle_tag|
7272
variation_formulae = all_formulae.map do |_, formula|
73-
Homebrew::API.merge_variations(formula, bottle_tag:)
73+
formula = Homebrew::API.merge_variations(formula, bottle_tag:)
74+
75+
version = Version.new(formula.dig("versions", "stable"))
76+
pkg_version = PkgVersion.new(version, formula["revision"])
77+
rebuild = formula.dig("bottle", "stable", "rebuild") || 0
78+
sha256 = formula.dig("bottle", "stable", "files", :all, "sha256")
79+
sha256 ||= formula.dig("bottle", "stable", "files", bottle_tag.to_sym, "sha256")
80+
81+
[formula["name"], pkg_version.to_s, rebuild, sha256]
7482
end
7583

7684
unless args.dry_run?
77-
File.write("api/internal/formula.#{bottle_tag}.json", JSON.pretty_generate(variation_formulae))
85+
File.write("api/internal/formula.#{bottle_tag}.json", JSON.generate(variation_formulae))
7886
end
7987
end
8088
end

0 commit comments

Comments
 (0)