Module: Homebrew::Bundle::MacAppStoreInstaller Private

Defined in:
bundle/mac_app_store_installer.rb

This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module if possible, as it may be removed or changed without warning.

Class Method Summary collapse

Class Method Details

.app_id_installed?(id) ⇒ Boolean

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Parameters:

Returns:

  • (Boolean)


71
72
73
# File 'bundle/mac_app_store_installer.rb', line 71

def self.app_id_installed?(id)
  installed_app_ids.include? id
end

.app_id_installed_and_up_to_date?(id, no_upgrade: false) ⇒ Boolean

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Parameters:

  • id (Integer)
  • no_upgrade (Boolean) (defaults to: false)

Returns:

  • (Boolean)


63
64
65
66
67
68
# File 'bundle/mac_app_store_installer.rb', line 63

def self.app_id_installed_and_up_to_date?(id, no_upgrade: false)
  return false unless app_id_installed?(id)
  return true if no_upgrade

  !app_id_upgradable?(id)
end

.app_id_upgradable?(id) ⇒ Boolean

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Parameters:

Returns:

  • (Boolean)


76
77
78
# File 'bundle/mac_app_store_installer.rb', line 76

def self.app_id_upgradable?(id)
  outdated_app_ids.include? id
end

.install!(name, id, preinstall: true, no_upgrade: false, verbose: false, force: false) ⇒ Boolean

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Parameters:

  • name (String)
  • id (Integer)
  • preinstall (Boolean) (defaults to: true)
  • no_upgrade (Boolean) (defaults to: false)
  • verbose (Boolean) (defaults to: false)
  • force (Boolean) (defaults to: false)

Returns:

  • (Boolean)


42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'bundle/mac_app_store_installer.rb', line 42

def self.install!(name, id, preinstall: true, no_upgrade: false, verbose: false, force: false)
  return true unless preinstall

  if app_id_installed?(id)
    puts "Upgrading #{name} app. It is installed but not up-to-date." if verbose
    mas = T.must(Bundle.which_mas)
    return false unless Bundle.system mas, "upgrade", id.to_s, verbose: verbose

    return true
  end

  puts "Installing #{name} app. It is not currently installed." if verbose

  mas = T.must(Bundle.which_mas)
  return false unless Bundle.system mas, "get", id.to_s, verbose: verbose

  installed_app_ids << id
  true
end

.installed_app_idsArray<Integer>

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



81
82
83
84
# File 'bundle/mac_app_store_installer.rb', line 81

def self.installed_app_ids
  require "bundle/mac_app_store_dumper"
  @installed_app_ids ||= T.let(Homebrew::Bundle::MacAppStoreDumper.app_ids, T.nilable(T::Array[Integer]))
end

.outdated_app_idsArray<Integer>

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



87
88
89
90
91
92
93
94
95
96
97
98
# File 'bundle/mac_app_store_installer.rb', line 87

def self.outdated_app_ids
  @outdated_app_ids ||= T.let(
    if Bundle.mas_installed?
      mas = T.must(Bundle.which_mas)
      `#{mas} outdated 2>/dev/null`.split("\n").map do |app|
        app.split(" ", 2).first.to_i
      end
    else
      []
    end, T.nilable(T::Array[Integer])
  )
end

.preinstall!(name, id, no_upgrade: false, verbose: false) ⇒ Boolean

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Parameters:

  • name (String)
  • id (Integer)
  • no_upgrade (Boolean) (defaults to: false)
  • verbose (Boolean) (defaults to: false)

Returns:

  • (Boolean)


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'bundle/mac_app_store_installer.rb', line 16

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:)
    raise "Unable to install #{name} app. mas installation failed." unless Bundle.mas_installed?
  end

  if app_id_installed?(id) &&
     (no_upgrade || !app_id_upgradable?(id))
    puts "Skipping install of #{name} app. It is already installed." if verbose
    return false
  end

  true
end

.reset!void

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

This method returns an undefined value.



10
11
12
13
# File 'bundle/mac_app_store_installer.rb', line 10

def self.reset!
  @installed_app_ids = nil
  @outdated_app_ids = nil
end