2025-04-19 22:22:42 +01:00
|
|
|
# typed: strict
|
2025-03-18 17:38:37 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Homebrew
|
|
|
|
module Bundle
|
|
|
|
module WhalebrewDumper
|
2025-04-19 22:22:42 +01:00
|
|
|
sig { void }
|
2025-03-21 04:24:55 +00:00
|
|
|
def self.reset!
|
2025-04-19 22:22:42 +01:00
|
|
|
@images = T.let(nil, T.nilable(T::Array[String]))
|
2025-03-18 17:38:37 +00:00
|
|
|
end
|
|
|
|
|
2025-04-19 22:22:42 +01:00
|
|
|
sig { returns(T::Array[T.nilable(String)]) }
|
2025-03-21 04:24:55 +00:00
|
|
|
def self.images
|
2025-03-18 17:38:37 +00:00
|
|
|
return [] unless Bundle.whalebrew_installed?
|
|
|
|
|
2025-04-22 17:15:23 +01:00
|
|
|
odeprecated "`brew bundle` `whalebrew` support", "using `whalebrew` directly"
|
2025-04-19 22:22:42 +01:00
|
|
|
@images ||= T.let(
|
|
|
|
`whalebrew list 2>/dev/null`.split("\n")
|
|
|
|
.reject { |line| line.start_with?("COMMAND ") }
|
|
|
|
.filter_map { |line| line.split(/\s+/).last }
|
|
|
|
.uniq,
|
|
|
|
T.nilable(T::Array[String]),
|
|
|
|
)
|
2025-03-18 17:38:37 +00:00
|
|
|
end
|
|
|
|
|
2025-04-19 22:22:42 +01:00
|
|
|
sig { returns(String) }
|
2025-03-21 04:24:55 +00:00
|
|
|
def self.dump
|
2025-03-18 17:38:37 +00:00
|
|
|
images.map { |image| "whalebrew \"#{image}\"" }.join("\n")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|