@koeroesi86/node-webserver-cli 20.10.2-0efe879 → 26.10.37037987262-master

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,11 +1,13 @@
1
- # @koeroesi86/node-webserver-cli [![Build Status](https://travis-ci.com/Koeroesi86/node-webserver-cli.svg?branch=master)](https://travis-ci.com/Koeroesi86/node-webserver-cli)
1
+ # @koeroesi86/node-webserver-cli
2
+
3
+ CLI for [@koeroesi86/node-webserver](../node-webserver).
2
4
 
3
5
  ### Dependencies to run
4
6
  * [NodeJS](https://nodejs.org/en/)
5
- * [Yarn](https://yarnpkg.com/en/)
6
7
 
7
8
  ### Usage:
8
9
 
9
10
  ```shell script
10
- yarn nws-cli --config </path/to/config>
11
- ```
11
+ npm install @koeroesi86/node-webserver-cli
12
+ npx nws-cli --config </path/to/config>
13
+ ```
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ const path_1 = require("path");
8
+ const node_webserver_1 = __importDefault(require("@koeroesi86/node-webserver"));
9
+ const parseArgv_1 = __importDefault(require("../utils/parseArgv"));
10
+ const { config } = (0, parseArgv_1.default)();
11
+ if (typeof config !== 'string') {
12
+ throw new Error('use with --config </path/to/config>');
13
+ }
14
+ (async () => {
15
+ await new Promise((r) => setTimeout(r, 1));
16
+ const configuration = require((0, path_1.resolve)(config));
17
+ await (0, node_webserver_1.default)(configuration);
18
+ })();
19
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/scripts/cli.ts"],"names":[],"mappings":";;;;;;AAEA,+BAA+B;AAC/B,gFAAqD;AACrD,mEAA2C;AAE3C,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,mBAAS,GAAE,CAAC;AAE/B,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;IAC/B,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;AACzD,CAAC;AAED,CAAC,KAAK,IAAI,EAAE;IACV,MAAM,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC3C,MAAM,aAAa,GAAsC,OAAO,CAAC,IAAA,cAAO,EAAC,MAAM,CAAC,CAAC,CAAC;IAClF,MAAM,IAAA,wBAAW,EAAC,aAAa,CAAC,CAAC;AACnC,CAAC,CAAC,EAAE,CAAC"}
@@ -0,0 +1,5 @@
1
+ export interface ParsedArgv {
2
+ [key: string]: string | boolean | undefined;
3
+ }
4
+ declare function parseArgv(argv?: string[]): ParsedArgv;
5
+ export default parseArgv;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const ARGUMENT_PATTERN = /[-]{1,2}([a-zA-Z0-9-]+)[=]?["']?([a-zA-Z0-9/\\.\-:]+)*["']?/;
4
+ const VALUE_PATTERN = /["']?([a-zA-Z0-9/\\.\-:]+)*["']?/;
5
+ function parseArgv(argv = process.argv) {
6
+ let skipNext = false;
7
+ return argv.reduce((result, current, index) => {
8
+ if (index < 2) {
9
+ result[index] = current;
10
+ return result;
11
+ }
12
+ if (current.indexOf('-') !== 0) {
13
+ return result;
14
+ }
15
+ if (skipNext) {
16
+ skipNext = false;
17
+ return result;
18
+ }
19
+ const matches = current.match(ARGUMENT_PATTERN);
20
+ if (!matches) {
21
+ return result;
22
+ }
23
+ const [, key, inlineValue] = matches;
24
+ result[key] = inlineValue || true;
25
+ const nextArgument = argv[index + 1];
26
+ if (inlineValue || !nextArgument || nextArgument.indexOf('-') === 0) {
27
+ return result;
28
+ }
29
+ // handle spaces
30
+ skipNext = true;
31
+ result[key] = nextArgument.match(VALUE_PATTERN)?.[1];
32
+ return result;
33
+ }, {});
34
+ }
35
+ exports.default = parseArgv;
36
+ //# sourceMappingURL=parseArgv.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseArgv.js","sourceRoot":"","sources":["../../src/utils/parseArgv.ts"],"names":[],"mappings":";;AAIA,MAAM,gBAAgB,GAAG,6DAA6D,CAAC;AACvF,MAAM,aAAa,GAAG,kCAAkC,CAAC;AAEzD,SAAS,SAAS,CAAC,OAAiB,OAAO,CAAC,IAAI;IAC9C,IAAI,QAAQ,GAAG,KAAK,CAAC;IAErB,OAAO,IAAI,CAAC,MAAM,CAAa,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE;QACxD,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;YACd,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC;YACxB,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,IAAI,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/B,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,IAAI,QAAQ,EAAE,CAAC;YACb,QAAQ,GAAG,KAAK,CAAC;YACjB,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;QAEhD,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,MAAM,CAAC,EAAE,GAAG,EAAE,WAAW,CAAC,GAAG,OAAO,CAAC;QACrC,MAAM,CAAC,GAAG,CAAC,GAAG,WAAW,IAAI,IAAI,CAAC;QAElC,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;QAErC,IAAI,WAAW,IAAI,CAAC,YAAY,IAAI,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YACpE,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,gBAAgB;QAChB,QAAQ,GAAG,IAAI,CAAC;QAChB,MAAM,CAAC,GAAG,CAAC,GAAG,YAAY,CAAC,KAAK,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QACrD,OAAO,MAAM,CAAC;IAChB,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC;AAED,kBAAe,SAAS,CAAC"}
@@ -1,11 +1,10 @@
1
1
  const path = require('path');
2
2
 
3
3
  module.exports = {
4
- serverOptions: {
5
- hostname: 'web.localhost',
6
- protocol: 'http',
7
- },
8
- workerOptions: {
4
+ hostname: 'web.localhost',
5
+ protocol: 'http',
6
+ type: 'worker', // 'child'|'lambda'|'worker'
7
+ options: {
9
8
  root: path.resolve(__dirname, 'worker'),
10
9
  index: [
11
10
  'index.js'
package/package.json CHANGED
@@ -1,24 +1,39 @@
1
1
  {
2
2
  "name": "@koeroesi86/node-webserver-cli",
3
- "version": "v20.10.2-0efe879",
3
+ "version": "26.10.37037987262-master",
4
4
  "license": "MIT",
5
- "description": "A local Lambda implementation",
5
+ "description": "CLI for @koeroesi86/node-webserver",
6
6
  "author": {
7
7
  "name": "Krisztian Korosi",
8
8
  "url": "https://github.com/Koeroesi86"
9
9
  },
10
- "repository": "github:Koeroesi86/node-webserver",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/Koeroesi86/node-webserver.git",
13
+ "directory": "packages/node-webserver-cli"
14
+ },
11
15
  "publishConfig": {
12
16
  "access": "public"
13
17
  },
14
18
  "bin": {
15
- "nws-cli": "./scripts/cli.js"
16
- },
17
- "scripts": {
18
- "start": "node ./scripts/cli.js --config configuration.example.js",
19
- "generate-version": "node ./scripts/version.js"
19
+ "nws-cli": "./dist/scripts/cli.js"
20
20
  },
21
21
  "dependencies": {
22
- "@koeroesi86/node-webserver": "^20.10.110-b4111b6"
22
+ "@koeroesi86/node-webserver": "26.10.36916718511-master"
23
+ },
24
+ "files": [
25
+ "dist",
26
+ "examples",
27
+ "configuration.example.js"
28
+ ],
29
+ "devDependencies": {
30
+ "@types/node": "^24.0.0",
31
+ "rimraf": "^3.0.2",
32
+ "typescript": "^5.9.3"
33
+ },
34
+ "gitHead": "182f09e0bfed105bc09c66b8d918dfa264bd9827",
35
+ "scripts": {
36
+ "build": "rimraf dist && tsc -p tsconfig.json",
37
+ "start": "node dist/scripts/cli.js --config configuration.example.js"
23
38
  }
24
- }
39
+ }
package/.travis.yml DELETED
@@ -1,19 +0,0 @@
1
- language: node_js
2
- node_js:
3
- - "12"
4
- cache:
5
- yarn: true
6
- directories:
7
- - node_modules
8
- - .cache
9
- script:
10
- - export YARN_CACHE_FOLDER=$TRAVIS_BUILD_DIR/.cache/yarn
11
- - export NODE_ENV=production
12
- - export TRAVIS_TAG="$(git rev-parse --short ${TRAVIS_COMMIT})"
13
- - yarn generate-version
14
- deploy:
15
- branch: master
16
- provider: npm
17
- skip_cleanup: true
18
- email: $NPM_EMAIL
19
- api_key: $NPM_TOKEN
package/scripts/cli.js DELETED
@@ -1,17 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const path = require('path');
4
- const { startServer } = require('@koeroesi86/node-webserver');
5
- const parseArgv = require('../utils/parseArgv');
6
-
7
- const { config } = parseArgv();
8
-
9
- if (!config) {
10
- throw new Error('use with --config </path/to/config>');
11
- }
12
-
13
- (async () => {
14
- await new Promise(r => setTimeout(r, 1));
15
- const configuration = require(path.resolve(config));
16
- await startServer(configuration);
17
- })();
@@ -1,9 +0,0 @@
1
- const { execSync } = require('child_process');
2
-
3
- const { TRAVIS_TAG, TRAVIS_BUILD_NUMBER } = process.env;
4
-
5
- const now = new Date();
6
- const version = `${(now.getFullYear() + '').substring(2)}.${((now.getMonth() + 1) + '').padStart(2, '0')}.${TRAVIS_BUILD_NUMBER}-${TRAVIS_TAG || 'release'}`;
7
-
8
- execSync(`yarn version --no-git-tag-version --new-version "v${version}"`, { shell: true });
9
- console.log('version set', version);
@@ -1,38 +0,0 @@
1
- /**
2
- * @param {string[]} argv
3
- * @returns {Object}
4
- */
5
- function parseArgv(argv = process.argv) {
6
- let skipNext = false;
7
- const parsedArgv =argv.reduce((result, current, index) => {
8
- if (index < 2) {
9
- result[index] = current;
10
- return result;
11
- }
12
-
13
- if (current.indexOf('-') === 0) {
14
- if (skipNext) {
15
- skipNext = false;
16
- return result;
17
- }
18
- const matches = current.match(/[-]{1,2}([a-zA-Z0-9\-]+)[=]?["']?([a-zA-Z0-9/\\.\-:]+)*["']?/);
19
- result[matches[1]] = true;
20
- if (matches[2]) {
21
- // if there is value set
22
- result[matches[1]] = matches[2];
23
- } else if (argv[Number(index) + 1] && argv[Number(index) + 1].indexOf('-') !== 0) {
24
- // handle spaces
25
- skipNext = true;
26
- result[matches[1]] = argv[Number(index) + 1].match(/["']?([a-zA-Z0-9/\\.\-:]+)*["']?/)[1];
27
- return result;
28
- }
29
- return result;
30
- }
31
-
32
- return result;
33
- }, {});
34
-
35
- return parsedArgv;
36
- }
37
-
38
- module.exports = parseArgv;