@koeroesi86/node-webserver-service 22.3.25-9a65a76 → 26.10.37633705232-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/.logs/.gitkeep +0 -0
- package/README.md +3 -4
- package/configuration.example.js +30 -0
- package/dist/constants/index.d.ts +3 -0
- package/dist/constants/index.js +8 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/scripts/manageService.d.ts +2 -0
- package/dist/scripts/manageService.js +51 -0
- package/dist/scripts/manageService.js.map +1 -0
- package/dist/scripts/start.d.ts +1 -0
- package/dist/scripts/start.js +16 -0
- package/dist/scripts/start.js.map +1 -0
- package/dist/types.d.ts +5 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/parseArgv.d.ts +5 -0
- package/dist/utils/parseArgv.js +36 -0
- package/dist/utils/parseArgv.js.map +1 -0
- package/dist/utils/start.d.ts +2 -0
- package/dist/utils/start.js +15 -0
- package/dist/utils/start.js.map +1 -0
- package/package.json +26 -11
- package/.travis.yml +0 -19
- package/scripts/manageService.js +0 -54
- package/scripts/start.js +0 -14
- package/scripts/version.js +0 -9
- package/utils/parseArgv.js +0 -38
- package/utils/start.js +0 -8
package/.logs/.gitkeep
ADDED
|
File without changes
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @koeroesi86/node-webserver-service
|
|
2
2
|
|
|
3
3
|
OS service integration for @koeroesi86/node-webserver
|
|
4
4
|
|
|
@@ -6,7 +6,6 @@ This package brings ability to deploy webapps a lot easier. Just copy [configura
|
|
|
6
6
|
|
|
7
7
|
### Dependencies to run
|
|
8
8
|
* [NodeJS](https://nodejs.org/en/)
|
|
9
|
-
* [Yarn](https://yarnpkg.com/en/)
|
|
10
9
|
* For Windows usage
|
|
11
10
|
1. [Python](https://www.python.org/)
|
|
12
11
|
1. [Visual C++ Build Tools](https://www.visualstudio.com/downloads/#build-tools-for-visual-studio-2017)
|
|
@@ -22,13 +21,13 @@ This package brings ability to deploy webapps a lot easier. Just copy [configura
|
|
|
22
21
|
### Usage
|
|
23
22
|
|
|
24
23
|
```shell script
|
|
25
|
-
|
|
24
|
+
npm install @koeroesi86/node-webserver-service
|
|
26
25
|
```
|
|
27
26
|
|
|
28
27
|
Please enter in a console/terminal:
|
|
29
28
|
|
|
30
29
|
```shell script
|
|
31
|
-
|
|
30
|
+
npx nws-service [argument]
|
|
32
31
|
|
|
33
32
|
arguments:
|
|
34
33
|
--add Installs the service
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
|
|
3
|
+
process.chdir(__dirname);
|
|
4
|
+
|
|
5
|
+
module.exports = {
|
|
6
|
+
serviceName: 'node-webserver',
|
|
7
|
+
serviceDisplayName: 'NodeJS Webserver',
|
|
8
|
+
// fileLogPath: path.resolve(__dirname, './.logs/'),
|
|
9
|
+
fileLogPath: null,
|
|
10
|
+
logLevels: {
|
|
11
|
+
system: true,
|
|
12
|
+
info: true,
|
|
13
|
+
success: true,
|
|
14
|
+
error: true,
|
|
15
|
+
warning: true,
|
|
16
|
+
},
|
|
17
|
+
// portHttp: 80,
|
|
18
|
+
// portHttps: 443,
|
|
19
|
+
// portLookup: {
|
|
20
|
+
// from: 3000,
|
|
21
|
+
// to: 3010,
|
|
22
|
+
// address: 'localhost'
|
|
23
|
+
// },
|
|
24
|
+
portLookup: false,
|
|
25
|
+
statsDomain: 'stats.localhost', // set to false to disable
|
|
26
|
+
statsRefreshInterval: 10000,
|
|
27
|
+
servers: [
|
|
28
|
+
path.resolve('./examples/serverConfig.js'),
|
|
29
|
+
]
|
|
30
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_CONFIGURATION_PATH = exports.PACKAGE_ROOT = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
/** folder of the package, both from src/ and dist/ */
|
|
6
|
+
exports.PACKAGE_ROOT = (0, path_1.resolve)(__dirname, '../..');
|
|
7
|
+
exports.DEFAULT_CONFIGURATION_PATH = (0, path_1.resolve)(exports.PACKAGE_ROOT, 'configuration.example.js');
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":";;;AAAA,+BAA+B;AAE/B,sDAAsD;AACzC,QAAA,YAAY,GAAG,IAAA,cAAO,EAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AAE3C,QAAA,0BAA0B,GAAG,IAAA,cAAO,EAAC,oBAAY,EAAE,0BAA0B,CAAC,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
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 os_service_1 = __importDefault(require("os-service"));
|
|
8
|
+
const fs_1 = require("fs");
|
|
9
|
+
const parseArgv_1 = __importDefault(require("../utils/parseArgv"));
|
|
10
|
+
const start_1 = __importDefault(require("../utils/start"));
|
|
11
|
+
const constants_1 = require("../constants");
|
|
12
|
+
const { add, remove, run, configuration } = (0, parseArgv_1.default)();
|
|
13
|
+
const configPath = (typeof configuration === 'string' && configuration) || process.env.NODE_WEBSERVER_CONFIG || constants_1.DEFAULT_CONFIGURATION_PATH;
|
|
14
|
+
if (!(0, fs_1.existsSync)(configPath)) {
|
|
15
|
+
throw new Error(`Configuration file does not exist: ${configPath}`);
|
|
16
|
+
}
|
|
17
|
+
const Configuration = require(configPath);
|
|
18
|
+
const handleError = (error) => {
|
|
19
|
+
if (error) {
|
|
20
|
+
console.trace(error);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
if (add) {
|
|
24
|
+
os_service_1.default.add(Configuration.serviceName, {
|
|
25
|
+
displayName: Configuration.serviceDisplayName || Configuration.serviceName,
|
|
26
|
+
programPath: __filename,
|
|
27
|
+
programArgs: ['--run', ...process.argv.slice(3)],
|
|
28
|
+
}, handleError);
|
|
29
|
+
}
|
|
30
|
+
else if (remove) {
|
|
31
|
+
os_service_1.default.remove(Configuration.serviceName, handleError);
|
|
32
|
+
}
|
|
33
|
+
else if (run) {
|
|
34
|
+
(0, start_1.default)(configPath);
|
|
35
|
+
os_service_1.default.run(() => {
|
|
36
|
+
os_service_1.default.stop(0);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
console.info('\x1b[32m%s\x1b[0m', `
|
|
41
|
+
Usage:
|
|
42
|
+
|
|
43
|
+
pnpm run service [argument]
|
|
44
|
+
|
|
45
|
+
arguments:
|
|
46
|
+
--add Installs the service
|
|
47
|
+
--remove Removes the service
|
|
48
|
+
--run Attempt to run the program as a service
|
|
49
|
+
`);
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=manageService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manageService.js","sourceRoot":"","sources":["../../src/scripts/manageService.ts"],"names":[],"mappings":";;;;;;AAEA,4DAAiC;AACjC,2BAAgC;AAChC,mEAA2C;AAC3C,2DAAmC;AACnC,4CAA0D;AAG1D,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,aAAa,EAAE,GAAG,IAAA,mBAAS,GAAE,CAAC;AAExD,MAAM,UAAU,GAAG,CAAC,OAAO,aAAa,KAAK,QAAQ,IAAI,aAAa,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,sCAA0B,CAAC;AAE3I,IAAI,CAAC,IAAA,eAAU,EAAC,UAAU,CAAC,EAAE,CAAC;IAC5B,MAAM,IAAI,KAAK,CAAC,sCAAsC,UAAU,EAAE,CAAC,CAAC;AACtE,CAAC;AAED,MAAM,aAAa,GAAyB,OAAO,CAAC,UAAU,CAAC,CAAC;AAEhE,MAAM,WAAW,GAAG,CAAC,KAAa,EAAQ,EAAE;IAC1C,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;AACH,CAAC,CAAC;AAEF,IAAI,GAAG,EAAE,CAAC;IACR,oBAAO,CAAC,GAAG,CACT,aAAa,CAAC,WAAW,EACzB;QACE,WAAW,EAAE,aAAa,CAAC,kBAAkB,IAAI,aAAa,CAAC,WAAW;QAC1E,WAAW,EAAE,UAAU;QACvB,WAAW,EAAE,CAAC,OAAO,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;KACjD,EACD,WAAW,CACZ,CAAC;AACJ,CAAC;KAAM,IAAI,MAAM,EAAE,CAAC;IAClB,oBAAO,CAAC,MAAM,CAAC,aAAa,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;AACzD,CAAC;KAAM,IAAI,GAAG,EAAE,CAAC;IACf,IAAA,eAAK,EAAC,UAAU,CAAC,CAAC;IAClB,oBAAO,CAAC,GAAG,CAAC,GAAG,EAAE;QACf,oBAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC;KAAM,CAAC;IACN,OAAO,CAAC,IAAI,CACV,mBAAmB,EACnB;;;;;;;;;KASC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const fs_1 = require("fs");
|
|
7
|
+
const parseArgv_1 = __importDefault(require("../utils/parseArgv"));
|
|
8
|
+
const start_1 = __importDefault(require("../utils/start"));
|
|
9
|
+
const constants_1 = require("../constants");
|
|
10
|
+
const { configuration } = (0, parseArgv_1.default)();
|
|
11
|
+
const configPath = (typeof configuration === 'string' && configuration) || process.env.NODE_WEBSERVER_CONFIG || constants_1.DEFAULT_CONFIGURATION_PATH;
|
|
12
|
+
if (!(0, fs_1.existsSync)(configPath)) {
|
|
13
|
+
(0, fs_1.copyFileSync)(constants_1.DEFAULT_CONFIGURATION_PATH, configPath);
|
|
14
|
+
}
|
|
15
|
+
(0, start_1.default)(configPath);
|
|
16
|
+
//# sourceMappingURL=start.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start.js","sourceRoot":"","sources":["../../src/scripts/start.ts"],"names":[],"mappings":";;;;;AAAA,2BAA8C;AAC9C,mEAA2C;AAC3C,2DAAmC;AACnC,4CAA0D;AAE1D,MAAM,EAAE,aAAa,EAAE,GAAG,IAAA,mBAAS,GAAE,CAAC;AAEtC,MAAM,UAAU,GAAG,CAAC,OAAO,aAAa,KAAK,QAAQ,IAAI,aAAa,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,sCAA0B,CAAC;AAE3I,IAAI,CAAC,IAAA,eAAU,EAAC,UAAU,CAAC,EAAE,CAAC;IAC5B,IAAA,iBAAY,EAAC,sCAA0B,EAAE,UAAU,CAAC,CAAC;AACvD,CAAC;AAED,IAAA,eAAK,EAAC,UAAU,CAAC,CAAC"}
|
package/dist/types.d.ts
ADDED
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -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"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const node_webserver_1 = __importDefault(require("@koeroesi86/node-webserver"));
|
|
7
|
+
const start = (configPath) => {
|
|
8
|
+
(async () => {
|
|
9
|
+
await new Promise((r) => setTimeout(r, 1));
|
|
10
|
+
const configuration = require(configPath);
|
|
11
|
+
await (0, node_webserver_1.default)(configuration);
|
|
12
|
+
})();
|
|
13
|
+
};
|
|
14
|
+
exports.default = start;
|
|
15
|
+
//# sourceMappingURL=start.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start.js","sourceRoot":"","sources":["../../src/utils/start.ts"],"names":[],"mappings":";;;;;AAAA,gFAAqD;AAErD,MAAM,KAAK,GAAG,CAAC,UAAkB,EAAQ,EAAE;IACzC,CAAC,KAAK,IAAI,EAAE;QACV,MAAM,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAC3C,MAAM,aAAa,GAAsC,OAAO,CAAC,UAAU,CAAC,CAAC;QAC7E,MAAM,IAAA,wBAAW,EAAC,aAAa,CAAC,CAAC;IACnC,CAAC,CAAC,EAAE,CAAC;AACP,CAAC,CAAC;AAEF,kBAAe,KAAK,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,29 +1,44 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@koeroesi86/node-webserver-service",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "26.10.37633705232-master",
|
|
4
4
|
"description": "OS service integration for @koeroesi86/node-webserver",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Krisztian Korosi",
|
|
8
8
|
"url": "https://github.com/Koeroesi86"
|
|
9
9
|
},
|
|
10
|
-
"repository":
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/Koeroesi86/node-webserver.git",
|
|
13
|
+
"directory": "packages/node-webserver-service"
|
|
14
|
+
},
|
|
11
15
|
"publishConfig": {
|
|
12
16
|
"access": "public"
|
|
13
17
|
},
|
|
14
18
|
"bin": {
|
|
15
|
-
"nws-service": "./scripts/manageService.js"
|
|
16
|
-
},
|
|
17
|
-
"scripts": {
|
|
18
|
-
"service": "node scripts/manageService.js",
|
|
19
|
-
"start": "nodemon scripts/start.js",
|
|
20
|
-
"generate-version": "node scripts/version.js"
|
|
19
|
+
"nws-service": "./dist/scripts/manageService.js"
|
|
21
20
|
},
|
|
22
21
|
"dependencies": {
|
|
23
|
-
"@koeroesi86/node-webserver": "
|
|
22
|
+
"@koeroesi86/node-webserver": "26.10.37633705232-master",
|
|
24
23
|
"os-service": "^2.2.0"
|
|
25
24
|
},
|
|
26
25
|
"devDependencies": {
|
|
27
|
-
"
|
|
26
|
+
"@types/node": "^24.0.0",
|
|
27
|
+
"@types/os-service": "^2.2.3",
|
|
28
|
+
"nodemon": "^2.0.15",
|
|
29
|
+
"rimraf": "^3.0.2",
|
|
30
|
+
"typescript": "^5.9.3"
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"dist",
|
|
34
|
+
"examples",
|
|
35
|
+
"configuration.example.js",
|
|
36
|
+
".logs/.gitkeep"
|
|
37
|
+
],
|
|
38
|
+
"gitHead": "df44146d25ab202ad04461024c6f67930c0e7026",
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "rimraf dist && tsc -p tsconfig.json",
|
|
41
|
+
"service": "node dist/scripts/manageService.js",
|
|
42
|
+
"start": "nodemon --watch src --ext ts --exec \"npm run build --silent && node dist/scripts/start.js\""
|
|
28
43
|
}
|
|
29
|
-
}
|
|
44
|
+
}
|
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/manageService.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const service = require('os-service');
|
|
4
|
-
const path = require('path');
|
|
5
|
-
const fs = require('fs');
|
|
6
|
-
const parseArgv = require('../utils/parseArgv');
|
|
7
|
-
|
|
8
|
-
const {add, remove, run, configuration} = parseArgv();
|
|
9
|
-
|
|
10
|
-
const configPath = configuration || process.env.NODE_WEBSERVER_CONFIG || path.resolve(__dirname, '../configuration.example.js');
|
|
11
|
-
|
|
12
|
-
if (!fs.existsSync(configPath)) {
|
|
13
|
-
throw new Error(`Configuration file does not exist: ${configPath}`);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const Configuration = require(configPath);
|
|
17
|
-
|
|
18
|
-
if (add) {
|
|
19
|
-
service.add(Configuration.serviceName, {
|
|
20
|
-
displayName: Configuration.serviceDisplayName || Configuration.serviceName,
|
|
21
|
-
programPath: __filename,
|
|
22
|
-
programArgs: [
|
|
23
|
-
'--run',
|
|
24
|
-
...process.argv.slice(3),
|
|
25
|
-
]
|
|
26
|
-
}, error => {
|
|
27
|
-
if (error) {
|
|
28
|
-
console.trace(error);
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
} else if (remove) {
|
|
32
|
-
service.remove(Configuration.serviceName, error => {
|
|
33
|
-
if (error) {
|
|
34
|
-
console.trace(error);
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
} else if (run) {
|
|
38
|
-
const start = require('../utils/start');
|
|
39
|
-
start(configPath);
|
|
40
|
-
service.run(() => {
|
|
41
|
-
service.stop(0);
|
|
42
|
-
});
|
|
43
|
-
} else {
|
|
44
|
-
console.info('\x1b[32m%s\x1b[0m', `
|
|
45
|
-
Usage:
|
|
46
|
-
|
|
47
|
-
yarn run service [argument]
|
|
48
|
-
|
|
49
|
-
arguments:
|
|
50
|
-
--add Installs the service
|
|
51
|
-
--remove Removes the service
|
|
52
|
-
--run Attempt to run the program as a service
|
|
53
|
-
`);
|
|
54
|
-
}
|
package/scripts/start.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
const path = require('path');
|
|
2
|
-
const fs = require('fs');
|
|
3
|
-
const parseArgv = require('../utils/parseArgv');
|
|
4
|
-
const start = require('../utils/start');
|
|
5
|
-
|
|
6
|
-
const { configuration } = parseArgv();
|
|
7
|
-
|
|
8
|
-
const configPath = configuration || process.env.NODE_WEBSERVER_CONFIG || path.resolve(__dirname, '../configuration.example.js');
|
|
9
|
-
|
|
10
|
-
if (!fs.existsSync(configPath)) {
|
|
11
|
-
fs.copyFileSync(path.resolve(__dirname, '../configuration.example.js'), configPath);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
start(configPath);
|
package/scripts/version.js
DELETED
|
@@ -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);
|
package/utils/parseArgv.js
DELETED
|
@@ -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;
|