Compare commits
14 Commits
Author | SHA1 | Date | |
---|---|---|---|
e9fc5b98f2 | |||
fef954c423 | |||
39408d9832 | |||
26d9b3e9cc | |||
5f027430bf | |||
d3385782ed | |||
7384b54e09 | |||
0eac72e15d | |||
b7957b0ab6 | |||
99a0a9ca81 | |||
bd66903419 | |||
740d8dac35 | |||
488e7410fe | |||
04deb8960c |
66
.gitea/workflows/default_nottags.yaml
Normal file
66
.gitea/workflows/default_nottags.yaml
Normal 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
|
124
.gitea/workflows/default_tags.yaml
Normal file
124
.gitea/workflows/default_tags.yaml
Normal 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
|
128
.gitlab-ci.yml
128
.gitlab-ci.yml
@ -1,128 +0,0 @@
|
|||||||
# gitzone ci_default
|
|
||||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
|
||||||
|
|
||||||
cache:
|
|
||||||
paths:
|
|
||||||
- .npmci_cache/
|
|
||||||
key: '$CI_BUILD_STAGE'
|
|
||||||
|
|
||||||
stages:
|
|
||||||
- security
|
|
||||||
- test
|
|
||||||
- release
|
|
||||||
- metadata
|
|
||||||
|
|
||||||
before_script:
|
|
||||||
- npm install -g @shipzone/npmci
|
|
||||||
|
|
||||||
# ====================
|
|
||||||
# security stage
|
|
||||||
# ====================
|
|
||||||
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
|
|
||||||
allow_failure: true
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
# ====================
|
|
||||||
# test stage
|
|
||||||
# ====================
|
|
||||||
|
|
||||||
testStable:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci node install stable
|
|
||||||
- npmci npm install
|
|
||||||
- npmci npm test
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
testBuild:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- 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 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 typescript
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci npm install
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- priv
|
|
||||||
|
|
||||||
trigger:
|
|
||||||
stage: metadata
|
|
||||||
script:
|
|
||||||
- npmci trigger
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
pages:
|
|
||||||
stage: metadata
|
|
||||||
script:
|
|
||||||
- npmci node install stable
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci npm install
|
|
||||||
- npmci command npm run buildDocs
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
artifacts:
|
|
||||||
expire_in: 1 week
|
|
||||||
paths:
|
|
||||||
- public
|
|
||||||
allow_failure: true
|
|
@ -7,10 +7,10 @@
|
|||||||
"projectType": "npm",
|
"projectType": "npm",
|
||||||
"module": {
|
"module": {
|
||||||
"githost": "gitlab.com",
|
"githost": "gitlab.com",
|
||||||
"gitscope": "pushrocks",
|
"gitscope": "push.rocks",
|
||||||
"gitrepo": "smartcli",
|
"gitrepo": "smartcli",
|
||||||
"description": "easy observable cli tasks",
|
"description": "easy observable cli tasks",
|
||||||
"npmPackagename": "@pushrocks/smartcli",
|
"npmPackagename": "@push.rocks/smartcli",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
14874
package-lock.json
generated
14874
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
28
package.json
28
package.json
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartcli",
|
"name": "@push.rocks/smartcli",
|
||||||
"private": false,
|
"private": false,
|
||||||
"version": "4.0.1",
|
"version": "4.0.7",
|
||||||
"description": "easy observable cli tasks",
|
"description": "easy observable cli tasks",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
"typings": "dist_ts/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
@ -28,21 +28,19 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/smartcli",
|
"homepage": "https://gitlab.com/pushrocks/smartcli",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/lik": "^6.0.0",
|
"@push.rocks/lik": "^6.0.3",
|
||||||
"@pushrocks/smartlog": "^3.0.1",
|
"@push.rocks/smartlog": "^3.0.1",
|
||||||
"@pushrocks/smartparam": "^1.1.6",
|
"@push.rocks/smartparam": "^1.1.10",
|
||||||
"@pushrocks/smartpromise": "^3.1.3",
|
"@push.rocks/smartpromise": "^4.0.3",
|
||||||
"@pushrocks/smartrx": "^2.0.25",
|
"@push.rocks/smartrx": "^3.0.3",
|
||||||
"@types/yargs": "^17.0.10",
|
"yargs-parser": "21.1.1"
|
||||||
"@types/yargs-parser": "^21.0.0",
|
|
||||||
"yargs-parser": "^21.0.1"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.25",
|
"@gitzone/tsbuild": "^2.1.66",
|
||||||
"@gitzone/tsrun": "^1.2.12",
|
"@gitzone/tsrun": "^1.2.42",
|
||||||
"@gitzone/tstest": "^1.0.52",
|
"@gitzone/tstest": "^1.0.74",
|
||||||
"@pushrocks/tapbundle": "^5.0.4",
|
"@push.rocks/tapbundle": "^5.0.4",
|
||||||
"@types/node": "^18.6.3"
|
"@types/node": "^20.4.1"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"ts/**/*",
|
"ts/**/*",
|
||||||
|
4771
pnpm-lock.yaml
generated
Normal file
4771
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
30
readme.md
30
readme.md
@ -1,27 +1,26 @@
|
|||||||
# @pushrocks/smartcli
|
# @push.rocks/smartcli
|
||||||
easy observable cli tasks
|
easy observable cli tasks
|
||||||
|
|
||||||
## Availabililty and Links
|
## Availabililty and Links
|
||||||
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartcli)
|
* [npmjs.org (npm package)](https://www.npmjs.com/package/@push.rocks/smartcli)
|
||||||
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartcli)
|
* [gitlab.com (source)](https://gitlab.com/push.rocks/smartcli)
|
||||||
* [github.com (source mirror)](https://github.com/pushrocks/smartcli)
|
* [github.com (source mirror)](https://github.com/push.rocks/smartcli)
|
||||||
* [docs (typedoc)](https://pushrocks.gitlab.io/smartcli/)
|
* [docs (typedoc)](https://push.rocks.gitlab.io/smartcli/)
|
||||||
|
|
||||||
## Status for master
|
## Status for master
|
||||||
|
|
||||||
Status Category | Status Badge
|
Status Category | Status Badge
|
||||||
-- | --
|
-- | --
|
||||||
GitLab Pipelines | [](https://lossless.cloud)
|
GitLab Pipelines | [](https://lossless.cloud)
|
||||||
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
||||||
npm | [](https://lossless.cloud)
|
npm | [](https://lossless.cloud)
|
||||||
Snyk | [](https://lossless.cloud)
|
Snyk | [](https://lossless.cloud)
|
||||||
TypeScript Support | [](https://lossless.cloud)
|
TypeScript Support | [](https://lossless.cloud)
|
||||||
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
Code Style | [](https://lossless.cloud)
|
Code Style | [](https://lossless.cloud)
|
||||||
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
||||||
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
||||||
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
||||||
Platform support | [](https://lossless.cloud) [](https://lossless.cloud)
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@ -70,7 +69,6 @@ We are always happy for code contributions. If you are not the code contributing
|
|||||||
|
|
||||||
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)
|
## Legal
|
||||||
|
> MIT licensed | **©** [Task Venture Capital GmbH](https://task.vc)
|
||||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||||
|
|
||||||
[](https://maintainedby.lossless.com)
|
|
||||||
|
39
test/test.ts
39
test/test.ts
@ -1,43 +1,42 @@
|
|||||||
import { tap, expect } from '@pushrocks/tapbundle';
|
import { tap, expect } from '@push.rocks/tapbundle';
|
||||||
import { Subject } from 'rxjs';
|
import * as smartrx from '@push.rocks/smartrx';
|
||||||
|
|
||||||
import * as smartcli from '../ts/index.js';
|
import * as smartcli from '../ts/index.js';
|
||||||
|
|
||||||
let smartCliTestObject: smartcli.Smartcli;
|
|
||||||
|
|
||||||
tap.test('should create a new Smartcli', async () => {
|
tap.test('should create a new Smartcli', async () => {
|
||||||
smartCliTestObject = new smartcli.Smartcli();
|
const smartCliTestObject = new smartcli.Smartcli();
|
||||||
expect(smartCliTestObject).toBeInstanceOf(smartcli.Smartcli);
|
expect(smartCliTestObject).toBeInstanceOf(smartcli.Smartcli);
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should add an command', async () => {
|
tap.test('should add an command', async (toolsArg) => {
|
||||||
expect(smartCliTestObject.addCommand('awesome')).toBeInstanceOf(Subject);
|
const done = toolsArg.defer();
|
||||||
|
const smartCliTestObject = new smartcli.Smartcli();
|
||||||
|
const awesomeCommandSubject = smartCliTestObject.addCommand('awesome');
|
||||||
|
expect(awesomeCommandSubject).toBeInstanceOf(smartrx.rxjs.Subject);
|
||||||
|
awesomeCommandSubject.subscribe(() => {
|
||||||
|
done.resolve();
|
||||||
|
});
|
||||||
|
console.log(process.argv);
|
||||||
|
process.argv.splice(2, 0, 'awesome');
|
||||||
|
console.log(process.argv);
|
||||||
|
smartCliTestObject.startParse();
|
||||||
|
await done.promise;
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should start parsing a standardTask', async () => {
|
tap.test('should start parsing a standardTask', async () => {
|
||||||
expect(smartCliTestObject.standardCommand()).toBeInstanceOf(Subject);
|
const smartCliTestObject = new smartcli.Smartcli();
|
||||||
|
expect(smartCliTestObject.standardCommand()).toBeInstanceOf(smartrx.rxjs.Subject);
|
||||||
});
|
});
|
||||||
|
|
||||||
let hasExecuted: boolean = false;
|
let hasExecuted: boolean = false;
|
||||||
|
|
||||||
tap.test('should accept a command', async () => {
|
tap.test('should accept a command', async () => {
|
||||||
|
const smartCliTestObject = new smartcli.Smartcli();
|
||||||
smartCliTestObject.addCommand('triggerme').subscribe(() => {
|
smartCliTestObject.addCommand('triggerme').subscribe(() => {
|
||||||
hasExecuted = true;
|
hasExecuted = true;
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
tap.test('should not have executed yet', async () => {
|
|
||||||
expect(hasExecuted).toBeFalse();
|
|
||||||
});
|
|
||||||
|
|
||||||
tap.test('should execute when triggered', async () => {
|
|
||||||
smartCliTestObject.triggerCommand('triggerme', {});
|
smartCliTestObject.triggerCommand('triggerme', {});
|
||||||
expect(hasExecuted).toBeTrue();
|
expect(hasExecuted).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should start parsing the CLI input', async () => {
|
|
||||||
smartCliTestObject.startParse();
|
|
||||||
expect(smartCliTestObject.parseCompleted.promise).toBeInstanceOf(Promise);
|
|
||||||
});
|
|
||||||
|
|
||||||
tap.start();
|
tap.start();
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* autocreated commitinfo by @pushrocks/commitinfo
|
* autocreated commitinfo by @pushrocks/commitinfo
|
||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@pushrocks/smartcli',
|
name: '@push.rocks/smartcli',
|
||||||
version: '4.0.1',
|
version: '4.0.7',
|
||||||
description: 'easy observable cli tasks'
|
description: 'easy observable cli tasks'
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ export class Smartcli {
|
|||||||
public parseCompleted = plugins.smartpromise.defer<any>();
|
public parseCompleted = plugins.smartpromise.defer<any>();
|
||||||
|
|
||||||
public version: string;
|
public version: string;
|
||||||
private checkForEnvCliCall = true;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* map of all Trigger/Observable objects to keep track
|
* map of all Trigger/Observable objects to keep track
|
||||||
@ -35,13 +34,6 @@ export class Smartcli {
|
|||||||
*/
|
*/
|
||||||
constructor() {}
|
constructor() {}
|
||||||
|
|
||||||
/**
|
|
||||||
* halts any execution of commands if (process.env.CLI_CALL === false)
|
|
||||||
*/
|
|
||||||
disableEnvCliCall() {
|
|
||||||
this.checkForEnvCliCall = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* adds an alias, meaning one equals the other in terms of command execution.
|
* adds an alias, meaning one equals the other in terms of command execution.
|
||||||
*/
|
*/
|
||||||
@ -103,12 +95,6 @@ export class Smartcli {
|
|||||||
*/
|
*/
|
||||||
public addVersion(versionArg: string) {
|
public addVersion(versionArg: string) {
|
||||||
this.version = versionArg;
|
this.version = versionArg;
|
||||||
this.addCommandAlias('v', 'version');
|
|
||||||
this.parseCompleted.promise.then((argv) => {
|
|
||||||
if (argv.v) {
|
|
||||||
console.log(this.version);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -123,19 +109,12 @@ export class Smartcli {
|
|||||||
* start the process of evaluating commands
|
* start the process of evaluating commands
|
||||||
*/
|
*/
|
||||||
public startParse(): void {
|
public startParse(): void {
|
||||||
// if we check for cli env calls, we might want to abort here.
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
const parsedYArgs = plugins.yargsParser(process.argv);
|
const parsedYArgs = plugins.yargsParser(process.argv);
|
||||||
|
|
||||||
// lets handle commands
|
// lets handle commands
|
||||||
let counter = 0;
|
let counter = 0;
|
||||||
let foundCommand = false;
|
let foundCommand = false;
|
||||||
parsedYArgs._.map((commandPartArg) => {
|
parsedYArgs._ = parsedYArgs._.filter((commandPartArg) => {
|
||||||
counter++;
|
counter++;
|
||||||
if (typeof commandPartArg === 'number') {
|
if (typeof commandPartArg === 'number') {
|
||||||
return true;
|
return true;
|
||||||
@ -148,8 +127,16 @@ export class Smartcli {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
const wantedCommand = parsedYArgs._[0];
|
||||||
|
|
||||||
|
// lets handle some standards
|
||||||
|
if (!wantedCommand && (parsedYArgs.v || parsedYArgs.version)) {
|
||||||
|
console.log(this.version || 'unknown version');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.log(`Wanted command: ${wantedCommand}`);
|
||||||
for (const command of this.commandObservableMap.getArray()) {
|
for (const command of this.commandObservableMap.getArray()) {
|
||||||
if (!parsedYArgs._[0]) {
|
if (!wantedCommand) {
|
||||||
const standardCommand = this.commandObservableMap.findSync((commandArg) => {
|
const standardCommand = this.commandObservableMap.findSync((commandArg) => {
|
||||||
return commandArg.commandName === 'standardCommand';
|
return commandArg.commandName === 'standardCommand';
|
||||||
});
|
});
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
// @pushrocks scope
|
// @pushrocks scope
|
||||||
import * as smartlog from '@pushrocks/smartlog';
|
import * as smartlog from '@push.rocks/smartlog';
|
||||||
import * as lik from '@pushrocks/lik';
|
import * as lik from '@push.rocks/lik';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as smartparam from '@pushrocks/smartparam';
|
import * as smartparam from '@push.rocks/smartparam';
|
||||||
import * as smartpromise from '@pushrocks/smartpromise';
|
import * as smartpromise from '@push.rocks/smartpromise';
|
||||||
import * as smartrx from '@pushrocks/smartrx';
|
import * as smartrx from '@push.rocks/smartrx';
|
||||||
|
|
||||||
export { smartlog, lik, path, smartparam, smartpromise, smartrx };
|
export { smartlog, lik, path, smartparam, smartpromise, smartrx };
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user