From e1b674cbf11e784c19424975b6caef4cb115d845 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 11 Apr 2026 14:27:00 +0100 Subject: [PATCH] build: stabilize a2ui bundle hash --- scripts/bundle-a2ui.mjs | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/scripts/bundle-a2ui.mjs b/scripts/bundle-a2ui.mjs index 042ab7718dd..085ea322075 100644 --- a/scripts/bundle-a2ui.mjs +++ b/scripts/bundle-a2ui.mjs @@ -19,6 +19,9 @@ const inputPaths = [ a2uiAppDir, ]; const ignoredBundleHashInputPrefixes = ["vendor/a2ui/renderers/lit/dist"]; +const relativeInputPaths = inputPaths.map((inputPath) => + normalizePath(path.relative(rootDir, inputPath)), +); function fail(message) { console.error(message); @@ -79,10 +82,29 @@ async function walkFiles(entryPath, files) { } } +function listTrackedInputFiles() { + const result = spawnSync("git", ["ls-files", "--", ...relativeInputPaths], { + cwd: rootDir, + encoding: "utf8", + stdio: ["ignore", "pipe", "pipe"], + }); + if (result.status !== 0) { + return null; + } + return result.stdout + .split("\n") + .filter(Boolean) + .map((filePath) => path.join(rootDir, filePath)) + .filter((filePath) => isBundleHashInputPath(filePath)); +} + async function computeHash() { - const files = []; - for (const inputPath of inputPaths) { - await walkFiles(inputPath, files); + let files = listTrackedInputFiles(); + if (!files) { + files = []; + for (const inputPath of inputPaths) { + await walkFiles(inputPath, files); + } } files.sort((left, right) => normalizePath(left).localeCompare(normalizePath(right)));