From c4efdeddd5801bc443bdbd4d5ef533daccfc1cae Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Wed, 8 Apr 2026 03:43:54 +0100 Subject: [PATCH] fix: harden parallels upgrade flows --- package.json | 2 +- scripts/build-all.mjs | 39 ++++++++++++++++++++++++++ scripts/e2e/parallels-macos-smoke.sh | 20 ++++++------- scripts/e2e/parallels-windows-smoke.sh | 5 ++-- 4 files changed, 52 insertions(+), 14 deletions(-) create mode 100644 scripts/build-all.mjs diff --git a/package.json b/package.json index fc5ce67a060..8c7ae83275e 100644 --- a/package.json +++ b/package.json @@ -1067,7 +1067,7 @@ "android:test:integration": "OPENCLAW_LIVE_TEST=1 OPENCLAW_LIVE_ANDROID_NODE=1 node scripts/run-vitest.mjs run --config vitest.live.config.ts src/gateway/android-node.capabilities.live.test.ts", "android:test:third-party": "cd apps/android && ./gradlew :app:testThirdPartyDebugUnitTest", "audit:seams": "node scripts/audit-seams.mjs", - "build": "pnpm canvas:a2ui:bundle && node scripts/tsdown-build.mjs && node scripts/runtime-postbuild.mjs && node scripts/build-stamp.mjs && pnpm build:plugin-sdk:dts && node --import tsx scripts/write-plugin-sdk-entry-dts.ts && node scripts/check-plugin-sdk-exports.mjs && node --import tsx scripts/canvas-a2ui-copy.ts && node --import tsx scripts/copy-hook-metadata.ts && node --import tsx scripts/copy-export-html-templates.ts && node --import tsx scripts/write-build-info.ts && node --experimental-strip-types scripts/write-cli-startup-metadata.ts && node --import tsx scripts/write-cli-compat.ts", + "build": "node scripts/build-all.mjs", "build:docker": "node scripts/tsdown-build.mjs && node scripts/runtime-postbuild.mjs && node scripts/build-stamp.mjs && node --import tsx scripts/canvas-a2ui-copy.ts && node --import tsx scripts/copy-hook-metadata.ts && node --import tsx scripts/copy-export-html-templates.ts && node --import tsx scripts/write-build-info.ts && node --experimental-strip-types scripts/write-cli-startup-metadata.ts && node --import tsx scripts/write-cli-compat.ts", "build:plugin-sdk:dts": "tsc -p tsconfig.plugin-sdk.dts.json", "build:strict-smoke": "pnpm canvas:a2ui:bundle && node scripts/tsdown-build.mjs && node scripts/runtime-postbuild.mjs && node scripts/build-stamp.mjs && pnpm build:plugin-sdk:dts && node --import tsx scripts/write-plugin-sdk-entry-dts.ts && node scripts/check-plugin-sdk-exports.mjs", diff --git a/scripts/build-all.mjs b/scripts/build-all.mjs new file mode 100644 index 00000000000..f497d2bfb23 --- /dev/null +++ b/scripts/build-all.mjs @@ -0,0 +1,39 @@ +#!/usr/bin/env node + +import { spawnSync } from "node:child_process"; + +const nodeBin = process.execPath; +const pnpmBin = process.platform === "win32" ? "pnpm.cmd" : "pnpm"; + +const steps = [ + { cmd: pnpmBin, args: ["canvas:a2ui:bundle"] }, + { cmd: nodeBin, args: ["scripts/tsdown-build.mjs"] }, + { cmd: nodeBin, args: ["scripts/runtime-postbuild.mjs"] }, + { cmd: nodeBin, args: ["scripts/build-stamp.mjs"] }, + { cmd: pnpmBin, args: ["build:plugin-sdk:dts"] }, + { cmd: nodeBin, args: ["--import", "tsx", "scripts/write-plugin-sdk-entry-dts.ts"] }, + { cmd: nodeBin, args: ["scripts/check-plugin-sdk-exports.mjs"] }, + { cmd: nodeBin, args: ["--import", "tsx", "scripts/canvas-a2ui-copy.ts"] }, + { cmd: nodeBin, args: ["--import", "tsx", "scripts/copy-hook-metadata.ts"] }, + { cmd: nodeBin, args: ["--import", "tsx", "scripts/copy-export-html-templates.ts"] }, + { cmd: nodeBin, args: ["--import", "tsx", "scripts/write-build-info.ts"] }, + { + cmd: nodeBin, + args: ["--experimental-strip-types", "scripts/write-cli-startup-metadata.ts"], + }, + { cmd: nodeBin, args: ["--import", "tsx", "scripts/write-cli-compat.ts"] }, +]; + +for (const step of steps) { + const result = spawnSync(step.cmd, step.args, { + stdio: "inherit", + env: process.env, + }); + if (typeof result.status === "number") { + if (result.status !== 0) { + process.exit(result.status); + } + continue; + } + process.exit(1); +} diff --git a/scripts/e2e/parallels-macos-smoke.sh b/scripts/e2e/parallels-macos-smoke.sh index 7e3373603e1..c7233c79f00 100644 --- a/scripts/e2e/parallels-macos-smoke.sh +++ b/scripts/e2e/parallels-macos-smoke.sh @@ -666,7 +666,7 @@ run_logged_guest_current_user_sh() { local done_path="$3" local timeout_s="$4" local runner_path="$5" - local deadline rc runner_body write_runner_cmd line + local deadline rc runner_body write_runner_cmd guest_current_user_exec /bin/rm -f "$log_path" "$done_path" "$runner_path" runner_body="$(cat <> $(shell_quote "$runner_path")"$'\n' - done <<< "$runner_body" + write_runner_cmd+="cat > $(shell_quote "$runner_path") <<'__OPENCLAW_RUNNER__'"$'\n' + write_runner_cmd+="$runner_body"$'\n' + write_runner_cmd+="__OPENCLAW_RUNNER__"$'\n' write_runner_cmd+="/bin/chmod +x $(shell_quote "$runner_path")"$'\n' write_runner_cmd+="nohup /bin/bash $(shell_quote "$runner_path") > $(shell_quote "$log_path") 2>&1 < /dev/null &" guest_current_user_sh "$write_runner_cmd" @@ -785,7 +785,7 @@ repair_legacy_dev_source_checkout_if_needed() { } run_dev_channel_update() { - local bootstrap_bin update_entry update_root update_log update_done update_runner update_rc + local bootstrap_bin update_root update_log update_done update_runner update_rc bootstrap_bin="/tmp/openclaw-smoke-pnpm-bootstrap/node_modules/.bin" update_root="$(resolve_guest_current_user_home)/openclaw" update_log="/tmp/openclaw-smoke-update-dev.log" @@ -807,17 +807,15 @@ EOF guest_current_user_tail_file "$update_log" 120 >&2 || true fi repair_legacy_dev_source_checkout_if_needed - update_entry="$update_root/openclaw.mjs" printf 'update-dev: git-version\n' - guest_current_user_exec "$GUEST_NODE_BIN" "$update_entry" --version + guest_current_user_exec "$GUEST_NODE_BIN" "$GUEST_OPENCLAW_ENTRY" --version printf 'update-dev: git-status\n' - guest_current_user_exec "$GUEST_NODE_BIN" "$update_entry" update status --json + guest_current_user_exec "$GUEST_NODE_BIN" "$GUEST_OPENCLAW_ENTRY" update status --json } verify_dev_channel_update() { - local status_json update_entry - update_entry="$(resolve_guest_current_user_home)/openclaw/openclaw.mjs" - status_json="$(guest_current_user_exec "$GUEST_NODE_BIN" "$update_entry" update status --json)" + local status_json + status_json="$(guest_current_user_exec "$GUEST_NODE_BIN" "$GUEST_OPENCLAW_ENTRY" update status --json)" printf '%s\n' "$status_json" printf '%s\n' "$status_json" | grep -F '"installKind": "git"' printf '%s\n' "$status_json" | grep -F '"value": "dev"' diff --git a/scripts/e2e/parallels-windows-smoke.sh b/scripts/e2e/parallels-windows-smoke.sh index f0a6763c579..5276c810bfd 100644 --- a/scripts/e2e/parallels-windows-smoke.sh +++ b/scripts/e2e/parallels-windows-smoke.sh @@ -1585,7 +1585,7 @@ try { $bootstrapBin = Join-Path $bootstrapRoot 'node_modules\.bin' $env:PATH = "$bootstrapBin;$portableGit\cmd;$portableGit\mingw64\bin;$env:PATH" $env:ComSpec = Join-Path $env:SystemRoot 'System32\cmd.exe' - $env:npm_config_script_shell = $env:ComSpec + $env:npm_config_ignore_scripts = 'true' $openclaw = Join-Path $env:APPDATA 'npm\openclaw.cmd' $gitRoot = Join-Path $env:USERPROFILE 'openclaw' $gitEntry = Join-Path $gitRoot 'openclaw.mjs' @@ -1599,7 +1599,8 @@ try { $env:TEMP = $shortTemp $env:TMP = $shortTemp Write-LoggedLine ("TEMP=" + $env:TEMP) - Write-LoggedLine ("npm_config_script_shell=" + $env:npm_config_script_shell) + Write-LoggedLine ("ComSpec=" + $env:ComSpec) + Write-LoggedLine ("npm_config_ignore_scripts=" + $env:npm_config_ignore_scripts) Write-ProgressLog 'update.where-pnpm-pre' $pnpmPre = Get-Command pnpm -ErrorAction SilentlyContinue