unversioned_cask_checker: check installer artifacts

This commit is contained in:
Bevan Kay 2022-12-05 14:26:38 +11:00
parent 001bacee18
commit 40fd8f7d78
No known key found for this signature in database
GPG Key ID: C55CB024B5314B57
4 changed files with 32 additions and 2 deletions

View File

@ -106,4 +106,12 @@ describe Homebrew::Livecheck::Strategy::ExtractPlist do
.to raise_error(TypeError, Homebrew::Livecheck::Strategy::INVALID_BLOCK_RETURN_VALUE_MSG)
end
end
describe "::find_versions" do
it "can be used with an installer artifact" do
cask = Cask::CaskLoader.load(cask_path("livecheck/installer-manual-livecheck"))
expect(extract_plist.find_versions(cask: cask)[:matches].values).to eq(["1.2.3"])
end
end
end

View File

@ -0,0 +1,16 @@
cask "installer-manual-livecheck" do
version "1.2.3"
sha256 "67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94"
url "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip"
name "With Installer Manual"
desc "Cask with a manual installer"
homepage "https://brew.sh/"
livecheck do
url :url
strategy :extract_plist
end
installer manual: "Caffeine.app"
end

View File

@ -36,6 +36,11 @@ module Homebrew
@qlplugins ||= @cask.artifacts.select { |a| a.is_a?(Cask::Artifact::Qlplugin) }
end
sig { returns(T::Array[Cask::Artifact::Installer]) }
def installers
@installers ||= @cask.artifacts.select { |a| a.is_a?(Cask::Artifact::Installer) }
end
sig { returns(T::Array[Cask::Artifact::Pkg]) }
def pkgs
@pkgs ||= @cask.artifacts.select { |a| a.is_a?(Cask::Artifact::Pkg) }
@ -88,8 +93,9 @@ module Homebrew
installer.extract_primary_container(to: dir)
info_plist_paths = apps.concat(qlplugins).flat_map do |artifact|
top_level_info_plists(Pathname.glob(dir/"**"/artifact.source.basename/"Contents"/"Info.plist")).sort
info_plist_paths = apps.concat(qlplugins, installers).flat_map do |artifact|
source = artifact.is_a?(Cask::Artifact::Installer) ? artifact.path : artifact.source.basename
top_level_info_plists(Pathname.glob(dir/"**"/source/"Contents"/"Info.plist")).sort
end
info_plist_paths.each(&parse_info_plist)