diff --git a/scripts/stage-bundled-plugin-runtime-deps.mjs b/scripts/stage-bundled-plugin-runtime-deps.mjs index d6385e521ee..eb929f8e0ec 100644 --- a/scripts/stage-bundled-plugin-runtime-deps.mjs +++ b/scripts/stage-bundled-plugin-runtime-deps.mjs @@ -489,6 +489,33 @@ function resolveInstalledDirectDependencyNames( return directDependencyNames; } +function appendDirectoryFingerprint(hash, rootDir, currentDir = rootDir) { + const entries = fs + .readdirSync(currentDir, { withFileTypes: true }) + .toSorted((left, right) => left.name.localeCompare(right.name)); + + for (const entry of entries) { + const fullPath = path.join(currentDir, entry.name); + const relativePath = path.relative(rootDir, fullPath).replace(/\\/g, "/"); + const stats = fs.lstatSync(fullPath); + if (stats.isSymbolicLink()) { + hash.update(`symlink:${relativePath}->${fs.readlinkSync(fullPath).replace(/\\/g, "/")}\n`); + continue; + } + if (stats.isDirectory()) { + hash.update(`dir:${relativePath}\n`); + appendDirectoryFingerprint(hash, rootDir, fullPath); + continue; + } + if (!stats.isFile()) { + continue; + } + const stat = fs.statSync(fullPath); + hash.update(`file:${relativePath}:${stat.size}\n`); + hash.update(fs.readFileSync(fullPath)); + } +} + function createInstalledRuntimeClosureFingerprint(rootNodeModulesDir, dependencyNames) { const hash = createHash("sha256"); for (const depName of [...dependencyNames].toSorted((left, right) => left.localeCompare(right))) { @@ -496,19 +523,8 @@ function createInstalledRuntimeClosureFingerprint(rootNodeModulesDir, dependency if (depRoot === null || !fs.existsSync(depRoot)) { return null; } - const packageJsonPath = path.join(depRoot, "package.json"); - const installedVersion = readInstalledDependencyVersionFromRoot(depRoot); - const realRoot = fs.realpathSync(depRoot); - const packageJsonStat = fs.statSync(packageJsonPath); - hash.update( - JSON.stringify({ - depName, - installedVersion, - packageJsonMtimeMs: packageJsonStat.mtimeMs, - packageJsonSize: packageJsonStat.size, - realRoot, - }), - ); + hash.update(`package:${depName}:${fs.realpathSync(depRoot)}\n`); + appendDirectoryFingerprint(hash, depRoot); } return hash.digest("hex"); } diff --git a/test/release-check.test.ts b/test/release-check.test.ts index 079142f964d..527e72bd694 100644 --- a/test/release-check.test.ts +++ b/test/release-check.test.ts @@ -577,6 +577,8 @@ describe("collectMissingPackPaths", () => { "dist/index.js", "dist/entry.js", "dist/control-ui/index.html", + "dist/extensions/acpx/error-format.mjs", + "dist/extensions/acpx/mcp-command-line.mjs", "dist/extensions/acpx/mcp-proxy.mjs", bundledDistPluginFile("diffs", "assets/viewer-runtime.js"), ...requiredBundledPluginPackPaths,