feat: unify onboarding + config schema
This commit is contained in:
52
src/wizard/prompts.ts
Normal file
52
src/wizard/prompts.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
export type WizardSelectOption<T = string> = {
|
||||
value: T;
|
||||
label: string;
|
||||
hint?: string;
|
||||
};
|
||||
|
||||
export type WizardSelectParams<T = string> = {
|
||||
message: string;
|
||||
options: Array<WizardSelectOption<T>>;
|
||||
initialValue?: T;
|
||||
};
|
||||
|
||||
export type WizardMultiSelectParams<T = string> = {
|
||||
message: string;
|
||||
options: Array<WizardSelectOption<T>>;
|
||||
initialValues?: T[];
|
||||
};
|
||||
|
||||
export type WizardTextParams = {
|
||||
message: string;
|
||||
initialValue?: string;
|
||||
placeholder?: string;
|
||||
validate?: (value: string) => string | undefined;
|
||||
};
|
||||
|
||||
export type WizardConfirmParams = {
|
||||
message: string;
|
||||
initialValue?: boolean;
|
||||
};
|
||||
|
||||
export type WizardProgress = {
|
||||
update: (message: string) => void;
|
||||
stop: (message?: string) => void;
|
||||
};
|
||||
|
||||
export type WizardPrompter = {
|
||||
intro: (title: string) => Promise<void>;
|
||||
outro: (message: string) => Promise<void>;
|
||||
note: (message: string, title?: string) => Promise<void>;
|
||||
select: <T>(params: WizardSelectParams<T>) => Promise<T>;
|
||||
multiselect: <T>(params: WizardMultiSelectParams<T>) => Promise<T[]>;
|
||||
text: (params: WizardTextParams) => Promise<string>;
|
||||
confirm: (params: WizardConfirmParams) => Promise<boolean>;
|
||||
progress: (label: string) => WizardProgress;
|
||||
};
|
||||
|
||||
export class WizardCancelledError extends Error {
|
||||
constructor(message = "wizard cancelled") {
|
||||
super(message);
|
||||
this.name = "WizardCancelledError";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user