Skip to content

Commit 47cbd72

Browse files
committed
chore: use repo-local .cache/external-tools/ for tool downloads
1 parent a78b730 commit 47cbd72

File tree

2 files changed

+4
-21
lines changed

2 files changed

+4
-21
lines changed

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@
4141
# Zig build artifacts
4242
**/.zig-cache/
4343

44-
# External tools download cache
45-
**/.external-tools-cache/
46-
4744
# Docker build output (from Dockerfile.local-dev)
4845
build-output/
4946

packages/build-infra/lib/tool-downloader.mjs

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,14 @@
22
* Tool Download + Cache Engine
33
*
44
* Downloads pinned tool versions, verifies checksums, and caches them
5-
* in a user-level directory shared across repos.
5+
* in the repo-local .cache/external-tools/ directory (gitignored via .cache/).
66
*
7-
* Cache location:
8-
* - Linux: $XDG_CACHE_HOME/.external-tools-cache/ or ~/.cache/.external-tools-cache/
9-
* - macOS: ~/.cache/.external-tools-cache/
10-
* - Windows: %LOCALAPPDATA%/.external-tools-cache/
11-
* - Override: $EXTERNAL_TOOLS_CACHE
7+
* Override: $EXTERNAL_TOOLS_CACHE
128
*/
139

1410
import { createHash } from 'node:crypto'
1511
import { createReadStream, existsSync, readFileSync } from 'node:fs'
1612
import { promises as fs } from 'node:fs'
17-
import os from 'node:os'
1813
import path from 'node:path'
1914
import process from 'node:process'
2015

@@ -24,23 +19,14 @@ import { spawn } from '@socketsecurity/lib/spawn'
2419
const logger = getDefaultLogger()
2520

2621
/**
27-
* Get the user-level cache directory for downloaded tools.
22+
* Get the repo-local cache directory for downloaded tools.
2823
* @returns {string}
2924
*/
3025
export function getCacheDir() {
31-
// Allow override via environment variable
3226
if (process.env.EXTERNAL_TOOLS_CACHE) {
3327
return process.env.EXTERNAL_TOOLS_CACHE
3428
}
35-
36-
if (process.platform === 'win32') {
37-
const localAppData = process.env.LOCALAPPDATA || path.join(os.homedir(), 'AppData', 'Local')
38-
return path.join(localAppData, '.external-tools-cache')
39-
}
40-
41-
// Unix: XDG_CACHE_HOME or ~/.cache
42-
const xdgCache = process.env.XDG_CACHE_HOME || path.join(os.homedir(), '.cache')
43-
return path.join(xdgCache, '.external-tools-cache')
29+
return path.join(process.cwd(), '.cache', 'external-tools')
4430
}
4531

4632
/**

0 commit comments

Comments
 (0)