Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
b036e609ce | |||
c2ec0df907 | |||
167b4d29df | |||
02fec216db | |||
4e9d2f3e8c | |||
65d8a8b6f5 | |||
8e04bd6a62 | |||
687a5f7c4e | |||
17983b1da9 | |||
5fcdf1ff8f |
18
.gitignore
vendored
18
.gitignore
vendored
@ -1,4 +1,20 @@
|
|||||||
node_modules/
|
.nogit/
|
||||||
|
|
||||||
|
# artifacts
|
||||||
coverage/
|
coverage/
|
||||||
public/
|
public/
|
||||||
|
pages/
|
||||||
|
|
||||||
|
# installs
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# caches
|
||||||
.yarn/
|
.yarn/
|
||||||
|
.cache/
|
||||||
|
.rpt2_cache
|
||||||
|
|
||||||
|
# builds
|
||||||
|
dist/
|
||||||
|
dist_*/
|
||||||
|
|
||||||
|
# custom
|
114
.gitlab-ci.yml
114
.gitlab-ci.yml
@ -1,16 +1,16 @@
|
|||||||
# gitzone standard
|
# gitzone ci_default
|
||||||
image: hosttoday/ht-docker-node:npmci
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
paths:
|
paths:
|
||||||
- .npmci_cache/
|
- .npmci_cache/
|
||||||
key: "$CI_BUILD_STAGE"
|
key: '$CI_BUILD_STAGE'
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- security
|
- security
|
||||||
- test
|
- test
|
||||||
- release
|
- release
|
||||||
- metadata
|
- metadata
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# security stage
|
# security stage
|
||||||
@ -18,102 +18,104 @@ stages:
|
|||||||
mirror:
|
mirror:
|
||||||
stage: security
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci git mirror
|
- npmci git mirror
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- lossless
|
||||||
- notpriv
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
snyk:
|
audit:
|
||||||
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
stage: security
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci command npm install -g snyk
|
|
||||||
- npmci command npm install --ignore-scripts
|
- npmci command npm install --ignore-scripts
|
||||||
- npmci command snyk test
|
- npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
- npmci command npm audit --audit-level=high
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- lossless
|
||||||
- notpriv
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# test stage
|
# test stage
|
||||||
# ====================
|
# ====================
|
||||||
|
|
||||||
testLTS:
|
testStable:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci node install lts
|
- npmci node install stable
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci npm test
|
- npmci npm test
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- lossless
|
||||||
- notpriv
|
- docker
|
||||||
|
- priv
|
||||||
|
|
||||||
testSTABLE:
|
testBuild:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci node install stable
|
- npmci node install stable
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci npm test
|
- npmci command npm run build
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- lossless
|
||||||
- notpriv
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
release:
|
release:
|
||||||
stage: release
|
stage: release
|
||||||
script:
|
script:
|
||||||
- npmci node install stable
|
- npmci node install stable
|
||||||
- npmci npm publish
|
- npmci npm publish
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- lossless
|
||||||
- notpriv
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# metadata stage
|
# metadata stage
|
||||||
# ====================
|
# ====================
|
||||||
codequality:
|
codequality:
|
||||||
stage: metadata
|
stage: metadata
|
||||||
image: docker:stable
|
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
services:
|
|
||||||
- docker:stable-dind
|
|
||||||
script:
|
script:
|
||||||
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
|
- npmci command npm install -g tslint typescript
|
||||||
- docker run
|
- npmci npm prepare
|
||||||
--env SOURCE_CODE="$PWD"
|
- npmci npm install
|
||||||
--volume "$PWD":/code
|
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
||||||
--volume /var/run/docker.sock:/var/run/docker.sock
|
|
||||||
"registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
|
|
||||||
artifacts:
|
|
||||||
paths: [codeclimate.json]
|
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- lossless
|
||||||
- priv
|
- docker
|
||||||
|
- priv
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
stage: metadata
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
- npmci trigger
|
- npmci trigger
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- lossless
|
||||||
- notpriv
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
pages:
|
pages:
|
||||||
image: hosttoday/ht-docker-node:npmci
|
|
||||||
stage: metadata
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
- npmci command npm install -g typedoc typescript
|
- npmci node install lts
|
||||||
|
- npmci command npm install -g @gitzone/tsdoc
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
|
- npmci command tsdoc
|
||||||
tags:
|
tags:
|
||||||
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
only:
|
only:
|
||||||
@ -121,5 +123,5 @@ pages:
|
|||||||
artifacts:
|
artifacts:
|
||||||
expire_in: 1 week
|
expire_in: 1 week
|
||||||
paths:
|
paths:
|
||||||
- public
|
- public
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
|
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"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
29
README.md
29
README.md
@ -1,29 +0,0 @@
|
|||||||
# smartcli
|
|
||||||
|
|
||||||
nodejs wrapper for CLI related tasks
|
|
||||||
|
|
||||||
## Availabililty
|
|
||||||
|
|
||||||
[](https://www.npmjs.com/package/smartcli)
|
|
||||||
[](https://GitLab.com/pushrocks/smartcli)
|
|
||||||
[](https://github.com/pushrocks/smartcli)
|
|
||||||
[](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/smartcli)
|
|
||||||
[](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/)
|
|
||||||
[](http://standardjs.com/)
|
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
[](https://)
|
|
@ -23,45 +23,6 @@ nodejs wrapper for CLI related tasks
|
|||||||
|
|
||||||
## Usage
|
## 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.
|
|
||||||
```
|
|
||||||
|
|
||||||
For further information read the linked docs at the top of this README.
|
For further information read the linked docs at the top of this README.
|
||||||
|
|
||||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||||
|
@ -2,5 +2,16 @@
|
|||||||
"npmci": {
|
"npmci": {
|
||||||
"npmGlobalTools": [],
|
"npmGlobalTools": [],
|
||||||
"npmAccesslevel": "public"
|
"npmAccesslevel": "public"
|
||||||
|
},
|
||||||
|
"gitzone": {
|
||||||
|
"projectType": "npm",
|
||||||
|
"module": {
|
||||||
|
"githost": "gitlab.com",
|
||||||
|
"gitscope": "pushrocks",
|
||||||
|
"gitrepo": "smartcli",
|
||||||
|
"shortDescription": "easy observable cli tasks",
|
||||||
|
"npmPackagename": "@pushrocks/smartcli",
|
||||||
|
"license": "MIT"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
1588
package-lock.json
generated
1588
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
50
package.json
50
package.json
@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartcli",
|
"name": "@pushrocks/smartcli",
|
||||||
"private": false,
|
"private": false,
|
||||||
"version": "3.0.7",
|
"version": "3.0.12",
|
||||||
"description": "nodejs wrapper for CLI related tasks",
|
"description": "easy observable cli tasks",
|
||||||
"main": "dist/index.js",
|
"main": "dist_ts/index.js",
|
||||||
"typings": "dist/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(tstest test/)",
|
"test": "(tstest test/)",
|
||||||
"build": "(tsbuild)"
|
"build": "(tsbuild)"
|
||||||
@ -26,21 +26,33 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/smartcli",
|
"homepage": "https://gitlab.com/pushrocks/smartcli",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/lik": "^3.0.4",
|
"@pushrocks/lik": "^4.0.13",
|
||||||
"@pushrocks/smartlog": "^2.0.9",
|
"@pushrocks/smartlog": "^2.0.21",
|
||||||
"@pushrocks/smartparam": "^1.0.4",
|
"@pushrocks/smartparam": "^1.1.6",
|
||||||
"@pushrocks/smartpromise": "^2.0.5",
|
"@pushrocks/smartpromise": "^3.0.6",
|
||||||
"@types/yargs": "^12.0.1",
|
"@types/yargs": "^15.0.5",
|
||||||
"rxjs": "^6.3.3",
|
"rxjs": "^6.5.5",
|
||||||
"yargs": "^12.0.5"
|
"yargs": "^15.3.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.3",
|
"@gitzone/tsbuild": "^2.1.24",
|
||||||
"@gitzone/tsrun": "^1.1.17",
|
"@gitzone/tsrun": "^1.2.8",
|
||||||
"@gitzone/tstest": "^1.0.18",
|
"@gitzone/tstest": "^1.0.28",
|
||||||
"@pushrocks/tapbundle": "^3.0.7",
|
"@pushrocks/tapbundle": "^3.2.1",
|
||||||
"@types/node": "^10.12.12",
|
"@types/node": "^14.0.5",
|
||||||
"tslint": "^5.11.0",
|
"tslint": "^6.1.2",
|
||||||
"tslint-config-prettier": "^1.17.0"
|
"tslint-config-prettier": "^1.18.0"
|
||||||
}
|
},
|
||||||
|
"files": [
|
||||||
|
"ts/**/*",
|
||||||
|
"ts_web/**/*",
|
||||||
|
"dist/**/*",
|
||||||
|
"dist_*/**/*",
|
||||||
|
"dist_ts/**/*",
|
||||||
|
"dist_ts_web/**/*",
|
||||||
|
"assets/**/*",
|
||||||
|
"cli.js",
|
||||||
|
"npmextra.json",
|
||||||
|
"readme.md"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
76
readme.md
Normal file
76
readme.md
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
# @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
|
||||||
|
|
||||||
|
Status Category | Status Badge
|
||||||
|
-- | --
|
||||||
|
GitLab Pipelines | [](https://lossless.cloud)
|
||||||
|
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
||||||
|
npm | [](https://lossless.cloud)
|
||||||
|
Snyk | [](https://lossless.cloud)
|
||||||
|
TypeScript Support | [](https://lossless.cloud)
|
||||||
|
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
|
Code Style | [](https://lossless.cloud)
|
||||||
|
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
||||||
|
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
||||||
|
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
||||||
|
Platform support | [](https://lossless.cloud) [](https://lossless.cloud)
|
||||||
|
|
||||||
|
## 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)
|
@ -4,7 +4,7 @@ import { Subject } from 'rxjs';
|
|||||||
import * as plugins from './smartcli.plugins';
|
import * as plugins from './smartcli.plugins';
|
||||||
|
|
||||||
// import classes
|
// import classes
|
||||||
import { Objectmap } from '@pushrocks/lik';
|
import { ObjectMap } from '@pushrocks/lik';
|
||||||
|
|
||||||
// interfaces
|
// interfaces
|
||||||
export interface ICommandPromiseObject {
|
export interface ICommandPromiseObject {
|
||||||
@ -27,12 +27,12 @@ export class Smartcli {
|
|||||||
commands;
|
commands;
|
||||||
questions;
|
questions;
|
||||||
version: string;
|
version: string;
|
||||||
private onlyOnProcessEnvCliCall = false;
|
private checkForEnvCliCall = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* map of all Trigger/Observable objects to keep track
|
* map of all Trigger/Observable objects to keep track
|
||||||
*/
|
*/
|
||||||
allTriggerObservablesMap = new Objectmap<ITriggerObservableObject>();
|
allTriggerObservablesMap = new ObjectMap<ITriggerObservableObject>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The constructor of Smartcli
|
* The constructor of Smartcli
|
||||||
@ -46,8 +46,8 @@ export class Smartcli {
|
|||||||
/**
|
/**
|
||||||
* halts any execution of commands if (process.env.CLI_CALL === false)
|
* halts any execution of commands if (process.env.CLI_CALL === false)
|
||||||
*/
|
*/
|
||||||
onlyTriggerOnProcessEnvCliCall() {
|
disableEnvCliCall() {
|
||||||
this.onlyOnProcessEnvCliCall = true;
|
this.checkForEnvCliCall = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -63,7 +63,7 @@ export class Smartcli {
|
|||||||
* Note: in e.g. "npm install something" the "install" is considered the command.
|
* Note: in e.g. "npm install something" the "install" is considered the command.
|
||||||
*/
|
*/
|
||||||
addCommand(commandNameArg: string): Subject<any> {
|
addCommand(commandNameArg: string): Subject<any> {
|
||||||
let triggerSubject = this.addTrigger(commandNameArg);
|
const triggerSubject = this.addTrigger(commandNameArg);
|
||||||
this.parseStarted.promise.then(() => {
|
this.parseStarted.promise.then(() => {
|
||||||
if (this.argv._.indexOf(commandNameArg) === 0) {
|
if (this.argv._.indexOf(commandNameArg) === 0) {
|
||||||
this.trigger(commandNameArg);
|
this.trigger(commandNameArg);
|
||||||
@ -76,7 +76,7 @@ export class Smartcli {
|
|||||||
* adds a Trigger. Like addCommand(), but returns an subscribable observable
|
* adds a Trigger. Like addCommand(), but returns an subscribable observable
|
||||||
*/
|
*/
|
||||||
addTrigger(triggerNameArg: string) {
|
addTrigger(triggerNameArg: string) {
|
||||||
let triggerSubject = new Subject<any>();
|
const triggerSubject = new Subject<any>();
|
||||||
if (!this.getTriggerSubject(triggerNameArg)) {
|
if (!this.getTriggerSubject(triggerNameArg)) {
|
||||||
this.allTriggerObservablesMap.add({
|
this.allTriggerObservablesMap.add({
|
||||||
triggerName: triggerNameArg,
|
triggerName: triggerNameArg,
|
||||||
@ -93,7 +93,7 @@ export class Smartcli {
|
|||||||
* @param commandNameArg - the name of the command to trigger
|
* @param commandNameArg - the name of the command to trigger
|
||||||
*/
|
*/
|
||||||
trigger(triggerName: string) {
|
trigger(triggerName: string) {
|
||||||
let triggerSubject = this.getTriggerSubject(triggerName);
|
const triggerSubject = this.getTriggerSubject(triggerName);
|
||||||
triggerSubject.next(this.argv);
|
triggerSubject.next(this.argv);
|
||||||
return triggerSubject;
|
return triggerSubject;
|
||||||
}
|
}
|
||||||
@ -137,18 +137,14 @@ export class Smartcli {
|
|||||||
* adds a trigger that is called when no command is specified
|
* adds a trigger that is called when no command is specified
|
||||||
*/
|
*/
|
||||||
standardTask(): Subject<any> {
|
standardTask(): Subject<any> {
|
||||||
let standardSubject = this.addTrigger('standardTask');
|
const standardSubject = this.addTrigger('standardTask');
|
||||||
this.parseStarted.promise.then(() => {
|
this.parseStarted.promise.then(() => {
|
||||||
if (this.argv._.length === 0 && !this.argv.v) {
|
if (
|
||||||
if (this.onlyOnProcessEnvCliCall) {
|
(this.argv._.length === 0 ||
|
||||||
if (process.env.CLI_CALL === 'true') {
|
(this.argv._.length === 1 && this.argv._[0].startsWith('test/'))) &&
|
||||||
this.trigger('standardTask');
|
!this.argv.v
|
||||||
} else {
|
) {
|
||||||
return;
|
this.trigger('standardTask');
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.trigger('standardTask');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return standardSubject;
|
return standardSubject;
|
||||||
@ -158,6 +154,12 @@ export class Smartcli {
|
|||||||
* start the process of evaluating commands
|
* start the process of evaluating commands
|
||||||
*/
|
*/
|
||||||
startParse(): void {
|
startParse(): void {
|
||||||
|
if (!process.env.CLI_CALL && this.checkForEnvCliCall) {
|
||||||
|
console.log(
|
||||||
|
`note: @pushrocks/smartcli: You called .startParse() on a SmartCli instance. However process.env.CLI_CALL being absent prevented parsing.`
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.argv = this.argv.argv;
|
this.argv = this.argv.argv;
|
||||||
this.parseStarted.resolve();
|
this.parseStarted.resolve();
|
||||||
return;
|
return;
|
||||||
|
Reference in New Issue
Block a user