feat(desktop): add verified install rollback and paged inspection
This commit is contained in:
+17
-4
@@ -4,6 +4,8 @@ import { execFileSync } from 'node:child_process';
|
||||
import { createHash } from 'node:crypto';
|
||||
import { planReaBundle, copyReaBundle } from './bundle-rea.mjs';
|
||||
import { planBrowserBundle, copyBrowserBundle } from './bundle-browser.mjs';
|
||||
import { planDesktopBundle, buildNativeLauncher, copyDesktopBundle } from './bundle-desktop.mjs';
|
||||
import { buildWindowsInstaller } from './build-installer.mjs';
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
if (args.some(value => !['--help', '--immutable'].includes(value))) throw new Error('Unsupported argument; use --help.');
|
||||
@@ -13,6 +15,7 @@ const meta = JSON.parse(fs.readFileSync('package.json', 'utf8'));
|
||||
const lock = JSON.parse(fs.readFileSync('package-lock.json', 'utf8'));
|
||||
const reaPlan = planReaBundle(root);
|
||||
const browserPlan = planBrowserBundle(root);
|
||||
const desktopPlan = planDesktopBundle(root);
|
||||
const releases = path.resolve(root, 'releases');
|
||||
fs.mkdirSync(releases, { recursive: true });
|
||||
const baseName = 'Agent-Workbench-' + meta.version;
|
||||
@@ -24,15 +27,15 @@ for (const target of [portableRoot, sourceRoot]) {
|
||||
fs.mkdirSync(target, { recursive: true });
|
||||
}
|
||||
|
||||
const portableFiles = ['dist-client', 'dist-server', 'docs', 'examples', 'benchmarks', 'research', 'README.md', 'CHANGELOG.md', 'DESIGN.md', 'AGENTS.md', 'Start-Workbench.cmd', 'Stop-Workbench.cmd'];
|
||||
const sourceFiles = ['src', 'public', 'scripts', 'tests', 'docs', 'examples', 'benchmarks', 'research', 'package.json', 'package-lock.json', 'vite.config.ts', 'tsconfig.json', 'index.html', '.gitignore', 'README.md', 'CHANGELOG.md', 'DESIGN.md', 'AGENTS.md', 'task_plan.md', 'findings.md', 'progress.md', 'Start-Workbench.cmd', 'Stop-Workbench.cmd'];
|
||||
const portableFiles = ['dist-client', 'dist-server', 'dist-desktop', 'public', 'docs', 'examples', 'benchmarks', 'research', 'README.md', 'CHANGELOG.md', 'DESIGN.md', 'AGENTS.md', 'Start-Workbench.cmd', 'Stop-Workbench.cmd', 'Start-Desktop.cmd'];
|
||||
const sourceFiles = ['src', 'public', 'scripts', 'tests', 'docs', 'examples', 'benchmarks', 'research', 'package.json', 'package-lock.json', 'vite.config.ts', 'tsconfig.json', 'index.html', '.gitignore', '.gitattributes', 'README.md', 'CHANGELOG.md', 'DESIGN.md', 'AGENTS.md', 'task_plan.md', 'findings.md', 'progress.md', 'Start-Workbench.cmd', 'Stop-Workbench.cmd', 'Start-Desktop.cmd'];
|
||||
const copyTree = (source, destination) => fs.cpSync(source, destination, { recursive: true, filter: (from, to) => {
|
||||
if (!fs.statSync(from).isFile() || !fs.existsSync(to)) return true;
|
||||
return !fs.readFileSync(from).equals(fs.readFileSync(to));
|
||||
} });
|
||||
for (const name of portableFiles) copyTree(path.join(root, name), path.join(portableRoot, name));
|
||||
fs.mkdirSync(path.join(portableRoot, 'scripts'), { recursive: true });
|
||||
for (const name of ['Start-Workbench.ps1', 'Stop-Workbench.ps1', 'upgrade-running.mjs', 'python-check-runner.py']) fs.copyFileSync(path.join(root, 'scripts', name), path.join(portableRoot, 'scripts', name));
|
||||
for (const name of ['Start-Workbench.ps1', 'Stop-Workbench.ps1', 'Start-Desktop.ps1', 'upgrade-running.mjs', 'python-check-runner.py']) fs.copyFileSync(path.join(root, 'scripts', name), path.join(portableRoot, 'scripts', name));
|
||||
for (const name of sourceFiles) copyTree(path.join(root, name), path.join(sourceRoot, name));
|
||||
|
||||
const preferredNode = path.resolve(root, '..', 'tools', 'node-v24.22.1-win-x64', 'node.exe');
|
||||
@@ -48,6 +51,15 @@ if (!fs.existsSync(runtimeDestination) || digest(runtimeDestination) !== digest(
|
||||
const npmRoot = path.join(path.dirname(nodeBinary), 'node_modules', 'npm');
|
||||
if (!fs.existsSync(path.join(npmRoot, 'bin', 'npm-cli.js'))) throw new Error('The portable engineering runner requires the npm shipped with this Node distribution.');
|
||||
copyTree(npmRoot, path.join(portableRoot, 'runtime', 'node_modules', 'npm'));
|
||||
fs.copyFileSync(nodeLicense, path.join(portableRoot, 'runtime', 'LICENSE'));
|
||||
fs.mkdirSync(path.join(sourceRoot, 'runtime'), { recursive: true });
|
||||
fs.copyFileSync(nodeBinary, path.join(sourceRoot, 'runtime', 'node.exe'));
|
||||
fs.copyFileSync(nodeLicense, path.join(sourceRoot, 'runtime', 'LICENSE'));
|
||||
copyTree(npmRoot, path.join(sourceRoot, 'runtime', 'node_modules', 'npm'));
|
||||
const launcherPath = path.join(root, '.qa', 'native-launcher', 'AgentWorkbench.exe');
|
||||
const nativeLauncher = buildNativeLauncher(root, launcherPath);
|
||||
const desktopRuntime = copyDesktopBundle(root, portableRoot, desktopPlan, { launcher: launcherPath });
|
||||
copyDesktopBundle(root, sourceRoot, desktopPlan, { source: true });
|
||||
const reaRuntime = copyReaBundle(path.join(portableRoot, 'runtime'), reaPlan);
|
||||
copyReaBundle(path.join(sourceRoot, 'runtime'), reaPlan);
|
||||
const browserRuntime = copyBrowserBundle(path.join(portableRoot, 'runtime'), browserPlan);
|
||||
@@ -109,6 +121,7 @@ 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';
|
||||
@@ -118,7 +131,7 @@ function archive(directory) {
|
||||
execFileSync('powershell.exe', ['-NoProfile', '-NonInteractive', '-Command', command], { windowsHide: true, stdio: 'pipe' });
|
||||
return { path: destination, bytes: fs.statSync(destination).size, sha256: createHash('sha256').update(fs.readFileSync(destination)).digest('hex') };
|
||||
}
|
||||
const result = { portableRoot, sourceRoot, portable: archive(portableRoot), source: archive(sourceRoot), nodeVersion, reaRuntime, portableFiles: portableManifest.files.length, licenseTexts: licenseCount + 2 };
|
||||
const result = { portableRoot, sourceRoot, portable: archive(portableRoot), source: archive(sourceRoot), installer, desktopRuntime, nativeLauncher, nodeVersion, reaRuntime, portableFiles: portableManifest.files.length, licenseTexts: licenseCount + 2 };
|
||||
result.browserRuntime = { playwrightVersion: browserRuntime.playwrightVersion, packages: browserRuntime.packages.map(pkg => ({ name: pkg.name, version: pkg.version, files: pkg.files.length })) };
|
||||
fs.writeFileSync(path.join(releases, 'latest.json'), JSON.stringify(result, null, 2));
|
||||
console.log(JSON.stringify(result, null, 2));
|
||||
|
||||
Reference in New Issue
Block a user