import prompts from 'prompts' ; import { requiredPrompts } from './helpers' ; param { boolean } initial returns { Promise < boolean > } export const usePlex = async ( initial ) : Promise < boolean > => ( await prompts ( { type : 'toggle' , name : 'usePlex' , message : 'Do you want to automatically refresh plex libraries?' , initial , active : 'Yes' , inactive : 'No' , } ) ) . usePlex ; import type { Section } from '@ctrl/plex' ; import { PlexSections } from '../types' ; param selectedSections param availableSections export const sections = async ( selectedSections , availableSections ) : Promise < PlexSections > => ( await prompts ( { type : 'multiselect' , name : 'sections' , message : "Please select the plex section's you want to refresh." , choices : Object . values ( availableSections ) . map ( ( availableSection ) => ( { title : `[${ availableSection . server . friendlyName }]: ${ availableSection . title }` , value : { server : availableSection . server . friendlyName , section : availableSection . title } , selected : selectedSections . includes ( { server : availableSection . server . friendlyName , section : availableSection . title } ) , } ) ) , hint : '- Space to select. Return to submit' , } ) ) . sections || selectedSections ; param { string } initial returns { Promise < string > } export const username = async ( ) : Promise < string > => ( await requiredPrompts ( { type : 'text' , name : 'username' , message : 'Plex account email/username:' , } ) ) . username ; param { string } initial returns { Promise < string > } export const password = async ( ) : Promise < string > => ( await requiredPrompts ( { type : 'password' , name : 'password' , message : 'Plex account password, (If you have 2factor enabled add your 2factor code at the end):' , } ) ) . password ; param { string } initial returns { Promise < string > } export const hostname = async ( initial ) : Promise < string > => ( await prompts ( { type : 'text' , name : 'hostname' , message : 'Plex server IP/Hostname:' , initial , } ) ) . hostname || initial ; param { number } initial returns { Promise < number > } export const port = async ( initial ) : Promise < number > => ( await prompts ( { type : 'text' , name : 'port' , message : 'Plex server port:' , initial , } ) ) . port || initial ;