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.

List Node's compile cache in the temporary folder on the Developer page

Țugui Dragoș73136f3ba1d7
diff --git a/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift b/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift
index 1d916064..844f78c1 100644
--- a/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift
@@ -433,6 +433,13 @@ public enum DeveloperCaches {
Folder(".cache/tuist", .buildData, source: "https://github.com/tuist/tuist/blob/9365e96671e69386cccae77079743ff871e14b79/server/priv/docs/en/cli/directories.md"),
]),
// JavaScript
+ Definition(id: "nodejs", name: "Node.js", systemImage: "cube", appBundleIdentifiers: [], folders: [
+ Folder(
+ "node-compile-cache/", .cache,
+ source: "https://github.com/nodejs/node/blob/6f71b9ba66553e2f3b31d99db2e1cc19891b3614/doc/api/module.md#L378-L385",
+ base: .userTemporary
+ ),
+ ]),
Definition(id: "npm", name: "npm", systemImage: "cube", appBundleIdentifiers: [], folders: [
Folder(".npm/_cacache", .downloads, source: "https://github.com/npm/cli/blob/b317f16c80df02ea3628cfa77170d5ae9b59720c/workspaces/config/lib/definitions/definitions.js#L443", movedBy: .npmCache(inside: "_cacache")),
Folder(".npm/_npx", .downloads, source: "https://github.com/npm/cli/blob/b317f16c80df02ea3628cfa77170d5ae9b59720c/workspaces/config/lib/definitions/definitions.js#L444", movedBy: .npmCache(inside: "_npx")),
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swift
index 820784b6..6c524bfa 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swift
@@ -403,7 +403,7 @@ struct DeveloperCachesTests {
let ownedOutright: Set<String> = [
".ccache", ".electron-gyp", ".gitlibs", ".node-gyp", ".virtualenvs", "nltk_data", "tensorflow_datasets",
".zcompdump*", ".pnpm-store", "playwright_*dev_profile-*/", "playwright-artifacts-*/", "metro-cache/",
- "metro-file-map-*",
+ "metro-file-map-*", "node-compile-cache/",
]
for definition in DeveloperCaches.definitions {
for path in definition.folders.map(\.path) {
@@ -1472,6 +1472,21 @@ struct DeveloperCachesTests {
#expect(locations.allSatisfy { $0.kind == .cache && $0.isRecommended })
}
+ @Test func offersNodesCompileCacheInTheTemporaryFolder() async throws {
+ let directory = try TemporaryDirectory()
+ let temporary = try directory.directory("var/T")
+ try directory.file("var/T/node-compile-cache/v24.10.0-arm64-5a7b9c-501/2f9e1c0d", bytes: 400_000)
+ try directory.file("var/T/node-cache-other/data", bytes: 400_000)
+ let node = DeveloperCaches.definitions.filter { $0.id == "nodejs" }
+
+ let locations = await DeveloperCaches.scan(
+ node, homeDirectory: directory.url.appending(path: "home"), userTemporaryDirectory: temporary
+ ).flatMap(\.locations)
+
+ #expect(locations.map(\.url.lastPathComponent) == ["node-compile-cache"])
+ #expect(locations.allSatisfy { $0.kind == .cache && $0.isRecommended })
+ }
+
@Test func offersTheSonarScannersCacheAndNeverItsCertificates() async throws {
let directory = try TemporaryDirectory()
try directory.file(".sonar/cache/0f2e/sonar-scanner-engine-shaded-10.jar", bytes: 400_000)