Class: Homebrew::Bundle::Extension Abstract Private
- Inherits:
-
PackageType
- Object
- PackageType
- Homebrew::Bundle::Extension
- Extended by:
- T::Helpers
- Defined in:
- bundle/extensions/extension.rb
Overview
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.
It cannot be directly instantiated. Subclasses must implement the abstract methods below.
Direct Known Subclasses
Cargo, Flatpak, Go, Krew, MacAppStore, Npm, Uv, VscodeExtension, Winget
Class Method Summary collapse
- .add_supported? ⇒ Boolean private
- .banner_name ⇒ String private
- .check(entries, exit_on_first_error: false, no_upgrade: false, verbose: false) ⇒ Array<Object> private
- .check_label ⇒ String private
- .cleanup!(items) ⇒ void private
- .cleanup_disable_description ⇒ String private
- .cleanup_disable_env ⇒ Symbol private
- .cleanup_heading ⇒ String? private
- .cleanup_item_name(item) ⇒ String private
- .cleanup_items(entries) ⇒ Array<String> private
- .cleanup_supported? ⇒ Boolean private
- .disable_predicate_method ⇒ Symbol private
- .dump ⇒ String private
- .dump_disable_description ⇒ String private
- .dump_disable_env ⇒ Symbol private
- .dump_disable_predicate_method ⇒ Symbol private
- .dump_disable_supported? ⇒ Boolean private
- .dump_entry(package) ⇒ String private
- .dump_name(package) ⇒ String private
- .dump_output(describe: false, no_restart: false) ⇒ String private
- .dump_supported? ⇒ Boolean private
- .dump_with(_package) ⇒ Array<String>? private
- .entry(name, options = {}) ⇒ Dsl::Entry private
- .fetchable_name(name, options = {}, no_upgrade: false) ⇒ String? private
- .flag ⇒ String private
- .inherited(subclass) ⇒ void private
- .install!(name, with: nil, preinstall: true, no_upgrade: false, verbose: false, force: false, **_options) ⇒ Boolean private
- .install_package!(name, with: nil, verbose: false) ⇒ Boolean private
- .install_supported? ⇒ Boolean private
- .install_verb(_name = "", _options = {}) ⇒ String private
- .installed_packages ⇒ Array<T.untyped> abstract private
- .legacy_check_step ⇒ Symbol private
- .package_description ⇒ String private
- .package_installed?(name, with: nil) ⇒ Boolean private
- .package_manager_env(executable) ⇒ Hash{String => String} private
- .package_manager_executable ⇒ Pathname? private
- .package_manager_executable! ⇒ Pathname private
- .package_manager_installed? ⇒ Boolean private
- .package_manager_name ⇒ String private
- .package_record(name, with: nil) ⇒ Object private
- .packages ⇒ Array<T.untyped> abstract private
- .predicate_method ⇒ Symbol private
- .preinstall!(name, with: nil, no_upgrade: false, verbose: false, **_options) ⇒ Boolean private
- .quote(value) ⇒ String private
- .remove_supported? ⇒ Boolean private
- .reset! ⇒ void abstract private
- .switch_description(description) ⇒ String private
- .type ⇒ Symbol private
- .uninstall_package!(name, executable: Pathname.new("")) ⇒ void private
- .with_package_manager_env(&_blk) ⇒ T.type_parameter(:U) private
Instance Method Summary collapse
- #failure_reason(package, no_upgrade:) ⇒ String private
- #installed_and_up_to_date?(package, no_upgrade: false) ⇒ Boolean private
Methods inherited from PackageType
#checkable_entries, #exit_early_check, #find_actionable, #format_checkable, #full_check
Class Method Details
.add_supported? ⇒ 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.
139 140 141 |
# File 'bundle/extensions/extension.rb', line 139 def self.add_supported? true end |
.banner_name ⇒ 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.
32 33 34 |
# File 'bundle/extensions/extension.rb', line 32 def self. T.cast(const_get(:BANNER_NAME), String) end |
.check(entries, exit_on_first_error: false, no_upgrade: false, verbose: false) ⇒ 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.
238 239 240 |
# File 'bundle/extensions/extension.rb', line 238 def self.check(entries, exit_on_first_error: false, no_upgrade: false, verbose: false) new.find_actionable(entries, exit_on_first_error:, no_upgrade:, verbose:) end |
.check_label ⇒ 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.
27 28 29 |
# File 'bundle/extensions/extension.rb', line 27 def self.check_label T.cast(const_get(:PACKAGE_TYPE_NAME), String) end |
.cleanup!(items) ⇒ 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.
267 268 269 270 271 272 273 274 275 276 277 |
# File 'bundle/extensions/extension.rb', line 267 def self.cleanup!(items) executable = package_manager_executable return if executable.nil? with_env(package_manager_env(executable)) do items.each do |name| uninstall_package!(name, executable:) end end puts "Uninstalled #{items.size} #{}#{"s" if items.size != 1}" end |
.cleanup_disable_description ⇒ 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.
124 125 126 |
# File 'bundle/extensions/extension.rb', line 124 def self.cleanup_disable_description "`cleanup` without #{}." end |
.cleanup_disable_env ⇒ Symbol
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.
114 115 116 |
# File 'bundle/extensions/extension.rb', line 114 def self.cleanup_disable_env :"bundle_cleanup_no_#{type}" end |
.cleanup_heading ⇒ 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.
174 175 176 |
# File 'bundle/extensions/extension.rb', line 174 def self.cleanup_heading nil end |
.cleanup_item_name(item) ⇒ 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.
257 258 259 |
# File 'bundle/extensions/extension.rb', line 257 def self.cleanup_item_name(item) item end |
.cleanup_items(entries) ⇒ 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.
243 244 245 246 247 248 249 250 251 252 253 254 |
# File 'bundle/extensions/extension.rb', line 243 def self.cleanup_items(entries) return [].freeze unless package_manager_installed? kept_packages = entries.filter_map do |entry| entry.name if entry.type == type end return [].freeze if kept_packages.empty? installed_names = packages.map { |pkg| dump_name(pkg) } installed_names - kept_packages end |
.cleanup_supported? ⇒ 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.
179 180 181 |
# File 'bundle/extensions/extension.rb', line 179 def self.cleanup_supported? !cleanup_heading.nil? end |
.disable_predicate_method ⇒ Symbol
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 |
# File 'bundle/extensions/extension.rb', line 134 def self.disable_predicate_method :"no_#{type}?" end |
.dump ⇒ 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.
218 219 220 |
# File 'bundle/extensions/extension.rb', line 218 def self.dump packages.map { |package| dump_entry(package) }.join("\n") end |
.dump_disable_description ⇒ 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.
104 105 106 |
# File 'bundle/extensions/extension.rb', line 104 def self.dump_disable_description "`dump` without #{}." end |
.dump_disable_env ⇒ Symbol
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.
109 110 111 |
# File 'bundle/extensions/extension.rb', line 109 def self.dump_disable_env :"bundle_dump_no_#{type}" end |
.dump_disable_predicate_method ⇒ Symbol
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.
129 130 131 |
# File 'bundle/extensions/extension.rb', line 129 def self.dump_disable_predicate_method disable_predicate_method end |
.dump_disable_supported? ⇒ 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.
119 120 121 |
# File 'bundle/extensions/extension.rb', line 119 def self.dump_disable_supported? true end |
.dump_entry(package) ⇒ 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.
193 194 195 196 197 198 199 200 |
# File 'bundle/extensions/extension.rb', line 193 def self.dump_entry(package) line = "#{type} #{quote(dump_name(package))}" with = dump_with(package) return line if with.blank? formatted_with = with.map { |requirement| quote(requirement) }.join(", ") "#{line}, with: [#{formatted_with}]" end |
.dump_name(package) ⇒ 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.
208 209 210 |
# File 'bundle/extensions/extension.rb', line 208 def self.dump_name(package) package.to_s end |
.dump_output(describe: false, no_restart: false) ⇒ 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.
223 224 225 226 227 228 |
# File 'bundle/extensions/extension.rb', line 223 def self.dump_output(describe: false, no_restart: false) _ = describe _ = no_restart dump end |
.dump_supported? ⇒ 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.
99 100 101 |
# File 'bundle/extensions/extension.rb', line 99 def self.dump_supported? true end |
.dump_with(_package) ⇒ 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.
213 214 215 |
# File 'bundle/extensions/extension.rb', line 213 def self.dump_with(_package) nil end |
.entry(name, options = {}) ⇒ Dsl::Entry
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 45 46 |
# File 'bundle/extensions/extension.rb', line 42 def self.entry(name, = {}) raise "unknown options(#{.keys.inspect}) for #{type}" if .present? Dsl::Entry.new(type, name) end |
.fetchable_name(name, options = {}, no_upgrade: false) ⇒ 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.
165 166 167 168 169 170 171 |
# File 'bundle/extensions/extension.rb', line 165 def self.fetchable_name(name, = {}, no_upgrade: false) _ = name _ = _ = no_upgrade nil end |
.flag ⇒ 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.
49 50 51 |
# File 'bundle/extensions/extension.rb', line 49 def self.flag type.to_s.tr("_", "-") end |
.inherited(subclass) ⇒ 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.
16 17 18 19 |
# File 'bundle/extensions/extension.rb', line 16 def self.inherited(subclass) super Homebrew::Bundle.register_extension(T.cast(subclass, T.class_of(Homebrew::Bundle::Extension))) end |
.install!(name, with: nil, preinstall: true, no_upgrade: false, verbose: false, force: false, **_options) ⇒ 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.
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 |
# File 'bundle/extensions/extension.rb', line 346 def self.install!(name, with: nil, preinstall: true, no_upgrade: false, verbose: false, force: false, **) _ = no_upgrade _ = force return true unless preinstall puts "Installing #{name} #{package_description}. It is not currently installed." if verbose return false unless install_package!(name, with:, verbose:) package = package_record(name, with:) installed_packages << package unless installed_packages.include?(package) packages << package unless packages.include?(package) true end |
.install_package!(name, with: nil, verbose: 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.
379 380 381 382 383 384 385 |
# File 'bundle/extensions/extension.rb', line 379 def self.install_package!(name, with: nil, verbose: false) _ = name _ = with _ = verbose raise NotImplementedError, "#{self} must override `install_package!` or `install!`." end |
.install_supported? ⇒ 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.
149 150 151 |
# File 'bundle/extensions/extension.rb', line 149 def self.install_supported? true end |
.install_verb(_name = "", _options = {}) ⇒ 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.
154 155 156 |
# File 'bundle/extensions/extension.rb', line 154 def self.install_verb(_name = "", = {}) "Installing" end |
.installed_packages ⇒ Array<T.untyped>
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.
190 |
# File 'bundle/extensions/extension.rb', line 190 def self.installed_packages; end |
.legacy_check_step ⇒ Symbol
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.
262 263 264 |
# File 'bundle/extensions/extension.rb', line 262 def self.legacy_check_step :registered_extensions_to_install end |
.package_description ⇒ 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.
94 95 96 |
# File 'bundle/extensions/extension.rb', line 94 def self.package_description check_label.downcase end |
.package_installed?(name, with: nil) ⇒ 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.
292 293 294 |
# File 'bundle/extensions/extension.rb', line 292 def self.package_installed?(name, with: nil) installed_packages.include?(package_record(name, with:)) end |
.package_manager_env(executable) ⇒ Hash{String => 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.
79 80 81 |
# File 'bundle/extensions/extension.rb', line 79 def self.package_manager_env(executable) { "PATH" => "#{executable.dirname}:#{ORIGINAL_PATHS.join(":")}" } end |
.package_manager_executable ⇒ Pathname?
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.
69 70 71 |
# File 'bundle/extensions/extension.rb', line 69 def self.package_manager_executable which(package_manager_name, ORIGINAL_PATHS) end |
.package_manager_executable! ⇒ Pathname
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.
74 75 76 |
# File 'bundle/extensions/extension.rb', line 74 def self.package_manager_executable! package_manager_executable || raise("#{package_manager_name} is not installed") end |
.package_manager_installed? ⇒ 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.
64 65 66 |
# File 'bundle/extensions/extension.rb', line 64 def self.package_manager_installed? package_manager_executable.present? end |
.package_manager_name ⇒ 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.
59 60 61 |
# File 'bundle/extensions/extension.rb', line 59 def self.package_manager_name flag end |
.package_record(name, with: nil) ⇒ 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.
285 286 287 288 289 |
# File 'bundle/extensions/extension.rb', line 285 def self.package_record(name, with: nil) _ = with name end |
.packages ⇒ Array<T.untyped>
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.
187 |
# File 'bundle/extensions/extension.rb', line 187 def self.packages; end |
.predicate_method ⇒ Symbol
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.
54 55 56 |
# File 'bundle/extensions/extension.rb', line 54 def self.predicate_method :"#{type}?" end |
.preinstall!(name, with: nil, no_upgrade: false, verbose: false, **_options) ⇒ 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.
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 |
# File 'bundle/extensions/extension.rb', line 305 def self.preinstall!(name, with: nil, no_upgrade: false, verbose: false, **) _ = no_upgrade unless package_manager_installed? puts "Installing #{package_manager_name}. It is not currently installed." if verbose Bundle.system(HOMEBREW_BREW_FILE, "install", "--formula", package_manager_name, verbose:) # `formula_versions_from_env` consumes the env vars once at startup, so # keep the cached values across reset when bootstrapping a manager. formula_versions_from_env = T.let( Bundle.formula_versions_from_env_cache, T.nilable(T::Hash[String, String]), ) upgrade_formulae = Bundle.upgrade_formulae Bundle.reset! Bundle.formula_versions_from_env_cache = formula_versions_from_env Bundle.upgrade_formulae = upgrade_formulae.join(",") unless package_manager_installed? raise "Unable to install #{name} #{package_description}. " \ "#{package_manager_name} installation failed." end end if package_installed?(name, with:) puts "Skipping install of #{name} #{package_description}. It is already installed." if verbose return false end true end |
.quote(value) ⇒ 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.
203 204 205 |
# File 'bundle/extensions/extension.rb', line 203 def self.quote(value) value.inspect end |
.remove_supported? ⇒ 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.
144 145 146 |
# File 'bundle/extensions/extension.rb', line 144 def self.remove_supported? true end |
.reset! ⇒ 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.
184 |
# File 'bundle/extensions/extension.rb', line 184 def self.reset!; end |
.switch_description(description) ⇒ 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.
37 38 39 |
# File 'bundle/extensions/extension.rb', line 37 def self.switch_description(description) description end |
.type ⇒ Symbol
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.
22 23 24 |
# File 'bundle/extensions/extension.rb', line 22 def self.type T.cast(const_get(:PACKAGE_TYPE), Symbol) end |
.uninstall_package!(name, executable: Pathname.new("")) ⇒ 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.
280 281 282 |
# File 'bundle/extensions/extension.rb', line 280 def self.uninstall_package!(name, executable: Pathname.new("")) raise NotImplementedError, "#{self} must override `uninstall_package!` or `cleanup!`." end |
.with_package_manager_env(&_blk) ⇒ T.type_parameter(:U)
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.
88 89 90 91 |
# File 'bundle/extensions/extension.rb', line 88 def self.with_package_manager_env(&_blk) executable = package_manager_executable! with_env(package_manager_env(executable)) { yield executable } end |
Instance Method Details
#failure_reason(package, no_upgrade:) ⇒ 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.
363 364 365 |
# File 'bundle/extensions/extension.rb', line 363 def failure_reason(package, no_upgrade:) "#{self.class.check_label} #{self.class.dump_name(package)} needs to be installed." end |
#installed_and_up_to_date?(package, no_upgrade: 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.
368 369 370 |
# File 'bundle/extensions/extension.rb', line 368 def installed_and_up_to_date?(package, no_upgrade: false) self.class.package_installed?(self.class.dump_name(package), with: self.class.dump_with(package)) end |