From d7eea3395b67d319822bcda7e1d58ddef73f236e Mon Sep 17 00:00:00 2001 From: Jeff Dickey <216188+jdx@users.noreply.github.com> Date: Fri, 25 Sep 2026 08:00:16 -0500 Subject: [PATCH] fix: align aube install scripts and cold-cache cleanup --- scripts/clean-helpers.sh | 16 +++++-- scripts/clean-helpers.test.js | 88 +++++++++++++++++++++++++++++++++++ scripts/variations/ci.sh | 4 +- scripts/variations/common.sh | 3 +- 4 files changed, 104 insertions(+), 7 deletions(-) create mode 100644 scripts/clean-helpers.test.js diff --git a/scripts/clean-helpers.sh b/scripts/clean-helpers.sh index c5def53bfd..dae9fcd1a9 100644 --- a/scripts/clean-helpers.sh +++ b/scripts/clean-helpers.sh @@ -112,12 +112,20 @@ clean_aube_metadata_cache() { fi } -# Function to safely clean ALL aube caches — metadata cache, package index, -# virtual-store (all under ~/.cache/aube/) AND the global content-addressable -# store (~/.aube-store/). Used in "clean" (fully cold) variations. +# Function to safely clean ALL aube caches, including the configured store. +# Current releases put content and package indexes under the XDG data directory; +# metadata and the global virtual store live under the XDG cache directory. +# Keep cleaning ~/.aube-store for older releases too. clean_aube_cache() { clean_aube_metadata_cache - safe_remove "$HOME/.cache/aube" + if command -v aube &> /dev/null; then + local store_path + store_path="$(aube store path 2>/dev/null)" || store_path="" + if [ -n "$store_path" ]; then + safe_remove "$store_path" + fi + fi + safe_remove "${XDG_CACHE_HOME:-$HOME/.cache}/aube" safe_remove "$HOME/.aube-store" } diff --git a/scripts/clean-helpers.test.js b/scripts/clean-helpers.test.js new file mode 100644 index 0000000000..e9e8f5f64c --- /dev/null +++ b/scripts/clean-helpers.test.js @@ -0,0 +1,88 @@ +const assert = require("node:assert/strict"); +const fs = require("node:fs"); +const os = require("node:os"); +const path = require("node:path"); +const { spawnSync } = require("node:child_process"); +const test = require("node:test"); + +for (const scenario of [ + { + name: "configured store with spaces", + command: "clean_aube_cache", + store: true, + }, + { name: "unavailable store path", command: "clean_aube_cache", store: false }, + { + name: "metadata-only cleanup", + command: "clean_aube_metadata_cache", + store: true, + }, +]) { + test(`aube cache cleanup: ${scenario.name}`, (t) => { + const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "aube-clean-test-")); + t.after(() => fs.rmSync(tempDir, { recursive: true, force: true })); + const binDir = path.join(tempDir, "bin"); + const store = path.join(tempDir, "custom store", "v1"); + const cache = path.join(tempDir, "xdg cache"); + const removeLog = path.join(tempDir, "removed.txt"); + const commandLog = path.join(tempDir, "commands.txt"); + fs.mkdirSync(binDir); + fs.writeFileSync(removeLog, ""); + fs.writeFileSync( + path.join(binDir, "aube"), + `#!/bin/sh +printf '%s\\n' "$*" >> "$COMMAND_LOG" +if [ "$1" = store ]; then + [ "$STORE_AVAILABLE" = 1 ] || exit 1 + printf '%s\\n' "$TEST_STORE" +fi +`, + { mode: 0o755 }, + ); + + // Record deletion targets so the test never touches the user's caches. + const result = spawnSync( + "bash", + [ + "-c", + ` +source "$HELPERS" >/dev/null +safe_remove() { printf '%s\\n' "$1" >> "$REMOVE_LOG"; } +"$CLEAN_COMMAND" +`, + ], + { + encoding: "utf8", + env: { + ...process.env, + PATH: `${binDir}${path.delimiter}${process.env.PATH}`, + HELPERS: path.join(__dirname, "clean-helpers.sh"), + TEST_STORE: store, + STORE_AVAILABLE: scenario.store ? "1" : "0", + XDG_CACHE_HOME: cache, + REMOVE_LOG: removeLog, + COMMAND_LOG: commandLog, + CLEAN_COMMAND: scenario.command, + }, + }, + ); + assert.equal(result.status, 0, result.stderr); + const removed = fs + .readFileSync(removeLog, "utf8") + .trim() + .split("\n") + .filter(Boolean); + const commands = fs.readFileSync(commandLog, "utf8").trim().split("\n"); + if (scenario.command === "clean_aube_metadata_cache") { + assert.deepEqual(removed, []); + assert.deepEqual(commands, ["cache delete *"]); + } else { + assert.deepEqual(removed, [ + ...(scenario.store ? [store] : []), + path.join(cache, "aube"), + path.join(os.homedir(), ".aube-store"), + ]); + assert.deepEqual(commands, ["cache delete *", "store path"]); + } + }); +} diff --git a/scripts/variations/ci.sh b/scripts/variations/ci.sh index 823b3e576a..71df5cc3fd 100644 --- a/scripts/variations/ci.sh +++ b/scripts/variations/ci.sh @@ -27,7 +27,7 @@ BENCH_CI_PACQUET="/tmp/pnpm12/bin/pnpm install --frozen-lockfile --ignore-script BENCH_CI_VLT="vlt ci --view=silent" BENCH_CI_BUN="bun install --frozen-lockfile --ignore-scripts --silent" BENCH_CI_DENO="deno install --frozen --quiet" -BENCH_CI_AUBE="aube ci --silent" +BENCH_CI_AUBE="aube ci --ignore-scripts --silent" # Override BENCH_COMMAND_* with CI commands + log redirection BENCH_COMMAND_NPM="timeout $BENCH_TIMEOUT $BENCH_CI_NPM >> $BENCH_OUTPUT_FOLDER/npm-output-\${HYPERFINE_ITERATION}.log 2>&1" @@ -93,7 +93,7 @@ BENCH_PREPARE_PACQUET="$(ci_prepare "$BENCH_SETUP_PACQUET" "/tmp/pnpm12/bin/pnpm BENCH_PREPARE_VLT="$(ci_prepare "$BENCH_SETUP_VLT" "vlt install --view=silent")" BENCH_PREPARE_BUN="$(ci_prepare "$BENCH_SETUP_BUN" "bun install --ignore-scripts --silent")" BENCH_PREPARE_DENO="$(ci_prepare "$BENCH_SETUP_DENO" "deno install --quiet")" -BENCH_PREPARE_AUBE="$(ci_prepare "$BENCH_SETUP_AUBE" "aube install --silent")" +BENCH_PREPARE_AUBE="$(ci_prepare "$BENCH_SETUP_AUBE" "aube install --ignore-scripts --silent")" # Run the benchmark suite hyperfine --ignore-failure \ diff --git a/scripts/variations/common.sh b/scripts/variations/common.sh index cd889de754..da7a2cdfb1 100644 --- a/scripts/variations/common.sh +++ b/scripts/variations/common.sh @@ -87,6 +87,7 @@ BENCH_SETUP_NODE="" # measure dependency resolution + linking only (not arbitrary postinstall work). # npm, yarn classic, bun: run scripts by default → --ignore-scripts # pnpm v11+: errors on ignored build scripts (ERR_PNPM_IGNORED_BUILDS) → --ignore-scripts +# aube: runs scripts for its default trusted dependencies → --ignore-scripts # berry, zpm, vlt: don't run scripts by default → no flag needed # deno: doesn't run scripts by default → removed --allow-scripts BENCH_INSTALL_NPM="npm install --no-audit --no-fund --ignore-scripts --silent" @@ -103,7 +104,7 @@ BENCH_INSTALL_PACQUET="/tmp/pnpm12/bin/pnpm install --ignore-scripts --silent" BENCH_INSTALL_VLT="vlt install --view=silent" BENCH_INSTALL_BUN="bun install --ignore-scripts --silent" BENCH_INSTALL_DENO="deno install --quiet" -BENCH_INSTALL_AUBE="aube install --silent" +BENCH_INSTALL_AUBE="aube install --ignore-scripts --silent" BENCH_COMMAND_NPM="timeout $BENCH_TIMEOUT $BENCH_INSTALL_NPM >> $BENCH_OUTPUT_FOLDER/npm-output-\${HYPERFINE_ITERATION}.log 2>&1" BENCH_COMMAND_YARN="timeout $BENCH_TIMEOUT $BENCH_INSTALL_YARN > $BENCH_OUTPUT_FOLDER/yarn-output-\${HYPERFINE_ITERATION}.log 2>&1"