Compare commits
52 Commits
Author | SHA1 | Date | |
---|---|---|---|
8e04bd6a62 | |||
687a5f7c4e | |||
17983b1da9 | |||
5fcdf1ff8f | |||
ef7ee7fc73 | |||
c48e85897e | |||
9466b3e473 | |||
ab3127b8a6 | |||
1e62e27980 | |||
4b87004478 | |||
7750f1fbf5 | |||
c4e5ba6587 | |||
9d1f0f22ba | |||
1ce9e32116 | |||
adfda70522 | |||
c701e3e04c | |||
7b1de5b31d | |||
7908fd8cfd | |||
21bd0c9279 | |||
9d1108e40d | |||
390e0cb491 | |||
032fd0c2fd | |||
440881c3d8 | |||
f208121e2c | |||
7c4ae84871 | |||
668f6c3e16 | |||
b1e08aad1f | |||
f1ab614cdf | |||
995c808512 | |||
28acb867a0 | |||
3148a50d43 | |||
41c99de4d8 | |||
a91f56dacf | |||
f60f17f91e | |||
d154cf0d0f | |||
a6e0fa65e0 | |||
c7e940f597 | |||
45d3ce8ffc | |||
ce121b8b7f | |||
ce65b8d7c9 | |||
9acdfca460 | |||
59bcd8dadf | |||
b6375fd8fa | |||
8183417c90 | |||
5e66d35125 | |||
3ff4c3ff2f | |||
6508b29bfc | |||
66fd7138ab | |||
f3ce1c1408 | |||
d2b84acc55 | |||
ce008da9ad | |||
f0f1f9b86f |
21
.gitignore
vendored
21
.gitignore
vendored
@ -1,9 +1,22 @@
|
|||||||
node_modules/
|
.nogit/
|
||||||
|
|
||||||
|
# artifacts
|
||||||
coverage/
|
coverage/
|
||||||
|
public/
|
||||||
pages/
|
pages/
|
||||||
|
|
||||||
|
# installs
|
||||||
|
node_modules/
|
||||||
|
|
||||||
ts/*.js
|
# caches
|
||||||
ts/*.js.map
|
.yarn/
|
||||||
ts/typings/
|
.cache/
|
||||||
|
.rpt2_cache
|
||||||
|
|
||||||
|
# builds
|
||||||
|
dist/
|
||||||
|
dist_web/
|
||||||
|
dist_serve/
|
||||||
|
dist_ts_web/
|
||||||
|
|
||||||
|
# custom
|
114
.gitlab-ci.yml
114
.gitlab-ci.yml
@ -1,50 +1,126 @@
|
|||||||
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:
|
stages:
|
||||||
- test
|
- security
|
||||||
- release
|
- test
|
||||||
- page
|
- release
|
||||||
|
- metadata
|
||||||
|
|
||||||
testLEGACY:
|
# ====================
|
||||||
stage: test
|
# security stage
|
||||||
|
# ====================
|
||||||
|
mirror:
|
||||||
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci test legacy
|
- npmci git mirror
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
allow_failure: true
|
- notpriv
|
||||||
|
|
||||||
testLTS:
|
snyk:
|
||||||
|
image: registry.gitlab.com/hosttoday/ht-docker-node:snyk
|
||||||
|
stage: security
|
||||||
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci command npm install --ignore-scripts
|
||||||
|
- npmci command snyk test
|
||||||
|
tags:
|
||||||
|
- lossless
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
|
# ====================
|
||||||
|
# test stage
|
||||||
|
# ====================
|
||||||
|
|
||||||
|
testStable:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci test lts
|
- npmci npm prepare
|
||||||
|
- npmci node install stable
|
||||||
|
- npmci npm install
|
||||||
|
- npmci npm test
|
||||||
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
|
- priv
|
||||||
testSTABLE:
|
|
||||||
|
testBuild:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
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:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
release:
|
release:
|
||||||
stage: release
|
stage: release
|
||||||
script:
|
script:
|
||||||
- npmci publish
|
- npmci node install stable
|
||||||
|
- npmci npm publish
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
|
# ====================
|
||||||
|
# metadata stage
|
||||||
|
# ====================
|
||||||
|
codequality:
|
||||||
|
stage: metadata
|
||||||
|
allow_failure: true
|
||||||
|
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: metadata
|
||||||
|
script:
|
||||||
|
- npmci trigger
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
|
tags:
|
||||||
|
- lossless
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
pages:
|
pages:
|
||||||
image: hosttoday/ht-docker-node:npmpage
|
stage: metadata
|
||||||
stage: page
|
|
||||||
script:
|
script:
|
||||||
- npmci test stable
|
- npmci node install lts
|
||||||
- npmci command npmpage --host gitlab
|
- npmci command npm install -g @gitzone/tsdoc
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci npm install
|
||||||
|
- npmci command tsdoc
|
||||||
|
tags:
|
||||||
|
- lossless
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
artifacts:
|
artifacts:
|
||||||
expire_in: 1 week
|
expire_in: 1 week
|
||||||
paths:
|
paths:
|
||||||
- public
|
- public
|
||||||
|
allow_failure: true
|
||||||
|
9
.snyk
Normal file
9
.snyk
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
|
||||||
|
version: v1.12.0
|
||||||
|
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
|
||||||
|
ignore:
|
||||||
|
'npm:mem:20180117':
|
||||||
|
- yargs > os-locale > mem:
|
||||||
|
reason: None given
|
||||||
|
expires: '2018-09-29T22:12:38.004Z'
|
||||||
|
patch: {}
|
29
.vscode/launch.json
vendored
Normal file
29
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "current file",
|
||||||
|
"type": "node",
|
||||||
|
"request": "launch",
|
||||||
|
"args": [
|
||||||
|
"${relativeFile}"
|
||||||
|
],
|
||||||
|
"runtimeArgs": ["-r", "@gitzone/tsrun"],
|
||||||
|
"cwd": "${workspaceRoot}",
|
||||||
|
"protocol": "inspector",
|
||||||
|
"internalConsoleOptions": "openOnSessionStart"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "test.ts",
|
||||||
|
"type": "node",
|
||||||
|
"request": "launch",
|
||||||
|
"args": [
|
||||||
|
"test/test.ts"
|
||||||
|
],
|
||||||
|
"runtimeArgs": ["-r", "@gitzone/tsrun"],
|
||||||
|
"cwd": "${workspaceRoot}",
|
||||||
|
"protocol": "inspector",
|
||||||
|
"internalConsoleOptions": "openOnSessionStart"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
26
.vscode/settings.json
vendored
Normal file
26
.vscode/settings.json
vendored
Normal 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"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
64
README.md
64
README.md
@ -1,64 +0,0 @@
|
|||||||
# smartcli
|
|
||||||
nodejs wrapper for CLI related tasks. TypeScript ready.
|
|
||||||
|
|
||||||
## Availabililty
|
|
||||||
[](https://www.npmjs.com/package/smartcli)
|
|
||||||
[](https://gitlab.com/pushrocks/smartcli)
|
|
||||||
[](https://github.com/pushrocks/smartcli)
|
|
||||||
[](https://pushrocks.gitlab.io/smartcli/docs)
|
|
||||||
|
|
||||||
## Status for master
|
|
||||||
[](https://gitlab.com/pushrocks/smartcli/commits/master)
|
|
||||||
[](https://gitlab.com/pushrocks/smartcli/commits/master)
|
|
||||||
[](https://david-dm.org/pushrocks/smartcli)
|
|
||||||
[](https://www.bithound.io/github/pushrocks/smartcli/master/dependencies/npm)
|
|
||||||
[](https://www.bithound.io/github/pushrocks/smartcli)
|
|
||||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
|
||||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
|
||||||
|
|
||||||
## Install the package
|
|
||||||
npm install smartcli --save
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
this plugin tries to establish some logic in which CLI tools work.
|
|
||||||
|
|
||||||
take the following commandline input:
|
|
||||||
|
|
||||||
```
|
|
||||||
mytool command argument1 argument2 --option1 -o2 option2Value
|
|
||||||
```
|
|
||||||
|
|
||||||
* `mytool` obviously is the tool (like git)
|
|
||||||
* `command` is the main thing the tool shall do (like commit)
|
|
||||||
* `argument1` and `argument2` are arguments
|
|
||||||
* `option1` is a longform option you can add (like --message for message)
|
|
||||||
* `optionValue` is the referenced option value (like a commit message)
|
|
||||||
|
|
||||||
When there is no command and no option specified the standardTask applied.
|
|
||||||
When there is a option specified but no command, standardTask applies,
|
|
||||||
except when of the options is -v, --version or --help.
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
import {Smartcli} from "smartcli"
|
|
||||||
mySmartcli = new Smartcli();
|
|
||||||
mySmartcli.standardTask()
|
|
||||||
.then(argvArg => {
|
|
||||||
// do something if program is called without an command
|
|
||||||
});
|
|
||||||
|
|
||||||
mySmartcli.addCommand({commandname: 'install'})
|
|
||||||
.then(argvArg => {
|
|
||||||
// do something if program is called with command "install"
|
|
||||||
})
|
|
||||||
|
|
||||||
mySmartcli.addVersion('1.0.0') // -v and --version options will display the specified version in the terminal
|
|
||||||
|
|
||||||
mySmartCli.addHelp({ // is triggered by help command and --help option
|
|
||||||
helpText: 'some help text to print' // the helpText to display
|
|
||||||
})
|
|
||||||
|
|
||||||
mySmartcli.startParse() // starts the evaluation and fullfills or rejects promises.
|
|
||||||
```
|
|
||||||
|
|
||||||
[](https://push.rocks)
|
|
1
dist/index.d.ts
vendored
1
dist/index.d.ts
vendored
@ -1 +0,0 @@
|
|||||||
export { Smartcli } from './smartcli.classes.smartcli';
|
|
4
dist/index.js
vendored
4
dist/index.js
vendored
@ -1,4 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var smartcli_classes_smartcli_1 = require("./smartcli.classes.smartcli");
|
|
||||||
exports.Smartcli = smartcli_classes_smartcli_1.Smartcli;
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEseUVBQXNEO0FBQTdDLCtDQUFBLFFBQVEsQ0FBQSJ9
|
|
69
dist/smartcli.classes.smartcli.d.ts
vendored
69
dist/smartcli.classes.smartcli.d.ts
vendored
@ -1,69 +0,0 @@
|
|||||||
/// <reference types="q" />
|
|
||||||
import * as q from 'q';
|
|
||||||
import { Subject } from 'rxjs';
|
|
||||||
import { Objectmap } from 'lik';
|
|
||||||
export interface ICommandPromiseObject {
|
|
||||||
commandName: string;
|
|
||||||
promise: q.Promise<void>;
|
|
||||||
}
|
|
||||||
export interface ITriggerObservableObject {
|
|
||||||
triggerName: string;
|
|
||||||
subject: Subject<any>;
|
|
||||||
}
|
|
||||||
export declare class Smartcli {
|
|
||||||
argv: any;
|
|
||||||
questionsDone: any;
|
|
||||||
parseStarted: any;
|
|
||||||
commands: any;
|
|
||||||
questions: any;
|
|
||||||
version: string;
|
|
||||||
/**
|
|
||||||
* map of all Command/Promise objects to keep track
|
|
||||||
*/
|
|
||||||
allCommandPromisesMap: Objectmap<ICommandPromiseObject>;
|
|
||||||
/**
|
|
||||||
* map of all Trigger/Observable objects to keep track
|
|
||||||
*/
|
|
||||||
allTriggerObservablesMap: Objectmap<ITriggerObservableObject>;
|
|
||||||
constructor();
|
|
||||||
/**
|
|
||||||
* adds an alias, meaning one equals the other in terms of command execution.
|
|
||||||
*/
|
|
||||||
addCommandAlias(keyArg: any, aliasArg: any): void;
|
|
||||||
/**
|
|
||||||
* adds a Command by returning a Promise that reacts to the specific commandString given.
|
|
||||||
* Note: in e.g. "npm install something" the "install" is considered the command.
|
|
||||||
*/
|
|
||||||
addCommand(commandNameArg: string): q.Promise<any>;
|
|
||||||
/**
|
|
||||||
* gets a Promise for a command word
|
|
||||||
*/
|
|
||||||
getCommandPromiseByName(commandNameArg: string): q.Promise<void>;
|
|
||||||
/**
|
|
||||||
* adds a Trigger. Like addCommand(), but returns an subscribable observable
|
|
||||||
*/
|
|
||||||
addTrigger(triggerNameArg: string): Subject<any>;
|
|
||||||
/**
|
|
||||||
* execute trigger by name
|
|
||||||
* @param commandNameArg - the name of the command to trigger
|
|
||||||
*/
|
|
||||||
trigger(triggerName: string): Subject<any>;
|
|
||||||
/**
|
|
||||||
* allows to specify help text to be printed above the rest of the help text
|
|
||||||
*/
|
|
||||||
addHelp(optionsArg: {
|
|
||||||
helpText: string;
|
|
||||||
}): void;
|
|
||||||
/**
|
|
||||||
* specify version to be printed for -v --version
|
|
||||||
*/
|
|
||||||
addVersion(versionArg: string): void;
|
|
||||||
/**
|
|
||||||
* returns promise that is resolved when no commands are specified
|
|
||||||
*/
|
|
||||||
standardTask(): q.Promise<any>;
|
|
||||||
/**
|
|
||||||
* start the process of evaluating commands
|
|
||||||
*/
|
|
||||||
startParse(): void;
|
|
||||||
}
|
|
133
dist/smartcli.classes.smartcli.js
vendored
133
dist/smartcli.classes.smartcli.js
vendored
@ -1,133 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
const q = require("q");
|
|
||||||
const rxjs_1 = require("rxjs");
|
|
||||||
const plugins = require("./smartcli.plugins");
|
|
||||||
// import classes
|
|
||||||
const lik_1 = require("lik");
|
|
||||||
class Smartcli {
|
|
||||||
constructor() {
|
|
||||||
/**
|
|
||||||
* map of all Command/Promise objects to keep track
|
|
||||||
*/
|
|
||||||
this.allCommandPromisesMap = new lik_1.Objectmap();
|
|
||||||
/**
|
|
||||||
* map of all Trigger/Observable objects to keep track
|
|
||||||
*/
|
|
||||||
this.allTriggerObservablesMap = new lik_1.Objectmap();
|
|
||||||
this.argv = plugins.yargs;
|
|
||||||
this.questionsDone = q.defer();
|
|
||||||
this.parseStarted = q.defer();
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* adds an alias, meaning one equals the other in terms of command execution.
|
|
||||||
*/
|
|
||||||
addCommandAlias(keyArg, aliasArg) {
|
|
||||||
this.argv = this.argv.alias(keyArg, aliasArg);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* adds a Command by returning a Promise that reacts to the specific commandString given.
|
|
||||||
* Note: in e.g. "npm install something" the "install" is considered the command.
|
|
||||||
*/
|
|
||||||
addCommand(commandNameArg) {
|
|
||||||
let done = q.defer();
|
|
||||||
this.allCommandPromisesMap.add({
|
|
||||||
commandName: commandNameArg,
|
|
||||||
promise: done.promise
|
|
||||||
});
|
|
||||||
this.parseStarted.promise
|
|
||||||
.then(() => {
|
|
||||||
if (this.argv._.indexOf(commandNameArg) === 0) {
|
|
||||||
done.resolve(this.argv);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
done.reject(this.argv);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return done.promise;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* gets a Promise for a command word
|
|
||||||
*/
|
|
||||||
getCommandPromiseByName(commandNameArg) {
|
|
||||||
return this.allCommandPromisesMap.find(commandDeferredObjectArg => {
|
|
||||||
return commandDeferredObjectArg.commandName === commandNameArg;
|
|
||||||
}).promise;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* adds a Trigger. Like addCommand(), but returns an subscribable observable
|
|
||||||
*/
|
|
||||||
addTrigger(triggerNameArg) {
|
|
||||||
let triggerSubject = new rxjs_1.Subject();
|
|
||||||
this.allTriggerObservablesMap.add({
|
|
||||||
triggerName: triggerNameArg,
|
|
||||||
subject: triggerSubject
|
|
||||||
});
|
|
||||||
this.addCommand(triggerNameArg).then(() => {
|
|
||||||
triggerSubject.next(this.argv);
|
|
||||||
});
|
|
||||||
return triggerSubject;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* execute trigger by name
|
|
||||||
* @param commandNameArg - the name of the command to trigger
|
|
||||||
*/
|
|
||||||
trigger(triggerName) {
|
|
||||||
let triggerSubject = this.allTriggerObservablesMap.find(triggerObservableObjectArg => {
|
|
||||||
return triggerObservableObjectArg.triggerName === triggerName;
|
|
||||||
}).subject;
|
|
||||||
triggerSubject.next(this.argv);
|
|
||||||
return triggerSubject;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* allows to specify help text to be printed above the rest of the help text
|
|
||||||
*/
|
|
||||||
addHelp(optionsArg) {
|
|
||||||
this.addCommand('help').then(argvArg => {
|
|
||||||
plugins.beautylog.log(optionsArg.helpText);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* specify version to be printed for -v --version
|
|
||||||
*/
|
|
||||||
addVersion(versionArg) {
|
|
||||||
this.version = versionArg;
|
|
||||||
this.addCommandAlias('v', 'version');
|
|
||||||
this.parseStarted.promise
|
|
||||||
.then(() => {
|
|
||||||
if (this.argv.v) {
|
|
||||||
console.log(this.version);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* returns promise that is resolved when no commands are specified
|
|
||||||
*/
|
|
||||||
standardTask() {
|
|
||||||
let done = q.defer();
|
|
||||||
this.allCommandPromisesMap.add({
|
|
||||||
commandName: 'standard',
|
|
||||||
promise: done.promise
|
|
||||||
});
|
|
||||||
this.parseStarted.promise
|
|
||||||
.then(() => {
|
|
||||||
if (this.argv._.length === 0 && !this.argv.v) {
|
|
||||||
done.resolve(this.argv);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
done.reject(this.argv);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return done.promise;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* start the process of evaluating commands
|
|
||||||
*/
|
|
||||||
startParse() {
|
|
||||||
this.argv = this.argv.argv;
|
|
||||||
this.parseStarted.resolve();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.Smartcli = Smartcli;
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRjbGkuY2xhc3Nlcy5zbWFydGNsaS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0Y2xpLmNsYXNzZXMuc21hcnRjbGkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLHVCQUFzQjtBQUN0QiwrQkFBOEI7QUFFOUIsOENBQTZDO0FBRTdDLGlCQUFpQj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FLElBQUksQ0FBQyxPQUFPO1NBQ3hCLENBQUMsQ0FBQTtRQUNGLElBQUksQ0FBQyxZQUFZLENBQUMsT0FBTzthQUNwQixJQUFJLENBQUM7WUFDRixFQUFFLENBQUMsQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQyxNQUFNLEtBQUssQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDO2dCQUMzQyxJQUFJLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsQ0FBQTtZQUMzQixDQUFDO1lBQUMsSUFBSSxDQUFDLENBQUM7Z0JBQ0osSUFBSSxDQUFDLE1BQU0sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUE7WUFDMUIsQ0FBQztRQUNMLENBQUMsQ0FBQyxDQUFBO1FBQ04sTUFBTSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUE7SUFDdkIsQ0FBQztJQUVEOztPQUVHO0lBQ0gsVUFBVTtRQUNOLElBQUksQ0FBQyxJQUFJLEdBQUcsSUFBSSxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUE7UUFDMUIsSUFBSSxDQUFDLFlBQVksQ0FBQyxPQUFPLEVBQUUsQ0FBQTtRQUMzQixNQUFNLENBQUE7SUFDVixDQUFDO0NBRUo7QUEvSUQsNEJBK0lDIn0=
|
|
7
dist/smartcli.plugins.d.ts
vendored
7
dist/smartcli.plugins.d.ts
vendored
@ -1,7 +0,0 @@
|
|||||||
import 'typings-global';
|
|
||||||
import * as yargs from 'yargs';
|
|
||||||
import * as beautylog from 'beautylog';
|
|
||||||
import * as lik from 'lik';
|
|
||||||
import * as path from 'path';
|
|
||||||
import * as smartparam from 'smartparam';
|
|
||||||
export { yargs, beautylog, lik, path, smartparam };
|
|
13
dist/smartcli.plugins.js
vendored
13
dist/smartcli.plugins.js
vendored
@ -1,13 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
require("typings-global");
|
|
||||||
const yargs = require("yargs");
|
|
||||||
exports.yargs = yargs;
|
|
||||||
const beautylog = require("beautylog");
|
|
||||||
exports.beautylog = beautylog;
|
|
||||||
const lik = require("lik");
|
|
||||||
exports.lik = lik;
|
|
||||||
const path = require("path");
|
|
||||||
exports.path = path;
|
|
||||||
const smartparam = require("smartparam");
|
|
||||||
exports.smartparam = smartparam;
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRjbGkucGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0Y2xpLnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDBCQUF1QjtBQUV2QiwrQkFBOEI7QUFPMUIsc0JBQUs7QUFOVCx1Q0FBc0M7QUFPbEMsOEJBQVM7QUFOYiwyQkFBMEI7QUFPdEIsa0JBQUc7QUFOUCw2QkFBNEI7QUFPeEIsb0JBQUk7QUFOUix5Q0FBd0M7QUFPcEMsZ0NBQVUifQ==
|
|
@ -1,15 +0,0 @@
|
|||||||
{
|
|
||||||
"structure": {
|
|
||||||
"readme": "index.md"
|
|
||||||
},
|
|
||||||
"plugins": [
|
|
||||||
"tonic",
|
|
||||||
"edit-link"
|
|
||||||
],
|
|
||||||
"pluginsConfig": {
|
|
||||||
"edit-link": {
|
|
||||||
"base": "https://gitlab.com/pushrocks/npmts/edit/master/docs/",
|
|
||||||
"label": "Edit on GitLab"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,47 +1,33 @@
|
|||||||
# smartcli
|
# smartcli
|
||||||
nodejs wrapper for CLI related tasks. TypeScript ready.
|
|
||||||
|
nodejs wrapper for CLI related tasks
|
||||||
|
|
||||||
## Availabililty
|
## Availabililty
|
||||||
[](https://www.npmjs.com/package/smartcli)
|
|
||||||
[](https://gitlab.com/pushrocks/smartcli)
|
[](https://www.npmjs.com/package/smartcli)
|
||||||
[](https://github.com/pushrocks/smartcli)
|
[](https://GitLab.com/pushrocks/smartcli)
|
||||||
[](https://pushrocks.gitlab.io/smartcli/docs)
|
[](https://github.com/pushrocks/smartcli)
|
||||||
|
[](https://pushrocks.gitlab.io/smartcli/)
|
||||||
|
|
||||||
## Status for master
|
## Status for master
|
||||||
[](https://gitlab.com/pushrocks/smartcli/commits/master)
|
|
||||||
[](https://gitlab.com/pushrocks/smartcli/commits/master)
|
[](https://GitLab.com/pushrocks/smartcli/commits/master)
|
||||||
|
[](https://GitLab.com/pushrocks/smartcli/commits/master)
|
||||||
|
[](https://www.npmjs.com/package/smartcli)
|
||||||
[](https://david-dm.org/pushrocks/smartcli)
|
[](https://david-dm.org/pushrocks/smartcli)
|
||||||
[](https://www.bithound.io/github/pushrocks/smartcli/master/dependencies/npm)
|
[](https://www.bithound.io/github/pushrocks/smartcli/master/dependencies/npm)
|
||||||
[](https://www.bithound.io/github/pushrocks/smartcli)
|
[](https://www.bithound.io/github/pushrocks/smartcli)
|
||||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||||
|
[](http://standardjs.com/)
|
||||||
## Install the package
|
|
||||||
npm install smartcli --save
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
this plugin tries to establish some logic in which CLI tools work.
|
|
||||||
|
|
||||||
take the following commandline input:
|
|
||||||
|
|
||||||
```
|
For further information read the linked docs at the top of this README.
|
||||||
mytool function argument1 argument2 --option1 -o2 option2Value
|
|
||||||
```
|
|
||||||
|
|
||||||
* 'mytool' obviously is the tool (like git)
|
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||||
* function is the main thing the tool shall do (like commit)
|
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
||||||
* argument1 and argument2 are arguments
|
|
||||||
* option1 is a longform option you can add (like --message for message)
|
|
||||||
* optionValue is the referenced option value (like a commit message)
|
|
||||||
|
|
||||||
```typescript
|
[](https://push.rocks)
|
||||||
import {Smartcli} from "smartcli"
|
|
||||||
mySmartcli = new Smartcli();
|
|
||||||
mySmartcli.standardTask()
|
|
||||||
.then(argvArg => {
|
|
||||||
// do something if program is called without an command
|
|
||||||
});
|
|
||||||
|
|
||||||
mySmartcli.question
|
|
||||||
```
|
|
||||||
|
17
npmextra.json
Normal file
17
npmextra.json
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"npmci": {
|
||||||
|
"npmGlobalTools": [],
|
||||||
|
"npmAccesslevel": "public"
|
||||||
|
},
|
||||||
|
"gitzone": {
|
||||||
|
"projectType": "npm",
|
||||||
|
"module": {
|
||||||
|
"githost": "gitlab.com",
|
||||||
|
"gitscope": "pushrocks",
|
||||||
|
"gitrepo": "smartcli",
|
||||||
|
"shortDescription": "easy observable cli tasks",
|
||||||
|
"npmPackagename": "@pushrocks/smartcli",
|
||||||
|
"license": "MIT"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"mode":"default"
|
|
||||||
}
|
|
1825
package-lock.json
generated
Normal file
1825
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
55
package.json
55
package.json
@ -1,16 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "smartcli",
|
"name": "@pushrocks/smartcli",
|
||||||
"version": "2.0.1",
|
"private": false,
|
||||||
"description": "nodejs wrapper for CLI related tasks",
|
"version": "3.0.9",
|
||||||
|
"description": "easy observable cli tasks",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"typings": "dist/index.d.ts",
|
"typings": "dist/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(npmts)",
|
"test": "(tstest test/)",
|
||||||
"testm": "(cd ts/compile && gulp) && (node test.js jazz jam --awesome)",
|
"build": "(tsbuild)"
|
||||||
"devTest": "(npm test) && (node test.js --test true)",
|
|
||||||
"reinstall": "(rm -r node_modules && npm install)",
|
|
||||||
"release": "(git pull origin master && npm version patch && git push origin master && git checkout release && git merge master && git push origin release && git checkout master)",
|
|
||||||
"startdev": "(git checkout master && git pull origin master)"
|
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -29,20 +26,32 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/smartcli",
|
"homepage": "https://gitlab.com/pushrocks/smartcli",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/q": "0.x.x",
|
"@pushrocks/lik": "^3.0.19",
|
||||||
"@types/yargs": "6.x.x",
|
"@pushrocks/smartlog": "^2.0.21",
|
||||||
"beautylog": "^6.0.0",
|
"@pushrocks/smartparam": "^1.1.6",
|
||||||
"lik": "^1.0.24",
|
"@pushrocks/smartpromise": "^3.0.6",
|
||||||
"q": "^1.4.1",
|
"@types/yargs": "^15.0.4",
|
||||||
"rxjs": "^5.0.1",
|
"rxjs": "^6.5.4",
|
||||||
"smartparam": "0.1.1",
|
"yargs": "^15.3.0"
|
||||||
"typings-global": "^1.0.14",
|
|
||||||
"yargs": "^6.4.0"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/should": "^8.1.30",
|
"@gitzone/tsbuild": "^2.1.20",
|
||||||
"npmts-g": "^5.2.8",
|
"@gitzone/tsrun": "^1.2.8",
|
||||||
"should": "^11.1.1",
|
"@gitzone/tstest": "^1.0.28",
|
||||||
"typings-test": "^1.0.3"
|
"@pushrocks/tapbundle": "^3.2.0",
|
||||||
}
|
"@types/node": "^13.9.0",
|
||||||
|
"tslint": "^6.1.0",
|
||||||
|
"tslint-config-prettier": "^1.18.0"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"ts/**/*",
|
||||||
|
"ts_web/**/*",
|
||||||
|
"dist/**/*",
|
||||||
|
"dist_web/**/*",
|
||||||
|
"dist_ts_web/**/*",
|
||||||
|
"assets/**/*",
|
||||||
|
"cli.js",
|
||||||
|
"npmextra.json",
|
||||||
|
"readme.md"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
69
readme.md
Normal file
69
readme.md
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
# @pushrocks/smartcli
|
||||||
|
easy observable cli tasks
|
||||||
|
|
||||||
|
## Availabililty and Links
|
||||||
|
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartcli)
|
||||||
|
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartcli)
|
||||||
|
* [github.com (source mirror)](https://github.com/pushrocks/smartcli)
|
||||||
|
* [docs (typedoc)](https://pushrocks.gitlab.io/smartcli/)
|
||||||
|
|
||||||
|
## Status for master
|
||||||
|
[](https://gitlab.com/pushrocks/smartcli/commits/master)
|
||||||
|
[](https://gitlab.com/pushrocks/smartcli/commits/master)
|
||||||
|
[](https://www.npmjs.com/package/@pushrocks/smartcli)
|
||||||
|
[](https://snyk.io/test/npm/@pushrocks/smartcli)
|
||||||
|
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
|
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
|
[](https://prettier.io/)
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
this plugin tries to establish some logic in which CLI tools work.
|
||||||
|
|
||||||
|
take the following commandline input:
|
||||||
|
|
||||||
|
```
|
||||||
|
mytool command argument1 argument2 --option1 -o2 option2Value
|
||||||
|
```
|
||||||
|
|
||||||
|
- `mytool` obviously is the tool (like git)
|
||||||
|
- `command` is the main thing the tool shall do (like commit)
|
||||||
|
- `argument1` and `argument2` are arguments
|
||||||
|
- `option1` is a longform option you can add (like --message for message)
|
||||||
|
- `optionValue` is the referenced option value (like a commit message)
|
||||||
|
|
||||||
|
When there is no command and no option specified the standardTask applied.
|
||||||
|
When there is a option specified but no command, standardTask applies,
|
||||||
|
except when of the options is -v, --version or --help.
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
import { Smartcli } from 'smartcli';
|
||||||
|
mySmartcli = new Smartcli();
|
||||||
|
mySmartcli.standardTask().then(argvArg => {
|
||||||
|
// do something if program is called without an command
|
||||||
|
});
|
||||||
|
|
||||||
|
mySmartcli.addCommand({ commandname: 'install' }).then(argvArg => {
|
||||||
|
// do something if program is called with command "install"
|
||||||
|
});
|
||||||
|
|
||||||
|
mySmartcli.addVersion('1.0.0'); // -v and --version options will display the specified version in the terminal
|
||||||
|
|
||||||
|
mySmartCli.addHelp({
|
||||||
|
// is triggered by help command and --help option
|
||||||
|
helpText: 'some help text to print' // the helpText to display
|
||||||
|
});
|
||||||
|
|
||||||
|
mySmartcli.startParse(); // starts the evaluation and fullfills or rejects promises.
|
||||||
|
```
|
||||||
|
|
||||||
|
## 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.
|
||||||
|
|
||||||
|
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||||
|
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||||
|
|
||||||
|
[](https://maintainedby.lossless.com)
|
1
test/test.d.ts
vendored
1
test/test.d.ts
vendored
@ -1 +0,0 @@
|
|||||||
import 'typings-test';
|
|
51
test/test.js
51
test/test.js
@ -1,51 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
require("typings-test");
|
|
||||||
const smartcli = require("../dist/index");
|
|
||||||
const should = require("should");
|
|
||||||
describe('smartcli.Smartcli class', function () {
|
|
||||||
let smartCliTestObject;
|
|
||||||
describe('new Smartcli()', function () {
|
|
||||||
it('should create a new Smartcli', function () {
|
|
||||||
smartCliTestObject = new smartcli.Smartcli();
|
|
||||||
should(smartCliTestObject).be.instanceof(smartcli.Smartcli);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
describe('.addCommand', function () {
|
|
||||||
it('should add an command', function () {
|
|
||||||
smartCliTestObject.addCommand('awesome');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
describe('.standardTask', function () {
|
|
||||||
it('should start parsing a standardTask', function (done) {
|
|
||||||
smartCliTestObject.standardTask()
|
|
||||||
.then(() => {
|
|
||||||
console.log('this is the standard Task!');
|
|
||||||
});
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
describe('.trigger', function () {
|
|
||||||
let hasExecuted = false;
|
|
||||||
it('should accept a command', function (done) {
|
|
||||||
smartCliTestObject.addTrigger('triggerme')
|
|
||||||
.subscribe(() => {
|
|
||||||
hasExecuted = true;
|
|
||||||
});
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
it('should not have executed yet', function () {
|
|
||||||
should(hasExecuted).be.false();
|
|
||||||
});
|
|
||||||
it('should execute when triggered', function (done) {
|
|
||||||
smartCliTestObject.trigger('triggerme');
|
|
||||||
should(hasExecuted).be.true();
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
describe('.startParse', function () {
|
|
||||||
it('should start parsing the CLI input', function () {
|
|
||||||
smartCliTestObject.startParse();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLHdCQUFxQjtBQUVyQiwwQ0FBMEM7QUFDMUMsaUNBQWdDO0FBRWhDLFFBQVEsQ0FBQyx5QkFBeUIsRUFBQztJQUMvQixJQUFJL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AAC;AACvD,CAAC,CAAC;AAEF,EAAE,CAAA,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAA,CAAC;IACjC,wBAAwB,EAAE,CAAC;AAC/B,CAAC;AAAC,IAAI,CAAC,CAAC;IACJ,SAAS,CAAC,IAAI,CAAC,0EAA0E,CAAC,CAAC;IAC3F,QAAQ,EAAE,CAAC;AACf,CAAC;AAAA,CAAC"}
|
|
90
test/test.ts
90
test/test.ts
@ -1,51 +1,43 @@
|
|||||||
import 'typings-test'
|
import { tap, expect } from '@pushrocks/tapbundle';
|
||||||
|
import { Subject } from 'rxjs';
|
||||||
|
|
||||||
import smartcli = require('../dist/index')
|
import smartcli = require('../ts/index');
|
||||||
import * as should from 'should'
|
|
||||||
|
|
||||||
describe('smartcli.Smartcli class',function(){
|
let smartCliTestObject: smartcli.Smartcli;
|
||||||
let smartCliTestObject: smartcli.Smartcli
|
|
||||||
describe('new Smartcli()',function(){
|
tap.test('should create a new Smartcli', async () => {
|
||||||
it('should create a new Smartcli',function(){
|
smartCliTestObject = new smartcli.Smartcli();
|
||||||
smartCliTestObject = new smartcli.Smartcli()
|
expect(smartCliTestObject).to.be.instanceof(smartcli.Smartcli);
|
||||||
should(smartCliTestObject).be.instanceof(smartcli.Smartcli)
|
});
|
||||||
})
|
|
||||||
})
|
tap.test('should add an command', async () => {
|
||||||
describe('.addCommand',function(){
|
expect(smartCliTestObject.addCommand('awesome')).to.be.instanceOf(Subject);
|
||||||
it('should add an command',function(){
|
});
|
||||||
smartCliTestObject.addCommand('awesome')
|
|
||||||
})
|
tap.test('should start parsing a standardTask', async () => {
|
||||||
})
|
expect(smartCliTestObject.standardTask()).to.be.instanceOf(Subject);
|
||||||
describe('.standardTask',function(){
|
});
|
||||||
it('should start parsing a standardTask',function(done){
|
|
||||||
smartCliTestObject.standardTask()
|
let hasExecuted: boolean = false;
|
||||||
.then(() => {
|
|
||||||
console.log('this is the standard Task!')
|
tap.test('should accept a command', async () => {
|
||||||
})
|
smartCliTestObject.addTrigger('triggerme').subscribe(() => {
|
||||||
done()
|
hasExecuted = true;
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
describe('.trigger', function() {
|
|
||||||
let hasExecuted = false
|
tap.test('should not have executed yet', async () => {
|
||||||
it('should accept a command', function(done) {
|
expect(hasExecuted).to.be.false;
|
||||||
smartCliTestObject.addTrigger('triggerme')
|
});
|
||||||
.subscribe(() => {
|
|
||||||
hasExecuted = true
|
tap.test('should execute when triggered', async () => {
|
||||||
})
|
smartCliTestObject.trigger('triggerme');
|
||||||
done()
|
expect(hasExecuted).be.true;
|
||||||
})
|
});
|
||||||
it('should not have executed yet', function() {
|
|
||||||
should(hasExecuted).be.false()
|
tap.test('should start parsing the CLI input', async () => {
|
||||||
})
|
smartCliTestObject.startParse();
|
||||||
it('should execute when triggered', function(done) {
|
expect(smartCliTestObject.parseStarted.promise).to.be.instanceOf(Promise);
|
||||||
smartCliTestObject.trigger('triggerme')
|
});
|
||||||
should(hasExecuted).be.true()
|
|
||||||
done()
|
tap.start();
|
||||||
})
|
|
||||||
})
|
|
||||||
describe('.startParse',function(){
|
|
||||||
it('should start parsing the CLI input',function(){
|
|
||||||
smartCliTestObject.startParse()
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
@ -1 +1 @@
|
|||||||
export { Smartcli } from './smartcli.classes.smartcli'
|
export { Smartcli } from './smartcli.classes.smartcli';
|
||||||
|
@ -1,163 +1,165 @@
|
|||||||
import * as q from 'q'
|
import * as smartpromise from '@pushrocks/smartpromise';
|
||||||
import { Subject } from 'rxjs'
|
import { Subject } from 'rxjs';
|
||||||
|
|
||||||
import * as plugins from './smartcli.plugins'
|
import * as plugins from './smartcli.plugins';
|
||||||
|
|
||||||
// import classes
|
// import classes
|
||||||
import { Objectmap } from 'lik'
|
import { Objectmap } from '@pushrocks/lik';
|
||||||
|
|
||||||
// interfaces
|
// interfaces
|
||||||
export interface ICommandPromiseObject {
|
export interface ICommandPromiseObject {
|
||||||
commandName: string,
|
commandName: string;
|
||||||
promise: q.Promise<void>
|
promise: Promise<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ITriggerObservableObject {
|
export interface ITriggerObservableObject {
|
||||||
triggerName: string
|
triggerName: string;
|
||||||
subject: Subject<any>
|
subject: Subject<any>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* class to create a new instance of Smartcli. Handles parsing of command line arguments.
|
||||||
|
*/
|
||||||
export class Smartcli {
|
export class Smartcli {
|
||||||
argv: any
|
argv: any;
|
||||||
questionsDone
|
questionsDone;
|
||||||
parseStarted
|
parseStarted: smartpromise.Deferred<any>;
|
||||||
commands
|
commands;
|
||||||
questions
|
questions;
|
||||||
version: string
|
version: string;
|
||||||
|
private onlyOnProcessEnvCliCall = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* map of all Command/Promise objects to keep track
|
* map of all Trigger/Observable objects to keep track
|
||||||
*/
|
*/
|
||||||
allCommandPromisesMap = new Objectmap<ICommandPromiseObject>()
|
allTriggerObservablesMap = new Objectmap<ITriggerObservableObject>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* map of all Trigger/Observable objects to keep track
|
* The constructor of Smartcli
|
||||||
*/
|
*/
|
||||||
allTriggerObservablesMap = new Objectmap<ITriggerObservableObject>()
|
constructor() {
|
||||||
|
this.argv = plugins.yargs;
|
||||||
|
this.questionsDone = smartpromise.defer();
|
||||||
|
this.parseStarted = smartpromise.defer();
|
||||||
|
}
|
||||||
|
|
||||||
constructor() {
|
/**
|
||||||
this.argv = plugins.yargs
|
* halts any execution of commands if (process.env.CLI_CALL === false)
|
||||||
this.questionsDone = q.defer()
|
*/
|
||||||
this.parseStarted = q.defer()
|
onlyTriggerOnProcessEnvCliCall() {
|
||||||
|
this.onlyOnProcessEnvCliCall = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* adds an alias, meaning one equals the other in terms of command execution.
|
||||||
|
*/
|
||||||
|
addCommandAlias(keyArg, aliasArg): void {
|
||||||
|
this.argv = this.argv.alias(keyArg, aliasArg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* adds a Command by returning a Promise that reacts to the specific commandString given.
|
||||||
|
* Note: in e.g. "npm install something" the "install" is considered the command.
|
||||||
|
*/
|
||||||
|
addCommand(commandNameArg: string): Subject<any> {
|
||||||
|
let triggerSubject = this.addTrigger(commandNameArg);
|
||||||
|
this.parseStarted.promise.then(() => {
|
||||||
|
if (this.argv._.indexOf(commandNameArg) === 0) {
|
||||||
|
this.trigger(commandNameArg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return triggerSubject;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* adds a Trigger. Like addCommand(), but returns an subscribable observable
|
||||||
|
*/
|
||||||
|
addTrigger(triggerNameArg: string) {
|
||||||
|
let triggerSubject = new Subject<any>();
|
||||||
|
if (!this.getTriggerSubject(triggerNameArg)) {
|
||||||
|
this.allTriggerObservablesMap.add({
|
||||||
|
triggerName: triggerNameArg,
|
||||||
|
subject: triggerSubject
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
throw new Error(`you can't add a trigger twice`);
|
||||||
}
|
}
|
||||||
|
return triggerSubject;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* adds an alias, meaning one equals the other in terms of command execution.
|
* execute trigger by name
|
||||||
*/
|
* @param commandNameArg - the name of the command to trigger
|
||||||
addCommandAlias(keyArg,aliasArg): void {
|
*/
|
||||||
this.argv = this.argv.alias(keyArg,aliasArg)
|
trigger(triggerName: string) {
|
||||||
return
|
let triggerSubject = this.getTriggerSubject(triggerName);
|
||||||
|
triggerSubject.next(this.argv);
|
||||||
|
return triggerSubject;
|
||||||
|
}
|
||||||
|
|
||||||
|
getTriggerSubject(triggerName: string) {
|
||||||
|
const triggerObservableObject = this.allTriggerObservablesMap.find(
|
||||||
|
triggerObservableObjectArg => {
|
||||||
|
return triggerObservableObjectArg.triggerName === triggerName;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
if (triggerObservableObject) {
|
||||||
|
return triggerObservableObject.subject;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* adds a Command by returning a Promise that reacts to the specific commandString given.
|
* allows to specify help text to be printed above the rest of the help text
|
||||||
* Note: in e.g. "npm install something" the "install" is considered the command.
|
*/
|
||||||
*/
|
addHelp(optionsArg: { helpText: string }) {
|
||||||
addCommand(commandNameArg: string): q.Promise<any> {
|
this.addCommand('help').subscribe(argvArg => {
|
||||||
let done = q.defer<any>()
|
plugins.smartlog.defaultLogger.log('info', optionsArg.helpText);
|
||||||
this.allCommandPromisesMap.add({
|
});
|
||||||
commandName: commandNameArg,
|
}
|
||||||
promise: done.promise
|
|
||||||
})
|
|
||||||
this.parseStarted.promise
|
|
||||||
.then(() => {
|
|
||||||
if (this.argv._.indexOf(commandNameArg) === 0) {
|
|
||||||
done.resolve(this.argv)
|
|
||||||
} else {
|
|
||||||
done.reject(this.argv)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return done.promise
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gets a Promise for a command word
|
* specify version to be printed for -v --version
|
||||||
*/
|
*/
|
||||||
getCommandPromiseByName(commandNameArg: string): q.Promise<void> {
|
addVersion(versionArg: string) {
|
||||||
return this.allCommandPromisesMap.find(commandDeferredObjectArg => {
|
this.version = versionArg;
|
||||||
return commandDeferredObjectArg.commandName === commandNameArg
|
this.addCommandAlias('v', 'version');
|
||||||
}).promise
|
this.parseStarted.promise.then(() => {
|
||||||
}
|
if (this.argv.v) {
|
||||||
|
console.log(this.version);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* adds a Trigger. Like addCommand(), but returns an subscribable observable
|
* adds a trigger that is called when no command is specified
|
||||||
*/
|
*/
|
||||||
addTrigger(triggerNameArg: string) {
|
standardTask(): Subject<any> {
|
||||||
let triggerSubject = new Subject<any>()
|
let standardSubject = this.addTrigger('standardTask');
|
||||||
this.allTriggerObservablesMap.add({
|
this.parseStarted.promise.then(() => {
|
||||||
triggerName: triggerNameArg,
|
if (this.argv._.length === 0 && !this.argv.v) {
|
||||||
subject: triggerSubject
|
if (this.onlyOnProcessEnvCliCall) {
|
||||||
})
|
if (process.env.CLI_CALL === 'true') {
|
||||||
this.addCommand(triggerNameArg).then(() => {
|
this.trigger('standardTask');
|
||||||
triggerSubject.next(this.argv)
|
} else {
|
||||||
})
|
return;
|
||||||
return triggerSubject
|
}
|
||||||
}
|
} else {
|
||||||
|
this.trigger('standardTask');
|
||||||
/**
|
}
|
||||||
* execute trigger by name
|
}
|
||||||
* @param commandNameArg - the name of the command to trigger
|
});
|
||||||
*/
|
return standardSubject;
|
||||||
trigger(triggerName: string) {
|
}
|
||||||
let triggerSubject = this.allTriggerObservablesMap.find(triggerObservableObjectArg => {
|
|
||||||
return triggerObservableObjectArg.triggerName === triggerName
|
|
||||||
}).subject
|
|
||||||
triggerSubject.next(this.argv)
|
|
||||||
return triggerSubject
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* allows to specify help text to be printed above the rest of the help text
|
|
||||||
*/
|
|
||||||
addHelp(optionsArg: {
|
|
||||||
helpText: string
|
|
||||||
}) {
|
|
||||||
this.addCommand('help').then(argvArg => {
|
|
||||||
plugins.beautylog.log(optionsArg.helpText)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* specify version to be printed for -v --version
|
|
||||||
*/
|
|
||||||
addVersion(versionArg: string) {
|
|
||||||
this.version = versionArg
|
|
||||||
this.addCommandAlias('v','version')
|
|
||||||
this.parseStarted.promise
|
|
||||||
.then(() => {
|
|
||||||
if (this.argv.v) {
|
|
||||||
console.log(this.version)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* returns promise that is resolved when no commands are specified
|
|
||||||
*/
|
|
||||||
standardTask(): q.Promise<any> {
|
|
||||||
let done = q.defer<any>()
|
|
||||||
this.allCommandPromisesMap.add({
|
|
||||||
commandName: 'standard',
|
|
||||||
promise: done.promise
|
|
||||||
})
|
|
||||||
this.parseStarted.promise
|
|
||||||
.then(() => {
|
|
||||||
if (this.argv._.length === 0 && !this.argv.v) {
|
|
||||||
done.resolve(this.argv)
|
|
||||||
} else {
|
|
||||||
done.reject(this.argv)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return done.promise
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* start the process of evaluating commands
|
|
||||||
*/
|
|
||||||
startParse(): void {
|
|
||||||
this.argv = this.argv.argv
|
|
||||||
this.parseStarted.resolve()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* start the process of evaluating commands
|
||||||
|
*/
|
||||||
|
startParse(): void {
|
||||||
|
this.argv = this.argv.argv;
|
||||||
|
this.parseStarted.resolve();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,7 @@
|
|||||||
import 'typings-global'
|
import * as yargs from 'yargs';
|
||||||
|
import * as smartlog from '@pushrocks/smartlog';
|
||||||
|
import * as lik from '@pushrocks/lik';
|
||||||
|
import * as path from 'path';
|
||||||
|
import * as smartparam from '@pushrocks/smartparam';
|
||||||
|
|
||||||
import * as yargs from 'yargs'
|
export { yargs, smartlog, lik, path, smartparam };
|
||||||
import * as beautylog from 'beautylog'
|
|
||||||
import * as lik from 'lik'
|
|
||||||
import * as path from 'path'
|
|
||||||
import * as smartparam from 'smartparam'
|
|
||||||
|
|
||||||
export {
|
|
||||||
yargs,
|
|
||||||
beautylog,
|
|
||||||
lik,
|
|
||||||
path,
|
|
||||||
smartparam
|
|
||||||
}
|
|
||||||
|
16
tslint.json
16
tslint.json
@ -1,3 +1,17 @@
|
|||||||
{
|
{
|
||||||
"extends": "tslint-config-standard"
|
"extends": ["tslint:latest", "tslint-config-prettier"],
|
||||||
|
"rules": {
|
||||||
|
"semicolon": [true, "always"],
|
||||||
|
"no-console": false,
|
||||||
|
"ordered-imports": false,
|
||||||
|
"object-literal-sort-keys": false,
|
||||||
|
"member-ordering": {
|
||||||
|
"options":{
|
||||||
|
"order": [
|
||||||
|
"static-method"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"defaultSeverity": "warning"
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user