46 Commits

Author SHA1 Message Date
5e92004a9f 2.0.12 2023-07-13 14:07:13 +02:00
db268d4fad fix(core): update 2023-07-13 14:07:12 +02:00
0acb00c9c4 switch to new org scheme 2023-07-11 00:50:50 +02:00
b2bf396bb6 switch to new org scheme 2023-07-10 02:56:26 +02:00
0d2e0ca4f7 2.0.11 2020-08-31 19:25:26 +00:00
aa74482b29 fix(core): update 2020-08-31 19:25:25 +00:00
ffe0f202f0 2.0.10 2020-08-31 19:23:52 +00:00
e1bbd5a844 fix(core): update 2020-08-31 19:23:51 +00:00
83dcc897a8 2.0.9 2020-02-07 16:45:49 +00:00
db19c7480f fix(core): update 2020-02-07 16:45:48 +00:00
c1a93102be 2.0.8 2020-02-07 16:36:36 +00:00
01fd22c7d0 fix(core): update 2020-02-07 16:36:35 +00:00
69592933aa 2.0.7 2020-02-02 18:05:50 +00:00
10074b5888 fix(core): update 2020-02-02 18:05:50 +00:00
fe9564e37c 2.0.6 2020-02-02 13:46:49 +00:00
fa5f2d0267 fix(core): update 2020-02-02 13:46:49 +00:00
a4cd5175b3 2.0.5 2020-02-02 13:46:00 +00:00
97c3ccb329 fix(core): update 2020-02-02 13:45:59 +00:00
cfdd54eff1 2.0.4 2018-07-25 17:39:31 +02:00
741365d325 fix(ci): build with right access level for npm 2018-07-25 17:39:31 +02:00
b36e95af1a 2.0.3 2018-07-25 17:37:34 +02:00
ac9ef4915e fix(spendendencies): fix old import to use new dependency 2018-07-25 17:37:34 +02:00
6ca2e427ff 2.0.2 2018-07-25 17:30:30 +02:00
39f9bb11fe fix(ci): add npmts for build step 2018-07-25 17:30:30 +02:00
8925f29962 2.0.1 2018-07-25 16:58:51 +02:00
2e862d6840 fix(package): update tslint 2018-07-25 16:58:51 +02:00
516c0c21de 2.0.0 2018-07-25 16:58:18 +02:00
5dd182d421 BREAKING CHANGE(package): change scope and update dependencies 2018-07-25 16:58:18 +02:00
81a5ce026f 1.0.10 2017-08-09 16:30:32 +02:00
2a45270902 update to support dots as usual 2017-08-09 16:30:30 +02:00
8b6a15388e 1.0.9 2017-07-28 14:50:17 +02:00
0a3b006139 update ci 2017-07-28 14:50:13 +02:00
1f4f9c0c44 1.0.8 2017-07-28 14:45:45 +02:00
9420815809 add docs 2017-07-28 14:45:41 +02:00
efada244c2 1.0.7 2017-07-28 14:30:57 +02:00
585f5a6310 fix npmextra.json 2017-07-28 14:30:52 +02:00
34c4be2740 1.0.6 2017-07-28 14:29:26 +02:00
123bdac087 update ci 2017-07-28 14:29:22 +02:00
8d2ccf8b57 1.0.5 2017-07-28 14:27:12 +02:00
d986d6f9b6 update dependencies and allow empty question set 2017-07-28 14:27:09 +02:00
653782859c 1.0.4 2016-12-10 22:47:10 +01:00
199b99ae2d add npmextra.json 2016-12-10 22:46:59 +01:00
c5e55e8958 1.0.3 2016-12-10 17:30:19 +01:00
256c53b6f9 update README 2016-12-10 17:30:04 +01:00
0dae90cc24 1.0.2 2016-11-20 22:34:39 +01:00
cc65584e9c update deps 2016-11-20 22:34:36 +01:00
27 changed files with 5684 additions and 504 deletions

View File

@ -0,0 +1,66 @@
name: Default (not tags)
on:
push:
tags-ignore:
- '**'
env:
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Install pnpm and npmci
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
- name: Run npm prepare
run: npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build

View File

