Compare commits
35 Commits
Author | SHA1 | Date | |
---|---|---|---|
b73807baf0 | |||
1e71fc24d5 | |||
e8071e76a1 | |||
b11d03dd41 | |||
72297d2f58 | |||
71b900ac47 | |||
f6d06edced | |||
3e98005843 | |||
7c4673a5b6 | |||
99ec82ab55 | |||
1f0c1964dd | |||
828229872d | |||
0ff482bd01 | |||
39c8da4f74 | |||
fcd2029744 | |||
d89e0a13d5 | |||
64c7815bca | |||
f3e69eb15e | |||
386e4c07c6 | |||
82557c96d6 | |||
c94d89fa8a | |||
639a5eebea | |||
fb88d3384e | |||
e38342604b | |||
390200ad2a | |||
1960b1d125 | |||
7ce6245286 | |||
3a8513d3a0 | |||
d425e290dd | |||
483aafd371 | |||
2a2a6fe461 | |||
843453f9d4 | |||
9b6e3e49f4 | |||
c24c272f6e | |||
4b8bb062c7 |
18
.gitignore
vendored
18
.gitignore
vendored
@@ -1,6 +1,22 @@
|
|||||||
.nogit/
|
.nogit/
|
||||||
node_modules/
|
|
||||||
|
# artifacts
|
||||||
coverage/
|
coverage/
|
||||||
public/
|
public/
|
||||||
pages/
|
pages/
|
||||||
|
|
||||||
|
# installs
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# caches
|
||||||
.yarn/
|
.yarn/
|
||||||
|
.cache/
|
||||||
|
.rpt2_cache
|
||||||
|
|
||||||
|
# builds
|
||||||
|
dist/
|
||||||
|
dist_web/
|
||||||
|
dist_serve/
|
||||||
|
dist_ts_web/
|
||||||
|
|
||||||
|
# custom
|
@@ -1,5 +1,5 @@
|
|||||||
# gitzone standard
|
# gitzone ci_default
|
||||||
image: hosttoday/ht-docker-node:npmci
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
paths:
|
paths:
|
||||||
@@ -37,32 +37,8 @@ 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:
|
testStable:
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci node install lts
|
|
||||||
- npmci npm install
|
|
||||||
- npmci npm test
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
testSTABLE:
|
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
@@ -72,6 +48,18 @@ testSTABLE:
|
|||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
- priv
|
||||||
|
|
||||||
|
testBuild:
|
||||||
|
stage: test
|
||||||
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci node install stable
|
||||||
|
- npmci npm install
|
||||||
|
- npmci command npm run build
|
||||||
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
|
|
||||||
release:
|
release:
|
||||||
@@ -90,19 +78,12 @@ release:
|
|||||||
# ====================
|
# ====================
|
||||||
codequality:
|
codequality:
|
||||||
stage: metadata
|
stage: metadata
|
||||||
image: docker:stable
|
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
services:
|
|
||||||
- docker:stable-dind
|
|
||||||
script:
|
script:
|
||||||
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
|
- npmci command npm install -g tslint typescript
|
||||||
- docker run
|
- npmci npm prepare
|
||||||
--env SOURCE_CODE="$PWD"
|
- npmci npm install
|
||||||
--volume "$PWD":/code
|
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
||||||
--volume /var/run/docker.sock:/var/run/docker.sock
|
|
||||||
"registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
|
|
||||||
artifacts:
|
|
||||||
paths: [codeclimate.json]
|
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
- priv
|
- priv
|
||||||
@@ -118,13 +99,15 @@ trigger:
|
|||||||
- notpriv
|
- notpriv
|
||||||
|
|
||||||
pages:
|
pages:
|
||||||
image: hosttoday/ht-docker-node:npmci
|
image: hosttoday/ht-docker-dbase:npmci
|
||||||
|
services:
|
||||||
|
- docker:stable-dind
|
||||||
stage: metadata
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
- npmci command npm install -g typedoc typescript
|
- npmci command npm install -g @gitzone/tsdoc
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
|
- npmci command tsdoc
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
@@ -135,13 +118,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"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
3955
package-lock.json
generated
3955
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
51
package.json
51
package.json
@@ -1,30 +1,49 @@
|
|||||||
{
|
{
|
||||||
"name": "@gitzone/tswatch",
|
"name": "@gitzone/tswatch",
|
||||||
"version": "1.0.2",
|
"version": "1.0.20",
|
||||||
"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",
|
"test": "(tstest test/)",
|
||||||
"test2": "(tstest test/)",
|
"build": "(tsbuild)"
|
||||||
"build": "(tsbuild)",
|
|
||||||
"format": "(gitzone format)"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.0.22",
|
"@gitzone/tsbuild": "^2.1.17",
|
||||||
"@gitzone/tstest": "^1.0.15",
|
"@gitzone/tstest": "^1.0.28",
|
||||||
"@pushrocks/tapbundle": "^3.0.7",
|
"@pushrocks/tapbundle": "^3.0.13",
|
||||||
"@types/node": "^10.11.7",
|
"@types/node": "^12.7.12",
|
||||||
"tslint": "^5.11.0",
|
"tslint": "^5.20.0",
|
||||||
"tslint-config-prettier": "^1.15.0"
|
"tslint-config-prettier": "^1.18.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@gitzone/tsrun": "^1.1.13",
|
"@gitzone/tsbundle": "^1.0.45",
|
||||||
"@pushrocks/smartcli": "^3.0.6",
|
"@gitzone/tsrun": "^1.2.8",
|
||||||
"@pushrocks/smartshell": "^2.0.6",
|
"@pushrocks/early": "^3.0.3",
|
||||||
"filewatcher": "^3.0.1"
|
"@pushrocks/lik": "^3.0.11",
|
||||||
}
|
"@pushrocks/smartchok": "^1.0.23",
|
||||||
|
"@pushrocks/smartcli": "^3.0.7",
|
||||||
|
"@pushrocks/smartdelay": "^2.0.3",
|
||||||
|
"@pushrocks/smartlog": "^2.0.19",
|
||||||
|
"@pushrocks/smartlog-destination-local": "^8.0.2",
|
||||||
|
"@pushrocks/smartserve": "^1.1.37",
|
||||||
|
"@pushrocks/smartshell": "^2.0.25"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"ts/**/*",
|
||||||
|
"ts_web/**/*",
|
||||||
|
"dist/**/*",
|
||||||
|
"dist_web/**/*",
|
||||||
|
"dist_ts_web/**/*",
|
||||||
|
"assets/**/*",
|
||||||
|
"cli.js",
|
||||||
|
"npmextra.json",
|
||||||
|
"readme.md"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
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)
|
||||||
|
|
||||||
|
[](https://maintainedby.lossless.com)
|
13
test/test.ts
13
test/test.ts
@@ -1,21 +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'
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should start the tswatch instance', async () => {
|
tap.test('should start the tswatch instance', async () => {
|
||||||
console.log('test executed');
|
await testTsWatchInstance.start();
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should run abitrary commands', async () => {
|
tap.test('should stop the instance', async tools => {
|
||||||
|
tools.delayFor(2000);
|
||||||
|
testTsWatchInstance.stop();
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.start();
|
tap.start();
|
||||||
|
@@ -1,3 +1,5 @@
|
|||||||
|
import * as early from '@pushrocks/early';
|
||||||
|
early.start('tswatch');
|
||||||
export * from './tswatch.classes.tswatch';
|
export * from './tswatch.classes.tswatch';
|
||||||
|
|
||||||
import './tswatch.cli';
|
import './tswatch.cli';
|
||||||
|
early.stop();
|
||||||
|
1
ts/interfaces/index.ts
Normal file
1
ts/interfaces/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export * from './interfaces.watchmodes';
|
7
ts/interfaces/interfaces.watchmodes.ts
Normal file
7
ts/interfaces/interfaces.watchmodes.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
export type TWatchModes =
|
||||||
|
| 'test'
|
||||||
|
| 'gitzone_npm'
|
||||||
|
| 'gitzone_service'
|
||||||
|
| 'gitzone_element'
|
||||||
|
| 'gitzone_website'
|
||||||
|
| 'echoSomething';
|
12
ts/tswatch.classes.elementserver.ts
Normal file
12
ts/tswatch.classes.elementserver.ts
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import * as plugins from './tswatch.plugins';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* an element server for developing lit elements compliant to gitzone standard
|
||||||
|
*/
|
||||||
|
export class ElementServer {
|
||||||
|
constructor() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@@ -1,70 +1,89 @@
|
|||||||
import * as plugins from './tswatch.plugins';
|
import * as plugins from './tswatch.plugins';
|
||||||
|
import * as paths from './tswatch.paths';
|
||||||
|
import * as interfaces from './interfaces';
|
||||||
|
|
||||||
|
import { Watcher } from './tswatch.classes.watcher';
|
||||||
|
|
||||||
/**
|
|
||||||
* 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 = plugins.fileWatcher();
|
|
||||||
private filePathToWatch: string;
|
|
||||||
private commandToExecute: string;
|
|
||||||
|
|
||||||
constructor(optionsArg: {
|
constructor(watchmodeArg: interfaces.TWatchModes) {
|
||||||
filePathToWatch: string,
|
this.watchmode = watchmodeArg;
|
||||||
commandToExecute: string
|
|
||||||
}) {
|
|
||||||
this.filePathToWatch = optionsArg.filePathToWatch;
|
|
||||||
this.commandToExecute = optionsArg.commandToExecute;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* start the file
|
* starts the TsWatch instance
|
||||||
*/
|
*/
|
||||||
public async start() {
|
public async start() {
|
||||||
this.setupCleanup();
|
switch (this.watchmode) {
|
||||||
console.log(`Looking at ${this.filePathToWatch} for changes`);
|
case 'test':
|
||||||
this.watcher.add(this.filePathToWatch); // __dirname refers to the directory of this very file
|
this.watcherMap.add(
|
||||||
this.watcher.on('change', async (file, stat) => {
|
new Watcher({
|
||||||
console.log('Noticed change!');
|
filePathToWatch: paths.cwd,
|
||||||
if (!stat) {
|
commandToExecute: 'npm run test2',
|
||||||
console.log('deleted');
|
timeout: null
|
||||||
}
|
})
|
||||||
this.updateCurrentExecution();
|
);
|
||||||
});
|
break;
|
||||||
this.updateCurrentExecution();
|
case 'gitzone_npm':
|
||||||
}
|
this.watcherMap.add(
|
||||||
|
new Watcher({
|
||||||
|
filePathToWatch: paths.cwd,
|
||||||
|
commandToExecute: 'npm run test',
|
||||||
|
timeout: null
|
||||||
|
})
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case 'gitzone_element':
|
||||||
|
this.watcherMap.add(
|
||||||
|
new Watcher({
|
||||||
|
filePathToWatch: plugins.path.join(paths.cwd, 'ts_web'),
|
||||||
|
commandToExecute: 'npm run build',
|
||||||
|
timeout: null
|
||||||
|
})
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case 'gitzone_website':
|
||||||
|
this.watcherMap.add(
|
||||||
|
new Watcher({
|
||||||
|
filePathToWatch: plugins.path.join(paths.cwd, './ts/'),
|
||||||
|
commandToExecute: 'npm run startTs',
|
||||||
|
timeout: null
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
private async updateCurrentExecution() {
|
// client directory
|
||||||
if (this.currentExecution) {
|
this.watcherMap.add(
|
||||||
process.kill(-this.currentExecution.childProcess.pid);
|
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.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 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);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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() {
|
||||||
|
await 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -1,16 +1,29 @@
|
|||||||
import * as plugins from './tswatch.plugins';
|
import * as plugins from './tswatch.plugins';
|
||||||
import * as paths from './tswatch.paths';
|
import * as paths from './tswatch.paths';
|
||||||
|
import { logger } from './tswatch.logging';
|
||||||
|
|
||||||
import { TsWatch } from './tswatch.classes.tswatch';
|
import { TsWatch } from './tswatch.classes.tswatch';
|
||||||
|
|
||||||
const tswatchCli = new plugins.smartcli.Smartcli();
|
const tswatchCli = new plugins.smartcli.Smartcli();
|
||||||
|
|
||||||
tswatchCli.addCommand('test').subscribe(argvArg => {
|
// standard behaviour will assume gitzone setup
|
||||||
const tsWatch = new TsWatch({
|
|
||||||
filePathToWatch: paths.cwd,
|
tswatchCli.addCommand('test').subscribe(async argvArg => {
|
||||||
commandToExecute: 'npm run test2'
|
logger.log('info', `running test task`);
|
||||||
});
|
const tsWatch = new TsWatch('test');
|
||||||
tsWatch.start();
|
await tsWatch.start();
|
||||||
|
});
|
||||||
|
|
||||||
|
tswatchCli.addCommand('website').subscribe(async argvArg => {
|
||||||
|
logger.log('info', `running watch task for a gitzone website project`);
|
||||||
|
const tsWatch = new TsWatch('gitzone_website');
|
||||||
|
await tsWatch.start();
|
||||||
|
});
|
||||||
|
|
||||||
|
tswatchCli.addCommand('element').subscribe(async argvArg => {
|
||||||
|
logger.log('info', `running watch task for a gitzone element project`);
|
||||||
|
const tsWatch = new TsWatch('gitzone_element');
|
||||||
|
await tsWatch.start();
|
||||||
});
|
});
|
||||||
|
|
||||||
tswatchCli.startParse();
|
tswatchCli.startParse();
|
||||||
|
15
ts/tswatch.logging.ts
Normal file
15
ts/tswatch.logging.ts
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import * as plugins from './tswatch.plugins';
|
||||||
|
|
||||||
|
export const logger = new plugins.smartlog.Smartlog({
|
||||||
|
logContext: {
|
||||||
|
company: 'Some Company',
|
||||||
|
companyunit: 'Some CompanyUnit',
|
||||||
|
containerName: 'Some Containername',
|
||||||
|
environment: 'local',
|
||||||
|
runtime: 'node',
|
||||||
|
zone: 'gitzone'
|
||||||
|
},
|
||||||
|
minimumLogLevel: 'silly'
|
||||||
|
});
|
||||||
|
|
||||||
|
logger.addLogDestination(new plugins.smartlogDestinationLocal.DestinationLocal());
|
@@ -2,12 +2,12 @@ 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 smartcli from '@pushrocks/smartcli';
|
import * as smartcli from '@pushrocks/smartcli';
|
||||||
|
import * as smartdelay from '@pushrocks/smartdelay';
|
||||||
|
import * as smartlog from '@pushrocks/smartlog';
|
||||||
|
import * as smartlogDestinationLocal from '@pushrocks/smartlog-destination-local';
|
||||||
import * as smartshell from '@pushrocks/smartshell';
|
import * as smartshell from '@pushrocks/smartshell';
|
||||||
|
|
||||||
export { smartshell, smartcli };
|
export { lik, smartchok, smartcli, smartdelay, smartlog, smartlogDestinationLocal, smartshell };
|
||||||
|
|
||||||
// Third Pary
|
|
||||||
import * as fileWatcher from 'filewatcher';
|
|
||||||
|
|
||||||
export { fileWatcher };
|
|
||||||
|
@@ -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