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
Warn before Mullvad VPN leaves, as the list of apps names it
Țugui Dragoș5de5abe0ee3a
diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Commands/AppCommands.swift b/Packages/PeelCore/Sources/PeelCommandLine/Commands/AppCommands.swiftindex 62884b8e..cce8a773 100644--- a/Packages/PeelCore/Sources/PeelCommandLine/Commands/AppCommands.swift+++ b/Packages/PeelCore/Sources/PeelCommandLine/Commands/AppCommands.swift@@ -372,6 +372,18 @@ struct UninstallCommand: AsyncParsableCommand {}}+ /// What the removal does that the Trash can't bring back, said before the question.+ static func warnings(moving urls: Set<URL>, of app: InstalledApp, resettingPrivacy: Bool) -> [String] {+ var warnings: [String] = []+ if resettingPrivacy {+ warnings.append("Peel resets \(app.name)'s privacy permissions just before it moves. The Trash can't bring them back.")+ }+ for app in UninstallsItself.when(moving: urls, among: [app]) {+ warnings.append("Once \(app.app.name) leaves the Applications folder, its own service uninstalls it: it logs this Mac out of the account and deletes its settings, which the Trash can't bring back. Write down the account number first, or run its own uninstaller instead: \(app.uninstaller)")+ }+ return warnings+ }+/// Why the app itself can't move: macOS keeps another developer's app from a terminal without App Management,/// which the person can allow, while an app in a folder they can't write to needs an administrator.static func whyItCannotMove(@@ -473,13 +485,10 @@ struct UninstallCommand: AsyncParsableCommand {[Output.size(item.size), Output.path(item.url)] + (staying ? [item.refusal.map { "stays: \($0.summary)" } ?? "moves"] : [])})Output.line("Total: \(Output.size(plan.total))")- if resetPrivacy {- Output.line("Peel resets \(target.name)'s privacy permissions just before it moves. The Trash can't bring them back.")- }- for app in UninstallsItself.when(moving: Set(plan.moving.map(\.url)), among: [target]) {- Output.line("Once \(app.app.name) leaves the Applications folder, its own service uninstalls it: it logs this Mac out of the account and deletes its settings, which the Trash can't bring back. Write down the account number first, or run its own uninstaller instead: \(app.uninstaller)")- }}+ // With `--json`, standard output is the report alone, so the warnings go where the notes go.+ let warnings = Self.warnings(moving: Set(plan.moving.map(\.url)), of: target, resettingPrivacy: resetPrivacy)+ warnings.forEach(output.json ? Output.note : Output.line)Self.whatStays(plan, app: target, homebrew: homebrew, scan: uninstallation.scan).forEach(Output.note)guard !dryRun else {diff --git a/Packages/PeelCore/Sources/PeelCore/Removal/UninstallsItself.swift b/Packages/PeelCore/Sources/PeelCore/Removal/UninstallsItself.swiftindex eead18ba..8c10bedc 100644--- a/Packages/PeelCore/Sources/PeelCore/Removal/UninstallsItself.swift+++ b/Packages/PeelCore/Sources/PeelCore/Removal/UninstallsItself.swift@@ -12,7 +12,7 @@ public struct UninstallsItself: Sendable, Hashable {public static func when(moving urls: Set<URL>, among apps: [InstalledApp]) -> [UninstallsItself] {apps.filter { app inurls.contains(app.url) && app.bundleIdentifier == mullvad.identifier- && app.url.path(percentEncoded: false) == mullvad.path+ && PathPattern.comparablePath(of: app.url) == mullvad.path}.map { UninstallsItself(app: $0, uninstaller: mullvad.path + "/Contents/Resources/uninstall.sh") }}}diff --git a/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swiftindex d0c47ea4..5f8604f4 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/CommandLineTests.swift@@ -45,6 +45,19 @@ struct CommandLineTests {#expect(permissions.contains("administrator"))}+ /// What the Trash can't bring back is said before the question in every output: with `--json` on standard error.+ @Test func warnsOfWhatTheTrashCantBringBack() {+ let mullvad = InstalledApp(+ url: URL(filePath: "/Applications/Mullvad VPN.app", directoryHint: .isDirectory),+ bundleIdentifier: "net.mullvad.vpn", name: "Mullvad VPN"+ )+ let warnings = UninstallCommand.warnings(moving: [mullvad.url], of: mullvad, resettingPrivacy: true)+ #expect(warnings.count == 2)+ #expect(warnings.contains { $0.contains("privacy permissions") })+ #expect(warnings.contains { $0.contains("logs this Mac out") })+ #expect(UninstallCommand.warnings(moving: [], of: mullvad, resettingPrivacy: false).isEmpty)+ }+@Test func parsesByteSizes() {#expect(ByteSize(argument: "2048")?.bytes == 2_048)#expect(ByteSize(argument: "500KB")?.bytes == 500_000)diff --git a/Packages/PeelCore/Tests/PeelCoreTests/UninstallsItselfTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/UninstallsItselfTests.swiftindex 9600ca17..1e768802 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/UninstallsItselfTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/UninstallsItselfTests.swift@@ -14,6 +14,15 @@ struct UninstallsItselfTests {])}+ /// The apps Peel lists come from a folder walk, whose URLs name a folder with a slash at the end.+ @Test func knowsMullvadAsTheListOfAppsNamesIt() throws {+ let walked = URL(filePath: "/Applications/Mullvad VPN.app", directoryHint: .isDirectory)+ #expect(walked.path(percentEncoded: false).hasSuffix("/"))+ let listed = InstalledApp(url: walked, bundleIdentifier: "net.mullvad.vpn", name: "Mullvad VPN")++ #expect(UninstallsItself.when(moving: [walked], among: [listed]).map(\.app) == [listed])+ }+@Test func nothingHappensWhileTheAppStaysOrSitsElsewhere() {let elsewhere = InstalledApp(url: URL(filePath: "/Users/me/Applications/Mullvad VPN.app"), bundleIdentifier: "net.mullvad.vpn",