Merge pull request #14851 from hyuraku/move-cask/cmd/list-to-cask/list
Move `cask/cmd/list` to `cask/list`
This commit is contained in:
commit
8c333f4ec6
@ -13,7 +13,6 @@ require "cask/cmd/abstract_command"
|
|||||||
require "cask/cmd/audit"
|
require "cask/cmd/audit"
|
||||||
require "cask/cmd/fetch"
|
require "cask/cmd/fetch"
|
||||||
require "cask/cmd/install"
|
require "cask/cmd/install"
|
||||||
require "cask/cmd/list"
|
|
||||||
require "cask/cmd/reinstall"
|
require "cask/cmd/reinstall"
|
||||||
require "cask/cmd/uninstall"
|
require "cask/cmd/uninstall"
|
||||||
require "cask/cmd/upgrade"
|
require "cask/cmd/upgrade"
|
||||||
|
|||||||
@ -1,81 +0,0 @@
|
|||||||
# typed: false
|
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
require "cask/artifact/relocated"
|
|
||||||
|
|
||||||
module Cask
|
|
||||||
class Cmd
|
|
||||||
# Cask implementation of the `brew list` command.
|
|
||||||
#
|
|
||||||
# @api private
|
|
||||||
class List < AbstractCommand
|
|
||||||
extend T::Sig
|
|
||||||
|
|
||||||
def self.parser
|
|
||||||
super do
|
|
||||||
switch "-1",
|
|
||||||
description: "Force output to be one entry per line."
|
|
||||||
switch "--versions",
|
|
||||||
description: "Show the version number the listed casks."
|
|
||||||
switch "--full-name",
|
|
||||||
description: "Print casks with fully-qualified names."
|
|
||||||
switch "--json",
|
|
||||||
description: "Print a JSON representation of the listed casks. "
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
sig { void }
|
|
||||||
def run
|
|
||||||
self.class.list_casks(
|
|
||||||
*casks,
|
|
||||||
json: args.json?,
|
|
||||||
one: args.public_send(:"1?"),
|
|
||||||
full_name: args.full_name?,
|
|
||||||
versions: args.versions?,
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.list_casks(*casks, json: false, one: false, full_name: false, versions: false)
|
|
||||||
output = if casks.any?
|
|
||||||
casks.each do |cask|
|
|
||||||
raise CaskNotInstalledError, cask unless cask.installed?
|
|
||||||
end
|
|
||||||
else
|
|
||||||
Caskroom.casks
|
|
||||||
end
|
|
||||||
|
|
||||||
if json
|
|
||||||
puts JSON.pretty_generate(output.map(&:to_h))
|
|
||||||
elsif one
|
|
||||||
puts output.map(&:to_s)
|
|
||||||
elsif full_name
|
|
||||||
puts output.map(&:full_name).sort(&tap_and_name_comparison)
|
|
||||||
elsif versions
|
|
||||||
puts output.map(&method(:format_versioned))
|
|
||||||
elsif !output.empty? && casks.any?
|
|
||||||
output.map(&method(:list_artifacts))
|
|
||||||
elsif !output.empty?
|
|
||||||
puts Formatter.columns(output.map(&:to_s))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.list_artifacts(cask)
|
|
||||||
cask.artifacts.group_by(&:class).sort_by { |klass, _| klass.english_name }.each do |klass, artifacts|
|
|
||||||
next if [Artifact::Uninstall, Artifact::Zap].include? klass
|
|
||||||
|
|
||||||
ohai klass.english_name
|
|
||||||
artifacts.each do |artifact|
|
|
||||||
puts artifact.summarize_installed if artifact.respond_to?(:summarize_installed)
|
|
||||||
next if artifact.respond_to?(:summarize_installed)
|
|
||||||
|
|
||||||
puts artifact
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.format_versioned(cask)
|
|
||||||
cask.to_s.concat(cask.versions.map(&:to_s).join(" ").prepend(" "))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
49
Library/Homebrew/cask/list.rb
Normal file
49
Library/Homebrew/cask/list.rb
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
# typed: false
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "cask/artifact/relocated"
|
||||||
|
|
||||||
|
module Cask
|
||||||
|
# @api private
|
||||||
|
class List
|
||||||
|
def self.list_casks(*casks, one: false, full_name: false, versions: false)
|
||||||
|
output = if casks.any?
|
||||||
|
casks.each do |cask|
|
||||||
|
raise CaskNotInstalledError, cask unless cask.installed?
|
||||||
|
end
|
||||||
|
else
|
||||||
|
Caskroom.casks
|
||||||
|
end
|
||||||
|
|
||||||
|
if one
|
||||||
|
puts output.map(&:to_s)
|
||||||
|
elsif full_name
|
||||||
|
puts output.map(&:full_name).sort(&tap_and_name_comparison)
|
||||||
|
elsif versions
|
||||||
|
puts output.map(&method(:format_versioned))
|
||||||
|
elsif !output.empty? && casks.any?
|
||||||
|
output.map(&method(:list_artifacts))
|
||||||
|
elsif !output.empty?
|
||||||
|
puts Formatter.columns(output.map(&:to_s))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.list_artifacts(cask)
|
||||||
|
cask.artifacts.group_by(&:class).sort_by { |klass, _| klass.english_name }.each do |klass, artifacts|
|
||||||
|
next if [Artifact::Uninstall, Artifact::Zap].include? klass
|
||||||
|
|
||||||
|
ohai klass.english_name
|
||||||
|
artifacts.each do |artifact|
|
||||||
|
puts artifact.summarize_installed if artifact.respond_to?(:summarize_installed)
|
||||||
|
next if artifact.respond_to?(:summarize_installed)
|
||||||
|
|
||||||
|
puts artifact
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.format_versioned(cask)
|
||||||
|
cask.to_s.concat(cask.versions.map(&:to_s).join(" ").prepend(" "))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -4,7 +4,7 @@
|
|||||||
require "metafiles"
|
require "metafiles"
|
||||||
require "formula"
|
require "formula"
|
||||||
require "cli/parser"
|
require "cli/parser"
|
||||||
require "cask/cmd"
|
require "cask/list"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
extend T::Sig
|
extend T::Sig
|
||||||
@ -164,7 +164,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
return if casks.blank?
|
return if casks.blank?
|
||||||
|
|
||||||
Cask::Cmd::List.list_casks(
|
Cask::List.list_casks(
|
||||||
*casks,
|
*casks,
|
||||||
one: args.public_send(:"1?"),
|
one: args.public_send(:"1?"),
|
||||||
full_name: args.full_name?,
|
full_name: args.full_name?,
|
||||||
|
|||||||
@ -1,367 +0,0 @@
|
|||||||
# typed: false
|
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
describe Cask::Cmd::List, :cask do
|
|
||||||
it "lists the installed Casks in a pretty fashion" do
|
|
||||||
casks = %w[local-caffeine local-transmission].map { |c| Cask::CaskLoader.load(c) }
|
|
||||||
|
|
||||||
casks.each do |c|
|
|
||||||
InstallHelper.install_with_caskfile(c)
|
|
||||||
end
|
|
||||||
|
|
||||||
expect {
|
|
||||||
described_class.run
|
|
||||||
}.to output(<<~EOS).to_stdout
|
|
||||||
local-caffeine
|
|
||||||
local-transmission
|
|
||||||
EOS
|
|
||||||
end
|
|
||||||
|
|
||||||
it "lists oneline" do
|
|
||||||
casks = %w[
|
|
||||||
local-caffeine
|
|
||||||
third-party/tap/third-party-cask
|
|
||||||
local-transmission
|
|
||||||
].map { |c| Cask::CaskLoader.load(c) }
|
|
||||||
|
|
||||||
casks.each do |c|
|
|
||||||
InstallHelper.install_with_caskfile(c)
|
|
||||||
end
|
|
||||||
|
|
||||||
expect {
|
|
||||||
described_class.run("-1")
|
|
||||||
}.to output(<<~EOS).to_stdout
|
|
||||||
local-caffeine
|
|
||||||
local-transmission
|
|
||||||
third-party-cask
|
|
||||||
EOS
|
|
||||||
end
|
|
||||||
|
|
||||||
it "lists full names" do
|
|
||||||
casks = %w[
|
|
||||||
local-caffeine
|
|
||||||
third-party/tap/third-party-cask
|
|
||||||
local-transmission
|
|
||||||
].map { |c| Cask::CaskLoader.load(c) }
|
|
||||||
|
|
||||||
casks.each do |c|
|
|
||||||
InstallHelper.install_with_caskfile(c)
|
|
||||||
end
|
|
||||||
|
|
||||||
expect {
|
|
||||||
described_class.run("--full-name")
|
|
||||||
}.to output(<<~EOS).to_stdout
|
|
||||||
local-caffeine
|
|
||||||
local-transmission
|
|
||||||
third-party/tap/third-party-cask
|
|
||||||
EOS
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "lists versions" do
|
|
||||||
let(:casks) { ["local-caffeine", "local-transmission"] }
|
|
||||||
let(:expected_output) {
|
|
||||||
<<~EOS
|
|
||||||
local-caffeine 1.2.3
|
|
||||||
local-transmission 2.61
|
|
||||||
EOS
|
|
||||||
}
|
|
||||||
|
|
||||||
before do
|
|
||||||
casks.map(&Cask::CaskLoader.method(:load)).each(&InstallHelper.method(:install_with_caskfile))
|
|
||||||
end
|
|
||||||
|
|
||||||
it "of all installed Casks" do
|
|
||||||
expect {
|
|
||||||
described_class.run("--versions")
|
|
||||||
}.to output(expected_output).to_stdout
|
|
||||||
end
|
|
||||||
|
|
||||||
it "of given Casks" do
|
|
||||||
expect {
|
|
||||||
described_class.run("--versions", "local-caffeine", "local-transmission")
|
|
||||||
}.to output(expected_output).to_stdout
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "lists json" do
|
|
||||||
let(:casks) {
|
|
||||||
["local-caffeine", "local-transmission", "multiple-versions", "with-languages",
|
|
||||||
"third-party/tap/third-party-cask"]
|
|
||||||
}
|
|
||||||
let(:expected_output) {
|
|
||||||
<<~EOS
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"token": "local-caffeine",
|
|
||||||
"full_token": "local-caffeine",
|
|
||||||
"tap": "homebrew/cask",
|
|
||||||
"name": [
|
|
||||||
|
|
||||||
],
|
|
||||||
"desc": null,
|
|
||||||
"homepage": "https://brew.sh/",
|
|
||||||
"url": "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip",
|
|
||||||
"url_specs": {
|
|
||||||
},
|
|
||||||
"appcast": null,
|
|
||||||
"version": "1.2.3",
|
|
||||||
"versions": {
|
|
||||||
},
|
|
||||||
"installed": "1.2.3",
|
|
||||||
"outdated": false,
|
|
||||||
"sha256": "67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94",
|
|
||||||
"artifacts": [
|
|
||||||
{
|
|
||||||
"app": [
|
|
||||||
"Caffeine.app"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"zap": [
|
|
||||||
{
|
|
||||||
"trash": "#{TEST_FIXTURE_DIR}/cask/caffeine/org.example.caffeine.plist"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"caveats": null,
|
|
||||||
"depends_on": {
|
|
||||||
},
|
|
||||||
"conflicts_with": null,
|
|
||||||
"container": null,
|
|
||||||
"auto_updates": null,
|
|
||||||
"tap_git_head": null,
|
|
||||||
"languages": [
|
|
||||||
|
|
||||||
],
|
|
||||||
"ruby_source_checksum": {
|
|
||||||
"sha256": "#{Digest::SHA256.file(Tap.default_cask_tap.cask_dir/"local-caffeine.rb").hexdigest}"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"token": "local-transmission",
|
|
||||||
"full_token": "local-transmission",
|
|
||||||
"tap": "homebrew/cask",
|
|
||||||
"name": [
|
|
||||||
"Transmission"
|
|
||||||
],
|
|
||||||
"desc": "BitTorrent client",
|
|
||||||
"homepage": "https://transmissionbt.com/",
|
|
||||||
"url": "file://#{TEST_FIXTURE_DIR}/cask/transmission-2.61.dmg",
|
|
||||||
"url_specs": {
|
|
||||||
},
|
|
||||||
"appcast": null,
|
|
||||||
"version": "2.61",
|
|
||||||
"versions": {
|
|
||||||
},
|
|
||||||
"installed": "2.61",
|
|
||||||
"outdated": false,
|
|
||||||
"sha256": "e44ffa103fbf83f55c8d0b1bea309a43b2880798dae8620b1ee8da5e1095ec68",
|
|
||||||
"artifacts": [
|
|
||||||
{
|
|
||||||
"app": [
|
|
||||||
"Transmission.app"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"caveats": null,
|
|
||||||
"depends_on": {
|
|
||||||
},
|
|
||||||
"conflicts_with": null,
|
|
||||||
"container": null,
|
|
||||||
"auto_updates": null,
|
|
||||||
"tap_git_head": null,
|
|
||||||
"languages": [
|
|
||||||
|
|
||||||
],
|
|
||||||
"ruby_source_checksum": {
|
|
||||||
"sha256": "#{Digest::SHA256.file(Tap.default_cask_tap.cask_dir/"local-transmission.rb").hexdigest}"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"token": "multiple-versions",
|
|
||||||
"full_token": "multiple-versions",
|
|
||||||
"tap": "homebrew/cask",
|
|
||||||
"name": [
|
|
||||||
|
|
||||||
],
|
|
||||||
"desc": null,
|
|
||||||
"homepage": "https://brew.sh/",
|
|
||||||
"url": "file://#{TEST_FIXTURE_DIR}/cask/caffeine/darwin-arm64/1.2.3/arm.zip",
|
|
||||||
"url_specs": {
|
|
||||||
},
|
|
||||||
"appcast": null,
|
|
||||||
"version": "1.2.3",
|
|
||||||
"versions": {
|
|
||||||
"big_sur": "1.2.0",
|
|
||||||
"catalina": "1.0.0",
|
|
||||||
"mojave": "1.0.0"
|
|
||||||
},
|
|
||||||
"installed": "1.2.3",
|
|
||||||
"outdated": false,
|
|
||||||
"sha256": "67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94",
|
|
||||||
"artifacts": [
|
|
||||||
{
|
|
||||||
"app": [
|
|
||||||
"Caffeine.app"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"caveats": null,
|
|
||||||
"depends_on": {
|
|
||||||
},
|
|
||||||
"conflicts_with": null,
|
|
||||||
"container": null,
|
|
||||||
"auto_updates": null,
|
|
||||||
"tap_git_head": null,
|
|
||||||
"languages": [
|
|
||||||
|
|
||||||
],
|
|
||||||
"ruby_source_checksum": {
|
|
||||||
"sha256": "#{Digest::SHA256.file(Tap.default_cask_tap.cask_dir/"multiple-versions.rb").hexdigest}"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"token": "third-party-cask",
|
|
||||||
"full_token": "third-party/tap/third-party-cask",
|
|
||||||
"tap": "third-party/tap",
|
|
||||||
"name": [
|
|
||||||
|
|
||||||
],
|
|
||||||
"desc": null,
|
|
||||||
"homepage": "https://brew.sh/",
|
|
||||||
"url": "https://brew.sh/ThirdParty.dmg",
|
|
||||||
"url_specs": {
|
|
||||||
},
|
|
||||||
"appcast": null,
|
|
||||||
"version": "1.2.3",
|
|
||||||
"versions": {
|
|
||||||
},
|
|
||||||
"installed": "1.2.3",
|
|
||||||
"outdated": false,
|
|
||||||
"sha256": "8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b",
|
|
||||||
"artifacts": [
|
|
||||||
{
|
|
||||||
"app": [
|
|
||||||
"ThirdParty.app"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"caveats": null,
|
|
||||||
"depends_on": {
|
|
||||||
},
|
|
||||||
"conflicts_with": null,
|
|
||||||
"container": null,
|
|
||||||
"auto_updates": null,
|
|
||||||
"tap_git_head": null,
|
|
||||||
"languages": [
|
|
||||||
|
|
||||||
],
|
|
||||||
"ruby_source_checksum": {
|
|
||||||
"sha256": "#{Digest::SHA256.file(Tap.fetch("third-party", "tap").cask_dir/"third-party-cask.rb").hexdigest}"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"token": "with-languages",
|
|
||||||
"full_token": "with-languages",
|
|
||||||
"tap": "homebrew/cask",
|
|
||||||
"name": [
|
|
||||||
|
|
||||||
],
|
|
||||||
"desc": null,
|
|
||||||
"homepage": "https://brew.sh/",
|
|
||||||
"url": "file://#{TEST_FIXTURE_DIR}/cask/caffeine.zip",
|
|
||||||
"url_specs": {
|
|
||||||
},
|
|
||||||
"appcast": null,
|
|
||||||
"version": "1.2.3",
|
|
||||||
"versions": {
|
|
||||||
},
|
|
||||||
"installed": "1.2.3",
|
|
||||||
"outdated": false,
|
|
||||||
"sha256": "xyz789",
|
|
||||||
"artifacts": [
|
|
||||||
{
|
|
||||||
"app": [
|
|
||||||
"Caffeine.app"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"caveats": null,
|
|
||||||
"depends_on": {
|
|
||||||
},
|
|
||||||
"conflicts_with": null,
|
|
||||||
"container": null,
|
|
||||||
"auto_updates": null,
|
|
||||||
"tap_git_head": null,
|
|
||||||
"languages": [
|
|
||||||
"zh",
|
|
||||||
"en-US"
|
|
||||||
],
|
|
||||||
"ruby_source_checksum": {
|
|
||||||
"sha256": "#{Digest::SHA256.file(Tap.default_cask_tap.cask_dir/"with-languages.rb").hexdigest}"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
EOS
|
|
||||||
}
|
|
||||||
let!(:original_macos_version) { MacOS.full_version.to_s }
|
|
||||||
|
|
||||||
before do
|
|
||||||
# Use a more limited symbols list to shorten the variations hash
|
|
||||||
symbols = {
|
|
||||||
monterey: "12",
|
|
||||||
big_sur: "11",
|
|
||||||
catalina: "10.15",
|
|
||||||
mojave: "10.14",
|
|
||||||
}
|
|
||||||
stub_const("MacOSVersions::SYMBOLS", symbols)
|
|
||||||
|
|
||||||
# For consistency, always run on Monterey and ARM
|
|
||||||
MacOS.full_version = "12"
|
|
||||||
allow(Hardware::CPU).to receive(:type).and_return(:arm)
|
|
||||||
|
|
||||||
casks.map(&Cask::CaskLoader.method(:load)).each(&InstallHelper.method(:install_with_caskfile))
|
|
||||||
end
|
|
||||||
|
|
||||||
after do
|
|
||||||
MacOS.full_version = original_macos_version
|
|
||||||
end
|
|
||||||
|
|
||||||
it "of all installed Casks" do
|
|
||||||
expect {
|
|
||||||
described_class.run("--json")
|
|
||||||
}.to output(expected_output).to_stdout
|
|
||||||
end
|
|
||||||
|
|
||||||
it "of given Casks" do
|
|
||||||
expect {
|
|
||||||
described_class.run("--json", "local-caffeine", "local-transmission", "multiple-versions",
|
|
||||||
"third-party/tap/third-party-cask", "with-languages")
|
|
||||||
}.to output(expected_output).to_stdout
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "given a set of installed Casks" do
|
|
||||||
let(:caffeine) { Cask::CaskLoader.load(cask_path("local-caffeine")) }
|
|
||||||
let(:transmission) { Cask::CaskLoader.load(cask_path("local-transmission")) }
|
|
||||||
let(:casks) { [caffeine, transmission] }
|
|
||||||
|
|
||||||
it "lists the installed files for those Casks" do
|
|
||||||
casks.each(&InstallHelper.method(:install_without_artifacts_with_caskfile))
|
|
||||||
|
|
||||||
transmission.artifacts.select { |a| a.is_a?(Cask::Artifact::App) }.each do |artifact|
|
|
||||||
artifact.install_phase(command: NeverSudoSystemCommand, force: false)
|
|
||||||
end
|
|
||||||
|
|
||||||
expect {
|
|
||||||
described_class.run("local-transmission", "local-caffeine")
|
|
||||||
}.to output(<<~EOS).to_stdout
|
|
||||||
==> App
|
|
||||||
#{transmission.config.appdir.join("Transmission.app")} (#{transmission.config.appdir.join("Transmission.app").abv})
|
|
||||||
==> App
|
|
||||||
Missing App: #{caffeine.config.appdir.join("Caffeine.app")}
|
|
||||||
EOS
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
109
Library/Homebrew/test/cask/list_spec.rb
Normal file
109
Library/Homebrew/test/cask/list_spec.rb
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
# typed: false
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "cask/list"
|
||||||
|
|
||||||
|
describe Cask::List, :cask do
|
||||||
|
it "lists the installed Casks in a pretty fashion" do
|
||||||
|
casks = %w[local-caffeine local-transmission].map { |c| Cask::CaskLoader.load(c) }
|
||||||
|
|
||||||
|
casks.each do |c|
|
||||||
|
InstallHelper.install_with_caskfile(c)
|
||||||
|
end
|
||||||
|
|
||||||
|
expect {
|
||||||
|
described_class.list_casks
|
||||||
|
}.to output(<<~EOS).to_stdout
|
||||||
|
local-caffeine
|
||||||
|
local-transmission
|
||||||
|
EOS
|
||||||
|
end
|
||||||
|
|
||||||
|
it "lists oneline" do
|
||||||
|
casks = %w[
|
||||||
|
local-caffeine
|
||||||
|
third-party/tap/third-party-cask
|
||||||
|
local-transmission
|
||||||
|
].map { |c| Cask::CaskLoader.load(c) }
|
||||||
|
|
||||||
|
casks.each do |c|
|
||||||
|
InstallHelper.install_with_caskfile(c)
|
||||||
|
end
|
||||||
|
|
||||||
|
expect {
|
||||||
|
described_class.list_casks(one: true)
|
||||||
|
}.to output(<<~EOS).to_stdout
|
||||||
|
local-caffeine
|
||||||
|
local-transmission
|
||||||
|
third-party-cask
|
||||||
|
EOS
|
||||||
|
end
|
||||||
|
|
||||||
|
it "lists full names" do
|
||||||
|
casks = %w[
|
||||||
|
local-caffeine
|
||||||
|
third-party/tap/third-party-cask
|
||||||
|
local-transmission
|
||||||
|
].map { |c| Cask::CaskLoader.load(c) }
|
||||||
|
|
||||||
|
casks.each do |c|
|
||||||
|
InstallHelper.install_with_caskfile(c)
|
||||||
|
end
|
||||||
|
|
||||||
|
expect {
|
||||||
|
described_class.list_casks(full_name: true)
|
||||||
|
}.to output(<<~EOS).to_stdout
|
||||||
|
local-caffeine
|
||||||
|
local-transmission
|
||||||
|
third-party/tap/third-party-cask
|
||||||
|
EOS
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "lists versions" do
|
||||||
|
let!(:casks) {
|
||||||
|
["local-caffeine",
|
||||||
|
"local-transmission"].map(&Cask::CaskLoader.method(:load)).each(&InstallHelper.method(:install_with_caskfile))
|
||||||
|
}
|
||||||
|
let(:expected_output) {
|
||||||
|
<<~EOS
|
||||||
|
local-caffeine 1.2.3
|
||||||
|
local-transmission 2.61
|
||||||
|
EOS
|
||||||
|
}
|
||||||
|
|
||||||
|
it "of all installed Casks" do
|
||||||
|
expect {
|
||||||
|
described_class.list_casks(versions: true)
|
||||||
|
}.to output(expected_output).to_stdout
|
||||||
|
end
|
||||||
|
|
||||||
|
it "of given Casks" do
|
||||||
|
expect {
|
||||||
|
described_class.list_casks(*casks, versions: true)
|
||||||
|
}.to output(expected_output).to_stdout
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "given a set of installed Casks" do
|
||||||
|
let(:caffeine) { Cask::CaskLoader.load(cask_path("local-caffeine")) }
|
||||||
|
let(:transmission) { Cask::CaskLoader.load(cask_path("local-transmission")) }
|
||||||
|
let(:casks) { [caffeine, transmission] }
|
||||||
|
|
||||||
|
it "lists the installed files for those Casks" do
|
||||||
|
casks.each(&InstallHelper.method(:install_without_artifacts_with_caskfile))
|
||||||
|
|
||||||
|
transmission.artifacts.select { |a| a.is_a?(Cask::Artifact::App) }.each do |artifact|
|
||||||
|
artifact.install_phase(command: NeverSudoSystemCommand, force: false)
|
||||||
|
end
|
||||||
|
|
||||||
|
expect {
|
||||||
|
described_class.list_casks(transmission, caffeine)
|
||||||
|
}.to output(<<~EOS).to_stdout
|
||||||
|
==> App
|
||||||
|
#{transmission.config.appdir.join("Transmission.app")} (#{transmission.config.appdir.join("Transmission.app").abv})
|
||||||
|
==> App
|
||||||
|
Missing App: #{caffeine.config.appdir.join("Caffeine.app")}
|
||||||
|
EOS
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
x
Reference in New Issue
Block a user