mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 09:50:42 +00:00
fix: route remote mac browser through node host
This commit is contained in:
45
src/cli/node-cli/register.test.ts
Normal file
45
src/cli/node-cli/register.test.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import { Command } from "commander";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { registerNodeCli } from "./register.js";
|
||||
|
||||
const daemonMocks = vi.hoisted(() => ({
|
||||
runNodeDaemonInstall: vi.fn(),
|
||||
runNodeDaemonRestart: vi.fn(),
|
||||
runNodeDaemonStart: vi.fn(),
|
||||
runNodeDaemonStatus: vi.fn(),
|
||||
runNodeDaemonStop: vi.fn(),
|
||||
runNodeDaemonUninstall: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock("./daemon.js", () => daemonMocks);
|
||||
|
||||
vi.mock("../../node-host/config.js", () => ({
|
||||
loadNodeHostConfig: vi.fn(async () => null),
|
||||
}));
|
||||
|
||||
vi.mock("../../node-host/runner.js", () => ({
|
||||
runNodeHost: vi.fn(),
|
||||
}));
|
||||
|
||||
function createProgram(): Command {
|
||||
const program = new Command();
|
||||
program.exitOverride();
|
||||
program.configureOutput({
|
||||
writeErr: () => undefined,
|
||||
writeOut: () => undefined,
|
||||
});
|
||||
registerNodeCli(program);
|
||||
return program;
|
||||
}
|
||||
|
||||
describe("registerNodeCli", () => {
|
||||
it("registers node start for the macOS app node service manager", async () => {
|
||||
const program = createProgram();
|
||||
|
||||
await program.parseAsync(["node", "start", "--json"], { from: "user" });
|
||||
|
||||
expect(daemonMocks.runNodeDaemonStart).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ json: true }),
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -9,6 +9,7 @@ import { formatHelpExamples } from "../help-format.js";
|
||||
import {
|
||||
runNodeDaemonInstall,
|
||||
runNodeDaemonRestart,
|
||||
runNodeDaemonStart,
|
||||
runNodeDaemonStatus,
|
||||
runNodeDaemonStop,
|
||||
runNodeDaemonUninstall,
|
||||
@@ -33,6 +34,7 @@ export function registerNodeCli(program: Command) {
|
||||
],
|
||||
["openclaw node status", "Check node host service status."],
|
||||
["openclaw node install", "Install the node host service."],
|
||||
["openclaw node start", "Start the installed node host service."],
|
||||
["openclaw node restart", "Restart the installed node host service."],
|
||||
])}\n\n${theme.muted("Docs:")} ${formatDocsLink("/cli/node", "docs.openclaw.ai/cli/node")}\n`,
|
||||
);
|
||||
@@ -103,6 +105,14 @@ export function registerNodeCli(program: Command) {
|
||||
await runNodeDaemonStop(opts);
|
||||
});
|
||||
|
||||
node
|
||||
.command("start")
|
||||
.description("Start the node host service (launchd/systemd/schtasks)")
|
||||
.option("--json", "Output JSON", false)
|
||||
.action(async (opts) => {
|
||||
await runNodeDaemonStart(opts);
|
||||
});
|
||||
|
||||
node
|
||||
.command("restart")
|
||||
.description("Restart the node host service (launchd/systemd/schtasks)")
|
||||
|
||||
Reference in New Issue
Block a user