Compare commits

...

10 Commits

Author SHA1 Message Date
3d263e2181 2.0.15 2019-01-18 00:45:29 +01:00
85639f29af fix(core): update 2019-01-18 00:45:29 +01:00
85448a21fc 2.0.14 2019-01-17 13:39:16 +01:00
3b85c4a37e fix(core): update 2019-01-17 13:39:15 +01:00
67dd650dce 2.0.13 2019-01-17 02:50:32 +01:00
92eaf5f19a fix(core): update 2019-01-17 02:50:32 +01:00
fcf9a61b1d 2.0.12 2019-01-09 14:13:32 +01:00
fbd258a876 fix(core): update 2019-01-09 14:13:32 +01:00
c65b8fc1af 2.0.11 2019-01-09 14:10:57 +01:00
b7b588d713 fix(core): update 2019-01-09 14:10:57 +01:00
6 changed files with 124 additions and 282 deletions

268
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartnginx",
"version": "2.0.10",
"version": "2.0.15",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -89,6 +89,16 @@
"symbol-tree": "^3.2.2"
}
},
"@pushrocks/qenv": {
"version": "4.0.0",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fqenv/-/qenv-4.0.0.tgz",
"integrity": "sha512-3/odPJaGp3ALtcSG/+N3dGtFX/CVBed9a5XKDa0bv7LoKCgYZeQwpF3jkCnNPjs7GKyzOzALHHID1L+zcb1RXw==",
"dev": true,
"requires": {
"@pushrocks/smartfile": "^6.0.6",
"@pushrocks/smartlog": "^2.0.9"
}
},
"@pushrocks/smartcli": {
"version": "3.0.7",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartcli/-/smartcli-3.0.7.tgz",
@ -152,11 +162,11 @@
}
},
"@pushrocks/smartlog": {
"version": "2.0.9",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartlog/-/smartlog-2.0.9.tgz",
"integrity": "sha512-F2u3O8OOQ7QXgg9o0lI7HnqEhSQZo2A8u0EuNbQH+Kj2oL62xDwjAg6KkINwH7ObSWpaldZ+I28prG0JxaRzvg==",
"version": "2.0.11",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartlog/-/smartlog-2.0.11.tgz",
"integrity": "sha512-V8SMzAAqDpl1+CJ9b3w5e/1ARjk4JOPZ35qZIllVBhHr8meCqnPE2immlfBYWmEp1xy3ntdAA+Lgewtu+iVk6A==",
"requires": {
"@pushrocks/smartlog-interfaces": "^2.0.2"
"@pushrocks/smartlog-interfaces": "^2.0.5"
}
},
"@pushrocks/smartlog-interfaces": {
@ -217,12 +227,12 @@
}
},
"@pushrocks/smartstring": {
"version": "3.0.5",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartstring/-/smartstring-3.0.5.tgz",
"integrity": "sha512-Bws2s6+Pc0HIXA35QH6cl6LJywhZ1U5icjyYMx+1kH8nURG+njzkacfarr9NWqyVYYOVu7SgXLzp9sR0eH7k9g==",
"version": "3.0.8",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartstring/-/smartstring-3.0.8.tgz",
"integrity": "sha512-twmCGF47+TJoiCpj6t5MxwcKDDJEATuKqJXxftcHOlXWW743LJ/1bCpMueDdtumo5EheUfSxb43aRse3DU3wig==",
"requires": {
"crypto-random-string": "^1.0.0",
"js-base64": "^2.4.9",
"js-base64": "^2.5.0",
"normalize-newline": "^3.0.0",
"randomatic": "^3.1.1",
"strip-indent": "^2.0.0"
@ -322,7 +332,7 @@
},
"@types/which": {
"version": "1.3.1",
"resolved": "https://verdaccio.lossless.one/@types%2fwhich/-/which-1.3.1.tgz",
"resolved": "https://registry.npmjs.org/@types/which/-/which-1.3.1.tgz",
"integrity": "sha512-ZrJDWpvg75LTGX4XwuneY9s6bF3OeZcGTpoGh3zDV9ytzcHMFsRrMIaLBRJZQMBoGyKs6unBQfVdrLZiYfb1zQ=="
},
"@types/yargs": {
@ -633,16 +643,6 @@
"type-detect": "^4.0.0"
}
},
"define-properties": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.2.tgz",
"integrity": "sha1-g6c/L+pWmJj7c3GTyPhzyvbUXJQ=",
"dev": true,
"requires": {
"foreach": "^2.0.5",
"object-keys": "^1.0.8"
}
},
"delayed-stream": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
@ -663,30 +663,6 @@
"once": "^1.4.0"
}
},
"es-abstract": {
"version": "1.12.0",
"resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.12.0.tgz",
"integrity": "sha512-C8Fx/0jFmV5IPoMOFPA9P9G5NtqW+4cOPit3MIuvR2t7Ag2K15EJTpxnHAYTzL+aYQJIESYeXZmDBfOBE1HcpA==",
"dev": true,
"requires": {
"es-to-primitive": "^1.1.1",
"function-bind": "^1.1.1",
"has": "^1.0.1",
"is-callable": "^1.1.3",
"is-regex": "^1.0.4"
}
},
"es-to-primitive": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.1.1.tgz",
"integrity": "sha1-RTVSSKiJeQNLZ5Lhm7gfK3l13Q0=",
"dev": true,
"requires": {
"is-callable": "^1.1.1",
"is-date-object": "^1.0.1",
"is-symbol": "^1.0.1"
}
},
"es6-error": {
"version": "4.1.1",
"resolved": "https://verdaccio.lossless.one/es6-error/-/es6-error-4.1.1.tgz",
@ -751,12 +727,6 @@
"readable-stream": "^2.0.2"
}
},
"foreach": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/foreach/-/foreach-2.0.5.tgz",
"integrity": "sha1-C+4AUBiusmDQo6865ljdATbsG5k=",
"dev": true
},
"form-data": {
"version": "2.3.3",
"resolved": "https://verdaccio.lossless.one/form-data/-/form-data-2.3.3.tgz",
@ -782,12 +752,6 @@
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8="
},
"function-bind": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
"integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==",
"dev": true
},
"get-caller-file": {
"version": "1.0.3",
"resolved": "https://verdaccio.lossless.one/get-caller-file/-/get-caller-file-1.0.3.tgz",
@ -810,9 +774,9 @@
}
},
"glob": {
"version": "7.1.2",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz",
"integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==",
"version": "7.1.3",
"resolved": "https://verdaccio.lossless.one/glob/-/glob-7.1.3.tgz",
"integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==",
"dev": true,
"requires": {
"fs.realpath": "^1.0.0",
@ -828,15 +792,6 @@
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz",
"integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg="
},
"has": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz",
"integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==",
"dev": true,
"requires": {
"function-bind": "^1.1.1"
}
},
"has-ansi": {
"version": "2.0.0",
"resolved": "https://verdaccio.lossless.one/has-ansi/-/has-ansi-2.0.0.tgz",
@ -860,15 +815,6 @@
"integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=",
"dev": true
},
"home": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/home/-/home-1.0.1.tgz",
"integrity": "sha1-lqQjzrSbmDeP9e886uBZpVf53TU=",
"dev": true,
"requires": {
"os-homedir": "^1.0.1"
}
},
"inflight": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
@ -889,18 +835,6 @@
"integrity": "sha512-wPVv/y/QQ/Uiirj/vh3oP+1Ww+AWehmi1g5fFWGPF6IpCBCDVrhgHRMvrLfdYcwDh3QJbGXDW4JAuzxElLSqKA==",
"dev": true
},
"is-callable": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.4.tgz",
"integrity": "sha512-r5p9sxJjYnArLjObpjA4xu5EKI3CuKHkJXMhT7kwbpUyIFD1n5PMAsoPvWnvtZiNz7LjkYDRZhd7FlI0eMijEA==",
"dev": true
},
"is-date-object": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.1.tgz",
"integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY=",
"dev": true
},
"is-fullwidth-code-point": {
"version": "2.0.0",
"resolved": "https://verdaccio.lossless.one/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz",
@ -918,27 +852,12 @@
"integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=",
"dev": true
},
"is-regex": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz",
"integrity": "sha1-VRdIm1RwkbCTDglWVM7SXul+lJE=",
"dev": true,
"requires": {
"has": "^1.0.1"
}
},
"is-stream": {
"version": "1.1.0",
"resolved": "https://verdaccio.lossless.one/is-stream/-/is-stream-1.1.0.tgz",
"integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=",
"dev": true
},
"is-symbol": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.1.tgz",
"integrity": "sha1-PMWfAAJRlLarLjjbrmaJJWtmBXI=",
"dev": true
},
"is-utf8": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz",
@ -1025,12 +944,6 @@
"path-exists": "^3.0.0"
}
},
"lodash": {
"version": "4.17.10",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz",
"integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==",
"dev": true
},
"luxon": {
"version": "1.9.0",
"resolved": "https://verdaccio.lossless.one/luxon/-/luxon-1.9.0.tgz",
@ -1052,9 +965,9 @@
}
},
"math-random": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/math-random/-/math-random-1.0.1.tgz",
"integrity": "sha1-izqsWIuKZuSXXjzepn97sylgH6w="
"version": "1.0.4",
"resolved": "https://verdaccio.lossless.one/math-random/-/math-random-1.0.4.tgz",
"integrity": "sha512-rUxjysqif/BZQH2yhd5Aaq7vXMSx9NdEsQcyA07uEzIvxgI7zIr33gGsh+RU0/XjmQpCW7RsVof1vlkvQVCK5A=="
},
"mem": {
"version": "4.0.0",
@ -1149,22 +1062,6 @@
"integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=",
"dev": true
},
"object-keys": {
"version": "1.0.12",
"resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.0.12.tgz",
"integrity": "sha512-FTMyFUm2wBcGHnH2eXmz7tC6IwlqQZ6mVZ+6dm6vZ4IQIHjs6FdNsQBuKGPuUUUY6NfJw2PshC08Tn6LzLDOag==",
"dev": true
},
"object.getownpropertydescriptors": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.0.3.tgz",
"integrity": "sha1-h1jIRvW0B62rDyNuCYbxSwUcqhY=",
"dev": true,
"requires": {
"define-properties": "^1.1.2",
"es-abstract": "^1.5.1"
}
},
"once": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
@ -1173,12 +1070,6 @@
"wrappy": "1"
}
},
"os-homedir": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz",
"integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=",
"dev": true
},
"os-locale": {
"version": "3.1.0",
"resolved": "https://verdaccio.lossless.one/os-locale/-/os-locale-3.1.0.tgz",
@ -1287,17 +1178,6 @@
"once": "^1.3.1"
}
},
"qenv": {
"version": "1.1.7",
"resolved": "https://registry.npmjs.org/qenv/-/qenv-1.1.7.tgz",
"integrity": "sha1-0D+L+P43SUzwjQkZ/nZdyoTZr64=",
"dev": true,
"requires": {
"lodash": "^4.17.4",
"smartfile": "^4.2.11",
"typings-global": "^1.0.16"
}
},
"randomatic": {
"version": "3.1.1",
"resolved": "https://verdaccio.lossless.one/randomatic/-/randomatic-3.1.1.tgz",
@ -1344,12 +1224,6 @@
"integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=",
"dev": true
},
"require-reload": {
"version": "0.2.2",
"resolved": "https://registry.npmjs.org/require-reload/-/require-reload-0.2.2.tgz",
"integrity": "sha1-KadZGEbK+RtuijzamRaD+V+NfUI=",
"dev": true
},
"resolve": {
"version": "1.9.0",
"resolved": "https://verdaccio.lossless.one/resolve/-/resolve-1.9.0.tgz",
@ -1419,74 +1293,6 @@
"chai-string": "^1.4.0"
}
},
"smartfile": {
"version": "4.2.28",
"resolved": "https://registry.npmjs.org/smartfile/-/smartfile-4.2.28.tgz",
"integrity": "sha512-zUeAOLYftz8xLfKTs9U1NOuNPTA9jlvTQNr7lDIv84kXnr1AEpDb2Xwy1MdK1w733sBil/RkxtezrkvgRVAnNg==",
"dev": true,
"requires": {
"@types/fs-extra": "5.0.0",
"@types/vinyl": "^2.0.2",
"fs-extra": "^5.0.0",
"glob": "^7.1.2",
"js-yaml": "^3.10.0",
"require-reload": "0.2.2",
"smartpath": "^3.2.8",
"smartq": "^1.1.6",
"smartrequest": "^1.0.8",
"vinyl-file": "^3.0.0"
},
"dependencies": {
"@types/fs-extra": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-5.0.0.tgz",
"integrity": "sha512-qtxDULQKUenuaDLW003CgC+0T0eiAfH3BrH+vSt87GLzbz5EZ6Ox6mv9rMttvhDOatbb9nYh0E1m7ydoYwUrAg==",
"dev": true,
"requires": {
"@types/node": "*"
}
},
"fs-extra": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-5.0.0.tgz",
"integrity": "sha512-66Pm4RYbjzdyeuqudYqhFiNBbCIuI9kgRqLPSHIlXHidW8NIQtVdkM1yeZ4lXwuhbTETv3EUGMNHAAw6hiundQ==",
"dev": true,
"requires": {
"graceful-fs": "^4.1.2",
"jsonfile": "^4.0.0",
"universalify": "^0.1.0"
}
}
}
},
"smartpath": {
"version": "3.2.8",
"resolved": "https://registry.npmjs.org/smartpath/-/smartpath-3.2.8.tgz",
"integrity": "sha1-SDS9OouuIpW6rK26I8h6UBlS+UA=",
"dev": true,
"requires": {
"home": "^1.0.1",
"typings-global": "^1.0.14"
}
},
"smartq": {
"version": "1.1.8",
"resolved": "https://registry.npmjs.org/smartq/-/smartq-1.1.8.tgz",
"integrity": "sha512-FURlYW/C3bLeZjJcBVyw7bxCyQoCXiXbLCZcDUKznhXHaLu35c8m33/a2H8CA0rtb82lvzN8dRLnBZAcNMzNHQ==",
"dev": true,
"requires": {
"util.promisify": "^1.0.0"
}
},
"smartrequest": {
"version": "1.0.13",
"resolved": "https://registry.npmjs.org/smartrequest/-/smartrequest-1.0.13.tgz",
"integrity": "sha512-OHrvzaxaA8Z8bJr33yxnyJF35nrWyaumsajqXm2Zkv0/2hfWO1NQAj02VVV51rLQfmtU0Hex7Nk19SoC8nOmYg==",
"dev": true,
"requires": {
"smartq": "^1.1.1"
}
},
"source-map": {
"version": "0.6.1",
"resolved": "https://verdaccio.lossless.one/source-map/-/source-map-0.6.1.tgz",
@ -1604,9 +1410,9 @@
"integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ=="
},
"tslint": {
"version": "5.12.0",
"resolved": "https://verdaccio.lossless.one/tslint/-/tslint-5.12.0.tgz",
"integrity": "sha512-CKEcH1MHUBhoV43SA/Jmy1l24HJJgI0eyLbBNSRyFlsQvb9v6Zdq+Nz2vEOH00nC5SUx4SneJ59PZUS/ARcokQ==",
"version": "5.12.1",
"resolved": "https://verdaccio.lossless.one/tslint/-/tslint-5.12.1.tgz",
"integrity": "sha512-sfodBHOucFg6egff8d1BvuofoOQ/nOeYNfbp7LDlKBcLNrL3lmS5zoiDGyOMdT7YsEXAwWpTdAHwOGOc8eRZAw==",
"dev": true,
"requires": {
"babel-code-frame": "^6.22.0",
@ -1650,12 +1456,6 @@
"integrity": "sha512-VCj5UiSyHBjwfYacmDuc/NOk4QQixbE+Wn7MFJuS0nRuPQbof132Pw4u53dm264O8LPc2MVsc7RJNml5szurkg==",
"dev": true
},
"typings-global": {
"version": "1.0.28",
"resolved": "https://registry.npmjs.org/typings-global/-/typings-global-1.0.28.tgz",
"integrity": "sha512-6VOwJWEY2971HOMHu/7sURzUXiD4/LiMJPsMAOqkHHAtS3MVpLFE5gzTiHilsH9KY5VE1mBQirWIgWFsDuo90A==",
"dev": true
},
"universalify": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz",
@ -1666,16 +1466,6 @@
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
},
"util.promisify": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/util.promisify/-/util.promisify-1.0.0.tgz",
"integrity": "sha512-i+6qA2MPhvoKLuxnJNpXAGhg7HphQOSUq2LKMZD0m15EiskXUkMvKdF4Uui0WYeCUGea+o2cw/ZuwehtfsrNkA==",
"dev": true,
"requires": {
"define-properties": "^1.1.2",
"object.getownpropertydescriptors": "^2.0.3"
}
},
"vinyl": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/vinyl/-/vinyl-2.2.0.tgz",

