Compare commits

...

168 Commits

Author SHA1 Message Date
5f027430bf 4.0.6 2022-08-07 11:40:46 +02:00
d3385782ed fix(core): update 2022-08-07 11:40:45 +02:00
7384b54e09 4.0.5 2022-08-04 12:22:49 +02:00
0eac72e15d fix(core): update 2022-08-04 12:22:49 +02:00
b7957b0ab6 4.0.4 2022-08-03 20:21:54 +02:00
99a0a9ca81 fix(core): update 2022-08-03 20:21:54 +02:00
bd66903419 4.0.3 2022-08-03 18:48:40 +02:00
740d8dac35 fix(core): update 2022-08-03 18:48:40 +02:00
488e7410fe 4.0.2 2022-08-03 18:47:35 +02:00
04deb8960c fix(core): update 2022-08-03 18:47:35 +02:00
19f0a9563f 4.0.1 2022-08-03 17:07:11 +02:00
db1e866fe1 fix(core): update 2022-08-03 17:07:11 +02:00
f7c24a0bd2 4.0.0 2022-08-03 17:00:36 +02:00
fa59d2da40 BREAKING CHANGE(core): switch to esm 2022-08-03 17:00:36 +02:00
311232aeea 3.0.14 2021-04-07 20:28:58 +00:00
4cd0844bc3 fix(core): update 2021-04-07 20:28:57 +00:00
17c1a687c8 3.0.13 2021-04-07 20:25:18 +00:00
1d1264c2b3 fix(core): update 2021-04-07 20:25:17 +00:00
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
8e04bd6a62 3.0.9 2020-03-11 22:50:40 +00:00
687a5f7c4e fix(core): update 2020-03-11 22:50:40 +00:00
17983b1da9 3.0.8 2020-03-11 22:49:44 +00:00
5fcdf1ff8f fix(core): update 2020-03-11 22:49:43 +00:00
ef7ee7fc73 3.0.7 2018-12-11 01:50:59 +01:00
c48e85897e fix(core): update 2018-12-11 01:50:59 +01:00
9466b3e473 3.0.6 2018-09-30 22:45:12 +02:00
ab3127b8a6 fix(ci): remove obsolete dependencies 2018-09-30 22:45:12 +02:00
1e62e27980 3.0.5 2018-09-30 22:36:31 +02:00
4b87004478 fix(core): update 2018-09-30 22:36:30 +02:00
7750f1fbf5 3.0.4 2018-08-31 00:14:18 +02:00
c4e5ba6587 fix(structure): remove dist/ dir from git repo 2018-08-31 00:14:18 +02:00
9d1f0f22ba 3.0.3 2018-08-31 00:13:05 +02:00
1ce9e32116 fix(dependencies): update to latest versions 2018-08-31 00:13:05 +02:00
adfda70522 3.0.2 2018-06-28 23:57:41 +02:00
c701e3e04c fix(core): slim down dependencies 2018-06-28 23:57:40 +02:00
7b1de5b31d 3.0.1 2018-05-04 00:19:45 +02:00
7908fd8cfd update 2018-05-04 00:19:41 +02:00
21bd0c9279 3.0.0 2018-05-03 12:10:48 +02:00
9d1108e40d change to an all rxjs Subject architecture 2018-05-03 12:10:39 +02:00
390e0cb491 system change 2018-03-03 13:57:54 +01:00
032fd0c2fd fix(core): cleanup 2018-01-27 18:06:13 +01:00
440881c3d8 remove package-lock since using yarn 2018-01-27 18:05:06 +01:00
f208121e2c 2.0.12 2018-01-27 18:02:05 +01:00
7c4ae84871 fix(improve security CI step): 2018-01-27 18:02:01 +01:00
668f6c3e16 2.0.11 2018-01-27 17:59:08 +01:00
b1e08aad1f fix(core): remove vulnerable paths 2018-01-27 17:59:04 +01:00
f1ab614cdf update ci 2018-01-27 02:27:55 +01:00
995c808512 update ci 2018-01-27 02:26:10 +01:00
28acb867a0 update ci 2018-01-27 02:23:24 +01:00
3148a50d43 update ci 2018-01-27 02:21:53 +01:00
41c99de4d8 2.0.10 2018-01-27 02:20:46 +01:00
a91f56dacf add security step to CI 2018-01-27 02:20:41 +01:00
f60f17f91e 2.0.9 2017-10-12 23:02:03 +02:00
d154cf0d0f ensure compatibility with code assertion library 2017-10-12 23:02:00 +02:00
a6e0fa65e0 2.0.8 2017-10-12 22:44:39 +02:00
c7e940f597 fix tests and add .triggerOnlyOnProcessEnvCliCall() 2017-10-12 22:44:34 +02:00
45d3ce8ffc fix linting issues 2017-10-12 20:38:34 +02:00
ce121b8b7f 2.0.7 2017-05-07 16:01:14 +02:00
ce65b8d7c9 fix promise rejection on standard task 2017-05-07 16:01:10 +02:00
9acdfca460 2.0.6 2017-04-23 15:21:11 +02:00
59bcd8dadf use new tapbundle 2017-04-23 15:21:08 +02:00
b6375fd8fa 2.0.5 2017-04-22 23:16:52 +02:00
8183417c90 comment out one test that makes problems due to tap 2017-04-22 23:16:49 +02:00
5e66d35125 update tests 2017-04-22 22:09:51 +02:00
3ff4c3ff2f 2.0.4 2017-04-22 21:08:07 +02:00
6508b29bfc add npmextra.json 2017-04-22 21:08:01 +02:00
66fd7138ab 2.0.3 2017-04-22 21:05:02 +02:00
f3ce1c1408 update ci 2017-04-22 21:04:59 +02:00
d2b84acc55 2.0.2 2017-04-22 21:04:15 +02:00
ce008da9ad update .gitignore 2017-04-22 21:04:11 +02:00
f0f1f9b86f update to latest standards 2017-04-22 21:03:28 +02:00
089787454a 2.0.1 2016-12-18 20:58:39 +01:00
f8a122b777 fix argvArg for observables 2016-12-18 20:58:37 +01:00
c6db092062 2.0.0 2016-12-18 20:53:53 +01:00
857d31dcb2 introduce triggers 2016-12-18 20:53:50 +01:00
e257a38688 1.0.16 2016-12-18 01:36:24 +01:00
19a5082381 added .triggerCommandByName 2016-12-18 01:36:19 +01:00
00f5539e6b improve README 2016-11-19 17:48:56 +01:00
cacb0221f1 IMprove README 2016-11-19 17:48:07 +01:00
b98b90163d 1.0.15 2016-11-19 17:41:16 +01:00
daa6312aea Update Metadata 2016-11-19 17:41:11 +01:00
7f2dab091f 1.0.14 2016-11-19 15:02:29 +01:00
dd293875c4 improve README 2016-11-19 15:02:24 +01:00
120eca42ac 1.0.13 2016-11-19 13:43:33 +01:00
fc289616f6 1.0.12 2016-11-19 13:43:10 +01:00
e7c1c1c45b cleanup 2016-11-19 13:43:06 +01:00
f33c759fa8 improve README 2016-10-15 02:12:10 +02:00
1185df362b update test file 2016-10-15 01:06:36 +02:00
36de8e11f0 1.0.11 2016-10-15 01:01:25 +02:00
74ffb3aa87 update deps 2016-10-15 01:01:22 +02:00
96a6d01720 1.0.10 2016-10-15 00:56:05 +02:00
7833bd0be8 implement standardJS 2016-10-15 00:56:02 +02:00
7ca18c4a46 1.0.9 2016-09-04 17:50:36 +02:00
b98e2a1a62 improve typings 2016-09-04 17:50:10 +02:00
e102203422 1.0.8 2016-09-04 17:36:19 +02:00
92a37cf29b fix ci 2016-09-04 17:36:07 +02:00
8408d1f3b5 1.0.7 2016-09-04 17:34:34 +02:00
d88e05466b fix base image 2016-09-04 17:34:29 +02:00
3a789d052c 1.0.6 2016-09-04 17:32:31 +02:00
d76d829e46 add page stage 2016-09-04 17:32:26 +02:00
f8157ab8aa improve typings and docs 2016-09-04 17:32:12 +02:00
5c67015779 update smartcli 2016-09-04 17:23:29 +02:00
b67e3c0de1 Add new file 2016-08-28 23:00:00 +00:00
c7a647d4ef start interaction module 2016-08-26 11:52:09 +02:00
9e5fb7a13a 1.0.5 2016-08-26 09:21:53 +02:00
c115d222c0 improve intellisense 2016-08-26 09:21:42 +02:00
643514c64a 1.0.4 2016-06-22 11:55:26 +02:00
19498f7b11 compile fix 2016-06-22 11:55:23 +02:00
3afadd9045 1.0.3 2016-06-22 11:54:19 +02:00
0889423a24 fix 2016-06-22 11:54:12 +02:00
86b4cf4cc3 add getCommandPromise 2016-06-22 01:21:09 +02:00
4cb4eabef4 update deps and transition from npmts to npmts-g 2016-06-22 01:18:04 +02:00
bad0971f1c 1.0.2 2016-06-16 02:58:49 +02:00
016f03bd8a standard tasks now returns argv 2016-06-16 02:58:45 +02:00
63a9da11be some cosmetics 2016-06-13 12:57:24 +02:00
ab18c75b28 introduce new classes 2016-06-13 12:56:42 +02:00
088d4ef11b 1.0.1 2016-06-10 04:32:14 +02:00
5ee866d9c6 fix version return 2016-06-10 04:32:11 +02:00
d65061aaaa return argv to command 2016-06-10 04:21:03 +02:00
506bb0cdaf 1.0.0 2016-06-10 04:13:30 +02:00
834a6c2953 first version with basic funtionality 2016-06-10 04:13:23 +02:00
e1c2de8a40 remove bulk and add some features to Smartcli class 2016-06-10 03:48:01 +02:00
9e76f2afb1 Start restructuring to use a smarter Smartcli class that handles command evaluation for you 2016-06-10 03:10:21 +02:00
cf78839e12 update dependencies 2016-06-10 02:27:04 +02:00
8733a601b4 compile 2016-06-09 14:03:18 +02:00
fdd1761333 add gitlab ci 2016-06-09 14:02:21 +02:00
542c77069f start smartcli class 2016-06-09 14:01:06 +02:00
96d82c3a20 update dependencies 2016-05-23 04:09:06 +02:00
ab8ce876a3 add class smartcli 2016-05-23 03:17:19 +02:00
de4d3bcf3a Update README 2016-05-12 03:33:23 +02:00
75ab5552e1 include commander and update README 2016-05-12 03:27:45 +02:00
eb3d9d722f fixed type issue 2016-05-10 17:21:30 -07:00
c32f41cc23 fixed test issue 2016-05-10 17:11:40 -07:00
cf03c6681b update deps 2016-05-10 03:18:40 +02:00
204c7105e8 0.0.13 2016-04-05 01:22:42 +02:00
ac0681507a updated deps 2016-04-05 01:22:42 +02:00
d17053532b 0.0.12 2016-04-05 01:22:11 +02:00
65d50ab238 updated deps 2016-04-05 01:22:11 +02:00
7eed737120 work in progress 2016-03-18 17:08:26 +00:00
8f72b3f2af work in progress 2016-03-14 07:12:00 +01:00
fea330b8ff small interface fix 2015-11-09 22:58:05 +01:00
b51bbb00a4 0.0.11 2015-11-09 04:07:36 +01:00
5bd32f03c5 improve travis process 2015-11-09 04:07:01 +01:00
68f7e7fc03 0.0.10 2015-11-09 04:02:51 +01:00
55cdd7f803 add tests and fix some errors 2015-11-09 04:02:46 +01:00
5444f1d3c0 add Tests and improve TypeScript organization 2015-11-09 00:58:40 +01:00
5611ad03aa start smarter CLI logic 2015-11-05 21:43:34 +01:00
d6cbefce2c fix small comment error 2015-10-14 21:16:42 +02:00
afa6f885ad fix small comment error 2015-10-14 21:16:12 +02:00
b1565dec3e 0.0.9 2015-10-14 21:14:29 +02:00
f6969ecfd5 improved readme 2015-10-14 21:14:20 +02:00
9bb85ca666 updated readme 2015-10-14 21:09:26 +02:00
9442f738d9 added devStatus badge 2015-10-14 21:01:39 +02:00
5043829132 0.0.8 2015-10-14 20:59:22 +02:00
09152c8f5f improved return objects 2015-10-14 20:59:01 +02:00
fd7352533f Merge pull request #3 from pushrocks/greenkeeper-beautylog-0.0.15
Update beautylog to version 0.0.15 🚀
2015-10-12 22:45:44 +02:00
4b977eee3b chore(package): update beautylog to version 0.0.15
http://greenkeeper.io/
2015-10-12 22:38:34 +02:00
bec0c4bbfa Merge pull request #2 from pushrocks/greenkeeper-beautylog-0.0.14
Update beautylog to version 0.0.14 🚀
2015-10-12 20:03:37 +02:00
686fa6c6f9 chore(package): update beautylog to version 0.0.14
http://greenkeeper.io/
2015-10-12 20:02:29 +02:00
400c5c6574 Merge pull request #1 from pushrocks/greenkeeper-beautylog-0.0.13
Update beautylog to version 0.0.13 🚀
2015-10-12 14:42:35 +02:00
80770612f5 chore(package): update beautylog to version 0.0.13
http://greenkeeper.io/
2015-10-12 13:15:41 +02:00
a65fcaffea disabled travis email 2015-10-08 00:50:10 +02:00
f80006310b 0.0.7 2015-10-08 00:49:15 +02:00
26 changed files with 14467 additions and 2494 deletions

