dustclaw 0.1.2 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,95 +1,19 @@
1
- import { execSync } from "node:child_process";
2
- import { existsSync, readdirSync, statSync } from "node:fs";
1
+ import { existsSync, lstatSync, readdirSync, statSync } from "node:fs";
3
2
  import { homedir } from "node:os";
4
3
  import { join } from "node:path";
4
+ import { resolveCacheNames, resolveConfig, resolveTargets } from "./config.js";
5
5
  import { dirSize } from "./scan.js";
6
6
  const home = homedir();
7
- const targets = [
8
- {
9
- name: "Xcode DerivedData",
10
- path: join(home, "Library/Developer/Xcode/DerivedData"),
11
- description: "Xcode build artifacts",
12
- },
13
- {
14
- name: "Xcode Archives",
15
- path: join(home, "Library/Developer/Xcode/Archives"),
16
- description: "Xcode archived builds",
17
- },
18
- {
19
- name: "Xcode Device Support",
20
- path: join(home, "Library/Developer/Xcode/iOS DeviceSupport"),
21
- description: "iOS device support files",
22
- },
23
- {
24
- name: "Homebrew Cache",
25
- path: () => {
26
- try {
27
- return execSync("brew --cache", { encoding: "utf-8" }).trim();
28
- }
29
- catch {
30
- return null;
31
- }
32
- },
33
- description: "Homebrew downloaded packages",
34
- },
35
- {
36
- name: "Gradle Cache",
37
- path: join(home, ".gradle/caches"),
38
- description: "Gradle build cache",
39
- },
40
- {
41
- name: "Maven Cache",
42
- path: join(home, ".m2/repository"),
43
- description: "Maven dependency cache",
44
- },
45
- {
46
- name: "Cargo Cache",
47
- path: join(home, ".cargo/registry"),
48
- description: "Rust crate cache",
49
- },
50
- {
51
- name: "pnpm Store",
52
- path: join(home, "Library/pnpm/store"),
53
- description: "pnpm content-addressable store",
54
- },
55
- {
56
- name: "npm Cache",
57
- path: join(home, ".npm/_cacache"),
58
- description: "npm download cache",
59
- },
60
- {
61
- name: "Docker Desktop",
62
- path: join(home, "Library/Containers/com.docker.docker/Data"),
63
- description: "Docker images, containers, and volumes",
64
- },
65
- {
66
- name: "iOS Simulators",
67
- path: join(home, "Library/Developer/CoreSimulator/Devices"),
68
- description: "iOS Simulator device data",
69
- },
70
- {
71
- name: "Android Emulators",
72
- path: join(home, ".android/avd"),
73
- description: "Android emulator images",
74
- },
75
- {
76
- name: "Trash",
77
- path: join(home, ".Trash"),
78
- description: "Files in Trash",
79
- },
80
- {
81
- name: "System Logs",
82
- path: join(home, "Library/Logs"),
83
- description: "Application and system logs",
84
- },
85
- ];
86
- const MIN_CACHE_SIZE = 50 * 1024 * 1024; // 50 MB minimum to show in breakdown
7
+ function friendlyName(dirName, cacheNames) {
8
+ return cacheNames[dirName] ?? dirName;
9
+ }
87
10
  export function findCaches() {
88
- const cachesDir = join(home, "Library/Caches");
11
+ const { minCacheSize, cachesPath, cacheSkipList } = resolveConfig();
12
+ const cachesDir = join(home, cachesPath);
89
13
  if (!existsSync(cachesDir))
90
14
  return [];
91
- // Paths already covered by specific targets — skip to avoid double-counting
92
- const skip = new Set(["Homebrew", "CocoaPods", "Yarn"]);
15
+ const skip = new Set(cacheSkipList);
16
+ const cacheNames = resolveCacheNames();
93
17
  const results = [];
94
18
  let items;
95
19
  try {
@@ -111,67 +35,45 @@ export function findCaches() {
111
35
  continue;
112
36
  }
113
37
  const size = dirSize(fullPath);
114
- if (size >= MIN_CACHE_SIZE) {
38
+ if (size >= minCacheSize) {
115
39
  results.push({
116
- name: `Cache: ${friendlyName(name)}`,
40
+ name: `Cache: ${friendlyName(name, cacheNames)}`,
117
41
  path: fullPath,
118
42
  size,
119
- description: `${name} cache`,
43
+ description: `${name} application cache`,
44
+ safe: true,
120
45
  });
121
46
  }
122
47
  }
123
48
  return results.sort((a, b) => b.size - a.size);
124
49
  }
125
- function friendlyName(dirName) {
126
- const map = {
127
- "com.spotify.client": "Spotify",
128
- "com.apple.Safari": "Safari",
129
- "com.google.Chrome": "Chrome",
130
- Google: "Google/Chrome",
131
- "com.docker.docker": "Docker",
132
- "com.microsoft.VSCode": "VS Code",
133
- "com.todesktop.230313mzl4w4u92.ShipIt": "Cursor Updates",
134
- "com.google.antigravity.ShipIt": "Chrome Updates",
135
- icloudmailagent: "iCloud Mail",
136
- "com.apple.callintelligenced": "Apple Call Intelligence",
137
- "ms-playwright": "Playwright Browsers",
138
- pip: "pip",
139
- Cypress: "Cypress",
140
- "node-gyp": "node-gyp",
141
- typescript: "TypeScript",
142
- pnpm: "pnpm",
143
- colima: "Colima",
144
- "com.openai.codex": "OpenAI Codex",
145
- };
146
- return map[dirName] ?? dirName;
147
- }
148
50
  export function findWaste() {
51
+ const targets = resolveTargets();
149
52
  const results = [];
150
53
  for (const target of targets) {
151
- const resolvedPath = typeof target.path === "function" ? target.path() : target.path;
152
- if (!resolvedPath)
54
+ if (!existsSync(target.path))
153
55
  continue;
154
- if (!existsSync(resolvedPath))
155
- continue;
156
- const size = dirSize(resolvedPath);
56
+ const size = dirSize(target.path);
157
57
  if (size > 0) {
158
58
  results.push({
159
59
  name: target.name,
160
- path: resolvedPath,
60
+ path: target.path,
161
61
  size,
162
62
  description: target.description,
63
+ safe: target.safe,
163
64
  });
164
65
  }
165
66
  }
166
67
  results.push(...findCaches());
167
68
  return results.sort((a, b) => b.size - a.size);
168
69
  }
169
- export function findNodeModules(root, maxDepth = 5) {
70
+ export function findNodeModules(root, maxDepth) {
71
+ const { nodeModulesMaxDepth, opaqueDirectories } = resolveConfig();
170
72
  const results = [];
171
- searchNodeModules(root, results, 0, maxDepth);
73
+ searchNodeModules(root, results, 0, maxDepth ?? nodeModulesMaxDepth, new Set(opaqueDirectories));
172
74
  return results.sort((a, b) => b.size - a.size);
173
75
  }
174
- function searchNodeModules(dir, results, depth, maxDepth) {
76
+ function searchNodeModules(dir, results, depth, maxDepth, opaqueSet) {
175
77
  if (depth > maxDepth)
176
78
  return;
177
79
  let items;
@@ -193,14 +95,17 @@ function searchNodeModules(dir, results, depth, maxDepth) {
193
95
  path: fullPath,
194
96
  size,
195
97
  description: `node_modules in ${dir}`,
98
+ safe: true,
196
99
  });
197
100
  }
198
101
  continue;
199
102
  }
103
+ if (opaqueSet.has(name))
104
+ continue;
200
105
  try {
201
- const stat = statSync(fullPath);
106
+ const stat = lstatSync(fullPath);
202
107
  if (stat.isDirectory()) {
203
- searchNodeModules(fullPath, results, depth + 1, maxDepth);
108
+ searchNodeModules(fullPath, results, depth + 1, maxDepth, opaqueSet);
204
109
  }
205
110
  }
206
111
  catch { }
package/package.json CHANGED
@@ -1,7 +1,10 @@
1
1
  {
2
2
  "name": "dustclaw",
3
- "version": "0.1.2",
3
+ "version": "0.4.0",
4
4
  "description": "Disk space monitoring, analysis, and cleanup CLI",
5
+ "engines": {
6
+ "node": ">=22.12.0"
7
+ },
5
8
  "homepage": "https://github.com/psandis/dustclaw",
6
9
  "type": "module",
7
10
  "repository": {
@@ -13,6 +16,7 @@
13
16
  },
14
17
  "files": [
15
18
  "dist",
19
+ "data",
16
20
  "README.md",
17
21
  "LICENSE",
18
22
  "assets/dustclaw.png"
@@ -37,22 +41,19 @@
37
41
  "license": "MIT",
38
42
  "packageManager": "pnpm@10.12.1",
39
43
  "dependencies": {
40
- "better-sqlite3": "^12.8.0",
41
- "chalk": "^5.6.2",
42
- "commander": "^14.0.3"
44
+ "chalk": "^6.0.1",
45
+ "commander": "^15.0.0"
43
46
  },
44
47
  "pnpm": {
45
48
  "onlyBuiltDependencies": [
46
- "better-sqlite3",
47
49
  "esbuild"
48
50
  ]
49
51
  },
50
52
  "devDependencies": {
51
- "@biomejs/biome": "^2.4.8",
52
- "@types/better-sqlite3": "^7.6.13",
53
- "@types/node": "^25.5.0",
54
- "tsx": "^4.21.0",
55
- "typescript": "^6.0.2",
56
- "vitest": "^4.1.1"
53
+ "@biomejs/biome": "^2.5.15",
54
+ "@types/node": "^26.6.5",
55
+ "tsx": "^4.23.15",
56
+ "typescript": "^7.0.2",
57
+ "vitest": "^5.0.3"
57
58
  }
58
59
  }