fix(core): Refactor watch modes and update dependencies
This commit is contained in:
parent
95c57d489d
commit
7611268fb9
@ -1,5 +1,13 @@
|
||||
# Changelog
|
||||
|
||||
## 2024-12-04 - 2.0.26 - fix(core)
|
||||
Refactor watch modes and update dependencies
|
||||
|
||||
- Updated dependencies in package.json
|
||||
- Refactored watch mode names in interfaces and classes
|
||||
- Refactored CLI commands to use new watch mode names
|
||||
- Added import for smartfile in tswatch.plugins.ts
|
||||
|
||||
## 2024-10-27 - 2.0.25 - fix(typescript)
|
||||
Remove unnecessary reference types in TypeScript declaration files
|
||||
|
||||
|
@ -16,20 +16,21 @@
|
||||
"build": "(tsbuild --web --allowimplicitany)"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@git.zone/tsbuild": "^2.1.85",
|
||||
"@git.zone/tsbuild": "^2.2.0",
|
||||
"@git.zone/tstest": "^1.0.90",
|
||||
"@push.rocks/tapbundle": "^5.3.0",
|
||||
"@types/node": "^22.8.1"
|
||||
"@push.rocks/tapbundle": "^5.5.3",
|
||||
"@types/node": "^22.10.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@api.global/typedserver": "^3.0.51",
|
||||
"@git.zone/tsbundle": "^2.1.0",
|
||||
"@git.zone/tsrun": "^1.2.49",
|
||||
"@git.zone/tsrun": "^1.3.3",
|
||||
"@push.rocks/early": "^4.0.4",
|
||||
"@push.rocks/lik": "^6.1.0",
|
||||
"@push.rocks/smartchok": "^1.0.34",
|
||||
"@push.rocks/smartcli": "^4.0.11",
|
||||
"@push.rocks/smartdelay": "^3.0.5",
|
||||
"@push.rocks/smartfile": "^11.0.21",
|
||||
"@push.rocks/smartlog": "^3.0.7",
|
||||
"@push.rocks/smartlog-destination-local": "^9.0.2",
|
||||
"@push.rocks/smartshell": "^3.0.6",
|
||||
|
9380
pnpm-lock.yaml
generated
9380
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@git.zone/tswatch',
|
||||
version: '2.0.25',
|
||||
version: '2.0.26',
|
||||
description: 'watch typescript projects during development'
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
export type TWatchModes =
|
||||
| 'test'
|
||||
| 'gitzone_npm'
|
||||
| 'gitzone_service'
|
||||
| 'gitzone_element'
|
||||
| 'gitzone_website'
|
||||
| 'echoSomething';
|
||||
| 'node'
|
||||
| 'service'
|
||||
| 'element'
|
||||
| 'website'
|
||||
| 'echo';
|
||||
|
@ -21,6 +21,9 @@ export class TsWatch {
|
||||
const htmlHandler = new plugins.tsbundle.HtmlHandler();
|
||||
switch (this.watchmode) {
|
||||
case 'test':
|
||||
/**
|
||||
* this strategy runs test whenever there is a change in the ts directory
|
||||
*/
|
||||
this.watcherMap.add(
|
||||
new Watcher({
|
||||
filePathToWatch: paths.cwd,
|
||||
@ -29,7 +32,7 @@ export class TsWatch {
|
||||
})
|
||||
);
|
||||
break;
|
||||
case 'gitzone_npm':
|
||||
case 'node':
|
||||
this.watcherMap.add(
|
||||
new Watcher({
|
||||
filePathToWatch: paths.cwd,
|
||||
@ -38,88 +41,126 @@ export class TsWatch {
|
||||
})
|
||||
);
|
||||
break;
|
||||
case 'gitzone_element':
|
||||
// lets create a standard server
|
||||
console.log(
|
||||
'bundling TypeScript files to "dist_watch" Note: This is for development only!'
|
||||
);
|
||||
this.typedserver = new plugins.typedserver.TypedServer({
|
||||
cors: true,
|
||||
injectReload: true,
|
||||
serveDir: plugins.path.join(paths.cwd, './dist_watch/'),
|
||||
port: 3002,
|
||||
enableCompression: true,
|
||||
preferredCompressionMethod: 'gzip',
|
||||
});
|
||||
case 'element':
|
||||
(async () => {
|
||||
/**
|
||||
* this strategy runs a standard server and bundles the ts files to a dist_watch directory
|
||||
*/
|
||||
// lets create a standard server
|
||||
console.log(
|
||||
'bundling TypeScript files to "dist_watch" Note: This is for development only!'
|
||||
);
|
||||
this.typedserver = new plugins.typedserver.TypedServer({
|
||||
cors: true,
|
||||
injectReload: true,
|
||||
serveDir: plugins.path.join(paths.cwd, './dist_watch/'),
|
||||
port: 3002,
|
||||
enableCompression: true,
|
||||
preferredCompressionMethod: 'gzip',
|
||||
});
|
||||
|
||||
const bundleAndReloadElement = async () => {
|
||||
await tsbundle.build(paths.cwd, './html/index.ts', './dist_watch/bundle.js', {
|
||||
bundler: 'esbuild',
|
||||
const bundleAndReloadElement = async () => {
|
||||
await tsbundle.build(paths.cwd, './html/index.ts', './dist_watch/bundle.js', {
|
||||
bundler: 'esbuild',
|
||||
});
|
||||
await this.typedserver.reload();
|
||||
};
|
||||
this.watcherMap.add(
|
||||
new Watcher({
|
||||
filePathToWatch: plugins.path.join(paths.cwd, './ts_web/'),
|
||||
functionToCall: async () => {
|
||||
await bundleAndReloadElement();
|
||||
},
|
||||
timeout: null,
|
||||
})
|
||||
);
|
||||
|
||||
// lets get the other ts folders
|
||||
let tsfolders = await plugins.smartfile.fs.listFolders(paths.cwd);
|
||||
tsfolders = tsfolders.filter(
|
||||
(itemArg) => itemArg.startsWith('ts') && itemArg !== 'ts_web'
|
||||
);
|
||||
const smartshellInstance = new plugins.smartshell.Smartshell({
|
||||
executor: 'bash',
|
||||
});
|
||||
await this.typedserver.reload();
|
||||
};
|
||||
this.watcherMap.add(
|
||||
new Watcher({
|
||||
filePathToWatch: plugins.path.join(paths.cwd, './ts_web/'),
|
||||
functionToCall: async () => {
|
||||
await bundleAndReloadElement();
|
||||
},
|
||||
timeout: null,
|
||||
})
|
||||
);
|
||||
this.watcherMap.add(
|
||||
new Watcher({
|
||||
filePathToWatch: plugins.path.join(paths.cwd, './html/'),
|
||||
functionToCall: async () => {
|
||||
await htmlHandler.processHtml({
|
||||
from: plugins.path.join(paths.cwd, './html/index.html'),
|
||||
to: plugins.path.join(paths.cwd, './dist_watch/index.html'),
|
||||
minify: false,
|
||||
});
|
||||
await bundleAndReloadElement();
|
||||
},
|
||||
timeout: null,
|
||||
})
|
||||
);
|
||||
for (const tsfolder of tsfolders) {
|
||||
this.watcherMap.add(
|
||||
new Watcher({
|
||||
filePathToWatch: plugins.path.join(paths.cwd, `./${tsfolder}/`),
|
||||
functionToCall: async () => {
|
||||
await smartshellInstance.exec(`npm run build`);
|
||||
await this.typedserver.reload();
|
||||
},
|
||||
timeout: null,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
this.watcherMap.add(
|
||||
new Watcher({
|
||||
filePathToWatch: plugins.path.join(paths.cwd, './html/'),
|
||||
functionToCall: async () => {
|
||||
await htmlHandler.processHtml({
|
||||
from: plugins.path.join(paths.cwd, './html/index.html'),
|
||||
to: plugins.path.join(paths.cwd, './dist_watch/index.html'),
|
||||
minify: false,
|
||||
});
|
||||
await bundleAndReloadElement();
|
||||
},
|
||||
timeout: null,
|
||||
})
|
||||
);
|
||||
})();
|
||||
break;
|
||||
case 'gitzone_website':
|
||||
this.watcherMap.add(
|
||||
new Watcher({
|
||||
filePathToWatch: plugins.path.join(paths.cwd, './ts/'),
|
||||
commandToExecute: 'npm run startTs',
|
||||
timeout: null,
|
||||
})
|
||||
);
|
||||
const bundleAndReloadWebsite = async () => {
|
||||
await tsbundle.build(paths.cwd, './ts_web/index.ts', './dist_serve/bundle.js', {
|
||||
bundler: 'esbuild',
|
||||
case 'website':
|
||||
(async () => {
|
||||
const bundleAndReloadWebsite = async () => {
|
||||
await tsbundle.build(paths.cwd, './ts_web/index.ts', './dist_serve/bundle.js', {
|
||||
bundler: 'esbuild',
|
||||
});
|
||||
};
|
||||
let tsfolders = await plugins.smartfile.fs.listFolders(paths.cwd);
|
||||
tsfolders = tsfolders.filter(
|
||||
(itemArg) => itemArg.startsWith('ts') && itemArg !== 'ts_web'
|
||||
);
|
||||
const smartshellInstance = new plugins.smartshell.Smartshell({
|
||||
executor: 'bash',
|
||||
});
|
||||
};
|
||||
this.watcherMap.add(
|
||||
new Watcher({
|
||||
filePathToWatch: plugins.path.join(paths.cwd, './ts_web/'),
|
||||
functionToCall: async () => {
|
||||
await bundleAndReloadWebsite();
|
||||
},
|
||||
timeout: null,
|
||||
})
|
||||
);
|
||||
this.watcherMap.add(
|
||||
new Watcher({
|
||||
filePathToWatch: plugins.path.join(paths.cwd, './html/'),
|
||||
functionToCall: async () => {
|
||||
await htmlHandler.processHtml({
|
||||
from: plugins.path.join(paths.cwd, './html/index.html'),
|
||||
to: plugins.path.join(paths.cwd, './dist_serve/index.html'),
|
||||
minify: false,
|
||||
});
|
||||
await bundleAndReloadWebsite();
|
||||
},
|
||||
timeout: null,
|
||||
})
|
||||
);
|
||||
for (const tsfolder of tsfolders) {
|
||||
this.watcherMap.add(
|
||||
new Watcher({
|
||||
filePathToWatch: plugins.path.join(paths.cwd, `./${tsfolder}/`),
|
||||
commandToExecute: `npm run startTs`,
|
||||
timeout: null,
|
||||
})
|
||||
);
|
||||
}
|
||||
this.watcherMap.add(
|
||||
new Watcher({
|
||||
filePathToWatch: plugins.path.join(paths.cwd, './ts_web/'),
|
||||
functionToCall: async () => {
|
||||
await bundleAndReloadWebsite();
|
||||
},
|
||||
timeout: null,
|
||||
})
|
||||
);
|
||||
this.watcherMap.add(
|
||||
new Watcher({
|
||||
filePathToWatch: plugins.path.join(paths.cwd, './html/'),
|
||||
functionToCall: async () => {
|
||||
await htmlHandler.processHtml({
|
||||
from: plugins.path.join(paths.cwd, './html/index.html'),
|
||||
to: plugins.path.join(paths.cwd, './dist_serve/index.html'),
|
||||
minify: false,
|
||||
});
|
||||
await bundleAndReloadWebsite();
|
||||
},
|
||||
timeout: null,
|
||||
})
|
||||
);
|
||||
})();
|
||||
break;
|
||||
case 'gitzone_service':
|
||||
case 'service':
|
||||
this.watcherMap.add(
|
||||
new Watcher({
|
||||
filePathToWatch: plugins.path.join(paths.cwd, './ts/'),
|
||||
@ -128,7 +169,7 @@ export class TsWatch {
|
||||
})
|
||||
);
|
||||
break;
|
||||
case 'echoSomething':
|
||||
case 'echo':
|
||||
const tsWatchInstanceEchoSomething = new Watcher({
|
||||
filePathToWatch: plugins.path.join(paths.cwd, './ts'),
|
||||
commandToExecute: 'npm -v',
|
||||
|
@ -13,19 +13,19 @@ tswatchCli.standardCommand().subscribe((argvArg => {
|
||||
|
||||
tswatchCli.addCommand('element').subscribe(async (argvArg) => {
|
||||
logger.log('info', `running watch task for a gitzone element project`);
|
||||
const tsWatch = new TsWatch('gitzone_element');
|
||||
const tsWatch = new TsWatch('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');
|
||||
const tsWatch = new TsWatch('node');
|
||||
await tsWatch.start();
|
||||
});
|
||||
|
||||
tswatchCli.addCommand('service').subscribe(async (argvArg) => {
|
||||
logger.log('info', `running test task`);
|
||||
const tsWatch = new TsWatch('gitzone_service');
|
||||
const tsWatch = new TsWatch('service');
|
||||
await tsWatch.start();
|
||||
});
|
||||
|
||||
@ -37,7 +37,7 @@ tswatchCli.addCommand('test').subscribe(async (argvArg) => {
|
||||
|
||||
tswatchCli.addCommand('website').subscribe(async (argvArg) => {
|
||||
logger.log('info', `running watch task for a gitzone website project`);
|
||||
const tsWatch = new TsWatch('gitzone_website');
|
||||
const tsWatch = new TsWatch('website');
|
||||
await tsWatch.start();
|
||||
});
|
||||
|
||||
|
@ -20,6 +20,7 @@ import * as lik from '@push.rocks/lik';
|
||||
import * as smartchok from '@push.rocks/smartchok';
|
||||
import * as smartcli from '@push.rocks/smartcli';
|
||||
import * as smartdelay from '@push.rocks/smartdelay';
|
||||
import * as smartfile from '@push.rocks/smartfile';
|
||||
import * as smartlog from '@push.rocks/smartlog';
|
||||
import * as smartlogDestinationLocal from '@push.rocks/smartlog-destination-local';
|
||||
import * as smartshell from '@push.rocks/smartshell';
|
||||
@ -30,6 +31,7 @@ export {
|
||||
smartchok,
|
||||
smartcli,
|
||||
smartdelay,
|
||||
smartfile,
|
||||
smartlog,
|
||||
smartlogDestinationLocal,
|
||||
smartshell,
|
||||
|
Loading…
Reference in New Issue
Block a user