Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.
Swift cache-cleanercleanerclideveloper-toolsdisk-cleanupdisk-spaceduplicate-finderhomebrewliquid-glassmac-cleanermacosmacos-appmacos-golden-gatemacos-tahoemacos-tweaksswiftswiftuiterminal-themesuninstalluninstaller
Read the apps of the home a Developer scan looks at
Țugui Dragoș9166d4439d77
diff --git a/Packages/PeelCore/Sources/PeelCore/Apps/AppCatalog.swift b/Packages/PeelCore/Sources/PeelCore/Apps/AppCatalog.swiftindex 2d4bb032..4575dd37 100644--- a/Packages/PeelCore/Sources/PeelCore/Apps/AppCatalog.swift+++ b/Packages/PeelCore/Sources/PeelCore/Apps/AppCatalog.swift@@ -15,16 +15,22 @@ public struct AppScan: Sendable, Equatable {public enum AppCatalog {/// Where Peel looks for apps: the Applications folders and the folders the person chose (`AppFolders`).public static var defaultDirectories: [URL] {- directories(adding: AppFolders().load() ?? [])+ directories(in: .current)+ }++ /// Where Peel looks for apps in `environment`: its Applications folders and the folders chosen in its home.+ static func directories(in environment: SearchEnvironment) -> [URL] {+ let chosen = AppFolders(url: AppFolders.url(inHome: environment.homeDirectory)).load() ?? []+ return standardDirectories(home: environment.homeDirectory, root: environment.rootDirectory) + chosen}static var standardDirectories: [URL] {standardDirectories(home: .homeDirectory)}- static func standardDirectories(home: URL) -> [URL] {+ static func standardDirectories(home: URL, root: URL = URL(filePath: "/", directoryHint: .isDirectory)) -> [URL] {[- URL(filePath: "/Applications", directoryHint: .isDirectory),+ root.appending(path: "Applications", directoryHint: .isDirectory),home.appending(path: "Applications", directoryHint: .isDirectory),]}diff --git a/Packages/PeelCore/Sources/PeelCore/Apps/AppFolders.swift b/Packages/PeelCore/Sources/PeelCore/Apps/AppFolders.swiftindex 703f3a78..63c89b98 100644--- a/Packages/PeelCore/Sources/PeelCore/Apps/AppFolders.swift+++ b/Packages/PeelCore/Sources/PeelCore/Apps/AppFolders.swift@@ -18,7 +18,11 @@ public struct AppFolders: Sendable {}public static var defaultURL: URL {- PeelFolder.url.appending(path: "app-folders.json")+ url(inHome: .homeDirectory)+ }++ static func url(inHome home: URL) -> URL {+ PeelFolder.url(inHome: home).appending(path: "app-folders.json")}/// The folders chosen, or nil when the file is there and cannot be read: the apps in them are then not known.diff --git a/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift b/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swiftindex 3807ae68..c97df8d4 100644--- a/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift+++ b/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift@@ -1123,7 +1123,7 @@ public enum DeveloperCaches {public static func scan(in environment: SearchEnvironment = .current, exclusions: Exclusions = .none) async -> [DeveloperEnvironment] {- let apps = await AppCatalog.installedApps()+ let apps = await AppCatalog.installedApps(in: AppCatalog.directories(in: environment))let electron = electronDefinitions(for: apps, home: environment.homeDirectory)return await scan(definitions + electron, homeDirectory: environment.homeDirectory,diff --git a/Packages/PeelCore/Sources/PeelCore/Support/PeelFolder.swift b/Packages/PeelCore/Sources/PeelCore/Support/PeelFolder.swiftindex e3813727..f13bd8fc 100644--- a/Packages/PeelCore/Sources/PeelCore/Support/PeelFolder.swift+++ b/Packages/PeelCore/Sources/PeelCore/Support/PeelFolder.swift@@ -4,8 +4,10 @@ public import Foundation/// has seen, Saved Settings, and the file digests Duplicates remembers.public enum PeelFolder {public static var url: URL {- let support = FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask).first- ?? URL.homeDirectory.appending(path: "Library/Application Support", directoryHint: .isDirectory)- return support.appending(path: "Peel", directoryHint: .isDirectory)+ url(inHome: .homeDirectory)+ }++ static func url(inHome home: URL) -> URL {+ home.appending(path: "Library/Application Support/Peel", directoryHint: .isDirectory)}}diff --git a/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swiftindex 79a0a623..934f3c17 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swift@@ -249,6 +249,27 @@ struct DeveloperCachesTests {#expect(chat.locations.map(\.url.lastPathComponent).sorted() == ["Cache", "GPUCache"])}+ @Test func readsTheAppsInTheFoldersChosenInTheHomeItScans() async throws {+ let directory = try TemporaryDirectory()+ let tools = try directory.directory("Tools")+ try directory.directory("Tools/Chat.app/Contents/Frameworks/Electron Framework.framework")+ let info = ["CFBundleIdentifier": "org.example.chat", "CFBundleName": "Chat"]+ try directory.file(+ "Tools/Chat.app/Contents/Info.plist",+ contents: try PropertyListSerialization.data(fromPropertyList: info, format: .xml, options: 0)+ )+ try directory.file("Library/Application Support/Chat/Local State")+ try directory.file("Library/Application Support/Chat/GPUCache/data_0", bytes: 4_096)+ let chosen = directory.url.appending(path: "Library/Application Support/Peel/app-folders.json")+ try #require(AppFolders(url: chosen).add([tools]))++ let environment = SearchEnvironment(homeDirectory: directory.url, rootDirectory: directory.url)+ let environments = await DeveloperCaches.scan(in: environment)++ let chat = try #require(environments.first { $0.appBundleIdentifiers == ["org.example.chat"] })+ #expect(chat.locations.map(\.url.lastPathComponent) == ["GPUCache"])+ }+/// A large `DerivedData`, or a Gradle cache on a cold disk, may not be measured in time. Such a folder is not/// read as empty: it is listed first, with no size, and never selected for the user.@Test func aFolderThatDidNotAnswerInTimeIsNotReadAsEmpty() async throws {diff --git a/Packages/PeelCore/Tests/PeelCoreTests/VendorRemovalTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/VendorRemovalTests.swiftindex 6e07ee59..fc5fcb14 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/VendorRemovalTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/VendorRemovalTests.swift@@ -16,12 +16,18 @@ struct VendorRemovalTests {)}+ private func folders(in directory: borrowing TemporaryDirectory) -> [URL] {+ AppCatalog.directories(in: SearchEnvironment(homeDirectory: directory.url, rootDirectory: directory.url))+ }+@Test func findsAnUninstallerShippedWithTheApp() throws {let directory = try TemporaryDirectory()try directory.directory("Suite/Example.app/Contents/Resources/Uninstall Example.app")let example = app(in: directory, path: "Suite/Example.app", name: "Example")- let uninstaller = try #require(VendorRemoval.uninstaller(for: example))+ let uninstaller = try #require(+ VendorRemoval.uninstaller(for: example, applicationsFolders: folders(in: directory))+ )#expect(uninstaller.lastPathComponent == "Uninstall Example.app")}@@ -31,7 +37,8 @@ struct VendorRemovalTests {try directory.directory("Suite/Example Uninstaller.app")let example = app(in: directory, path: "Suite/Example.app", name: "Example")- #expect(VendorRemoval.uninstaller(for: example)?.lastPathComponent == "Example Uninstaller.app")+ let uninstaller = VendorRemoval.uninstaller(for: example, applicationsFolders: folders(in: directory))+ #expect(uninstaller?.lastPathComponent == "Example Uninstaller.app")}@Test func ignoresUnrelatedAppsNextToIt() throws {@@ -40,7 +47,7 @@ struct VendorRemovalTests {try directory.directory("Suite/Helper.app")let example = app(in: directory, path: "Suite/Example.app", name: "Example")- #expect(VendorRemoval.uninstaller(for: example) == nil)+ #expect(VendorRemoval.uninstaller(for: example, applicationsFolders: folders(in: directory)) == nil)#expect(!VendorRemoval.isUninstallerName("Helper.app", app: example))#expect(VendorRemoval.isUninstallerName("Uninstall.app", app: example))}@@ -56,9 +63,16 @@ struct VendorRemovalTests {try directory.directory("Suite/Example.app")try directory.directory("Suite/Uninstall Other Product.app")+ let applications = folders(in: directory)+ let inApplications = app(in: directory, path: "Applications/Example.app", name: "Example")+ let inSuite = app(in: directory, path: "Suite/Example.app", name: "Example")+#expect(VendorRemoval.isApplicationsFolder(URL(filePath: "/Applications/Example.app").deletingLastPathComponent()))- #expect(VendorRemoval.uninstaller(for: app(in: directory, path: "Applications/Example.app", name: "Example")) == nil)- #expect(VendorRemoval.uninstaller(for: app(in: directory, path: "Suite/Example.app", name: "Example")) == nil, "a vendor's folder holds its other products too")+ #expect(VendorRemoval.uninstaller(for: inApplications, applicationsFolders: applications) == nil)+ #expect(+ VendorRemoval.uninstaller(for: inSuite, applicationsFolders: applications) == nil,+ "a vendor's folder holds its other products too"+ )}@Test func aSiblingProductsUninstallerIsNotThisAppsEvenWhenItsNameHoldsThisOne() throws {@@ -67,10 +81,14 @@ struct VendorRemovalTests {try directory.directory("Acme/Acme Pro.app")try directory.directory("Acme/Uninstall Acme Pro.app")- #expect(VendorRemoval.uninstaller(for: app(in: directory, path: "Acme/Acme.app", name: "Acme")) == nil)+ let applications = folders(in: directory)+ let acme = app(in: directory, path: "Acme/Acme.app", name: "Acme")+ let acmePro = app(in: directory, path: "Acme/Acme Pro.app", name: "Acme Pro")++ #expect(VendorRemoval.uninstaller(for: acme, applicationsFolders: applications) == nil)#expect(- VendorRemoval.uninstaller(for: app(in: directory, path: "Acme/Acme Pro.app", name: "Acme Pro"))?- .lastPathComponent == "Uninstall Acme Pro.app"+ VendorRemoval.uninstaller(for: acmePro, applicationsFolders: applications)?.lastPathComponent+ == "Uninstall Acme Pro.app")}