View File

@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartnginx",
"version": "2.0.10",
"version": "2.0.15",
"private": false,
"description": "control nginx from node, TypeScript ready",
"main": "dist/index.js",
@ -26,18 +26,18 @@
"dependencies": {
"@pushrocks/lik": "^3.0.4",
"@pushrocks/smartfile": "^6.0.11",
"@pushrocks/smartlog": "^2.0.9",
"@pushrocks/smartlog": "^2.0.11",
"@pushrocks/smartpromise": "^2.0.5",
"@pushrocks/smartshell": "^2.0.13",
"@pushrocks/smartstring": "^3.0.5"
"@pushrocks/smartstring": "^3.0.8"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.1.4",
"@gitzone/tsrun": "^1.1.17",
"@gitzone/tstest": "^1.0.18",
"@pushrocks/qenv": "^4.0.0",
"@pushrocks/tapbundle": "^3.0.7",
"qenv": "^1.1.7",
"tslint": "^5.12.0",
"tslint": "^5.12.1",
"tslint-config-prettier": "^1.17.0"
}
}

View File

@ -1,10 +1,10 @@
import { tap, expect } from '@pushrocks/tapbundle';
import path = require('path');
import { Qenv } from 'qenv';
let testQenv = new Qenv(process.cwd(), path.join(process.cwd(), '.nogit'));
import { Qenv } from '@pushrocks/qenv';
const testQenv = new Qenv('./', './.nogit/');
import * as smartnginx from '../ts';
import * as smartnginx from '../ts/index';
let testSmartNginx: smartnginx.SmartNginx;
let testNginxZone01: smartnginx.NginxHost;
@ -29,12 +29,11 @@ tap.test(`should produce an instance of NginxConfig`, async () => {
publicKey: 'some public'
});
expect(testNginxZone01).to.be.instanceof(smartnginx.NginxHost);
console.log(testNginxZone01.configString);
});
tap.test('.addZone() should add a zone to NginxConfig Object', async () => {
testSmartNginx.addHost(testNginxZone01);
testSmartNginx.addHost(testNginxZone02);
tap.test('.addHostCandidate() should add a zone to NginxConfig Object', async () => {
testSmartNginx.addHostCandidate(testNginxZone01);
testSmartNginx.addHostCandidate(testNginxZone02);
});
tap.test('.deploy() should deploy a config from an instance', async () => {

View File

@ -17,19 +17,21 @@ export class NginxHost implements IHostConfig {
/**
* smartnginxInstance this NginHost belongs to
*/
smartnginxInstance: SmartNginx;
public smartnginxInstance: SmartNginx;
hostName: string; // the host name e.g. domain name
destination: string;
configString: string; // the actual host config file as string
privateKey: string;
publicKey: string;
public hostName: string; // the host name e.g. domain name
public destination: string;
public configString: string; // the actual host config file as string
public privateKey: string;
public publicKey: string;
constructor(smartnginxInstanceArg: SmartNginx, optionsArg: IHostConfig) {
this.smartnginxInstance = smartnginxInstanceArg;
this.hostName = optionsArg.hostName;
this.destination = optionsArg.destination;
this.configString = snippets.getHostConfigString(optionsArg.hostName, optionsArg.destination);
this.privateKey = optionsArg.privateKey;
this.publicKey = optionsArg.publicKey;
}
/**
@ -37,8 +39,15 @@ export class NginxHost implements IHostConfig {
* @param certInstanceArg
*/
public async deploy() {
const filePath = plugins.path.join(paths.nginxHostDirPath, `${this.hostName}.conf`);
const filePathConfig = plugins.path.join(paths.nginxHostDirPath, `${this.hostName}.conf`);
const filePathPrivate = plugins.path.join(paths.nginxHostDirPath, `${this.hostName}.private.pem`);
const filePathPublic = plugins.path.join(paths.nginxHostDirPath, `${this.hostName}.public.pem`);
// writeConfig
plugins.smartfile.memory.toFsSync(this.configString, filePath);
plugins.smartfile.memory.toFsSync(this.configString, filePathConfig);
// write ssl
plugins.smartfile.memory.toFsSync(this.privateKey, filePathPrivate);
plugins.smartfile.memory.toFsSync(this.publicKey, filePathPublic);
}
}

View File

@ -10,7 +10,11 @@ import { IHostConfig } from './interfaces/hostconfig';
*/
export class SmartNginx {
public logger: plugins.smartlog.Smartlog;
private hosts = new plugins.lik.Objectmap<NginxHost>();
// the objectmaps
private deployedHosts = new plugins.lik.Objectmap<NginxHost>();
private hostCandidates = new plugins.lik.Objectmap<NginxHost>();
public nginxProcess: NginxProcess = new NginxProcess(this);
constructor(optionsArg: { logger?: plugins.smartlog.Smartlog }) {
optionsArg.logger
@ -26,9 +30,9 @@ export class SmartNginx {
* add a host
* @param nginxHostArg
*/
public addHost(optionsArg: IHostConfig): NginxHost {
public addHostCandidate(optionsArg: IHostConfig): NginxHost {
const nginxHost = new NginxHost(this, optionsArg);
this.hosts.add(nginxHost);
this.hostCandidates.add(nginxHost);
return nginxHost;
}
@ -36,47 +40,84 @@ export class SmartNginx {
* Gets a NginxHost by hostname
* @param hostNameArg
*/
public getNginxHostByHostName(hostNameArg: string): NginxHost {
return this.hosts.find(nginxHost => {
public getDeployedNginxHostByHostName(hostNameArg: string): NginxHost {
return this.deployedHosts.find(nginxHost => {
return nginxHost.hostName === hostNameArg;
});
}
/**
* listHosts
*/
public listHosts(): NginxHost[] {
return this.hosts.getArray();
public async listDeployedHosts(): Promise<NginxHost[]> {
return this.deployedHosts.getArray();
}
/**
* remove a Host
* @param nginxHostArg
*/
public removeHost(nginxHostArg: NginxHost) {
this.hosts.remove(nginxHostArg);
public async removeDeployedHost(nginxHostArg: NginxHost) {
if (this.hostCandidates.isEmpty()) {
this.deployedHosts.forEach(hostArg => {
this.hostCandidates.add(hostArg);
});
}
this.hostCandidates.remove(nginxHostArg);
this.deploy();
}
/**
* clean all hosts
* check wether there has been a diverging host configuration
* this function will only redeploy the nginx configuration in case there has been a change
*/
public wipeHosts() {
this.hosts.wipe();
private areHostsDiverged(): boolean {
let hostCounter = 0;
let unfoundHosts = 0;
this.hostCandidates.forEach(hostCandidateArg => {
let foundHost = false;
this.deployedHosts.forEach(deployedHostArg => {
if (
hostCandidateArg.hostName === deployedHostArg.hostName &&
hostCandidateArg.destination === deployedHostArg.destination
) {
hostCounter++;
foundHost = true;
}
});
if (!foundHost) {
unfoundHosts++;
}
});
return (
this.deployedHosts.getArray.length !== this.hostCandidates.getArray().length ||
hostCounter !== this.deployedHosts.getArray().length ||
unfoundHosts !== 0
);
}
/**
* deploy the current stack and restart nginx
*/
public async deploy() {
// write base config
plugins.smartfile.fs.ensureDirSync(paths.nginxConfigDirPath);
plugins.smartfile.memory.toFsSync(snippets.getBaseConfigString(), paths.nginxConfFile);
if (this.areHostsDiverged()) {
this.logger.log('ok', `hosts have diverged, trigger config deployment and nginx reload!`);
this.deployedHosts.wipe();
this.deployedHosts.addArray(this.hostCandidates.getArray());
this.hostCandidates.wipe();
// deploy hosts
plugins.smartfile.fs.ensureEmptyDirSync(paths.nginxHostDirPath);
for (const host of this.hosts.getArray()) {
await host.deploy();
this.logger.log('info', `Host ${host.hostName} deployed!`);
// write base config
plugins.smartfile.fs.ensureDirSync(paths.nginxConfigDirPath);
plugins.smartfile.memory.toFsSync(snippets.getBaseConfigString(), paths.nginxConfFile);
// deploy hosts
plugins.smartfile.fs.ensureEmptyDirSync(paths.nginxHostDirPath);
for (const host of this.deployedHosts.getArray()) {
await host.deploy();
this.logger.log('info', `Host ${host.hostName} deployed!`);
}
this.nginxProcess.reloadConfig();
} else {
this.logger.log('info', `hosts have not diverged, skipping nginx reload`);
}
this.nginxProcess.reloadConfig();
}
}

View File

@ -4,7 +4,7 @@ export let getBaseConfigString = () => {
let baseConfig = plugins.smartstring.indent.normalize(`
user www-data;
worker_processes auto;
pid /run/nginx.pid;
pid /run/nginx/nginx.pid;
events {
worker_connections 768;
@ -90,8 +90,11 @@ export let getHostConfigString = (hostNameArg: string, destinationIpArg: string)
ssl_certificate_key ${paths.nginxHostDirPath}/${hostNameArg}.private.pem;
location / {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://${hostNameArg};
include /etc/nginx/proxy_params;
}
location ~ /\.git {
deny all;