Merge pull request #15008 from dduugg/enable-types
Enable types in Library/Homebrew/cask, etc.
This commit is contained in:
commit
96eb047121
@ -1,4 +1,4 @@
|
|||||||
# typed: false
|
# typed: true
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "delegate"
|
require "delegate"
|
||||||
@ -24,14 +24,14 @@ module Cask
|
|||||||
def initialize(**options)
|
def initialize(**options)
|
||||||
options.assert_valid_keys!(*VALID_KEYS)
|
options.assert_valid_keys!(*VALID_KEYS)
|
||||||
|
|
||||||
conflicts = options.transform_values { |v| Set.new(Array(v)) }
|
conflicts = options.transform_values { |v| Set.new(Kernel.Array(v)) }
|
||||||
conflicts.default = Set.new
|
conflicts.default = Set.new
|
||||||
|
|
||||||
super(conflicts)
|
super(conflicts)
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_json(generator)
|
def to_json(generator)
|
||||||
transform_values(&:to_a).to_json(generator)
|
__getobj__.transform_values(&:to_a).to_json(generator)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
# typed: false
|
# typed: true
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "delegate"
|
require "delegate"
|
||||||
@ -38,7 +38,7 @@ module Cask
|
|||||||
pairs.each do |key, value|
|
pairs.each do |key, value|
|
||||||
raise "invalid depends_on key: '#{key.inspect}'" unless VALID_KEYS.include?(key)
|
raise "invalid depends_on key: '#{key.inspect}'" unless VALID_KEYS.include?(key)
|
||||||
|
|
||||||
self[key] = send(:"#{key}=", *value)
|
__getobj__[key] = send(:"#{key}=", *value)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -54,15 +54,18 @@ module Cask
|
|||||||
def macos=(*args)
|
def macos=(*args)
|
||||||
raise "Only a single 'depends_on macos' is allowed." if defined?(@macos)
|
raise "Only a single 'depends_on macos' is allowed." if defined?(@macos)
|
||||||
|
|
||||||
|
# workaround for https://github.com/sorbet/sorbet/issues/6860
|
||||||
|
first_arg = args.first&.to_s
|
||||||
|
|
||||||
begin
|
begin
|
||||||
@macos = if args.count > 1
|
@macos = if args.count > 1
|
||||||
MacOSRequirement.new([args], comparator: "==")
|
MacOSRequirement.new([args], comparator: "==")
|
||||||
elsif MacOSVersions::SYMBOLS.key?(args.first)
|
elsif MacOSVersions::SYMBOLS.key?(args.first)
|
||||||
MacOSRequirement.new([args.first], comparator: "==")
|
MacOSRequirement.new([args.first], comparator: "==")
|
||||||
elsif /^\s*(?<comparator><|>|[=<>]=)\s*:(?<version>\S+)\s*$/ =~ args.first
|
elsif (md = /^\s*(?<comparator><|>|[=<>]=)\s*:(?<version>\S+)\s*$/.match(first_arg))
|
||||||
MacOSRequirement.new([version.to_sym], comparator: comparator)
|
MacOSRequirement.new([T.must(md[:version]).to_sym], comparator: md[:comparator])
|
||||||
elsif /^\s*(?<comparator><|>|[=<>]=)\s*(?<version>\S+)\s*$/ =~ args.first
|
elsif (md = /^\s*(?<comparator><|>|[=<>]=)\s*(?<version>\S+)\s*$/.match(first_arg))
|
||||||
MacOSRequirement.new([version], comparator: comparator)
|
MacOSRequirement.new([md[:version]], comparator: md[:comparator])
|
||||||
else # rubocop:disable Lint/DuplicateBranch
|
else # rubocop:disable Lint/DuplicateBranch
|
||||||
MacOSRequirement.new([args.first], comparator: "==")
|
MacOSRequirement.new([args.first], comparator: "==")
|
||||||
end
|
end
|
||||||
|
|||||||
5
Library/Homebrew/cask/dsl/depends_on.rbi
Normal file
5
Library/Homebrew/cask/dsl/depends_on.rbi
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# typed: strict
|
||||||
|
|
||||||
|
class Cask::DSL::DependsOn
|
||||||
|
include Kernel
|
||||||
|
end
|
||||||
@ -1,4 +1,4 @@
|
|||||||
# typed: false
|
# typed: true
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "formula_installer"
|
require "formula_installer"
|
||||||
@ -241,7 +241,7 @@ module Cask
|
|||||||
save_download_sha if @cask.version.latest?
|
save_download_sha if @cask.version.latest?
|
||||||
rescue => e
|
rescue => e
|
||||||
begin
|
begin
|
||||||
already_installed_artifacts.each do |artifact|
|
already_installed_artifacts&.each do |artifact|
|
||||||
if artifact.respond_to?(:uninstall_phase)
|
if artifact.respond_to?(:uninstall_phase)
|
||||||
odebug "Reverting installation of artifact of class #{artifact.class}"
|
odebug "Reverting installation of artifact of class #{artifact.class}"
|
||||||
artifact.uninstall_phase(command: @command, verbose: verbose?, force: force?)
|
artifact.uninstall_phase(command: @command, verbose: verbose?, force: force?)
|
||||||
@ -296,7 +296,7 @@ module Cask
|
|||||||
|
|
||||||
graph = ::Utils::TopologicalHash.graph_package_dependencies(@cask)
|
graph = ::Utils::TopologicalHash.graph_package_dependencies(@cask)
|
||||||
|
|
||||||
raise CaskSelfReferencingDependencyError, cask.token if graph[@cask].include?(@cask)
|
raise CaskSelfReferencingDependencyError, @cask.token if graph[@cask].include?(@cask)
|
||||||
|
|
||||||
::Utils::TopologicalHash.graph_package_dependencies(primary_container.dependencies, graph)
|
::Utils::TopologicalHash.graph_package_dependencies(primary_container.dependencies, graph)
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
# typed: false
|
# typed: true
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "development_tools"
|
require "development_tools"
|
||||||
@ -11,29 +11,27 @@ module Cask
|
|||||||
module Quarantine
|
module Quarantine
|
||||||
extend T::Sig
|
extend T::Sig
|
||||||
|
|
||||||
module_function
|
|
||||||
|
|
||||||
QUARANTINE_ATTRIBUTE = "com.apple.quarantine"
|
QUARANTINE_ATTRIBUTE = "com.apple.quarantine"
|
||||||
|
|
||||||
QUARANTINE_SCRIPT = (HOMEBREW_LIBRARY_PATH/"cask/utils/quarantine.swift").freeze
|
QUARANTINE_SCRIPT = (HOMEBREW_LIBRARY_PATH/"cask/utils/quarantine.swift").freeze
|
||||||
|
|
||||||
def swift
|
def self.swift
|
||||||
@swift ||= DevelopmentTools.locate("swift")
|
@swift ||= DevelopmentTools.locate("swift")
|
||||||
end
|
end
|
||||||
private :swift
|
private_class_method :swift
|
||||||
|
|
||||||
def xattr
|
def self.xattr
|
||||||
@xattr ||= DevelopmentTools.locate("xattr")
|
@xattr ||= DevelopmentTools.locate("xattr")
|
||||||
end
|
end
|
||||||
private :xattr
|
private_class_method :xattr
|
||||||
|
|
||||||
def swift_target_args
|
def self.swift_target_args
|
||||||
["-target", "#{Hardware::CPU.arch}-apple-macosx#{MacOS.version}"]
|
["-target", "#{Hardware::CPU.arch}-apple-macosx#{MacOS.version}"]
|
||||||
end
|
end
|
||||||
private :swift_target_args
|
private_class_method :swift_target_args
|
||||||
|
|
||||||
sig { returns(Symbol) }
|
sig { returns(Symbol) }
|
||||||
def check_quarantine_support
|
def self.check_quarantine_support
|
||||||
odebug "Checking quarantine support"
|
odebug "Checking quarantine support"
|
||||||
|
|
||||||
if !system_command(xattr, args: ["-h"], print_stderr: false).success?
|
if !system_command(xattr, args: ["-h"], print_stderr: false).success?
|
||||||
@ -58,13 +56,13 @@ module Cask
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def available?
|
def self.available?
|
||||||
@status ||= check_quarantine_support
|
@status ||= check_quarantine_support
|
||||||
|
|
||||||
@status == :quarantine_available
|
@status == :quarantine_available
|
||||||
end
|
end
|
||||||
|
|
||||||
def detect(file)
|
def self.detect(file)
|
||||||
return if file.nil?
|
return if file.nil?
|
||||||
|
|
||||||
odebug "Verifying Gatekeeper status of #{file}"
|
odebug "Verifying Gatekeeper status of #{file}"
|
||||||
@ -76,13 +74,13 @@ module Cask
|
|||||||
quarantine_status
|
quarantine_status
|
||||||
end
|
end
|
||||||
|
|
||||||
def status(file)
|
def self.status(file)
|
||||||
system_command(xattr,
|
system_command(xattr,
|
||||||
args: ["-p", QUARANTINE_ATTRIBUTE, file],
|
args: ["-p", QUARANTINE_ATTRIBUTE, file],
|
||||||
print_stderr: false).stdout.rstrip
|
print_stderr: false).stdout.rstrip
|
||||||
end
|
end
|
||||||
|
|
||||||
def toggle_no_translocation_bit(attribute)
|
def self.toggle_no_translocation_bit(attribute)
|
||||||
fields = attribute.split(";")
|
fields = attribute.split(";")
|
||||||
|
|
||||||
# Fields: status, epoch, download agent, event ID
|
# Fields: status, epoch, download agent, event ID
|
||||||
@ -94,7 +92,7 @@ module Cask
|
|||||||
fields.join(";")
|
fields.join(";")
|
||||||
end
|
end
|
||||||
|
|
||||||
def release!(download_path: nil)
|
def self.release!(download_path: nil)
|
||||||
return unless detect(download_path)
|
return unless detect(download_path)
|
||||||
|
|
||||||
odebug "Releasing #{download_path} from quarantine"
|
odebug "Releasing #{download_path} from quarantine"
|
||||||
@ -112,7 +110,7 @@ module Cask
|
|||||||
raise CaskQuarantineReleaseError.new(download_path, quarantiner.stderr)
|
raise CaskQuarantineReleaseError.new(download_path, quarantiner.stderr)
|
||||||
end
|
end
|
||||||
|
|
||||||
def cask!(cask: nil, download_path: nil, action: true)
|
def self.cask!(cask: nil, download_path: nil, action: true)
|
||||||
return if cask.nil? || download_path.nil?
|
return if cask.nil? || download_path.nil?
|
||||||
|
|
||||||
return if detect(download_path)
|
return if detect(download_path)
|
||||||
@ -139,7 +137,7 @@ module Cask
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def propagate(from: nil, to: nil)
|
def self.propagate(from: nil, to: nil)
|
||||||
return if from.nil? || to.nil?
|
return if from.nil? || to.nil?
|
||||||
|
|
||||||
raise CaskError, "#{from} was not quarantined properly." unless detect(from)
|
raise CaskError, "#{from} was not quarantined properly." unless detect(from)
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
# typed: false
|
# typed: true
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "env_config"
|
require "env_config"
|
||||||
@ -124,7 +124,9 @@ module Cask
|
|||||||
|
|
||||||
return true if caught_exceptions.empty?
|
return true if caught_exceptions.empty?
|
||||||
raise MultipleCaskErrors, caught_exceptions if caught_exceptions.count > 1
|
raise MultipleCaskErrors, caught_exceptions if caught_exceptions.count > 1
|
||||||
raise caught_exceptions.first if caught_exceptions.count == 1
|
raise caught_exceptions.fetch(0) if caught_exceptions.count == 1
|
||||||
|
|
||||||
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.upgrade_cask(
|
def self.upgrade_cask(
|
||||||
|
|||||||
@ -1,8 +1,5 @@
|
|||||||
# typed: strict
|
# typed: strict
|
||||||
|
|
||||||
module GitRepositoryExtension
|
module GitRepositoryExtension
|
||||||
include Kernel
|
requires_ancestor { Pathname }
|
||||||
|
|
||||||
sig { params(args: T.any(String, Pathname)).returns(Pathname) }
|
|
||||||
def join(*args); end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,19 +1,9 @@
|
|||||||
# typed: strict
|
# typed: strict
|
||||||
|
|
||||||
module DiskUsageExtension
|
module DiskUsageExtension
|
||||||
include Kernel
|
requires_ancestor { Pathname }
|
||||||
|
|
||||||
def exist?; end
|
|
||||||
|
|
||||||
def symlink?; end
|
|
||||||
|
|
||||||
def resolved_path; end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
module ObserverPathnameExtension
|
module ObserverPathnameExtension
|
||||||
include Kernel
|
requires_ancestor { Pathname }
|
||||||
|
|
||||||
def dirname; end
|
|
||||||
|
|
||||||
def basename; end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -45,7 +45,7 @@ module OS
|
|||||||
sig { returns(T.self_type) }
|
sig { returns(T.self_type) }
|
||||||
def strip_patch
|
def strip_patch
|
||||||
# Big Sur is 11.x but Catalina is 10.15.x.
|
# Big Sur is 11.x but Catalina is 10.15.x.
|
||||||
if major >= 11
|
if T.must(major) >= 11
|
||||||
self.class.new(major.to_s)
|
self.class.new(major.to_s)
|
||||||
else
|
else
|
||||||
major_minor
|
major_minor
|
||||||
|
|||||||
@ -1,10 +0,0 @@
|
|||||||
# typed: strict
|
|
||||||
|
|
||||||
module OS
|
|
||||||
module Mac
|
|
||||||
class Version
|
|
||||||
sig { returns(Token) }
|
|
||||||
def major; end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
Loading…
x
Reference in New Issue
Block a user