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.

Nx's cache and database are offered only together

Țugui Dragoșd3cee1677491
diff --git a/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift b/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift
index 2b5e71a4..53828361 100644
--- a/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift
@@ -174,8 +174,9 @@ public enum DeveloperCaches {
Folder(".expo/android-apk-cache", .downloads),
]),
Definition(id: "nx", name: "Nx", systemImage: "cube", appBundleIdentifiers: [], folders: [
- Folder(".nx/*/cache", .buildData),
- Folder(".nx/*/databases", .cache),
+ // One workspace's `cache` and `databases`, named by 16 hex digits of a hash. They go together: Nx
+ // answers a cache hit from the database alone, and a database without its cache restores nothing.
+ Folder(".nx/" + String(repeating: "[0-9a-f]", count: 16), .buildData),
]),
Definition(id: "playwright", name: "Playwright", systemImage: "globe", appBundleIdentifiers: [], folders: [
Folder("Library/Caches/ms-playwright", .downloads),
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swift
index f352fafb..728311a6 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swift
@@ -290,6 +290,20 @@ struct DeveloperCachesTests {
#expect(suggested == ["pnpm"], "a store installed packages link into was suggested")
}
+ /// Nx answers a cache hit from its database alone, so a workspace's `cache` and `databases` go together: the
+ /// folder that holds both is offered as one, and nothing else in `~/.nx` is.
+ @Test func offersNxsCacheAndDatabaseOnlyTogether() async throws {
+ let directory = try TemporaryDirectory()
+ try directory.file(".nx/5d41402abc4b2a76/cache/12345/outputs/dist.js", bytes: 400_000)
+ try directory.file(".nx/5d41402abc4b2a76/databases/workspace.db", bytes: 400_000)
+ try directory.file(".nx/sockets/daemon", bytes: 16)
+ let nx = DeveloperCaches.definitions.filter { $0.id == "nx" }
+
+ let offered = await DeveloperCaches.scan(nx, homeDirectory: directory.url).flatMap(\.locations).map(\.url.lastPathComponent)
+
+ #expect(offered == ["5d41402abc4b2a76"])
+ }
+
/// Bun's cache is a plain download cache until its global store is turned on: then `links` inside it is what
/// every project's `node_modules` points into, and the whole folder is listed without a checkmark. A store
/// moved to another disk leaves `links` as a link, which projects still reach through the cache.