Compare commits

..

6 Commits

Author SHA1 Message Date
b036e609ce 3.0.12 2020-05-29 17:48:18 +00:00
c2ec0df907 fix(core): update 2020-05-29 17:48:17 +00:00
167b4d29df 3.0.11 2020-04-13 21:53:18 +00:00
02fec216db fix(core): more consistent handling of process.enc.CLI_CALL 2020-04-13 21:53:18 +00:00
4e9d2f3e8c 3.0.10 2020-04-13 21:44:27 +00:00
65d8a8b6f5 fix(core): now works better with tapbundle tests 2020-04-13 21:44:27 +00:00
7 changed files with 262 additions and 563 deletions

4
.gitignore vendored
View File

@ -15,8 +15,6 @@ node_modules/
# builds # builds
dist/ dist/
dist_web/ dist_*/
dist_serve/
dist_ts_web/
# custom # custom

View File

@ -24,13 +24,14 @@ mirror:
- docker - docker
- notpriv - notpriv
snyk: audit:
image: registry.gitlab.com/hosttoday/ht-docker-node:snyk 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 --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:
- lossless - lossless
- docker - docker

View File

@ -23,8 +23,6 @@ nodejs wrapper for CLI related tasks
## Usage ## Usage
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)

726
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,10 +1,10 @@
{ {
"name": "@pushrocks/smartcli", "name": "@pushrocks/smartcli",
"private": false, "private": false,
"version": "3.0.9", "version": "3.0.12",
"description": "easy observable cli 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,28 +26,29 @@
}, },
"homepage": "https://gitlab.com/pushrocks/smartcli", "homepage": "https://gitlab.com/pushrocks/smartcli",
"dependencies": { "dependencies": {
"@pushrocks/lik": "^3.0.19", "@pushrocks/lik": "^4.0.13",
"@pushrocks/smartlog": "^2.0.21", "@pushrocks/smartlog": "^2.0.21",
"@pushrocks/smartparam": "^1.1.6", "@pushrocks/smartparam": "^1.1.6",
"@pushrocks/smartpromise": "^3.0.6", "@pushrocks/smartpromise": "^3.0.6",
"@types/yargs": "^15.0.4", "@types/yargs": "^15.0.5",
"rxjs": "^6.5.4", "rxjs": "^6.5.5",
"yargs": "^15.3.0" "yargs": "^15.3.1"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.20", "@gitzone/tsbuild": "^2.1.24",
"@gitzone/tsrun": "^1.2.8", "@gitzone/tsrun": "^1.2.8",
"@gitzone/tstest": "^1.0.28", "@gitzone/tstest": "^1.0.28",
"@pushrocks/tapbundle": "^3.2.0", "@pushrocks/tapbundle": "^3.2.1",
"@types/node": "^13.9.0", "@types/node": "^14.0.5",
"tslint": "^6.1.0", "tslint": "^6.1.2",
"tslint-config-prettier": "^1.18.0" "tslint-config-prettier": "^1.18.0"
}, },
"files": [ "files": [
"ts/**/*", "ts/**/*",
"ts_web/**/*", "ts_web/**/*",
"dist/**/*", "dist/**/*",
"dist_web/**/*", "dist_*/**/*",
"dist_ts/**/*",
"dist_ts_web/**/*", "dist_ts_web/**/*",
"assets/**/*", "assets/**/*",
"cli.js", "cli.js",

View File

@ -8,13 +8,20 @@ easy observable cli tasks
* [docs (typedoc)](https://pushrocks.gitlab.io/smartcli/) * [docs (typedoc)](https://pushrocks.gitlab.io/smartcli/)
## Status for master ## Status for master
[![pipeline status](https://gitlab.com/pushrocks/smartcli/badges/master/pipeline.svg)](https://gitlab.com/pushrocks/smartcli/commits/master)
[![coverage report](https://gitlab.com/pushrocks/smartcli/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartcli/commits/master) Status Category | Status Badge
[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/smartcli.svg)](https://www.npmjs.com/package/@pushrocks/smartcli) -- | --
[![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/smartcli/badge.svg)](https://snyk.io/test/npm/@pushrocks/smartcli) GitLab Pipelines | [![pipeline status](https://gitlab.com/pushrocks/smartcli/badges/master/pipeline.svg)](https://lossless.cloud)
[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/) GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/pushrocks/smartcli/badges/master/coverage.svg)](https://lossless.cloud)
[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/) npm | [![npm downloads per month](https://badgen.net/npm/dy/@pushrocks/smartcli)](https://lossless.cloud)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](https://prettier.io/) Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/pushrocks/smartcli)](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/@pushrocks/smartcli)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@pushrocks/smartcli)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@pushrocks/smartcli)](https://lossless.cloud)
Platform support | [![Supports Windows 10](https://badgen.net/badge/supports%20Windows%2010/yes/green?icon=windows)](https://lossless.cloud) [![Supports Mac OS X](https://badgen.net/badge/supports%20Mac%20OS%20X/yes/green?icon=apple)](https://lossless.cloud)
## Usage ## Usage

View File

@ -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;