mirror of
https://github.com/tw93/Mole.git
synced 2026-03-22 19:40:07 +00:00
All files in cmd/analyze/ are macOS-only but several were missing the //go:build darwin constraint. On Linux (e.g. CodeQL CI), Go compiled these files without the types defined in main.go (which had the tag), causing undefined symbol errors for dirEntry, fileEntry, scanResult, cacheEntry, historyEntry and model. - Add //go:build darwin to heap.go, cache.go, scanner.go, cleanable.go, delete.go, format.go, constants.go and all *_test.go files Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
110 lines
2.1 KiB
Go
110 lines
2.1 KiB
Go
//go:build darwin
|
|
|
|
package main
|
|
|
|
import (
|
|
"path/filepath"
|
|
"strings"
|
|
)
|
|
|
|
// isCleanableDir marks paths safe to delete manually (not handled by mo clean).
|
|
func isCleanableDir(path string) bool {
|
|
if path == "" {
|
|
return false
|
|
}
|
|
|
|
// Exclude paths mo clean already handles.
|
|
if isHandledByMoClean(path) {
|
|
return false
|
|
}
|
|
|
|
baseName := filepath.Base(path)
|
|
|
|
// Project dependencies and build outputs are safe.
|
|
if projectDependencyDirs[baseName] {
|
|
return true
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
// isHandledByMoClean checks if a path is cleaned by mo clean.
|
|
func isHandledByMoClean(path string) bool {
|
|
cleanPaths := []string{
|
|
"/Library/Caches/",
|
|
"/Library/Logs/",
|
|
"/Library/Saved Application State/",
|
|
"/.Trash/",
|
|
"/Library/DiagnosticReports/",
|
|
}
|
|
|
|
for _, p := range cleanPaths {
|
|
if strings.Contains(path, p) {
|
|
return true
|
|
}
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
// Project dependency and build directories.
|
|
var projectDependencyDirs = map[string]bool{
|
|
// JavaScript/Node.
|
|
"node_modules": true,
|
|
"bower_components": true,
|
|
".yarn": true,
|
|
".pnpm-store": true,
|
|
|
|
// Python.
|
|
"venv": true,
|
|
".venv": true,
|
|
"virtualenv": true,
|
|
"__pycache__": true,
|
|
".pytest_cache": true,
|
|
".mypy_cache": true,
|
|
".ruff_cache": true,
|
|
".tox": true,
|
|
".eggs": true,
|
|
"htmlcov": true,
|
|
".ipynb_checkpoints": true,
|
|
|
|
// Ruby.
|
|
"vendor": true,
|
|
".bundle": true,
|
|
|
|
// Java/Kotlin/Scala.
|
|
".gradle": true,
|
|
"out": true,
|
|
|
|
// Build outputs.
|
|
"build": true,
|
|
"dist": true,
|
|
"target": true,
|
|
".next": true,
|
|
".nuxt": true,
|
|
".output": true,
|
|
".parcel-cache": true,
|
|
".turbo": true,
|
|
".vite": true,
|
|
".nx": true,
|
|
"coverage": true,
|
|
".coverage": true,
|
|
".nyc_output": true,
|
|
|
|
// Frontend framework outputs.
|
|
".angular": true,
|
|
".svelte-kit": true,
|
|
".astro": true,
|
|
".docusaurus": true,
|
|
|
|
// Apple dev.
|
|
"DerivedData": true,
|
|
"Pods": true,
|
|
".build": true,
|
|
"Carthage": true,
|
|
".dart_tool": true,
|
|
|
|
// Other tools.
|
|
".terraform": true,
|
|
}
|