Skip to content

Commit ee6cab4

Browse files
authored
fix(e2e): use packaged CLI in git fixtures (#126383)
1 parent 42a4db5 commit ee6cab4

2 files changed

Lines changed: 48 additions & 0 deletions

File tree

‎scripts/e2e/lib/package-git-fixture.mjs‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,14 @@ function prepare(root) {
4343
ensureDependencyIgnores(root);
4444
const packageJsonPath = path.join(root, "package.json");
4545
const packageJson = readJson(packageJsonPath);
46+
packageJson.scripts = {
47+
...packageJson.scripts,
48+
openclaw: "node openclaw.mjs",
49+
};
4650
const aiRuntimeSource = path.join(root, "node_modules", "@openclaw", "ai");
4751
const aiRuntimePackageJson = path.join(aiRuntimeSource, "package.json");
4852
if (!fs.existsSync(aiRuntimePackageJson)) {
53+
writeJson(packageJsonPath, packageJson);
4954
return;
5055
}
5156

‎test/scripts/package-git-fixture.test.ts‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ describe("package git fixture", () => {
1818
{
1919
dependencies: { "@openclaw/ai": "2026.6.11", chalk: "5.6.2" },
2020
bundleDependencies: ["@openclaw/ai", "chalk"],
21+
scripts: {
22+
build: "node build.mjs",
23+
openclaw: "node scripts/run-node.mjs",
24+
},
2125
},
2226
null,
2327
2,
@@ -48,6 +52,10 @@ describe("package git fixture", () => {
4852
const packageJson = JSON.parse(readFileSync(path.join(root, "package.json"), "utf8"));
4953
expect(packageJson.dependencies["@openclaw/ai"]).toBe("file:.openclaw-fixture/packages/ai");
5054
expect(packageJson.bundleDependencies).toEqual(["chalk"]);
55+
expect(packageJson.scripts).toEqual({
56+
build: "node build.mjs",
57+
openclaw: "node openclaw.mjs",
58+
});
5159
const relocatedAiPackage = JSON.parse(
5260
readFileSync(path.join(root, ".openclaw-fixture", "packages", "ai", "package.json"), "utf8"),
5361
);
@@ -79,4 +87,39 @@ describe("package git fixture", () => {
7987
expect(staged.stdout).not.toContain("node_modules");
8088
expect(staged.stdout).not.toContain("pnpm-lock.yaml");
8189
});
90+
91+
it("uses the packed entrypoint without a bundled ai runtime", () => {
92+
const root = tempDirs.make("openclaw-package-git-fixture-no-ai-");
93+
writeFileSync(
94+
path.join(root, "package.json"),
95+
`${JSON.stringify(
96+
{
97+
dependencies: { chalk: "5.6.2" },
98+
scripts: {
99+
lint: "node lint.mjs",
100+
openclaw: "node scripts/run-node.mjs",
101+
},
102+
},
103+
null,
104+
2,
105+
)}\n`,
106+
);
107+
108+
const result = spawnSync(
109+
process.execPath,
110+
["scripts/e2e/lib/package-git-fixture.mjs", "prepare", root],
111+
{ cwd: process.cwd(), encoding: "utf8" },
112+
);
113+
114+
expect(result.status, `${result.stdout}\n${result.stderr}`).toBe(0);
115+
const packageJson = JSON.parse(readFileSync(path.join(root, "package.json"), "utf8"));
116+
expect(packageJson).toMatchObject({
117+
dependencies: { chalk: "5.6.2" },
118+
scripts: {
119+
lint: "node lint.mjs",
120+
openclaw: "node openclaw.mjs",
121+
},
122+
});
123+
expect(packageJson.dependencies).not.toHaveProperty("@openclaw/ai");
124+
});
82125
});

0 commit comments

Comments
 (0)