@ -0,0 +1,124 @@
name: Default (tags)
on:
push:
tags:
- '*'
env:
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build
release:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Release
run: |
npmci node install stable
npmci npm publish
metadata:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
continue-on-error: true
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Code quality
run: |
npmci command npm install -g typescript
npmci npm install
- name: Trigger
run: npmci trigger
- name: Build docs and upload artifacts
run: |
npmci node install stable
npmci npm install
pnpm install -g @gitzone/tsdoc
npmci command tsdoc
continue-on-error: true

20
.gitignore vendored
View File

@ -1,4 +1,20 @@
node_modules/
.nogit/
# artifacts
coverage/
public/
pages/
coverage/
# installs
node_modules/
# caches
.yarn/
.cache/
.rpt2_cache
# builds
dist/
dist_*/
# custom

View File

@ -1,59 +1,137 @@
image: hosttoday/ht-docker-node:npmts
# gitzone ci_default
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
cache:
paths:
- .npmci_cache/
key: '$CI_BUILD_STAGE'
stages:
- test
- release
- trigger
- pages
- security
- test
- release
- metadata
testLEGACY:
stage: test
# ====================
# security stage
# ====================
mirror:
stage: security
script:
- npmci test legacy
- npmci git mirror
only:
- tags
tags:
- lossless
- docker
- notpriv
auditProductionDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci npm prepare
- npmci command npm install --production --ignore-scripts
- npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high --only=prod --production
tags:
- docker
auditDevDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci npm prepare
- npmci command npm install --ignore-scripts
- npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high --only=dev
tags:
- docker
allow_failure: true
testLTS:
# ====================
# test stage
# ====================
testStable:
stage: test
script:
- npmci test lts
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
testSTABLE:
testBuild:
stage: test
script:
- npmci test stable
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci command npm run build
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
release:
stage: release
script:
- npmci publish
- npmci node install stable
- npmci npm publish
only:
- tags
tags:
- lossless
- docker
- notpriv
# ====================
# metadata stage
# ====================
codequality:
stage: metadata
allow_failure: true
only:
- tags
script:
- npmci command npm install -g tslint typescript
- npmci npm prepare
- npmci npm install
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
tags:
- lossless
- docker
- priv
trigger:
stage: trigger
stage: metadata
script:
- npmci trigger
only:
- tags
tags:
- lossless
- docker
- notpriv
pages:
image: hosttoday/ht-docker-node:npmpage
stage: pages
stage: metadata
script:
- npmci command npmpage --host gitlab
- npmci node install lts
- npmci command npm install -g @gitzone/tsdoc
- npmci npm prepare
- npmci npm install
- npmci command tsdoc
tags:
- lossless
- docker
- notpriv
only:
- tags
artifacts:
expire_in: 1 week
paths:
- public
- public
allow_failure: true

11
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,11 @@
{
"version": "0.2.0",
"configurations": [
{
"command": "npm test",
"name": "Run npm test",
"request": "launch",
"type": "node-terminal"
}
]
}

26
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,26 @@
{
"json.schemas": [
{
"fileMatch": ["/npmextra.json"],
"schema": {
"type": "object",
"properties": {
"npmci": {
"type": "object",
"description": "settings for npmci"
},
"gitzone": {
"type": "object",
"description": "settings for gitzone",
"properties": {
"projectType": {
"type": "string",
"enum": ["website", "element", "service", "npm", "wcc"]
}
}
}
}
}
}
]
}

View File

