
























@@ -614,11 +614,107 @@ describe("runGatewayUpdate", () => {
614614expect(calls.some((call) => call.startsWith("npm install --prefix "))).toBe(true);
615615expect(calls).toContain("pnpm install");
616616expect(calls).toContain("pnpm build");
617-expect(calls).toContain("pnpm lint");
617+expect(calls).not.toContain("pnpm lint");
618618expect(calls).toContain("pnpm ui:build");
619619expect(pnpmEnvPaths.some((value) => value.includes("openclaw-update-pnpm-"))).toBe(true);
620620});
621621622+it("runs dev preflight lint in constrained mode when explicitly enabled", async () => {
623+await setupGitPackageManagerFixture();
624+const calls: string[] = [];
625+const lintEnv: NodeJS.ProcessEnv[] = [];
626+const upstreamSha = "upstream123";
627+const doctorNodePath = await resolveStableNodePath(process.execPath);
628+const doctorCommand = `${doctorNodePath} ${path.join(tempDir, "openclaw.mjs")} doctor --non-interactive --fix`;
629+630+const runCommand = async (
631+argv: string[],
632+options?: { env?: NodeJS.ProcessEnv; cwd?: string; timeoutMs?: number },
633+) => {
634+const key = argv.join(" ");
635+calls.push(key);
636+637+if (key === `git -C ${tempDir} rev-parse --show-toplevel`) {
638+return { stdout: tempDir, stderr: "", code: 0 };
639+}
640+if (key === `git -C ${tempDir} rev-parse HEAD`) {
641+return { stdout: "abc123", stderr: "", code: 0 };
642+}
643+if (key === `git -C ${tempDir} rev-parse --abbrev-ref HEAD`) {
644+return { stdout: "main", stderr: "", code: 0 };
645+}
646+if (key === `git -C ${tempDir} status --porcelain -- :!dist/control-ui/`) {
647+return { stdout: "", stderr: "", code: 0 };
648+}
649+if (key === `git -C ${tempDir} rev-parse --abbrev-ref --symbolic-full-name @{upstream}`) {
650+return { stdout: "origin/main", stderr: "", code: 0 };
651+}
652+if (key === `git -C ${tempDir} fetch --all --prune --tags`) {
653+return { stdout: "", stderr: "", code: 0 };
654+}
655+if (key === `git -C ${tempDir} rev-parse @{upstream}`) {
656+return { stdout: upstreamSha, stderr: "", code: 0 };
657+}
658+if (key === `git -C ${tempDir} rev-list --max-count=10 ${upstreamSha}`) {
659+return { stdout: `${upstreamSha}\n`, stderr: "", code: 0 };
660+}
661+if (key === "pnpm --version") {
662+return { stdout: "10.0.0", stderr: "", code: 0 };
663+}
664+if (
665+key.startsWith(`git -C ${tempDir} worktree add --detach /tmp/`) &&
666+key.endsWith(` ${upstreamSha}`) &&
667+preflightPrefixPattern.test(key)
668+) {
669+return { stdout: `HEAD is now at ${upstreamSha}`, stderr: "", code: 0 };
670+}
671+if (
672+key.startsWith("git -C /tmp/") &&
673+preflightPrefixPattern.test(key) &&
674+key.includes(" checkout --detach ") &&
675+key.endsWith(upstreamSha)
676+) {
677+return { stdout: "", stderr: "", code: 0 };
678+}
679+if (key === "pnpm install" || key === "pnpm build" || key === "pnpm ui:build") {
680+return { stdout: "", stderr: "", code: 0 };
681+}
682+if (key === "pnpm lint") {
683+lintEnv.push(options?.env ?? {});
684+return { stdout: "", stderr: "", code: 0 };
685+}
686+if (
687+key.startsWith(`git -C ${tempDir} worktree remove --force /tmp/`) &&
688+preflightPrefixPattern.test(key)
689+) {
690+return { stdout: "", stderr: "", code: 0 };
691+}
692+if (key === `git -C ${tempDir} worktree prune`) {
693+return { stdout: "", stderr: "", code: 0 };
694+}
695+if (key === `git -C ${tempDir} rebase ${upstreamSha}`) {
696+return { stdout: "", stderr: "", code: 0 };
697+}
698+if (key === doctorCommand) {
699+return { stdout: "", stderr: "", code: 0 };
700+}
701+return { stdout: "", stderr: "", code: 0 };
702+};
703+704+const result = await withEnvAsync({ OPENCLAW_UPDATE_PREFLIGHT_LINT: "1" }, async () =>
705+runWithCommand(runCommand, { channel: "dev" }),
706+);
707+708+expect(result.status).toBe("ok");
709+expect(calls).toContain("pnpm lint");
710+expect(lintEnv).toHaveLength(1);
711+expect(lintEnv[0]).toMatchObject({
712+OPENCLAW_LOCAL_CHECK: "1",
713+OPENCLAW_LOCAL_CHECK_MODE: "throttled",
714+OPENCLAW_OXLINT_SHARDS_SERIAL: "1",
715+});
716+});
717+622718it("retries windows pnpm git installs with --ignore-scripts for dev updates", async () => {
623719await setupGitPackageManagerFixture();
624720const calls: string[] = [];
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。