fix(core): update

This commit is contained in:
2020-08-31 19:23:51 +00:00
parent 83dcc897a8
commit e1bbd5a844
15 changed files with 10070 additions and 832 deletions

View File

@ -5,7 +5,7 @@ import { IAnswerObject } from './smartinteract.classes.smartinteract';
* class AnswerBucket holds answers
*/
export class AnswerBucket {
private answerMap = new plugins.lik.Objectmap<IAnswerObject>();
private answerMap = new plugins.lik.ObjectMap<IAnswerObject>();
/**
* add an answer to the bucket
@ -18,7 +18,7 @@ export class AnswerBucket {
* gets an answer for a specific name
*/
public getAnswerFor(nameArg: string) {
const answer = this.answerMap.find(answerArg => {
const answer = this.answerMap.find((answerArg) => {
return answerArg.name === nameArg;
});
return answer ? answer.value : null;

View File

@ -45,10 +45,23 @@ export interface IValidateFunction {
* class SmartInteract - allows to specify an user interaction during runtime
*/
export class SmartInteract {
// STATIC
public static async getCliConfirmation(questionArg: string, defaultArg: boolean): Promise<boolean> {
const smartinteractInstance = new SmartInteract();
const response = await smartinteractInstance.askQuestion({
default: defaultArg,
message: questionArg,
name: 'question',
type: 'confirm'
});
return response.value;
};
// INSTANCE
/**
* holds the qestion queue, that is emptied once you call
*/
private questionMap = new plugins.lik.Objectmap<IQuestionObject>();
private questionMap = new plugins.lik.ObjectMap<IQuestionObject>();
/**
* constructor of class SmartInteract
@ -73,24 +86,24 @@ export class SmartInteract {
message: optionsArg.message,
default: optionsArg.default,
choices: optionsArg.choices,
validate: optionsArg.validate
}
validate: optionsArg.validate,
},
])
.then(answers => {
.then((answers) => {
// adjust to the fact that now dots define paths for inquirer
const answerValue = plugins.smartparam.smartGet(answers, optionsArg.name);
done.resolve({
name: optionsArg.name,
value: answerValue
value: answerValue,
});
})
.catch(err => {
.catch((err) => {
console.log(err);
});
} else {
const answer: IAnswerObject = {
name: optionsArg.name,
value: optionsArg.default
value: optionsArg.default,
};
done.resolve(answer);
}