Compare commits

...

15 Commits

Author SHA1 Message Date
21b962b9a8 1.0.28 2019-10-12 18:09:42 +02:00
f673e8577b fix(core): update 2019-10-12 18:09:41 +02:00
e4278ed270 1.0.27 2019-10-12 17:43:44 +02:00
8ae0f960ac fix(core): update 2019-10-12 17:43:43 +02:00
c9a3b996cb 1.0.26 2019-10-12 17:34:05 +02:00
d81d19008a fix(core): update 2019-10-12 17:34:05 +02:00
e4ef6bad8f 1.0.25 2019-10-12 17:31:26 +02:00
2873314742 fix(core): update 2019-10-12 17:31:25 +02:00
e26fa92744 1.0.24 2019-10-12 17:17:32 +02:00
995f296319 fix(core): update 2019-10-12 17:17:31 +02:00
e7866dadb7 1.0.23 2019-10-12 17:12:51 +02:00
9302e78f86 fix(core): update 2019-10-12 17:12:50 +02:00
0a302bee95 1.0.22 2019-10-12 16:54:19 +02:00
deb5e1daf9 1.0.21 2019-10-12 16:54:03 +02:00
5fe27ee706 fix(core): update 2019-10-12 16:54:03 +02:00
6 changed files with 96 additions and 32 deletions

37
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{ {
"name": "@gitzone/tswatch", "name": "@gitzone/tswatch",
"version": "1.0.20", "version": "1.0.28",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@@ -804,9 +804,9 @@
} }
}, },
"@gitzone/tsbundle": { "@gitzone/tsbundle": {
"version": "1.0.45", "version": "1.0.47",
"resolved": "https://verdaccio.lossless.one/@gitzone%2ftsbundle/-/tsbundle-1.0.45.tgz", "resolved": "https://verdaccio.lossless.one/@gitzone%2ftsbundle/-/tsbundle-1.0.47.tgz",
"integrity": "sha512-hN4SEozvZZUXmRsL1D1SjVzXR7+Tq4V5I2MZrAz60IJOztd4QiCpRQwgfLHS70K5PH9TE736+lhs0l3XbABVbA==", "integrity": "sha512-lg/LHfzF+SqXa+SaiCNlCja+N/xreu87rc83hadsDmCids1yurevB5e6W3xRbWGyJxiQ3yrTunRolPPP040hPQ==",
"requires": { "requires": {
"@babel/core": "^7.6.2", "@babel/core": "^7.6.2",
"@babel/plugin-proposal-class-properties": "^7.5.5", "@babel/plugin-proposal-class-properties": "^7.5.5",
@@ -1354,6 +1354,35 @@
} }
} }
}, },
"@pushrocks/taskbuffer": {
"version": "2.0.15",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2ftaskbuffer/-/taskbuffer-2.0.15.tgz",
"integrity": "sha512-mDqakt2NU9gv6Vd5hTZj9Nv3YgjUU5r1ILK3YZOlOjzcKXZkVYL1+BdtrPUb4Shp30xPXpMSBaesC1OZNliWjQ==",
"requires": {
"@pushrocks/lik": "^3.0.11",
"@pushrocks/smartdelay": "^2.0.3",
"@pushrocks/smartlog": "^2.0.19",
"@pushrocks/smartpromise": "^3.0.5",
"@types/cron": "^1.7.1",
"cron": "^1.7.2",
"rxjs": "^6.5.3"
},
"dependencies": {
"@pushrocks/smartpromise": {
"version": "3.0.6",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartpromise/-/smartpromise-3.0.6.tgz",
"integrity": "sha512-vlQlBGNVIjfClgnsfgQBU6GIKcskYSFzEcKLt18ngPzPEcjKklXcxaqzLXpnoxR+KBh30QPE8255ncYHXuPPOg=="
},
"rxjs": {
"version": "6.5.3",
"resolved": "https://verdaccio.lossless.one/rxjs/-/rxjs-6.5.3.tgz",
"integrity": "sha512-wuYsAYYFdWTAnAaPoKGNhfpWwKZbJW+HgAJ+mImp+Epl7BG8oNWBCTyRM8gba9k4lk8BgWdoYm21Mo/RYhhbgA==",
"requires": {
"tslib": "^1.9.0"
}
}
}
},
"@types/body-parser": { "@types/body-parser": {
"version": "1.17.1", "version": "1.17.1",
"resolved": "https://verdaccio.lossless.one/@types%2fbody-parser/-/body-parser-1.17.1.tgz", "resolved": "https://verdaccio.lossless.one/@types%2fbody-parser/-/body-parser-1.17.1.tgz",

View File

@@ -1,6 +1,6 @@
{ {
"name": "@gitzone/tswatch", "name": "@gitzone/tswatch",
"version": "1.0.20", "version": "1.0.28",
"private": false, "private": false,
"description": "watch typescript projects during development", "description": "watch typescript projects during development",
"main": "dist/index.js", "main": "dist/index.js",
@@ -23,7 +23,7 @@
"tslint-config-prettier": "^1.18.0" "tslint-config-prettier": "^1.18.0"
}, },
"dependencies": { "dependencies": {
"@gitzone/tsbundle": "^1.0.45", "@gitzone/tsbundle": "^1.0.47",
"@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.11",
@@ -33,7 +33,8 @@
"@pushrocks/smartlog": "^2.0.19", "@pushrocks/smartlog": "^2.0.19",
"@pushrocks/smartlog-destination-local": "^8.0.2", "@pushrocks/smartlog-destination-local": "^8.0.2",
"@pushrocks/smartserve": "^1.1.37", "@pushrocks/smartserve": "^1.1.37",
"@pushrocks/smartshell": "^2.0.25" "@pushrocks/smartshell": "^2.0.25",
"@pushrocks/taskbuffer": "^2.0.15"
}, },
"files": [ "files": [
"ts/**/*", "ts/**/*",

View File

@@ -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() {
}
}

View File

@@ -36,10 +36,22 @@ export class TsWatch {
); );
break; break;
case 'gitzone_element': case 'gitzone_element':
// lets create a standard server
const smartserve = new plugins.smartserve.SmartServe({
port: 3001,
injectReload: true,
serveDir: plugins.path.join(paths.cwd, './dist_web/')
});
await smartserve.start();
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.buildProduction('./ts_web/index.ts', './dist_web/bundle.js');
await htmlHandler.copyHtml();
},
timeout: null timeout: null
}) })
); );
@@ -64,7 +76,7 @@ export class TsWatch {
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
}); });

View File

@@ -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;
@@ -41,6 +62,7 @@ export class Watcher {
* updates the current execution * updates the current execution
*/ */
private async updateCurrentExecution() { private async updateCurrentExecution() {
if (typeof this.options.commandToExecute === 'string') {
if (this.currentExecution) { if (this.currentExecution) {
logger.log('ok', `reexecuting ${this.options.commandToExecute}`); logger.log('ok', `reexecuting ${this.options.commandToExecute}`);
process.kill(-this.currentExecution.childProcess.pid); process.kill(-this.currentExecution.childProcess.pid);
@@ -51,6 +73,9 @@ export class Watcher {
this.options.commandToExecute this.options.commandToExecute
); );
this.currentExecution = null; this.currentExecution = null;
} else {
await this.executionTask.trigger();
}
} }
/** /**

View File

@@ -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 };