rush-init-project-plugin
Version:
Rush plugin for initialize project in monorepo
114 lines • 3.53 kB
TypeScript
import { Widgets } from 'blessed';
import type { PromptQuestion } from 'node-plop';
import type { SyncHook } from 'tapable';
import { Answers } from 'inquirer';
export interface IComponentOptions {
height: number;
top: number;
}
export type BaseValueType = number | string | boolean | Array<string | boolean | number>;
export interface IExtendedAnswers extends Answers {
authorName: string;
description: string;
template: string;
packageName: string;
unscopedPackageName: string;
projectFolder: string;
shouldRunRushUpdate: boolean;
}
/**
* This is a basic Field component based on inquirer
* Any new component based on inquirer should extend this class
*/
export declare class BaseFieldComponent {
/**
* Each Field need a label
*/
label: Widgets.BoxElement;
option: IComponentOptions;
form: Widgets.FormElement<Answers>;
prompt: PromptQuestion;
/**
* control the active of the this field, if this field is active, its value is active and it's visible
*/
isActived: boolean;
/**
* validation of the field
*/
isValidate: boolean | string;
/**
* all elements involved in field
*/
elements: Array<Widgets.BoxElement | Widgets.BoxElement[]>;
private _hookForPrompt;
constructor(form: Widgets.FormElement<Answers>, prompt: PromptQuestion, option: IComponentOptions, hookForPrompt: SyncHook<[PromptQuestion, Partial<IExtendedAnswers>], null | undefined> | undefined);
/**
* validate result based on blessed widget implemented by every component
*/
validateResult(): Promise<void>;
/**
* set default value on the blessed widget implemented by every component
*/
setDefaultValue(): Promise<void>;
/**
* set content on the blessed widget implemented by every component
*/
setMessage(): Promise<void>;
/**
* used for blessed to focus on field implemented by every component
*/
focus(): void;
/**
* used for blessed to focus on next field
*/
focusNext(): void;
/**
* get really field object
*/
getFieldComponent(): Widgets.Node | undefined;
reset(): void;
render(): void;
invokeHooks(): Promise<void>;
/**
* get current total height of all elements and it's top
*/
getLayout(): IComponentOptions;
/**
* update and top of all elements
*/
updateLayout(updateOption: IComponentOptions): IComponentOptions;
/**
* The default value of the question.
* implement of default param in inquirer
*/
default(): Promise<BaseValueType>;
/**
* The message value of the question.
* implement of message param in inquirer
*/
message(): Promise<string>;
/**
* Validates the integrity of the answer.
* implement of validate param in inquirer
*
* @param input
* The answer provided by the user.
*
* @returns
* If this field is inactive, it will always return true
* Either a value indicating whether the answer is valid or a `string` which describes the error.
*/
validate(value: BaseValueType | {
value: BaseValueType;
}): Promise<boolean | string>;
/**
* A value indicating whether the question should be prompted.
* implement of when param in inquirer
*/
when(): Promise<void>;
/**
* init state include default and message config
*/
initState(): Promise<void>;
}
//# sourceMappingURL=BaseFieldComponent.d.ts.map