Class: Homebrew::Bundle::VscodeExtension Private
- Inherits:
-
Extension
- Object
- PackageType
- Extension
- Homebrew::Bundle::VscodeExtension
- Defined in:
- bundle/extensions/vscode_extension.rb
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.
Constant Summary collapse
- EXTENSION_ID_REGEX =
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.
/\A[a-z0-9][a-z0-9-]*\.[a-z0-9][a-z0-9._-]*\z/i
Class Method Summary collapse
- .banner_name ⇒ String private
- .batch_installable?(_name, _options = {}) ⇒ Boolean private
- .check_label ⇒ String private
- .cleanup_heading ⇒ String? private
- .cleanup_items(entries) ⇒ Array<String> private
- .extensions ⇒ Array<String> private
- .install!(name, with: nil, preinstall: true, no_upgrade: false, verbose: false, force: false, **_options) ⇒ Boolean private
- .install_batch!(entries, verbose: false) ⇒ Boolean private
- .install_package!(name, with: nil, verbose: false) ⇒ Boolean private
- .install_verb(name = "", _options = {}) ⇒ String private
- .installed_extensions ⇒ Array<String> private
- .installed_packages ⇒ Array<String> private
- .package_installed?(name, with: nil) ⇒ Boolean private
- .package_manager_executable ⇒ Pathname? private
- .package_record(name, with: nil) ⇒ Object private
- .packages ⇒ Array<String> private
- .preinstall!(name, with: nil, no_upgrade: false, verbose: false, **_options) ⇒ Boolean private
- .reset! ⇒ void private
- .type ⇒ Symbol private
- .uninstall_package!(name, executable: Pathname.new("")) ⇒ Boolean private
Methods inherited from Extension
add_supported?, check, cleanup!, cleanup_disable_description, cleanup_disable_env, cleanup_item_name, cleanup_supported?, disable_predicate_method, dump, dump_disable_description, dump_disable_env, dump_disable_predicate_method, dump_disable_supported?, dump_entry, dump_name, dump_output, dump_supported?, dump_with, ensure_package_manager_installed!, entry, #failure_reason, flag, inherited, install_supported?, #installed_and_up_to_date?, legacy_check_step, package_description, package_manager_env, package_manager_executable!, package_manager_installed?, package_manager_name, package_outdated?, predicate_method, quote, remove_supported?, switch_description, with_package_manager_env
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_install_status, #pretty_installed, #pretty_removed, #pretty_uninstalled, #pretty_unmarked, #pretty_upgradable, #pretty_warning
Methods inherited from PackageType
check, #checkable_entries, dump, dump_output, dump_supported?, #exit_early_check, #failure_reason, #find_actionable, #format_checkable, #full_check, inherited, install_supported?, #installed_and_up_to_date?
Class Method Details
.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.
19 |
# File 'bundle/extensions/vscode_extension.rb', line 19 def = "VSCode (and forks/variants) extensions" |
.batch_installable?(_name, _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.
53 54 55 |
# File 'bundle/extensions/vscode_extension.rb', line 53 def batch_installable?(_name, = {}) true 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.
16 |
# File 'bundle/extensions/vscode_extension.rb', line 16 def check_label = "VSCode Extension" |
.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.
28 29 30 |
# File 'bundle/extensions/vscode_extension.rb', line 28 def cleanup_heading "VSCode extensions" 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.
184 185 186 187 188 189 190 191 192 193 |
# File 'bundle/extensions/vscode_extension.rb', line 184 def cleanup_items(entries) kept_extensions = entries.filter_map do |entry| entry = T.cast(entry, Dsl::Entry) entry.name.downcase if entry.type == type end return [].freeze if kept_extensions.empty? packages - kept_extensions end |
.extensions ⇒ 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.
66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'bundle/extensions/vscode_extension.rb', line 66 def extensions extensions = @extensions return extensions if extensions @extensions = if (vscode = package_manager_executable) ENV["WSL_DISTRO_NAME"] = ENV.fetch("HOMEBREW_WSL_DISTRO_NAME", nil) command_output(vscode, args: ["--list-extensions"]) .split("\n").map(&:strip).grep(EXTENSION_ID_REGEX, &:downcase) end return [] if @extensions.nil? @extensions 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.
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'bundle/extensions/vscode_extension.rb', line 161 def install!(name, with: nil, preinstall: true, no_upgrade: false, verbose: false, force: false, **) _ = with _ = no_upgrade _ = force return true unless preinstall puts "#{install_verb(name)} #{name} VSCode extension." if verbose return false unless install_package!(name, verbose:) package = T.cast(package_record(name), String) installed_extensions << package unless installed_extensions.include?(package) if @extensions @extensions << package unless @extensions.include?(package) else @extensions = [package] end true end |
.install_batch!(entries, 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.
58 59 60 61 62 63 |
# File 'bundle/extensions/vscode_extension.rb', line 58 def install_batch!(entries, verbose: false) args = entries.flat_map { |entry| ["--install-extension", entry.name] } args << "--force" if entries.any? { |entry| package_installed?(entry.name) } Bundle.system(package_manager_executable!, *args, verbose:) 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.
143 144 145 146 147 148 |
# File 'bundle/extensions/vscode_extension.rb', line 143 def install_package!(name, with: nil, verbose: false) _ = with Bundle.system(package_manager_executable!, "--install-extension", name, *(package_installed?(name) ? ["--force"] : []), verbose:) 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.
48 49 50 |
# File 'bundle/extensions/vscode_extension.rb', line 48 def install_verb(name = "", = {}) package_installed?(name) ? "Upgrading" : "Installing" end |
.installed_extensions ⇒ 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.
91 92 93 94 95 96 |
# File 'bundle/extensions/vscode_extension.rb', line 91 def installed_extensions installed_extensions = @installed_extensions return installed_extensions if installed_extensions @installed_extensions = extensions.dup end |
.installed_packages ⇒ 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.
86 87 88 |
# File 'bundle/extensions/vscode_extension.rb', line 86 def installed_packages installed_extensions 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.
99 100 101 102 103 |
# File 'bundle/extensions/vscode_extension.rb', line 99 def package_installed?(name, with: nil) _ = with installed_extensions.include?(name.downcase) 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.
40 41 42 43 44 45 |
# File 'bundle/extensions/vscode_extension.rb', line 40 def package_manager_executable which("code", ORIGINAL_PATHS) || which("codium", ORIGINAL_PATHS) || which("cursor", ORIGINAL_PATHS) || which("code-insiders", ORIGINAL_PATHS) 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.
33 34 35 36 37 |
# File 'bundle/extensions/vscode_extension.rb', line 33 def package_record(name, with: nil) _ = with name.downcase end |
.packages ⇒ 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.
81 82 83 |
# File 'bundle/extensions/vscode_extension.rb', line 81 def packages extensions 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.
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'bundle/extensions/vscode_extension.rb', line 114 def preinstall!(name, with: nil, no_upgrade: false, verbose: false, **) _ = with if !package_manager_installed? && Bundle.cask_installed? puts "Installing visual-studio-code. It is not currently installed." if verbose Bundle.system(HOMEBREW_BREW_FILE, "install", "--cask", "visual-studio-code", verbose:) end if package_installed?(name) return true unless no_upgrade puts "Skipping install of #{name} VSCode extension. It is already installed." if verbose return false end unless package_manager_installed? raise "Unable to install #{name} VSCode extension. VSCode is not installed." 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.
22 23 24 25 |
# File 'bundle/extensions/vscode_extension.rb', line 22 def reset! @extensions = T.let(nil, T.nilable(T::Array[String])) @installed_extensions = T.let(nil, T.nilable(T::Array[String])) 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.
13 |
# File 'bundle/extensions/vscode_extension.rb', line 13 def type = :vscode |
.uninstall_package!(name, executable: Pathname.new("")) ⇒ 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.
196 197 198 |
# File 'bundle/extensions/vscode_extension.rb', line 196 def uninstall_package!(name, executable: Pathname.new("")) Kernel.system(executable.to_s, "--uninstall-extension", name) == true end |