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.

Refuse a folder to search where apps and tools keep what they install

Țugui Dragoș0e83fdc61313
diff --git a/GUIDE.md b/GUIDE.md
index 2897f11a..01824530 100644
--- a/GUIDE.md
+++ b/GUIDE.md
@@ -100,7 +100,8 @@ project changed in the last 7 days, installed packages (a Python environment, `v
and a folder like `target` 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. A chosen folder Peel can't
search, such as one on a disk that isn't connected, is named at the top of the page with the reason, never taken for
-one with nothing built in it.
+one with nothing built in it. Peel never searches a hidden folder, a Library, or a folder a tool fills, such as
+`node_modules`, where apps and tools keep what they install, so choosing one, or a folder inside one, is refused.
**Space:** what's taking up room, and which app it belongs to. What an app manages itself, such as Xcode's
simulators, Docker's disk, Rust's toolchains, or Android's NDK versions, Space measures and leaves to that tool,
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstrings
index 14df06e9..9f59c046 100644
--- a/Localization/Peel/Localizable.xcstrings
+++ b/Localization/Peel/Localizable.xcstrings
@@ -59300,6 +59300,112 @@
}
}
},
+ "It is a hidden folder, a Library, or a folder a tool fills, such as node_modules, or it sits inside one. Apps and tools keep what they install there, so Peel doesn’t look for projects in it." : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Je to skrytá složka, složka Knihovna nebo složka jako node_modules, kterou plní nějaký nástroj, nebo se nachází uvnitř některé z nich. Aplikace a nástroje si tam ukládají, co instalují, a proto v ní Peel projekty nehledá."
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Dies ist ein ausgeblendeter Ordner, ein Library-Ordner oder ein Ordner, den ein Tool füllt, etwa node_modules, oder liegt in einem solchen. Apps und Tools bewahren dort auf, was sie installieren, daher sucht Peel darin nicht nach Projekten."
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Es una carpeta oculta, una carpeta Biblioteca o una carpeta que una herramienta llena, como node_modules, o está dentro de una. Las apps y las herramientas guardan ahí lo que instalan, así que Peel no busca proyectos en ella."
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "C’est un dossier masqué, un dossier Bibliothèque ou un dossier qu’un outil remplit, comme node_modules, ou il se trouve dans l’un d’eux. Les apps et les outils y conservent ce qu’ils installent : Peel n’y recherche donc pas de projets."
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "È una cartella nascosta, una cartella Libreria o una cartella che uno strumento riempie, come node_modules, oppure si trova all’interno di una di esse. Le app e gli strumenti conservano lì ciò che installano, quindi Peel non cerca progetti al suo interno."
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "隠しフォルダ、ライブラリフォルダ、またはツールが中身を入れるフォルダ(node_modulesなど)であるか、そのいずれかの中にあります。アプリやツールがインストールしたものをそこに保管するため、Peelはその中でプロジェクトを探しません。"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "숨김 폴더, 라이브러리 폴더 또는 node_modules처럼 도구가 채우는 폴더이거나 그 안에 있습니다. 앱과 도구는 설치하는 항목을 이러한 폴더에 보관하므로 Peel은 그 안에서 프로젝트를 찾지 않습니다."
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Het is een verborgen map, een bibliotheekmap of een map die door een tool wordt gevuld, zoals node_modules, of het staat in zo'n map. Apps en tools bewaren daar wat ze installeren, dus Peel zoekt er niet naar projecten."
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "To ukryty folder, folder Biblioteki lub folder wypełniany przez narzędzie, taki jak node_modules, albo folder wewnątrz jednego z nich. Aplikacje i narzędzia przechowują tam to, co instalują, więc Peel nie szuka w nim projektów."
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "É uma pasta oculta, uma pasta Biblioteca ou uma pasta que uma ferramenta preenche, como node_modules, ou está dentro de uma. Os apps e as ferramentas guardam ali o que instalam, então o Peel não procura projetos nela."
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Este un dosar ascuns, un dosar Bibliotecă sau un dosar pe care îl umple un instrument, cum ar fi node_modules, ori se află într‑unul. Aplicațiile și instrumentele păstrează acolo ce instalează, așa că Peel nu caută proiecte în el."
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Это скрытая папка, папка «Библиотека» или папка, которую заполняет инструмент, например node_modules, либо папка внутри одной из них. Приложения и инструменты хранят там то, что устанавливают, поэтому Peel не ищет в ней проекты."
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Den är en gömd mapp, en biblioteksmapp eller en mapp som ett verktyg fyller, till exempel node_modules, eller ligger i en sådan. Appar och verktyg sparar det som de installerar där, så Peel letar inte efter projekt i den."
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Gizli bir klasör, bir Kitaplık klasörü veya bir aracın doldurduğu, node_modules gibi bir klasör ya da bunlardan birinin içinde. Uygulamalar ve araçlar yüklediklerini orada tutar, bu yüzden Peel bunun içinde proje aramaz."
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Це прихована папка, Бібліотека чи папка, яку заповнює інструмент, як-от node_modules, або папка всередині однієї з них. Програми та інструменти зберігають там те, що інсталюють, тож Peel не шукає в ній проєктів."
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "它是隐藏文件夹、“资源库”文件夹或由工具填充的文件夹(例如node_modules),或者位于其中。App和工具会将它们安装的内容保存在那里,因此Peel不会在其中查找项目。"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "它是隱藏的檔案夾、「資源庫」檔案夾或由工具填入內容的檔案夾(例如node_modules),或位於其中。App和工具會將所安裝的內容存放在那裡,因此Peel不會在其中尋找計畫案。"
+ }
+ }
+ }
+ },
"It is an app or another package, or inside one, and what is inside belongs to it." : {
"localizations" : {
"cs" : {
diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift
index 6e355ddc..6f0e5ccf 100644
--- a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift
+++ b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift
@@ -355,6 +355,7 @@ extension ProjectArtifacts.Refusal {
case .inTheCloud: "it is in a cloud folder, which Peel leaves to the app that syncs it"
case .notAFolder: "it isn't a folder Peel can reach"
case .inAPackage: "it is an app or another package, or inside one, and what is inside belongs to it"
+ case .neverSearched: "it is a hidden folder, a Library, or a folder a tool fills, such as node_modules, or it sits inside one, where apps and tools keep what they install"
}
}
}
diff --git a/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift b/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift
index 4bd7b9a6..2ea88a63 100644
--- a/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift
@@ -488,6 +488,8 @@ public enum ProjectArtifacts {
case notAFolder
/// An app or another package, or a folder inside one: what is inside belongs to it.
case inAPackage
+ /// A folder the walk never enters (`isSkipped`), or one inside it: apps and tools keep what they install there.
+ case neverSearched
}
/// The folders in the home folder where people usually keep projects, suggested until one is chosen: each is
@@ -531,7 +533,10 @@ public enum ProjectArtifacts {
FileManager.default.fileExists(atPath: PathPattern.comparablePath(of: root), isDirectory: &isDirectory)
&& isDirectory.boolValue
guard isThere else { return .notAFolder }
- return root.isOrIsInsideAPackage ? .inAPackage : nil
+ if root.isOrIsInsideAPackage { return .inAPackage }
+ // The kernel's name for the folder: links resolved, each name as the disk holds it, as the walk sees names.
+ let names = PathComponents.of(PathPattern.canonical(root).path(percentEncoded: false))
+ return names.contains(where: isSkipped) ? .neverSearched : nil
}
/// Walks `root` for artifacts. Each folder is read on a thread of its own, within `FileSize`'s budget, since a
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift
index b34cc56e..4405c473 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift
@@ -148,6 +148,34 @@ struct ProjectArtifactsTests {
#expect(scan.refusedRoots.map(\.reason) == [.notAFolder])
}
+ /// An editor keeps an installed extension's `package.json` beside its `node_modules`, where the walk never goes.
+ @Test func refusesAFolderTheWalkNeverEnters() async throws {
+ let directory = try TemporaryDirectory()
+ let home = URL(filePath: "/Users/x", directoryHint: .isDirectory)
+ try directory.file("Tool/.editor/extensions/org.example.sample-1.0.0/package.json")
+ try directory.file("Tool/.editor/extensions/org.example.sample-1.0.0/node_modules/org-example-dep/index.js")
+ let extensions = directory.url.appending(path: "Tool/.editor/extensions", directoryHint: .isDirectory)
+ let installed = try directory.directory("Code/app/node_modules/org-example-dep")
+ let library = try directory.directory("Work/Library/Application Support/Editor")
+ let dotted = try directory.directory("Code/my.projects")
+ let real = try directory.directory("Code/real")
+ let linkInside = directory.url.appending(path: "Tool/.editor/real")
+ try FileManager.default.createSymbolicLink(at: linkInside, withDestinationURL: real)
+ let linkToExtensions = directory.url.appending(path: "Code/extensions")
+ try FileManager.default.createSymbolicLink(at: linkToExtensions, withDestinationURL: extensions)
+
+ #expect(ProjectArtifacts.refusal(for: extensions, home: home) == .neverSearched)
+ #expect(ProjectArtifacts.refusal(for: installed, home: home) == .neverSearched)
+ #expect(ProjectArtifacts.refusal(for: library, home: home) == .neverSearched)
+ #expect(ProjectArtifacts.refusal(for: linkToExtensions, home: home) == .neverSearched)
+ #expect(ProjectArtifacts.refusal(for: linkInside, home: home) == nil)
+ #expect(ProjectArtifacts.refusal(for: dotted, home: home) == nil)
+
+ let scan = await ProjectArtifacts.scan(roots: [extensions])
+ #expect(scan.artifacts.isEmpty)
+ #expect(scan.refusedRoots.map(\.reason) == [.neverSearched])
+ }
+
private struct Kind {
let artifact: String
let marker: String
@@ -613,7 +641,7 @@ struct ProjectArtifactsTests {
try directory.file("Sample.app/Contents/Resources/app/package.json")
let app = directory.url.appending(path: "Sample.app", directoryHint: .isDirectory)
- #expect(ProjectArtifacts.refusal(for: kit, home: home) == nil)
+ #expect(ProjectArtifacts.refusal(for: kit, home: home) == .neverSearched)
#expect(ProjectArtifacts.refusal(for: app, home: home) == .inAPackage)
#expect(ProjectArtifacts.refusal(for: app.appending(path: "Contents/Resources/app"), home: home) == .inAPackage)
}
diff --git a/Peel/Views/Presentation.swift b/Peel/Views/Presentation.swift
index d6699046..c49ce6e5 100644
--- a/Peel/Views/Presentation.swift
+++ b/Peel/Views/Presentation.swift
@@ -199,6 +199,7 @@ extension ProjectArtifacts.Refusal {
case .inTheCloud: String(localized: "It is in iCloud Drive or another cloud folder, which Peel leaves to the app that syncs it.")
case .notAFolder: String(localized: "It isn’t a folder Peel can reach. A disk that isn’t connected looks like this too.")
case .inAPackage: String(localized: "It is an app or another package, or inside one, and what is inside belongs to it.")
+ case .neverSearched: String(localized: "It is a hidden folder, a Library, or a folder a tool fills, such as node_modules, or it sits inside one. Apps and tools keep what they install there, so Peel doesn’t look for projects in it.")
}
}
}
diff --git a/SAFETY.md b/SAFETY.md
index f7893fc5..63204c0d 100644
--- a/SAFETY.md
+++ b/SAFETY.md
@@ -320,7 +320,10 @@ Build Artifacts recommends what a build or a package manager makes again from th
includes `node_modules` and `Pods`, which `npm install` and `pod install` put back from the project's `package.json` and
`Podfile`. A Python environment (`.venv`, `venv`) is listed and never selected, since packages are often installed into
one by hand, and so is Terraform's `.terraform`, which keeps the workspace you chose. A folder whose name says nothing
-on its own, such as `target` or `build`, is listed and never selected either.
+on its own, such as `target` or `build`, is listed and never selected either. Build Artifacts never searches a hidden
+folder, a Library, or a folder a tool fills, such as `node_modules`: apps and tools keep there what they install, as
+an editor keeps each extension's `package.json` beside the `node_modules` it runs with. A folder chosen to search
+that is one of those, or sits inside one, is refused with the reason.
Developer, Build Artifacts, Space, and Installers and Backups select nothing for you: opening a page selects nothing,
and Select Recommended selects what Peel recommends there.