Compare commits
3 Commits
fix/2692-w
...
fix/4855-c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1f875b48dd | ||
|
|
ba8cc81d05 | ||
|
|
ed68163cf4 |
@@ -74,6 +74,7 @@ Status: stable.
|
||||
- **BREAKING:** Gateway auth mode "none" is removed; gateway now requires token/password (Tailscale Serve identity still allowed).
|
||||
|
||||
### Fixes
|
||||
- Infra: resolve Control UI assets for npm global installs. (#4909) Thanks @YuriNachos.
|
||||
- Gateway: prevent blank token prompts from storing "undefined". (#4873) Thanks @Hisleren.
|
||||
- Telegram: use undici fetch for per-account proxy dispatcher. (#4456) Thanks @spiceoogway.
|
||||
- Telegram: fix HTML nesting for overlapping styles and links. (#4578) Thanks @ThanhNguyxn.
|
||||
|
||||
@@ -37,11 +37,46 @@ describe("control UI assets helpers", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("resolves dist control-ui index path for dist argv1", () => {
|
||||
it("resolves dist control-ui index path for dist argv1", async () => {
|
||||
const argv1 = path.resolve("/tmp", "pkg", "dist", "index.js");
|
||||
const distDir = path.dirname(argv1);
|
||||
expect(resolveControlUiDistIndexPath(argv1)).toBe(
|
||||
expect(await resolveControlUiDistIndexPath(argv1)).toBe(
|
||||
path.join(distDir, "control-ui", "index.html"),
|
||||
);
|
||||
});
|
||||
|
||||
it("resolves dist control-ui index path from package root argv1", async () => {
|
||||
const tmp = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-ui-"));
|
||||
try {
|
||||
await fs.writeFile(path.join(tmp, "package.json"), JSON.stringify({ name: "openclaw" }));
|
||||
await fs.writeFile(path.join(tmp, "openclaw.mjs"), "export {};\n");
|
||||
await fs.mkdir(path.join(tmp, "dist", "control-ui"), { recursive: true });
|
||||
await fs.writeFile(path.join(tmp, "dist", "control-ui", "index.html"), "<html></html>\n");
|
||||
|
||||
expect(await resolveControlUiDistIndexPath(path.join(tmp, "openclaw.mjs"))).toBe(
|
||||
path.join(tmp, "dist", "control-ui", "index.html"),
|
||||
);
|
||||
} finally {
|
||||
await fs.rm(tmp, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
it("resolves dist control-ui index path from .bin argv1", async () => {
|
||||
const tmp = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-ui-"));
|
||||
try {
|
||||
const binDir = path.join(tmp, "node_modules", ".bin");
|
||||
const pkgRoot = path.join(tmp, "node_modules", "openclaw");
|
||||
await fs.mkdir(binDir, { recursive: true });
|
||||
await fs.mkdir(path.join(pkgRoot, "dist", "control-ui"), { recursive: true });
|
||||
await fs.writeFile(path.join(binDir, "openclaw"), "#!/usr/bin/env node\n");
|
||||
await fs.writeFile(path.join(pkgRoot, "package.json"), JSON.stringify({ name: "openclaw" }));
|
||||
await fs.writeFile(path.join(pkgRoot, "dist", "control-ui", "index.html"), "<html></html>\n");
|
||||
|
||||
expect(await resolveControlUiDistIndexPath(path.join(binDir, "openclaw"))).toBe(
|
||||
path.join(pkgRoot, "dist", "control-ui", "index.html"),
|
||||
);
|
||||
} finally {
|
||||
await fs.rm(tmp, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,6 +3,7 @@ import path from "node:path";
|
||||
|
||||
import { runCommandWithTimeout } from "../process/exec.js";
|
||||
import { defaultRuntime, type RuntimeEnv } from "../runtime.js";
|
||||
import { resolveOpenClawPackageRoot } from "./openclaw-root.js";
|
||||
|
||||
export function resolveControlUiRepoRoot(
|
||||
argv1: string | undefined = process.argv[1],
|
||||
@@ -32,14 +33,21 @@ export function resolveControlUiRepoRoot(
|
||||
return null;
|
||||
}
|
||||
|
||||
export function resolveControlUiDistIndexPath(
|
||||
export async function resolveControlUiDistIndexPath(
|
||||
argv1: string | undefined = process.argv[1],
|
||||
): string | null {
|
||||
): Promise<string | null> {
|
||||
if (!argv1) return null;
|
||||
const normalized = path.resolve(argv1);
|
||||
|
||||
// Case 1: entrypoint is directly inside dist/ (e.g., dist/entry.js)
|
||||
const distDir = path.dirname(normalized);
|
||||
if (path.basename(distDir) !== "dist") return null;
|
||||
return path.join(distDir, "control-ui", "index.html");
|
||||
if (path.basename(distDir) === "dist") {
|
||||
return path.join(distDir, "control-ui", "index.html");
|
||||
}
|
||||
|
||||
const packageRoot = await resolveOpenClawPackageRoot({ argv1: normalized });
|
||||
if (!packageRoot) return null;
|
||||
return path.join(packageRoot, "dist", "control-ui", "index.html");
|
||||
}
|
||||
|
||||
export type EnsureControlUiAssetsResult = {
|
||||
@@ -63,7 +71,7 @@ export async function ensureControlUiAssetsBuilt(
|
||||
runtime: RuntimeEnv = defaultRuntime,
|
||||
opts?: { timeoutMs?: number },
|
||||
): Promise<EnsureControlUiAssetsResult> {
|
||||
const indexFromDist = resolveControlUiDistIndexPath(process.argv[1]);
|
||||
const indexFromDist = await resolveControlUiDistIndexPath(process.argv[1]);
|
||||
if (indexFromDist && fs.existsSync(indexFromDist)) {
|
||||
return { ok: true, built: false };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user