24
.gitignore vendored
View File

@ -1,6 +1,20 @@
node_modules/ .nogit/
.settings/
.idea/
ts/*.js # artifacts
ts/*.js.map coverage/
public/
pages/
# installs
node_modules/
# caches
.yarn/
.cache/
.rpt2_cache
# builds
dist/
dist_*/
# custom

128
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,128 @@
# 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

6
.idea/vcs.xml generated
View File

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

View File

@ -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: XAtA2XHAr96ILKpm1VnB/Nff9hiQv3FUa/NDfGZgvJKimuF/TwU2+kXyAag/LlEQGckZ9/IDx0PTIe8x4wOvg2VyKceYktGt6G5/MHeAXwzkkM253k2CKweVtBgnpZ2doTZXeeV/h7hHuEWZbWRXIVCgM6/inaaNe4cMRGCWqwb1xmw6D8VkLpNo6PiB37gR4GfMokasgVHZEVMg2evWKk0moREGW9XKqoE6PS9TPHPHerdqFqfbmeOq3nNgHrJZkNsAJ3PPESWCe/NGEBwtYDKrPI3QlouvXmxScI9/p2VCQmdFoUxKMDsVzBdRMrCx+XxoS8x81HxubZSpnvzUlzGtznZi7e6OyAlI7xXELIO551AH4V/pNWWUPATX+7vXVDGh7aAZYme/fejisjO5Tk9aqRvohh2jCDml3ED6alHHfI0oX5UvBpOE+XwGTIJ8qpf9RrLP5DC27JWE3fqY/WoqIZX7phoKeKYLl+R7Iln/dfvepbMBgcesnBf4PuMh3Qm2l2G1bElJ/hniV1dgggwjcg50nA0Ee9sCnORPxxjdDIMwJw//NJSe+Aq5Fm1ure9oNiBYOeF0bLVQyfGIC8J8coy1xdqv2klKnGHjMMN44bjNlmDp00SaRpbdDuavyocosQVpzfA+hY2QtGV5TXFv6TLgcMYwf8gNyVNkSGE=
on:
tags: true
repo: pushrocks/smartcli
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=

