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
Build Artifacts knows what JavaScript frameworks build
Țugui Dragoș8618c5256cf9
diff --git a/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift b/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swiftindex 6e9d8ee2..3539f692 100644--- a/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift+++ b/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift@@ -55,6 +55,10 @@ public enum ProjectArtifacts {private static let gradleFiles = ["build.gradle", "build.gradle.kts", "settings.gradle", "settings.gradle.kts"]private static let pythonProjectFiles = ["pyproject.toml", "requirements.txt", "Pipfile", "setup.py"]private static let nextConfigFiles = ["next.config.js", "next.config.mjs", "next.config.ts"]+ private static let nuxtConfigFiles = ["nuxt.config.ts", "nuxt.config.js", "nuxt.config.mjs"]+ private static let viteConfigFiles = ["ts", "mts", "cts", "js", "mjs", "cjs"].map { "vite.config." + $0 }+ private static let vitestConfigFiles = ["ts", "mts", "cts", "js", "mjs", "cjs"].map { "vitest.config." + $0 }+ private static let gatsbyConfigFiles = ["gatsby-config.js", "gatsby-config.ts", "gatsby-config.mjs"]static let definitions: [Definition] = [Definition(@@ -81,6 +85,54 @@ public enum ProjectArtifacts {name: ".next", markers: nextConfigFiles, tool: "Next.js", isGeneric: false,source: "https://nextjs.org/docs/app/api-reference/config/next-config-js/distDir"),+ Definition(+ name: ".nuxt", markers: nuxtConfigFiles, tool: "Nuxt", isGeneric: false,+ source: "https://nuxt.com/docs/4.x/directory-structure/nuxt"+ ),+ Definition(+ name: ".output", markers: nuxtConfigFiles, tool: "Nuxt", isGeneric: false,+ source: "https://nuxt.com/docs/4.x/directory-structure/output"+ ),+ Definition(+ name: ".svelte-kit", markers: ["svelte.config.js"], tool: "SvelteKit", isGeneric: false,+ source: "https://svelte.dev/docs/kit/project-structure"+ ),+ Definition(+ name: ".angular", markers: ["angular.json"], tool: "Angular", isGeneric: false,+ source: "https://angular.dev/cli/cache"+ ),+ Definition(+ name: ".turbo", markers: ["turbo.json"], tool: "Turborepo", isGeneric: false,+ source: "https://turborepo.dev/docs/crafting-your-repository/caching"+ ),+ Definition(+ name: ".parcel-cache", markers: ["package.json"], tool: "Parcel", isGeneric: false,+ source: "https://parceljs.org/features/cli/"+ ),+ Definition(+ name: "storybook-static", markers: [".storybook"], tool: "Storybook", isGeneric: false,+ source: "https://github.com/storybookjs/storybook/blob/next/code/core/src/cli/build.ts"+ ),+ Definition(+ name: "dist", markers: viteConfigFiles, tool: "Vite", isGeneric: true,+ source: "https://vite.dev/config/build-options"+ ),+ Definition(+ name: "out", markers: nextConfigFiles, tool: "Next.js", isGeneric: true,+ source: "https://nextjs.org/docs/app/guides/static-exports"+ ),+ Definition(+ name: "coverage", markers: vitestConfigFiles, tool: "Vitest", isGeneric: true,+ source: "https://vitest.dev/config/coverage"+ ),+ Definition(+ name: ".cache", markers: gatsbyConfigFiles, tool: "Gatsby", isGeneric: true,+ source: "https://www.gatsbyjs.com/docs/reference/gatsby-cli/"+ ),+ Definition(+ name: "public", markers: gatsbyConfigFiles, tool: "Gatsby", isGeneric: true,+ source: "https://www.gatsbyjs.com/docs/reference/gatsby-cli/"+ ),Definition(name: ".dart_tool", markers: ["pubspec.yaml"], tool: "Dart & Flutter", isGeneric: false,source: "https://dart.dev/tools/pub/package-layout"@@ -264,10 +316,11 @@ public enum ProjectArtifacts {}/// A hidden folder is usually a tool's own store, such as `~/.npm` with its many `node_modules`, which belong- /// to the Developer page.+ /// to the Developer page. A generic name like `public` is walked, since it is the person's own folder unless+ /// the file of the tool that makes it sits beside it.static func isSkipped(_ name: String) -> Bool {if name.hasPrefix(".") || name == "Library" { return true }- return definitions.contains { $0.name == name }+ return definitions.contains { $0.name == name && !$0.isGeneric }}static func marker(for definition: Definition, in names: Set<String>) -> String? {diff --git a/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swiftindex 98effdb0..07199409 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift@@ -51,6 +51,79 @@ struct ProjectArtifactsTests {#expect(!scan.needsFullDiskAccess)}+ private struct Kind {+ let artifact: String+ let marker: String+ var markerIsAFolder = false+ let tool: String+ let isGeneric: Bool+ var isEnvironment = false+ }++ private func expectFound(_ kinds: [Kind]) async throws {+ for kind in kinds {+ let directory = try TemporaryDirectory()+ if kind.markerIsAFolder {+ try directory.directory("with/\(kind.marker)")+ } else {+ try directory.file("with/\(kind.marker)", bytes: 16)+ }+ try directory.file("with/README.md", bytes: 16)+ try directory.file("with/\(kind.artifact)/output.bin", bytes: 400_000)+ try directory.file("without/\(kind.artifact)/output.bin", bytes: 400_000)+ try age(directory.url, days: 60)++ let found = await ProjectArtifacts.scan(roots: [directory.url]).artifacts++ let projects = found.map(\.project.lastPathComponent)+ #expect(projects == ["with"], "\(kind.artifact) was found in \(projects)")+ let artifact = found.first { $0.name == kind.artifact }+ #expect(artifact?.tool == kind.tool, "\(kind.artifact)")+ #expect(artifact?.hasGenericName == kind.isGeneric, "\(kind.artifact)")+ #expect(artifact?.isEnvironment == kind.isEnvironment, "\(kind.artifact)")+ #expect(artifact?.isRecommended == (!kind.isGeneric && !kind.isEnvironment), "\(kind.artifact)")+ }+ }++ @Test func looksInsideAFolderWithAGenericNameThatNoToolMade() async throws {+ let directory = try TemporaryDirectory()+ try directory.file("Code/public/site/package.json", bytes: 16)+ try directory.file("Code/public/site/node_modules/left-pad/index.js", bytes: 400_000)+ try directory.file("Code/shop/next.config.js", bytes: 16)+ try directory.file("Code/shop/.next/cache/data", bytes: 400_000)+ try directory.file("Code/shop/public/logo.svg", bytes: 16)+ try age(directory.url, days: 60)+ try FileManager.default.setAttributes(+ [.modificationDate: Date.now],+ ofItemAtPath: directory.url.appending(path: "Code/shop/public/logo.svg").path(percentEncoded: false)+ )++ let found = await ProjectArtifacts.scan(roots: [directory.url.appending(path: "Code")]).artifacts++ #expect(found.map(\.project.lastPathComponent).sorted() == ["shop", "site"])+ let next = try #require(found.first { $0.name == ".next" })+ #expect(next.isRecentlyActive, "a change in the project's own public folder was not counted")+ }++ @Test func findsWhatJavaScriptToolsBuild() async throws {+ try await expectFound([+ Kind(artifact: ".nuxt", marker: "nuxt.config.ts", tool: "Nuxt", isGeneric: false),+ Kind(artifact: ".output", marker: "nuxt.config.mjs", tool: "Nuxt", isGeneric: false),+ Kind(artifact: ".svelte-kit", marker: "svelte.config.js", tool: "SvelteKit", isGeneric: false),+ Kind(artifact: ".angular", marker: "angular.json", tool: "Angular", isGeneric: false),+ Kind(artifact: ".turbo", marker: "turbo.json", tool: "Turborepo", isGeneric: false),+ Kind(artifact: ".parcel-cache", marker: "package.json", tool: "Parcel", isGeneric: false),+ Kind(+ artifact: "storybook-static", marker: ".storybook", markerIsAFolder: true, tool: "Storybook", isGeneric: false+ ),+ Kind(artifact: "dist", marker: "vite.config.ts", tool: "Vite", isGeneric: true),+ Kind(artifact: "out", marker: "next.config.js", tool: "Next.js", isGeneric: true),+ Kind(artifact: "coverage", marker: "vitest.config.mts", tool: "Vitest", isGeneric: true),+ Kind(artifact: ".cache", marker: "gatsby-config.ts", tool: "Gatsby", isGeneric: true),+ Kind(artifact: "public", marker: "gatsby-config.js", tool: "Gatsby", isGeneric: true),+ ])+ }+private func age(_ url: URL, days: Int) throws {let date = Date.now.addingTimeInterval(-Double(days) * 24 * 60 * 60)guard let enumerator = FileManager.default.enumerator(at: url, includingPropertiesForKeys: nil) else { return }