Class: Homebrew::DevCmd::LivecheckCmd Private

Inherits:
AbstractCommand show all
Defined in:
dev-cmd/livecheck.rb,
sorbet/rbi/dsl/homebrew/dev_cmd/livecheck_cmd.rbi

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

Defined Under Namespace

Classes: Args

Instance Method Summary collapse

Methods inherited from AbstractCommand

command, command_name, dev_cmd?, #initialize, parser, ruby_cmd?

Methods included from Utils::Output::Mixin

#issue_reporting_message, #odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #opoo_once, #opoo_outside_github_actions, #opoo_without_github_actions_annotation, #pretty_cannot_install, #pretty_deprecated, #pretty_disabled, #pretty_duration, #pretty_incompatible, #pretty_install_status, #pretty_installed, #pretty_removed, #pretty_uninstalled, #pretty_unmarked, #pretty_upgradable, #pretty_warning

Constructor Details

This class inherits a constructor from Homebrew::AbstractCommand

Instance Method Details

#args ⇒ Homebrew::DevCmd::LivecheckCmd::Args

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.



10
# File 'sorbet/rbi/dsl/homebrew/dev_cmd/livecheck_cmd.rbi', line 10

def args; end

#run ⇒ void

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.

This method returns an undefined value.

Raises:



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'dev-cmd/livecheck.rb', line 59

def run
  Utils::GemSetup.install_bundler_gems!(groups: ["livecheck"])

  if args.debug? && args.verbose?
    puts args
    puts Homebrew::EnvConfig.livecheck_watchlist if Homebrew::EnvConfig.livecheck_watchlist.present?
  end

  formulae_and_casks_to_check = Homebrew::API.with_no_api_env do
    if args.tap
      tap = Tap.fetch(args.tap)
      formula_files = args.cask? ? [] : tap.formula_files
      cask_files = args.formula? ? [] : tap.cask_files
      formula_files.map { |path| Formulary.from_path(path) } +
        cask_files.map { |path| Cask::CaskLoader.from_path(path) }
    elsif args.installed?
      formulae = args.cask? ? [] : Formula.installed
      casks = args.formula? ? [] : Cask::Caskroom.casks
      formulae + casks
    elsif args.named.present?
      args.named.to_formulae_and_casks_with_taps
    elsif File.exist?(watchlist_path)
      begin
        # This removes blank lines, comment lines, and trailing comments
        names = Pathname.new(watchlist_path)
                        .read
                        .lines
                        .filter_map do |line|
                          comment_index = line.index("#")
                          next if comment_index&.zero?

                          line = line[0...comment_index] if comment_index
                          line&.strip.presence
                        end

        named_args = CLI::NamedArgs.new(*names, parent: args)
        named_args.to_formulae_and_casks(ignore_unavailable: true)
      rescue Errno::ENOENT => e
        onoe e
      end
    else
      formulae = args.cask? ? [] : Formula.all
      casks = args.formula? ? [] : Cask::Cask.all
      formulae + casks
    end
  end

  skipped_autobump = T.let(false, T::Boolean)
  if !args.autobump? && !Homebrew::EnvConfig.livecheck_autobump?
    autobump_lists = {}

    formulae_and_casks_to_check = formulae_and_casks_to_check.reject do |formula_or_cask|
      tap = formula_or_cask.tap
      next false if tap.nil?

      autobump_lists[tap] ||= tap.autobump

      name = Utils.name_or_token(formula_or_cask)
      next unless autobump_lists[tap].include?(name)

      odebug "Skipping #{name} as it is autobumped in #{tap}."
      skipped_autobump = true
      true
    end
  end

  formulae_and_casks_to_check = formulae_and_casks_to_check.sort_by do |formula_or_cask|
    Utils.name_or_token(formula_or_cask)
  end

  raise UsageError, "No formulae or casks to check." if formulae_and_casks_to_check.blank? && !skipped_autobump
  return if formulae_and_casks_to_check.blank?

  Livecheck.run_checks(
    formulae_and_casks_to_check,
    full_name:            args.full_name?,
    handle_name_conflict: !args.formula? && !args.cask?,
    check_resources:      args.resources?,
    json:                 args.json?,
    newer_only:           args.newer_only?,
    extract_plist:        args.extract_plist?,
    debug:                args.debug?,
    quiet:                args.quiet?,
    verbose:              args.verbose?,
  )
end