mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-08 11:02:26 +00:00
fix(macos): prefer repo pnpm for packaging
This commit is contained in:
@@ -205,6 +205,68 @@ describe("package-mac-app plist stamping", () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it("prefers repo Corepack pnpm over a global pnpm shim", () => {
|
||||
const helperBlock = getPackageManagerHelperBlock();
|
||||
const tempRoot = mkdtempSync(path.join(tmpdir(), "openclaw-package-pnpm-root-"));
|
||||
const outerRoot = mkdtempSync(path.join(tmpdir(), "openclaw-package-pnpm-outer-"));
|
||||
const toolsDir = mkdtempSync(path.join(tmpdir(), "openclaw-package-pnpm-tools-"));
|
||||
const logPath = path.join(tempRoot, "pnpm.log");
|
||||
tempDirs.push(tempRoot, outerRoot, toolsDir);
|
||||
|
||||
writeFileSync(
|
||||
path.join(tempRoot, "package.json"),
|
||||
'{\n "packageManager": "pnpm@11.2.2+sha512.test"\n}\n',
|
||||
);
|
||||
writeFileSync(
|
||||
path.join(outerRoot, "package.json"),
|
||||
'{\n "packageManager": "pnpm@11.8.0+sha512.test"\n}\n',
|
||||
);
|
||||
writeFileSync(
|
||||
path.join(toolsDir, "pnpm"),
|
||||
[
|
||||
"#!/usr/bin/env bash",
|
||||
"set -euo pipefail",
|
||||
'printf "global|%s|%s\\n" "$PWD" "$*" >> "$OPENCLAW_TEST_LOG"',
|
||||
'if [[ "${1:-}" == "--version" ]]; then echo "11.8.0"; fi',
|
||||
"",
|
||||
].join("\n"),
|
||||
"utf8",
|
||||
);
|
||||
writeFileSync(
|
||||
path.join(toolsDir, "corepack"),
|
||||
[
|
||||
"#!/usr/bin/env bash",
|
||||
"set -euo pipefail",
|
||||
'printf "corepack|%s|%s\\n" "$PWD" "$*" >> "$OPENCLAW_TEST_LOG"',
|
||||
'if [[ "${1:-}" == "pnpm" && "${2:-}" == "--version" ]]; then',
|
||||
' if grep -q "pnpm@11.2.2" package.json 2>/dev/null; then echo "11.2.2"; else echo "11.8.0"; fi',
|
||||
"fi",
|
||||
"",
|
||||
].join("\n"),
|
||||
"utf8",
|
||||
);
|
||||
chmodSync(path.join(toolsDir, "pnpm"), 0o755);
|
||||
chmodSync(path.join(toolsDir, "corepack"), 0o755);
|
||||
|
||||
const result = runHelper(`
|
||||
set -euo pipefail
|
||||
ROOT_DIR=${JSON.stringify(tempRoot)}
|
||||
OPENCLAW_TEST_LOG=${JSON.stringify(logPath)}
|
||||
export OPENCLAW_TEST_LOG
|
||||
PATH=${JSON.stringify(`${toolsDir}:/usr/bin:/bin`)}
|
||||
cd ${JSON.stringify(outerRoot)}
|
||||
${helperBlock}
|
||||
run_pnpm --version
|
||||
`);
|
||||
|
||||
expect(result.status).toBe(0);
|
||||
expect(result.stdout).toBe("11.2.2\n");
|
||||
expect(readFileSync(logPath, "utf8").trim().split("\n")).toEqual([
|
||||
`corepack|${tempRoot}|pnpm --version`,
|
||||
`corepack|${tempRoot}|pnpm --version`,
|
||||
]);
|
||||
});
|
||||
|
||||
it("fails with an actionable error when neither pnpm nor corepack pnpm is available", () => {
|
||||
const helperBlock = getPackageManagerHelperBlock();
|
||||
const tempRoot = mkdtempSync(path.join(tmpdir(), "openclaw-package-pnpm-root-"));
|
||||
|
||||
@@ -37,6 +37,17 @@ function runHelper(script: string) {
|
||||
});
|
||||
}
|
||||
|
||||
function getPackageManagerHelperBlock(): string {
|
||||
const script = readFileSync(scriptPath, "utf8");
|
||||
const start = script.indexOf("DIST_PNPM_CMD=()");
|
||||
const end = script.indexOf("ensure_sparkle_build_deps()");
|
||||
|
||||
expect(start).toBeGreaterThanOrEqual(0);
|
||||
expect(end).toBeGreaterThan(start);
|
||||
|
||||
return script.slice(start, end);
|
||||
}
|
||||
|
||||
afterEach(() => {
|
||||
for (const dir of tempDirs.splice(0)) {
|
||||
rmSync(dir, { recursive: true, force: true });
|
||||
@@ -102,6 +113,68 @@ describe("package-mac-dist plist validation", () => {
|
||||
expect(script).not.toContain('canonical_sparkle_build "$VERSION" 2>/dev/null || true');
|
||||
});
|
||||
|
||||
it("prefers repo Corepack pnpm over a global pnpm shim", () => {
|
||||
const helperBlock = getPackageManagerHelperBlock();
|
||||
const tempRoot = mkdtempSync(path.join(tmpdir(), "openclaw-dist-pnpm-root-"));
|
||||
const outerRoot = mkdtempSync(path.join(tmpdir(), "openclaw-dist-pnpm-outer-"));
|
||||
const toolsDir = mkdtempSync(path.join(tmpdir(), "openclaw-dist-pnpm-tools-"));
|
||||
const logPath = path.join(tempRoot, "pnpm.log");
|
||||
tempDirs.push(tempRoot, outerRoot, toolsDir);
|
||||
|
||||
writeFileSync(
|
||||
path.join(tempRoot, "package.json"),
|
||||
'{\n "packageManager": "pnpm@11.2.2+sha512.test"\n}\n',
|
||||
);
|
||||
writeFileSync(
|
||||
path.join(outerRoot, "package.json"),
|
||||
'{\n "packageManager": "pnpm@11.8.0+sha512.test"\n}\n',
|
||||
);
|
||||
writeFileSync(
|
||||
path.join(toolsDir, "pnpm"),
|
||||
[
|
||||
"#!/usr/bin/env bash",
|
||||
"set -euo pipefail",
|
||||
'printf "global|%s|%s\\n" "$PWD" "$*" >> "$OPENCLAW_TEST_LOG"',
|
||||
'if [[ "${1:-}" == "--version" ]]; then echo "11.8.0"; fi',
|
||||
"",
|
||||
].join("\n"),
|
||||
"utf8",
|
||||
);
|
||||
writeFileSync(
|
||||
path.join(toolsDir, "corepack"),
|
||||
[
|
||||
"#!/usr/bin/env bash",
|
||||
"set -euo pipefail",
|
||||
'printf "corepack|%s|%s\\n" "$PWD" "$*" >> "$OPENCLAW_TEST_LOG"',
|
||||
'if [[ "${1:-}" == "pnpm" && "${2:-}" == "--version" ]]; then',
|
||||
' if grep -q "pnpm@11.2.2" package.json 2>/dev/null; then echo "11.2.2"; else echo "11.8.0"; fi',
|
||||
"fi",
|
||||
"",
|
||||
].join("\n"),
|
||||
"utf8",
|
||||
);
|
||||
chmodSync(path.join(toolsDir, "pnpm"), 0o755);
|
||||
chmodSync(path.join(toolsDir, "corepack"), 0o755);
|
||||
|
||||
const result = runHelper(`
|
||||
set -euo pipefail
|
||||
ROOT_DIR=${JSON.stringify(tempRoot)}
|
||||
OPENCLAW_TEST_LOG=${JSON.stringify(logPath)}
|
||||
export OPENCLAW_TEST_LOG
|
||||
PATH=${JSON.stringify(`${toolsDir}:/usr/bin:/bin`)}
|
||||
cd ${JSON.stringify(outerRoot)}
|
||||
${helperBlock}
|
||||
run_dist_pnpm --version
|
||||
`);
|
||||
|
||||
expect(result.status).toBe(0);
|
||||
expect(result.stdout).toBe("11.2.2\n");
|
||||
expect(readFileSync(logPath, "utf8").trim().split("\n")).toEqual([
|
||||
`corepack|${tempRoot}|pnpm --version`,
|
||||
`corepack|${tempRoot}|pnpm --version`,
|
||||
]);
|
||||
});
|
||||
|
||||
it("keeps dependency bootstrap output out of captured Sparkle build values", () => {
|
||||
const script = readFileSync(scriptPath, "utf8");
|
||||
const helpers = script.slice(
|
||||
|
||||
Reference in New Issue
Block a user