Compare commits
163 Commits
Author | SHA1 | Date | |
---|---|---|---|
311232aeea | |||
4cd0844bc3 | |||
17c1a687c8 | |||
1d1264c2b3 | |||
b036e609ce | |||
c2ec0df907 | |||
167b4d29df | |||
02fec216db | |||
4e9d2f3e8c | |||
65d8a8b6f5 | |||
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 | |||
089787454a | |||
f8a122b777 | |||
c6db092062 | |||
857d31dcb2 | |||
e257a38688 | |||
19a5082381 | |||
00f5539e6b | |||
cacb0221f1 | |||
b98b90163d | |||
daa6312aea | |||
7f2dab091f | |||
dd293875c4 | |||
120eca42ac | |||
fc289616f6 | |||
e7c1c1c45b | |||
f33c759fa8 | |||
1185df362b | |||
36de8e11f0 | |||
74ffb3aa87 | |||
96a6d01720 | |||
7833bd0be8 | |||
7ca18c4a46 | |||
b98e2a1a62 | |||
e102203422 | |||
92a37cf29b | |||
8408d1f3b5 | |||
d88e05466b | |||
3a789d052c | |||
d76d829e46 | |||
f8157ab8aa | |||
5c67015779 | |||
b67e3c0de1 | |||
c7a647d4ef | |||
9e5fb7a13a | |||
c115d222c0 | |||
643514c64a | |||
19498f7b11 | |||
3afadd9045 | |||
0889423a24 | |||
86b4cf4cc3 | |||
4cb4eabef4 | |||
bad0971f1c | |||
016f03bd8a | |||
63a9da11be | |||
ab18c75b28 | |||
088d4ef11b | |||
5ee866d9c6 | |||
d65061aaaa | |||
506bb0cdaf | |||
834a6c2953 | |||
e1c2de8a40 | |||
9e76f2afb1 | |||
cf78839e12 | |||
8733a601b4 | |||
fdd1761333 | |||
542c77069f | |||
96d82c3a20 | |||
ab8ce876a3 | |||
de4d3bcf3a | |||
75ab5552e1 | |||
eb3d9d722f | |||
c32f41cc23 | |||
cf03c6681b | |||
204c7105e8 | |||
ac0681507a | |||
d17053532b | |||
65d50ab238 | |||
7eed737120 | |||
8f72b3f2af | |||
fea330b8ff | |||
b51bbb00a4 | |||
5bd32f03c5 | |||
68f7e7fc03 | |||
55cdd7f803 | |||
5444f1d3c0 | |||
5611ad03aa | |||
d6cbefce2c | |||
afa6f885ad | |||
b1565dec3e | |||
f6969ecfd5 | |||
9bb85ca666 | |||
9442f738d9 | |||
5043829132 | |||
09152c8f5f | |||
fd7352533f | |||
4b977eee3b | |||
bec0c4bbfa | |||
686fa6c6f9 | |||
400c5c6574 | |||
80770612f5 | |||
a65fcaffea | |||
f80006310b | |||
236cce7297 | |||
05595ac997 | |||
ce1dde6d54 | |||
44b20b011c | |||
b1dfe658c4 | |||
28b9666133 | |||
067f579337 | |||
e28670de17 | |||
2dec60ce56 |
21
.gitignore
vendored
21
.gitignore
vendored
@ -1,3 +1,20 @@
|
|||||||
|
.nogit/
|
||||||
|
|
||||||
|
# artifacts
|
||||||
|
coverage/
|
||||||
|
public/
|
||||||
|
pages/
|
||||||
|
|
||||||
|
# installs
|
||||||
node_modules/
|
node_modules/
|
||||||
.settings/
|
|
||||||
.idea/
|
# caches
|
||||||
|
.yarn/
|
||||||
|
.cache/
|
||||||
|
.rpt2_cache
|
||||||
|
|
||||||
|
# builds
|
||||||
|
dist/
|
||||||
|
dist_*/
|
||||||
|
|
||||||
|
# custom
|
137
.gitlab-ci.yml
Normal file
137
.gitlab-ci.yml
Normal file
@ -0,0 +1,137 @@
|
|||||||
|
# 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
|
||||||
|
|
||||||
|
# ====================
|
||||||
|
# security stage
|
||||||
|
# ====================
|
||||||
|
mirror:
|
||||||
|
stage: security
|
||||||
|
script:
|
||||||
|
- npmci git mirror
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
|
tags:
|
||||||
|
- lossless
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
|
auditProductionDependencies:
|
||||||
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
stage: security
|
||||||
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci command npm install --production --ignore-scripts
|
||||||
|
- npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
- npmci command npm audit --audit-level=high --only=prod --production
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
|
||||||
|
auditDevDependencies:
|
||||||
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
stage: security
|
||||||
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci command npm install --ignore-scripts
|
||||||
|
- npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
- npmci command npm audit --audit-level=high --only=dev
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
allow_failure: true
|
||||||
|
|
||||||
|
# ====================
|
||||||
|
# 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 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:
|
||||||
|
stage: metadata
|
||||||
|
script:
|
||||||
|
- npmci node install lts
|
||||||
|
- npmci command npm install -g @gitzone/tsdoc
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci npm install
|
||||||
|
- npmci command tsdoc
|
||||||
|
tags:
|
||||||
|
- lossless
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
|
artifacts:
|
||||||
|
expire_in: 1 week
|
||||||
|
paths:
|
||||||
|
- public
|
||||||
|
allow_failure: true
|
6
.idea/vcs.xml
generated
6
.idea/vcs.xml
generated
@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="VcsDirectoryMappings">
|
|
||||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
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: {}
|
19
.travis.yml
19
.travis.yml
@ -1,19 +0,0 @@
|
|||||||
language: node_js
|
|
||||||
before_install:
|
|
||||||
- nvm install stable
|
|
||||||
- node -v
|
|
||||||
- npm -v
|
|
||||||
- npm install -g gulp
|
|
||||||
- npm install gulp
|
|
||||||
- npm install gulp-typescript
|
|
||||||
deploy:
|
|
||||||
provider: npm
|
|
||||||
email: npm@smart-coordination.com
|
|
||||||
api_key:
|
|
||||||
secure: y7l1JyBDihAYxbqfuPAUXJfY+PC7RSSCkAtXtBIjPA6wytSBnz55te/Vdy8RFgVty6O/k4hHzrhgUJMSoWKmPuGQ5bMBgkyV9OI5PPp4uEUyy5UdcJZv3cZYpGGDRjLjCHP4pF7AHdRcDUMEiE5ZrDtmUH1SBLoRswieO0TKsiMr3u45yR6rHFoPnnw1YlatoAPpiuP3SLnCrIjQeSOS7y9SL6PpakiquJNtpseVOr60sp39L6vLAeqJ7xTjjNJk23LF/60lfiKtM7QFg9qqE7cxFUWJs7Zmgfg4/hGcU9XRfDfZQgSNntcdFczPejO5juv2KOb1tzH7EhXrWlcF1yd70RBdJbcOn7O6ctHjMCGrCSn6IQPzcNWNErFELfMLsjVQUxbfHSc0iA1JxcYWeXUivrStwVOa9ufuG2KZCQZyEjra3zPdCu9yrE30c/mTace7eJXPYTsNn2tmxvTnFoTWmeQ0xL9Iyz9zceADpxjYJoJ8r4XMDWxWga5G9OPaqCINHxjKhOX0C36YEjYTaeNMNHv6F6BPLdKwQ9SmklMtcyC312nJsXwKy+KYJSoY6WqMef9Zk3ez0o09W0UkSr0qiQkyYCoNm8b1L7VrYuccPH24GE0fn8QMWmeE5TBThYbEIdt6NBoYCDeocflUm5KBrImFGo1peeYS1aQnpoQ=
|
|
||||||
on:
|
|
||||||
tags: true
|
|
||||||
repo: pushrocks/gulp-bootstrap
|
|
||||||
notifications:
|
|
||||||
slack:
|
|
||||||
secure: f5Uss0z9RPl/QcA/DroB8loyE93aOYI6bqCkrsiUscmZtlv/TVQtT4dxqGA6uvcG6iTQDBi3Ul88dQxWkRm4IqbhY35/iMaV2dHW4FVYMAh8GQMbsfL2sALCcufxD9blw47awv3iFcwhV1EeyesscjgL0JIjduk96v/7G/6QIO2838M1lzlgtj+kRUkim8qkaEs1je3gRrhMUIjLuAdscMXyUKYFMjWo9ACSjVUl30R/ZNemb18itIja6i92GotreBgcfEMczvy58ovDC7xdJUsY8LjMI01DwY+WPRnI0tAhsuI8moBwwcdM4e3bAjKjucQRjO33O5bMWRZ6QCiYd0DnCEFyCPQLJ4GSy/tkD00n8ijLHAOSV3AH1zNbdK1EAdSPQXDvlI36KJn/2hyQLoitGHVUPr76ujJWP82ypO2tgIp3XQU0dJVCxDuHnwJO2+hjdI+gCPqxNTpjeujHx3UdkTGNRjuuf9dlZ/D08fApjYxy2fxItTqo3QjP/nrqvBXUOPP8yPHpjIT4H2t5Pr4SJjBGI6X4qhKyFj6s9rA/Xu1rL+45zu1C3uC3z+u3T9UwrbzJ/cZM6r6UQvQmUvIfBNaMlg4I/diQCDIPL+Rhop2nylY3IcHmJnk2itn7kOqj1tohCpFEml5pRuSZy4udWywkdtyBAsHWFLF7oiQ=
|
|
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", "wcc"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
16
README.md
16
README.md
@ -1,16 +0,0 @@
|
|||||||
# smartcli
|
|
||||||
nodejs wrapper for CLI related tasks
|
|
||||||
|
|
||||||
### Buildstatus/Dependencies
|
|
||||||
[](https://travis-ci.org/pushrocks/smartcli)
|
|
||||||
[](https://david-dm.org/pushrocks/smartcli#info=devDependencies)
|
|
||||||
|
|
||||||
### Usage
|
|
||||||
This npm package comes with everything you need to start your own gulp plugin.
|
|
||||||
|
|
||||||
We recommend modifying the ts/index.ts file,
|
|
||||||
then run `npm install` to install the dev dependencies
|
|
||||||
and use `npm test` to compile the TypeScript file.
|
|
||||||
|
|
||||||
Cheers
|
|
||||||
Phil from Lossless Digital
|
|
31
docs/index.md
Normal file
31
docs/index.md
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
# 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/)
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
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://push.rocks)
|
11
index.js
11
index.js
@ -1,11 +0,0 @@
|
|||||||
/// <reference path="typings/tsd.d.ts" />
|
|
||||||
var path, through;
|
|
||||||
through = require("through2");
|
|
||||||
path = require("path");
|
|
||||||
module.exports = function (jadeTemplate, mojo) {
|
|
||||||
if (mojo === void 0) { mojo = undefined; }
|
|
||||||
return through.obj(function (file, enc, cb) {
|
|
||||||
//run callback function to signal end of plugin process.
|
|
||||||
return cb(null, file);
|
|
||||||
});
|
|
||||||
};
|
|
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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11685
package-lock.json
generated
Normal file
11685
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
67
package.json
67
package.json
@ -1,32 +1,61 @@
|
|||||||
{
|
{
|
||||||
"name": "smartcli",
|
"name": "@pushrocks/smartcli",
|
||||||
"version": "0.0.2",
|
"private": false,
|
||||||
"description": "nodejs wrapper for CLI related tasks",
|
"version": "3.0.14",
|
||||||
"main": "index.js",
|
"description": "easy observable cli tasks",
|
||||||
|
"main": "dist_ts/index.js",
|
||||||
|
"typings": "dist_ts/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(cd ts/compile && gulp)",
|
"test": "(tstest test/ --web)",
|
||||||
"reinstall": "(rm -r node_modules && npm install)",
|
"build": "(tsbuild --web)"
|
||||||
"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",
|
||||||
"url": "https://github.com/pushrocks/gulp-bootstrap.git"
|
"url": "https://gitlab.com/pushrocks/smartcli.git"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"json",
|
"cli",
|
||||||
"jade",
|
"promise",
|
||||||
"template"
|
"task",
|
||||||
|
"push.rocks"
|
||||||
],
|
],
|
||||||
"author": "Smart Coordination GmbH <office@push.rocks> (https://push.rocks)",
|
"author": "Lossless GmbH <office@lossless.com> (https://lossless.com)",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/pushrocks/gulp-bootstrap/issues"
|
"url": "https://gitlab.com/pushrocks/smartcli/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://gitlab.com/pushrocks/smartcli",
|
||||||
|
"dependencies": {
|
||||||
|
"@pushrocks/lik": "^4.0.20",
|
||||||
|
"@pushrocks/smartlog": "^2.0.39",
|
||||||
|
"@pushrocks/smartparam": "^1.1.6",
|
||||||
|
"@pushrocks/smartpromise": "^3.1.3",
|
||||||
|
"@types/yargs": "^16.0.1",
|
||||||
|
"rxjs": "^6.6.7",
|
||||||
|
"yargs": "^16.2.0"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/pushrocks/gulp-bootstrap",
|
|
||||||
"dependencies": {},
|
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"gulp": "3.9.0",
|
"@gitzone/tsbuild": "^2.1.25",
|
||||||
"gulp-typescript": "2.9.2"
|
"@gitzone/tsrun": "^1.2.12",
|
||||||
}
|
"@gitzone/tstest": "^1.0.52",
|
||||||
|
"@pushrocks/tapbundle": "^3.2.14",
|
||||||
|
"@types/node": "^14.14.37",
|
||||||
|
"tslint": "^6.1.3",
|
||||||
|
"tslint-config-prettier": "^1.18.0"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"ts/**/*",
|
||||||
|
"ts_web/**/*",
|
||||||
|
"dist/**/*",
|
||||||
|
"dist_*/**/*",
|
||||||
|
"dist_ts/**/*",
|
||||||
|
"dist_ts_web/**/*",
|
||||||
|
"assets/**/*",
|
||||||
|
"cli.js",
|
||||||
|
"npmextra.json",
|
||||||
|
"readme.md"
|
||||||
|
],
|
||||||
|
"browserslist": [
|
||||||
|
"last 1 chrome versions"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
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)
|
43
test/test.ts
Normal file
43
test/test.ts
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
import { tap, expect } from '@pushrocks/tapbundle';
|
||||||
|
import { Subject } from 'rxjs';
|
||||||
|
|
||||||
|
import smartcli = require('../ts/index');
|
||||||
|
|
||||||
|
let smartCliTestObject: smartcli.Smartcli;
|
||||||
|
|
||||||
|
tap.test('should create a new Smartcli', async () => {
|
||||||
|
smartCliTestObject = new smartcli.Smartcli();
|
||||||
|
expect(smartCliTestObject).to.be.instanceof(smartcli.Smartcli);
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('should add an command', async () => {
|
||||||
|
expect(smartCliTestObject.addCommand('awesome')).to.be.instanceOf(Subject);
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('should start parsing a standardTask', async () => {
|
||||||
|
expect(smartCliTestObject.standardTask()).to.be.instanceOf(Subject);
|
||||||
|
});
|
||||||
|
|
||||||
|
let hasExecuted: boolean = false;
|
||||||
|
|
||||||
|
tap.test('should accept a command', async () => {
|
||||||
|
smartCliTestObject.addTrigger('triggerme').subscribe(() => {
|
||||||
|
hasExecuted = true;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('should not have executed yet', async () => {
|
||||||
|
expect(hasExecuted).to.be.false;
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('should execute when triggered', async () => {
|
||||||
|
smartCliTestObject.trigger('triggerme');
|
||||||
|
expect(hasExecuted).be.true;
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('should start parsing the CLI input', async () => {
|
||||||
|
smartCliTestObject.startParse();
|
||||||
|
expect(smartCliTestObject.parseStarted.promise).to.be.instanceOf(Promise);
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.start();
|
@ -1,2 +0,0 @@
|
|||||||
nvm use v0.12.7
|
|
||||||
gulp
|
|
@ -1,16 +0,0 @@
|
|||||||
// import gulp
|
|
||||||
var gulp = require("gulp"),
|
|
||||||
gulpTypescript = require("gulp-typescript");
|
|
||||||
|
|
||||||
gulp.task('compileTS', function() {
|
|
||||||
var stream = gulp.src('../index.ts')
|
|
||||||
.pipe(gulpTypescript({
|
|
||||||
out: "index.js"
|
|
||||||
}))
|
|
||||||
.pipe(gulp.dest("../../"));
|
|
||||||
return stream;
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('default',['compileTS'], function() {
|
|
||||||
console.log('Typescript compiled');
|
|
||||||
});
|
|
@ -1,2 +0,0 @@
|
|||||||
# How to compile.
|
|
||||||
Make sure gulp and gulp-taypescript from npm are available. Then run the gulpfile in this directory.
|
|
15
ts/index.ts
15
ts/index.ts
@ -1,14 +1 @@
|
|||||||
/// <reference path="typings/tsd.d.ts" />
|
export { Smartcli } from './smartcli.classes.smartcli';
|
||||||
var path, through;
|
|
||||||
|
|
||||||
through = require("through2");
|
|
||||||
path = require("path");
|
|
||||||
|
|
||||||
module.exports = (jadeTemplate,mojo = undefined) => {
|
|
||||||
|
|
||||||
return through.obj((file, enc, cb) => {
|
|
||||||
|
|
||||||
//run callback function to signal end of plugin process.
|
|
||||||
return cb(null, file);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
169
ts/smartcli.classes.smartcli.ts
Normal file
169
ts/smartcli.classes.smartcli.ts
Normal file
@ -0,0 +1,169 @@
|
|||||||
|
import * as smartpromise from '@pushrocks/smartpromise';
|
||||||
|
import { Subject } from 'rxjs';
|
||||||
|
|
||||||
|
import * as plugins from './smartcli.plugins';
|
||||||
|
|
||||||
|
// import classes
|
||||||
|
import { ObjectMap } from '@pushrocks/lik';
|
||||||
|
|
||||||
|
// interfaces
|
||||||
|
export interface ICommandPromiseObject {
|
||||||
|
commandName: string;
|
||||||
|
promise: Promise<void>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ITriggerObservableObject {
|
||||||
|
triggerName: string;
|
||||||
|
subject: Subject<any>;
|
||||||
|
}
|
||||||
|
|
||||||
|
const logger = new plugins.smartlog.ConsoleLog();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* class to create a new instance of Smartcli. Handles parsing of command line arguments.
|
||||||
|
*/
|
||||||
|
export class Smartcli {
|
||||||
|
argv: any;
|
||||||
|
questionsDone;
|
||||||
|
parseStarted: smartpromise.Deferred<any>;
|
||||||
|
commands;
|
||||||
|
questions;
|
||||||
|
version: string;
|
||||||
|
private checkForEnvCliCall = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* map of all Trigger/Observable objects to keep track
|
||||||
|
*/
|
||||||
|
allTriggerObservablesMap = new ObjectMap<ITriggerObservableObject>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The constructor of Smartcli
|
||||||
|
*/
|
||||||
|
constructor() {
|
||||||
|
this.argv = plugins.yargs;
|
||||||
|
this.questionsDone = smartpromise.defer();
|
||||||
|
this.parseStarted = smartpromise.defer();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
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> {
|
||||||
|
const 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) {
|
||||||
|
const 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* execute trigger by name
|
||||||
|
* @param commandNameArg - the name of the command to trigger
|
||||||
|
*/
|
||||||
|
trigger(triggerName: string) {
|
||||||
|
const 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* allows to specify help text to be printed above the rest of the help text
|
||||||
|
*/
|
||||||
|
addHelp(optionsArg: { helpText: string }) {
|
||||||
|
this.addCommand('help').subscribe((argvArg) => {
|
||||||
|
logger.log('info', 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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* adds a trigger that is called when no command is specified
|
||||||
|
*/
|
||||||
|
standardTask(): Subject<any> {
|
||||||
|
const standardSubject = this.addTrigger('standardTask');
|
||||||
|
this.parseStarted.promise.then(() => {
|
||||||
|
if (
|
||||||
|
(this.argv._.length === 0 ||
|
||||||
|
(this.argv._.length === 1 && this.argv._[0].startsWith('test/'))) &&
|
||||||
|
!this.argv.v
|
||||||
|
) {
|
||||||
|
this.trigger('standardTask');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return standardSubject;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* start the process of evaluating commands
|
||||||
|
*/
|
||||||
|
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.parseStarted.resolve();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
7
ts/smartcli.plugins.ts
Normal file
7
ts/smartcli.plugins.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
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';
|
||||||
|
|
||||||
|
export { yargs, smartlog, lik, path, smartparam };
|
12
ts/tsd.json
12
ts/tsd.json
@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
"version": "v4",
|
|
||||||
"repo": "borisyankov/DefinitelyTyped",
|
|
||||||
"ref": "master",
|
|
||||||
"path": "typings",
|
|
||||||
"bundle": "typings/tsd.d.ts",
|
|
||||||
"installed": {
|
|
||||||
"node/node.d.ts": {
|
|
||||||
"commit": "efa0c1196d7280640e624ac1e7fa604502e7bd63"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
2079
ts/typings/node/node.d.ts
vendored
2079
ts/typings/node/node.d.ts
vendored
File diff suppressed because it is too large
Load Diff
1
ts/typings/tsd.d.ts
vendored
1
ts/typings/tsd.d.ts
vendored
@ -1 +0,0 @@
|
|||||||
/// <reference path="node/node.d.ts" />
|
|
17
tslint.json
Normal file
17
tslint.json
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"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