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
Leave a version out when a bundle states none
Țugui Dragoș18d744d76789
diff --git a/Packages/PeelCore/Sources/PeelCore/Apps/AppInspector.swift b/Packages/PeelCore/Sources/PeelCore/Apps/AppInspector.swiftindex 62558426..3c324e82 100644--- a/Packages/PeelCore/Sources/PeelCore/Apps/AppInspector.swift+++ b/Packages/PeelCore/Sources/PeelCore/Apps/AppInspector.swift@@ -103,8 +103,7 @@ public enum AppInspector {bundleIdentifier: bundleIdentifier,name: displayName(of: url, identifier: bundleIdentifier),bundleName: info["CFBundleName"] as? String,- // Falls back to the build number when the short version is empty or is not a string, such as a number.- version: (info["CFBundleShortVersionString"] as? String).flatMap { $0.isEmpty ? nil : $0 } ?? info["CFBundleVersion"] as? String,+ version: statedVersion(in: info),buildVersion: info["CFBundleVersion"] as? String,teamIdentifier: signing.teamIdentifier,developer: signing.developer,@@ -159,6 +158,18 @@ public enum AppInspector {return try? PropertyListSerialization.propertyList(from: data, format: nil) as? [String: Any]}+ /// The version a bundle's Info.plist states: its short version, else its build number.+ static func statedVersion(in info: [String: Any]?) -> String? {+ stated(info?["CFBundleShortVersionString"]) ?? stated(info?["CFBundleVersion"])+ }++ /// A value of an Info.plist as text. One that is not text, or holds only blank space, states nothing, so it is+ /// never shown as an empty line.+ static func stated(_ value: Any?) -> String? {+ guard let text = value as? String, !text.allSatisfy(\.isWhitespace) else { return nil }+ return text+ }+/// Whether the bundle's Info.plist is there and macOS will not let Peel read it, so nothing can be told about/// the app.static func isClosed(_ bundle: URL) -> Bool {diff --git a/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift b/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swiftindex f3ecd15f..f1d92993 100644--- a/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift+++ b/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift@@ -344,8 +344,8 @@ public enum DeveloperCaches {let facts = BoundedRead.propertyList(at: url.appending(path: "Info.plist")),let app = facts["ApplicationProperties"] as? [String: Any]else { return nil }- let version = app["CFBundleShortVersionString"] as? String- let build = app["CFBundleVersion"] as? String+ let version = AppInspector.stated(app["CFBundleShortVersionString"])+ let build = AppInspector.stated(app["CFBundleVersion"])guard version != nil || build != nil else { return nil }return DeveloperEnvironment.Archive(version: version, build: build)}diff --git a/Packages/PeelCore/Sources/PeelCore/Plugins/Plugins.swift b/Packages/PeelCore/Sources/PeelCore/Plugins/Plugins.swiftindex 02da6642..120cf2cf 100644--- a/Packages/PeelCore/Sources/PeelCore/Plugins/Plugins.swift+++ b/Packages/PeelCore/Sources/PeelCore/Plugins/Plugins.swift@@ -235,7 +235,7 @@ public enum Plugins {url: item.url,name: name(of: item.url, info: info),bundleIdentifier: info?["CFBundleIdentifier"] as? String,- version: (info?["CFBundleShortVersionString"] ?? info?["CFBundleVersion"]) as? String,+ version: AppInspector.statedVersion(in: info),category: item.category,isInstalledForAllUsers: item.isForAllUsers,size: await measure(item.url),diff --git a/Packages/PeelCore/Sources/PeelCore/Space/Installers.swift b/Packages/PeelCore/Sources/PeelCore/Space/Installers.swiftindex 0ab178ea..7f7204d6 100644--- a/Packages/PeelCore/Sources/PeelCore/Space/Installers.swift+++ b/Packages/PeelCore/Sources/PeelCore/Space/Installers.swift@@ -473,9 +473,8 @@ public enum Installers {guard !exclusions.excludes(url), !exclusions.holds(url) else { continue }let (size, seen, _) = await measured(url, by: measure)guard isWorthARow(size, minimumSize) else { continue }- let version = AppInspector.infoDictionary(- in: url.appending(path: "Contents", directoryHint: .isDirectory)- )?["CFBundleShortVersionString"] as? String+ let info = AppInspector.infoDictionary(in: url.appending(path: "Contents", directoryHint: .isDirectory))+ let version = AppInspector.stated(info?["CFBundleShortVersionString"])items.append(InstallerItem(url: url,kind: .macOSInstaller,diff --git a/Packages/PeelCore/Tests/PeelCoreTests/AppInspectorTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/AppInspectorTests.swiftindex 90146a20..59804bb6 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/AppInspectorTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/AppInspectorTests.swift@@ -333,6 +333,15 @@ struct AppInspectorTests {#expect(AppInspector.inspect(directory.url.appending(path: "Empty.app"))?.version == "7")}+ @Test func statesNoVersionWhenTheBundleGivesOnlyBlankSpace() throws {+ let directory = try TemporaryDirectory()+ try plist(["CFBundleIdentifier": "org.example.blank", "CFBundleShortVersionString": "", "CFBundleVersion": ""], at: "Blank.app/Contents/Info.plist", in: directory)+ try plist(["CFBundleIdentifier": "org.example.spaces", "CFBundleShortVersionString": " ", "CFBundleVersion": "12"], at: "Spaces.app/Contents/Info.plist", in: directory)++ #expect(try #require(AppInspector.inspect(directory.url.appending(path: "Blank.app"))).version == nil)+ #expect(try #require(AppInspector.inspect(directory.url.appending(path: "Spaces.app"))).version == "12")+ }+@Test func readsAnAppWhoseInfoPlistNamesNoIdentifier() throws {let directory = try TemporaryDirectory()try plist(["CFBundleName": "Plain Editor", "CFBundleVersion": "4.0"], at: "Plain Editor.app/Contents/Info.plist", in: directory)diff --git a/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swiftindex 362189e8..a3bc75e2 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swift@@ -1123,6 +1123,19 @@ struct DeveloperCachesTests {#expect(locations.first { $0.url.lastPathComponent.hasPrefix("App 02.09") }?.archive == nil)}+ @Test func anArchiveWithABlankVersionShowsItsBuild() throws {+ let directory = try TemporaryDirectory()+ for (name, properties) in [("Blank", ["CFBundleShortVersionString": "", "CFBundleVersion": "45"]), ("Nothing", ["CFBundleShortVersionString": " ", "CFBundleVersion": ""])] {+ try directory.file(+ "\(name).xcarchive/Info.plist",+ contents: try PropertyListSerialization.data(fromPropertyList: ["ApplicationProperties": properties], format: .xml, options: 0)+ )+ }++ #expect(DeveloperCaches.archive(at: directory.url.appending(path: "Blank.xcarchive"))?.label == "45")+ #expect(DeveloperCaches.archive(at: directory.url.appending(path: "Nothing.xcarchive")) == nil)+ }+@Test func listsEveryArchiveHoweverManyThereAre() async throws {let directory = try TemporaryDirectory()for day in 1...130 {diff --git a/Packages/PeelCore/Tests/PeelCoreTests/InstallersTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/InstallersTests.swiftindex db882956..be8e8dfd 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/InstallersTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/InstallersTests.swift@@ -692,6 +692,24 @@ struct InstallersTests {#expect(scan.items(in: .firmware).map(\.name) == ["iPhone17,1_26.1.ipsw"])}+ @Test func aMacOSInstallerWithABlankVersionNotesNone() async throws {+ let directory = try TemporaryDirectory()+ for (name, version) in [("Install macOS Tahoe", ""), ("Install macOS Sequoia", "15.6")] {+ try directory.file("Applications/\(name).app/Contents/MacOS/app", bytes: 400_000)+ try directory.file(+ "Applications/\(name).app/Contents/Info.plist",+ contents: try PropertyListSerialization.data(fromPropertyList: ["CFBundleShortVersionString": version], format: .xml, options: 0)+ )+ }++ let scan = await Installers.scan(+ installedApps: [], home: directory.url, root: directory.url, minimumSize: 100_000+ )++ #expect(try #require(scan.items(in: .macOSInstaller).first { $0.name == "Install macOS Tahoe" }).notes == [])+ #expect(try #require(scan.items(in: .macOSInstaller).first { $0.name == "Install macOS Sequoia" }).notes == [.version("15.6")])+ }+@Test func findsMacOSInstallersWhereverThePersonKeepsApps() async throws {let directory = try TemporaryDirectory()let home = directory.url.appending(path: "home", directoryHint: .isDirectory)diff --git a/Packages/PeelCore/Tests/PeelCoreTests/PluginsTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/PluginsTests.swiftindex 51008023..001d4a28 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/PluginsTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/PluginsTests.swift@@ -158,6 +158,23 @@ struct PluginsTests {#expect(Plugins.name(of: localized, info: ["CFBundleName": "Input"]) == "Kana Input")}+ @Test func aPlugInThatStatesNoVersionShowsNone() async throws {+ let directory = try TemporaryDirectory()+ for (name, info) in [("Blank", ["CFBundleShortVersionString": "", "CFBundleVersion": ""]), ("Build", ["CFBundleShortVersionString": " ", "CFBundleVersion": "12"])] {+ let data = try PropertyListSerialization.data(fromPropertyList: info, format: .xml, options: 0)+ try data.write(to: directory.file("home/Library/Audio/Plug-Ins/Components/\(name).component/Contents/Info.plist"))+ }+ let environment = SearchEnvironment(+ homeDirectory: directory.url.appending(path: "home", directoryHint: .isDirectory),+ rootDirectory: directory.url.appending(path: "root", directoryHint: .isDirectory)+ )++ let plugins = await Plugins.scan(environment: environment).plugins++ #expect(try #require(plugins.first { $0.name == "Blank" }).version == nil)+ #expect(try #require(plugins.first { $0.name == "Build" }).version == "12")+ }+@Test func findsPluginBundlesInUserAndSystemLibraries() async throws {let directory = try TemporaryDirectory()let info = try PropertyListSerialization.data(