Compare commits
23 Commits
Author | SHA1 | Date | |
---|---|---|---|
4d23145529 | |||
27e0d7588d | |||
88d4bf6be0 | |||
d4f8215f35 | |||
85f72feeb9 | |||
bd4ccbd215 | |||
79940cec3f | |||
e20508ffbc | |||
21b962b9a8 | |||
f673e8577b | |||
e4278ed270 | |||
8ae0f960ac | |||
c9a3b996cb | |||
d81d19008a | |||
e4ef6bad8f | |||
2873314742 | |||
e26fa92744 | |||
995f296319 | |||
e7866dadb7 | |||
9302e78f86 | |||
0a302bee95 | |||
deb5e1daf9 | |||
5fe27ee706 |
2179
package-lock.json
generated
2179
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
21
package.json
21
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@gitzone/tswatch",
|
"name": "@gitzone/tswatch",
|
||||||
"version": "1.0.20",
|
"version": "1.0.32",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "watch typescript projects during development",
|
"description": "watch typescript projects during development",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
@@ -17,23 +17,24 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.17",
|
"@gitzone/tsbuild": "^2.1.17",
|
||||||
"@gitzone/tstest": "^1.0.28",
|
"@gitzone/tstest": "^1.0.28",
|
||||||
"@pushrocks/tapbundle": "^3.0.13",
|
"@pushrocks/tapbundle": "^3.2.0",
|
||||||
"@types/node": "^12.7.12",
|
"@types/node": "^13.9.0",
|
||||||
"tslint": "^5.20.0",
|
"tslint": "^6.0.0",
|
||||||
"tslint-config-prettier": "^1.18.0"
|
"tslint-config-prettier": "^1.18.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@gitzone/tsbundle": "^1.0.45",
|
"@gitzone/tsbundle": "^1.0.51",
|
||||||
"@gitzone/tsrun": "^1.2.8",
|
"@gitzone/tsrun": "^1.2.8",
|
||||||
"@pushrocks/early": "^3.0.3",
|
"@pushrocks/early": "^3.0.3",
|
||||||
"@pushrocks/lik": "^3.0.11",
|
"@pushrocks/lik": "^3.0.19",
|
||||||
"@pushrocks/smartchok": "^1.0.23",
|
"@pushrocks/smartchok": "^1.0.23",
|
||||||
"@pushrocks/smartcli": "^3.0.7",
|
"@pushrocks/smartcli": "^3.0.7",
|
||||||
"@pushrocks/smartdelay": "^2.0.3",
|
"@pushrocks/smartdelay": "^2.0.6",
|
||||||
"@pushrocks/smartlog": "^2.0.19",
|
"@pushrocks/smartlog": "^2.0.21",
|
||||||
"@pushrocks/smartlog-destination-local": "^8.0.2",
|
"@pushrocks/smartlog-destination-local": "^8.0.2",
|
||||||
"@pushrocks/smartserve": "^1.1.37",
|
"@pushrocks/smartserve": "^1.1.39",
|
||||||
"@pushrocks/smartshell": "^2.0.25"
|
"@pushrocks/smartshell": "^2.0.25",
|
||||||
|
"@pushrocks/taskbuffer": "^2.1.1"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"ts/**/*",
|
"ts/**/*",
|
||||||
|
@@ -1,12 +0,0 @@
|
|||||||
import * as plugins from './tswatch.plugins';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* an element server for developing lit elements compliant to gitzone standard
|
|
||||||
*/
|
|
||||||
export class ElementServer {
|
|
||||||
constructor() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@@ -7,6 +7,7 @@ import { Watcher } from './tswatch.classes.watcher';
|
|||||||
export class TsWatch {
|
export class TsWatch {
|
||||||
public watchmode: interfaces.TWatchModes;
|
public watchmode: interfaces.TWatchModes;
|
||||||
public watcherMap = new plugins.lik.Objectmap<Watcher>();
|
public watcherMap = new plugins.lik.Objectmap<Watcher>();
|
||||||
|
public smartserve: plugins.smartserve.SmartServe;
|
||||||
|
|
||||||
constructor(watchmodeArg: interfaces.TWatchModes) {
|
constructor(watchmodeArg: interfaces.TWatchModes) {
|
||||||
this.watchmode = watchmodeArg;
|
this.watchmode = watchmodeArg;
|
||||||
@@ -36,10 +37,22 @@ export class TsWatch {
|
|||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case 'gitzone_element':
|
case 'gitzone_element':
|
||||||
|
// lets create a standard server
|
||||||
|
console.log('bundling TypeScript files to "dist_watch" Note: This is for development only!');
|
||||||
|
this.smartserve = new plugins.smartserve.SmartServe({
|
||||||
|
port: 3001,
|
||||||
|
injectReload: true,
|
||||||
|
serveDir: plugins.path.join(paths.cwd, './dist_watch/')
|
||||||
|
});
|
||||||
this.watcherMap.add(
|
this.watcherMap.add(
|
||||||
new Watcher({
|
new Watcher({
|
||||||
filePathToWatch: plugins.path.join(paths.cwd, 'ts_web'),
|
filePathToWatch: plugins.path.join(paths.cwd, './ts_web/'),
|
||||||
commandToExecute: 'npm run build',
|
commandToExecute: async () => {
|
||||||
|
const tsbundle = new plugins.tsbundle.TsBundle();
|
||||||
|
const htmlHandler = new plugins.tsbundle.HtmlHandler();
|
||||||
|
await tsbundle.buildTest('./ts_web/index.ts', './dist_watch/bundle.js');
|
||||||
|
await htmlHandler.copyHtml(plugins.path.join(process.cwd(), './dist_watch/index.html'));
|
||||||
|
},
|
||||||
timeout: null
|
timeout: null
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@@ -62,9 +75,18 @@ export class TsWatch {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
case 'gitzone_service':
|
||||||
|
this.watcherMap.add(
|
||||||
|
new Watcher({
|
||||||
|
filePathToWatch: plugins.path.join(paths.cwd, './ts/'),
|
||||||
|
commandToExecute: 'npm run startTs',
|
||||||
|
timeout: null
|
||||||
|
})
|
||||||
|
);
|
||||||
|
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
|
||||||
});
|
});
|
||||||
@@ -76,12 +98,19 @@ export class TsWatch {
|
|||||||
this.watcherMap.forEach(async watcher => {
|
this.watcherMap.forEach(async watcher => {
|
||||||
await watcher.start();
|
await watcher.start();
|
||||||
});
|
});
|
||||||
|
if (this.smartserve) {
|
||||||
|
|
||||||
|
await this.smartserve.start();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* stops the execution of any active Watchers
|
* stops the execution of any active Watchers
|
||||||
*/
|
*/
|
||||||
public async stop() {
|
public async stop() {
|
||||||
|
if (this.smartserve) {
|
||||||
|
await this.smartserve.stop();
|
||||||
|
}
|
||||||
this.watcherMap.forEach(async watcher => {
|
this.watcherMap.forEach(async watcher => {
|
||||||
await watcher.stop();
|
await watcher.stop();
|
||||||
});
|
});
|
||||||
|
@@ -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;
|
||||||
@@ -34,23 +55,27 @@ export class Watcher {
|
|||||||
changeObservable.subscribe(() => {
|
changeObservable.subscribe(() => {
|
||||||
this.updateCurrentExecution();
|
this.updateCurrentExecution();
|
||||||
});
|
});
|
||||||
this.updateCurrentExecution();
|
await this.updateCurrentExecution();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -8,6 +8,24 @@ const tswatchCli = new plugins.smartcli.Smartcli();
|
|||||||
|
|
||||||
// standard behaviour will assume gitzone setup
|
// standard behaviour will assume gitzone setup
|
||||||
|
|
||||||
|
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.addCommand('npm').subscribe(async argvArg => {
|
||||||
|
logger.log('info', `running watch task for a gitzone element project`);
|
||||||
|
const tsWatch = new TsWatch('gitzone_npm');
|
||||||
|
await tsWatch.start();
|
||||||
|
});
|
||||||
|
|
||||||
|
tswatchCli.addCommand('service').subscribe(async argvArg => {
|
||||||
|
logger.log('info', `running test task`);
|
||||||
|
const tsWatch = new TsWatch('gitzone_service');
|
||||||
|
await tsWatch.start();
|
||||||
|
});
|
||||||
|
|
||||||
tswatchCli.addCommand('test').subscribe(async argvArg => {
|
tswatchCli.addCommand('test').subscribe(async argvArg => {
|
||||||
logger.log('info', `running test task`);
|
logger.log('info', `running test task`);
|
||||||
const tsWatch = new TsWatch('test');
|
const tsWatch = new TsWatch('test');
|
||||||
@@ -20,10 +38,4 @@ 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