mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 02:11:23 +00:00
refactor(cli): dedupe configure section parsing
This commit is contained in:
@@ -20,6 +20,24 @@ export const CONFIGURE_WIZARD_SECTIONS = [
|
||||
|
||||
export type WizardSection = (typeof CONFIGURE_WIZARD_SECTIONS)[number];
|
||||
|
||||
export function parseConfigureWizardSections(raw: unknown): {
|
||||
sections: WizardSection[];
|
||||
invalid: string[];
|
||||
} {
|
||||
const sectionsRaw: string[] = Array.isArray(raw)
|
||||
? raw.map((value: unknown) => (typeof value === "string" ? value.trim() : "")).filter(Boolean)
|
||||
: [];
|
||||
if (sectionsRaw.length === 0) {
|
||||
return { sections: [], invalid: [] };
|
||||
}
|
||||
|
||||
const invalid = sectionsRaw.filter((s) => !CONFIGURE_WIZARD_SECTIONS.includes(s as never));
|
||||
const sections = sectionsRaw.filter((s): s is WizardSection =>
|
||||
CONFIGURE_WIZARD_SECTIONS.includes(s as never),
|
||||
);
|
||||
return { sections, invalid };
|
||||
}
|
||||
|
||||
export type ChannelsWizardMode = "configure" | "remove";
|
||||
|
||||
export type ConfigureWizardParams = {
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
export { configureCommand, configureCommandWithSections } from "./configure.commands.js";
|
||||
export { buildGatewayAuthConfig } from "./configure.gateway-auth.js";
|
||||
export { CONFIGURE_WIZARD_SECTIONS, type WizardSection } from "./configure.shared.js";
|
||||
export {
|
||||
CONFIGURE_WIZARD_SECTIONS,
|
||||
parseConfigureWizardSections,
|
||||
type WizardSection,
|
||||
} from "./configure.shared.js";
|
||||
export { runConfigureWizard } from "./configure.wizard.js";
|
||||
|
||||
Reference in New Issue
Block a user