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.

Build Artifacts offers the usual project folders

Țugui Dragoș88954b4c4710
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstrings
index eab506b8..98dc6307 100644
--- a/Localization/Peel/Localizable.xcstrings
+++ b/Localization/Peel/Localizable.xcstrings
@@ -8541,6 +8541,112 @@
}
}
},
+ "Add “%@”" : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Přidat „%@“"
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "„%@“ hinzufügen"
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Añadir “%@”"
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Ajouter « %@ »"
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Aggiungi “%@”"
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "“%@”を追加"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "‘%@’ 추가"
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Voeg '%@' toe"
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Dodaj „%@”"
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Adicionar “%@”"
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Adăugați „%@”"
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Добавить папку «%@»"
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Lägg till ”%@”"
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "“%@” Klasörünü Ekle"
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Додати «%@»"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "添加“%@”"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "加入「%@」"
+ }
+ }
+ }
+ },
"Added %@" : {
"localizations" : {
"cs" : {
diff --git a/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift b/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift
index 76e41df9..b99d3819 100644
--- a/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift
@@ -437,6 +437,15 @@ public enum ProjectArtifacts {
case notAFolder
}
+ /// The folders in the home folder where people usually keep projects, suggested until one is chosen: each is
+ /// offered only when it is a real folder there, never a link, and the person still confirms it.
+ public static func suggestedRoots(home: URL = .homeDirectory) -> [URL] {
+ ["Developer", "Projects", "Code", "src"].compactMap { name in
+ let url = home.appending(path: name, directoryHint: .isDirectory)
+ return url.isRealFolder && refusal(for: url, home: home) == nil ? url : nil
+ }
+ }
+
/// Why `root` cannot be searched, or nil. Every spelling of the path is checked: `/users/me` and
/// `/System/Volumes/Data/Users/me` are the same home folder, and a link into a cloud folder is that cloud folder.
public static func refusal(for root: URL, home: URL = .homeDirectory) -> Refusal? {
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift
index 763a7669..b4361275 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift
@@ -20,6 +20,22 @@ struct ProjectArtifactsTests {
#expect(stop.askedAfter == 0)
}
+ @Test func suggestsTheProjectFoldersThatExistInTheHomeFolder() throws {
+ let directory = try TemporaryDirectory()
+ try directory.directory("Developer")
+ try directory.directory("Code")
+ try directory.file("Projects", bytes: 1)
+ try directory.directory("Elsewhere/src")
+ try FileManager.default.createSymbolicLink(
+ atPath: directory.url.appending(path: "src").path(percentEncoded: false),
+ withDestinationPath: directory.url.appending(path: "Elsewhere/src").path(percentEncoded: false)
+ )
+
+ let suggested = ProjectArtifacts.suggestedRoots(home: directory.url)
+
+ #expect(suggested.map(\.lastPathComponent) == ["Developer", "Code"])
+ }
+
/// Full Disk Access does not open a folder closed by ordinary file permissions, so the scan must not ask for it.
/// The Time Machine checkbox marks only what a build certainly makes again, and never an artifact Time
/// Machine already leaves out through a folder above it, whose exclusion is not its own to change. A project
diff --git a/Peel/Model/ProjectLibrary.swift b/Peel/Model/ProjectLibrary.swift
index 40f66327..b9365243 100644
--- a/Peel/Model/ProjectLibrary.swift
+++ b/Peel/Model/ProjectLibrary.swift
@@ -84,7 +84,18 @@ final class ProjectLibrary {
panel.prompt = String(localized: "Choose")
panel.message = String(localized: "Choose the folders your projects live in.")
guard await panel.begin() == .OK else { return }
- let chosen = panel.urls.filter { url in !folders.contains { $0.standardizedFileURL == url.standardizedFileURL } }
+ await add(panel.urls)
+ }
+
+ /// The usual project folders in the home folder that are not on the list yet.
+ var suggestedFolders: [URL] {
+ ProjectArtifacts.suggestedRoots().filter { url in
+ !folders.contains { $0.standardizedFileURL == url.standardizedFileURL }
+ }
+ }
+
+ func add(_ urls: [URL]) async {
+ let chosen = urls.filter { url in !folders.contains { $0.standardizedFileURL == url.standardizedFileURL } }
// A folder that cannot be scanned is refused here, rather than saved and then silently skipped.
refused = chosen.compactMap { url in ProjectArtifacts.refusal(for: url).map { (url, $0) } }
let keeping = chosen.filter { url in !refused.contains { $0.url == url } }
diff --git a/Peel/Views/Projects/ProjectList.swift b/Peel/Views/Projects/ProjectList.swift
index 74115d62..ff0d50f1 100644
--- a/Peel/Views/Projects/ProjectList.swift
+++ b/Peel/Views/Projects/ProjectList.swift
@@ -47,6 +47,11 @@ struct ProjectList: View {
Task { await projects.addFolder() }
}
.buttonStyle(.borderedProminent)
+ ForEach(projects.suggestedFolders, id: \.self) { folder in
+ Button("Add “\(folder.lastPathComponent)”") {
+ Task { await projects.add([folder]) }
+ }
+ }
}
} else if !searchText.isEmpty, projects.groups?.isEmpty == false, filtered.isEmpty {
ContentUnavailableView.search(text: searchText)
diff --git a/README.md b/README.md
index f67bfcd5..84c6c317 100644
--- a/README.md
+++ b/README.md
@@ -115,7 +115,8 @@ Peel is free and open source, and it speaks English and 17 other languages.
`.nuxt`, `__pycache__`, Unity's `Library`, and any folder its tool tagged as a cache (`CACHEDIR.TAG`), each only
when a file of the tool that makes it proves it. A project changed in the last 7 days is never selected for you, and
neither are installed packages (a Python environment, `vendor`, Terraform's `.terraform`) or a folder like `target`
- whose name says nothing on its own.
+ whose name says nothing on its own. Until you choose a folder, Peel offers `~/Developer`, `~/Projects`, `~/Code`,
+ or `~/src` when you have one, and adds it only when you say so.
- **Duplicates:** files and whole folders with identical contents, compared with SHA-256. One copy is always kept.
- **Installers and Backups:** installers of apps you already have, including packages an app keeps in Application
Support, macOS installers, device firmware, downloads a browser never finished, and what your iPhone backups hold.