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
peel projects says when macOS kept it out of a chosen folder
Țugui Dragoșa55370bb5b2e
diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swift b/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swiftindex aa80d1e6..f76172dd 100644--- a/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swift+++ b/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swift@@ -290,7 +290,7 @@ struct ProjectsCommand: AsyncParsableCommand {@OptionGroup var output: OutputOptions- private struct Record: Encodable {+ struct Record: Encodable {let path: Stringlet project: Stringlet tool: String@@ -322,14 +322,43 @@ struct ProjectsCommand: AsyncParsableCommand {let scan = await ProjectArtifacts.scan(roots: roots, exclusions: UnreadableExclusions.load())let artifacts = scan.artifactsif removal.remove {- if scan.wasCutShort {- Output.note("There were more folders than Peel looks at in one go, so this isn't all of them.")- }+ Self.notes(for: scan).forEach(Output.note)return try await clean(artifacts, using: TrashService(exclusions: await ExclusionStore().load()))}if output.json {- try Output.json(artifacts.map {+ try Output.json(Self.report(for: scan))+ } else if artifacts.isEmpty {+ Output.line("Nothing built was found in those folders.")+ } else {+ Output.table(Self.rows(for: artifacts))+ }+ Self.notes(for: scan).forEach(Output.note)+ }++ /// What `--json` writes: the build output, and the chosen folders macOS kept Peel out of, where there may be+ /// more.+ struct Report: Encodable {+ let artifacts: [Record]+ let unreadableLocations: [String]+ }++ /// What the scan couldn't look at, said on standard error whatever the output, so that "Nothing built was+ /// found" or an empty list is not read as folders with nothing built in them.+ static func notes(for scan: ProjectArtifacts.Scan) -> [String] {+ var notes: [String] = []+ if !scan.unreadableLocations.isEmpty {+ notes.append(Output.fullDiskAccessNote)+ }+ if scan.wasCutShort {+ notes.append("There were more folders than Peel looks at in one go, so this list isn't all of them.")+ }+ return notes+ }++ static func report(for scan: ProjectArtifacts.Scan) -> Report {+ Report(+ artifacts: scan.artifacts.map {Record(path: Output.path($0.url),project: Output.path($0.project),@@ -338,15 +367,9 @@ struct ProjectsCommand: AsyncParsableCommand {suggested: $0.isRecommended,recentlyActive: $0.isRecentlyActive)- })- } else if artifacts.isEmpty {- Output.line("Nothing built was found in those folders.")- } else {- Output.table(Self.rows(for: artifacts))- }- if scan.wasCutShort, !output.json {- Output.note("There were more folders than Peel looks at in one go, so this list isn't all of them.")- }+ },+ unreadableLocations: scan.unreadableLocations.map(Output.path)+ )}func clean(diff --git a/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift b/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swiftindex bbcdc74a..4b1dcc55 100644--- a/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift+++ b/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift@@ -101,8 +101,10 @@ public enum ProjectArtifacts {public struct Scan: Sendable {public var artifacts: [ProjectArtifact] = []public var wasCutShort = false- /// True when macOS refused a chosen folder, which Full Disk Access would open.- public var needsFullDiskAccess = false+ /// The chosen folders macOS refused, which Full Disk Access would open.+ public var unreadableLocations: [URL] = []++ public var needsFullDiskAccess: Bool { !unreadableLocations.isEmpty }}@concurrent@@ -128,7 +130,7 @@ public enum ProjectArtifacts {return Scan(artifacts: found.sorted { SizeTotal([$0.size]) > SizeTotal([$1.size]) },wasCutShort: wasCutShort,- needsFullDiskAccess: roots.contains { isSearchable($0) && FullDiskAccess.canList($0) == .missing }+ unreadableLocations: roots.filter { isSearchable($0) && FullDiskAccess.canList($0) == .missing })}}diff --git a/Packages/PeelCore/Tests/PeelCoreTests/FileCommandTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/FileCommandTests.swiftindex 21ccd2df..1a7cb83b 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/FileCommandTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/FileCommandTests.swift@@ -421,6 +421,21 @@ struct FileCommandTests {#expect(found["skippedLocations"] as? [String] == ["/Users/me/Projects/app"])}+ /// A chosen folder macOS kept Peel out of is said whatever the output, so "Nothing built was found" is not+ /// read as a folder with nothing built in it.+ @Test func saysWhenItCouldNotLookInAChosenFolder() throws {+ let locked = URL(filePath: "/Users/me/Library/Safari", directoryHint: .isDirectory)+ let scan = ProjectArtifacts.Scan(artifacts: [], wasCutShort: true, unreadableLocations: [locked])++ #expect(ProjectsCommand.notes(for: scan) == [+ Output.fullDiskAccessNote,+ "There were more folders than Peel looks at in one go, so this list isn't all of them.",+ ])+ let json = try Output.jsonText(ProjectsCommand.report(for: scan))+ let report = try #require(JSONSerialization.jsonObject(with: Data(json.utf8)) as? [String: Any])+ #expect(report["unreadableLocations"] as? [String] == ["/Users/me/Library/Safari"])+ }+/// `peel caches --json` says which folders `--remove` would take.@Test func theCachesListSaysWhatRemoveWouldTake() throws {let directory = try TemporaryDirectory()