Skip to content

Commit 7fba338

Browse files
authored
support command line arguments (#74)
* add --port --host arguments * update readme * 2.1.0
1 parent ae55e64 commit 7fba338

6 files changed

Lines changed: 100 additions & 31 deletions

File tree

modules/test/README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
[![npm](https://img.shields.io/npm/v/@themost%2Ftest.svg)](https://www.npmjs.com/package/@themost%2Ftest)
22
![](https://github.com/themost-framework/themost-test/workflows/test/badge.svg)
3-
![](https://img.shields.io/david/themost-framework/themost-test?path=modules%2Ftest) ![](https://img.shields.io/david/peer/themost-framework/themost-test?path=modules%2Ftest)
4-
![](https://img.shields.io/david/dev/themost-framework/themost-test?path=modules%2Ftest)
5-
![GitHub top language](https://img.shields.io/github/languages/top/themost-framework/themost-test)
6-
[![License](https://img.shields.io/npm/l/@themost/test)](https://github.com/themost-framework/themost-test/blob/master/LICENSE)
7-
![GitHub last commit](https://img.shields.io/github/last-commit/themost-framework/themost-test)
8-
![GitHub Release Date](https://img.shields.io/github/release-date/themost-framework/themost-test)
3+
![GitHub top language](https://img.shields.io/github/languages/top/themost-framework/test)
4+
[![License](https://img.shields.io/npm/l/@themost/test)](https://github.com/themost-framework/test/blob/master/LICENSE)
5+
![GitHub last commit](https://img.shields.io/github/last-commit/themost-framework/test)
6+
![GitHub Release Date](https://img.shields.io/github/release-date/themost-framework/test)
97
[![npm](https://img.shields.io/npm/dw/@themost/test)](https://www.npmjs.com/package/@themost%2Ftest)
108
[![Snyk Vulnerabilities for npm package](https://img.shields.io/snyk/vulnerabilities/npm/@themost/test)](https://snyk.io/vuln/npm:%40themost%2Ftest)
119

@@ -20,7 +18,11 @@ This project contains a test api server for testing libraries and modules.
2018
2119
### Usage
2220

23-
Create a jasmine test spec and start testing api server
21+
`@themost/test` may be started as standalone application by using the following command:
22+
23+
npx @themost/test [--port] [--host]
24+
25+
or being started it as backend server in any testing environment:
2426

2527
import { getApplication, serveApplication, getServerAddress } from "@themost/test";
2628
import fetch from "node-fetch";

modules/test/package-lock.json

Lines changed: 31 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

modules/test/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@themost/test",
3-
"version": "2.0.0",
3+
"version": "2.1.0",
44
"description": "MOST Web Framework Test Api Server",
55
"repository": "https://github.com/themost-framework/themost-test.git",
66
"author": "Kyriakos Barbounakis<k.barbounakis@gmail.com>",
@@ -26,6 +26,7 @@
2626
"@themost/sqlite": "^2.6.12",
2727
"@themost/web": "^2.5.16",
2828
"@themost/xml": "^2.5.2",
29+
"commander": "^10.0.0",
2930
"cors": "^2.8.5",
3031
"debug": "~2.6.9",
3132
"ejs": "^3.1.6",

modules/test/server/standalone.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,20 @@
99
import {serveApplication} from './serve';
1010
import debug from 'debug';
1111
import {getApplication} from './app';
12+
import { Command, Option } from 'commander';
1213
const log = debug('themost-framework:test');
1314
(async function() {
1415
try {
15-
await serveApplication(getApplication(), process.env.PORT, process.env.IP);
16+
const program = new Command();
17+
program
18+
.name('npx @themost/test')
19+
.description('starts @themost-framework test api server')
20+
.version('2')
21+
.addOption(new Option('-p, --port <number>', 'port number').env('PORT'))
22+
.addOption(new Option('-h, --host <string>', 'host address').env('IP'))
23+
program.parse();
24+
const args = program.opts();
25+
await serveApplication(getApplication(), args.port, args.host);
1626
}
1727
catch(err) {
1828
log(err);

package-lock.json

Lines changed: 45 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,14 @@
3939
"@themost/sqlite": "^2.6.12",
4040
"@themost/web": "^2.5.16",
4141
"@themost/xml": "^2.5.2",
42+
"@types/commander": "^2.12.2",
4243
"@types/express": "^4.17.13",
4344
"@types/jasmine": "^3.10.0",
4445
"@types/lodash": "^4.14.175",
4546
"@types/node-fetch": "^2.6.2",
4647
"@types/passport": "^1.0.7",
4748
"babel-eslint": "^10.1.0",
49+
"commander": "^10.0.0",
4850
"cors": "^2.8.5",
4951
"es6-promisify": "^6.1.1",
5052
"eslint": "^7.32.0",

0 commit comments

Comments
 (0)