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