Class: Homebrew::DevCmd::GenerateZap Private

Inherits:
AbstractCommand show all
Defined in:
dev-cmd/generate-zap.rb,
sorbet/rbi/dsl/homebrew/dev_cmd/generate_zap.rbi

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

Defined Under Namespace

Classes: Args

Constant Summary collapse

USER_TRASH_PATHS =

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

T.let([
  "Desktop",
  "Documents",
  "Library",
  "Library/Application Scripts",
  "Library/Application Support",
  "Library/Application Support/CrashReporter",
  "Library/Application Support/com.apple.sharedfilelist/" \
  "com.apple.LSSharedFileList.ApplicationRecentDocuments",
  "Library/Caches",
  "Library/Caches/com.apple.helpd/Generated",
  "Library/Caches/com.apple.helpd/SDMHelpData/Other/English/HelpSDMIndexFile",
  "Library/Containers",
  "Library/Cookies",
  "Library/Group Containers",
  "Library/HTTPStorages",
  "Library/Internet Plug-Ins",
  "Library/LaunchAgents",
  "Library/Logs",
  "Library/Logs/DiagnosticReports",
  "Library/PreferencePanes",
  "Library/Preferences",
  "Library/Preferences/ByHost",
  "Library/Saved Application State",
  "Library/WebKit",
  "Music",
].freeze, T::Array[String])
SYSTEM_DELETE_PATHS =

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

T.let([
  "/Library/Application Support",
  "/Library/Caches",
  "/Library/Frameworks",
  "/Library/LaunchAgents",
  "/Library/LaunchDaemons",
  "/Library/Logs",
  "/Library/PreferencePanes",
  "/Library/Preferences",
  "/Library/PrivilegedHelperTools",
  "/Library/Screen Savers",
  "/Library/ScriptingAdditions",
  "/Library/Services",
  "/Users/Shared",
  "/etc/newsyslog.d",
].freeze, T::Array[String])
RMDIR_EXCLUSIONS =

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

T.let([
  "Library/Application Support/CrashReporter",
  "/Library/Application Support",
  "/Library/Caches",
  "/Library/Preferences",
].freeze, T::Array[String])
UUID_PATTERN =

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

T.let(/[0-9A-F]{8}(-[0-9A-F]{4}){3}-[0-9A-F]{12}/i, Regexp)

Instance Method Summary collapse

Methods inherited from AbstractCommand

command, command_name, dev_cmd?, #initialize, parser, ruby_cmd?

Methods included from Utils::Output::Mixin

#odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #opoo_outside_github_actions, #pretty_deprecated, #pretty_disabled, #pretty_duration, #pretty_installed, #pretty_outdated, #pretty_uninstalled

Constructor Details

This class inherits a constructor from Homebrew::AbstractCommand

Instance Method Details

#argsHomebrew::DevCmd::GenerateZap::Args

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.



10
# File 'sorbet/rbi/dsl/homebrew/dev_cmd/generate_zap.rbi', line 10

def args; end

#runvoid

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.



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'dev-cmd/generate-zap.rb', line 87

def run
  input = args.named.fetch(0)

  app_name = if args.name?
    input
  else
    resolve_app_name_from_cask(input)
  end

  ohai "Scanning for files matching \"#{app_name}\"..."

  trash_paths  = scan_directories(USER_TRASH_PATHS, home_relative: true, pattern: app_name)
  trash_paths += scan_home_root(app_name)
  delete_paths = scan_directories(SYSTEM_DELETE_PATHS, home_relative: false, pattern: app_name)

  trash_paths  = replace_uuids(collapse_to_wildcards(trash_paths))
  delete_paths = replace_uuids(collapse_to_wildcards(delete_paths))

  rmdir_paths = derive_rmdir_candidates(trash_paths + delete_paths)

  if trash_paths.empty? && delete_paths.empty?
    opoo "No files found matching \"#{app_name}\"."
    puts "# No zap stanza required"
    return
  end

  puts format_stanza(trash: trash_paths, delete: delete_paths, rmdir: rmdir_paths)
end