refactor(cli): dedupe configure section parsing

This commit is contained in:
Peter Steinberger
2026-02-15 04:42:00 +00:00
parent b5c81f732c
commit ae599243fd
4 changed files with 32 additions and 15 deletions

View File

@@ -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 = {