mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
bundle: remove include Kernel
references
This commit is contained in:
parent
75de3aaeb5
commit
7e64051479
@ -4,9 +4,7 @@
|
||||
module Homebrew
|
||||
module Bundle
|
||||
module Brewfile
|
||||
module_function
|
||||
|
||||
def path(dash_writes_to_stdout: false, global: false, file: nil)
|
||||
def self.path(dash_writes_to_stdout: false, global: false, file: nil)
|
||||
env_bundle_file_global = ENV.fetch("HOMEBREW_BUNDLE_FILE_GLOBAL", nil)
|
||||
env_bundle_file = ENV.fetch("HOMEBREW_BUNDLE_FILE", nil)
|
||||
user_config_home = ENV.fetch("HOMEBREW_USER_CONFIG_HOME", nil)
|
||||
@ -36,13 +34,13 @@ module Homebrew
|
||||
Pathname.new(filename).expand_path(Dir.pwd)
|
||||
end
|
||||
|
||||
def read(global: false, file: nil)
|
||||
def self.read(global: false, file: nil)
|
||||
Homebrew::Bundle::Dsl.new(Brewfile.path(global:, file:))
|
||||
rescue Errno::ENOENT
|
||||
raise "No Brewfile found"
|
||||
end
|
||||
|
||||
def handle_file_value(filename, dash_writes_to_stdout)
|
||||
private_class_method def self.handle_file_value(filename, dash_writes_to_stdout)
|
||||
if filename != "-"
|
||||
filename
|
||||
elsif dash_writes_to_stdout
|
||||
|
@ -1,7 +0,0 @@
|
||||
# typed: strict
|
||||
|
||||
module Homebrew::Bundle
|
||||
module Brewfile
|
||||
include Kernel
|
||||
end
|
||||
end
|
@ -4,26 +4,24 @@
|
||||
module Homebrew
|
||||
module Bundle
|
||||
module CaskDumper
|
||||
module_function
|
||||
|
||||
def reset!
|
||||
def self.reset!
|
||||
@casks = nil
|
||||
@cask_names = nil
|
||||
@cask_hash = nil
|
||||
end
|
||||
|
||||
def cask_names
|
||||
def self.cask_names
|
||||
@cask_names ||= casks.map(&:to_s)
|
||||
end
|
||||
|
||||
def outdated_cask_names
|
||||
def self.outdated_cask_names
|
||||
return [] unless Bundle.cask_installed?
|
||||
|
||||
casks.select { |c| c.outdated?(greedy: false) }
|
||||
.map(&:to_s)
|
||||
end
|
||||
|
||||
def cask_is_outdated_using_greedy?(cask_name)
|
||||
def self.cask_is_outdated_using_greedy?(cask_name)
|
||||
return false unless Bundle.cask_installed?
|
||||
|
||||
cask = casks.find { |c| c.to_s == cask_name }
|
||||
@ -32,7 +30,7 @@ module Homebrew
|
||||
cask.outdated?(greedy: true)
|
||||
end
|
||||
|
||||
def dump(describe: false)
|
||||
def self.dump(describe: false)
|
||||
casks.map do |cask|
|
||||
description = "# #{cask.desc}\n" if describe && cask.desc.present?
|
||||
config = ", args: { #{explicit_s(cask.config)} }" if cask.config.present? && cask.config.explicit.present?
|
||||
@ -40,7 +38,7 @@ module Homebrew
|
||||
end.join("\n")
|
||||
end
|
||||
|
||||
def formula_dependencies(cask_list)
|
||||
def self.formula_dependencies(cask_list)
|
||||
return [] unless Bundle.cask_installed?
|
||||
return [] if cask_list.blank?
|
||||
|
||||
@ -51,15 +49,14 @@ module Homebrew
|
||||
end.compact
|
||||
end
|
||||
|
||||
def casks
|
||||
private_class_method def self.casks
|
||||
return [] unless Bundle.cask_installed?
|
||||
|
||||
require "cask/caskroom"
|
||||
@casks ||= Cask::Caskroom.casks
|
||||
end
|
||||
private_class_method :casks
|
||||
|
||||
def explicit_s(cask_config)
|
||||
private_class_method def self.explicit_s(cask_config)
|
||||
cask_config.explicit.map do |key, value|
|
||||
# inverse of #env - converts :languages config key back to --language flag
|
||||
if key == :languages
|
||||
|
@ -1,7 +0,0 @@
|
||||
# typed: strict
|
||||
|
||||
module Homebrew::Bundle
|
||||
module CaskDumper
|
||||
include Kernel
|
||||
end
|
||||
end
|
@ -4,14 +4,12 @@
|
||||
module Homebrew
|
||||
module Bundle
|
||||
module CaskInstaller
|
||||
module_function
|
||||
|
||||
def reset!
|
||||
def self.reset!
|
||||
@installed_casks = nil
|
||||
@outdated_casks = nil
|
||||
end
|
||||
|
||||
def upgrading?(no_upgrade, name, options)
|
||||
private_class_method def self.upgrading?(no_upgrade, name, options)
|
||||
return false if no_upgrade
|
||||
return true if outdated_casks.include?(name)
|
||||
return false unless options[:greedy]
|
||||
@ -19,7 +17,7 @@ module Homebrew
|
||||
Homebrew::Bundle::CaskDumper.cask_is_outdated_using_greedy?(name)
|
||||
end
|
||||
|
||||
def preinstall(name, no_upgrade: false, verbose: false, **options)
|
||||
def self.preinstall(name, no_upgrade: false, verbose: false, **options)
|
||||
if installed_casks.include?(name) && !upgrading?(no_upgrade, name, options)
|
||||
puts "Skipping install of #{name} cask. It is already installed." if verbose
|
||||
return false
|
||||
@ -28,7 +26,7 @@ module Homebrew
|
||||
true
|
||||
end
|
||||
|
||||
def install(name, preinstall: true, no_upgrade: false, verbose: false, force: false, **options)
|
||||
def self.install(name, preinstall: true, no_upgrade: false, verbose: false, force: false, **options)
|
||||
return true unless preinstall
|
||||
|
||||
full_name = options.fetch(:full_name, name)
|
||||
@ -73,7 +71,7 @@ module Homebrew
|
||||
result
|
||||
end
|
||||
|
||||
def postinstall_change_state!(name:, options:, verbose:)
|
||||
private_class_method def self.postinstall_change_state!(name:, options:, verbose:)
|
||||
postinstall = options.fetch(:postinstall, nil)
|
||||
return true if postinstall.blank?
|
||||
|
||||
@ -88,19 +86,19 @@ module Homebrew
|
||||
!cask_upgradable?(cask)
|
||||
end
|
||||
|
||||
def cask_installed?(cask)
|
||||
def self.cask_installed?(cask)
|
||||
installed_casks.include? cask
|
||||
end
|
||||
|
||||
def cask_upgradable?(cask)
|
||||
def self.cask_upgradable?(cask)
|
||||
outdated_casks.include? cask
|
||||
end
|
||||
|
||||
def installed_casks
|
||||
def self.installed_casks
|
||||
@installed_casks ||= Homebrew::Bundle::CaskDumper.cask_names
|
||||
end
|
||||
|
||||
def outdated_casks
|
||||
def self.outdated_casks
|
||||
@outdated_casks ||= Homebrew::Bundle::CaskDumper.outdated_cask_names
|
||||
end
|
||||
end
|
||||
|
@ -1,7 +0,0 @@
|
||||
# typed: strict
|
||||
|
||||
module Homebrew::Bundle
|
||||
module CaskInstaller
|
||||
include Kernel
|
||||
end
|
||||
end
|
@ -55,8 +55,6 @@ module Homebrew
|
||||
end
|
||||
end
|
||||
|
||||
module_function
|
||||
|
||||
CheckResult = Struct.new :work_to_be_done, :errors
|
||||
|
||||
CHECKS = {
|
||||
@ -68,7 +66,7 @@ module Homebrew
|
||||
formulae_to_start: "Services",
|
||||
}.freeze
|
||||
|
||||
def check(global: false, file: nil, exit_on_first_error: false, no_upgrade: false, verbose: false)
|
||||
def self.check(global: false, file: nil, exit_on_first_error: false, no_upgrade: false, verbose: false)
|
||||
@dsl ||= Brewfile.read(global:, file:)
|
||||
|
||||
check_method_names = CHECKS.keys
|
||||
@ -89,49 +87,49 @@ module Homebrew
|
||||
CheckResult.new work_to_be_done, errors
|
||||
end
|
||||
|
||||
def casks_to_install(exit_on_first_error: false, no_upgrade: false, verbose: false)
|
||||
def self.casks_to_install(exit_on_first_error: false, no_upgrade: false, verbose: false)
|
||||
Homebrew::Bundle::Checker::CaskChecker.new.find_actionable(
|
||||
@dsl.entries,
|
||||
exit_on_first_error:, no_upgrade:, verbose:,
|
||||
)
|
||||
end
|
||||
|
||||
def formulae_to_install(exit_on_first_error: false, no_upgrade: false, verbose: false)
|
||||
def self.formulae_to_install(exit_on_first_error: false, no_upgrade: false, verbose: false)
|
||||
Homebrew::Bundle::Checker::BrewChecker.new.find_actionable(
|
||||
@dsl.entries,
|
||||
exit_on_first_error:, no_upgrade:, verbose:,
|
||||
)
|
||||
end
|
||||
|
||||
def taps_to_tap(exit_on_first_error: false, no_upgrade: false, verbose: false)
|
||||
def self.taps_to_tap(exit_on_first_error: false, no_upgrade: false, verbose: false)
|
||||
Homebrew::Bundle::Checker::TapChecker.new.find_actionable(
|
||||
@dsl.entries,
|
||||
exit_on_first_error:, no_upgrade:, verbose:,
|
||||
)
|
||||
end
|
||||
|
||||
def apps_to_install(exit_on_first_error: false, no_upgrade: false, verbose: false)
|
||||
def self.apps_to_install(exit_on_first_error: false, no_upgrade: false, verbose: false)
|
||||
Homebrew::Bundle::Checker::MacAppStoreChecker.new.find_actionable(
|
||||
@dsl.entries,
|
||||
exit_on_first_error:, no_upgrade:, verbose:,
|
||||
)
|
||||
end
|
||||
|
||||
def extensions_to_install(exit_on_first_error: false, no_upgrade: false, verbose: false)
|
||||
def self.extensions_to_install(exit_on_first_error: false, no_upgrade: false, verbose: false)
|
||||
Homebrew::Bundle::Checker::VscodeExtensionChecker.new.find_actionable(
|
||||
@dsl.entries,
|
||||
exit_on_first_error:, no_upgrade:, verbose:,
|
||||
)
|
||||
end
|
||||
|
||||
def formulae_to_start(exit_on_first_error: false, no_upgrade: false, verbose: false)
|
||||
def self.formulae_to_start(exit_on_first_error: false, no_upgrade: false, verbose: false)
|
||||
Homebrew::Bundle::Checker::BrewServiceChecker.new.find_actionable(
|
||||
@dsl.entries,
|
||||
exit_on_first_error:, no_upgrade:, verbose:,
|
||||
)
|
||||
end
|
||||
|
||||
def reset!
|
||||
def self.reset!
|
||||
@dsl = nil
|
||||
Homebrew::Bundle::CaskDumper.reset!
|
||||
Homebrew::Bundle::BrewDumper.reset!
|
||||
|
@ -5,9 +5,7 @@ module Homebrew
|
||||
module Bundle
|
||||
module Commands
|
||||
module Add
|
||||
module_function
|
||||
|
||||
def run(*args, type:, global:, file:)
|
||||
def self.run(*args, type:, global:, file:)
|
||||
Homebrew::Bundle::Adder.add(*args, type:, global:, file:)
|
||||
end
|
||||
end
|
||||
|
@ -5,12 +5,10 @@ module Homebrew
|
||||
module Bundle
|
||||
module Commands
|
||||
module Check
|
||||
module_function
|
||||
|
||||
ARROW = "→"
|
||||
FAILURE_MESSAGE = "brew bundle can't satisfy your Brewfile's dependencies."
|
||||
|
||||
def run(global: false, file: nil, no_upgrade: false, verbose: false)
|
||||
def self.run(global: false, file: nil, no_upgrade: false, verbose: false)
|
||||
output_errors = verbose
|
||||
exit_on_first_error = !verbose
|
||||
check_result = Homebrew::Bundle::Checker.check(
|
||||
|
@ -8,9 +8,7 @@ module Homebrew
|
||||
module Commands
|
||||
# TODO: refactor into multiple modules
|
||||
module Cleanup
|
||||
module_function
|
||||
|
||||
def reset!
|
||||
def self.reset!
|
||||
@dsl = nil
|
||||
@kept_casks = nil
|
||||
@kept_formulae = nil
|
||||
@ -21,7 +19,7 @@ module Homebrew
|
||||
Homebrew::Bundle::BrewServices.reset!
|
||||
end
|
||||
|
||||
def run(global: false, file: nil, force: false, zap: false, dsl: nil)
|
||||
def self.run(global: false, file: nil, force: false, zap: false, dsl: nil)
|
||||
@dsl ||= dsl
|
||||
|
||||
casks = casks_to_uninstall(global:, file:)
|
||||
@ -88,11 +86,11 @@ module Homebrew
|
||||
end
|
||||
end
|
||||
|
||||
def casks_to_uninstall(global: false, file: nil)
|
||||
def self.casks_to_uninstall(global: false, file: nil)
|
||||
Homebrew::Bundle::CaskDumper.cask_names - kept_casks(global:, file:)
|
||||
end
|
||||
|
||||
def formulae_to_uninstall(global: false, file: nil)
|
||||
def self.formulae_to_uninstall(global: false, file: nil)
|
||||
kept_formulae = self.kept_formulae(global:, file:)
|
||||
|
||||
current_formulae = Homebrew::Bundle::BrewDumper.formulae
|
||||
@ -102,7 +100,7 @@ module Homebrew
|
||||
current_formulae.map { |f| f[:full_name] }
|
||||
end
|
||||
|
||||
def kept_formulae(global: false, file: nil)
|
||||
private_class_method def self.kept_formulae(global: false, file: nil)
|
||||
@kept_formulae ||= begin
|
||||
@dsl ||= Brewfile.read(global:, file:)
|
||||
|
||||
@ -118,14 +116,14 @@ module Homebrew
|
||||
end
|
||||
end
|
||||
|
||||
def kept_casks(global: false, file: nil)
|
||||
private_class_method def self.kept_casks(global: false, file: nil)
|
||||
return @kept_casks if @kept_casks
|
||||
|
||||
@dsl ||= Brewfile.read(global:, file:)
|
||||
@kept_casks = @dsl.entries.select { |e| e.type == :cask }.map(&:name)
|
||||
end
|
||||
|
||||
def recursive_dependencies(current_formulae, formulae_names, top_level: true)
|
||||
private_class_method def self.recursive_dependencies(current_formulae, formulae_names, top_level: true)
|
||||
@checked_formulae_names = [] if top_level
|
||||
dependencies = T.let([], T::Array[Formula])
|
||||
|
||||
@ -153,7 +151,7 @@ module Homebrew
|
||||
|
||||
IGNORED_TAPS = %w[homebrew/core].freeze
|
||||
|
||||
def taps_to_untap(global: false, file: nil)
|
||||
def self.taps_to_untap(global: false, file: nil)
|
||||
@dsl ||= Brewfile.read(global:, file:)
|
||||
kept_formulae = self.kept_formulae(global:, file:).filter_map(&method(:lookup_formula))
|
||||
kept_taps = @dsl.entries.select { |e| e.type == :tap }.map(&:name)
|
||||
@ -162,14 +160,14 @@ module Homebrew
|
||||
current_taps - kept_taps - IGNORED_TAPS
|
||||
end
|
||||
|
||||
def lookup_formula(formula)
|
||||
def self.lookup_formula(formula)
|
||||
Formulary.factory(formula)
|
||||
rescue TapFormulaUnavailableError
|
||||
# ignore these as an unavailable formula implies there is no tap to worry about
|
||||
nil
|
||||
end
|
||||
|
||||
def vscode_extensions_to_uninstall(global: false, file: nil)
|
||||
def self.vscode_extensions_to_uninstall(global: false, file: nil)
|
||||
@dsl ||= Brewfile.read(global:, file:)
|
||||
kept_extensions = @dsl.entries.select { |e| e.type == :vscode }.map { |x| x.name.downcase }
|
||||
|
||||
@ -182,7 +180,7 @@ module Homebrew
|
||||
current_extensions - kept_extensions
|
||||
end
|
||||
|
||||
def system_output_no_stderr(cmd, *args)
|
||||
def self.system_output_no_stderr(cmd, *args)
|
||||
IO.popen([cmd, *args], err: :close).read
|
||||
end
|
||||
end
|
||||
|
@ -1,29 +0,0 @@
|
||||
# typed: strict
|
||||
|
||||
module Homebrew::Bundle
|
||||
module Commands
|
||||
module Check
|
||||
include Kernel
|
||||
end
|
||||
|
||||
module Cleanup
|
||||
include Kernel
|
||||
end
|
||||
|
||||
module Dump
|
||||
include Kernel
|
||||
end
|
||||
|
||||
module Exec
|
||||
include Kernel
|
||||
end
|
||||
|
||||
module Install
|
||||
include Kernel
|
||||
end
|
||||
|
||||
module List
|
||||
include Kernel
|
||||
end
|
||||
end
|
||||
end
|
@ -5,9 +5,7 @@ module Homebrew
|
||||
module Bundle
|
||||
module Commands
|
||||
module Dump
|
||||
module_function
|
||||
|
||||
def run(global:, file:, describe:, force:, no_restart:, taps:, brews:, casks:, mas:, whalebrew:, vscode:)
|
||||
def self.run(global:, file:, describe:, force:, no_restart:, taps:, brews:, casks:, mas:, whalebrew:, vscode:)
|
||||
Homebrew::Bundle::Dumper.dump_brewfile(
|
||||
global:, file:, describe:, force:, no_restart:, taps:, brews:, casks:, mas:, whalebrew:, vscode:,
|
||||
)
|
||||
|
@ -10,8 +10,6 @@ module Homebrew
|
||||
module Bundle
|
||||
module Commands
|
||||
module Exec
|
||||
module_function
|
||||
|
||||
# Homebrew's global environment variables that we don't want to leak into
|
||||
# the `brew bundle exec` environment.
|
||||
HOMEBREW_ENV_CLEANUP = %w[
|
||||
@ -49,7 +47,7 @@ module Homebrew
|
||||
|
||||
PATH_LIKE_ENV_REGEX = /.+#{File::PATH_SEPARATOR}/
|
||||
|
||||
def run(*args, global: false, file: nil, subcommand: "")
|
||||
def self.run(*args, global: false, file: nil, subcommand: "")
|
||||
# Cleanup Homebrew's global environment
|
||||
HOMEBREW_ENV_CLEANUP.each { |key| ENV.delete(key) }
|
||||
|
||||
|
@ -5,9 +5,7 @@ module Homebrew
|
||||
module Bundle
|
||||
module Commands
|
||||
module Install
|
||||
module_function
|
||||
|
||||
def run(global: false, file: nil, no_lock: false, no_upgrade: false, verbose: false, force: false,
|
||||
def self.run(global: false, file: nil, no_lock: false, no_upgrade: false, verbose: false, force: false,
|
||||
quiet: false)
|
||||
@dsl = Brewfile.read(global:, file:)
|
||||
Homebrew::Bundle::Installer.install(
|
||||
@ -16,7 +14,7 @@ module Homebrew
|
||||
) || exit(1)
|
||||
end
|
||||
|
||||
def dsl
|
||||
def self.dsl
|
||||
@dsl
|
||||
end
|
||||
end
|
||||
|
@ -5,9 +5,7 @@ module Homebrew
|
||||
module Bundle
|
||||
module Commands
|
||||
module List
|
||||
module_function
|
||||
|
||||
def run(global:, file:, brews:, casks:, taps:, mas:, whalebrew:, vscode:)
|
||||
def self.run(global:, file:, brews:, casks:, taps:, mas:, whalebrew:, vscode:)
|
||||
parsed_entries = Brewfile.read(global:, file:).entries
|
||||
Homebrew::Bundle::Lister.list(
|
||||
parsed_entries,
|
||||
|
@ -5,9 +5,7 @@ module Homebrew
|
||||
module Bundle
|
||||
module Commands
|
||||
module Remove
|
||||
module_function
|
||||
|
||||
def run(*args, type:, global:, file:)
|
||||
def self.run(*args, type:, global:, file:)
|
||||
Homebrew::Bundle::Remover.remove(*args, type:, global:, file:)
|
||||
end
|
||||
end
|
||||
|
@ -7,15 +7,13 @@ require "pathname"
|
||||
module Homebrew
|
||||
module Bundle
|
||||
module Dumper
|
||||
module_function
|
||||
|
||||
def can_write_to_brewfile?(brewfile_path, force: false)
|
||||
private_class_method def self.can_write_to_brewfile?(brewfile_path, force: false)
|
||||
raise "#{brewfile_path} already exists" if should_not_write_file?(brewfile_path, overwrite: force)
|
||||
|
||||
true
|
||||
end
|
||||
|
||||
def build_brewfile(describe:, no_restart:, brews:, taps:, casks:, mas:, whalebrew:, vscode:)
|
||||
def self.build_brewfile(describe:, no_restart:, brews:, taps:, casks:, mas:, whalebrew:, vscode:)
|
||||
content = []
|
||||
content << TapDumper.dump if taps
|
||||
content << BrewDumper.dump(describe:, no_restart:) if brews
|
||||
@ -26,7 +24,7 @@ module Homebrew
|
||||
"#{content.reject(&:empty?).join("\n")}\n"
|
||||
end
|
||||
|
||||
def dump_brewfile(global:, file:, describe:, force:, no_restart:, brews:, taps:, casks:, mas:, whalebrew:,
|
||||
def self.dump_brewfile(global:, file:, describe:, force:, no_restart:, brews:, taps:, casks:, mas:, whalebrew:,
|
||||
vscode:)
|
||||
path = brewfile_path(global:, file:)
|
||||
can_write_to_brewfile?(path, force:)
|
||||
@ -34,15 +32,15 @@ module Homebrew
|
||||
write_file path, content
|
||||
end
|
||||
|
||||
def brewfile_path(global: false, file: nil)
|
||||
def self.brewfile_path(global: false, file: nil)
|
||||
Brewfile.path(dash_writes_to_stdout: true, global:, file:)
|
||||
end
|
||||
|
||||
def should_not_write_file?(file, overwrite: false)
|
||||
private_class_method def self.should_not_write_file?(file, overwrite: false)
|
||||
file.exist? && !overwrite && file.to_s != "/dev/stdout"
|
||||
end
|
||||
|
||||
def write_file(file, content)
|
||||
def self.write_file(file, content)
|
||||
Bundle.exchange_uid_if_needed! do
|
||||
file.open("w") { |io| io.write content }
|
||||
end
|
||||
|
@ -1,7 +0,0 @@
|
||||
# typed: strict
|
||||
|
||||
module Homebrew::Bundle
|
||||
module Dumper
|
||||
include Kernel
|
||||
end
|
||||
end
|
@ -4,10 +4,8 @@
|
||||
module Homebrew
|
||||
module Bundle
|
||||
module Installer
|
||||
module_function
|
||||
|
||||
def install(entries, global: false, file: nil, no_lock: false, no_upgrade: false, verbose: false, force: false,
|
||||
quiet: false)
|
||||
def self.install(entries, global: false, file: nil, no_lock: false, no_upgrade: false, verbose: false,
|
||||
force: false, quiet: false)
|
||||
success = 0
|
||||
failure = 0
|
||||
|
||||
|
@ -1,7 +0,0 @@
|
||||
# typed: strict
|
||||
|
||||
module Homebrew::Bundle
|
||||
module Installer
|
||||
include Kernel
|
||||
end
|
||||
end
|
@ -4,15 +4,13 @@
|
||||
module Homebrew
|
||||
module Bundle
|
||||
module Lister
|
||||
module_function
|
||||
|
||||
def list(entries, brews:, casks:, taps:, mas:, whalebrew:, vscode:)
|
||||
def self.list(entries, brews:, casks:, taps:, mas:, whalebrew:, vscode:)
|
||||
entries.each do |entry|
|
||||
puts entry.name if show?(entry.type, brews:, casks:, taps:, mas:, whalebrew:, vscode:)
|
||||
end
|
||||
end
|
||||
|
||||
def show?(type, brews:, casks:, taps:, mas:, whalebrew:, vscode:)
|
||||
private_class_method def self.show?(type, brews:, casks:, taps:, mas:, whalebrew:, vscode:)
|
||||
return true if brews && type == :brew
|
||||
return true if casks && type == :cask
|
||||
return true if taps && type == :tap
|
||||
|
@ -1,7 +0,0 @@
|
||||
# typed: strict
|
||||
|
||||
module Homebrew::Bundle
|
||||
module Lister
|
||||
include Kernel
|
||||
end
|
||||
end
|
@ -6,13 +6,11 @@ require "json"
|
||||
module Homebrew
|
||||
module Bundle
|
||||
module MacAppStoreDumper
|
||||
module_function
|
||||
|
||||
def reset!
|
||||
def self.reset!
|
||||
@apps = nil
|
||||
end
|
||||
|
||||
def apps
|
||||
def self.apps
|
||||
@apps ||= if Bundle.mas_installed?
|
||||
`mas list 2>/dev/null`.split("\n").map do |app|
|
||||
app_details = app.match(/\A(?<id>\d+)\s+(?<name>.*?)\s+\((?<version>[\d.]*)\)\Z/)
|
||||
@ -29,11 +27,11 @@ module Homebrew
|
||||
end.compact
|
||||
end
|
||||
|
||||
def app_ids
|
||||
def self.app_ids
|
||||
apps.map { |id, _| id.to_i }
|
||||
end
|
||||
|
||||
def dump
|
||||
def self.dump
|
||||
apps.sort_by { |_, name| name.downcase }.map { |id, name| "mas \"#{name}\", id: #{id}" }.join("\n")
|
||||
end
|
||||
end
|
||||
|
@ -1,7 +0,0 @@
|
||||
# typed: strict
|
||||
|
||||
module Homebrew::Bundle
|
||||
module MacAppStoreDumper
|
||||
include Kernel
|
||||
end
|
||||
end
|
@ -6,14 +6,12 @@ require "os"
|
||||
module Homebrew
|
||||
module Bundle
|
||||
module MacAppStoreInstaller
|
||||
module_function
|
||||
|
||||
def reset!
|
||||
def self.reset!
|
||||
@installed_app_ids = nil
|
||||
@outdated_app_ids = nil
|
||||
end
|
||||
|
||||
def preinstall(name, id, no_upgrade: false, verbose: false)
|
||||
def self.preinstall(name, id, no_upgrade: false, verbose: false)
|
||||
unless Bundle.mas_installed?
|
||||
puts "Installing mas. It is not currently installed." if verbose
|
||||
Bundle.brew("install", "mas", verbose:)
|
||||
@ -29,7 +27,7 @@ module Homebrew
|
||||
true
|
||||
end
|
||||
|
||||
def install(name, id, preinstall: true, no_upgrade: false, verbose: false, force: false)
|
||||
def self.install(name, id, preinstall: true, no_upgrade: false, verbose: false, force: false)
|
||||
return true unless preinstall
|
||||
|
||||
if app_id_installed?(id)
|
||||
@ -54,19 +52,19 @@ module Homebrew
|
||||
!app_id_upgradable?(id)
|
||||
end
|
||||
|
||||
def app_id_installed?(id)
|
||||
def self.app_id_installed?(id)
|
||||
installed_app_ids.include? id
|
||||
end
|
||||
|
||||
def app_id_upgradable?(id)
|
||||
def self.app_id_upgradable?(id)
|
||||
outdated_app_ids.include? id
|
||||
end
|
||||
|
||||
def installed_app_ids
|
||||
def self.installed_app_ids
|
||||
@installed_app_ids ||= Homebrew::Bundle::MacAppStoreDumper.app_ids
|
||||
end
|
||||
|
||||
def outdated_app_ids
|
||||
def self.outdated_app_ids
|
||||
@outdated_app_ids ||= if Bundle.mas_installed?
|
||||
`mas outdated 2>/dev/null`.split("\n").map do |app|
|
||||
app.split(" ", 2).first.to_i
|
||||
|
@ -1,7 +0,0 @@
|
||||
# typed: strict
|
||||
|
||||
module Homebrew::Bundle
|
||||
module MacAppStoreInstaller
|
||||
include Kernel
|
||||
end
|
||||
end
|
@ -4,9 +4,7 @@
|
||||
module Homebrew
|
||||
module Bundle
|
||||
module Remover
|
||||
module_function
|
||||
|
||||
def remove(*args, type:, global:, file:)
|
||||
def self.remove(*args, type:, global:, file:)
|
||||
brewfile = Brewfile.read(global:, file:)
|
||||
content = brewfile.input
|
||||
entry_type = type.to_s if type != :none
|
||||
@ -36,7 +34,7 @@ module Homebrew
|
||||
Dumper.write_file path, new_content
|
||||
end
|
||||
|
||||
def possible_names(formula_name, raise_error: true)
|
||||
def self.possible_names(formula_name, raise_error: true)
|
||||
formula = Formulary.factory(formula_name)
|
||||
[formula_name, formula.name, formula.full_name, *formula.aliases, *formula.oldnames].compact.uniq
|
||||
rescue FormulaUnavailableError
|
||||
|
@ -1,7 +0,0 @@
|
||||
# typed: strict
|
||||
|
||||
module Homebrew::Bundle
|
||||
module Remover
|
||||
include Kernel
|
||||
end
|
||||
end
|
@ -6,13 +6,11 @@ require "json"
|
||||
module Homebrew
|
||||
module Bundle
|
||||
module TapDumper
|
||||
module_function
|
||||
|
||||
def reset!
|
||||
def self.reset!
|
||||
@taps = nil
|
||||
end
|
||||
|
||||
def dump
|
||||
def self.dump
|
||||
taps.map do |tap|
|
||||
remote = if tap.custom_remote? && (tap_remote = tap.remote)
|
||||
if (api_token = ENV.fetch("HOMEBREW_GITHUB_API_TOKEN", false).presence)
|
||||
@ -29,17 +27,16 @@ module Homebrew
|
||||
end.sort.uniq.join("\n")
|
||||
end
|
||||
|
||||
def tap_names
|
||||
def self.tap_names
|
||||
taps.map(&:name)
|
||||
end
|
||||
|
||||
def taps
|
||||
private_class_method def self.taps
|
||||
@taps ||= begin
|
||||
require "tap"
|
||||
Tap.select(&:installed?).to_a
|
||||
end
|
||||
end
|
||||
private_class_method :taps
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1,7 +0,0 @@
|
||||
# typed: strict
|
||||
|
||||
module Homebrew::Bundle
|
||||
module TapDumper
|
||||
include Kernel
|
||||
end
|
||||
end
|
@ -4,9 +4,7 @@
|
||||
module Homebrew
|
||||
module Bundle
|
||||
module TapInstaller
|
||||
module_function
|
||||
|
||||
def preinstall(name, verbose: false, **_options)
|
||||
def self.preinstall(name, verbose: false, **_options)
|
||||
if installed_taps.include? name
|
||||
puts "Skipping install of #{name} tap. It is already installed." if verbose
|
||||
return false
|
||||
@ -15,7 +13,7 @@ module Homebrew
|
||||
true
|
||||
end
|
||||
|
||||
def install(name, preinstall: true, verbose: false, force: false, **options)
|
||||
def self.install(name, preinstall: true, verbose: false, force: false, **options)
|
||||
return true unless preinstall
|
||||
|
||||
puts "Installing #{name} tap. It is not currently installed." if verbose
|
||||
@ -38,7 +36,7 @@ module Homebrew
|
||||
true
|
||||
end
|
||||
|
||||
def installed_taps
|
||||
def self.installed_taps
|
||||
@installed_taps ||= Homebrew::Bundle::TapDumper.tap_names
|
||||
end
|
||||
end
|
||||
|
@ -1,7 +0,0 @@
|
||||
# typed: strict
|
||||
|
||||
module Homebrew::Bundle
|
||||
module TapInstaller
|
||||
include Kernel
|
||||
end
|
||||
end
|
@ -4,13 +4,11 @@
|
||||
module Homebrew
|
||||
module Bundle
|
||||
module VscodeExtensionDumper
|
||||
module_function
|
||||
|
||||
def reset!
|
||||
def self.reset!
|
||||
@extensions = nil
|
||||
end
|
||||
|
||||
def extensions
|
||||
def self.extensions
|
||||
@extensions ||= if Bundle.vscode_installed?
|
||||
Bundle.exchange_uid_if_needed! do
|
||||
`"#{Bundle.which_vscode}" --list-extensions 2>/dev/null`
|
||||
@ -20,7 +18,7 @@ module Homebrew
|
||||
end
|
||||
end
|
||||
|
||||
def dump
|
||||
def self.dump
|
||||
extensions.map { |name| "vscode \"#{name}\"" }.join("\n")
|
||||
end
|
||||
end
|
||||
|
@ -1,7 +0,0 @@
|
||||
# typed: strict
|
||||
|
||||
module Homebrew::Bundle
|
||||
module VscodeExtensionDumper
|
||||
include Kernel
|
||||
end
|
||||
end
|
@ -4,13 +4,11 @@
|
||||
module Homebrew
|
||||
module Bundle
|
||||
module VscodeExtensionInstaller
|
||||
module_function
|
||||
|
||||
def reset!
|
||||
def self.reset!
|
||||
@installed_extensions = nil
|
||||
end
|
||||
|
||||
def preinstall(name, no_upgrade: false, verbose: false)
|
||||
def self.preinstall(name, no_upgrade: false, verbose: false)
|
||||
if !Bundle.vscode_installed? && Bundle.cask_installed?
|
||||
puts "Installing visual-studio-code. It is not currently installed." if verbose
|
||||
Bundle.brew("install", "--cask", "visual-studio-code", verbose:)
|
||||
@ -26,7 +24,7 @@ module Homebrew
|
||||
true
|
||||
end
|
||||
|
||||
def install(name, preinstall: true, no_upgrade: false, verbose: false, force: false)
|
||||
def self.install(name, preinstall: true, no_upgrade: false, verbose: false, force: false)
|
||||
return true unless preinstall
|
||||
return true if extension_installed?(name)
|
||||
|
||||
@ -41,11 +39,11 @@ module Homebrew
|
||||
true
|
||||
end
|
||||
|
||||
def extension_installed?(name)
|
||||
def self.extension_installed?(name)
|
||||
installed_extensions.include? name.downcase
|
||||
end
|
||||
|
||||
def installed_extensions
|
||||
def self.installed_extensions
|
||||
@installed_extensions ||= Homebrew::Bundle::VscodeExtensionDumper.extensions
|
||||
end
|
||||
end
|
||||
|
@ -1,7 +0,0 @@
|
||||
# typed: strict
|
||||
|
||||
module Homebrew::Bundle
|
||||
module VscodeExtensionInstaller
|
||||
include Kernel
|
||||
end
|
||||
end
|
@ -4,13 +4,11 @@
|
||||
module Homebrew
|
||||
module Bundle
|
||||
module WhalebrewDumper
|
||||
module_function
|
||||
|
||||
def reset!
|
||||
def self.reset!
|
||||
@images = nil
|
||||
end
|
||||
|
||||
def images
|
||||
def self.images
|
||||
return [] unless Bundle.whalebrew_installed?
|
||||
|
||||
# odeprecated "`brew bundle` `whalebrew` support", "using `whalebrew` directly"
|
||||
@ -20,7 +18,7 @@ module Homebrew
|
||||
.uniq
|
||||
end
|
||||
|
||||
def dump
|
||||
def self.dump
|
||||
images.map { |image| "whalebrew \"#{image}\"" }.join("\n")
|
||||
end
|
||||
end
|
||||
|
@ -1,7 +0,0 @@
|
||||
# typed: strict
|
||||
|
||||
module Homebrew::Bundle
|
||||
module WhalebrewDumper
|
||||
include Kernel
|
||||
end
|
||||
end
|
@ -4,13 +4,11 @@
|
||||
module Homebrew
|
||||
module Bundle
|
||||
module WhalebrewInstaller
|
||||
module_function
|
||||
|
||||
def reset!
|
||||
def self.reset!
|
||||
@installed_images = nil
|
||||
end
|
||||
|
||||
def preinstall(name, verbose: false, **_options)
|
||||
def self.preinstall(name, verbose: false, **_options)
|
||||
unless Bundle.whalebrew_installed?
|
||||
puts "Installing whalebrew. It is not currently installed." if verbose
|
||||
Bundle.brew("install", "--formula", "whalebrew", verbose:)
|
||||
@ -25,7 +23,7 @@ module Homebrew
|
||||
true
|
||||
end
|
||||
|
||||
def install(name, preinstall: true, verbose: false, force: false, **_options)
|
||||
def self.install(name, preinstall: true, verbose: false, force: false, **_options)
|
||||
# odeprecated "`brew bundle` `whalebrew` support", "using `whalebrew` directly"
|
||||
return true unless preinstall
|
||||
|
||||
@ -37,11 +35,11 @@ module Homebrew
|
||||
true
|
||||
end
|
||||
|
||||
def image_installed?(image)
|
||||
def self.image_installed?(image)
|
||||
installed_images.include? image
|
||||
end
|
||||
|
||||
def installed_images
|
||||
def self.installed_images
|
||||
@installed_images ||= Homebrew::Bundle::WhalebrewDumper.images
|
||||
end
|
||||
end
|
||||
|
@ -1,7 +0,0 @@
|
||||
# typed: strict
|
||||
|
||||
module Homebrew::Bundle
|
||||
module WhalebrewInstaller
|
||||
include Kernel
|
||||
end
|
||||
end
|
@ -74,7 +74,7 @@ RSpec.describe Homebrew::Bundle::Commands::Check do
|
||||
|
||||
context "when apps are not installed", :needs_macos do
|
||||
it "raises an error" do
|
||||
allow_any_instance_of(Homebrew::Bundle::MacAppStoreDumper).to receive(:app_ids).and_return([])
|
||||
allow(Homebrew::Bundle::MacAppStoreDumper).to receive(:app_ids).and_return([])
|
||||
allow(Homebrew::Bundle::BrewInstaller).to receive(:upgradable_formulae).and_return([])
|
||||
allow_any_instance_of(Pathname).to receive(:read).and_return("mas 'foo', id: 123")
|
||||
expect { do_check }.to raise_error(SystemExit)
|
||||
|
Loading…
x
Reference in New Issue
Block a user