Module: Homebrew::Bundle::Installer Private
- Defined in:
- bundle/installer.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.
Class Method Summary collapse
- .fetchable_formulae_and_casks(entries, no_upgrade:) ⇒ Array<String> private
- .install!(entries, global: false, file: nil, no_lock: false, no_upgrade: false, verbose: false, force: false, quiet: false) ⇒ Boolean private
- .tap_installed?(package_full_name) ⇒ Boolean private
Class Method Details
.fetchable_formulae_and_casks(entries, no_upgrade:) ⇒ Array<String>
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.
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'bundle/installer.rb', line 134 def self.fetchable_formulae_and_casks(entries, no_upgrade:) entries.filter_map do |entry| name = entry.fetch(:name) = entry.fetch(:options) case entry.fetch(:type) when :brew next unless tap_installed?(name) next if Homebrew::Bundle::FormulaInstaller.formula_installed_and_up_to_date?(name, no_upgrade:) name when :cask full_name = .fetch(:full_name, name) next unless tap_installed?(full_name) next unless Homebrew::Bundle::CaskInstaller.installable_or_upgradable?(name, no_upgrade:, **) full_name end end end |
.install!(entries, global: false, file: nil, no_lock: false, no_upgrade: false, verbose: false, force: false, quiet: false) ⇒ Boolean
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.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 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 |
# File 'bundle/installer.rb', line 30 def self.install!(entries, global: false, file: nil, no_lock: false, no_upgrade: false, verbose: false, force: false, quiet: false) success = 0 failure = 0 installable_entries = entries.filter_map do |entry| next if Homebrew::Bundle::Skipper.skip? entry name = entry.name args = [name] = {} verb = "Installing" type = entry.type cls = case type when :brew = entry. verb = "Upgrading" if Homebrew::Bundle::FormulaInstaller.formula_upgradable?(name) Homebrew::Bundle::FormulaInstaller when :cask = entry. verb = "Upgrading" if Homebrew::Bundle::CaskInstaller.cask_upgradable?(name) Homebrew::Bundle::CaskInstaller when :mas args << entry.[:id] Homebrew::Bundle::MacAppStoreInstaller when :vscode Homebrew::Bundle::VscodeExtensionInstaller when :go Homebrew::Bundle::GoInstaller when :cargo Homebrew::Bundle::CargoInstaller when :flatpak = entry. Homebrew::Bundle::FlatpakInstaller when :tap verb = "Tapping" = entry. Homebrew::Bundle::TapInstaller end next if cls.nil? { name:, args:, options:, verb:, type:, cls: } end if (fetchable_names = fetchable_formulae_and_casks(installable_entries, no_upgrade:).presence) fetchable_names_joined = fetchable_names.join(", ") Formatter.success("Fetching #{fetchable_names_joined}") unless quiet unless Bundle.brew("fetch", *fetchable_names, verbose:) $stderr.puts Formatter.error "`brew bundle` failed! Failed to fetch #{fetchable_names_joined}" return false end end installable_entries.each do |entry| name = entry.fetch(:name) args = entry.fetch(:args) = entry.fetch(:options) verb = entry.fetch(:verb) cls = entry.fetch(:cls) preinstall = if cls.preinstall!(*args, **, no_upgrade:, verbose:) puts Formatter.success("#{verb} #{name}") true else puts "Using #{name}" unless quiet false end if cls.install!(*args, **, preinstall:, no_upgrade:, verbose:, force:) success += 1 else $stderr.puts Formatter.error("#{verb} #{name} has failed!") failure += 1 end end unless failure.zero? require "utils" dependency = Utils.pluralize("dependency", failure) $stderr.puts Formatter.error "`brew bundle` failed! #{failure} Brewfile #{dependency} failed to install" return false end unless quiet require "utils" dependency = Utils.pluralize("dependency", success) puts Formatter.success "`brew bundle` complete! #{success} Brewfile #{dependency} now installed." end true end |
.tap_installed?(package_full_name) ⇒ Boolean
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.
156 157 158 159 160 161 |
# File 'bundle/installer.rb', line 156 def self.tap_installed?(package_full_name) user, repository, = package_full_name.split("/", 3) return true if user.blank? || repository.blank? Homebrew::Bundle::TapInstaller.installed_taps.include?("#{user}/#{repository}") end |