@ -1,56 +0,0 @@
# smartinteract
interact with terminal users
## Availabililty
[![npm](https://push.rocks/assets/repo-button-npm.svg)](https://www.npmjs.com/package/smartinteract)
[![git](https://push.rocks/assets/repo-button-git.svg)](https://gitlab.com/pushrocks/smartinteract)
[![git](https://push.rocks/assets/repo-button-mirror.svg)](https://github.com/pushrocks/smartinteract)
[![docs](https://push.rocks/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)
[![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
We recommend the use of TypeScript for best in class intellesense
```javascript
import { SmartInteract } from 'smartinteract'
let myInteract = new SmartInteract([{ // note: its an array. You can specify multiple questions
name: 'question1',
type: 'input',
message: 'Who are you?',
default: 'Somebody',
validate: (inputString) => { return true } // implement your own validation
}])
SmartInteract.addQuestions([ ... ]) // add more questions
SmartInteract.runQueue()
.then(answerBucket => { // the bucket has all the answers of the completed queue
let answerQuestion1 = answerBucket.getAnswerFor('question1')
// do something with the answers
})
// alternatively use .askQuestion() for more direct control
SmartInteract.askQuestion{ // note: its an array. You can specify multiple questions
name: 'question2',
type: 'confirm',
message: 'Do you speak English?',
default: true,
validate: (inputString) => { return true } // implement your own validation
}().then(answerObject => {
// answerObject looks like { name: 'question2', value: true }
})
```
### Environment
In some environments like CI there is no user input to be expected.
smartinteract will always directyl create an answer from the default value
[![npm](https://push.rocks/assets/repo-header.svg)](https://push.rocks)

1
dist/index.d.ts vendored
View File

@ -1 +0,0 @@
export * from './smartinteract.classes.smartinteract';

6
dist/index.js vendored
View File

@ -1,6 +0,0 @@
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
__export(require("./smartinteract.classes.smartinteract"));
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7O0FBQUEsMkRBQXFEIn0=

View File

@ -1,71 +0,0 @@
/// <reference types="q" />
import * as q from 'q';
import { Objectmap } from 'lik';
export declare type questionType = 'input' | 'confirm' | 'list' | 'rawlist' | 'expand' | 'checkbox' | 'password' | 'editor';
export interface IChoiceObject {
name: string;
value: any;
}
export interface IQuestionObject {
name: string;
type: questionType;
message: string;
default: any;
choices?: string[] | IChoiceObject[];
validate?: IValidateFunction;
}
export interface IAnswerObject {
name: string;
value: any;
}
export interface IValidateFunction {
(anyObject: any): boolean;
}
/**
* class SmartInteract - allows to specify an user interaction during runtime
*/
export declare class SmartInteract {
/**
* holds the qestion queue, that is emptied once you call
*/
private questionMap;
/**
* constructor of class SmartInteract
*/
constructor(questionArrayArg?: IQuestionObject[]);
/**
* allows you to ask a single question and returns the answer in a promise
* skips the queue
*/
askQuestion(optionsArg: IQuestionObject): q.Promise<IAnswerObject>;
/**
* add questions to queue
*/
addQuestions(questionArrayArg: IQuestionObject[]): void;
/**
* run the question queue
*/
runQueue(): q.Promise<AnswerBucket>;
/**
* checks if the current env is valid for userinput
*/
private isValidEnv();
}
/**
* class AnswerBucket holds answers
*/
export declare class AnswerBucket {
answerMap: Objectmap<IAnswerObject>;
/**
* add an answer to the bucket
*/
addAnswer(answerArg: IAnswerObject): void;
/**
* gets an answer for a specific name
*/
getAnswerFor(nameArg: string): any;
/**
* gets all answers as array
*/
getAllAnswers(): IAnswerObject[];
}

View File

@ -1,121 +0,0 @@
"use strict";
const plugins = require("./smartinteract.plugins");
const q = require("q");
const lik_1 = require("lik");
/**
* class SmartInteract - allows to specify an user interaction during runtime
*/
class SmartInteract {
/**
* constructor of class SmartInteract
*/
constructor(questionArrayArg) {
/**
* holds the qestion queue, that is emptied once you call
*/
this.questionMap = new lik_1.Objectmap();
if (questionArrayArg) {
this.addQuestions(questionArrayArg);
}
}
/**
* allows you to ask a single question and returns the answer in a promise
* skips the queue
*/
askQuestion(optionsArg) {
let done = q.defer();
if (this.isValidEnv()) {
plugins.inquirer.prompt([{
name: optionsArg.name,
type: optionsArg.type,
message: optionsArg.message,
default: optionsArg.default,
choices: optionsArg.choices,
validate: optionsArg.validate
}]).then((answers) => {
done.resolve({
name: optionsArg.name,
value: answers[optionsArg.name]
});
});
}
else {
let answer = {
name: optionsArg.name,
value: optionsArg.default
};
done.resolve(answer);
}
return done.promise;
}
/**
* add questions to queue
*/
addQuestions(questionArrayArg) {
this.questionMap.addArray(questionArrayArg);
}
/**
* run the question queue
*/
runQueue() {
let done = q.defer();
let answerBucket = new AnswerBucket();
let handleQuestion = () => {
let oneQuestion = this.questionMap.getOneAndRemove();
this.askQuestion(oneQuestion).then((answerArg) => {
answerBucket.addAnswer(answerArg);
if (!this.questionMap.isEmpty()) {
handleQuestion(); // recursion: as questions until empty
}
else {
done.resolve(answerBucket); // when empty, then resolve promise
}
});
};
handleQuestion();
return done.promise;
}
/**
* checks if the current env is valid for userinput
*/
isValidEnv() {
if (!process.env.CI) {
return true;
}
else {
return false;
}
}
}
exports.SmartInteract = SmartInteract;
/**
* class AnswerBucket holds answers
*/
class AnswerBucket {
constructor() {
this.answerMap = new lik_1.Objectmap();
}
/**
* add an answer to the bucket
*/
addAnswer(answerArg) {
this.answerMap.add(answerArg);
}
/**
* gets an answer for a specific name
*/
getAnswerFor(nameArg) {
let answer = this.answerMap.find(answerArg => {
return answerArg.name === nameArg;
});
return answer.value;
}
/**
* gets all answers as array
*/
getAllAnswers() {
return this.answerMap.getArray();
}
}
exports.AnswerBucket = AnswerBucket;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRpbnRlcmFjdC5jbGFzc2VzLnNtYXJ0aW50ZXJhY3QuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGludGVyYWN0LmNsYXNzZXMuc21hcnRpbnRlcmFjdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsbURBQWtEO0FBQ2xELHVCQUFzQjtBQUN0Qiw2QkFBK0I7QUEyQi9COztHQUVHO0FBQ0g7SUFPSTs7T0FFRztJQUNILFlBQVksZ0JBQW9DO1FBUmhEOztXQUVHO1FBQ0ssZ0JBQVcsR0FBRyxJQUFJLGVBQVMsRUFBbUIsQ0FBQTtRQU1sRCxFQUFFLENBQUMsQ0FBQyxnQkFBZ0IsQ0FBQyxDQUFDLENBQUM7WUFDbkIsSUFBSSxDQUFDLFlBQVksQ0FBQyxnQkFBZ0IsQ0FBQyxDQUFBO1FBQ3ZDLENBQUM7SUFDTCxDQUFDO0lBQ0Q7OztPQUdHO0lBQ0gsV0FBVyxDQUFDLFVBQTJCO1FBQ25DLElBQUksSUFBSSxHQUFHLENBQUMsQ0FBQyxLQUFLLEVBQWlCLENBQUE7UUFDbkMsRUFBRSxDQUFDLENBQUMsSUFBSSxDQUFDLFVBQVUsRUFBRSxDQUFDLENBQUMsQ0FBQztZQUNwQixPQUFPLENBQUMsUUFBUSxDQUFDLE1BQU0sQ0FBQyxDQUFDO29CQUNyQixJQUFJLEVBQUUsVUFBVSxDQUFD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Q0FBQyxTQUF3QjtRQUM5QixJQUFJLENBQUMsU0FBUyxDQUFDLEdBQUcsQ0FBQyxTQUFTLENBQUMsQ0FBQTtJQUNqQyxDQUFDO0lBRUQ7O09BRUc7SUFDSCxZQUFZLENBQUMsT0FBZTtRQUN4QixJQUFJLE1BQU0sR0FBRyxJQUFJLENBQUMsU0FBUyxDQUFDLElBQUksQ0FBQyxTQUFTO1lBQ3RDLE1BQU0sQ0FBQyxTQUFTLENBQUMsSUFBSSxLQUFLLE9BQU8sQ0FBQTtRQUNyQyxDQUFDLENBQUMsQ0FBQTtRQUNGLE1BQU0sQ0FBQyxNQUFNLENBQUMsS0FBSyxDQUFBO0lBQ3ZCLENBQUM7SUFFRDs7T0FFRztJQUNILGFBQWE7UUFDVCxNQUFNLENBQUMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxRQUFRLEVBQUUsQ0FBQTtJQUNwQyxDQUFDO0NBQ0o7QUExQkQsb0NBMEJDIn0=

View File

@ -1,3 +0,0 @@
import 'typings-global';
import * as inquirer from 'inquirer';
export { inquirer };

View File

@ -1,5 +0,0 @@
"use strict";
require("typings-global");
const inquirer = require("inquirer");
exports.inquirer = inquirer;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRpbnRlcmFjdC5wbHVnaW5zLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRpbnRlcmFjdC5wbHVnaW5zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSwwQkFBdUI7QUFDdkIscUNBQW9DO0FBR2hDLDRCQUFRIn0=

17
npmextra.json Normal file
View File

@ -0,0 +1,17 @@
{
"gitzone": {
"projectType": "npm",
"module": {
"githost": "gitlab.com",
"gitscope": "push.rocks",
"gitrepo": "smartinteract",
"description": "smart cli interaction",
"npmPackagename": "@push.rocks/smartinteract",
"license": "MIT"
}
},
"npmci": {
"npmGlobalTools": [],
"npmAccessLevel": "public"
}
}

View File

@ -1,11 +1,14 @@
{
"name": "smartinteract",
"version": "1.0.1",
"name": "@push.rocks/smartinteract",
"private": false,
"version": "2.0.12",
"description": "smart cli interaction",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"scripts": {
"test": "(npmts)"
"test": "(tstest test/)",
"build": "(tsbuild --web)",
"buildDocs": "tsdoc"
},
"repository": {
"type": "git",
@ -22,17 +25,32 @@
},
"homepage": "https://gitlab.com/pushrocks/smartinteract#README",
"dependencies": {
"@types/inquirer": "0.0.31",
"@types/node": "^6.0.48",
"@types/q": "0.0.32",
"@types/should": "^8.1.30",
"inquirer": "^1.2.3",
"lik": "^1.0.27",
"q": "^1.4.1",
"should": "^11.1.1",
"typings-global": "^1.0.14"
"@push.rocks/lik": "^6.0.2",
"@push.rocks/smartobject": "^1.0.12",
"@push.rocks/smartpromise": "^4.0.2",
"@types/inquirer": "^9.0.3",
"inquirer": "^9.2.7"
},
"devDependencies": {
"typings-test": "^1.0.3"
}
"@gitzone/tsbuild": "^2.1.66",
"@gitzone/tsrun": "^1.2.44",
"@gitzone/tstest": "^1.0.74",
"@push.rocks/tapbundle": "^5.0.12"
},
"files": [
"ts/**/*",
"ts_web/**/*",
"dist/**/*",
"dist_*/**/*",
"dist_ts/**/*",
"dist_ts_web/**/*",
"assets/**/*",
"cli.js",
"npmextra.json",
"readme.md"
],
"browserslist": [
"last 1 chrome versions"
],
"type": "module"
}

4982
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

66
readme.md Normal file
View File

@ -0,0 +1,66 @@
# @push.rocks/smartinteract
smart cli interaction
## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@push.rocks/smartinteract)
* [gitlab.com (source)](https://gitlab.com/push.rocks/smartinteract)
* [github.com (source mirror)](https://github.com/push.rocks/smartinteract)
* [docs (typedoc)](https://push.rocks.gitlab.io/smartinteract/)
## Status for master
Status Category | Status Badge
-- | --
GitLab Pipelines | [![pipeline status](https://gitlab.com/push.rocks/smartinteract/badges/master/pipeline.svg)](https://lossless.cloud)
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/push.rocks/smartinteract/badges/master/coverage.svg)](https://lossless.cloud)
npm | [![npm downloads per month](https://badgen.net/npm/dy/@push.rocks/smartinteract)](https://lossless.cloud)
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/push.rocks/smartinteract)](https://lossless.cloud)
TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@push.rocks/smartinteract)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@push.rocks/smartinteract)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@push.rocks/smartinteract)](https://lossless.cloud)
## Usage
Use TypeScript for best in class instellisense.
```javascript
import { SmartInteract } from 'smartinteract'
let myInteract = new SmartInteract([{ // note: its an array. You can specify multiple questions
name: 'question1',
type: 'input',
message: 'Who are you?',
default: 'Somebody',
validate: (inputString) => { return true } // implement your own validation
}])
myInteract.addQuestions([ ... ]) // add more questions
myInteract.runQueue()
.then(answerBucket => { // the bucket has all the answers of the completed queue
let answerQuestion1 = answerBucket.getAnswerFor('question1')
// do something with the answers
})
// alternatively use .askQuestion() for more direct control
myInteract.askQuestion{ // note: its an array. You can specify multiple questions
name: 'question2',
type: 'confirm',
message: 'Do you speak English?',
default: true,
validate: (inputString) => { return true } // implement your own validation
}().then(answerObject => {
// answerObject looks like { name: 'question2', value: true }
})
```
## Contribution
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
For further information read the linked docs at the top of this readme.
## Legal
> MIT licensed | **&copy;** [Task Venture Capital GmbH](https://task.vc)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)

1
test/test.d.ts vendored
View File

@ -1 +0,0 @@
import 'typings-test';

View File

@ -1,37 +0,0 @@
"use strict";
require("typings-test");
const should = require("should");
const smartinteract = require("../dist/index");
describe('smartinteract', function () {
let testInteract;
it('should create a valid new instance', function () {
testInteract = new smartinteract.SmartInteract();
should(testInteract).be.instanceOf(smartinteract.SmartInteract);
});
it('should add question to SmartInteract instance', function () {
testInteract.addQuestions([{
name: 'testQuestion1',
type: 'input',
message: 'what is your favourite color? Answer is blue',
default: 'blue'
}]);
testInteract.addQuestions([{
name: 'testQuestion2',
type: 'input',
message: 'what is your second favourite color? Answer is red',
default: 'red'
}]);
});
it('should use default value when not in CI', function (done) {
this.timeout(30000);
testInteract.runQueue().then(answerBucket => {
should(answerBucket.getAnswerFor('testQuestion1')).equal('blue');
should(answerBucket.getAnswerFor('testQuestion2')).equal('red');
done();
}).catch(err => {
console.log(err);
throw err;
});
});
});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLHdCQUFxQjtBQUNyQixpQ0FBZ0M7QUFFaEMsK0NBQThDO0FBRTlDLFFBQVEsQ0FBQyxlQUFlLEVBQUU7SUFDdEIsSUFBSSxZQUF5QyxDQUFBO0lBQzdDLEVBQUUsQ0FBQyxvQ0FBb0MsRUFBRTtRQUNyQyxZQUFZLEdBQUcsSUFBSSxhQUFhLENBQUMsYUFBYSxFQUFF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NSLE9BQU8sQ0FBQyxHQUFHLENBQUMsR0FBRyxDQUFDLENBQUE7WUFDaEIsTUFBTSxHQUFHLENBQUE7UUFDYixDQUFDLENBQUMsQ0FBQTtJQUNOLENBQUMsQ0FBQyxDQUFBO0FBQ04sQ0FBQyxDQUFDLENBQUEifQ==

View File

@ -1,37 +1,54 @@
import 'typings-test'
import * as should from 'should'
import { expect, tap } from '@push.rocks/tapbundle';
import * as smartinteract from '../dist/index'
import * as smartinteract from '../ts/index.js';
describe('smartinteract', function(){
let testInteract: smartinteract.SmartInteract
it('should create a valid new instance', function(){
testInteract = new smartinteract.SmartInteract()
should(testInteract).be.instanceOf(smartinteract.SmartInteract)
})
it('should add question to SmartInteract instance', function() {
testInteract.addQuestions([{
name: 'testQuestion1',
type: 'input',
message: 'what is your favourite color? Answer is blue',
default: 'blue'
}])
testInteract.addQuestions([{
name: 'testQuestion2',
type: 'input',
message: 'what is your second favourite color? Answer is red',
default: 'red'
}])
})
it('should use default value when not in CI', function(done){
this.timeout(30000)
testInteract.runQueue().then(answerBucket => {
should(answerBucket.getAnswerFor('testQuestion1')).equal('blue')
should(answerBucket.getAnswerFor('testQuestion2')).equal('red')
done()
}).catch(err => {
console.log(err)
throw err
})
})
})
let testInteract: smartinteract.SmartInteract;
tap.test('should create a valid new instance', async () => {
testInteract = new smartinteract.SmartInteract();
expect(testInteract).toBeInstanceOf(smartinteract.SmartInteract);
});
tap.test('should get a simple confirmation', async () => {
const response = await smartinteract.SmartInteract.getCliConfirmation(
'You feel awesome, right?',
true
);
expect(response).toBeTrue();
});
tap.test('should add question to SmartInteract instance', async () => {
testInteract.addQuestions([
{
name: 'testQuestion1',
type: 'input',
message: 'what is your favourite color? Answer is blue',
default: 'blue',
},
]);
testInteract.addQuestions([
{
name: 'testQuestion2',
type: 'input',
message: 'what is your second favourite color? Answer is red',
default: 'red',
},
]);
testInteract.addQuestions([
{
name: 'some.dotted.name',
type: 'input',
message: 'what is your second favourite color? Answer is aValidAnswer',
default: 'aValidAnswer',
},
]);
});
tap.test('should use default value when not in CI', async () => {
const answerBucket = await testInteract.runQueue();
expect(answerBucket.getAnswerFor('testQuestion1')).toEqual('blue');
expect(answerBucket.getAnswerFor('testQuestion2')).toEqual('red');
expect(answerBucket.getAnswerFor('some.dotted.name')).toEqual('aValidAnswer');
});
tap.start();

8
ts/00_commitinfo_data.ts Normal file
View File

@ -0,0 +1,8 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
*/
export const commitinfo = {
name: '@push.rocks/smartinteract',
version: '2.0.12',
description: 'smart cli interaction'
}

View File

@ -1 +1,2 @@
export * from './smartinteract.classes.smartinteract'
export * from './smartinteract.classes.smartinteract.js';
export * from './smartinteract.classes.answerbucket.js';

View File

@ -0,0 +1,33 @@
import * as plugins from './smartinteract.plugins.js';
import { type IAnswerObject } from './smartinteract.classes.smartinteract.js';
/**
* class AnswerBucket holds answers
*/
export class AnswerBucket {
private answerMap = new plugins.lik.ObjectMap<IAnswerObject>();
/**
* add an answer to the bucket
*/
public addAnswer(answerArg: IAnswerObject) {
this.answerMap.add(answerArg);
}
/**
* gets an answer for a specific name
*/
public getAnswerFor(nameArg: string) {
const answer = this.answerMap.findSync((answerArg) => {
return answerArg.name === nameArg;
});
return answer ? answer.value : null;
}
/**
* gets all answers as array
*/
public getAllAnswers() {
return this.answerMap.getArray();
}
}

View File

@ -1,148 +1,153 @@
import * as plugins from './smartinteract.plugins'
import * as q from 'q'
import { Objectmap } from 'lik'
import * as plugins from './smartinteract.plugins.js';
import { AnswerBucket } from './smartinteract.classes.answerbucket.js';
export type questionType = 'input' | 'confirm' | 'list' | 'rawlist' | 'expand' | 'checkbox' | 'password' | 'editor'
/**
* the availeable question types
*/
export type questionType =
| 'input'
| 'confirm'
| 'list'
| 'rawlist'
| 'expand'
| 'checkbox'
| 'password'
| 'editor';
/**
* a choice
*/
export interface IChoiceObject {
name: string
value: any
name: string;
value: any;
}
export interface IQuestionObject {
name: string
type: questionType
message: string
default: any
choices?: string[] | IChoiceObject[]
validate?: IValidateFunction
name: string;
type: questionType;
message: string;
default: any;
choices?: string[] | IChoiceObject[];
validate?: IValidateFunction;
}
export interface IAnswerObject {
name: string,
value: any
name: string;
value: any;
}
export interface IValidateFunction {
(anyObject: any): boolean
(anyObject: any): boolean;
}
/**
* 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;
}
/**
* holds the qestion queue, that is emptied once you call
*/
private questionMap = new Objectmap<IQuestionObject>()
// INSTANCE
/**
* holds the qestion queue, that is emptied once you call
*/
private questionMap = new plugins.lik.ObjectMap<IQuestionObject>();
/**
* constructor of class SmartInteract
*/
constructor(questionArrayArg?: IQuestionObject[]) {
if (questionArrayArg) {
this.addQuestions(questionArrayArg)
}
/**
* constructor of class SmartInteract
*/
constructor(questionArrayArg?: IQuestionObject[]) {
if (questionArrayArg) {
this.addQuestions(questionArrayArg);
}
/**
* allows you to ask a single question and returns the answer in a promise
* skips the queue
*/
askQuestion(optionsArg: IQuestionObject): q.Promise<IAnswerObject> {
let done = q.defer<IAnswerObject>()
if (this.isValidEnv()) {
plugins.inquirer.prompt([{
name: optionsArg.name,
type: optionsArg.type,
message: optionsArg.message,
default: optionsArg.default,
choices: optionsArg.choices,
validate: optionsArg.validate
}]).then((answers: IAnswerObject[]) => {
done.resolve({
name: optionsArg.name,
value: answers[optionsArg.name]
})
})
} else {
let answer: IAnswerObject = {
name: optionsArg.name,
value: optionsArg.default
}
done.resolve(answer)
}
return done.promise
}
/**
* add questions to queue
*/
addQuestions(questionArrayArg: IQuestionObject[]) {
this.questionMap.addArray(questionArrayArg)
}
/**
* run the question queue
*/
runQueue() {
let done = q.defer<AnswerBucket>()
let answerBucket = new AnswerBucket()
let handleQuestion = () => {
let oneQuestion = this.questionMap.getOneAndRemove()
this.askQuestion(oneQuestion).then((answerArg: IAnswerObject) => {
answerBucket.addAnswer(answerArg)
if (!this.questionMap.isEmpty()) {
handleQuestion() // recursion: as questions until empty
} else {
done.resolve(answerBucket) // when empty, then resolve promise
}
})
}
handleQuestion()
return done.promise
}
/**
* checks if the current env is valid for userinput
*/
private isValidEnv(): boolean {
if (!process.env.CI) {
return true
} else {
return false
}
}
}
/**
* 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
}
/**
* allows you to ask a single question and returns the answer in a promise
* skips the queue
*/
askQuestion(optionsArg: IQuestionObject): Promise<IAnswerObject> {
const done = plugins.smartpromise.defer<IAnswerObject>();
if (this.isValidEnv()) {
plugins.inquirer.default
.prompt([
{
name: optionsArg.name,
type: optionsArg.type,
message: optionsArg.message,
default: optionsArg.default,
choices: optionsArg.choices,
validate: optionsArg.validate,
},
])
.then((answers) => {
// adjust to the fact that now dots define paths for inquirer
const answerValue = plugins.smartobject.smartGet(answers, optionsArg.name);
done.resolve({
name: optionsArg.name,
value: answerValue,
});
})
return answer.value
.catch((err) => {
console.log(err);
});
} else {
const answer: IAnswerObject = {
name: optionsArg.name,
value: optionsArg.default,
};
done.resolve(answer);
}
/**
* gets all answers as array
*/
getAllAnswers() {
return this.answerMap.getArray()
return done.promise;
}
/**
* add questions to queue
*/
addQuestions(questionArrayArg: IQuestionObject[]) {
this.questionMap.addArray(questionArrayArg);
}
/**
* run the question queue
*/
runQueue() {
const done = plugins.smartpromise.defer<AnswerBucket>();
const answerBucket = new AnswerBucket();
const handleQuestion = async () => {
if (!this.questionMap.isEmpty()) {
const oneQuestion = this.questionMap.getOneAndRemove();
const answer: IAnswerObject = await this.askQuestion(oneQuestion);
answerBucket.addAnswer(answer);
handleQuestion(); // recursion: as questions until empty
} else {
done.resolve(answerBucket); // when empty, then resolve promise
}
};
handleQuestion();
return done.promise;
}
/**
* checks if the current env is valid for userinput
*/
private isValidEnv(): boolean {
if (!process.env.CI) {
return true;
} else {
return false;
}
}
}

View File

@ -1,6 +1,11 @@
import 'typings-global'
import * as inquirer from 'inquirer'
// pushrocks scope
import * as lik from '@push.rocks/lik';
import * as smartobject from '@push.rocks/smartobject';
import * as smartpromise from '@push.rocks/smartpromise';
export {
inquirer
}
export { lik, smartobject, smartpromise };
// third party scope
import * as inquirer from 'inquirer';
export { inquirer };

11
tsconfig.json Normal file
View File

@ -0,0 +1,11 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"useDefineForClassFields": false,
"target": "ES2022",
"module": "ES2022",
"moduleResolution": "nodenext",
"esModuleInterop": true,
"verbatimModuleSyntax": true,
}
}

View File

@ -1,3 +0,0 @@
{
"extends": "tslint-config-standard"
}