





















@@ -10,6 +10,10 @@ import { describe, expect, it } from "vitest";
1010const execFileAsync = promisify(execFile);
1111const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
121213+async function writeExecutable(file: string, content: string) {
14+await writeFile(file, content, { mode: 0o755 });
15+}
16+1317describe("scripts/clawdock/clawdock-helpers.sh", () => {
1418it("loads the standard docker-compose.override.yml before ClawDock extra overrides", async () => {
1519const tempDir = await mkdtemp(path.join(tmpdir(), "openclaw-clawdock-"));
@@ -22,12 +26,11 @@ describe("scripts/clawdock/clawdock-helpers.sh", () => {
2226await writeFile(path.join(projectDir, "docker-compose.yml"), "services: {}\n");
2327await writeFile(path.join(projectDir, "docker-compose.override.yml"), "services: {}\n");
2428await writeFile(path.join(projectDir, "docker-compose.extra.yml"), "services: {}\n");
25-await writeFile(
29+await writeExecutable(
2630path.join(binDir, "docker"),
2731`#!/usr/bin/env bash
2832printf '%s\\n' "$@" > "$CLAWDOCK_DOCKER_ARGS_FILE"
2933`,
30-{ mode: 0o755 },
3134);
32353336await execFileAsync(
@@ -62,4 +65,79 @@ printf '%s\\n' "$@" > "$CLAWDOCK_DOCKER_ARGS_FILE"
6265await rm(tempDir, { force: true, recursive: true });
6366}
6467});
68+69+it("opens dashboard URLs through the published gateway port without starting dependencies", async () => {
70+const tempDir = await mkdtemp(path.join(tmpdir(), "openclaw-clawdock-"));
71+try {
72+const projectDir = path.join(tempDir, "project");
73+const binDir = path.join(tempDir, "bin");
74+const argsFile = path.join(tempDir, "docker-args.txt");
75+const openedUrlFile = path.join(tempDir, "opened-url.txt");
76+await mkdir(projectDir);
77+await mkdir(binDir);
78+await writeFile(path.join(projectDir, "docker-compose.yml"), "services: {}\n");
79+await writeExecutable(
80+path.join(binDir, "docker"),
81+`#!/usr/bin/env bash
82+printf '%s\\n' "$@" >> "$CLAWDOCK_DOCKER_ARGS_FILE"
83+printf '%s\\n' '---' >> "$CLAWDOCK_DOCKER_ARGS_FILE"
84+if [[ "$*" == *" port openclaw-gateway 18789" ]]; then
85+ printf '%s\\n' '0.0.0.0:19001'
86+else
87+ printf '%s\\n' 'Dashboard: http://127.0.0.1:18789/?token=test-token'
88+fi
89+`,
90+);
91+await writeExecutable(
92+path.join(binDir, "open"),
93+`#!/usr/bin/env bash
94+printf '%s\\n' "$1" > "$CLAWDOCK_OPENED_URL_FILE"
95+`,
96+);
97+98+await execFileAsync(
99+"bash",
100+["-c", "source scripts/clawdock/clawdock-helpers.sh; clawdock-dashboard"],
101+{
102+cwd: repoRoot,
103+env: {
104+ ...process.env,
105+CLAWDOCK_DIR: projectDir,
106+CLAWDOCK_DOCKER_ARGS_FILE: argsFile,
107+CLAWDOCK_OPENED_URL_FILE: openedUrlFile,
108+HOME: path.join(tempDir, "home"),
109+PATH: `${binDir}${path.delimiter}${process.env.PATH ?? ""}`,
110+},
111+},
112+);
113+114+await expect(readFile(openedUrlFile, "utf8")).resolves.toBe(
115+"http://127.0.0.1:19001/?token=test-token\n",
116+);
117+await expect(readFile(argsFile, "utf8")).resolves.toBe(
118+[
119+"compose",
120+"-f",
121+path.join(projectDir, "docker-compose.yml"),
122+"run",
123+"--rm",
124+"--no-deps",
125+"openclaw-cli",
126+"dashboard",
127+"--no-open",
128+"---",
129+"compose",
130+"-f",
131+path.join(projectDir, "docker-compose.yml"),
132+"port",
133+"openclaw-gateway",
134+"18789",
135+"---",
136+"",
137+].join("\n"),
138+);
139+} finally {
140+await rm(tempDir, { force: true, recursive: true });
141+}
142+});
65143});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。