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.

Hold which note a system extension's page chooses with a test

Țugui Dragoș5ef0ec6130ed
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/AppExtensionsTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/AppExtensionsTests.swift
index 6fd27187..e3b05b51 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/AppExtensionsTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/AppExtensionsTests.swift
@@ -340,7 +340,7 @@ struct AppExtensionsTests {
#expect(FileManager.default.fileExists(atPath: path), "\(item.identifier) is at \(path), which isn't there")
#expect(item.reportedState?.isEmpty == false, "\(item.identifier) reported no state")
#expect(
- item.owner != nil || item.election == .beingRemoved,
+ item.appName != nil || item.election == .beingRemoved,
"nothing says which app brought \(item.identifier)"
)
}
diff --git a/Peel/Views/Extensions/ExtensionDetailView.swift b/Peel/Views/Extensions/ExtensionDetailView.swift
index 84eced91..34736c58 100644
--- a/Peel/Views/Extensions/ExtensionDetailView.swift
+++ b/Peel/Views/Extensions/ExtensionDetailView.swift
@@ -175,7 +175,7 @@ struct ExtensionDetailView: View {
private var explanation: LocalizedStringResource {
switch (item.kind, item.turnedOnAndOffIn) {
- case (.systemExtension, _): systemExtensionExplanation
+ case (.systemExtension, _): item.systemExtensionNote
case (.appExtension, .systemSettings):
"Peel doesn’t turn extensions on or off: macOS does. Removing one means removing the app it came with."
case (.appExtension, .safari):
@@ -186,20 +186,4 @@ struct ExtensionDetailView: View {
"Nothing turns this on or off: Shortcuts and Siri use it whenever someone asks for the app’s actions. Removing it means removing the app it came with."
}
}
-
- private var systemExtensionExplanation: LocalizedStringResource {
- // With its app gone, the advice for an installed app leads nowhere: Orphaned Files' words say what does.
- if item.goneApp != nil, let reason = item.leftAlone { return reason.explanation }
- // A version macOS is removing goes on its own, whatever happens to the app.
- if item.election == .beingRemoved {
- guard let newer = item.replacedBy else { return item.election.explanation }
- return "Version \(newer) replaced this one, which macOS is removing. Some removals finish only when the Mac restarts."
- }
- if #available(macOS 27, *) {
- return item.systemSettingsDeletesIt
- ? "macOS keeps its own copy of this, apart from the app, so Peel leaves that app to Finder. Moving the app to the Trash in Finder asks macOS to remove it. So does System Settings: in General > Login Items & Extensions, choose By Category, click the Info button beside Network Extensions, then click the More button beside it and choose Delete Extension."
- : "macOS keeps its own copy of this, apart from the app, and moving the app to the Trash in Finder asks macOS to remove it, sometimes at the next restart. So Peel leaves that app to Finder."
- }
- return "macOS keeps its own copy of this, apart from the app, and removes it only when the app goes to the Trash in Finder, sometimes at the next restart. So Peel leaves that app to Finder."
- }
}
diff --git a/Peel/Views/Extensions/ExtensionText.swift b/Peel/Views/Extensions/ExtensionText.swift
index ff081ad2..b1d700a8 100644
--- a/Peel/Views/Extensions/ExtensionText.swift
+++ b/Peel/Views/Extensions/ExtensionText.swift
@@ -46,6 +46,31 @@ extension AppExtension {
: election.explanation
}
+ var systemExtensionNote: LocalizedStringResource {
+ if #available(macOS 27, *) {
+ return systemExtensionNote(isOnMacOS27: true, systemSettingsDeletesIt: systemSettingsDeletesIt)
+ }
+ return systemExtensionNote(isOnMacOS27: false, systemSettingsDeletesIt: false)
+ }
+
+ /// What the page says of a system extension: what its app being gone leaves to do, what macOS is doing with it, or
+ /// what moving its app asks of macOS.
+ func systemExtensionNote(isOnMacOS27: Bool, systemSettingsDeletesIt: Bool) -> LocalizedStringResource {
+ // With its app gone, the advice for an installed app leads nowhere: Orphaned Files' words say what does.
+ if goneApp != nil, let reason = leftAlone { return reason.explanation }
+ // A version macOS is removing goes on its own, whatever happens to the app.
+ if election == .beingRemoved {
+ guard let newer = replacedBy else { return election.explanation }
+ return "Version \(newer) replaced this one, which macOS is removing. Some removals finish only when the Mac restarts."
+ }
+ if isOnMacOS27 {
+ return systemSettingsDeletesIt
+ ? "macOS keeps its own copy of this, apart from the app, so Peel leaves that app to Finder. Moving the app to the Trash in Finder asks macOS to remove it. So does System Settings: in General > Login Items & Extensions, choose By Category, click the Info button beside Network Extensions, then click the More button beside it and choose Delete Extension."
+ : "macOS keeps its own copy of this, apart from the app, and moving the app to the Trash in Finder asks macOS to remove it, sometimes at the next restart. So Peel leaves that app to Finder."
+ }
+ return "macOS keeps its own copy of this, apart from the app, and removes it only when the app goes to the Trash in Finder, sometimes at the next restart. So Peel leaves that app to Finder."
+ }
+
/// Whether a search for `text` finds it, by what its row and page say as well as by its identifiers.
func matches(_ text: String) -> Bool {
[name, owner, pointName, categoryName, point, identifier].contains {
diff --git a/PeelTests/ExtensionTextTests.swift b/PeelTests/ExtensionTextTests.swift
index f2dc6265..294f96dd 100644
--- a/PeelTests/ExtensionTextTests.swift
+++ b/PeelTests/ExtensionTextTests.swift
@@ -110,6 +110,35 @@ struct ExtensionTextTests {
#expect(gone.rowDetail(showingVersion: true) == "\(String(localized: "\("Example"), no longer installed")) · \(words)")
}
+ @Test func aSystemExtensionsNoteSaysWhatIsLeftToDoWithIt() {
+ func system(
+ election: AppExtension.Election = .on, goneApp: String? = nil, replacedBy: String? = nil
+ ) -> AppExtension {
+ var item = AppExtension(
+ identifier: "org.example.part", name: "Part", kind: .systemExtension, point: nil, owner: "Example",
+ url: nil, election: election, teamIdentifier: nil, reportedState: nil, goneApp: goneApp
+ )
+ item.replacedBy = replacedBy
+ return item
+ }
+ let gone = system(goneApp: "/Applications/Example.app")
+ #expect(system(goneApp: "/Applications/Example.app").systemExtensionNote(
+ isOnMacOS27: false, systemSettingsDeletesIt: false
+ ).key == gone.leftAlone?.explanation.key)
+ let goingWithANewerVersion = system(election: .beingRemoved, replacedBy: "2.20.2 (2629)")
+ #expect(goingWithANewerVersion.systemExtensionNote(isOnMacOS27: false, systemSettingsDeletesIt: false).key
+ == "Version %@ replaced this one, which macOS is removing. Some removals finish only when the Mac restarts.")
+ let going = system(election: .beingRemoved)
+ #expect(going.systemExtensionNote(isOnMacOS27: true, systemSettingsDeletesIt: true).key
+ == AppExtension.Election.beingRemoved.explanation.key)
+ let onItsOwn = Set([
+ system().systemExtensionNote(isOnMacOS27: false, systemSettingsDeletesIt: false).key,
+ system().systemExtensionNote(isOnMacOS27: true, systemSettingsDeletesIt: false).key,
+ system().systemExtensionNote(isOnMacOS27: true, systemSettingsDeletesIt: true).key,
+ ])
+ #expect(onItsOwn.count == 3)
+ }
+
@Test func findsAPartByTheWordItsPageShows() throws {
let widget = part(name: "Example", owner: "Example", point: "com.apple.widgetkit-extension")
let word = try #require(widget.pointName)