fix(core): update
This commit is contained in:
parent
cfdd54eff1
commit
97c3ccb329
33
README.md
33
README.md
@ -1,33 +0,0 @@
|
||||
# smartinteract
|
||||
|
||||
smart cli interaction
|
||||
|
||||
## Availabililty
|
||||
|
||||
[![npm](https://pushrocks.gitlab.io/assets/repo-button-npm.svg)](https://www.npmjs.com/package/smartinteract)
|
||||
[![git](https://pushrocks.gitlab.io/assets/repo-button-git.svg)](https://GitLab.com/pushrocks/smartinteract)
|
||||
[![git](https://pushrocks.gitlab.io/assets/repo-button-mirror.svg)](https://github.com/pushrocks/smartinteract)
|
||||
[![docs](https://pushrocks.gitlab.io/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/smartinteract/)
|
||||
|
||||
## Status for master
|
||||
|
||||
[![build status](https://GitLab.com/pushrocks/smartinteract/badges/master/build.svg)](https://GitLab.com/pushrocks/smartinteract/commits/master)
|
||||
[![coverage report](https://GitLab.com/pushrocks/smartinteract/badges/master/coverage.svg)](https://GitLab.com/pushrocks/smartinteract/commits/master)
|
||||
[![npm downloads per month](https://img.shields.io/npm/dm/smartinteract.svg)](https://www.npmjs.com/package/smartinteract)
|
||||
[![Dependency Status](https://david-dm.org/pushrocks/smartinteract.svg)](https://david-dm.org/pushrocks/smartinteract)
|
||||
[![bitHound Dependencies](https://www.bithound.io/github/pushrocks/smartinteract/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/smartinteract/master/dependencies/npm)
|
||||
[![bitHound Code](https://www.bithound.io/github/pushrocks/smartinteract/badges/code.svg)](https://www.bithound.io/github/pushrocks/smartinteract)
|
||||
[![TypeScript](https://img.shields.io/badge/TypeScript-2.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||
[![node](https://img.shields.io/badge/node->=%206.x.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
|
||||
|
||||
## Usage
|
||||
|
||||
Use TypeScript for best in class instellisense.
|
||||
|
||||
For further information read the linked docs at the top of this README.
|
||||
|
||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
||||
|
||||
[![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://push.rocks)
|
1364
package-lock.json
generated
1364
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
15
package.json
15
package.json
@ -25,13 +25,16 @@
|
||||
},
|
||||
"homepage": "https://gitlab.com/pushrocks/smartinteract#README",
|
||||
"dependencies": {
|
||||
"@pushrocks/lik": "^3.0.1",
|
||||
"@pushrocks/smartpromise": "^2.0.5",
|
||||
"@types/inquirer": "0.0.42",
|
||||
"inquirer": "^6.0.0"
|
||||
"@pushrocks/lik": "^3.0.13",
|
||||
"@pushrocks/smartparam": "^1.1.6",
|
||||
"@pushrocks/smartpromise": "^3.0.6",
|
||||
"@types/inquirer": "^6.5.0",
|
||||
"inquirer": "^7.0.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsrun": "^1.1.9",
|
||||
"@pushrocks/tapbundle": "^3.0.1"
|
||||
"@gitzone/tsrun": "^1.2.8",
|
||||
"@pushrocks/tapbundle": "^3.2.0",
|
||||
"tslint": "^6.0.0",
|
||||
"tslint-config-prettier": "^1.18.0"
|
||||
}
|
||||
}
|
||||
|
@ -30,14 +30,14 @@ tap.test('should add question to SmartInteract instance', async () => {
|
||||
{
|
||||
name: 'some.dotted.name',
|
||||
type: 'input',
|
||||
message: 'what is your second favourite color? Answer is red',
|
||||
message: 'what is your second favourite color? Answer is aValidAnswer',
|
||||
default: 'aValidAnswer'
|
||||
}
|
||||
]);
|
||||
});
|
||||
|
||||
tap.test('should use default value when not in CI', async () => {
|
||||
let answerBucket = await testInteract.runQueue();
|
||||
const answerBucket = await testInteract.runQueue();
|
||||
expect(answerBucket.getAnswerFor('testQuestion1')).to.equal('blue');
|
||||
expect(answerBucket.getAnswerFor('testQuestion2')).to.equal('red');
|
||||
expect(answerBucket.getAnswerFor('some.dotted.name')).to.equal('aValidAnswer');
|
||||
|
33
ts/smartinteract.classes.answerbucket.ts
Normal file
33
ts/smartinteract.classes.answerbucket.ts
Normal file
@ -0,0 +1,33 @@
|
||||
import * as plugins from './smartinteract.plugins';
|
||||
import { IAnswerObject } from './smartinteract.classes.smartinteract';
|
||||
|
||||
/**
|
||||
* class AnswerBucket holds answers
|
||||
*/
|
||||
export class AnswerBucket {
|
||||
answerMap = new plugins.lik.Objectmap<IAnswerObject>();
|
||||
|
||||
/**
|
||||
* add an answer to the bucket
|
||||
*/
|
||||
addAnswer(answerArg: IAnswerObject) {
|
||||
this.answerMap.add(answerArg);
|
||||
}
|
||||
|
||||
/**
|
||||
* gets an answer for a specific name
|
||||
*/
|
||||
getAnswerFor(nameArg: string) {
|
||||
let answer = this.answerMap.find(answerArg => {
|
||||
return answerArg.name === nameArg;
|
||||
});
|
||||
return answer ? answer.value : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* gets all answers as array
|
||||
*/
|
||||
getAllAnswers() {
|
||||
return this.answerMap.getArray();
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
import * as plugins from './smartinteract.plugins';
|
||||
import * as smartpromise from '@pushrocks/smartpromise';
|
||||
import { Objectmap } from '@pushrocks/lik';
|
||||
import { AnswerBucket } from './smartinteract.classes.answerbucket';
|
||||
|
||||
/**
|
||||
* the availeable question types
|
||||
@ -48,7 +48,7 @@ export class SmartInteract {
|
||||
/**
|
||||
* holds the qestion queue, that is emptied once you call
|
||||
*/
|
||||
private questionMap = new Objectmap<IQuestionObject>();
|
||||
private questionMap = new plugins.lik.Objectmap<IQuestionObject>();
|
||||
|
||||
/**
|
||||
* constructor of class SmartInteract
|
||||
@ -76,13 +76,9 @@ export class SmartInteract {
|
||||
validate: optionsArg.validate
|
||||
}
|
||||
])
|
||||
.then((answers: IAnswerObject[]) => {
|
||||
.then((answers) => {
|
||||
// adjust to the fact that now dots define paths for inquirer
|
||||
let answerValue: any = answers;
|
||||
let nameArray = optionsArg.name.split('.');
|
||||
for (let name of nameArray) {
|
||||
answerValue = answerValue[name];
|
||||
}
|
||||
let answerValue = plugins.smartparam.smartGet(answers, optionsArg.name);
|
||||
done.resolve({
|
||||
name: optionsArg.name,
|
||||
value: answerValue
|
||||
@ -140,34 +136,3 @@ export class SmartInteract {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* class AnswerBucket holds answers
|
||||
*/
|
||||
export class AnswerBucket {
|
||||
answerMap = new Objectmap<IAnswerObject>();
|
||||
|
||||
/**
|
||||
* add an answer to the bucket
|
||||
*/
|
||||
addAnswer(answerArg: IAnswerObject) {
|
||||
this.answerMap.add(answerArg);
|
||||
}
|
||||
|
||||
/**
|
||||
* gets an answer for a specific name
|
||||
*/
|
||||
getAnswerFor(nameArg: string) {
|
||||
let answer = this.answerMap.find(answerArg => {
|
||||
return answerArg.name === nameArg;
|
||||
});
|
||||
return answer.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* gets all answers as array
|
||||
*/
|
||||
getAllAnswers() {
|
||||
return this.answerMap.getArray();
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,14 @@
|
||||
// pushrocks scope
|
||||
import * as lik from '@pushrocks/lik';
|
||||
import * as smartparam from '@pushrocks/smartparam';
|
||||
|
||||
export {
|
||||
lik,
|
||||
smartparam
|
||||
}
|
||||
|
||||
|
||||
// third party scope
|
||||
import * as inquirer from 'inquirer';
|
||||
|
||||
export { inquirer };
|
||||
|
Loading…
Reference in New Issue
Block a user