Compare commits
17 Commits
Author | SHA1 | Date | |
---|---|---|---|
c9a3b996cb | |||
d81d19008a | |||
e4ef6bad8f | |||
2873314742 | |||
e26fa92744 | |||
995f296319 | |||
e7866dadb7 | |||
9302e78f86 | |||
0a302bee95 | |||
deb5e1daf9 | |||
5fe27ee706 | |||
b73807baf0 | |||
1e71fc24d5 | |||
e8071e76a1 | |||
b11d03dd41 | |||
72297d2f58 | |||
71b900ac47 |
5
.gitignore
vendored
5
.gitignore
vendored
@@ -8,9 +8,12 @@ pages/
|
|||||||
# installs
|
# installs
|
||||||
node_modules/
|
node_modules/
|
||||||
|
|
||||||
# caches and builds
|
# caches
|
||||||
.yarn/
|
.yarn/
|
||||||
.cache/
|
.cache/
|
||||||
|
.rpt2_cache
|
||||||
|
|
||||||
|
# builds
|
||||||
dist/
|
dist/
|
||||||
dist_web/
|
dist_web/
|
||||||
dist_serve/
|
dist_serve/
|
||||||
|
@@ -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:
|
||||||
@@ -38,19 +38,7 @@ snyk:
|
|||||||
# test stage
|
# test stage
|
||||||
# ====================
|
# ====================
|
||||||
|
|
||||||
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
|
||||||
@@ -60,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:
|
||||||
@@ -78,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
|
||||||
@@ -106,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
|
||||||
|
3571
package-lock.json
generated
3571
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
41
package.json
41
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@gitzone/tswatch",
|
"name": "@gitzone/tswatch",
|
||||||
"version": "1.0.17",
|
"version": "1.0.26",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "watch typescript projects during development",
|
"description": "watch typescript projects during development",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
@@ -12,26 +12,39 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(tstest test/)",
|
"test": "(tstest test/)",
|
||||||
"build": "(tsbuild)",
|
"build": "(tsbuild)"
|
||||||
"format": "(gitzone format)"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.11",
|
"@gitzone/tsbuild": "^2.1.17",
|
||||||
"@gitzone/tstest": "^1.0.23",
|
"@gitzone/tstest": "^1.0.28",
|
||||||
"@pushrocks/tapbundle": "^3.0.9",
|
"@pushrocks/tapbundle": "^3.0.13",
|
||||||
"@types/node": "^12.0.2",
|
"@types/node": "^12.7.12",
|
||||||
"tslint": "^5.16.0",
|
"tslint": "^5.20.0",
|
||||||
"tslint-config-prettier": "^1.18.0"
|
"tslint-config-prettier": "^1.18.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@gitzone/tsrun": "^1.2.6",
|
"@gitzone/tsbundle": "^1.0.47",
|
||||||
|
"@gitzone/tsrun": "^1.2.8",
|
||||||
"@pushrocks/early": "^3.0.3",
|
"@pushrocks/early": "^3.0.3",
|
||||||
"@pushrocks/lik": "^3.0.5",
|
"@pushrocks/lik": "^3.0.11",
|
||||||
"@pushrocks/smartchok": "^1.0.18",
|
"@pushrocks/smartchok": "^1.0.23",
|
||||||
"@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": "^8.0.2",
|
||||||
"@pushrocks/smartshell": "^2.0.22"
|
"@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.
|
For further information read the linked docs at the top of this readme.
|
||||||
|
|
||||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
> 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)
|
||||||
|
@@ -12,7 +12,7 @@ tap.test('should start the tswatch instance', async () => {
|
|||||||
await testTsWatchInstance.start();
|
await testTsWatchInstance.start();
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should stop the instance', async (tools) => {
|
tap.test('should stop the instance', async tools => {
|
||||||
tools.delayFor(2000);
|
tools.delayFor(2000);
|
||||||
testTsWatchInstance.stop();
|
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,39 +18,63 @@ export class TsWatch {
|
|||||||
public async start() {
|
public async start() {
|
||||||
switch (this.watchmode) {
|
switch (this.watchmode) {
|
||||||
case 'test':
|
case 'test':
|
||||||
this.watcherMap.add(new Watcher({
|
this.watcherMap.add(
|
||||||
filePathToWatch: paths.cwd,
|
new Watcher({
|
||||||
commandToExecute: 'npm run test2',
|
filePathToWatch: paths.cwd,
|
||||||
timeout: null
|
commandToExecute: 'npm run test2',
|
||||||
}));
|
timeout: null
|
||||||
|
})
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
case 'gitzone_npm':
|
case 'gitzone_npm':
|
||||||
this.watcherMap.add(new Watcher({
|
this.watcherMap.add(
|
||||||
filePathToWatch: paths.cwd,
|
new Watcher({
|
||||||
commandToExecute: 'npm run test',
|
filePathToWatch: paths.cwd,
|
||||||
timeout: null
|
commandToExecute: 'npm run test',
|
||||||
}));
|
timeout: null
|
||||||
|
})
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case 'gitzone_element':
|
||||||
|
const smartserve = new plugins.smartserve.SmartServe({
|
||||||
|
injectReload: true,
|
||||||
|
serveDir: './dist_web/'
|
||||||
|
});
|
||||||
|
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;
|
break;
|
||||||
case 'gitzone_website':
|
case 'gitzone_website':
|
||||||
// server directory
|
|
||||||
this.watcherMap.add(
|
this.watcherMap.add(
|
||||||
new Watcher({
|
new Watcher({
|
||||||
filePathToWatch: plugins.path.join(paths.cwd, './ts/'),
|
filePathToWatch: plugins.path.join(paths.cwd, './ts/'),
|
||||||
commandToExecute: 'npm run start',
|
commandToExecute: 'npm run startTs',
|
||||||
timeout: null
|
timeout: null
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
// client directory
|
// client directory
|
||||||
this.watcherMap.add(new Watcher({
|
this.watcherMap.add(
|
||||||
filePathToWatch: plugins.path.join(paths.cwd, './ts_web/'),
|
new Watcher({
|
||||||
commandToExecute: 'npm run build',
|
filePathToWatch: plugins.path.join(paths.cwd, './ts_web/'),
|
||||||
timeout: null
|
commandToExecute: 'npm run build',
|
||||||
}));
|
timeout: null
|
||||||
|
})
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
case 'echoSomething':
|
case 'echoSomething':
|
||||||
const tsWatchInstanceEchoSomething = new Watcher({
|
const tsWatchInstanceEchoSomething = new Watcher({
|
||||||
filePathToWatch: paths.cwd,
|
filePathToWatch: plugins.path.join(paths.cwd, './ts'),
|
||||||
commandToExecute: 'npm -v',
|
commandToExecute: 'npm -v',
|
||||||
timeout: null
|
timeout: null
|
||||||
});
|
});
|
||||||
|
@@ -1,9 +1,11 @@
|
|||||||
import * as plugins from './tswatch.plugins';
|
import * as plugins from './tswatch.plugins';
|
||||||
import { logger } from './tswatch.logging';
|
import { logger } from './tswatch.logging';
|
||||||
|
|
||||||
|
export type TCommandFunction = () => Promise<void>;
|
||||||
|
|
||||||
export interface IWatcherConstructorOptions {
|
export interface IWatcherConstructorOptions {
|
||||||
filePathToWatch: string;
|
filePathToWatch: string;
|
||||||
commandToExecute: string;
|
commandToExecute: string | TCommandFunction;
|
||||||
timeout?: number;
|
timeout?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -11,9 +13,28 @@ export interface IWatcherConstructorOptions {
|
|||||||
* A watcher keeps track of one child execution
|
* A watcher keeps track of one child execution
|
||||||
*/
|
*/
|
||||||
export class Watcher {
|
export class Watcher {
|
||||||
|
/**
|
||||||
|
* used to execute shell commands
|
||||||
|
*/
|
||||||
private smartshellInstance = new plugins.smartshell.Smartshell({
|
private smartshellInstance = new plugins.smartshell.Smartshell({
|
||||||
executor: 'bash'
|
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 currentExecution: plugins.smartshell.IExecResultStreaming;
|
||||||
private smartchokWatcher = new plugins.smartchok.Smartchok([], {});
|
private smartchokWatcher = new plugins.smartchok.Smartchok([], {});
|
||||||
private options: IWatcherConstructorOptions;
|
private options: IWatcherConstructorOptions;
|
||||||
@@ -26,7 +47,7 @@ export class Watcher {
|
|||||||
* start the file
|
* start the file
|
||||||
*/
|
*/
|
||||||
public async start() {
|
public async start() {
|
||||||
this.setupCleanup();
|
await this.setupCleanup();
|
||||||
console.log(`Looking at ${this.options.filePathToWatch} for changes`);
|
console.log(`Looking at ${this.options.filePathToWatch} for changes`);
|
||||||
this.smartchokWatcher.add([this.options.filePathToWatch]); // __dirname refers to the directory of this very file
|
this.smartchokWatcher.add([this.options.filePathToWatch]); // __dirname refers to the directory of this very file
|
||||||
await this.smartchokWatcher.start();
|
await this.smartchokWatcher.start();
|
||||||
@@ -41,16 +62,20 @@ export class Watcher {
|
|||||||
* updates the current execution
|
* updates the current execution
|
||||||
*/
|
*/
|
||||||
private async updateCurrentExecution() {
|
private async updateCurrentExecution() {
|
||||||
if (this.currentExecution) {
|
if (typeof this.options.commandToExecute === 'string') {
|
||||||
logger.log('ok', `reexecuting ${this.options.commandToExecute}`);
|
if (this.currentExecution) {
|
||||||
process.kill(-this.currentExecution.childProcess.pid);
|
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 {
|
} 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -20,4 +20,10 @@ tswatchCli.addCommand('website').subscribe(async argvArg => {
|
|||||||
await tsWatch.start();
|
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();
|
||||||
|
@@ -1,6 +1,13 @@
|
|||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
export { path };
|
export { path };
|
||||||
|
|
||||||
|
// @gitzone scope
|
||||||
|
import * as tsbundle from '@gitzone/tsbundle';
|
||||||
|
|
||||||
|
export {
|
||||||
|
tsbundle
|
||||||
|
};
|
||||||
|
|
||||||
// @pushrocks scope
|
// @pushrocks scope
|
||||||
import * as lik from '@pushrocks/lik';
|
import * as lik from '@pushrocks/lik';
|
||||||
import * as smartchok from '@pushrocks/smartchok';
|
import * as smartchok from '@pushrocks/smartchok';
|
||||||
@@ -8,6 +15,8 @@ import * as smartcli from '@pushrocks/smartcli';
|
|||||||
import * as smartdelay from '@pushrocks/smartdelay';
|
import * as smartdelay from '@pushrocks/smartdelay';
|
||||||
import * as smartlog from '@pushrocks/smartlog';
|
import * as smartlog from '@pushrocks/smartlog';
|
||||||
import * as smartlogDestinationLocal from '@pushrocks/smartlog-destination-local';
|
import * as smartlogDestinationLocal from '@pushrocks/smartlog-destination-local';
|
||||||
|
import * as smartserve from '@pushrocks/smartserve';
|
||||||
import * as smartshell from '@pushrocks/smartshell';
|
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