mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 05:51:24 +00:00
refactor(commands): share configure wizard channel/daemon steps
This commit is contained in:
@@ -345,6 +345,33 @@ export async function runConfigureWizard(
|
|||||||
await ensureWorkspaceAndSessions(workspaceDir, runtime);
|
await ensureWorkspaceAndSessions(workspaceDir, runtime);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const configureChannelsSection = async () => {
|
||||||
|
await noteChannelStatus({ cfg: nextConfig, prompter });
|
||||||
|
const channelMode = await promptChannelMode(runtime);
|
||||||
|
if (channelMode === "configure") {
|
||||||
|
nextConfig = await setupChannels(nextConfig, runtime, prompter, {
|
||||||
|
allowDisable: true,
|
||||||
|
allowSignalInstall: true,
|
||||||
|
skipConfirm: true,
|
||||||
|
skipStatusNote: true,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
nextConfig = await removeChannelConfigWizard(nextConfig, runtime);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const promptDaemonPort = async () => {
|
||||||
|
const portInput = guardCancel(
|
||||||
|
await text({
|
||||||
|
message: "Gateway port for service install",
|
||||||
|
initialValue: String(gatewayPort),
|
||||||
|
validate: (value) => (Number.isFinite(Number(value)) ? undefined : "Invalid port"),
|
||||||
|
}),
|
||||||
|
runtime,
|
||||||
|
);
|
||||||
|
gatewayPort = Number.parseInt(String(portInput), 10);
|
||||||
|
};
|
||||||
|
|
||||||
if (opts.sections) {
|
if (opts.sections) {
|
||||||
const selected = opts.sections;
|
const selected = opts.sections;
|
||||||
if (!selected || selected.length === 0) {
|
if (!selected || selected.length === 0) {
|
||||||
@@ -372,18 +399,7 @@ export async function runConfigureWizard(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (selected.includes("channels")) {
|
if (selected.includes("channels")) {
|
||||||
await noteChannelStatus({ cfg: nextConfig, prompter });
|
await configureChannelsSection();
|
||||||
const channelMode = await promptChannelMode(runtime);
|
|
||||||
if (channelMode === "configure") {
|
|
||||||
nextConfig = await setupChannels(nextConfig, runtime, prompter, {
|
|
||||||
allowDisable: true,
|
|
||||||
allowSignalInstall: true,
|
|
||||||
skipConfirm: true,
|
|
||||||
skipStatusNote: true,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
nextConfig = await removeChannelConfigWizard(nextConfig, runtime);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selected.includes("skills")) {
|
if (selected.includes("skills")) {
|
||||||
@@ -395,15 +411,7 @@ export async function runConfigureWizard(
|
|||||||
|
|
||||||
if (selected.includes("daemon")) {
|
if (selected.includes("daemon")) {
|
||||||
if (!selected.includes("gateway")) {
|
if (!selected.includes("gateway")) {
|
||||||
const portInput = guardCancel(
|
await promptDaemonPort();
|
||||||
await text({
|
|
||||||
message: "Gateway port for service install",
|
|
||||||
initialValue: String(gatewayPort),
|
|
||||||
validate: (value) => (Number.isFinite(Number(value)) ? undefined : "Invalid port"),
|
|
||||||
}),
|
|
||||||
runtime,
|
|
||||||
);
|
|
||||||
gatewayPort = Number.parseInt(String(portInput), 10);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await maybeInstallDaemon({ runtime, port: gatewayPort, gatewayToken });
|
await maybeInstallDaemon({ runtime, port: gatewayPort, gatewayToken });
|
||||||
@@ -448,18 +456,7 @@ export async function runConfigureWizard(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (choice === "channels") {
|
if (choice === "channels") {
|
||||||
await noteChannelStatus({ cfg: nextConfig, prompter });
|
await configureChannelsSection();
|
||||||
const channelMode = await promptChannelMode(runtime);
|
|
||||||
if (channelMode === "configure") {
|
|
||||||
nextConfig = await setupChannels(nextConfig, runtime, prompter, {
|
|
||||||
allowDisable: true,
|
|
||||||
allowSignalInstall: true,
|
|
||||||
skipConfirm: true,
|
|
||||||
skipStatusNote: true,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
nextConfig = await removeChannelConfigWizard(nextConfig, runtime);
|
|
||||||
}
|
|
||||||
await persistConfig();
|
await persistConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -471,15 +468,7 @@ export async function runConfigureWizard(
|
|||||||
|
|
||||||
if (choice === "daemon") {
|
if (choice === "daemon") {
|
||||||
if (!didConfigureGateway) {
|
if (!didConfigureGateway) {
|
||||||
const portInput = guardCancel(
|
await promptDaemonPort();
|
||||||
await text({
|
|
||||||
message: "Gateway port for service install",
|
|
||||||
initialValue: String(gatewayPort),
|
|
||||||
validate: (value) => (Number.isFinite(Number(value)) ? undefined : "Invalid port"),
|
|
||||||
}),
|
|
||||||
runtime,
|
|
||||||
);
|
|
||||||
gatewayPort = Number.parseInt(String(portInput), 10);
|
|
||||||
}
|
}
|
||||||
await maybeInstallDaemon({
|
await maybeInstallDaemon({
|
||||||
runtime,
|
runtime,
|
||||||
|
|||||||
Reference in New Issue
Block a user