Compare commits

...

4 Commits

Author SHA1 Message Date
4cf71d2edc 1.0.64 2022-03-18 13:18:15 +01:00
0eec0c04e8 fix(core): update 2022-03-18 13:18:15 +01:00
ef5d4d2a9c 1.0.63 2022-03-18 07:13:20 +01:00
f05481a267 fix(core): update 2022-03-18 07:13:20 +01:00
5 changed files with 837 additions and 873 deletions

1642
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{ {
"name": "@gitzone/tswatch", "name": "@gitzone/tswatch",
"version": "1.0.62", "version": "1.0.64",
"private": false, "private": false,
"description": "watch typescript projects during development", "description": "watch typescript projects during development",
"main": "dist_ts/index.js", "main": "dist_ts/index.js",
@@ -16,12 +16,13 @@
"build": "(tsbuild --web --skiplibcheck --allowimplicitany)" "build": "(tsbuild --web --skiplibcheck --allowimplicitany)"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.50", "@gitzone/tsbuild": "^2.1.56",
"@gitzone/tstest": "^1.0.67", "@gitzone/tstest": "^1.0.69",
"@pushrocks/tapbundle": "^5.0.2", "@pushrocks/tapbundle": "^5.0.2",
"@types/node": "^17.0.21" "@types/node": "^17.0.21"
}, },
"dependencies": { "dependencies": {
"@gitzone/tsbundle": "^1.0.99",
"@gitzone/tsrun": "^1.2.31", "@gitzone/tsrun": "^1.2.31",
"@pushrocks/early": "^3.0.3", "@pushrocks/early": "^3.0.3",
"@pushrocks/lik": "^5.0.4", "@pushrocks/lik": "^5.0.4",
@@ -30,8 +31,7 @@
"@pushrocks/smartdelay": "^2.0.13", "@pushrocks/smartdelay": "^2.0.13",
"@pushrocks/smartlog": "^2.0.44", "@pushrocks/smartlog": "^2.0.44",
"@pushrocks/smartlog-destination-local": "^8.0.8", "@pushrocks/smartlog-destination-local": "^8.0.8",
"@pushrocks/smartparcel": "^1.0.13", "@pushrocks/smartserve": "^2.0.0",
"@pushrocks/smartserve": "^1.1.41",
"@pushrocks/smartshell": "^2.0.30", "@pushrocks/smartshell": "^2.0.30",
"@pushrocks/taskbuffer": "^2.1.17" "@pushrocks/taskbuffer": "^2.1.17"
}, },

View File

@@ -41,12 +41,34 @@ export class TsWatch {
console.log( console.log(
'bundling TypeScript files to "dist_watch" Note: This is for development only!' 'bundling TypeScript files to "dist_watch" Note: This is for development only!'
); );
const parcel = new plugins.smartparcel.Parcel( const smartserve = new plugins.smartserve.SmartServe({
injectReload: true,
serveDir: plugins.path.join(paths.cwd, './dist_watch/'),
port: 3002,
});
const tsbundle = new plugins.tsbundle.TsBundle();
const bundleAndReload = async () => {
await tsbundle.build(paths.cwd, './ts_web/index.ts', './dist_watch/bundle.js', {
bundler: 'esbuild'
});
await smartserve.reload();
}
this.watcherMap.add(
new Watcher({
filePathToWatch: plugins.path.join(paths.cwd, './ts_web/'),
functionToCall: async () => {
await bundleAndReload();
},
timeout: null,
})
);
await smartserve.start();
/* const parcel = new plugins.smartparcel.Parcel(
plugins.path.join(process.cwd(), './html/index.html'), plugins.path.join(process.cwd(), './html/index.html'),
plugins.path.join(process.cwd(), './dist_watch'), plugins.path.join(process.cwd(), './dist_watch'),
'index.html' 'index.html'
); );
await parcel.watchAndServe(); await parcel.watchAndServe(); */
break; break;
case 'gitzone_website': case 'gitzone_website':
this.watcherMap.add( this.watcherMap.add(
@@ -56,14 +78,21 @@ export class TsWatch {
timeout: null, timeout: null,
}) })
); );
this.watcherMap.add(
new Watcher({
filePathToWatch: plugins.path.join(paths.cwd, './ts_web/'),
commandToExecute: 'npm run bundle',
timeout: null,
})
);
// client directory // client directory
const parcelWebsite = new plugins.smartparcel.Parcel( /* const parcelWebsite = new plugins.smartparcel.Parcel(
plugins.path.join(process.cwd(), './html/index.html'), plugins.path.join(process.cwd(), './html/index.html'),
plugins.path.join(process.cwd(), './dist_serve'), plugins.path.join(process.cwd(), './dist_serve'),
'bundle.js' 'bundle.js'
); );
await parcelWebsite.watchAndServe(); await parcelWebsite.watchAndServe(); */
break; break;
case 'gitzone_service': case 'gitzone_service':
this.watcherMap.add( this.watcherMap.add(

View File

@@ -1,11 +1,10 @@
import * as plugins from './tswatch.plugins.js'; import * as plugins from './tswatch.plugins.js';
import { logger } from './tswatch.logging.js'; import { logger } from './tswatch.logging.js';
export type TCommandFunction = () => Promise<void>;
export interface IWatcherConstructorOptions { export interface IWatcherConstructorOptions {
filePathToWatch: string; filePathToWatch: string;
commandToExecute: string | TCommandFunction; commandToExecute?: string;
functionToCall?: () => Promise<any>;
timeout?: number; timeout?: number;
} }
@@ -47,7 +46,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.options.commandToExecute) {
if (this.currentExecution) { if (this.currentExecution) {
logger.log('ok', `reexecuting ${this.options.commandToExecute}`); logger.log('ok', `reexecuting ${this.options.commandToExecute}`);
this.currentExecution.kill(); this.currentExecution.kill();
@@ -58,7 +57,12 @@ export class Watcher {
this.options.commandToExecute this.options.commandToExecute
); );
} else { } else {
console.log('cannot run execution task'); console.log('no executionCommand set');
}
if (this.options.functionToCall) {
this.options.functionToCall();
} else {
console.log('no functionToCall set.')
} }
} }

View File

@@ -1,6 +1,13 @@
// node native scope
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';