Compare commits
124 Commits
Author | SHA1 | Date | |
---|---|---|---|
5e2225669d | |||
a4a3343b1d | |||
e10e8cf90d | |||
19900d088e | |||
3e5793f842 | |||
4fd13e65c4 | |||
e5a8bbf4a3 | |||
f28589603b | |||
fed411a30f | |||
2328801f03 | |||
60883fed6d | |||
e9fc5b98f2 | |||
fef954c423 | |||
39408d9832 | |||
26d9b3e9cc | |||
5f027430bf | |||
d3385782ed | |||
7384b54e09 | |||
0eac72e15d | |||
b7957b0ab6 | |||
99a0a9ca81 | |||
bd66903419 | |||
740d8dac35 | |||
488e7410fe | |||
04deb8960c | |||
19f0a9563f | |||
db1e866fe1 | |||
f7c24a0bd2 | |||
fa59d2da40 | |||
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 |
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 @git.zone/tsdoc
|
||||||
|
npmci command tsdoc
|
||||||
|
continue-on-error: true
|
23
.gitignore
vendored
23
.gitignore
vendored
@ -1,11 +1,20 @@
|
|||||||
node_modules/
|
.nogit/
|
||||||
.settings/
|
|
||||||
.idea/
|
# artifacts
|
||||||
coverage/
|
coverage/
|
||||||
docs/
|
public/
|
||||||
|
pages/
|
||||||
|
|
||||||
|
# installs
|
||||||
|
node_modules/
|
||||||
|
|
||||||
ts/*.js
|
# caches
|
||||||
ts/*.js.map
|
.yarn/
|
||||||
ts/typings/
|
.cache/
|
||||||
|
.rpt2_cache
|
||||||
|
|
||||||
|
# builds
|
||||||
|
dist/
|
||||||
|
dist_*/
|
||||||
|
|
||||||
|
# custom
|
@ -1,37 +0,0 @@
|
|||||||
image: hosttoday/ht-docker-node:npmci
|
|
||||||
|
|
||||||
stages:
|
|
||||||
- test
|
|
||||||
- release
|
|
||||||
|
|
||||||
testLEGACY:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci test legacy
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
allow_failure: true
|
|
||||||
|
|
||||||
testLTS:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci test lts
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
testSTABLE:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci test stable
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
release:
|
|
||||||
stage: release
|
|
||||||
script:
|
|
||||||
- npmci publish
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
|
|
11
.vscode/launch.json
vendored
Normal file
11
.vscode/launch.json
vendored
Normal 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
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"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
54
README.md
54
README.md
@ -1,54 +0,0 @@
|
|||||||
# smartcli
|
|
||||||
nodejs wrapper for CLI related tasks. TypeScript ready.
|
|
||||||
|
|
||||||
## Status
|
|
||||||
[](https://travis-ci.org/pushrocks/smartcli)
|
|
||||||
[](https://david-dm.org/pushrocks/smartcli)
|
|
||||||
[](https://www.bithound.io/github/pushrocks/smartcli)
|
|
||||||
[](https://www.bithound.io/github/pushrocks/smartcli)
|
|
||||||
|
|
||||||
## Install the package
|
|
||||||
npm install smartcli --save
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
this plugin tries to establish some logic in which CLI tools work.
|
|
||||||
|
|
||||||
take the following commandline input:
|
|
||||||
|
|
||||||
```
|
|
||||||
mytool function argument1 argument2 --option1 option1Value --option2 option2Value
|
|
||||||
```
|
|
||||||
|
|
||||||
* 'mytool' obviously is the tool (like git)
|
|
||||||
* function is the main thing the tool shall do (like commit)
|
|
||||||
* option is an option you can add (like -m for message)
|
|
||||||
* optionValue is the referenced option value (like a commit message)
|
|
||||||
|
|
||||||
|
|
||||||
### The inner organization of smartcli
|
|
||||||
**smartcli** exposes three major groups of functions:
|
|
||||||
|
|
||||||
* check functions
|
|
||||||
* are grouped in **smartcli.checks** object
|
|
||||||
* get functions
|
|
||||||
* are grouped in **smartcli.get** object
|
|
||||||
* async interaction functions
|
|
||||||
* are grouped in **smartcli.interaction** object
|
|
||||||
|
|
||||||
|
|
||||||
### Methods
|
|
||||||
The examples are written in TypeScript
|
|
||||||
```typescript
|
|
||||||
import * as smartcli from "smartcli"
|
|
||||||
|
|
||||||
/* -------------- Check Functions -------------------*/
|
|
||||||
smartcli.check.command("jazz"); // check for a special command.
|
|
||||||
smartcli.check.commandPresence() // check if any command is specified
|
|
||||||
smartcli.check.commandArguemnt("myargument",1) // checks if a special argument is given, second argument is level
|
|
||||||
smartcli.check.commandArguemntPresence // checks of any Argument is present
|
|
||||||
smartcli.check.option("someoption") // checks for a specific option
|
|
||||||
smartcli.check.optionPresence() // checks if any option is specified
|
|
||||||
smartcli.get.option('myoption'); //
|
|
||||||
```
|
|
||||||
|
|
2
dist/index.d.ts
vendored
2
dist/index.d.ts
vendored
@ -1,2 +0,0 @@
|
|||||||
import "typings-global";
|
|
||||||
export { Smartcli } from "./smartcli.classes.smartcli";
|
|
5
dist/index.js
vendored
5
dist/index.js
vendored
@ -1,5 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
require("typings-global");
|
|
||||||
var smartcli_classes_smartcli_1 = require("./smartcli.classes.smartcli");
|
|
||||||
exports.Smartcli = smartcli_classes_smartcli_1.Smartcli;
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsUUFBTyxnQkFBZ0IsQ0FBQyxDQUFBO0FBR3hCLDBDQUF1Qiw2QkFBNkIsQ0FBQztBQUE3Qyx3REFBNkMifQ==
|
|
4
dist/smartcli.classes.interaction.d.ts
vendored
4
dist/smartcli.classes.interaction.d.ts
vendored
@ -1,4 +0,0 @@
|
|||||||
import "typings-global";
|
|
||||||
export declare class Question {
|
|
||||||
constructor();
|
|
||||||
}
|
|
17
dist/smartcli.classes.interaction.helpers.d.ts
vendored
17
dist/smartcli.classes.interaction.helpers.d.ts
vendored
@ -1,17 +0,0 @@
|
|||||||
import "typings-global";
|
|
||||||
import "./smartcli.interfaces";
|
|
||||||
/**
|
|
||||||
* 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}
|
|
||||||
*/
|
|
||||||
export declare let getAnswer: (questionString: string, cb: any) => any;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param questionString
|
|
||||||
* @param choiceOptions
|
|
||||||
* @param cb
|
|
||||||
* @returns {null}
|
|
||||||
*/
|
|
||||||
export declare let getChoice: (questionString: string, choiceOptions: string[], cb: any) => any;
|
|
54
dist/smartcli.classes.interaction.helpers.js
vendored
54
dist/smartcli.classes.interaction.helpers.js
vendored
@ -1,54 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
require("typings-global");
|
|
||||||
require("./smartcli.interfaces");
|
|
||||||
const plugins = require("./smartcli.plugins");
|
|
||||||
/**
|
|
||||||
* 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}
|
|
||||||
*/
|
|
||||||
exports.getAnswer = function (questionString, cb) {
|
|
||||||
if (typeof questionString != 'string') {
|
|
||||||
plugins.beautylog.error('no question specified');
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
//make inquirer compatible question object
|
|
||||||
let question = {
|
|
||||||
type: "input",
|
|
||||||
name: "userFeedback",
|
|
||||||
message: questionString,
|
|
||||||
validate: function (value) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
plugins.inquirer.prompt([question], function (answers) {
|
|
||||||
let answer = answers.userFeedback;
|
|
||||||
cb(answer);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param questionString
|
|
||||||
* @param choiceOptions
|
|
||||||
* @param cb
|
|
||||||
* @returns {null}
|
|
||||||
*/
|
|
||||||
exports.getChoice = function (questionString, choiceOptions, cb) {
|
|
||||||
if (!Array.isArray(choiceOptions)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
//make inquirer compatible question object
|
|
||||||
let question = {
|
|
||||||
type: "list",
|
|
||||||
name: "userFeedback",
|
|
||||||
message: questionString,
|
|
||||||
choices: choiceOptions,
|
|
||||||
filter: function (val) { return val.toLowerCase(); }
|
|
||||||
};
|
|
||||||
plugins.inquirer.prompt(question, function (answers) {
|
|
||||||
let answer = answers.userFeedback;
|
|
||||||
cb(answer);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRjbGkuY2xhc3Nlcy5pbnRlcmFjdGlvbi5oZWxwZXJzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRjbGkuY2xhc3Nlcy5pbnRlcmFjdGlvbi5oZWxwZXJzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUFnQixDQUFDLENBQUE7QUFFeEIsUUFBTyx1QkFBdUIsQ0FBQyxDQUFBO0FBQy9CLE1BQU8sT0FBTyxXQUFXLG9CQUFvQixDQUFDLENBQUM7QUFFL0M7Ozs7O0dBS0c7QUFDUSxpQkFBUyxHQUFHLFVBQVMsY0FBcUIsRUFBRSxFQUFFO0lBQ3JELEVBQUUsQ0FBQyxDQUFDLE9BQU8sY0FBYyxJQUFJLFFBQVEsQ0FBQyxDQUFDLENBQUM7UUFDcEMsT0FBTyxDQUFDLFNBQVMsQ0FBQyxLQUFLLENBQUMsdUJBQXVCLENBQUMsQ0FBQztRQUNqRCxNQUFNLENBQUMsSUFBSSxDQUFDO0lBQ2hCLENBQUM7SUFDRCwwQ0FBMEM7SUFDMUMsSUFBSSxRQUFRLEdBQ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DO1FBQ2xDLEVBQUUsQ0FBQyxNQUFNLENBQUMsQ0FBQztJQUNmLENBQUMsQ0FBQyxDQUFDO0FBRVAsQ0FBQyxDQUFDIn0=
|
|
8
dist/smartcli.classes.interaction.js
vendored
8
dist/smartcli.classes.interaction.js
vendored
@ -1,8 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
require("typings-global");
|
|
||||||
class Question {
|
|
||||||
constructor() {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.Question = Question;
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRjbGkuY2xhc3Nlcy5pbnRlcmFjdGlvbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0Y2xpLmNsYXNzZXMuaW50ZXJhY3Rpb24udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sZ0JBQWdCLENBQUMsQ0FBQTtBQUd4QjtJQUNJO0lBRUEsQ0FBQztBQUNMLENBQUM7QUFKWSxnQkFBUSxXQUlwQixDQUFBIn0=
|
|
36
dist/smartcli.classes.smartcli.d.ts
vendored
36
dist/smartcli.classes.smartcli.d.ts
vendored
@ -1,36 +0,0 @@
|
|||||||
/// <reference types="q" />
|
|
||||||
import "typings-global";
|
|
||||||
import * as plugins from "./smartcli.plugins";
|
|
||||||
export declare class Smartcli {
|
|
||||||
argv: any;
|
|
||||||
questionsDone: any;
|
|
||||||
parseStarted: any;
|
|
||||||
commands: any;
|
|
||||||
questions: any;
|
|
||||||
version: string;
|
|
||||||
constructor();
|
|
||||||
/**
|
|
||||||
* adds an alias, meaning one equals the other in terms of triggering associated commands
|
|
||||||
*/
|
|
||||||
addAlias(keyArg: any, aliasArg: any): void;
|
|
||||||
/**
|
|
||||||
* 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(definitionArg: {
|
|
||||||
commandName: string;
|
|
||||||
}): plugins.q.Promise<{}>;
|
|
||||||
/**
|
|
||||||
* gets a Promise for a command word
|
|
||||||
*/
|
|
||||||
getCommandPromise(commandNameArg: any): void;
|
|
||||||
addQuestion(definitionArg: {
|
|
||||||
questionString: string;
|
|
||||||
questionType: string;
|
|
||||||
}): void;
|
|
||||||
addHelp(): void;
|
|
||||||
addVersion(versionArg: string): void;
|
|
||||||
standardTask(): plugins.q.Promise<{}>;
|
|
||||||
startParse(): void;
|
|
||||||
}
|
|
78
dist/smartcli.classes.smartcli.js
vendored
78
dist/smartcli.classes.smartcli.js
vendored
@ -1,78 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
require("typings-global");
|
|
||||||
const plugins = require("./smartcli.plugins");
|
|
||||||
class Smartcli {
|
|
||||||
constructor() {
|
|
||||||
this.argv = plugins.argv;
|
|
||||||
this.questionsDone = plugins.q.defer();
|
|
||||||
this.parseStarted = plugins.q.defer();
|
|
||||||
}
|
|
||||||
;
|
|
||||||
/**
|
|
||||||
* adds an alias, meaning one equals the other in terms of triggering associated commands
|
|
||||||
*/
|
|
||||||
addAlias(keyArg, aliasArg) {
|
|
||||||
this.argv = this.argv.alias(keyArg, 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.
|
|
||||||
*/
|
|
||||||
addCommand(definitionArg) {
|
|
||||||
let done = plugins.q.defer();
|
|
||||||
this.parseStarted.promise
|
|
||||||
.then(() => {
|
|
||||||
if (this.argv._.indexOf(definitionArg.commandName) == 0) {
|
|
||||||
done.resolve(this.argv);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
done.reject(this.argv);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return done.promise;
|
|
||||||
}
|
|
||||||
;
|
|
||||||
/**
|
|
||||||
* gets a Promise for a command word
|
|
||||||
*/
|
|
||||||
getCommandPromise(commandNameArg) {
|
|
||||||
//TODO
|
|
||||||
}
|
|
||||||
addQuestion(definitionArg) {
|
|
||||||
}
|
|
||||||
;
|
|
||||||
addHelp() {
|
|
||||||
}
|
|
||||||
addVersion(versionArg) {
|
|
||||||
this.version = versionArg;
|
|
||||||
this.addAlias("v", "version");
|
|
||||||
this.parseStarted.promise
|
|
||||||
.then(() => {
|
|
||||||
if (this.argv.v) {
|
|
||||||
console.log(this.version);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
standardTask() {
|
|
||||||
let done = plugins.q.defer();
|
|
||||||
this.parseStarted.promise
|
|
||||||
.then(() => {
|
|
||||||
if (this.argv._.length == 0 && !this.argv.v) {
|
|
||||||
done.resolve(this.argv);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
done.reject(this.argv);
|
|
||||||
}
|
|
||||||
;
|
|
||||||
});
|
|
||||||
return done.promise;
|
|
||||||
}
|
|
||||||
startParse() {
|
|
||||||
this.argv = this.argv.argv;
|
|
||||||
this.parseStarted.resolve();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.Smartcli = Smartcli;
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRjbGkuY2xhc3Nlcy5zbWFydGNsaS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0Y2xpLmNsYXNzZXMuc21hcnRjbGkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sZ0JBQWdCLENBQUMsQ0FBQTtBQUV4QixNQUFZLE9BQU8sV0FBTSxvQkFBb0IsQ0FBQyxDQUFBO0FBRzlDO0lBT0k7UUFDSSxJQUFJLENBQUMsSUFBSSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUM7UUFDekIsSUFBSSxDQUFDLGFBQWEsR0FBRyxPQ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ElBQUksR0FBRyxJQUFJLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQztRQUMzQixJQUFJLENBQUMsWUFBWSxDQUFDLE9BQU8sRUFBRSxDQUFDO0lBQ2hDLENBQUM7QUFFTCxDQUFDO0FBN0VZLGdCQUFRLFdBNkVwQixDQUFBIn0=
|
|
9
dist/smartcli.plugins.d.ts
vendored
9
dist/smartcli.plugins.d.ts
vendored
@ -1,9 +0,0 @@
|
|||||||
import "typings-global";
|
|
||||||
export declare let argv: any;
|
|
||||||
export import beautylog = require("beautylog");
|
|
||||||
export declare let cliff: any;
|
|
||||||
export declare let inquirer: any;
|
|
||||||
export import lik = require("lik");
|
|
||||||
export declare let path: any;
|
|
||||||
export import q = require("q");
|
|
||||||
export import smartparam = require("smartparam");
|
|
11
dist/smartcli.plugins.js
vendored
11
dist/smartcli.plugins.js
vendored
@ -1,11 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
require("typings-global");
|
|
||||||
exports.argv = require('yargs');
|
|
||||||
exports.beautylog = require("beautylog");
|
|
||||||
exports.cliff = require("cliff");
|
|
||||||
exports.inquirer = require("inquirer");
|
|
||||||
exports.lik = require("lik");
|
|
||||||
exports.path = require("path");
|
|
||||||
exports.q = require("q");
|
|
||||||
exports.smartparam = require("smartparam");
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRjbGkucGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0Y2xpLnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sZ0JBQWdCLENBQUMsQ0FBQTtBQUViLFlBQUksR0FBRyxPQUFPLENBQUMsT0FBTyxDQUFDLENBQUM7QUFDckIsaUJBQVMsV0FBVyxXQUFXLENBQUMsQ0FBQztBQUNwQyxhQUFLLEdBQUcsT0FBTyxDQUFDLE9BQU8sQ0FBQyxDQUFDO0FBQ3pCLGdCQUFRLEdBQUcsT0FBTyxDQUFDLFVBQVUsQ0FBQyxDQUFDO0FBQzVCLFdBQUcsV0FBVyxLQUFLLENBQUMsQ0FBQztBQUN4QixZQUFJLEdBQUcsT0FBTyxDQUFDLE1BQU0sQ0FBQyxDQUFDO0FBQ3BCLFNBQUMsV0FBVyxHQUFHLENBQUMsQ0FBQztBQUNqQixrQkFBVSxXQUFXLFlBQVksQ0FBQyxDQUFDIn0=
|
|
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)
|
32
npmextra.json
Normal file
32
npmextra.json
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
{
|
||||||
|
"npmci": {
|
||||||
|
"npmGlobalTools": [],
|
||||||
|
"npmAccesslevel": "public"
|
||||||
|
},
|
||||||
|
"gitzone": {
|
||||||
|
"projectType": "npm",
|
||||||
|
"module": {
|
||||||
|
"githost": "code.foss.global",
|
||||||
|
"gitscope": "push.rocks",
|
||||||
|
"gitrepo": "smartcli",
|
||||||
|
"description": "A library for easily creating observable CLI tasks with support for commands, arguments, and options.",
|
||||||
|
"npmPackagename": "@push.rocks/smartcli",
|
||||||
|
"license": "MIT",
|
||||||
|
"keywords": [
|
||||||
|
"CLI",
|
||||||
|
"command line",
|
||||||
|
"observable",
|
||||||
|
"tasks",
|
||||||
|
"commands",
|
||||||
|
"arguments",
|
||||||
|
"options",
|
||||||
|
"typescript",
|
||||||
|
"node.js",
|
||||||
|
"development tool"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"tsdoc": {
|
||||||
|
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
|
||||||
|
}
|
||||||
|
}
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"mode":"default"
|
|
||||||
}
|
|
76
package.json
76
package.json
@ -1,46 +1,66 @@
|
|||||||
{
|
{
|
||||||
"name": "smartcli",
|
"name": "@push.rocks/smartcli",
|
||||||
"version": "1.0.5",
|
"private": false,
|
||||||
"description": "nodejs wrapper for CLI related tasks",
|
"version": "4.0.11",
|
||||||
"main": "dist/index.js",
|
"description": "A library for easily creating observable CLI tasks with support for commands, arguments, and options.",
|
||||||
"typings": "dist/index.d.ts",
|
"main": "dist_ts/index.js",
|
||||||
|
"typings": "dist_ts/index.d.ts",
|
||||||
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(npmts)",
|
"test": "(tstest test/ --web)",
|
||||||
"testm": "(cd ts/compile && gulp) && (node test.js jazz jam --awesome)",
|
"build": "(tsbuild --web --allowimplicitany)",
|
||||||
"devTest": "(npm test) && (node test.js --test true)",
|
"buildDocs": "tsdoc"
|
||||||
"reinstall": "(rm -r node_modules && npm install)",
|
|
||||||
"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://gitlab.com/pushrocks/smartcli.git"
|
"url": "https://gitlab.com/pushrocks/smartcli.git"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"json",
|
"CLI",
|
||||||
"jade",
|
"command line",
|
||||||
"template"
|
"observable",
|
||||||
|
"tasks",
|
||||||
|
"commands",
|
||||||
|
"arguments",
|
||||||
|
"options",
|
||||||
|
"typescript",
|
||||||
|
"node.js",
|
||||||
|
"development tool"
|
||||||
],
|
],
|
||||||
"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://gitlab.com/pushrocks/smartcli/issues"
|
"url": "https://gitlab.com/pushrocks/smartcli/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/smartcli",
|
"homepage": "https://gitlab.com/pushrocks/smartcli",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/q": "0.0.30",
|
"@push.rocks/lik": "^6.0.15",
|
||||||
"beautylog": "^5.0.20",
|
"@push.rocks/smartlog": "^3.0.6",
|
||||||
"cliff": "^0.1.10",
|
"@push.rocks/smartobject": "^1.0.12",
|
||||||
"inquirer": "^1.1.2",
|
"@push.rocks/smartpromise": "^4.0.3",
|
||||||
"lik": "^1.0.15",
|
"@push.rocks/smartrx": "^3.0.3",
|
||||||
"q": "^1.4.1",
|
"yargs-parser": "21.1.1"
|
||||||
"smartparam": "0.1.1",
|
|
||||||
"typings-global": "^1.0.6",
|
|
||||||
"yargs": "^5.0.0"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"npmts-g": "^5.2.8",
|
"@git.zone/tsbuild": "^2.1.80",
|
||||||
"should": "^11.1.0",
|
"@git.zone/tsrun": "^1.2.42",
|
||||||
"typings-test": "^1.0.1"
|
"@git.zone/tstest": "^1.0.90",
|
||||||
}
|
"@push.rocks/tapbundle": "^5.0.23",
|
||||||
|
"@types/node": "^20.12.12"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"ts/**/*",
|
||||||
|
"ts_web/**/*",
|
||||||
|
"dist/**/*",
|
||||||
|
"dist_*/**/*",
|
||||||
|
"dist_ts/**/*",
|
||||||
|
"dist_ts_web/**/*",
|
||||||
|
"assets/**/*",
|
||||||
|
"cli.js",
|
||||||
|
"npmextra.json",
|
||||||
|
"readme.md"
|
||||||
|
],
|
||||||
|
"browserslist": [
|
||||||
|
"last 1 chrome versions"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
6825
pnpm-lock.yaml
generated
Normal file
6825
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
1
readme.hints.md
Normal file
1
readme.hints.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
No specific hints.
|
133
readme.md
Normal file
133
readme.md
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
# @push.rocks/smartcli
|
||||||
|
|
||||||
|
easy observable cli tasks
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
To install `@push.rocks/smartcli`, use the following command in your terminal:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install @push.rocks/smartcli --save
|
||||||
|
```
|
||||||
|
|
||||||
|
This will add `@push.rocks/smartcli` as a dependency to your project's `package.json` file and download it into the `node_modules` folder.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
The `@push.rocks/smartcli` module is designed to simplify the creation of command-line interfaces (CLIs) by providing an easy-to-use API for managing CLI commands and options. It combines observables with the parsing power of [yargs-parser](https://www.npmjs.com/package/yargs-parser) to offer a dynamic and flexible way to handle various CLI tasks.
|
||||||
|
|
||||||
|
### Getting Started
|
||||||
|
|
||||||
|
First, ensure you have TypeScript and the necessary types for node installed in your project. If not, you can add them by running:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install typescript @types/node --save-dev
|
||||||
|
```
|
||||||
|
|
||||||
|
Then, import the `Smartcli` class from the `@push.rocks/smartcli` package.
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { Smartcli } from '@push.rocks/smartcli';
|
||||||
|
```
|
||||||
|
|
||||||
|
### Creating an Instance
|
||||||
|
|
||||||
|
Create an instance of `Smartcli`. This instance will be used to define and manage your CLI commands.
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
const mySmartcli = new Smartcli();
|
||||||
|
```
|
||||||
|
|
||||||
|
### Defining Commands
|
||||||
|
|
||||||
|
With `Smartcli`, you can define commands that your CLI tool can execute. Here's how you can add a new command:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
mySmartcli.addCommand('install').subscribe((argv) => {
|
||||||
|
console.log('Install command was called with arguments:', argv);
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
In this example, when the user types `install` after your CLI tool's name in the terminal, the provided function will execute, printing the parsed arguments to the console.
|
||||||
|
|
||||||
|
### Handling Options
|
||||||
|
|
||||||
|
Options can be accessed using the `getOption` method. If you have an option named `--config` or `-c`, you can access its value like this:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
const configValue = mySmartcli.getOption('config');
|
||||||
|
console.log('Config value:', configValue);
|
||||||
|
```
|
||||||
|
|
||||||
|
### Default Task (Standard Command)
|
||||||
|
|
||||||
|
If you want to perform a task when no specific command is provided, you can use the `standardCommand` method:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
mySmartcli.standardCommand().subscribe((argv) => {
|
||||||
|
console.log('No specific command provided. Running default task with arguments:', argv);
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
### Version and Help
|
||||||
|
|
||||||
|
To add a version option that prints the version of your CLI tool, use `addVersion`:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
mySmartcli.addVersion('1.0.0');
|
||||||
|
```
|
||||||
|
|
||||||
|
For a help option that displays helpful information about your CLI commands and options, use `addHelp`:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
mySmartcli.addHelp({
|
||||||
|
helpText: 'Here are the commands you can use...'
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
### Parsing and Execution
|
||||||
|
|
||||||
|
After defining all your commands and options, call `startParse` to begin parsing the command line input and execute the corresponding actions:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
mySmartcli.startParse();
|
||||||
|
```
|
||||||
|
|
||||||
|
### Advanced Usage: Command Aliases
|
||||||
|
|
||||||
|
You can also define aliases for your commands, allowing users to use alternate names for them:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
mySmartcli.addCommandAlias('install', 'i');
|
||||||
|
```
|
||||||
|
|
||||||
|
With this setup, both `install` and `i` will trigger the same command action.
|
||||||
|
|
||||||
|
### Observables and Async Operations
|
||||||
|
|
||||||
|
Since commands in `smartcli` are handled using observables, you can easily integrate asynchronous operations within your command actions. This makes it perfect for CLI tasks that involve file operations, network requests, or any other async tasks.
|
||||||
|
|
||||||
|
### Conclusion
|
||||||
|
|
||||||
|
`@push.rocks/smartcli` offers a robust and intuitive way to build CLI tools with TypeScript, leveraging the reactive programming paradigm. By following the examples provided in this guide, you'll be able to create a feature-rich command-line application tailored to your specific needs.
|
||||||
|
|
||||||
|
Remember, this is just the start. The true power of `smartcli` lies in its flexibility and the vast ecosystem of RxJS. Dive into the RxJS documentation to explore more ways to handle data streams and asynchronous events in your CLI app.
|
||||||
|
|
||||||
|
## License and Legal Information
|
||||||
|
|
||||||
|
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
|
||||||
|
|
||||||
|
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
### Trademarks
|
||||||
|
|
||||||
|
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
|
||||||
|
|
||||||
|
### Company Information
|
||||||
|
|
||||||
|
Task Venture Capital GmbH
|
||||||
|
Registered at District court Bremen HRB 35230 HB, Germany
|
||||||
|
|
||||||
|
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
|
||||||
|
|
||||||
|
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
|
1
test/test.d.ts
vendored
1
test/test.d.ts
vendored
@ -1 +0,0 @@
|
|||||||
import "typings-test";
|
|
36
test/test.js
36
test/test.js
@ -1,36 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
require("typings-test");
|
|
||||||
const smartcli = require("../dist/index");
|
|
||||||
let beautylog = require("beautylog");
|
|
||||||
let should = require("should");
|
|
||||||
describe("smartcli.Smartcli class", function () {
|
|
||||||
let smartCliTestObject;
|
|
||||||
describe("new Smartcli()", function () {
|
|
||||||
it("should create a new Smartcli", function () {
|
|
||||||
smartCliTestObject = new smartcli.Smartcli();
|
|
||||||
smartCliTestObject.should.be.instanceof(smartcli.Smartcli);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
describe(".addCommand", function () {
|
|
||||||
it("should add an command", function () {
|
|
||||||
smartCliTestObject.addCommand({
|
|
||||||
commandName: "awesome"
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
describe(".standardTask", function () {
|
|
||||||
it("should start parsing a standardTask", function (done) {
|
|
||||||
smartCliTestObject.standardTask()
|
|
||||||
.then(() => {
|
|
||||||
console.log("this is the standard Task!");
|
|
||||||
});
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
describe(".startParse", function () {
|
|
||||||
it("should start parsing the CLI input", function () {
|
|
||||||
smartCliTestObject.startParse();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sY0FBYyxDQUFDLENBQUE7QUFFdEIsTUFBTyxRQUFRLFdBQVcsZUFBZSxDQUFDLENBQUM7QUFDM0MsSUFBSSxTQUFTLEdBQUcsT0FBTyxDQUFDLFdBQVcsQ0FBQyxDQUFDO0FBQ3JDLElBQUksTUFBTSxHQUFHLE9BQU8sQ0FBQyxRQUFRLENBQUMsQ0FBQztBQUUvQixRQUFRLENBQUMseUJBQXlCLEVBQUM7SUFDL0IsSUFBSSxrQkFBb0MsQ0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,wBAAwB,GAAG;IAC3B,QAAQ,CAAC,WAAW,CAAC,SAAS,CAAC,iCAAiC,EAAC,CAAC,MAAM,EAAC,OAAO,EAAC,WAAW,CAAC,EAAC,UAAS,MAAM;QACzG,OAAO,CAAC,GAAG,CAAC,iBAAiB,GAAG,MAAM,CAAC,CAAC;QACxC,QAAQ,EAAE,CAAC;IACf,CAAC,CAAC,CAAC;AACP,CAAC,CAAC;AAEF,IAAI,QAAQ,GAAG;IACX,SAAS,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC;IAC/B,SAAS,CAAC,OAAO,CAAC,+BAA+B,CAAC,CAAC;AACvD,CAAC,CAAC;AAEF,EAAE,CAAA,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAA,CAAC;IACjC,wBAAwB,EAAE,CAAC;AAC/B,CAAC;AAAC,IAAI,CAAC,CAAC;IACJ,SAAS,CAAC,IAAI,CAAC,0EAA0E,CAAC,CAAC;IAC3F,QAAQ,EAAE,CAAC;AACf,CAAC;AAAA,CAAC"}
|
|
73
test/test.ts
73
test/test.ts
@ -1,37 +1,42 @@
|
|||||||
import "typings-test";
|
import { tap, expect } from '@push.rocks/tapbundle';
|
||||||
|
import * as smartrx from '@push.rocks/smartrx';
|
||||||
|
|
||||||
import smartcli = require("../dist/index");
|
import * as smartcli from '../ts/index.js';
|
||||||
let beautylog = require("beautylog");
|
|
||||||
let should = require("should");
|
|
||||||
|
|
||||||
describe("smartcli.Smartcli class",function(){
|
tap.test('should create a new Smartcli', async () => {
|
||||||
let smartCliTestObject:smartcli.Smartcli;
|
const smartCliTestObject = new smartcli.Smartcli();
|
||||||
describe("new Smartcli()",function(){
|
expect(smartCliTestObject).toBeInstanceOf(smartcli.Smartcli);
|
||||||
it("should create a new Smartcli",function(){
|
|
||||||
smartCliTestObject = new smartcli.Smartcli();
|
|
||||||
smartCliTestObject.should.be.instanceof(smartcli.Smartcli);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
describe(".addCommand",function(){
|
|
||||||
it("should add an command",function(){
|
|
||||||
smartCliTestObject.addCommand({
|
|
||||||
commandName:"awesome"
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
});
|
|
||||||
describe(".standardTask",function(){
|
|
||||||
it("should start parsing a standardTask",function(done){
|
|
||||||
smartCliTestObject.standardTask()
|
|
||||||
.then(() => {
|
|
||||||
console.log("this is the standard Task!");
|
|
||||||
});
|
|
||||||
done();
|
|
||||||
})
|
|
||||||
})
|
|
||||||
describe(".startParse",function(){
|
|
||||||
it("should start parsing the CLI input",function(){
|
|
||||||
smartCliTestObject.startParse();
|
|
||||||
})
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
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(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 () => {
|
||||||
|
const smartCliTestObject = new smartcli.Smartcli();
|
||||||
|
expect(smartCliTestObject.standardCommand()).toBeInstanceOf(smartrx.rxjs.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
8
ts/00_commitinfo_data.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
/**
|
||||||
|
* autocreated commitinfo by @pushrocks/commitinfo
|
||||||
|
*/
|
||||||
|
export const commitinfo = {
|
||||||
|
name: '@push.rocks/smartcli',
|
||||||
|
version: '4.0.11',
|
||||||
|
description: 'A library for easily creating observable CLI tasks with support for commands, arguments, and options.'
|
||||||
|
}
|
@ -1,4 +1 @@
|
|||||||
import "typings-global";
|
export { Smartcli } from './smartcli.classes.smartcli.js';
|
||||||
|
|
||||||
import {Smartcli} from "./smartcli.classes.smartcli";
|
|
||||||
export {Smartcli} from "./smartcli.classes.smartcli";
|
|
||||||
|
@ -1,59 +0,0 @@
|
|||||||
import "typings-global";
|
|
||||||
|
|
||||||
import "./smartcli.interfaces";
|
|
||||||
import plugins = require("./smartcli.plugins");
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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}
|
|
||||||
*/
|
|
||||||
export let getAnswer = function(questionString:string, cb) {
|
|
||||||
if (typeof questionString != 'string') {
|
|
||||||
plugins.beautylog.error('no question specified');
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
//make inquirer compatible question object
|
|
||||||
let question = {
|
|
||||||
type: "input",
|
|
||||||
name: "userFeedback",
|
|
||||||
message: questionString,
|
|
||||||
validate: function( value ) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
plugins.inquirer.prompt([question],function(answers){
|
|
||||||
let answer = answers.userFeedback;
|
|
||||||
cb(answer);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param questionString
|
|
||||||
* @param choiceOptions
|
|
||||||
* @param cb
|
|
||||||
* @returns {null}
|
|
||||||
*/
|
|
||||||
export let getChoice = function(questionString:string, choiceOptions:string[], cb) {
|
|
||||||
if(!Array.isArray(choiceOptions)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
//make inquirer compatible question object
|
|
||||||
let question = {
|
|
||||||
type: "list",
|
|
||||||
name: "userFeedback",
|
|
||||||
message: questionString,
|
|
||||||
choices: choiceOptions,
|
|
||||||
filter: function( val ) { return val.toLowerCase(); }
|
|
||||||
};
|
|
||||||
|
|
||||||
plugins.inquirer.prompt(question,function(answers){
|
|
||||||
let answer = answers.userFeedback;
|
|
||||||
cb(answer);
|
|
||||||
});
|
|
||||||
|
|
||||||
};
|
|
@ -1,8 +0,0 @@
|
|||||||
import "typings-global";
|
|
||||||
import * as plugins from "./smartcli.plugins";
|
|
||||||
|
|
||||||
export class Question {
|
|
||||||
constructor(){
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,83 +1,174 @@
|
|||||||
import "typings-global";
|
import * as plugins from './smartcli.plugins.js';
|
||||||
|
|
||||||
import * as plugins from "./smartcli.plugins";
|
// interfaces
|
||||||
import {Question} from "./smartcli.classes.interaction";
|
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 {
|
export class Smartcli {
|
||||||
argv;
|
/**
|
||||||
questionsDone;
|
* this Deferred contains the parsed result in the end
|
||||||
parseStarted;
|
*/
|
||||||
commands;
|
public parseCompleted = plugins.smartpromise.defer<any>();
|
||||||
questions;
|
|
||||||
version:string;
|
public version: string;
|
||||||
constructor(){
|
|
||||||
this.argv = plugins.argv;
|
|
||||||
this.questionsDone = plugins.q.defer();
|
|
||||||
this.parseStarted = plugins.q.defer();
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* adds an alias, meaning one equals the other in terms of triggering associated commands
|
* map of all Trigger/Observable objects to keep track
|
||||||
*/
|
*/
|
||||||
addAlias(keyArg,aliasArg){
|
private commandObservableMap = new plugins.lik.ObjectMap<ICommandObservableObject>();
|
||||||
this.argv = this.argv.alias(keyArg,aliasArg);
|
|
||||||
};
|
/**
|
||||||
|
* 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.
|
* 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.
|
* Note: in e.g. "npm install something" the "install" is considered the command.
|
||||||
*/
|
*/
|
||||||
addCommand(definitionArg:{commandName:string}){
|
public addCommand(commandNameArg: string): plugins.smartrx.rxjs.Subject<any> {
|
||||||
let done = plugins.q.defer();
|
let commandSubject: plugins.smartrx.rxjs.Subject<any>;
|
||||||
this.parseStarted.promise
|
const existingCommandSubject = this.getCommandSubject(commandNameArg);
|
||||||
.then(() => {
|
commandSubject = existingCommandSubject || new plugins.smartrx.rxjs.Subject<any>();
|
||||||
if (this.argv._.indexOf(definitionArg.commandName) == 0) {
|
|
||||||
done.resolve(this.argv);
|
this.commandObservableMap.add({
|
||||||
} else {
|
commandName: commandNameArg,
|
||||||
done.reject(this.argv);
|
subject: commandSubject,
|
||||||
}
|
|
||||||
});
|
});
|
||||||
return done.promise;
|
return commandSubject;
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gets a Promise for a command word
|
* execute trigger by name
|
||||||
|
* @param commandNameArg - the name of the command to trigger
|
||||||
*/
|
*/
|
||||||
getCommandPromise(commandNameArg){
|
public triggerCommand(commandNameArg: string, argvObject: any) {
|
||||||
//TODO
|
const triggerSubject = this.getCommandSubject(commandNameArg);
|
||||||
|
triggerSubject.next(argvObject);
|
||||||
|
return triggerSubject;
|
||||||
}
|
}
|
||||||
addQuestion(definitionArg:{questionString:string,questionType:string}){
|
|
||||||
|
|
||||||
};
|
|
||||||
addHelp(){
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gets the command subject for the specified name.
|
||||||
|
* call this before calling .parse()
|
||||||
|
* @param commandNameArg
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
public getCommandSubject(commandNameArg: string) {
|
||||||
|
const triggerObservableObject = this.commandObservableMap.findSync(
|
||||||
|
(triggerObservableObjectArg) => {
|
||||||
|
return triggerObservableObjectArg.commandName === commandNameArg;
|
||||||
}
|
}
|
||||||
addVersion(versionArg:string){
|
);
|
||||||
this.version = versionArg;
|
if (triggerObservableObject) {
|
||||||
this.addAlias("v","version");
|
return triggerObservableObject.subject;
|
||||||
this.parseStarted.promise
|
|
||||||
.then(() => {
|
|
||||||
if(this.argv.v){
|
|
||||||
console.log(this.version);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
standardTask(){
|
|
||||||
let done = plugins.q.defer();
|
|
||||||
this.parseStarted.promise
|
|
||||||
.then(() => {
|
|
||||||
if(this.argv._.length == 0 && !this.argv.v){
|
|
||||||
done.resolve(this.argv);
|
|
||||||
} else {
|
} else {
|
||||||
done.reject(this.argv);
|
return null;
|
||||||
};
|
|
||||||
});
|
|
||||||
return done.promise;
|
|
||||||
}
|
}
|
||||||
startParse(){
|
|
||||||
this.argv = this.argv.argv;
|
|
||||||
this.parseStarted.resolve();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* getOption
|
||||||
|
*/
|
||||||
|
public getOption(optionNameArg: string) {
|
||||||
|
const parsedYargs = plugins.yargsParser(process.argv);
|
||||||
|
return parsedYargs[optionNameArg];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,10 +1,14 @@
|
|||||||
import "typings-global";
|
// @pushrocks scope
|
||||||
|
import * as smartlog from '@push.rocks/smartlog';
|
||||||
|
import * as lik from '@push.rocks/lik';
|
||||||
|
import * as path from 'path';
|
||||||
|
import * as smartparam from '@push.rocks/smartobject';
|
||||||
|
import * as smartpromise from '@push.rocks/smartpromise';
|
||||||
|
import * as smartrx from '@push.rocks/smartrx';
|
||||||
|
|
||||||
export let argv = require('yargs');
|
export { smartlog, lik, path, smartparam, smartpromise, smartrx };
|
||||||
export import beautylog = require("beautylog");
|
|
||||||
export let cliff = require("cliff");
|
// thirdparty scope
|
||||||
export let inquirer = require("inquirer");
|
import yargsParser from 'yargs-parser';
|
||||||
export import lik = require("lik");
|
|
||||||
export let path = require("path");
|
export { yargsParser };
|
||||||
export import q = require("q");
|
|
||||||
export import smartparam = require("smartparam");
|
|
||||||
|
14
tsconfig.json
Normal file
14
tsconfig.json
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"useDefineForClassFields": false,
|
||||||
|
"target": "ES2022",
|
||||||
|
"module": "NodeNext",
|
||||||
|
"moduleResolution": "NodeNext",
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"verbatimModuleSyntax": true
|
||||||
|
},
|
||||||
|
"exclude": [
|
||||||
|
"dist_*/**/*.d.ts"
|
||||||
|
]
|
||||||
|
}
|
Reference in New Issue
Block a user