Remove JSON v3 cask logic
This commit is contained in:
parent
a600438123
commit
042d6cc97e
@ -400,63 +400,15 @@ module Cask
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_internal_api_hash
|
|
||||||
api_hash = {
|
|
||||||
"token" => token,
|
|
||||||
"name" => name,
|
|
||||||
"desc" => desc,
|
|
||||||
"homepage" => homepage,
|
|
||||||
"url" => url,
|
|
||||||
"version" => version,
|
|
||||||
"sha256" => sha256,
|
|
||||||
"artifacts" => artifacts_list(compact: true),
|
|
||||||
"ruby_source_path" => ruby_source_path,
|
|
||||||
"ruby_source_sha256" => ruby_source_checksum.fetch(:sha256),
|
|
||||||
}
|
|
||||||
|
|
||||||
if deprecation_date
|
|
||||||
api_hash["deprecation_date"] = deprecation_date
|
|
||||||
api_hash["deprecation_reason"] = deprecation_reason
|
|
||||||
api_hash["deprecation_replacement"] = deprecation_replacement
|
|
||||||
end
|
|
||||||
|
|
||||||
if disable_date
|
|
||||||
api_hash["disable_date"] = disable_date
|
|
||||||
api_hash["disable_reason"] = disable_reason
|
|
||||||
api_hash["disable_replacement"] = disable_replacement
|
|
||||||
end
|
|
||||||
|
|
||||||
if (url_specs_hash = url_specs).present?
|
|
||||||
api_hash["url_specs"] = url_specs_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
api_hash["caskfile_only"] = true if caskfile_only?
|
|
||||||
api_hash["conflicts_with"] = conflicts_with if conflicts_with.present?
|
|
||||||
api_hash["depends_on"] = depends_on if depends_on.present?
|
|
||||||
api_hash["container"] = container.pairs if container
|
|
||||||
api_hash["caveats"] = caveats if caveats.present?
|
|
||||||
api_hash["auto_updates"] = auto_updates if auto_updates
|
|
||||||
api_hash["languages"] = languages if languages.present?
|
|
||||||
|
|
||||||
api_hash
|
|
||||||
end
|
|
||||||
|
|
||||||
HASH_KEYS_TO_SKIP = %w[outdated installed versions].freeze
|
HASH_KEYS_TO_SKIP = %w[outdated installed versions].freeze
|
||||||
private_constant :HASH_KEYS_TO_SKIP
|
private_constant :HASH_KEYS_TO_SKIP
|
||||||
|
|
||||||
def to_hash_with_variations(hash_method: :to_h)
|
def to_hash_with_variations
|
||||||
case hash_method
|
if loaded_from_api? && !Homebrew::EnvConfig.no_install_from_api?
|
||||||
when :to_h
|
return api_to_local_hash(Homebrew::API::Cask.all_casks[token].dup)
|
||||||
if loaded_from_api? && !Homebrew::EnvConfig.no_install_from_api?
|
|
||||||
return api_to_local_hash(Homebrew::API::Cask.all_casks[token].dup)
|
|
||||||
end
|
|
||||||
when :to_internal_api_hash
|
|
||||||
raise ArgumentError, "API Hash must be generated from Ruby source files" if loaded_from_api?
|
|
||||||
else
|
|
||||||
raise ArgumentError, "Unknown hash method #{hash_method.inspect}"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
hash = public_send(hash_method)
|
hash = to_h
|
||||||
variations = {}
|
variations = {}
|
||||||
|
|
||||||
if @dsl.on_system_blocks_exist?
|
if @dsl.on_system_blocks_exist?
|
||||||
@ -471,7 +423,7 @@ module Cask
|
|||||||
Homebrew::SimulateSystem.with(os:, arch:) do
|
Homebrew::SimulateSystem.with(os:, arch:) do
|
||||||
refresh
|
refresh
|
||||||
|
|
||||||
public_send(hash_method).each do |key, value|
|
to_h.each do |key, value|
|
||||||
next if HASH_KEYS_TO_SKIP.include? key
|
next if HASH_KEYS_TO_SKIP.include? key
|
||||||
next if value.to_s == hash[key].to_s
|
next if value.to_s == hash[key].to_s
|
||||||
|
|
||||||
@ -485,11 +437,11 @@ module Cask
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
hash["variations"] = variations if hash_method != :to_internal_api_hash || variations.present?
|
hash["variations"] = variations
|
||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
def artifacts_list(compact: false, uninstall_only: false)
|
def artifacts_list(uninstall_only: false)
|
||||||
artifacts.filter_map do |artifact|
|
artifacts.filter_map do |artifact|
|
||||||
case artifact
|
case artifact
|
||||||
when Artifact::AbstractFlightBlock
|
when Artifact::AbstractFlightBlock
|
||||||
@ -498,8 +450,7 @@ module Cask
|
|||||||
next if uninstall_only && !uninstall_flight_block
|
next if uninstall_only && !uninstall_flight_block
|
||||||
|
|
||||||
# Only indicate whether this block is used as we don't load it from the API
|
# Only indicate whether this block is used as we don't load it from the API
|
||||||
# We can skip this entirely once we move to internal JSON v3.
|
{ artifact.summarize.to_sym => nil }
|
||||||
{ artifact.summarize.to_sym => nil } unless compact
|
|
||||||
else
|
else
|
||||||
zap_artifact = artifact.is_a?(Artifact::Zap)
|
zap_artifact = artifact.is_a?(Artifact::Zap)
|
||||||
uninstall_artifact = artifact.respond_to?(:uninstall_phase) || artifact.respond_to?(:post_uninstall_phase)
|
uninstall_artifact = artifact.respond_to?(:uninstall_phase) || artifact.respond_to?(:post_uninstall_phase)
|
||||||
|
|||||||
@ -62,8 +62,6 @@ module Homebrew
|
|||||||
raise
|
raise
|
||||||
end
|
end
|
||||||
|
|
||||||
homebrew_cask_tap_json = JSON.generate(tap.to_internal_api_hash)
|
|
||||||
File.write("api/internal/v3/homebrew-cask.json", homebrew_cask_tap_json) unless args.dry_run?
|
|
||||||
canonical_json = JSON.pretty_generate(tap.cask_renames)
|
canonical_json = JSON.pretty_generate(tap.cask_renames)
|
||||||
File.write("_data/cask_canonical.json", "#{canonical_json}\n") unless args.dry_run?
|
File.write("_data/cask_canonical.json", "#{canonical_json}\n") unless args.dry_run?
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1491,22 +1491,6 @@ class CoreCaskTap < AbstractCoreTap
|
|||||||
migrations
|
migrations
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { returns(T::Hash[String, T.untyped]) }
|
|
||||||
def to_internal_api_hash
|
|
||||||
casks_api_hash = cask_tokens.to_h do |token|
|
|
||||||
cask = Cask::CaskLoader.load(token)
|
|
||||||
cask_hash = cask.to_hash_with_variations(hash_method: :to_internal_api_hash)
|
|
||||||
[token, cask_hash]
|
|
||||||
end
|
|
||||||
|
|
||||||
{
|
|
||||||
"tap_git_head" => git_head,
|
|
||||||
"renames" => cask_renames,
|
|
||||||
"tap_migrations" => tap_migrations,
|
|
||||||
"casks" => casks_api_hash,
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Permanent configuration per {Tap} using `git-config(1)`.
|
# Permanent configuration per {Tap} using `git-config(1)`.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user