From ee6cab4a2e4ed92f55b3afceb56cd70179acbeee Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Thu, 20 Aug 2026 05:00:25 +0800 Subject: [PATCH] fix(e2e): use packaged CLI in git fixtures (#126383) --- scripts/e2e/lib/package-git-fixture.mjs | 5 +++ test/scripts/package-git-fixture.test.ts | 43 ++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/scripts/e2e/lib/package-git-fixture.mjs b/scripts/e2e/lib/package-git-fixture.mjs index bb87cf387e78..09845666df8f 100644 --- a/scripts/e2e/lib/package-git-fixture.mjs +++ b/scripts/e2e/lib/package-git-fixture.mjs @@ -43,9 +43,14 @@ function prepare(root) { ensureDependencyIgnores(root); const packageJsonPath = path.join(root, "package.json"); const packageJson = readJson(packageJsonPath); + packageJson.scripts = { + ...packageJson.scripts, + openclaw: "node openclaw.mjs", + }; const aiRuntimeSource = path.join(root, "node_modules", "@openclaw", "ai"); const aiRuntimePackageJson = path.join(aiRuntimeSource, "package.json"); if (!fs.existsSync(aiRuntimePackageJson)) { + writeJson(packageJsonPath, packageJson); return; } diff --git a/test/scripts/package-git-fixture.test.ts b/test/scripts/package-git-fixture.test.ts index 5e5208108e50..1902b3f1512b 100644 --- a/test/scripts/package-git-fixture.test.ts +++ b/test/scripts/package-git-fixture.test.ts @@ -18,6 +18,10 @@ describe("package git fixture", () => { { dependencies: { "@openclaw/ai": "2026.6.11", chalk: "5.6.2" }, bundleDependencies: ["@openclaw/ai", "chalk"], + scripts: { + build: "node build.mjs", + openclaw: "node scripts/run-node.mjs", + }, }, null, 2, @@ -48,6 +52,10 @@ describe("package git fixture", () => { const packageJson = JSON.parse(readFileSync(path.join(root, "package.json"), "utf8")); expect(packageJson.dependencies["@openclaw/ai"]).toBe("file:.openclaw-fixture/packages/ai"); expect(packageJson.bundleDependencies).toEqual(["chalk"]); + expect(packageJson.scripts).toEqual({ + build: "node build.mjs", + openclaw: "node openclaw.mjs", + }); const relocatedAiPackage = JSON.parse( readFileSync(path.join(root, ".openclaw-fixture", "packages", "ai", "package.json"), "utf8"), ); @@ -79,4 +87,39 @@ describe("package git fixture", () => { expect(staged.stdout).not.toContain("node_modules"); expect(staged.stdout).not.toContain("pnpm-lock.yaml"); }); + + it("uses the packed entrypoint without a bundled ai runtime", () => { + const root = tempDirs.make("openclaw-package-git-fixture-no-ai-"); + writeFileSync( + path.join(root, "package.json"), + `${JSON.stringify( + { + dependencies: { chalk: "5.6.2" }, + scripts: { + lint: "node lint.mjs", + openclaw: "node scripts/run-node.mjs", + }, + }, + null, + 2, + )}\n`, + ); + + const result = spawnSync( + process.execPath, + ["scripts/e2e/lib/package-git-fixture.mjs", "prepare", root], + { cwd: process.cwd(), encoding: "utf8" }, + ); + + expect(result.status, `${result.stdout}\n${result.stderr}`).toBe(0); + const packageJson = JSON.parse(readFileSync(path.join(root, "package.json"), "utf8")); + expect(packageJson).toMatchObject({ + dependencies: { chalk: "5.6.2" }, + scripts: { + lint: "node lint.mjs", + openclaw: "node openclaw.mjs", + }, + }); + expect(packageJson.dependencies).not.toHaveProperty("@openclaw/ai"); + }); });