Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.
Swift cache-cleanercleanerclideveloper-toolsdisk-cleanupdisk-spaceduplicate-finderhomebrewliquid-glassmac-cleanermacosmacos-appmacos-golden-gatemacos-tahoemacos-tweaksswiftswiftuiterminal-themesuninstalluninstaller
List the cache Ruby Sass left behind in Build Artifacts
Țugui Dragoș9f8e7e01adec
diff --git a/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift b/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swiftindex 787e2358..17297763 100644--- a/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift+++ b/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift@@ -112,6 +112,9 @@ public enum ProjectArtifacts {case holdsOnlyFilesEnding(String)/// Nothing but entries with these names, `including` among them.case holdsOnly(Set<String>, including: String)+ /// Nothing but folders named by a lowercase hexadecimal digest of this many characters, as Ruby Sass names+ /// each folder of its cache by the SHA-1 of the folder its stylesheet sits in.+ case holdsOnlyFoldersNamedByDigest(characters: Int)func holds(at url: URL) -> Bool {switch self {@@ -131,6 +134,13 @@ public enum ProjectArtifacts {entry.lastPathComponent.hasSuffix(ending)&& (try? entry.resourceValues(forKeys: [.isRegularFileKey]).isRegularFile) == true}+ case .holdsOnlyFoldersNamedByDigest(let characters):+ let entries = ProjectArtifacts.contents(of: url) ?? []+ return !entries.isEmpty && entries.allSatisfy { entry in+ let name = entry.lastPathComponent.utf8+ return name.count == characters && name.allSatisfy { "0123456789abcdef".utf8.contains($0) }+ && ProjectArtifacts.isRealFolder(entry)+ }}}}@@ -287,6 +297,12 @@ public enum ProjectArtifacts {name: ".parcel-cache", markers: ["package.json"], tool: "Parcel", isGeneric: false,source: "https://parceljs.org/features/cli/"),+ // Ruby Sass leaves its cache in whatever folder it ran from, so it is known by what it holds.+ Definition(+ name: ".sass-cache", markers: [], tool: "Ruby Sass", isGeneric: false,+ source: "https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/engine.rb#L171",+ proof: .holdsOnlyFoldersNamedByDigest(characters: 40)+ ),Definition(name: "storybook-static", markers: [".storybook"], tool: "Storybook", isGeneric: false,source: "https://github.com/storybookjs/storybook/blob/dc9b30e8fd8a71383ec01b9510f38bee51457e8a/code/core/src/cli/build.ts"diff --git a/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swiftindex 32ed1301..4741b9ed 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift@@ -296,6 +296,21 @@ struct ProjectArtifactsTests {#expect(found.allSatisfy { $0.tool == "Meson" && $0.heldBack == .keepsItsSetup && !$0.isRecommended })}+ @Test func listsRubySassCacheWhereverItRan() async throws {+ let directory = try TemporaryDirectory()+ let digest = String(repeating: "3f", count: 20)+ try directory.file("site/stylesheets/.sass-cache/\(digest)/screen.scssc", bytes: 400_000)+ try directory.file("site/stylesheets/screen.scss", bytes: 16)+ try directory.file("notes/.sass-cache/readme.txt", bytes: 400_000)+ try directory.file("other/.sass-cache/drafts/screen.scssc", bytes: 400_000)+ try age(directory.url, days: 60)++ let found = await ProjectArtifacts.scan(roots: [directory.url]).artifacts++ #expect(found.map(\.project.lastPathComponent) == ["stylesheets"])+ #expect(found.allSatisfy { $0.name == ".sass-cache" && $0.tool == "Ruby Sass" && $0.isRecommended })+ }+@Test func listsPDMsPackagesAndNothingInsideThem() async throws {let directory = try TemporaryDirectory()try directory.file("app/pyproject.toml", bytes: 16)@@ -1071,6 +1086,8 @@ struct ProjectArtifactsTests {case .holds(let file): try directory.file("\(artifact)/\(file)")case .holdsOnlyFilesEnding(let ending): try directory.file("\(artifact)/module\(ending)")case .holdsOnly(_, let including): try directory.file("\(artifact)/\(including)/content")+ case .holdsOnlyFoldersNamedByDigest(let characters):+ try directory.file("\(artifact)/\(String(repeating: "a", count: characters))/content")case nil: try directory.file("\(artifact)/content")}expected[artifact] = definition.tool