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.

Deno's caches are offered one by one, never its REPL history

Țugui Dragoș1fa1fe5c8b86
diff --git a/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift b/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift
index a698ac96..2b5e71a4 100644
--- a/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift
@@ -152,7 +152,17 @@ public enum DeveloperCaches {
Folder(".bun/install/cache", .downloads, storeInside: "links"),
]),
Definition(id: "deno", name: "Deno", systemImage: "chevron.left.forwardslash.chevron.right", appBundleIdentifiers: [], folders: [
- Folder("Library/Caches/deno", .downloads),
+ // `DENO_DIR` keeps the REPL history (`deno_history.txt`) and what scripts store (`location_data`)
+ // beside its caches, so the caches are named one by one, as Deno's `deno_dir.rs` names them. `deps` and
+ // the `_v1` databases are Deno 1's names.
+ Folder("Library/Caches/deno/remote", .downloads),
+ Folder("Library/Caches/deno/deps", .downloads),
+ Folder("Library/Caches/deno/npm", .downloads),
+ Folder("Library/Caches/deno/dl", .downloads),
+ Folder("Library/Caches/deno/gen", .buildData),
+ Folder("Library/Caches/deno/registries", .cache),
+ Folder("Library/Caches/deno/*_cache_v1", .cache),
+ Folder("Library/Caches/deno/*_cache_v2", .cache),
]),
Definition(id: "reactnative", name: "React Native CLI", systemImage: "cube", appBundleIdentifiers: [], folders: [
Folder("Library/Caches/react-native-cli", .cache),
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swift
index 0f4a5297..f352fafb 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swift
@@ -193,17 +193,23 @@ struct DeveloperCachesTests {
}
}
- /// `~/Library/Caches/deno` is Deno's `DENO_DIR`. Besides downloads, it holds `location_data`, with
- /// `localStorage` and the database behind `Deno.openKv()`. Once a script has kept state there, the folder is
- /// more than a cache and is not offered.
- @Test func leavesDenosFolderOnceAScriptHasKeptStateInIt() async throws {
+ /// `~/Library/Caches/deno` is Deno's `DENO_DIR`. Beside its caches it keeps the REPL history
+ /// (`deno_history.txt`) and what scripts store (`location_data`, with `localStorage` and the database behind
+ /// `Deno.openKv()`), so only the caches are offered, whatever else is there.
+ @Test func offersDenosCachesAndNeverItsHistoryOrWhatScriptsKept() async throws {
let directory = try TemporaryDirectory()
- try directory.file("Library/Caches/deno/deps/https/x.ts", bytes: 400_000)
+ for cache in ["remote/https/deno.land/x.ts", "npm/registry.npmjs.org/chalk/5.3.0/index.js", "deps/https/x.ts",
+ "gen/file/x.js", "registries/deno.land.json", "dl/deno-2.0.0.zip", "check_cache_v2", "dep_analysis_cache_v1"] {
+ try directory.file("Library/Caches/deno/\(cache)", bytes: 400_000)
+ }
+ try directory.file("Library/Caches/deno/deno_history.txt", bytes: 4_096)
+ try directory.file("Library/Caches/deno/location_data/abc/kv.sqlite3", bytes: 4_096)
+ try directory.file("Library/Caches/deno/latest.txt", bytes: 64)
let deno = DeveloperCaches.definitions.filter { $0.id == "deno" }
- #expect(await DeveloperCaches.scan(deno, homeDirectory: directory.url).flatMap(\.locations).count == 1)
- try directory.file("Library/Caches/deno/location_data/abc/kv.sqlite3")
- #expect(await DeveloperCaches.scan(deno, homeDirectory: directory.url).isEmpty)
+ let offered = Set(await DeveloperCaches.scan(deno, homeDirectory: directory.url).flatMap(\.locations).map(\.url.lastPathComponent))
+
+ #expect(offered == ["remote", "npm", "deps", "gen", "registries", "dl", "check_cache_v2", "dep_analysis_cache_v1"])
}
/// The whole table at once: every folder is found, at its own size, and nothing beside it is.