fix(release): preserve Windows long paths when archiving source evidence

This commit is contained in:
Agent Workbench Dev
2026-11-03 14:45:46 +08:00
parent 6bd605ad15
commit d22448d1f2
4 changed files with 20 additions and 4 deletions
+2 -4
View File
@@ -7,6 +7,7 @@ import { planBrowserBundle, copyBrowserBundle } from './bundle-browser.mjs';
import { planDesktopBundle, buildNativeLauncher, copyDesktopBundle } from './bundle-desktop.mjs';
import { buildWindowsInstaller } from './build-installer.mjs';
import { createDocumentationBundle } from './documentation-bundle.mjs';
import { archiveWindowsDirectory } from './release-archive.mjs';
const args = process.argv.slice(2);
if (args.some(value => !['--help', '--immutable'].includes(value))) throw new Error('Unsupported argument; use --help.');
@@ -127,13 +128,10 @@ function manifest(directory, kind) {
const portableManifest = manifest(portableRoot, 'portable');
manifest(sourceRoot, 'source');
const installer = buildWindowsInstaller({ root, portableRoot, outputRoot: releases });
const quote = value => "'" + value.replaceAll("'", "''") + "'";
function archive(directory) {
const destination = directory + '.zip';
if (!destination.startsWith(releases + path.sep)) throw new Error('Archive path is outside releases.');
if (fs.existsSync(destination)) fs.unlinkSync(destination);
const command = "$ErrorActionPreference='Stop'; Add-Type -AssemblyName System.IO.Compression.FileSystem; [IO.Compression.ZipFile]::CreateFromDirectory(" + quote(directory) + ', ' + quote(destination) + ', [IO.Compression.CompressionLevel]::Optimal, $true)';
execFileSync('powershell.exe', ['-NoProfile', '-NonInteractive', '-Command', command], { windowsHide: true, stdio: 'pipe' });
archiveWindowsDirectory(directory, destination);
return { path: destination, bytes: fs.statSync(destination).size, sha256: createHash('sha256').update(fs.readFileSync(destination)).digest('hex') };
}
const result = { portableRoot, sourceRoot, evidenceRoot, portable: archive(portableRoot), source: archive(sourceRoot), evidence: archive(evidenceRoot), documentation: { sourceCommit, originalFiles: documentation.originalFiles, originalBytes: documentation.originalBytes, shippedFiles: documentation.shipped.length, shippedBytes: documentation.shipped.reduce((sum, row) => sum + row.bytes, 0), evidenceManifestSha256: documentation.evidenceManifestSha256 }, installer, desktopRuntime, nativeLauncher, nodeVersion, reaRuntime, portableFiles: portableManifest.files.length, licenseTexts: licenseCount + 2 };
+14
View File
@@ -0,0 +1,14 @@
import fs from 'node:fs';
import path from 'node:path';
import { execFileSync } from 'node:child_process';
export function archiveWindowsDirectory(directory, destination) {
if (fs.existsSync(destination)) throw new Error('Archive output already exists; preserve the original candidate.');
const quote = value => "'" + value.replaceAll("'", "''") + "'";
// Windows PowerShell runs on .NET Framework. Namespace both paths so deeply
// nested source/evidence files do not fall back to the legacy MAX_PATH limit.
const command = "$ErrorActionPreference='Stop'; Add-Type -AssemblyName System.IO.Compression.FileSystem; [IO.Compression.ZipFile]::CreateFromDirectory("
+ quote(path.toNamespacedPath(path.resolve(directory))) + ', ' + quote(path.toNamespacedPath(path.resolve(destination)))
+ ', [IO.Compression.CompressionLevel]::Optimal, $true)';
execFileSync('powershell.exe', ['-NoProfile', '-NonInteractive', '-Command', command], { windowsHide: true, stdio: 'pipe' });
}