Module: Homebrew::Bundle::UvInstaller Private
- Defined in:
- bundle/uv_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
- .install!(name, preinstall: true, verbose: false, force: false, with: [], **_options) ⇒ Boolean private
- .installed_packages ⇒ Array<Hash{Symbol => T.untyped}> private
- .normalize_name(name) ⇒ String private
- .normalize_with(with) ⇒ Array<String> private
- .normalized_options(name, with:) ⇒ Hash{Symbol => T.untyped} private
- .package_installed?(package, with: []) ⇒ Boolean private
- .preinstall!(name, verbose: false, with: [], **_options) ⇒ Boolean private
- .reset! ⇒ void private
Class Method Details
.install!(name, preinstall: true, verbose: false, force: false, with: [], **_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.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'bundle/uv_installer.rb', line 46 def self.install!(name, preinstall: true, verbose: false, force: false, with: [], **) return true unless preinstall puts "Installing #{name} uv tool. It is not currently installed." if verbose uv = T.must(Bundle.which_uv) args = ["tool", "install", name] normalized_with = normalize_with(with) normalized_with.each do |requirement| args << "--with" args << requirement end success = Bundle.system uv.to_s, *args, verbose: verbose return false unless success installed_packages << (name, with:) true end |
.installed_packages ⇒ Array<Hash{Symbol => 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.
83 84 85 86 87 |
# File 'bundle/uv_installer.rb', line 83 def self.installed_packages require "bundle/uv_dumper" @installed_packages ||= T.let(Homebrew::Bundle::UvDumper.packages, T.nilable(T::Array[T::Hash[Symbol, T.untyped]])) end |
.normalize_name(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.
98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'bundle/uv_installer.rb', line 98 def self.normalize_name(name) match = name.strip.match(/\A(?<base>[^\[\]]+)(?:\[(?<extras>[^\]]+)\])?\z/) return name.strip unless match base = T.must(match[:base]).strip extras_raw = match[:extras] return base if extras_raw.blank? extras = extras_raw.split(",").map(&:strip).reject(&:empty?).uniq.sort return base if extras.empty? "#{base}[#{extras.join(",")}]" end |
.normalize_with(with) ⇒ 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.
90 91 92 93 94 95 |
# File 'bundle/uv_installer.rb', line 90 def self.normalize_with(with) with.map(&:strip) .reject(&:empty?) .uniq .sort end |
.normalized_options(name, with:) ⇒ Hash{Symbol => 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.
118 119 120 121 122 123 |
# File 'bundle/uv_installer.rb', line 118 def self.(name, with:) { name: normalize_name(name), with: normalize_with(with), } end |
.package_installed?(package, with: []) ⇒ 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.
72 73 74 75 76 77 78 79 80 |
# File 'bundle/uv_installer.rb', line 72 def self.package_installed?(package, with: []) desired = (package, with:) installed_packages.any? do |installed| installed_name = T.cast(installed[:name], String) installed_with = T.cast(installed[:with] || [], T::Array[String]) installed_name == desired[:name] && installed_with == desired[:with] end end |
.preinstall!(name, verbose: false, with: [], **_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.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'bundle/uv_installer.rb', line 20 def self.preinstall!(name, verbose: false, with: [], **) unless Bundle.uv_installed? puts "Installing uv. It is not currently installed." if verbose Bundle.brew("install", "--formula", "uv", verbose:) Bundle.reset! raise "Unable to install #{name} uv tool. uv installation failed." unless Bundle.uv_installed? end if package_installed?(name, with:) puts "Skipping install of #{name} uv tool. It is already installed." if verbose return false end 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.
8 9 10 |
# File 'bundle/uv_installer.rb', line 8 def self.reset! @installed_packages = nil end |