refactor(commands): share configure wizard channel/daemon steps

This commit is contained in:
Peter Steinberger
2026-02-18 18:37:17 +00:00
parent 079bf25fee
commit 4c096020a2

View File

@@ -345,6 +345,33 @@ export async function runConfigureWizard(
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) {
const selected = opts.sections;
if (!selected || selected.length === 0) {
@@ -372,18 +399,7 @@ export async function runConfigureWizard(
}
if (selected.includes("channels")) {
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);
}
await configureChannelsSection();
}
if (selected.includes("skills")) {
@@ -395,15 +411,7 @@ export async function runConfigureWizard(
if (selected.includes("daemon")) {
if (!selected.includes("gateway")) {
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);
await promptDaemonPort();
}
await maybeInstallDaemon({ runtime, port: gatewayPort, gatewayToken });
@@ -448,18 +456,7 @@ export async function runConfigureWizard(
}
if (choice === "channels") {
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);
}
await configureChannelsSection();
await persistConfig();
}
@@ -471,15 +468,7 @@ export async function runConfigureWizard(
if (choice === "daemon") {
if (!didConfigureGateway) {
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);
await promptDaemonPort();
}
await maybeInstallDaemon({
runtime,