Compare commits
21 Commits
Author | SHA1 | Date | |
---|---|---|---|
f6d06edced | |||
3e98005843 | |||
7c4673a5b6 | |||
99ec82ab55 | |||
1f0c1964dd | |||
828229872d | |||
0ff482bd01 | |||
39c8da4f74 | |||
fcd2029744 | |||
d89e0a13d5 | |||
64c7815bca | |||
f3e69eb15e | |||
386e4c07c6 | |||
82557c96d6 | |||
c94d89fa8a | |||
639a5eebea | |||
fb88d3384e | |||
e38342604b | |||
390200ad2a | |||
1960b1d125 | |||
7ce6245286 |
15
.gitignore
vendored
15
.gitignore
vendored
@@ -1,6 +1,19 @@
|
|||||||
.nogit/
|
.nogit/
|
||||||
node_modules/
|
|
||||||
|
# artifacts
|
||||||
coverage/
|
coverage/
|
||||||
public/
|
public/
|
||||||
pages/
|
pages/
|
||||||
|
|
||||||
|
# installs
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# caches and builds
|
||||||
.yarn/
|
.yarn/
|
||||||
|
.cache/
|
||||||
|
dist/
|
||||||
|
dist_web/
|
||||||
|
dist_serve/
|
||||||
|
dist_ts_web/
|
||||||
|
|
||||||
|
# custom
|
@@ -37,18 +37,6 @@ snyk:
|
|||||||
# ====================
|
# ====================
|
||||||
# test stage
|
# test stage
|
||||||
# ====================
|
# ====================
|
||||||
testLEGACY:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci node install legacy
|
|
||||||
- npmci npm install
|
|
||||||
- npmci npm test
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
allow_failure: true
|
|
||||||
|
|
||||||
testLTS:
|
testLTS:
|
||||||
stage: test
|
stage: test
|
||||||
@@ -135,13 +123,3 @@ pages:
|
|||||||
paths:
|
paths:
|
||||||
- public
|
- public
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
|
|
||||||
windowsCompatibility:
|
|
||||||
image: stefanscherer/node-windows:10-build-tools
|
|
||||||
stage: metadata
|
|
||||||
script:
|
|
||||||
- npm install & npm test
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- windows
|
|
||||||
allow_failure: true
|
|
||||||
|
@@ -2,5 +2,15 @@
|
|||||||
"npmci": {
|
"npmci": {
|
||||||
"npmGlobalTools": [],
|
"npmGlobalTools": [],
|
||||||
"npmAccessLevel": "public"
|
"npmAccessLevel": "public"
|
||||||
|
},
|
||||||
|
"gitzone": {
|
||||||
|
"module": {
|
||||||
|
"githost": "gitlab.com",
|
||||||
|
"gitscope": "gitzone",
|
||||||
|
"gitrepo": "tswatch",
|
||||||
|
"shortDescription": "watch typescript projects during development",
|
||||||
|
"npmPackagename": "@gitzone/tswatch",
|
||||||
|
"license": "MIT"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
85
package-lock.json
generated
85
package-lock.json
generated
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@gitzone/tswatch",
|
"name": "@gitzone/tswatch",
|
||||||
"version": "1.0.6",
|
"version": "1.0.17",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -149,19 +149,19 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@gitzone/tstest": {
|
"@gitzone/tstest": {
|
||||||
"version": "1.0.20",
|
"version": "1.0.23",
|
||||||
"resolved": "https://verdaccio.lossless.one/@gitzone%2ftstest/-/tstest-1.0.20.tgz",
|
"resolved": "https://verdaccio.lossless.one/@gitzone%2ftstest/-/tstest-1.0.23.tgz",
|
||||||
"integrity": "sha512-nEHRDpmPOns47/LIJQ+y+CJDzjiS17UKJpl7PYok4EgNJJGqJUN5ilz2KVLPDcRd/7JiB7JYKujlf2UgFKadgQ==",
|
"integrity": "sha512-iP+bCTVV+67MvWwM1l4AfQ0NuLP0xgsf2OTeUICq6I1zHm2bbGr7UuNZ2veBkx3fFb4A2Acs49bs5EkukYMi4Q==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@gitzone/tsrun": "^1.2.5",
|
"@gitzone/tsrun": "^1.2.6",
|
||||||
"@pushrocks/consolecolor": "^2.0.1",
|
"@pushrocks/consolecolor": "^2.0.1",
|
||||||
"@pushrocks/smartfile": "^7.0.2",
|
"@pushrocks/smartfile": "^7.0.2",
|
||||||
"@pushrocks/smartlog": "^2.0.19",
|
"@pushrocks/smartlog": "^2.0.19",
|
||||||
"@pushrocks/smartpromise": "^3.0.2",
|
"@pushrocks/smartpromise": "^3.0.2",
|
||||||
"@pushrocks/smartshell": "^2.0.13",
|
"@pushrocks/smartshell": "^2.0.20",
|
||||||
"@types/figures": "^2.0.0",
|
"@types/figures": "^3.0.1",
|
||||||
"figures": "^2.0.0"
|
"figures": "^3.0.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/smartpromise": {
|
"@pushrocks/smartpromise": {
|
||||||
@@ -275,6 +275,16 @@
|
|||||||
"@pushrocks/smartpromise": "^2.0.5"
|
"@pushrocks/smartpromise": "^2.0.5"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"@pushrocks/smartexit": {
|
||||||
|
"version": "1.0.15",
|
||||||
|
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartexit/-/smartexit-1.0.15.tgz",
|
||||||
|
"integrity": "sha512-pvJBmF13spcDN+O8rSpYlKBOObyfW+omZKQr3hhSMT1VHMEYV8e/njsA19Cg4C2DfLPv+cRFFgPn27zJpleRsQ==",
|
||||||
|
"requires": {
|
||||||
|
"@pushrocks/lik": "^3.0.5",
|
||||||
|
"@pushrocks/smartdelay": "^2.0.3",
|
||||||
|
"@pushrocks/smartlog-source-ora": "^1.0.7"
|
||||||
|
}
|
||||||
|
},
|
||||||
"@pushrocks/smartfile": {
|
"@pushrocks/smartfile": {
|
||||||
"version": "7.0.2",
|
"version": "7.0.2",
|
||||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartfile/-/smartfile-7.0.2.tgz",
|
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartfile/-/smartfile-7.0.2.tgz",
|
||||||
@@ -324,6 +334,15 @@
|
|||||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartlog-interfaces/-/smartlog-interfaces-2.0.5.tgz",
|
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartlog-interfaces/-/smartlog-interfaces-2.0.5.tgz",
|
||||||
"integrity": "sha512-eLNlRpDwy3E+6v/B6fo/NiAo+UxBO3SxKgIIsgUGbWfVpsyUi0PG2xfVCdhJlhL1AsRRvKglfHSOB8qKE+XCLw=="
|
"integrity": "sha512-eLNlRpDwy3E+6v/B6fo/NiAo+UxBO3SxKgIIsgUGbWfVpsyUi0PG2xfVCdhJlhL1AsRRvKglfHSOB8qKE+XCLw=="
|
||||||
},
|
},
|
||||||
|
"@pushrocks/smartlog-source-ora": {
|
||||||
|
"version": "1.0.7",
|
||||||
|
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartlog-source-ora/-/smartlog-source-ora-1.0.7.tgz",
|
||||||
|
"integrity": "sha512-lgpZ2rBLt9UGIdMb43cB9rxwtbu4RaNmdQnAYfNGxizGPuNtXw3WAzdHyS5tEJFZAbvMOiwNguQ6Bk1i2gaedw==",
|
||||||
|
"requires": {
|
||||||
|
"@pushrocks/smartlog-interfaces": "^2.0.5",
|
||||||
|
"ora": "^3.4.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"@pushrocks/smartparam": {
|
"@pushrocks/smartparam": {
|
||||||
"version": "1.0.4",
|
"version": "1.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/@pushrocks/smartparam/-/smartparam-1.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/@pushrocks/smartparam/-/smartparam-1.0.4.tgz",
|
||||||
@@ -366,13 +385,22 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@pushrocks/smartshell": {
|
"@pushrocks/smartshell": {
|
||||||
"version": "2.0.13",
|
"version": "2.0.22",
|
||||||
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartshell/-/smartshell-2.0.13.tgz",
|
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartshell/-/smartshell-2.0.22.tgz",
|
||||||
"integrity": "sha512-jLfAhLxMVKAScKdln1QrQqBI7A7INhMNHIq28fJEBi0BNDUS0eerw4yMAnR4CRmcrh4xFp1z+ju1kaPO3I/4MA==",
|
"integrity": "sha512-ChlRBOAhvSmxA6xfNoc1BHISV78IjvKwBP3w70r80rpQ09Bw/9ajlmGLmCDqe9aDqlaHe9HNTEPp68gNg69NBA==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@pushrocks/smartpromise": "^2.0.5",
|
"@pushrocks/smartdelay": "^2.0.3",
|
||||||
|
"@pushrocks/smartexit": "^1.0.15",
|
||||||
|
"@pushrocks/smartpromise": "^3.0.2",
|
||||||
"@types/which": "^1.3.1",
|
"@types/which": "^1.3.1",
|
||||||
"which": "^1.3.1"
|
"which": "^1.3.1"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@pushrocks/smartpromise": {
|
||||||
|
"version": "3.0.2",
|
||||||
|
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartpromise/-/smartpromise-3.0.2.tgz",
|
||||||
|
"integrity": "sha512-jmrJMUEmBCWChWK8CIcx4Vw3wv/8OgVNmkaxJrbs+WMaoRUfJtpWWJfrAwwHWt9ZXJbarJ+CwfwfYiiZXymndQ=="
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@pushrocks/smartspawn": {
|
"@pushrocks/smartspawn": {
|
||||||
@@ -474,10 +502,13 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@types/figures": {
|
"@types/figures": {
|
||||||
"version": "2.0.0",
|
"version": "3.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/@types/figures/-/figures-2.0.0.tgz",
|
"resolved": "https://verdaccio.lossless.one/@types%2ffigures/-/figures-3.0.1.tgz",
|
||||||
"integrity": "sha512-mcRgJ+ncKuNI+Dwac7omO18B8C8u+YBS+AU/oyLhEyjAnT3cUUThhHgZpbiIvu5ZqSvdD30BXtrqg9nxc3OKMg==",
|
"integrity": "sha512-2OXodKWdNhYl+S+wCvlafqJbfMIVDfQZYX2wRyUOcRiEQpeJ9zU6cT7d+RbMpjS+/vmQ2cAUUL8gyGy1YxtLPw==",
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"figures": "*"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"@types/form-data": {
|
"@types/form-data": {
|
||||||
"version": "2.2.1",
|
"version": "2.2.1",
|
||||||
@@ -503,13 +534,13 @@
|
|||||||
},
|
},
|
||||||
"@types/minimatch": {
|
"@types/minimatch": {
|
||||||
"version": "3.0.3",
|
"version": "3.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.3.tgz",
|
"resolved": "https://verdaccio.lossless.one/@types%2fminimatch/-/minimatch-3.0.3.tgz",
|
||||||
"integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA=="
|
"integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA=="
|
||||||
},
|
},
|
||||||
"@types/node": {
|
"@types/node": {
|
||||||
"version": "12.0.0",
|
"version": "12.0.2",
|
||||||
"resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-12.0.0.tgz",
|
"resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-12.0.2.tgz",
|
||||||
"integrity": "sha512-Jrb/x3HT4PTJp6a4avhmJCDEVrPdqLfl3e8GGMbpkGGdwAV5UGlIs4vVEfsHHfylZVOKZWpOqmqFH8CbfOZ6kg=="
|
"integrity": "sha512-5tabW/i+9mhrfEOUcLDu2xBPsHJ+X5Orqy9FKpale3SjDA17j5AEpYq5vfy3oAeAHGcvANRCO3NV3d2D6q3NiA=="
|
||||||
},
|
},
|
||||||
"@types/vinyl": {
|
"@types/vinyl": {
|
||||||
"version": "2.0.2",
|
"version": "2.0.2",
|
||||||
@@ -912,9 +943,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"figures": {
|
"figures": {
|
||||||
"version": "2.0.0",
|
"version": "3.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz",
|
"resolved": "https://verdaccio.lossless.one/figures/-/figures-3.0.0.tgz",
|
||||||
"integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=",
|
"integrity": "sha512-HKri+WoWoUgr83pehn/SIgLOMZ9nAWC6dcGj26RY2R4F50u4+RTUz0RCrUlOV3nKRAICW1UGzyb+kcX2qK1S/g==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"escape-string-regexp": "^1.0.5"
|
"escape-string-regexp": "^1.0.5"
|
||||||
@@ -1205,9 +1236,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"luxon": {
|
"luxon": {
|
||||||
"version": "1.13.0",
|
"version": "1.13.1",
|
||||||
"resolved": "https://verdaccio.lossless.one/luxon/-/luxon-1.13.0.tgz",
|
"resolved": "https://verdaccio.lossless.one/luxon/-/luxon-1.13.1.tgz",
|
||||||
"integrity": "sha512-j/t5wLTDCUbJgJ6MDp1VFNmeE/j7jmOhk3yKnZ972laS1ofpXVbOOVr9+7abyclAcG8FrPv8T2mg4A39V26vEQ=="
|
"integrity": "sha512-IQKRIiz9ldUrgcozN13SAeNZVYfD3bEI9X6TcrGu+dkgE4GR/Iik03ozbTM5cTr0lz8ucYPL2jtYT7Va2Flbsg=="
|
||||||
},
|
},
|
||||||
"make-error": {
|
"make-error": {
|
||||||
"version": "1.3.5",
|
"version": "1.3.5",
|
||||||
@@ -1725,7 +1756,7 @@
|
|||||||
},
|
},
|
||||||
"symbol-tree": {
|
"symbol-tree": {
|
||||||
"version": "3.2.2",
|
"version": "3.2.2",
|
||||||
"resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.2.tgz",
|
"resolved": "https://verdaccio.lossless.one/symbol-tree/-/symbol-tree-3.2.2.tgz",
|
||||||
"integrity": "sha1-rifbOPZgp64uHDt9G8KQgZuFGeY="
|
"integrity": "sha1-rifbOPZgp64uHDt9G8KQgZuFGeY="
|
||||||
},
|
},
|
||||||
"threads": {
|
"threads": {
|
||||||
|
15
package.json
15
package.json
@@ -1,34 +1,37 @@
|
|||||||
{
|
{
|
||||||
"name": "@gitzone/tswatch",
|
"name": "@gitzone/tswatch",
|
||||||
"version": "1.0.6",
|
"version": "1.0.17",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "watch typescript projects during development",
|
"description": "watch typescript projects during development",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"typings": "dist/index.d.ts",
|
"typings": "dist/index.d.ts",
|
||||||
"author": "Lossless GmbH",
|
"author": "Lossless GmbH",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"bin": {
|
||||||
|
"tswatch": "cli.js"
|
||||||
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "node ./cli.ts.js test --timeout 10000",
|
"test": "(tstest test/)",
|
||||||
"test2": "(tstest test/)",
|
|
||||||
"build": "(tsbuild)",
|
"build": "(tsbuild)",
|
||||||
"format": "(gitzone format)"
|
"format": "(gitzone format)"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.11",
|
"@gitzone/tsbuild": "^2.1.11",
|
||||||
"@gitzone/tstest": "^1.0.20",
|
"@gitzone/tstest": "^1.0.23",
|
||||||
"@pushrocks/tapbundle": "^3.0.9",
|
"@pushrocks/tapbundle": "^3.0.9",
|
||||||
"@types/node": "^12.0.0",
|
"@types/node": "^12.0.2",
|
||||||
"tslint": "^5.16.0",
|
"tslint": "^5.16.0",
|
||||||
"tslint-config-prettier": "^1.18.0"
|
"tslint-config-prettier": "^1.18.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@gitzone/tsrun": "^1.2.6",
|
"@gitzone/tsrun": "^1.2.6",
|
||||||
"@pushrocks/early": "^3.0.3",
|
"@pushrocks/early": "^3.0.3",
|
||||||
|
"@pushrocks/lik": "^3.0.5",
|
||||||
"@pushrocks/smartchok": "^1.0.18",
|
"@pushrocks/smartchok": "^1.0.18",
|
||||||
"@pushrocks/smartcli": "^3.0.7",
|
"@pushrocks/smartcli": "^3.0.7",
|
||||||
"@pushrocks/smartdelay": "^2.0.3",
|
"@pushrocks/smartdelay": "^2.0.3",
|
||||||
"@pushrocks/smartlog": "^2.0.19",
|
"@pushrocks/smartlog": "^2.0.19",
|
||||||
"@pushrocks/smartlog-destination-local": "^7.0.5",
|
"@pushrocks/smartlog-destination-local": "^7.0.5",
|
||||||
"@pushrocks/smartshell": "^2.0.13"
|
"@pushrocks/smartshell": "^2.0.22"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
26
readme.md
Normal file
26
readme.md
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
# @gitzone/tswatch
|
||||||
|
watch typescript projects during development
|
||||||
|
|
||||||
|
## Availabililty and Links
|
||||||
|
* [npmjs.org (npm package)](https://www.npmjs.com/package/@gitzone/tswatch)
|
||||||
|
* [gitlab.com (source)](https://gitlab.com/gitzone/tswatch)
|
||||||
|
* [github.com (source mirror)](https://github.com/gitzone/tswatch)
|
||||||
|
* [docs (typedoc)](https://gitzone.gitlab.io/tswatch/)
|
||||||
|
|
||||||
|
## Status for master
|
||||||
|
[](https://gitlab.com/gitzone/tswatch/commits/master)
|
||||||
|
[](https://gitlab.com/gitzone/tswatch/commits/master)
|
||||||
|
[](https://www.npmjs.com/package/@gitzone/tswatch)
|
||||||
|
[](https://snyk.io/test/npm/@gitzone/tswatch)
|
||||||
|
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
|
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
|
[](https://prettier.io/)
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
For further information read the linked docs at the top of this readme.
|
||||||
|
|
||||||
|
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||||
|
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
||||||
|
|
||||||
|
[](https://maintainedby.lossless.com)
|
15
test/test.ts
15
test/test.ts
@@ -1,23 +1,20 @@
|
|||||||
|
// tslint:disable-next-line: no-implicit-dependencies
|
||||||
import { expect, tap } from '@pushrocks/tapbundle';
|
import { expect, tap } from '@pushrocks/tapbundle';
|
||||||
import * as tswatch from '../ts/index';
|
import * as tswatch from '../ts/index';
|
||||||
|
|
||||||
let testTsWatchInstance: tswatch.TsWatch;
|
let testTsWatchInstance: tswatch.TsWatch;
|
||||||
|
|
||||||
tap.test('should create a valid TsWatch instance', async () => {
|
tap.test('should create a valid TsWatch instance', async () => {
|
||||||
testTsWatchInstance = new tswatch.TsWatch({
|
testTsWatchInstance = new tswatch.TsWatch('echoSomething');
|
||||||
filePathToWatch: process.cwd(),
|
|
||||||
commandToExecute: 'npm -v',
|
|
||||||
timeout: 1000
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should start the tswatch instance', async () => {
|
tap.test('should start the tswatch instance', async () => {
|
||||||
testTsWatchInstance.start();
|
await testTsWatchInstance.start();
|
||||||
console.log('test executed');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should run abitrary commands', async () => {
|
tap.test('should stop the instance', async (tools) => {
|
||||||
|
tools.delayFor(2000);
|
||||||
|
testTsWatchInstance.stop();
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.start();
|
tap.start();
|
||||||
|
@@ -2,4 +2,4 @@ import * as early from '@pushrocks/early';
|
|||||||
early.start('tswatch');
|
early.start('tswatch');
|
||||||
export * from './tswatch.classes.tswatch';
|
export * from './tswatch.classes.tswatch';
|
||||||
import './tswatch.cli';
|
import './tswatch.cli';
|
||||||
early.stop();
|
early.stop();
|
||||||
|
1
ts/interfaces/index.ts
Normal file
1
ts/interfaces/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export * from './interfaces.watchmodes';
|
1
ts/interfaces/interfaces.watchmodes.ts
Normal file
1
ts/interfaces/interfaces.watchmodes.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export type TWatchModes = 'test' | 'gitzone_npm' | 'gitzone_service' | 'gitzone_website' | 'echoSomething';
|
@@ -1,77 +1,75 @@
|
|||||||
import * as plugins from './tswatch.plugins';
|
import * as plugins from './tswatch.plugins';
|
||||||
|
import * as paths from './tswatch.paths';
|
||||||
|
import * as interfaces from './interfaces';
|
||||||
|
|
||||||
export interface ITsWatchConstructorOptions {
|
import { Watcher } from './tswatch.classes.watcher';
|
||||||
filePathToWatch: string;
|
|
||||||
commandToExecute: string;
|
|
||||||
timeout?: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* handles the management of watching for foes
|
|
||||||
*/
|
|
||||||
export class TsWatch {
|
export class TsWatch {
|
||||||
private smartshellInstance = new plugins.smartshell.Smartshell({
|
public watchmode: interfaces.TWatchModes;
|
||||||
executor: 'bash'
|
public watcherMap = new plugins.lik.Objectmap<Watcher>();
|
||||||
});
|
|
||||||
private currentExecution: plugins.smartshell.IExecResultStreaming;
|
|
||||||
private watcher = new plugins.smartchok.Smartchok([], {});
|
|
||||||
private options: ITsWatchConstructorOptions;
|
|
||||||
|
|
||||||
constructor(optionsArg: ITsWatchConstructorOptions) {
|
constructor(watchmodeArg: interfaces.TWatchModes) {
|
||||||
this.options = optionsArg;
|
this.watchmode = watchmodeArg;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* start the file
|
* starts the TsWatch instance
|
||||||
*/
|
*/
|
||||||
public async start() {
|
public async start() {
|
||||||
this.setupCleanup();
|
switch (this.watchmode) {
|
||||||
console.log(`Looking at ${this.options.filePathToWatch} for changes`);
|
case 'test':
|
||||||
this.watcher.add([this.options.filePathToWatch]); // __dirname refers to the directory of this very file
|
this.watcherMap.add(new Watcher({
|
||||||
const changeObservable = await this.watcher.getObservableFor('change');
|
filePathToWatch: paths.cwd,
|
||||||
changeObservable.subscribe(() => {
|
commandToExecute: 'npm run test2',
|
||||||
this.updateCurrentExecution();
|
timeout: null
|
||||||
})
|
}));
|
||||||
this.updateCurrentExecution();
|
break;
|
||||||
}
|
case 'gitzone_npm':
|
||||||
|
this.watcherMap.add(new Watcher({
|
||||||
private async updateCurrentExecution() {
|
filePathToWatch: paths.cwd,
|
||||||
if (this.currentExecution) {
|
commandToExecute: 'npm run test',
|
||||||
process.kill(-this.currentExecution.childProcess.pid);
|
timeout: null
|
||||||
|
}));
|
||||||
|
break;
|
||||||
|
case 'gitzone_website':
|
||||||
|
// server directory
|
||||||
|
this.watcherMap.add(
|
||||||
|
new Watcher({
|
||||||
|
filePathToWatch: plugins.path.join(paths.cwd, './ts/'),
|
||||||
|
commandToExecute: 'npm run start',
|
||||||
|
timeout: null
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
// client directory
|
||||||
|
this.watcherMap.add(new Watcher({
|
||||||
|
filePathToWatch: plugins.path.join(paths.cwd, './ts_web/'),
|
||||||
|
commandToExecute: 'npm run build',
|
||||||
|
timeout: null
|
||||||
|
}));
|
||||||
|
break;
|
||||||
|
case 'echoSomething':
|
||||||
|
const tsWatchInstanceEchoSomething = new Watcher({
|
||||||
|
filePathToWatch: paths.cwd,
|
||||||
|
commandToExecute: 'npm -v',
|
||||||
|
timeout: null
|
||||||
|
});
|
||||||
|
this.watcherMap.add(tsWatchInstanceEchoSomething);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
this.currentExecution = await this.smartshellInstance.execStreaming(this.options.commandToExecute);
|
this.watcherMap.forEach(async watcher => {
|
||||||
this.currentExecution = null;
|
await watcher.start();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* this method sets up a clean exit strategy
|
* stops the execution of any active Watchers
|
||||||
*/
|
*/
|
||||||
private async setupCleanup() {
|
public async stop() {
|
||||||
const cleanup = () => {
|
this.watcherMap.forEach(async watcher => {
|
||||||
if (this.currentExecution) {
|
await watcher.stop();
|
||||||
process.kill(-this.currentExecution.childProcess.pid);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
process.on('exit', () => {
|
|
||||||
console.log('');
|
|
||||||
console.log('now exiting!');
|
|
||||||
cleanup();
|
|
||||||
process.exit(0);
|
|
||||||
});
|
});
|
||||||
process.on('SIGINT', () => {
|
|
||||||
console.log('');
|
|
||||||
console.log('ok! got SIGINT We are exiting! Just cleaning up to exit neatly :)');
|
|
||||||
cleanup();
|
|
||||||
process.exit(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
// handle timeout
|
|
||||||
if (this.options.timeout) {
|
|
||||||
plugins.smartdelay.delayFor(this.options.timeout).then(() => {
|
|
||||||
console.log(`timed out afer ${this.options.timeout} milliseconds! exiting!`);
|
|
||||||
cleanup();
|
|
||||||
process.exit(0);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
97
ts/tswatch.classes.watcher.ts
Normal file
97
ts/tswatch.classes.watcher.ts
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
import * as plugins from './tswatch.plugins';
|
||||||
|
import { logger } from './tswatch.logging';
|
||||||
|
|
||||||
|
export interface IWatcherConstructorOptions {
|
||||||
|
filePathToWatch: string;
|
||||||
|
commandToExecute: string;
|
||||||
|
timeout?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A watcher keeps track of one child execution
|
||||||
|
*/
|
||||||
|
export class Watcher {
|
||||||
|
private smartshellInstance = new plugins.smartshell.Smartshell({
|
||||||
|
executor: 'bash'
|
||||||
|
});
|
||||||
|
private currentExecution: plugins.smartshell.IExecResultStreaming;
|
||||||
|
private smartchokWatcher = new plugins.smartchok.Smartchok([], {});
|
||||||
|
private options: IWatcherConstructorOptions;
|
||||||
|
|
||||||
|
constructor(optionsArg: IWatcherConstructorOptions) {
|
||||||
|
this.options = optionsArg;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* start the file
|
||||||
|
*/
|
||||||
|
public async start() {
|
||||||
|
this.setupCleanup();
|
||||||
|
console.log(`Looking at ${this.options.filePathToWatch} for changes`);
|
||||||
|
this.smartchokWatcher.add([this.options.filePathToWatch]); // __dirname refers to the directory of this very file
|
||||||
|
await this.smartchokWatcher.start();
|
||||||
|
const changeObservable = await this.smartchokWatcher.getObservableFor('change');
|
||||||
|
changeObservable.subscribe(() => {
|
||||||
|
this.updateCurrentExecution();
|
||||||
|
});
|
||||||
|
this.updateCurrentExecution();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* updates the current execution
|
||||||
|
*/
|
||||||
|
private async updateCurrentExecution() {
|
||||||
|
if (this.currentExecution) {
|
||||||
|
logger.log('ok', `reexecuting ${this.options.commandToExecute}`);
|
||||||
|
process.kill(-this.currentExecution.childProcess.pid);
|
||||||
|
} else {
|
||||||
|
logger.log('ok', `executing ${this.options.commandToExecute} for the first time`);
|
||||||
|
}
|
||||||
|
this.currentExecution = await this.smartshellInstance.execStreaming(
|
||||||
|
this.options.commandToExecute
|
||||||
|
);
|
||||||
|
this.currentExecution = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* this method sets up a clean exit strategy
|
||||||
|
*/
|
||||||
|
private async setupCleanup() {
|
||||||
|
const cleanup = () => {
|
||||||
|
if (this.currentExecution) {
|
||||||
|
process.kill(-this.currentExecution.childProcess.pid);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
process.on('exit', () => {
|
||||||
|
console.log('');
|
||||||
|
console.log('now exiting!');
|
||||||
|
cleanup();
|
||||||
|
process.exit(0);
|
||||||
|
});
|
||||||
|
process.on('SIGINT', () => {
|
||||||
|
console.log('');
|
||||||
|
console.log('ok! got SIGINT We are exiting! Just cleaning up to exit neatly :)');
|
||||||
|
cleanup();
|
||||||
|
process.exit(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
// handle timeout
|
||||||
|
if (this.options.timeout) {
|
||||||
|
plugins.smartdelay.delayFor(this.options.timeout).then(() => {
|
||||||
|
console.log(`timed out afer ${this.options.timeout} milliseconds! exiting!`);
|
||||||
|
cleanup();
|
||||||
|
process.exit(0);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* stops the watcher
|
||||||
|
*/
|
||||||
|
public async stop() {
|
||||||
|
await this.smartchokWatcher.stop();
|
||||||
|
if (this.currentExecution && !this.currentExecution.childProcess.killed) {
|
||||||
|
process.kill(-this.currentExecution.childProcess.pid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -8,21 +8,16 @@ const tswatchCli = new plugins.smartcli.Smartcli();
|
|||||||
|
|
||||||
// standard behaviour will assume gitzone setup
|
// standard behaviour will assume gitzone setup
|
||||||
|
|
||||||
tswatchCli.addCommand('test').subscribe(argvArg => {
|
tswatchCli.addCommand('test').subscribe(async argvArg => {
|
||||||
logger.log('info', `running test task`);
|
logger.log('info', `running test task`);
|
||||||
const tsWatch = new TsWatch({
|
const tsWatch = new TsWatch('test');
|
||||||
filePathToWatch: paths.cwd,
|
await tsWatch.start();
|
||||||
commandToExecute: 'npm run test2',
|
});
|
||||||
timeout: (() => {
|
|
||||||
if (argvArg.timeout) {
|
tswatchCli.addCommand('website').subscribe(async argvArg => {
|
||||||
console.log(`timeing out after ${argvArg.timeout}`);
|
logger.log('info', `running watch task for a gitzone website project`);
|
||||||
return argvArg.timeout;
|
const tsWatch = new TsWatch('gitzone_website');
|
||||||
} else {
|
await tsWatch.start();
|
||||||
return null;
|
|
||||||
}
|
|
||||||
})()
|
|
||||||
});
|
|
||||||
tsWatch.start();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
tswatchCli.startParse();
|
tswatchCli.startParse();
|
||||||
|
@@ -5,7 +5,7 @@ export const logger = new plugins.smartlog.Smartlog({
|
|||||||
company: 'Some Company',
|
company: 'Some Company',
|
||||||
companyunit: 'Some CompanyUnit',
|
companyunit: 'Some CompanyUnit',
|
||||||
containerName: 'Some Containername',
|
containerName: 'Some Containername',
|
||||||
environment: "local",
|
environment: 'local',
|
||||||
runtime: 'node',
|
runtime: 'node',
|
||||||
zone: 'gitzone'
|
zone: 'gitzone'
|
||||||
},
|
},
|
||||||
|
@@ -2,6 +2,7 @@ import * as path from 'path';
|
|||||||
export { path };
|
export { path };
|
||||||
|
|
||||||
// @pushrocks scope
|
// @pushrocks scope
|
||||||
|
import * as lik from '@pushrocks/lik';
|
||||||
import * as smartchok from '@pushrocks/smartchok';
|
import * as smartchok from '@pushrocks/smartchok';
|
||||||
import * as smartcli from '@pushrocks/smartcli';
|
import * as smartcli from '@pushrocks/smartcli';
|
||||||
import * as smartdelay from '@pushrocks/smartdelay';
|
import * as smartdelay from '@pushrocks/smartdelay';
|
||||||
@@ -9,4 +10,4 @@ import * as smartlog from '@pushrocks/smartlog';
|
|||||||
import * as smartlogDestinationLocal from '@pushrocks/smartlog-destination-local';
|
import * as smartlogDestinationLocal from '@pushrocks/smartlog-destination-local';
|
||||||
import * as smartshell from '@pushrocks/smartshell';
|
import * as smartshell from '@pushrocks/smartshell';
|
||||||
|
|
||||||
export { smartchok, smartcli, smartdelay, smartlog, smartlogDestinationLocal, smartshell, };
|
export { lik, smartchok, smartcli, smartdelay, smartlog, smartlogDestinationLocal, smartshell };
|
||||||
|
@@ -4,7 +4,14 @@
|
|||||||
"semicolon": [true, "always"],
|
"semicolon": [true, "always"],
|
||||||
"no-console": false,
|
"no-console": false,
|
||||||
"ordered-imports": false,
|
"ordered-imports": false,
|
||||||
"object-literal-sort-keys": false
|
"object-literal-sort-keys": false,
|
||||||
|
"member-ordering": {
|
||||||
|
"options":{
|
||||||
|
"order": [
|
||||||
|
"static-method"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"defaultSeverity": "warning"
|
"defaultSeverity": "warning"
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user