mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-23 02:45:38 -06:00
fix(e2e): use packaged CLI in git fixtures (#126383)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user