fix(core): update
This commit is contained in:
parent
82f3b4bd7d
commit
e5b75014af
54
package-lock.json
generated
54
package-lock.json
generated
@ -619,9 +619,9 @@
|
||||
}
|
||||
},
|
||||
"commander": {
|
||||
"version": "2.19.0",
|
||||
"resolved": "https://verdaccio.lossless.one/commander/-/commander-2.19.0.tgz",
|
||||
"integrity": "sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg==",
|
||||
"version": "2.20.0",
|
||||
"resolved": "https://verdaccio.lossless.one/commander/-/commander-2.20.0.tgz",
|
||||
"integrity": "sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==",
|
||||
"dev": true
|
||||
},
|
||||
"concat-map": {
|
||||
@ -1071,6 +1071,11 @@
|
||||
"integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==",
|
||||
"dev": true
|
||||
},
|
||||
"node-forge": {
|
||||
"version": "0.7.5",
|
||||
"resolved": "https://verdaccio.lossless.one/node-forge/-/node-forge-0.7.5.tgz",
|
||||
"integrity": "sha512-MmbQJ2MTESTjt3Gi/3yG1wGpIMhUfcIypUCGtTizFR9IiccFwxSpfp0vtIZlkFclEqERemxfnSdZEMR9VqqEFQ=="
|
||||
},
|
||||
"normalize-newline": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/normalize-newline/-/normalize-newline-3.0.0.tgz",
|
||||
@ -1254,9 +1259,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"resolve": {
|
||||
"version": "1.9.0",
|
||||
"resolved": "https://verdaccio.lossless.one/resolve/-/resolve-1.9.0.tgz",
|
||||
"integrity": "sha512-TZNye00tI67lwYvzxCxHGjwTNlUV70io54/Ed4j6PscB8xVfuBJpRenI/o6dVk0cY0PYTY27AgCoGGxRnYuItQ==",
|
||||
"version": "1.10.0",
|
||||
"resolved": "https://verdaccio.lossless.one/resolve/-/resolve-1.10.0.tgz",
|
||||
"integrity": "sha512-3sUr9aq5OfSg2S9pNtPA9hL1FVEAjvfOC4leW0SNf/mpnaakz2a9femSd6LqAww2RaFctwyf1lCqnTHuF1rxDg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"path-parse": "^1.0.6"
|
||||
@ -1275,6 +1280,14 @@
|
||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
|
||||
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
|
||||
},
|
||||
"selfsigned": {
|
||||
"version": "1.10.4",
|
||||
"resolved": "https://verdaccio.lossless.one/selfsigned/-/selfsigned-1.10.4.tgz",
|
||||
"integrity": "sha512-9AukTiDmHXGXWtWjembZ5NDmVvP2695EtpgbCsxCa68w3c88B+alqbmZ4O3hZ4VWGXeGWzEVdvqgAJD8DQPCDw==",
|
||||
"requires": {
|
||||
"node-forge": "0.7.5"
|
||||
}
|
||||
},
|
||||
"semver": {
|
||||
"version": "5.6.0",
|
||||
"resolved": "https://verdaccio.lossless.one/semver/-/semver-5.6.0.tgz",
|
||||
@ -1447,9 +1460,9 @@
|
||||
"integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ=="
|
||||
},
|
||||
"tslint": {
|
||||
"version": "5.12.1",
|
||||
"resolved": "https://verdaccio.lossless.one/tslint/-/tslint-5.12.1.tgz",
|
||||
"integrity": "sha512-sfodBHOucFg6egff8d1BvuofoOQ/nOeYNfbp7LDlKBcLNrL3lmS5zoiDGyOMdT7YsEXAwWpTdAHwOGOc8eRZAw==",
|
||||
"version": "5.15.0",
|
||||
"resolved": "https://verdaccio.lossless.one/tslint/-/tslint-5.15.0.tgz",
|
||||
"integrity": "sha512-6bIEujKR21/3nyeoX2uBnE8s+tMXCQXhqMmaIPJpHmXJoBJPTLcI7/VHRtUwMhnLVdwLqqY3zmd8Dxqa5CVdJA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"babel-code-frame": "^6.22.0",
|
||||
@ -1458,18 +1471,31 @@
|
||||
"commander": "^2.12.1",
|
||||
"diff": "^3.2.0",
|
||||
"glob": "^7.1.1",
|
||||
"js-yaml": "^3.7.0",
|
||||
"js-yaml": "^3.13.0",
|
||||
"minimatch": "^3.0.4",
|
||||
"mkdirp": "^0.5.1",
|
||||
"resolve": "^1.3.2",
|
||||
"semver": "^5.3.0",
|
||||
"tslib": "^1.8.0",
|
||||
"tsutils": "^2.27.2"
|
||||
"tsutils": "^2.29.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"js-yaml": {
|
||||
"version": "3.13.1",
|
||||
"resolved": "https://verdaccio.lossless.one/js-yaml/-/js-yaml-3.13.1.tgz",
|
||||
"integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"argparse": "^1.0.7",
|
||||
"esprima": "^4.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"tslint-config-prettier": {
|
||||
"version": "1.17.0",
|
||||
"resolved": "https://verdaccio.lossless.one/tslint-config-prettier/-/tslint-config-prettier-1.17.0.tgz",
|
||||
"integrity": "sha512-NKWNkThwqE4Snn4Cm6SZB7lV5RMDDFsBwz6fWUkTxOKGjMx8ycOHnjIbhn7dZd5XmssW3CwqUjlANR6EhP9YQw==",
|
||||
"version": "1.18.0",
|
||||
"resolved": "https://verdaccio.lossless.one/tslint-config-prettier/-/tslint-config-prettier-1.18.0.tgz",
|
||||
"integrity": "sha512-xPw9PgNPLG3iKRxmK7DWr+Ea/SzrvfHtjFt5LBl61gk2UBG/DB9kCXRjv+xyIU1rUtnayLeMUVJBcMX8Z17nDg==",
|
||||
"dev": true
|
||||
},
|
||||
"tsutils": {
|
||||
|
@ -30,7 +30,8 @@
|
||||
"@pushrocks/smartpromise": "^2.0.5",
|
||||
"@pushrocks/smartshell": "^2.0.13",
|
||||
"@pushrocks/smartstring": "^3.0.8",
|
||||
"@pushrocks/smartunique": "^3.0.1"
|
||||
"@pushrocks/smartunique": "^3.0.1",
|
||||
"selfsigned": "^1.10.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.4",
|
||||
@ -38,7 +39,7 @@
|
||||
"@gitzone/tstest": "^1.0.18",
|
||||
"@pushrocks/qenv": "^4.0.0",
|
||||
"@pushrocks/tapbundle": "^3.0.7",
|
||||
"tslint": "^5.12.1",
|
||||
"tslint-config-prettier": "^1.17.0"
|
||||
"tslint": "^5.15.0",
|
||||
"tslint-config-prettier": "^1.18.0"
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ let testNginxZone01: smartnginx.NginxHost;
|
||||
let testNginxZone02: smartnginx.NginxHost;
|
||||
|
||||
tap.test('should create a valid instance of SmartNginx', async () => {
|
||||
testSmartNginx = new smartnginx.SmartNginx({});
|
||||
testSmartNginx = new smartnginx.SmartNginx({defaultProxyUrl: 'https://git.zone'});
|
||||
expect(testSmartNginx).to.be.instanceof(smartnginx.SmartNginx);
|
||||
});
|
||||
|
||||
|
@ -5,10 +5,16 @@ import { NginxHost } from './smartnginx.classes.nginxhost';
|
||||
import { NginxProcess } from './smartnginx.classes.nginxprocess';
|
||||
import { IHostConfig } from './interfaces/hostconfig';
|
||||
|
||||
export interface ISmartNginxContructorOptions {
|
||||
logger?: plugins.smartlog.Smartlog;
|
||||
defaultProxyUrl: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* main class that manages a NginxInstance
|
||||
*/
|
||||
export class SmartNginx {
|
||||
public options: ISmartNginxContructorOptions;
|
||||
public logger: plugins.smartlog.Smartlog;
|
||||
|
||||
// the objectmaps
|
||||
@ -16,9 +22,10 @@ export class SmartNginx {
|
||||
private hostCandidates = new plugins.lik.Objectmap<NginxHost>();
|
||||
|
||||
public nginxProcess: NginxProcess = new NginxProcess(this);
|
||||
constructor(optionsArg: { logger?: plugins.smartlog.Smartlog }) {
|
||||
optionsArg.logger
|
||||
? (this.logger = optionsArg.logger)
|
||||
constructor(optionsArg: ISmartNginxContructorOptions) {
|
||||
this.options = optionsArg;
|
||||
this.options.logger
|
||||
? (this.logger = this.options.logger)
|
||||
: (this.logger = plugins.smartlog.defaultLogger);
|
||||
}
|
||||
|
||||
@ -108,7 +115,12 @@ export class SmartNginx {
|
||||
|
||||
// write base config
|
||||
plugins.smartfile.fs.ensureDirSync(paths.nginxConfigDirPath);
|
||||
plugins.smartfile.memory.toFsSync(snippets.getBaseConfigString(), paths.nginxConfFile);
|
||||
plugins.smartfile.memory.toFsSync(snippets.getBaseConfigString(this.options.defaultProxyUrl), paths.nginxConfFile);
|
||||
|
||||
// write standard self signed certificate
|
||||
const selfsignedCert = plugins.selfsigned.generate([{ name: 'commonName', value: 'selfsigned.git.zone' }], { days: 365});
|
||||
plugins.smartfile.memory.toFsSync(selfsignedCert.private, plugins.path.join(paths.nginxConfigDirPath, './default.private.pem'));
|
||||
plugins.smartfile.memory.toFsSync(selfsignedCert.public, plugins.path.join(paths.nginxConfigDirPath, './default.public.pem'));
|
||||
|
||||
// deploy hosts
|
||||
plugins.smartfile.fs.ensureEmptyDirSync(paths.nginxHostDirPath);
|
||||
|
@ -13,3 +13,10 @@ import * as smartstring from '@pushrocks/smartstring';
|
||||
import * as smartunique from '@pushrocks/smartunique';
|
||||
|
||||
export { lik, smartlog, smartpromise, smartshell, smartfile, smartstring, smartunique };
|
||||
|
||||
// thirdparty scope
|
||||
import * as selfsigned from 'selfsigned';
|
||||
|
||||
export {
|
||||
selfsigned
|
||||
};
|
||||
|
@ -1,6 +1,6 @@
|
||||
import * as plugins from './smartnginx.plugins';
|
||||
import * as paths from './smartnginx.paths';
|
||||
export let getBaseConfigString = () => {
|
||||
export let getBaseConfigString = (defaultProxy: string) => {
|
||||
const baseConfig = plugins.smartstring.indent.normalize(`
|
||||
user www-data;
|
||||
worker_processes auto;
|
||||
@ -63,6 +63,31 @@ export let getBaseConfigString = () => {
|
||||
# Virtual Host Configs
|
||||
##
|
||||
|
||||
server {
|
||||
# The keepalive parameter sets the maximum number of idle keepalive connections
|
||||
# to upstream servers that are preserved in the cache of each worker process. When
|
||||
# this number is exceeded, the least recently used connections are closed.
|
||||
listen *:80 default_server;
|
||||
rewrite ^ ${defaultProxy} permanent;
|
||||
}
|
||||
|
||||
server {
|
||||
listen *:443 ssl default_server;
|
||||
ssl_certificate ${paths.nginxHostDirPath}/default.public.pem;
|
||||
ssl_certificate_key ${paths.nginxHostDirPath}/default.private.pem;
|
||||
location / {
|
||||
proxy_http_version 1.1;
|
||||
proxy_buffering off;
|
||||
proxy_redirect off;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $remote_addr;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_next_upstream error timeout http_404 http_429 http_500 http_502;
|
||||
proxy_next_upstream_tries 5;
|
||||
proxy_pass ${defaultProxy};
|
||||
}
|
||||
}
|
||||
|
||||
include ${paths.nginxHostDirPath}/*.conf;
|
||||
include /etc/nginx/sites-enabled/*;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user