fix(update): reject openclaw source package targets

This commit is contained in:
Vincent Koc
2026-05-22 07:20:49 +08:00
parent fad1c8a071
commit 15a0156a8c
19 changed files with 254 additions and 36 deletions

View File

@@ -96,4 +96,17 @@ describe("install-cli.sh", () => {
expect(script).toContain('freshness_flag="--before=$(date -u');
expect(script).toContain("env -u NPM_CONFIG_BEFORE -u npm_config_before");
});
it("rejects OpenClaw GitHub source targets for npm installs", () => {
const result = runInstallCliShell(`
set -euo pipefail
source "${SCRIPT_PATH}"
OPENCLAW_VERSION=main
install_openclaw
`);
expect(result.status).toBe(1);
expect(result.stdout).toContain("npm installs do not support OpenClaw GitHub source targets");
expect(result.stdout).toContain("--install-method git --version main");
});
});

View File

@@ -104,6 +104,16 @@ describe("install.ps1 failure handling", () => {
);
});
it("rejects OpenClaw GitHub source targets for npm installs", () => {
const npmInstallBody = extractFunctionBody(source, "Install-OpenClaw");
const sourceTargetBody = extractFunctionBody(source, "Test-OpenClawSourcePackageInstallSpec");
expect(sourceTargetBody).toContain('$normalizedTag -eq "main"');
expect(sourceTargetBody).toContain("^github:openclaw/openclaw");
expect(npmInstallBody).toContain("Test-OpenClawSourcePackageInstallSpec -RequestedTag $Tag");
expect(npmInstallBody).toContain("npm installs do not support OpenClaw GitHub source targets");
expect(npmInstallBody).toContain("-InstallMethod git -Tag main");
});
it("cleans legacy git submodules only from the selected git checkout", () => {
const gitInstallBody = extractFunctionBody(source, "Install-OpenClawFromGit");
const mainBody = extractFunctionBody(source, "Main");

View File

@@ -41,6 +41,24 @@ describe("install.sh", () => {
expect(script).toContain('cmd+=(--no-fund --no-audit "$freshness_flag" install -g "$spec")');
});
it("rejects OpenClaw GitHub source targets for npm installs", () => {
const result = runInstallShell(`
set -euo pipefail
source "${SCRIPT_PATH}"
set +e
OPENCLAW_VERSION=main
USE_BETA=0
install_openclaw
status=$?
printf 'status=%s\\n' "$status"
`);
expect(result.status).toBe(0);
expect(result.stdout).toContain("status=1");
expect(result.stdout).toContain("npm installs do not support OpenClaw GitHub source targets");
expect(result.stdout).toContain("--install-method git --version main");
});
it("exports noninteractive apt env during Linux startup", () => {
expect(script).toMatch(
/detect_os_or_die\s+if \[\[ "\$OS" == "linux" \]\]; then\s+export DEBIAN_FRONTEND="\$\{DEBIAN_FRONTEND:-noninteractive\}"\s+export NEEDRESTART_MODE="\$\{NEEDRESTART_MODE:-a\}"\s+fi/m,