Class: Homebrew::DevCmd::GenerateZap Private
- Inherits:
-
AbstractCommand
- Object
- AbstractCommand
- Homebrew::DevCmd::GenerateZap
- Includes:
- SystemCommand::Mixin
- 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
- #args ⇒ Homebrew::DevCmd::GenerateZap::Args private
- #run ⇒ void private
Methods included from SystemCommand::Mixin
#system_command, #system_command!
Methods inherited from AbstractCommand
command, command_name, dev_cmd?, #initialize, parser, ruby_cmd?
Methods included from Utils::Output::Mixin
#issue_reporting_message, #odebug, #odeprecated, #odie, #odisabled, #ofail, #oh1, #oh1_title, #ohai, #ohai_title, #onoe, #opoo, #opoo_outside_github_actions, #opoo_without_github_actions_annotation, #pretty_deprecated, #pretty_disabled, #pretty_duration, #pretty_install_status, #pretty_installed, #pretty_uninstalled, #pretty_upgradable, #pretty_warning
Constructor Details
This class inherits a constructor from Homebrew::AbstractCommand
Instance Method Details
#args ⇒ Homebrew::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 |
#run ⇒ 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.
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 115 116 117 118 119 120 121 122 123 124 125 |
# File 'dev-cmd/generate-zap.rb', line 90 def run patterns = if args.name? [args.named.fetch(0)] else resolve_patterns_from_cask(args.named.to_casks.fetch(0)) end ohai "Scanning for files matching #{format_patterns(patterns)}..." begin trash_paths = scan_directories(USER_TRASH_PATHS, home_relative: true, patterns:) + scan_home_root(patterns) delete_paths = scan_directories(SYSTEM_DELETE_PATHS, home_relative: false, patterns:) rescue Errno::EACCES, Errno::EPERM => e = "Unable to generate a complete zap stanza: #{e.}" unless Cask::Utils.full_disk_access_enabled? += " Please enable Full Disk Access for your terminal under " \ "#{Cask::Utils.privacy_security_preference_pane("Full Disk Access")}." end odie end 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 #{format_patterns(patterns)}." puts "# No zap stanza required" return end puts format_stanza(trash: trash_paths, delete: delete_paths, rmdir: rmdir_paths) end |