From ce31fc91e15d3ec6bc48700f12400d728a8ca808 Mon Sep 17 00:00:00 2001 From: Jason <263060202+fuller-stack-dev@users.noreply.github.com> Date: Wed, 13 May 2026 05:30:08 -0600 Subject: [PATCH] Allow pnpm source updates to build OpenClaw (#81294) Merged via squash. Prepared head SHA: 4815d5a8c9ac5917933296ca30f690a350cc4599 Co-authored-by: fuller-stack-dev <263060202+fuller-stack-dev@users.noreply.github.com> Co-authored-by: altaywtf <9790196+altaywtf@users.noreply.github.com> Reviewed-by: @altaywtf --- CHANGELOG.md | 1 + src/infra/update-global.test.ts | 32 ++++++++++++++++++++++++++++++++ src/infra/update-global.ts | 17 +++++++++++++++++ 3 files changed, 50 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d74d1d08d09..c22f2796233 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -69,6 +69,7 @@ Docs: https://docs.openclaw.ai - Agents: rewrite generic provider internal errors with support request IDs into user-friendly transient error copy. (#49401) Thanks @y471823206. - WhatsApp: finish handling pending debounced inbound messages before closing the socket. (#81246) Thanks @mcaxtr. - CLI/commitments: write `--json` output to stdout instead of diagnostic logs so automation can parse commitment list and dismiss results. (#81215) Thanks @giodl73-repo. +- Update: allow pnpm GitHub-source OpenClaw updates to approve the OpenClaw package build, so source installs complete their prepare/prepack lifecycle. (#81294) Thanks @fuller-stack-dev. ### Changes diff --git a/src/infra/update-global.test.ts b/src/infra/update-global.test.ts index 2c340baa12e..50213f8c499 100644 --- a/src/infra/update-global.test.ts +++ b/src/infra/update-global.test.ts @@ -570,6 +570,22 @@ describe("update global helpers", () => { "-g", "openclaw@latest", ]); + expect(globalInstallArgs("pnpm", "github:openclaw/openclaw#release/2026.5.12")).toEqual([ + "pnpm", + "add", + "-g", + "--allow-build=openclaw", + "github:openclaw/openclaw#release/2026.5.12", + ]); + expect( + globalInstallArgs("pnpm", "openclaw@git+https://github.com/openclaw/openclaw.git"), + ).toEqual([ + "pnpm", + "add", + "-g", + "--allow-build=openclaw", + "openclaw@git+https://github.com/openclaw/openclaw.git", + ]); expect(globalInstallArgs("bun", "openclaw@latest")).toEqual([ "bun", "add", @@ -599,6 +615,22 @@ describe("update global helpers", () => { "/opt/pnpm-global", "openclaw@latest", ]); + expect( + globalInstallArgs( + "pnpm", + "github:openclaw/openclaw#release/2026.5.12", + null, + "/opt/pnpm-global", + ), + ).toEqual([ + "pnpm", + "add", + "-g", + "--global-dir", + "/opt/pnpm-global", + "--allow-build=openclaw", + "github:openclaw/openclaw#release/2026.5.12", + ]); }); it("builds npm staged install argv with an explicit prefix", () => { diff --git a/src/infra/update-global.ts b/src/infra/update-global.ts index 3f54663c1c7..9e79c9152f2 100644 --- a/src/infra/update-global.ts +++ b/src/infra/update-global.ts @@ -46,6 +46,7 @@ const NPM_GLOBAL_INSTALL_OMIT_OPTIONAL_FLAGS = [ "--omit=optional", ...NPM_GLOBAL_INSTALL_QUIET_FLAGS, ] as const; +const PNPM_OPENCLAW_BUILD_ALLOWLIST_FLAG = `--allow-build=${PRIMARY_PACKAGE_NAME}`; const FIRST_PACKAGED_DIST_INVENTORY_VERSION = { major: 2026, minor: 4, patch: 15 }; const OMITTED_PRIVATE_QA_BUNDLED_PLUGIN_ROOTS = new Set([ "dist/extensions/qa-channel", @@ -87,6 +88,21 @@ export function isExplicitPackageInstallSpec(value: string): boolean { ); } +function stripPrimaryPackageAlias(spec: string): string { + const normalized = normalizePackageTarget(spec); + const prefix = `${PRIMARY_PACKAGE_NAME}@`; + return normalized.startsWith(prefix) ? normalized.slice(prefix.length).trim() : normalized; +} + +function isPnpmOpenClawSourceInstallSpec(spec: string): boolean { + const target = stripPrimaryPackageAlias(spec); + return ( + /^github:/i.test(target) || + /^git\+(?:ssh|https|http|file):/i.test(target) || + /^git:/i.test(target) + ); +} + export function resolveExpectedInstalledVersionFromSpec( packageName: string, spec: string, @@ -715,6 +731,7 @@ export function globalInstallArgs( "add", "-g", ...(installPrefix ? ["--global-dir", installPrefix] : []), + ...(isPnpmOpenClawSourceInstallSpec(spec) ? [PNPM_OPENCLAW_BUILD_ALLOWLIST_FLAG] : []), spec, ]; }