Module: Homebrew::Bundle::Checker Private

Defined in:
bundle/checker.rb

This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module if possible, as it may be removed or changed without warning.

Defined Under Namespace

Classes: CheckResult

Constant Summary collapse

CheckStep =

This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.

T.type_alias { Symbol }
CORE_CHECKS =

This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.

T.let([
  :taps_to_tap,
  :casks_to_install,
  :registered_extensions_to_install,
  :apps_to_install,
  :formulae_to_install,
  :formulae_to_start,
].freeze, T::Array[CheckStep])

Class Method Summary collapse

Class Method Details

.apps_to_install(exit_on_first_error: false, no_upgrade: false, verbose: false) ⇒ Object

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



42
43
44
# File 'bundle/checker.rb', line 42

def self.apps_to_install(exit_on_first_error: false, no_upgrade: false, verbose: false)
  extension_errors(:apps_to_install, exit_on_first_error:, no_upgrade:, verbose:)
end

.casks_to_install(exit_on_first_error: false, no_upgrade: false, verbose: false) ⇒ Object

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



57
58
59
# File 'bundle/checker.rb', line 57

def self.casks_to_install(exit_on_first_error: false, no_upgrade: false, verbose: false)
  package_type_errors(:cask, exit_on_first_error:, no_upgrade:, verbose:)
end

.check(global: false, file: nil, exit_on_first_error: false, no_upgrade: false, verbose: false) ⇒ Object

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'bundle/checker.rb', line 23

def self.check(global: false, file: nil, exit_on_first_error: false, no_upgrade: false, verbose: false)
  require "bundle/brewfile"
  @dsl ||= Brewfile.read(global:, file:)

  errors = []
  enumerator = exit_on_first_error ? :find : :map

  work_to_be_done = CORE_CHECKS.public_send(enumerator) do |check_step|
    check_errors = public_send(check_step, exit_on_first_error:, no_upgrade:, verbose:)
    any_errors = check_errors.any?
    errors.concat(check_errors) if any_errors
    any_errors
  end

  work_to_be_done = Array(work_to_be_done).flatten.any?

  CheckResult.new work_to_be_done, errors
end

.extension_errors(step, exit_on_first_error:, no_upgrade:, verbose:) ⇒ Array<Object>

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Parameters:

  • step (Symbol)
  • exit_on_first_error (Boolean)
  • no_upgrade (Boolean)
  • verbose (Boolean)

Returns:



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'bundle/checker.rb', line 77

def self.extension_errors(step, exit_on_first_error:, no_upgrade:, verbose:)
  matching_extensions = Homebrew::Bundle.extensions.select { |extension| extension.legacy_check_step == step }
  errors = T.let([], T::Array[Object])

  matching_extensions.each do |extension|
    check_errors = extension.check(
      @dsl.entries,
      exit_on_first_error:, no_upgrade:, verbose:,
    )
    next if check_errors.empty?

    return check_errors if exit_on_first_error

    errors.concat(check_errors)
  end

  errors
end

.formulae_to_install(exit_on_first_error: false, no_upgrade: false, verbose: false) ⇒ Object

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



61
62
63
# File 'bundle/checker.rb', line 61

def self.formulae_to_install(exit_on_first_error: false, no_upgrade: false, verbose: false)
  package_type_errors(:brew, exit_on_first_error:, no_upgrade:, verbose:)
end

.formulae_to_start(exit_on_first_error: false, no_upgrade: false, verbose: false) ⇒ Object

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



46
47
48
49
50
51
# File 'bundle/checker.rb', line 46

def self.formulae_to_start(exit_on_first_error: false, no_upgrade: false, verbose: false)
  Homebrew::Bundle::Brew::Services.new.find_actionable(
    @dsl.entries,
    exit_on_first_error:, no_upgrade:, verbose:,
  )
end

.package_type_errors(type, exit_on_first_error:, no_upgrade:, verbose:) ⇒ Array<Object>

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Parameters:

  • type (Symbol)
  • exit_on_first_error (Boolean)
  • no_upgrade (Boolean)
  • verbose (Boolean)

Returns:



110
111
112
113
114
115
# File 'bundle/checker.rb', line 110

def self.package_type_errors(type, exit_on_first_error:, no_upgrade:, verbose:)
  package_type = Homebrew::Bundle.package_type(type)
  return [] if package_type.nil?

  package_type.check(@dsl.entries, exit_on_first_error:, no_upgrade:, verbose:)
end

.registered_extensions_to_install(exit_on_first_error: false, no_upgrade: false, verbose: false) ⇒ Object

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



65
66
67
# File 'bundle/checker.rb', line 65

def self.registered_extensions_to_install(exit_on_first_error: false, no_upgrade: false, verbose: false)
  extension_errors(:registered_extensions_to_install, exit_on_first_error:, no_upgrade:, verbose:)
end

.reset!Object

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



96
97
98
99
100
# File 'bundle/checker.rb', line 96

def self.reset!
  @dsl = nil
  Homebrew::Bundle.package_types.each(&:reset!)
  Homebrew::Bundle.extensions.each(&:reset!)
end

.taps_to_tap(exit_on_first_error: false, no_upgrade: false, verbose: false) ⇒ Object

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



53
54
55
# File 'bundle/checker.rb', line 53

def self.taps_to_tap(exit_on_first_error: false, no_upgrade: false, verbose: false)
  package_type_errors(:tap, exit_on_first_error:, no_upgrade:, verbose:)
end