Compare commits
30 Commits
Author | SHA1 | Date | |
---|---|---|---|
e4ef6bad8f | |||
2873314742 | |||
e26fa92744 | |||
995f296319 | |||
e7866dadb7 | |||
9302e78f86 | |||
0a302bee95 | |||
deb5e1daf9 | |||
5fe27ee706 | |||
b73807baf0 | |||
1e71fc24d5 | |||
e8071e76a1 | |||
b11d03dd41 | |||
72297d2f58 | |||
71b900ac47 | |||
f6d06edced | |||
3e98005843 | |||
7c4673a5b6 | |||
99ec82ab55 | |||
1f0c1964dd | |||
828229872d | |||
0ff482bd01 | |||
39c8da4f74 | |||
fcd2029744 | |||
d89e0a13d5 | |||
64c7815bca | |||
f3e69eb15e | |||
386e4c07c6 | |||
82557c96d6 | |||
c94d89fa8a |
5
.gitignore
vendored
5
.gitignore
vendored
@@ -8,9 +8,12 @@ pages/
|
||||
# installs
|
||||
node_modules/
|
||||
|
||||
# caches and builds
|
||||
# caches
|
||||
.yarn/
|
||||
.cache/
|
||||
.rpt2_cache
|
||||
|
||||
# builds
|
||||
dist/
|
||||
dist_web/
|
||||
dist_serve/
|
||||
|
@@ -1,5 +1,5 @@
|
||||
# gitzone standard
|
||||
image: hosttoday/ht-docker-node:npmci
|
||||
# gitzone ci_default
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
|
||||
cache:
|
||||
paths:
|
||||
@@ -38,19 +38,7 @@ snyk:
|
||||
# test stage
|
||||
# ====================
|
||||
|
||||
testLTS:
|
||||
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:
|
||||
testStable:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
@@ -60,6 +48,18 @@ testSTABLE:
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- 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
|
||||
|
||||
release:
|
||||
@@ -78,19 +78,12 @@ release:
|
||||
# ====================
|
||||
codequality:
|
||||
stage: metadata
|
||||
image: docker:stable
|
||||
allow_failure: true
|
||||
services:
|
||||
- docker:stable-dind
|
||||
script:
|
||||
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
|
||||
- docker run
|
||||
--env SOURCE_CODE="$PWD"
|
||||
--volume "$PWD":/code
|
||||
--volume /var/run/docker.sock:/var/run/docker.sock
|
||||
"registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
|
||||
artifacts:
|
||||
paths: [codeclimate.json]
|
||||
- npmci command npm install -g tslint typescript
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
||||
tags:
|
||||
- docker
|
||||
- priv
|
||||
@@ -106,13 +99,15 @@ trigger:
|
||||
- notpriv
|
||||
|
||||
pages:
|
||||
image: hosttoday/ht-docker-node:npmci
|
||||
image: hosttoday/ht-docker-dbase:npmci
|
||||
services:
|
||||
- docker:stable-dind
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci command npm install -g typedoc typescript
|
||||
- npmci command npm install -g @gitzone/tsdoc
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
|
||||
- npmci command tsdoc
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
|
3626
package-lock.json
generated
3626
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
44
package.json
44
package.json
@@ -1,34 +1,50 @@
|
||||
{
|
||||
"name": "@gitzone/tswatch",
|
||||
"version": "1.0.9",
|
||||
"version": "1.0.25",
|
||||
"private": false,
|
||||
"description": "watch typescript projects during development",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"author": "Lossless GmbH",
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"tswatch": "cli.js"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "(tstest test/)",
|
||||
"build": "(tsbuild)",
|
||||
"format": "(gitzone format)"
|
||||
"build": "(tsbuild)"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.11",
|
||||
"@gitzone/tstest": "^1.0.20",
|
||||
"@pushrocks/tapbundle": "^3.0.9",
|
||||
"@types/node": "^12.0.0",
|
||||
"tslint": "^5.16.0",
|
||||
"@gitzone/tsbuild": "^2.1.17",
|
||||
"@gitzone/tstest": "^1.0.28",
|
||||
"@pushrocks/tapbundle": "^3.0.13",
|
||||
"@types/node": "^12.7.12",
|
||||
"tslint": "^5.20.0",
|
||||
"tslint-config-prettier": "^1.18.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@gitzone/tsrun": "^1.2.6",
|
||||
"@gitzone/tsbundle": "^1.0.47",
|
||||
"@gitzone/tsrun": "^1.2.8",
|
||||
"@pushrocks/early": "^3.0.3",
|
||||
"@pushrocks/lik": "^3.0.5",
|
||||
"@pushrocks/smartchok": "^1.0.18",
|
||||
"@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": "^7.0.5",
|
||||
"@pushrocks/smartshell": "^2.0.13"
|
||||
}
|
||||
"@pushrocks/smartlog-destination-local": "^8.0.2",
|
||||
"@pushrocks/smartserve": "^1.1.37",
|
||||
"@pushrocks/smartshell": "^2.0.25",
|
||||
"@pushrocks/taskbuffer": "^2.0.15"
|
||||
},
|
||||
"files": [
|
||||
"ts/**/*",
|
||||
"ts_web/**/*",
|
||||
"dist/**/*",
|
||||
"dist_web/**/*",
|
||||
"dist_ts_web/**/*",
|
||||
"assets/**/*",
|
||||
"cli.js",
|
||||
"npmextra.json",
|
||||
"readme.md"
|
||||
]
|
||||
}
|
||||
|
@@ -21,6 +21,6 @@ watch typescript projects during development
|
||||
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)
|
||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||
|
||||
[](https://maintainedby.lossless.com)
|
||||
[](https://maintainedby.lossless.com)
|
||||
|
@@ -4,6 +4,10 @@ import * as tswatch from '../ts/index';
|
||||
|
||||
let testTsWatchInstance: tswatch.TsWatch;
|
||||
|
||||
if (process.env.CI) {
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
tap.test('should create a valid TsWatch instance', async () => {
|
||||
testTsWatchInstance = new tswatch.TsWatch('echoSomething');
|
||||
});
|
||||
@@ -12,7 +16,7 @@ tap.test('should start the tswatch instance', async () => {
|
||||
await testTsWatchInstance.start();
|
||||
});
|
||||
|
||||
tap.test('should stop the instance', async (tools) => {
|
||||
tap.test('should stop the instance', async tools => {
|
||||
tools.delayFor(2000);
|
||||
testTsWatchInstance.stop();
|
||||
});
|
||||
|
@@ -1 +1,7 @@
|
||||
export type TWatchModes = 'test' | 'gitzone_npm' | 'gitzone_service' | 'gitzone_website' | 'echoSomething';
|
||||
export type TWatchModes =
|
||||
| 'test'
|
||||
| 'gitzone_npm'
|
||||
| 'gitzone_service'
|
||||
| 'gitzone_element'
|
||||
| 'gitzone_website'
|
||||
| 'echoSomething';
|
||||
|
@@ -18,37 +18,59 @@ export class TsWatch {
|
||||
public async start() {
|
||||
switch (this.watchmode) {
|
||||
case 'test':
|
||||
const tsWatchInstanceTest = new Watcher({
|
||||
filePathToWatch: paths.cwd,
|
||||
commandToExecute: 'npm run test2',
|
||||
timeout: null
|
||||
});
|
||||
this.watcherMap.add(tsWatchInstanceTest);
|
||||
this.watcherMap.add(
|
||||
new Watcher({
|
||||
filePathToWatch: paths.cwd,
|
||||
commandToExecute: 'npm run test2',
|
||||
timeout: null
|
||||
})
|
||||
);
|
||||
break;
|
||||
case 'gitzone_npm':
|
||||
const tsWatchInstanceGitzoneNpm = new Watcher({
|
||||
filePathToWatch: paths.cwd,
|
||||
commandToExecute: 'npm run test',
|
||||
timeout: null
|
||||
this.watcherMap.add(
|
||||
new Watcher({
|
||||
filePathToWatch: paths.cwd,
|
||||
commandToExecute: 'npm run test',
|
||||
timeout: null
|
||||
})
|
||||
);
|
||||
break;
|
||||
case 'gitzone_element':
|
||||
const smartserve = new plugins.smartserve.SmartServe({
|
||||
injectReload: true,
|
||||
serveDir: './dist_web/'
|
||||
});
|
||||
this.watcherMap.add(tsWatchInstanceGitzoneNpm);
|
||||
await smartserve.start();
|
||||
this.watcherMap.add(
|
||||
new Watcher({
|
||||
filePathToWatch: plugins.path.join(paths.cwd, './ts_web/'),
|
||||
commandToExecute: async () => {
|
||||
const tsbundle = new plugins.tsbundle.TsBundle();
|
||||
const htmlHandler = new plugins.tsbundle.HtmlHandler();
|
||||
await tsbundle.buildProduction('./ts_web/index.ts', './dist_web/bundle.js');
|
||||
await htmlHandler.copyHtml();
|
||||
},
|
||||
timeout: null
|
||||
})
|
||||
);
|
||||
break;
|
||||
case 'gitzone_website':
|
||||
// server directory
|
||||
this.watcherMap.add(
|
||||
new Watcher({
|
||||
filePathToWatch: plugins.path.join(paths.cwd, './ts/'),
|
||||
commandToExecute: 'npm run start',
|
||||
commandToExecute: 'npm run startTs',
|
||||
timeout: null
|
||||
})
|
||||
);
|
||||
|
||||
// client directory
|
||||
this.watcherMap.add(new Watcher({
|
||||
filePathToWatch: plugins.path.join(paths.cwd, './ts_web/'),
|
||||
commandToExecute: 'npm run build',
|
||||
timeout: null
|
||||
}));
|
||||
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({
|
||||
|
@@ -1,9 +1,11 @@
|
||||
import * as plugins from './tswatch.plugins';
|
||||
import { logger } from './tswatch.logging';
|
||||
|
||||
export type TCommandFunction = () => Promise<void>;
|
||||
|
||||
export interface IWatcherConstructorOptions {
|
||||
filePathToWatch: string;
|
||||
commandToExecute: string;
|
||||
commandToExecute: string | TCommandFunction;
|
||||
timeout?: number;
|
||||
}
|
||||
|
||||
@@ -11,9 +13,28 @@ export interface IWatcherConstructorOptions {
|
||||
* A watcher keeps track of one child execution
|
||||
*/
|
||||
export class Watcher {
|
||||
/**
|
||||
* used to execute shell commands
|
||||
*/
|
||||
private smartshellInstance = new plugins.smartshell.Smartshell({
|
||||
executor: 'bash'
|
||||
});
|
||||
|
||||
/**
|
||||
* used to execute
|
||||
*/
|
||||
private executionTask: plugins.taskbuffer.Task = new plugins.taskbuffer.Task({
|
||||
name: 'watcherCommandFunctionTask',
|
||||
taskFunction: async () => {
|
||||
if (typeof this.options.commandToExecute === 'string') {
|
||||
throw new Error('cannot execute string as task');
|
||||
}
|
||||
await this.options.commandToExecute();
|
||||
},
|
||||
buffered: true,
|
||||
bufferMax: 1
|
||||
});
|
||||
|
||||
private currentExecution: plugins.smartshell.IExecResultStreaming;
|
||||
private smartchokWatcher = new plugins.smartchok.Smartchok([], {});
|
||||
private options: IWatcherConstructorOptions;
|
||||
@@ -26,7 +47,7 @@ export class Watcher {
|
||||
* start the file
|
||||
*/
|
||||
public async start() {
|
||||
this.setupCleanup();
|
||||
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();
|
||||
@@ -41,16 +62,20 @@ export class Watcher {
|
||||
* updates the current execution
|
||||
*/
|
||||
private async updateCurrentExecution() {
|
||||
if (this.currentExecution) {
|
||||
logger.log('ok', `reexecuting ${this.options.commandToExecute}`);
|
||||
process.kill(-this.currentExecution.childProcess.pid);
|
||||
if (typeof this.options.commandToExecute === 'string') {
|
||||
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;
|
||||
} else {
|
||||
logger.log('ok', `executing ${this.options.commandToExecute} for the first time`);
|
||||
await this.executionTask.trigger();
|
||||
}
|
||||
this.currentExecution = await this.smartshellInstance.execStreaming(
|
||||
this.options.commandToExecute
|
||||
);
|
||||
this.currentExecution = null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,7 +115,7 @@ export class Watcher {
|
||||
*/
|
||||
public async stop() {
|
||||
await this.smartchokWatcher.stop();
|
||||
if (this.currentExecution) {
|
||||
if (this.currentExecution && !this.currentExecution.childProcess.killed) {
|
||||
process.kill(-this.currentExecution.childProcess.pid);
|
||||
}
|
||||
}
|
||||
|
@@ -18,6 +18,12 @@ 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();
|
||||
|
@@ -1,6 +1,13 @@
|
||||
import * as path from 'path';
|
||||
export { path };
|
||||
|
||||
// @gitzone scope
|
||||
import * as tsbundle from '@gitzone/tsbundle';
|
||||
|
||||
export {
|
||||
tsbundle
|
||||
};
|
||||
|
||||
// @pushrocks scope
|
||||
import * as lik from '@pushrocks/lik';
|
||||
import * as smartchok from '@pushrocks/smartchok';
|
||||
@@ -8,6 +15,8 @@ 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 smartserve from '@pushrocks/smartserve';
|
||||
import * as smartshell from '@pushrocks/smartshell';
|
||||
import * as taskbuffer from '@pushrocks/taskbuffer';
|
||||
|
||||
export { lik, smartchok, smartcli, smartdelay, smartlog, smartlogDestinationLocal, smartshell };
|
||||
export { lik, smartchok, smartcli, smartdelay, smartlog, smartlogDestinationLocal, smartserve, smartshell, taskbuffer };
|
||||
|
Reference in New Issue
Block a user