Skip to content

armgit / peel

Public Imported from GitHub
0

Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.

Examples in the code and tests use a made-up app

Țugui Dragoș88916699d53b
diff --git a/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swift b/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swift
index d94fd0e5..31f80392 100644
--- a/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Homebrew/Homebrew.swift
@@ -20,11 +20,11 @@ public struct HomebrewPackage: Sendable, Hashable, Identifiable {
public let isPinned: Bool
public let isInstalledOnRequest: Bool
public let dependencies: [String]
- /// Apps a cask installs, like "Pearcleaner.app".
+ /// Apps a cask installs, like "Example.app".
public let appNames: [String]
- /// Where Homebrew put them, for a cask that is installed: "/Applications/Pearcleaner.app".
+ /// Where Homebrew put them, for a cask that is installed: "/Applications/Example.app".
public let appTargets: [String]
- /// Where Homebrew linked the commands an installed cask puts on the path: "/opt/homebrew/bin/pearcleaner".
+ /// Where Homebrew linked the commands an installed cask puts on the path: "/opt/homebrew/bin/example".
/// `brew uninstall` removes these links.
public let commandLinks: [String]
/// Bundle identifiers the cask tells macOS to quit, which prove a cask really is a given app.
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/AppInspectorTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/AppInspectorTests.swift
index cda3f29d..603b0c0a 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/AppInspectorTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/AppInspectorTests.swift
@@ -138,10 +138,10 @@ struct AppInspectorTests {
func app(_ path: String, _ identifier: String) -> InstalledApp {
InstalledApp(url: URL(filePath: path, directoryHint: .isDirectory), bundleIdentifier: identifier, name: "App")
}
- #expect(app("/Applications/CleanMyMac.app", "com.macpaw.CleanMyMac-setapp").isFromSetapp)
- #expect(app("/Applications/CleanMyMac.app", "com.macpaw.CleanMyMac-Setapp").isFromSetapp)
- #expect(app("/Applications/Setapp/Gemini.app", "app.macpaw.Gemini").isFromSetapp)
- #expect(app("/Users/me/Applications/Setapp/Gemini.app", "app.macpaw.Gemini").isFromSetapp)
+ #expect(app("/Applications/Sample.app", "org.example.Sample-setapp").isFromSetapp)
+ #expect(app("/Applications/Sample.app", "org.example.Sample-Setapp").isFromSetapp)
+ #expect(app("/Applications/Setapp/Sample.app", "org.example.Sample").isFromSetapp)
+ #expect(app("/Users/me/Applications/Setapp/Sample.app", "org.example.Sample").isFromSetapp)
#expect(!app("/Applications/Setapp.app", "com.setapp.DesktopClient").isFromSetapp, "Setapp itself is not an app from Setapp")
#expect(!app("/Applications/Setapp Tools/Thing.app", "com.example.thing").isFromSetapp)
#expect(!app("/Applications/Thing.app", "com.example.setappish").isFromSetapp)
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/CaskEvidenceTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/CaskEvidenceTests.swift
index 811d62a1..71e64608 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/CaskEvidenceTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/CaskEvidenceTests.swift
@@ -20,23 +20,23 @@ struct CaskEvidenceTests {
#expect(combined.first?.leftoverPatterns == ["~/Library/Application Support/AdGuard"])
}
- /// The real shape of a cask, taken from `brew info --json=v2 --installed` for pearcleaner.
+ /// A cask shaped as `brew info --json=v2 --installed` writes one.
private let caskJSON = """
{
"formulae": [],
"casks": [
{
- "token": "pearcleaner",
- "desc": "Application uninstaller",
- "homepage": "https://github.com/alienator88/Pearcleaner",
- "installed": "5.4.3",
- "version": "5.4.3",
+ "token": "sample",
+ "desc": "A sample app",
+ "homepage": "https://example.org/sample",
+ "installed": "2.1.0",
+ "version": "2.1.0",
"outdated": false,
"artifacts": [
- {"uninstall": [{"launchctl": "com.alienator88.PearcleanerSentinel*", "quit": "com.alienator88.Pearcleaner", "login_item": "Pearcleaner"}]},
- {"app": ["Pearcleaner.app"], "target": "/Applications/Pearcleaner.app"},
- {"binary": ["/Applications/Pearcleaner.app/Contents/MacOS/Pearcleaner", {"target": "pearcleaner"}], "target": "/opt/homebrew/bin/pearcleaner"},
- {"zap": [{"trash": ["~/Library/Application Support/Pearcleaner", "~/Library/Caches/com.alienator88.Pearcleaner", "~/Library/Containers/com.alienator88.Pearcleaner*"]}]}
+ {"uninstall": [{"launchctl": "org.example.SampleHelper*", "quit": "org.example.Sample", "login_item": "Sample"}]},
+ {"app": ["Sample.app"], "target": "/Applications/Sample.app"},
+ {"binary": ["/Applications/Sample.app/Contents/MacOS/Sample", {"target": "sample"}], "target": "/opt/homebrew/bin/sample"},
+ {"zap": [{"trash": ["~/Library/Application Support/Sample", "~/Library/Caches/org.example.Sample", "~/Library/Containers/org.example.Sample*"]}]}
]
}
]
@@ -52,22 +52,22 @@ struct CaskEvidenceTests {
/// `brew uninstall` removes. A cask that is not installed has linked nothing.
@Test func readsWhereHomebrewLinkedACasksCommands() throws {
let cask = try #require(try casks().first { $0.kind == .cask })
- #expect(cask.commandLinks == ["/opt/homebrew/bin/pearcleaner"])
- #expect(cask.appTargets == ["/Applications/Pearcleaner.app"], "a command's link was read as the app's place")
+ #expect(cask.commandLinks == ["/opt/homebrew/bin/sample"])
+ #expect(cask.appTargets == ["/Applications/Sample.app"], "a command's link was read as the app's place")
- let notInstalled = #"{"binary": ["$APPDIR/Pearcleaner.app/Contents/MacOS/Pearcleaner", {"target": "pearcleaner"}]}"#
+ let notInstalled = #"{"binary": ["$APPDIR/Sample.app/Contents/MacOS/Sample", {"target": "sample"}]}"#
let known = try JSONDecoder().decode(CaskArtifact.self, from: Data(notInstalled.utf8))
#expect(known.commandLinks.isEmpty)
}
@Test func readsAppsAndLeftoverPathsFromACask() throws {
let cask = try #require(try casks().first { $0.kind == .cask })
- #expect(cask.name == "pearcleaner")
- #expect(cask.appNames == ["Pearcleaner.app"])
+ #expect(cask.name == "sample")
+ #expect(cask.appNames == ["Sample.app"])
#expect(cask.leftoverPatterns == [
- "~/Library/Application Support/Pearcleaner",
- "~/Library/Caches/com.alienator88.Pearcleaner",
- "~/Library/Containers/com.alienator88.Pearcleaner*",
+ "~/Library/Application Support/Sample",
+ "~/Library/Caches/org.example.Sample",
+ "~/Library/Containers/org.example.Sample*",
])
}
@@ -122,10 +122,10 @@ struct CaskEvidenceTests {
@Test func findsTheCaskBehindAnApp() throws {
let packages = try casks()
- let app = InstalledApp(url: URL(filePath: "/Applications/Pearcleaner.app"), bundleIdentifier: "com.alienator88.Pearcleaner", name: "Pearcleaner")
+ let app = InstalledApp(url: URL(filePath: "/Applications/Sample.app"), bundleIdentifier: "org.example.Sample", name: "Sample")
let other = InstalledApp(url: URL(filePath: "/Applications/Something.app"), bundleIdentifier: "com.example.something", name: "Something")
- #expect(CaskEvidence.cask(for: app, in: packages)?.name == "pearcleaner")
+ #expect(CaskEvidence.cask(for: app, in: packages)?.name == "sample")
#expect(CaskEvidence.cask(for: other, in: packages) == nil)
}
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/HomebrewTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/HomebrewTests.swift
index d825616f..5bc4d89a 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/HomebrewTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/HomebrewTests.swift
@@ -35,10 +35,10 @@ struct HomebrewTests {
/// Homebrew writes warnings to stderr and still exits 0, for example for a formula from a tap that uses a
/// deprecated method. So the answer is read from stdout alone: JSON with a warning after it is not JSON.
@Test func readsAnAnswerFromWhatWasPrintedAsTheAnswer() throws {
- let json = #"{"formulae": [], "casks": [{"token": "pearcleaner", "installed": "5.4.3", "version": "5.4.3", "outdated": false}]}"#
+ let json = #"{"formulae": [], "casks": [{"token": "sample", "installed": "2.1.0", "version": "2.1.0", "outdated": false}]}"#
let warned = Homebrew.Attempt(status: 0, standardOutput: json, standardError: "Warning: Calling plist_options is deprecated!\n")
- #expect(try Homebrew.parseInstalled(Data(warned.answer().utf8))?.map(\.name) == ["pearcleaner"])
+ #expect(try Homebrew.parseInstalled(Data(warned.answer().utf8))?.map(\.name) == ["sample"])
#expect(try warned.transcript().hasSuffix("is deprecated!\n"), "what the user is shown keeps the warning")
let failed = Homebrew.Attempt(status: 1, standardOutput: "", standardError: "Error: No such keg\n")
@@ -58,14 +58,14 @@ struct HomebrewTests {
"outdated": false, "pinned": true, "dependencies": ["libgit2", "oniguruma"]}
],
"casks": [
- {"token": "pearcleaner", "desc": "Utility to uninstall apps", "homepage": "https://github.com/alienator88/Pearcleaner",
- "installed": "5.4.3", "version": "5.4.3", "outdated": false}
+ {"token": "sample", "desc": "A sample app", "homepage": "https://example.org/sample",
+ "installed": "2.1.0", "version": "2.1.0", "outdated": false}
]
}
"""
let packages = try #require(Homebrew.parseInstalled(Data(json.utf8)))
- #expect(packages.map(\.id) == ["formula/bat", "formula/openssl@3", "cask/pearcleaner"])
+ #expect(packages.map(\.id) == ["formula/bat", "formula/openssl@3", "cask/sample"])
let openssl = try #require(packages.first { $0.name == "openssl@3" })
#expect(openssl.isOutdated)
#expect(openssl.installedVersion == "3.5.2")
@@ -79,7 +79,7 @@ struct HomebrewTests {
#expect(packages.first { $0.name == "bat" }?.fullName == "sharkdp/tap/bat")
#expect(openssl.fullName == "openssl@3", "an older Homebrew says no full name, and the short one stands in")
#expect(packages.last?.kind == .cask)
- #expect(packages.last?.installedVersion == "5.4.3")
+ #expect(packages.last?.installedVersion == "2.1.0")
}
/// The JSON follows what Homebrew 7.0.4 reports for packages it has stopped or will stop offering. A package
@@ -105,7 +105,7 @@ struct HomebrewTests {
{"token": "active-trader-pro", "installed": "2.0", "version": "2.0",
"deprecated": true, "deprecation_date": "2025-12-17", "deprecation_reason": "discontinued", "disabled": false,
"disable_date": "2026-12-17"},
- {"token": "pearcleaner", "installed": "5.4.3", "version": "5.4.3"}
+ {"token": "sample", "installed": "2.1.0", "version": "2.1.0"}
]
}
"""
@@ -118,7 +118,7 @@ struct HomebrewTests {
#expect(retirement("1kc-razer") == HomebrewRetirement(stage: .disabled, reason: .failsGatekeeperCheck, disableDate: day("2026-09-01"), replacement: .cask("razer-synapse")))
#expect(retirement("active-trader-pro") == HomebrewRetirement(stage: .deprecated, reason: .discontinued, disableDate: day("2026-12-17"), replacement: nil))
#expect(retirement("abricate") == nil, "a deprecation dated ahead has not happened yet")
- #expect(retirement("pearcleaner") == nil)
+ #expect(retirement("sample") == nil)
}
/// Every reason keyword Homebrew 7.0.4 declares in `deprecate_disable.rb` is recognized, and any other text
@@ -181,7 +181,7 @@ struct HomebrewTests {
@Test func readsWhatACleanUpWouldFree() {
let output = """
Would remove: /opt/homebrew/Cellar/x265/4.2 (12 files, 17MB)
- Would remove (broken link): /opt/homebrew/bin/pearcleaner
+ Would remove (broken link): /opt/homebrew/bin/sample
==> This operation would free approximately 61.2MB of disk space.
"""
@@ -221,7 +221,7 @@ struct HomebrewTests {
"tier": 1,
"findings": [
{
- "text": "Broken symlinks were found:\\n /opt/homebrew/bin/pearcleaner\\n",
+ "text": "Broken symlinks were found:\\n /opt/homebrew/bin/sample\\n",
"tier": 1,
"affects": [],
"links": [],
@@ -235,7 +235,7 @@ struct HomebrewTests {
let findings = report.findings.map(\.finding)
#expect(findings.count == 2)
- #expect(findings[0].text == "Broken symlinks were found:\n /opt/homebrew/bin/pearcleaner")
+ #expect(findings[0].text == "Broken symlinks were found:\n /opt/homebrew/bin/sample")
#expect(findings[0].remedy == "Remove them with `brew cleanup`")
#expect(findings[0].commands == ["brew cleanup"])
#expect(findings[1].remedy == nil)
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/InventoryTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/InventoryTests.swift
index 7fdcf8ff..e4bc3413 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/InventoryTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/InventoryTests.swift
@@ -32,7 +32,7 @@ struct InventoryTests {
app("AdGuard", bundleIdentifier: "com.adguard.mac", feed: .sparkle(URL(string: "https://example.com/appcast.xml")!)),
app("Code", bundleIdentifier: "com.microsoft.VSCode", feed: .appStore),
app("Nothing", bundleIdentifier: "com.example.nothing"),
- app("CleanMyMac", bundleIdentifier: "com.macpaw.CleanMyMac-setapp", feed: .sparkle(URL(string: "https://example.com/setapp.xml")!)),
+ app("Sample", bundleIdentifier: "org.example.Sample-setapp", feed: .sparkle(URL(string: "https://example.com/setapp.xml")!)),
],
casks: [cask]
)
@@ -43,7 +43,7 @@ struct InventoryTests {
#expect(sources["AdGuard"] == "Sparkle")
#expect(sources["Code"] == "Unknown")
#expect(sources["Nothing"] == "Unknown")
- #expect(sources["CleanMyMac"] == "Setapp", "Setapp keeps the app up to date, whatever feed it also carries")
+ #expect(sources["Sample"] == "Setapp", "Setapp keeps the app up to date, whatever feed it also carries")
#expect(inventory.entries.first { $0.name == "Bear" }?.sourceDetail == "bear")
#expect(inventory.entries.first { $0.name == "AdGuard" }?.sourceDetail == "https://example.com/appcast.xml")
}
@@ -111,13 +111,13 @@ struct InventoryTests {
apps: [app("Sparkly", bundleIdentifier: "com.example.sparkly", feed: .sparkle(URL(string: "https://example.com/a.xml")!))],
casks: [
HomebrewPackage(name: "wget", kind: .formula),
- HomebrewPackage(name: "pearcleaner", kind: .cask),
+ HomebrewPackage(name: "sample", kind: .cask),
HomebrewPackage(name: "not-asked-for", kind: .formula, isInstalledOnRequest: false),
]
)
let brewfile = try inventory.written(as: .brewfile)
- #expect(brewfile == "brew \"wget\"\ncask \"pearcleaner\"\n")
+ #expect(brewfile == "brew \"wget\"\ncask \"sample\"\n")
#expect(!brewfile.contains("Sparkly"))
}
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/LaunchctlTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/LaunchctlTests.swift
index 144846d1..2b27ff0e 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/LaunchctlTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/LaunchctlTests.swift
@@ -54,7 +54,7 @@ struct LaunchctlTests {
\t\t}
\t}
\tdisabled services = {
- \t\t"com.piriform.ccleaner.uninstall" => enabled
+ \t\t"org.example.agent" => enabled
\t\t"com.example.daemon" => disabled
\t}
}
@@ -64,7 +64,7 @@ struct LaunchctlTests {
#expect(services?["com.adguard.mac.adguard.helper"] == .some(761))
let disabled = Launchctl.parseDisabled(output)
- #expect(disabled == ["com.piriform.ccleaner.uninstall": false, "com.example.daemon": true])
+ #expect(disabled == ["org.example.agent": false, "com.example.daemon": true])
}
@Test func parsesJobDetails() {
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swift
index 1f99edd4..3abd745f 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swift
@@ -311,8 +311,8 @@ struct OrphanScannerTests {
}
@Test(arguments: [
- ("S8EX82NJP6.com.macpaw.CleanMyMac5", "com.macpaw.CleanMyMac5"),
- ("6H4HRTU5E3.group.com.avast.osx", "com.avast.osx"),
+ ("S8EX82NJP6.org.example.Sample5", "org.example.Sample5"),
+ ("6H4HRTU5E3.group.org.example.osx", "org.example.osx"),
("group.is.workflow.my.app", "is.workflow.my.app"),
("ABCDE12345.shared", "ABCDE12345.shared"),
])
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/VendorRemovalTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/VendorRemovalTests.swift
index 1eabffb5..9468650b 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/VendorRemovalTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/VendorRemovalTests.swift
@@ -43,7 +43,7 @@ struct VendorRemovalTests {
let directory = try TemporaryDirectory()
try directory.directory("Applications/Example.app")
try directory.directory("Applications/Uninstall Pulse Secure.app")
- try directory.directory("Applications/App Cleaner & Uninstaller.app")
+ try directory.directory("Applications/Other Product Uninstaller.app")
try directory.directory("Suite/Example.app")
try directory.directory("Suite/Uninstall Other Product.app")