11
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,11 @@
{
"version": "0.2.0",
"configurations": [
{
"command": "npm test",
"name": "Run npm test",
"request": "launch",
"type": "node-terminal"
}
]
}

26
.vscode/settings.json vendored Normal file
View 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"]
}
}
}
}
}
}
]
}

View File

@ -1,16 +0,0 @@
# smartcli
nodejs wrapper for CLI related tasks
### Buildstatus/Dependencies
[![Build Status](https://travis-ci.org/pushrocks/smartcli.svg?branch=master)](https://travis-ci.org/pushrocks/smartcli)
[![devDependency Status](https://david-dm.org/pushrocks/smartcli/dev-status.svg)](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
View File

@ -0,0 +1,31 @@
# smartcli
nodejs wrapper for CLI related tasks
## Availabililty
[![npm](https://pushrocks.gitlab.io/assets/repo-button-npm.svg)](https://www.npmjs.com/package/smartcli)
[![git](https://pushrocks.gitlab.io/assets/repo-button-git.svg)](https://GitLab.com/pushrocks/smartcli)
[![git](https://pushrocks.gitlab.io/assets/repo-button-mirror.svg)](https://github.com/pushrocks/smartcli)
[![docs](https://pushrocks.gitlab.io/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/smartcli/)
## Status for master
[![build status](https://GitLab.com/pushrocks/smartcli/badges/master/build.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)
[![npm downloads per month](https://img.shields.io/npm/dm/smartcli.svg)](https://www.npmjs.com/package/smartcli)
[![Dependency Status](https://david-dm.org/pushrocks/smartcli.svg)](https://david-dm.org/pushrocks/smartcli)
[![bitHound Dependencies](https://www.bithound.io/github/pushrocks/smartcli/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/smartcli/master/dependencies/npm)
[![bitHound Code](https://www.bithound.io/github/pushrocks/smartcli/badges/code.svg)](https://www.bithound.io/github/pushrocks/smartcli)
[![TypeScript](https://img.shields.io/badge/TypeScript-2.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%206.x.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
## Usage
For further information read the linked docs at the top of this README.
> MIT licensed | **&copy;** [Lossless GmbH](https://lossless.gmbh)
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
[![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://push.rocks)

101
index.js
View File

@ -1,101 +0,0 @@
/// <reference path="typings/tsd.d.ts" />
var path = require("path");
var beautylog = require("beautylog");
var cliff = require("cliff");
var inquirer = require("inquirer");
var argv = require('yargs').argv;
//define the smartcli object
var smartcli = {};
//add plugins from above for direct use
smartcli.inquirer = inquirer;
smartcli.cliff = cliff;
smartcli.argv = argv;
/* ------------------------------------------------------------------------------
*----------------------- initial call CLI args -----------------------------
*----------------------------------------------------------------------------- */
// commands
smartcli.checkCommand = function (commandString) {
if (argv._.indexOf(commandString) != -1) {
return true;
}
return false;
};
smartcli.getCommands = function () {
return argv._;
};
// options
smartcli.checkOption = function (optionParam) {
if (argv.hasOwnProperty(optionParam)) {
return true;
}
return false;
};
smartcli.getOptions = function () {
var options = {};
for (var key in argv) {
if (key != "_") {
options['key'] = argv['key'];
}
}
return options;
};
/**
* returns the current working directory
* @returns {string}
*/
smartcli.getCwd = function () {
return process.cwd();
};
/* ------------------------------------------------------------------------------
*----------------------- in program CLI interaction -----------------------------
*----------------------------------------------------------------------------- */
/**
* executes callback with answer to question as argument
* @param questionString the question you want to ask the user
* @param cb the function to execute with answer as param
* @returns {null}
*/
smartcli.getAnswer = function (questionString, cb) {
if (typeof questionString != 'string') {
beautylog.error('no question specified');
return null;
}
//make inquirer compatible question object
var question = {
type: "input",
name: "userFeedback",
message: questionString,
validate: function (value) {
return true;
}
};
inquirer.prompt([question], function (answers) {
var answer = answers.userFeedback;
cb(answer);
});
};
/**
*
* @param questionString
* @param choiceOptions
* @param cb
* @returns {null}
*/
smartcli.getChoice = function (questionString, choiceOptions, cb) {
if (!Array.isArray(choiceOptions)) {
return null;
}
//make inquirer compatible question object
var question = {
type: "list",
name: "userFeedback",
message: questionString,
choices: choiceOptions,
filter: function (val) { return val.toLowerCase(); }
};
inquirer.prompt(question, function (answers) {
var answer = answers.userFeedback;
cb(answer);
});
};
module.exports = smartcli;

17
npmextra.json Normal file
View File

@ -0,0 +1,17 @@
{
"npmci": {
"npmGlobalTools": [],
"npmAccesslevel": "public"
},
"gitzone": {
"projectType": "npm",
"module": {
"githost": "gitlab.com",
"gitscope": "pushrocks",
"gitrepo": "smartcli",
"description": "easy observable cli tasks",
"npmPackagename": "@pushrocks/smartcli",
"license": "MIT"
}
}
}

13879
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,37 +1,60 @@
{ {
"name": "smartcli", "name": "@pushrocks/smartcli",
"version": "0.0.6", "private": false,
"description": "nodejs wrapper for CLI related tasks", "version": "4.0.6",
"main": "index.js", "description": "easy observable cli tasks",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"type": "module",
"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)", "buildDocs": "tsdoc"
"startdev": "(git checkout master && git pull origin master)"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/pushrocks/smartcli.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/smartcli/issues" "url": "https://gitlab.com/pushrocks/smartcli/issues"
}, },
"homepage": "https://github.com/pushrocks/smartcli", "homepage": "https://gitlab.com/pushrocks/smartcli",
"dependencies": { "dependencies": {
"beautylog": "0.0.12", "@pushrocks/lik": "^6.0.0",
"cliff": "^0.1.10", "@pushrocks/smartlog": "^3.0.1",
"inquirer": "^0.10.1", "@pushrocks/smartparam": "^1.1.6",
"yargs": "^3.26.0" "@pushrocks/smartpromise": "^3.1.3",
"@pushrocks/smartrx": "^2.0.25",
"yargs-parser": "21.0.1"
}, },
"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": "^5.0.4",
"@types/node": "^18.6.3"
},
"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
View 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 | [![pipeline status](https://gitlab.com/pushrocks/smartcli/badges/master/pipeline.svg)](https://lossless.cloud)
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/pushrocks/smartcli/badges/master/coverage.svg)](https://lossless.cloud)
npm | [![npm downloads per month](https://badgen.net/npm/dy/@pushrocks/smartcli)](https://lossless.cloud)
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
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 | **&copy;** [Lossless GmbH](https://lossless.gmbh)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)

33
test.js
View File

@ -1,33 +0,0 @@
/// <reference path="typings/tsd.d.ts" />
var smartcli = require("./index.js");
var bl = require("beautylog");
bl.log('now starting Test');
bl.log('starting with initial CLI commands and options');
var commandsString = 'You specified the following commands:';
var commands = smartcli.getCommands();
for (var key in commands) {
commandsString = commandsString + ' ' + commands[key];
}
bl.log(commandsString);
if (smartcli.checkCommand('jazz')) {
bl.log('One of your commands is jazz');
}
else {
bl.log('None of your commands is jazz');
}
var getAnswerTest = function () {
smartcli.getAnswer('How do you feel?', function (answer) {
console.log('The answer is: ' + answer);
getChoiceTest();
});
};
var getChoiceTest = function () {
smartcli.getChoice('What music do you like to hear?', ['Jazz', 'Blues', 'Classical'], function (answer) {
console.log('The answer is: ' + answer);
getCwdTest();
});
};
var getCwdTest = function () {
console.log('The current directory is: ' + smartcli.getCwd());
};
getAnswerTest();

42
test/test.ts Normal file
View File

@ -0,0 +1,42 @@
import { tap, expect } from '@pushrocks/tapbundle';
import { Subject } from 'rxjs';
import * as smartcli from '../ts/index.js';
tap.test('should create a new Smartcli', async () => {
const smartCliTestObject = new smartcli.Smartcli();
expect(smartCliTestObject).toBeInstanceOf(smartcli.Smartcli);
});
tap.test('should add an command', async (toolsArg) => {
const done = toolsArg.defer();
const smartCliTestObject = new smartcli.Smartcli();
const awesomeCommandSubject = smartCliTestObject.addCommand('awesome')
expect(awesomeCommandSubject).toBeInstanceOf(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 () => {
const smartCliTestObject = new smartcli.Smartcli();
expect(smartCliTestObject.standardCommand()).toBeInstanceOf(Subject);
});
let hasExecuted: boolean = false;
tap.test('should accept a command', async () => {
const smartCliTestObject = new smartcli.Smartcli();
smartCliTestObject.addCommand('triggerme').subscribe(() => {
hasExecuted = true;
});
smartCliTestObject.triggerCommand('triggerme', {});
expect(hasExecuted).toBeTrue();
});
tap.start();

8
ts/00_commitinfo_data.ts Normal file
View File

@ -0,0 +1,8 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
*/
export const commitinfo = {
name: '@pushrocks/smartcli',
version: '4.0.6',
description: 'easy observable cli tasks'
}

View File

@ -1,25 +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('compileTestTS', function() {
var stream = gulp.src('../test.ts')
.pipe(gulpTypescript({
out: "test.js"
}))
.pipe(gulp.dest("../../"));
return stream;
});
gulp.task('default',['compileTS','compileTestTS'], function() {
console.log('Typescript compiled');
});

View File

@ -1,2 +0,0 @@
# How to compile.
Make sure gulp and gulp-taypescript from npm are available. Then run the gulpfile in this directory.

View File

@ -1,133 +1 @@
/// <reference path="typings/tsd.d.ts" /> export { Smartcli } from './smartcli.classes.smartcli.js';
var path = require("path");
var beautylog = require("beautylog");
var cliff = require("cliff");
var inquirer = require("inquirer");
var argv = require('yargs').argv;
//define the smartcli object
var smartcli:any = {};
//add plugins from above for direct use
smartcli.inquirer = inquirer;
smartcli.cliff = cliff;
smartcli.argv = argv;
/* ------------------------------------------------------------------------------
*----------------------- initial call CLI args -----------------------------
*----------------------------------------------------------------------------- */
// commands
smartcli.checkCommand = function(commandString:string):boolean {
if (argv._.indexOf(commandString) != -1) {
return true
}
return false;
};
smartcli.getCommands = function ():string[] {
return argv._;
};
// options
smartcli.checkOption = function(optionParam:string):boolean {
if (argv.hasOwnProperty(optionParam)) {
return true;
}
return false
};
smartcli.getOptionValue = function(optionParam:string):any {
if (smartcli.checkOption(optionParam)) {
return argv[optionParam]
}
return false;
};
smartcli.getOptions = function() {
var options = {};
for (var key in argv) {
if (key != "_") {
options['key'] = argv['key'];
}
}
return options;
};
/**
* returns the current working directory
* @returns {string}
*/
smartcli.getCwd = function () {
return process.cwd();
};
/* ------------------------------------------------------------------------------
*----------------------- in program CLI interaction -----------------------------
*----------------------------------------------------------------------------- */
/**
* executes callback with answer to question as argument
* @param questionString the question you want to ask the user
* @param cb the function to execute with answer as param
* @returns {null}
*/
smartcli.getAnswer = function(questionString:string, cb) {
if (typeof questionString != 'string') {
beautylog.error('no question specified');
return null;
}
//make inquirer compatible question object
var question = {
type: "input",
name: "userFeedback",
message: questionString,
validate: function( value ) {
return true;
}
};
inquirer.prompt([question],function(answers){
var answer = answers.userFeedback;
cb(answer);
});
};
/**
*
* @param questionString
* @param choiceOptions
* @param cb
* @returns {null}
*/
smartcli.getChoice = function(questionString:string, choiceOptions:string[], cb) {
if(!Array.isArray(choiceOptions)) {
return null;
}
//make inquirer compatible question object
var question = {
type: "list",
name: "userFeedback",
message: questionString,
choices: choiceOptions,
filter: function( val ) { return val.toLowerCase(); }
};
inquirer.prompt(question,function(answers){
var answer = answers.userFeedback;
cb(answer);
});
};
module.exports = smartcli;

View File

@ -0,0 +1,160 @@
import * as plugins from './smartcli.plugins.js';
// interfaces
export interface ICommandObservableObject {
commandName: string;
subject: plugins.smartrx.rxjs.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 {
/**
* this Deferred contains the parsed result in the end
*/
public parseCompleted = plugins.smartpromise.defer<any>();
public version: string;
/**
* map of all Trigger/Observable objects to keep track
*/
private commandObservableMap = new plugins.lik.ObjectMap<ICommandObservableObject>();
/**
* maps alias
*/
public aliasObject: { [key: string]: string[] } = {};
/**
* The constructor of Smartcli
*/
constructor() {}
/**
* adds an alias, meaning one equals the other in terms of command execution.
*/
public addCommandAlias(originalArg: string, aliasArg: string): void {
this.aliasObject[originalArg] = this.aliasObject[originalArg] || [];
this.aliasObject[originalArg].push(aliasArg);
}
/**
* 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.
*/
public addCommand(commandNameArg: string): plugins.smartrx.rxjs.Subject<any> {
let commandSubject: plugins.smartrx.rxjs.Subject<any>;
const existingCommandSubject = this.getCommandSubject(commandNameArg);
commandSubject = existingCommandSubject || new plugins.smartrx.rxjs.Subject<any>();
this.commandObservableMap.add({
commandName: commandNameArg,
subject: commandSubject,
});
return commandSubject;
}
/**
* execute trigger by name
* @param commandNameArg - the name of the command to trigger
*/
public triggerCommand(commandNameArg: string, argvObject: any) {
const triggerSubject = this.getCommandSubject(commandNameArg);
triggerSubject.next(argvObject);
return triggerSubject;
}
public getCommandSubject(commandNameArg: string) {
const triggerObservableObject = this.commandObservableMap.findSync(
(triggerObservableObjectArg) => {
return triggerObservableObjectArg.commandName === commandNameArg;
}
);
if (triggerObservableObject) {
return triggerObservableObject.subject;
} else {
return null;
}
}
/**
* allows to specify help text to be printed above the rest of the help text
*/
public addHelp(optionsArg: { helpText: string }) {
this.addCommand('help').subscribe((argvArg) => {
logger.log('info', optionsArg.helpText);
});
}
/**
* specify version to be printed for -v --version
*/
public addVersion(versionArg: string) {
this.version = versionArg;
}
/**
* adds a trigger that is called when no command is specified
*/
public standardCommand(): plugins.smartrx.rxjs.Subject<any> {
const standardSubject = this.addCommand('standardCommand');
return standardSubject;
}
/**
* start the process of evaluating commands
*/
public startParse(): void {
const parsedYArgs = plugins.yargsParser(process.argv);
// lets handle commands
let counter = 0;
let foundCommand = false;
parsedYArgs._ = parsedYArgs._.filter((commandPartArg) => {
counter++;
if (typeof commandPartArg === 'number') {
return true;
}
if (counter <= 2 && !foundCommand) {
const isPath = commandPartArg.startsWith('/');
foundCommand = !isPath;
return foundCommand;
} else {
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()) {
if (!wantedCommand) {
const standardCommand = this.commandObservableMap.findSync((commandArg) => {
return commandArg.commandName === 'standardCommand';
});
if (standardCommand) {
standardCommand.subject.next(parsedYArgs);
} else {
console.log('no smartcli standard task was created or assigned.');
}
break;
}
if (command.commandName === parsedYArgs._[0]) {
command.subject.next(parsedYArgs);
break;
}
if (this.aliasObject[parsedYArgs[0]]) {
}
}
this.parseCompleted.resolve(parsedYArgs);
return;
}
}

14
ts/smartcli.plugins.ts Normal file
View File

@ -0,0 +1,14 @@
// @pushrocks scope
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 smartpromise from '@pushrocks/smartpromise';
import * as smartrx from '@pushrocks/smartrx';
export { smartlog, lik, path, smartparam, smartpromise, smartrx };
// thirdparty scope
import yargsParser from 'yargs-parser';
export { yargsParser };

View File

@ -1,40 +0,0 @@
/// <reference path="typings/tsd.d.ts" />
var smartcli = require("./index.js");
var bl = require("beautylog");
bl.log('now starting Test');
bl.log('starting with initial CLI commands and options');
var commandsString:string = 'You specified the following commands:';
var commands = smartcli.getCommands();
for (var key in commands) {
commandsString = commandsString + ' ' + commands[key];
}
bl.log(commandsString);
if (smartcli.checkCommand('jazz')) {
bl.log('One of your commands is jazz');
} else {
bl.log('None of your commands is jazz');
}
var getAnswerTest = function() {
smartcli.getAnswer('How do you feel?',function(answer){
console.log('The answer is: ' + answer);
getChoiceTest();
});
};
var getChoiceTest = function() {
smartcli.getChoice('What music do you like to hear?',['Jazz','Blues','Classical'],function(answer){
console.log('The answer is: ' + answer);
getCwdTest();
});
};
var getCwdTest = function(){
console.log('The current directory is: ' + smartcli.getCwd());
};
getAnswerTest();

View File

@ -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"
}
}
}

File diff suppressed because it is too large Load Diff

1
ts/typings/tsd.d.ts vendored
View File

@ -1 +0,0 @@
/// <reference path="node/node.d.ts" />

10
tsconfig.json Normal file
View File

@ -0,0 +1,10 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"useDefineForClassFields": false,
"target": "ES2022",
"module": "ES2022",
"moduleResolution": "nodenext",
"esModuleInterop": true
}
}