Compare commits
203 Commits
Author | SHA1 | Date | |
---|---|---|---|
de4d7d3a2d | |||
f1f3465917 | |||
a6441a3e3e | |||
7611268fb9 | |||
95c57d489d | |||
8ab28f582b | |||
8ad3a21ed8 | |||
e94af8a1d4 | |||
71269a1820 | |||
f76a58a3a4 | |||
d79c4d2eaa | |||
5ea12b77e7 | |||
0fbb18690a | |||
adbc255bcd | |||
16676d52da | |||
89251ad3e7 | |||
7e2a4725a5 | |||
f2c5cecbd3 | |||
8139cb93b2 | |||
f107a157af | |||
e0c2f8671d | |||
c644337bf0 | |||
405cad9002 | |||
a2af8cef07 | |||
b1532fe23f | |||
91cf04385d | |||
1d5a37d0c0 | |||
9b383006c2 | |||
7c918287f7 | |||
4a1443d2f4 | |||
1d76d50bc3 | |||
4415d889b4 | |||
404bdc9aac | |||
f09289717a | |||
ed3d76cf86 | |||
83e904bb3c | |||
93b27f8e6a | |||
c0bbe6ef68 | |||
b11104bd74 | |||
f96024380a | |||
cd5d50369e | |||
d03ead86fd | |||
66b1dc0a3f | |||
5b8d6ee471 | |||
eb993c20f2 | |||
6dc8009a32 | |||
b0aeb19b5d | |||
c0f85dd931 | |||
4b08d321bc | |||
a53b9f9aa6 | |||
64a31e9812 | |||
776f993f6f | |||
7481784a64 | |||
aa6649483a | |||
65f778c40f | |||
4204a61db9 | |||
181369ad3f | |||
d5816b0ed8 | |||
889643e233 | |||
1d3a2dcb64 | |||
9688e3323d | |||
6fa56e9be6 | |||
15e9df5f4f | |||
e0f8503b2b | |||
1337a6ec25 | |||
bd36e3edf3 | |||
89fae2edc9 | |||
82b09ad253 | |||
57ce71cda3 | |||
b171a14c0a | |||
63e0d7fe9e | |||
e2bc505c41 | |||
af82480644 | |||
27a08f11b7 | |||
073f978626 | |||
8d7ab769e1 | |||
8ebc438e2d | |||
d0d158ee87 | |||
3ada286495 | |||
0514a74a07 | |||
587d08239a | |||
7ee934eb46 | |||
ebcd8d4b51 | |||
27477253ee | |||
9ed461e1e4 | |||
b854a161f3 | |||
0598357010 | |||
9dae6dcda1 | |||
4cf71d2edc | |||
0eec0c04e8 | |||
ef5d4d2a9c | |||
f05481a267 | |||
d66a88538a | |||
1c1a110ca3 | |||
3f7790e8c8 | |||
2018b27a4b | |||
3b8ac18a6c | |||
e36af800a3 | |||
76b810663f | |||
9950661a36 | |||
6fa461aff5 | |||
4ca73a77f9 | |||
2d4d243454 | |||
f77f36312f | |||
c508c85473 | |||
50a0cadd11 | |||
d5cb794ea6 | |||
3bb65bedf6 | |||
53147a8812 | |||
c63a5f88d5 | |||
f039ace7bc | |||
bbc34ad98b | |||
c699954d08 | |||
1c84726ed8 | |||
c589e20222 | |||
f170cb8909 | |||
ca1d058789 | |||
4423631fa9 | |||
5e62fa2124 | |||
8ef3b47e76 | |||
ed91da6e3f | |||
7b777ea1a9 | |||
faec3d38bc | |||
a2ff76dc78 | |||
7e973c906a | |||
6c109cb381 | |||
2266813faf | |||
bf7a2c9146 | |||
1a4ada879d | |||
0046985b82 | |||
d876b09337 | |||
f48ba50236 | |||
f04833d5b5 | |||
073685e683 | |||
b91b3e0a0c | |||
12d31533f5 | |||
f9b8a356e4 | |||
408b6f8fc5 | |||
80dd3ee970 | |||
717e1d29ed | |||
a8254e6962 | |||
35ee69981d | |||
bd66e9a897 | |||
fc356e62f4 | |||
a34d98b840 | |||
9525f28507 | |||
787aae63d7 | |||
bf2a32a5d5 | |||
7ced66fc28 | |||
d01905ae99 | |||
59c744cc5e | |||
4d23145529 | |||
27e0d7588d | |||
88d4bf6be0 | |||
d4f8215f35 | |||
85f72feeb9 | |||
bd4ccbd215 | |||
79940cec3f | |||
e20508ffbc | |||
21b962b9a8 | |||
f673e8577b | |||
e4278ed270 | |||
8ae0f960ac | |||
c9a3b996cb | |||
d81d19008a | |||
e4ef6bad8f | |||
2873314742 | |||
e26fa92744 | |||
995f296319 | |||
e7866dadb7 | |||
9302e78f86 | |||
0a302bee95 | |||
deb5e1daf9 | |||
5fe27ee706 | |||
b73807baf0 | |||
1e71fc24d5 | |||
e8071e76a1 | |||
b11d03dd41 | |||
72297d2f58 | |||
71b900ac47 | |||
f6d06edced | |||
3e98005843 | |||
7c4673a5b6 | |||
99ec82ab55 | |||
1f0c1964dd | |||
828229872d | |||
0ff482bd01 | |||
39c8da4f74 | |||
fcd2029744 | |||
d89e0a13d5 | |||
64c7815bca | |||
f3e69eb15e | |||
386e4c07c6 | |||
82557c96d6 | |||
c94d89fa8a | |||
639a5eebea | |||
fb88d3384e | |||
e38342604b | |||
390200ad2a | |||
1960b1d125 | |||
7ce6245286 | |||
3a8513d3a0 | |||
d425e290dd |
16
.gitignore
vendored
16
.gitignore
vendored
@@ -1,6 +1,20 @@
|
||||
.nogit/
|
||||
node_modules/
|
||||
|
||||
# artifacts
|
||||
coverage/
|
||||
public/
|
||||
pages/
|
||||
|
||||
# installs
|
||||
node_modules/
|
||||
|
||||
# caches
|
||||
.yarn/
|
||||
.cache/
|
||||
.rpt2_cache
|
||||
|
||||
# builds
|
||||
dist/
|
||||
dist_*/
|
||||
|
||||
# custom
|
147
.gitlab-ci.yml
147
.gitlab-ci.yml
@@ -1,147 +0,0 @@
|
||||
# gitzone standard
|
||||
image: hosttoday/ht-docker-node:npmci
|
||||
|
||||
cache:
|
||||
paths:
|
||||
- .npmci_cache/
|
||||
key: "$CI_BUILD_STAGE"
|
||||
|
||||
stages:
|
||||
- security
|
||||
- test
|
||||
- release
|
||||
- metadata
|
||||
|
||||
# ====================
|
||||
# security stage
|
||||
# ====================
|
||||
mirror:
|
||||
stage: security
|
||||
script:
|
||||
- npmci git mirror
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
snyk:
|
||||
stage: security
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci command npm install -g snyk
|
||||
- npmci command npm install --ignore-scripts
|
||||
- npmci command snyk test
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
# ====================
|
||||
# test stage
|
||||
# ====================
|
||||
testLEGACY:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install legacy
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
allow_failure: true
|
||||
|
||||
testLTS:
|
||||
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
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
release:
|
||||
stage: release
|
||||
script:
|
||||
- npmci node install stable
|
||||
- npmci npm publish
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
# ====================
|
||||
# metadata stage
|
||||
# ====================
|
||||
codequality:
|
||||
stage: metadata
|
||||
image: docker:stable
|
||||
allow_failure: true
|
||||
services:
|
||||
- docker:stable-dind
|
||||
script:
|
||||
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
|
||||
- docker run
|
||||
--env SOURCE_CODE="$PWD"
|
||||
--volume "$PWD":/code
|
||||
--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:
|
||||
- docker
|
||||
- priv
|
||||
|
||||
trigger:
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci trigger
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
pages:
|
||||
image: hosttoday/ht-docker-node:npmci
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci command npm install -g typedoc typescript
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
only:
|
||||
- tags
|
||||
artifacts:
|
||||
expire_in: 1 week
|
||||
paths:
|
||||
- public
|
||||
allow_failure: true
|
||||
|
||||
windowsCompatibility:
|
||||
image: stefanscherer/node-windows:10-build-tools
|
||||
stage: metadata
|
||||
script:
|
||||
- npm install & npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- windows
|
||||
allow_failure: true
|
29
.vscode/launch.json
vendored
Normal file
29
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "current file",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"args": [
|
||||
"${relativeFile}"
|
||||
],
|
||||
"runtimeArgs": ["-r", "@git.zone/tsrun"],
|
||||
"cwd": "${workspaceRoot}",
|
||||
"protocol": "inspector",
|
||||
"internalConsoleOptions": "openOnSessionStart"
|
||||
},
|
||||
{
|
||||
"name": "test.ts",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"args": [
|
||||
"test/test.ts"
|
||||
],
|
||||
"runtimeArgs": ["-r", "@git.zone/tsrun"],
|
||||
"cwd": "${workspaceRoot}",
|
||||
"protocol": "inspector",
|
||||
"internalConsoleOptions": "openOnSessionStart"
|
||||
}
|
||||
]
|
||||
}
|
26
.vscode/settings.json
vendored
Normal file
26
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"json.schemas": [
|
||||
{
|
||||
"fileMatch": ["/npmextra.json"],
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"npmci": {
|
||||
"type": "object",
|
||||
"description": "settings for npmci"
|
||||
},
|
||||
"gitzone": {
|
||||
"type": "object",
|
||||
"description": "settings for gitzone",
|
||||
"properties": {
|
||||
"projectType": {
|
||||
"type": "string",
|
||||
"enum": ["website", "element", "service", "npm", "wcc"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
92
changelog.md
Normal file
92
changelog.md
Normal file
@@ -0,0 +1,92 @@
|
||||
# Changelog
|
||||
|
||||
## 2024-12-04 - 2.0.27 - fix(core)
|
||||
Refactor watch mode commands and exports
|
||||
|
||||
- Updated watch mode names in CLI and type definitions for consistency.
|
||||
- Added export for smartfile plugin.
|
||||
- Ensured updated command logic is applied during CLI operations.
|
||||
|
||||
## 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
|
||||
|
||||
- Removed unnecessary comment line from TypeScript declaration files.
|
||||
|
||||
## 2024-10-27 - 2.0.24 - fix(core)
|
||||
Remove .gitlab-ci.yml and update dependencies in package.json
|
||||
|
||||
- Deleted .gitlab-ci.yml which contained CI/CD configuration settings.
|
||||
- Updated various dependencies and devDependencies in package.json to newer versions.
|
||||
|
||||
## 2024-01-28 to 2024-01-09 - 2.0.14 to 2.0.23 - Core
|
||||
Several updates to the core functionality.
|
||||
|
||||
- Updated core functionality for efficiency and stability.
|
||||
|
||||
## 2023-09-21 to 2023-01-28 - 2.0.8 to 2.0.13 - Core
|
||||
Core system updates and fixes.
|
||||
|
||||
- Continuous updates to core functionality for improved performance.
|
||||
|
||||
## 2023-03-31 to 2022-08-04 - 2.0.0 to 2.0.7 - Core
|
||||
Enhanced core operations.
|
||||
|
||||
- Regular core updates to address performance and reliability.
|
||||
|
||||
## 2022-05-04 - 1.0.81 - Core
|
||||
Introduction of a breaking change in the core system.
|
||||
|
||||
- Switched to gitzone v2 generation tools.
|
||||
|
||||
## 2022-04-21 to 2022-03-18 - 1.0.62 to 1.0.80 - Core
|
||||
Routine updates to core operations.
|
||||
|
||||
- Various core fixes enhancing stability and function.
|
||||
|
||||
## 2022-03-14 to 2022-03-18 - 1.0.61 to 1.0.75 - Core
|
||||
Further adjustments to core functionality.
|
||||
|
||||
- Fixes across multiple modules in core.
|
||||
|
||||
## 2021-08-17 to 2020-07-07 - 1.0.46 to 1.0.60 - Core
|
||||
Core component updates.
|
||||
|
||||
- Consistent core updates to refine performance.
|
||||
|
||||
## 2020-07-04 to 2020-05-22 - 1.0.39 to 1.0.45 - Core
|
||||
Incremental updates to core systems.
|
||||
|
||||
- Enhanced features within the core for better integration.
|
||||
|
||||
## 2020-03-13 to 2020-03-05 - 1.0.30 to 1.0.38 - Core
|
||||
Stabilizing and refining core functions.
|
||||
|
||||
- Series of core fixes improving overall system durability.
|
||||
|
||||
## 2019-10-14 to 2019-10-12 - 1.0.21 to 1.0.29 - Core
|
||||
Tweaks and enhancements to the core mechanics.
|
||||
|
||||
- Continued improvements in core system support services.
|
||||
|
||||
## 2019-05-28 to 2019-05-06 - 1.0.10 to 1.0.20 - Core
|
||||
Core module enhancements and fixes.
|
||||
|
||||
- Several iterations to the core functionality for increased resilience.
|
||||
|
||||
## 2019-05-06 to 2019-05-08 - 1.0.5 to 1.0.9 - Core
|
||||
Regular updates ensuring core integrity.
|
||||
|
||||
- Stability improvements within the core services.
|
||||
|
||||
## 2018-10-28 - 1.0.1 to 1.0.3 - Core
|
||||
Initial setup and fixes to the core.
|
||||
|
||||
- Foundational updates to core functionality.
|
4
cli.child.ts
Normal file
4
cli.child.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env node
|
||||
process.env.CLI_CALL = 'true';
|
||||
import * as cliTool from './ts/index.js';
|
||||
cliTool.runCli();
|
3
cli.js
3
cli.js
@@ -1,3 +1,4 @@
|
||||
#!/usr/bin/env node
|
||||
process.env.CLI_CALL = 'true';
|
||||
require('./dist/index');
|
||||
const cliTool = await import('./dist_ts/index.js');
|
||||
cliTool.runCli();
|
||||
|
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env node
|
||||
process.env.CLI_CALL = 'true';
|
||||
require('@gitzone/tsrun');
|
||||
require('./ts/index');
|
||||
|
||||
import * as tsrun from '@git.zone/tsrun';
|
||||
tsrun.runPath('./cli.child.js', import.meta.url);
|
||||
|
2
dist_ts/index.d.ts
vendored
Normal file
2
dist_ts/index.d.ts
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from './tswatch.classes.tswatch.js';
|
||||
export * from './tswatch.cli.js';
|
6
dist_ts/index.js
Normal file
6
dist_ts/index.js
Normal file
@@ -0,0 +1,6 @@
|
||||
import * as early from '@push.rocks/early';
|
||||
early.start('tswatch');
|
||||
export * from './tswatch.classes.tswatch.js';
|
||||
export * from './tswatch.cli.js';
|
||||
early.stop();
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssS0FBSyxNQUFNLG1CQUFtQixDQUFDO0FBQzNDLEtBQUssQ0FBQyxLQUFLLENBQUMsU0FBUyxDQUFDLENBQUM7QUFDdkIsY0FBYyw4QkFBOEIsQ0FBQztBQUM3QyxjQUFjLGtCQUFrQixDQUFDO0FBQ2pDLEtBQUssQ0FBQyxJQUFJLEVBQUUsQ0FBQyJ9
|
1
dist_ts/interfaces/index.d.ts
vendored
Normal file
1
dist_ts/interfaces/index.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from './interfaces.watchmodes.js';
|
2
dist_ts/interfaces/index.js
Normal file
2
dist_ts/interfaces/index.js
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from './interfaces.watchmodes.js';
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi90cy9pbnRlcmZhY2VzL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGNBQWMsNEJBQTRCLENBQUMifQ==
|
1
dist_ts/interfaces/interfaces.watchmodes.d.ts
vendored
Normal file
1
dist_ts/interfaces/interfaces.watchmodes.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export type TWatchModes = 'test' | 'node' | 'service' | 'element' | 'website' | 'echo';
|
2
dist_ts/interfaces/interfaces.watchmodes.js
Normal file
2
dist_ts/interfaces/interfaces.watchmodes.js
Normal file
@@ -0,0 +1,2 @@
|
||||
export {};
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW50ZXJmYWNlcy53YXRjaG1vZGVzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vdHMvaW50ZXJmYWNlcy9pbnRlcmZhY2VzLndhdGNobW9kZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9
|
3
dist_ts/tswatch.classes.parcel.d.ts
vendored
Normal file
3
dist_ts/tswatch.classes.parcel.d.ts
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export declare class Parcel {
|
||||
start(): Promise<void>;
|
||||
}
|
44
dist_ts/tswatch.classes.parcel.js
Normal file
44
dist_ts/tswatch.classes.parcel.js
Normal file
@@ -0,0 +1,44 @@
|
||||
"use strict";
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||
result["default"] = mod;
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const plugins = __importStar(require("./tswatch.plugins"));
|
||||
const paths = __importStar(require("./tswatch.paths"));
|
||||
class Parcel {
|
||||
async start() {
|
||||
const entryFiles = plugins.path.join(paths.cwd, './html/index.html');
|
||||
// Bundler options
|
||||
const options = {
|
||||
outDir: './dist_watch',
|
||||
outFile: 'index.html',
|
||||
publicUrl: '/',
|
||||
watch: true,
|
||||
cache: true,
|
||||
cacheDir: '.nogit/.parcelcache',
|
||||
contentHash: false,
|
||||
global: 'moduleName',
|
||||
minify: false,
|
||||
scopeHoist: false,
|
||||
target: 'browser',
|
||||
bundleNodeModules: true,
|
||||
https: null,
|
||||
logLevel: 3,
|
||||
hmr: true,
|
||||
hmrPort: 3003,
|
||||
sourceMaps: true,
|
||||
hmrHostname: '',
|
||||
detailedReport: false // Prints a detailed report of the bundles, assets, filesizes and times, defaults to false, reports are only printed if watch is disabled
|
||||
};
|
||||
const bundler = new plugins.parcel(entryFiles, options);
|
||||
// Run the bundler, this returns the main bundle
|
||||
// Use the events if you're using watch mode as this promise will only trigger once and not for every rebuild
|
||||
const bundle = await bundler.serve(3002);
|
||||
}
|
||||
}
|
||||
exports.Parcel = Parcel;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHN3YXRjaC5jbGFzc2VzLnBhcmNlbC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3Rzd2F0Y2guY2xhc3Nlcy5wYXJjZWwudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7O0FBQUEsMkRBQTZDO0FBQzdDLHVEQUF5QztBQUV6QyxNQUFhLE1BQU07SUFDVixLQUFLLENBQUMsS0FBSztRQUNoQixNQUFNLFVBQVUsR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxLQUFLLENBQUMsR0FBRyxFQUFFLG1CQUFtQixDQUFDLENBQUM7UUFFckUsa0JBQWtCO1FBQ2xCLE1BQU0sT0FBTyxHQUFpQztZQUM1QyxNQUFNLEVBQUUsY0FBYztZQUN0QixPQUFPLEVBQUUsWUFBWTtZQUNyQixTQUFTLEVBQUUsR0FBRztZQUNkLEtBQUssRUFBRSxJQUFJO1lBQ1gsS0FBSyxFQUFFLElBQUk7WUFDWCxRQUFRLEVBQUUscUJBQXFCO1lBQy9CLFdBQVcsRUFBRSxLQUFLO1lBQ2xCLE1BQU0sRUFBRSxZQUFZO1lBQ3BCLE1BQU0sRUFBRSxLQUFLO1lBQ2IsVUFBVSxFQUFFLEtBQUs7WUFDakIsTUFBTSxFQUFFLFNBQVM7WUFDakIsaUJBQWlCLEVBQUUsSUFBSTtZQUN2QixLQUFLLEVBQUUsSUFBSTtZQUNYLFFBQVEsRUFBRSxDQUFDO1lBQ1gsR0FBRyxFQUFFLElBQUk7WUFDVCxPQUFPLEVBQUUsSUFBSTtZQUNiLFVBQVUsRUFBRSxJQUFJO1lBQ2hCLFdBQVcsRUFBRSxFQUFFO1lBQ2YsY0FBYyxFQUFFLEtBQUssQ0FBQyx5SUFBeUk7U0FDaEssQ0FBQztRQUVGLE1BQU0sT0FBTyxHQUFHLElBQUksT0FBTyxDQUFDLE1BQU0sQ0FBQyxVQUFVLEVBQUUsT0FBTyxDQUFDLENBQUM7UUFFeEQsZ0RBQWdEO1FBQ2hELDZHQUE2RztRQUM3RyxNQUFNLE1BQU0sR0FBRyxNQUFNLE9BQU8sQ0FBQyxLQUFLLENBQUMsSUFBSSxDQUFDLENBQUM7SUFDM0MsQ0FBQztDQUNGO0FBakNELHdCQWlDQyJ9
|
17
dist_ts/tswatch.classes.tswatch.d.ts
vendored
Normal file
17
dist_ts/tswatch.classes.tswatch.d.ts
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
import * as plugins from './tswatch.plugins.js';
|
||||
import * as interfaces from './interfaces/index.js';
|
||||
import { Watcher } from './tswatch.classes.watcher.js';
|
||||
export declare class TsWatch {
|
||||
watchmode: interfaces.TWatchModes;
|
||||
watcherMap: plugins.lik.ObjectMap<Watcher>;
|
||||
typedserver: plugins.typedserver.TypedServer;
|
||||
constructor(watchmodeArg: interfaces.TWatchModes);
|
||||
/**
|
||||
* starts the TsWatch instance
|
||||
*/
|
||||
start(): Promise<void>;
|
||||
/**
|
||||
* stops the execution of any active Watchers
|
||||
*/
|
||||
stop(): Promise<void>;
|
||||
}
|
169
dist_ts/tswatch.classes.tswatch.js
Normal file
169
dist_ts/tswatch.classes.tswatch.js
Normal file
File diff suppressed because one or more lines are too long
35
dist_ts/tswatch.classes.watcher.d.ts
vendored
Normal file
35
dist_ts/tswatch.classes.watcher.d.ts
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
export interface IWatcherConstructorOptions {
|
||||
filePathToWatch: string;
|
||||
commandToExecute?: string;
|
||||
functionToCall?: () => Promise<any>;
|
||||
timeout?: number;
|
||||
}
|
||||
/**
|
||||
* A watcher keeps track of one child execution
|
||||
*/
|
||||
export declare class Watcher {
|
||||
/**
|
||||
* used to execute shell commands
|
||||
*/
|
||||
private smartshellInstance;
|
||||
private currentExecution;
|
||||
private smartchokWatcher;
|
||||
private options;
|
||||
constructor(optionsArg: IWatcherConstructorOptions);
|
||||
/**
|
||||
* start the file
|
||||
*/
|
||||
start(): Promise<void>;
|
||||
/**
|
||||
* updates the current execution
|
||||
*/
|
||||
private updateCurrentExecution;
|
||||
/**
|
||||
* this method sets up a clean exit strategy
|
||||
*/
|
||||
private setupCleanup;
|
||||
/**
|
||||
* stops the watcher
|
||||
*/
|
||||
stop(): Promise<void>;
|
||||
}
|
90
dist_ts/tswatch.classes.watcher.js
Normal file
90
dist_ts/tswatch.classes.watcher.js
Normal file
@@ -0,0 +1,90 @@
|
||||
import * as plugins from './tswatch.plugins.js';
|
||||
import { logger } from './tswatch.logging.js';
|
||||
/**
|
||||
* A watcher keeps track of one child execution
|
||||
*/
|
||||
export class Watcher {
|
||||
constructor(optionsArg) {
|
||||
/**
|
||||
* used to execute shell commands
|
||||
*/
|
||||
this.smartshellInstance = new plugins.smartshell.Smartshell({
|
||||
executor: 'bash',
|
||||
});
|
||||
this.smartchokWatcher = new plugins.smartchok.Smartchok([]);
|
||||
this.options = optionsArg;
|
||||
}
|
||||
/**
|
||||
* start the file
|
||||
*/
|
||||
async start() {
|
||||
await this.setupCleanup();
|
||||
console.log(`Looking at ${this.options.filePathToWatch} for changes`);
|
||||
this.smartchokWatcher.add([this.options.filePathToWatch]); // __dirname refers to the directory of this very file
|
||||
await this.smartchokWatcher.start();
|
||||
const changeObservable = await this.smartchokWatcher.getObservableFor('change');
|
||||
changeObservable.subscribe(() => {
|
||||
this.updateCurrentExecution();
|
||||
});
|
||||
await this.updateCurrentExecution();
|
||||
}
|
||||
/**
|
||||
* updates the current execution
|
||||
*/
|
||||
async updateCurrentExecution() {
|
||||
if (this.options.commandToExecute) {
|
||||
if (this.currentExecution) {
|
||||
logger.log('ok', `reexecuting ${this.options.commandToExecute}`);
|
||||
this.currentExecution.kill();
|
||||
}
|
||||
else {
|
||||
logger.log('ok', `executing ${this.options.commandToExecute} for the first time`);
|
||||
}
|
||||
this.currentExecution = await this.smartshellInstance.execStreaming(this.options.commandToExecute);
|
||||
}
|
||||
else {
|
||||
console.log('no executionCommand set');
|
||||
}
|
||||
if (this.options.functionToCall) {
|
||||
this.options.functionToCall();
|
||||
}
|
||||
else {
|
||||
console.log('no functionToCall set.');
|
||||
}
|
||||
}
|
||||
/**
|
||||
* this method sets up a clean exit strategy
|
||||
*/
|
||||
async setupCleanup() {
|
||||
process.on('exit', () => {
|
||||
console.log('');
|
||||
console.log('now exiting!');
|
||||
this.stop();
|
||||
process.exit(0);
|
||||
});
|
||||
process.on('SIGINT', () => {
|
||||
console.log('');
|
||||
console.log('ok! got SIGINT We are exiting! Just cleaning up to exit neatly :)');
|
||||
this.stop();
|
||||
process.exit(0);
|
||||
});
|
||||
// handle timeout
|
||||
if (this.options.timeout) {
|
||||
plugins.smartdelay.delayFor(this.options.timeout).then(() => {
|
||||
console.log(`timed out afer ${this.options.timeout} milliseconds! exiting!`);
|
||||
this.stop();
|
||||
process.exit(0);
|
||||
});
|
||||
}
|
||||
}
|
||||
/**
|
||||
* stops the watcher
|
||||
*/
|
||||
async stop() {
|
||||
await this.smartchokWatcher.stop();
|
||||
if (this.currentExecution && !this.currentExecution.childProcess.killed) {
|
||||
this.currentExecution.kill();
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHN3YXRjaC5jbGFzc2VzLndhdGNoZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy90c3dhdGNoLmNsYXNzZXMud2F0Y2hlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssT0FBTyxNQUFNLHNCQUFzQixDQUFDO0FBQ2hELE9BQU8sRUFBRSxNQUFNLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQVM5Qzs7R0FFRztBQUNILE1BQU0sT0FBTyxPQUFPO0lBWWxCLFlBQVksVUFBc0M7UUFYbEQ7O1dBRUc7UUFDSyx1QkFBa0IsR0FBRyxJQUFJLE9BQU8sQ0FBQyxVQUFVLENBQUMsVUFBVSxDQUFDO1lBQzdELFFBQVEsRUFBRSxNQUFNO1NBQ2pCLENBQUMsQ0FBQztRQUdLLHFCQUFnQixHQUFHLElBQUksT0FBTyxDQUFDLFNBQVMsQ0FBQyxTQUFTLENBQUMsRUFBRSxDQUFDLENBQUM7UUFJN0QsSUFBSSxDQUFDLE9BQU8sR0FBRyxVQUFVLENBQUM7SUFDNUIsQ0FBQztJQUVEOztPQUVHO0lBQ0ksS0FBSyxDQUFDLEtBQUs7UUFDaEIsTUFBTSxJQUFJLENBQUMsWUFBWSxFQUFFLENBQUM7UUFDMUIsT0FBTyxDQUFDLEdBQUcsQ0FB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ENBQUMsQ0FBQyxDQUFDLENBQUM7UUFDbEIsQ0FBQyxDQUFDLENBQUM7UUFFSCxpQkFBaUI7UUFDakIsSUFBSSxJQUFJLENBQUMsT0FBTyxDQUFDLE9BQU8sRUFBRSxDQUFDO1lBQ3pCLE9BQU8sQ0FBQyxVQUFVLENBQUMsUUFBUSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUMsT0FBTyxDQUFDLENBQUMsSUFBSSxDQUFDLEdBQUcsRUFBRTtnQkFDMUQsT0FBTyxDQUFDLEdBQUcsQ0FBQyxrQkFBa0IsSUFBSSxDQUFDLE9BQU8sQ0FBQyxPQUFPLHlCQUF5QixDQUFDLENBQUM7Z0JBQzdFLElBQUksQ0FBQyxJQUFJLEVBQUUsQ0FBQztnQkFDWixPQUFPLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQyxDQUFDO1lBQ2xCLENBQUMsQ0FBQyxDQUFDO1FBQ0wsQ0FBQztJQUNILENBQUM7SUFFRDs7T0FFRztJQUNJLEtBQUssQ0FBQyxJQUFJO1FBQ2YsTUFBTSxJQUFJLENBQUMsZ0JBQWdCLENBQUMsSUFBSSxFQUFFLENBQUM7UUFDbkMsSUFBSSxJQUFJLENBQUMsZ0JBQWdCLElBQUksQ0FBQyxJQUFJLENBQUMsZ0JBQWdCLENBQUMsWUFBWSxDQUFDLE1BQU0sRUFBRSxDQUFDO1lBQ3hFLElBQUksQ0FBQyxnQkFBZ0IsQ0FBQyxJQUFJLEVBQUUsQ0FBQztRQUMvQixDQUFDO0lBQ0gsQ0FBQztDQUNGIn0=
|
1
dist_ts/tswatch.cli.d.ts
vendored
Normal file
1
dist_ts/tswatch.cli.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare const runCli: () => Promise<void>;
|
38
dist_ts/tswatch.cli.js
Normal file
38
dist_ts/tswatch.cli.js
Normal file
@@ -0,0 +1,38 @@
|
||||
import * as plugins from './tswatch.plugins.js';
|
||||
import * as paths from './tswatch.paths.js';
|
||||
import { logger } from './tswatch.logging.js';
|
||||
import { TsWatch } from './tswatch.classes.tswatch.js';
|
||||
const tswatchCli = new plugins.smartcli.Smartcli();
|
||||
// standard behaviour will assume gitzone setup
|
||||
tswatchCli.standardCommand().subscribe((argvArg => {
|
||||
tswatchCli.triggerCommand('npm', {});
|
||||
}));
|
||||
tswatchCli.addCommand('element').subscribe(async (argvArg) => {
|
||||
logger.log('info', `running watch task for a gitzone element project`);
|
||||
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('node');
|
||||
await tsWatch.start();
|
||||
});
|
||||
tswatchCli.addCommand('service').subscribe(async (argvArg) => {
|
||||
logger.log('info', `running test task`);
|
||||
const tsWatch = new TsWatch('service');
|
||||
await tsWatch.start();
|
||||
});
|
||||
tswatchCli.addCommand('test').subscribe(async (argvArg) => {
|
||||
logger.log('info', `running test task`);
|
||||
const tsWatch = new TsWatch('test');
|
||||
await tsWatch.start();
|
||||
});
|
||||
tswatchCli.addCommand('website').subscribe(async (argvArg) => {
|
||||
logger.log('info', `running watch task for a gitzone website project`);
|
||||
const tsWatch = new TsWatch('website');
|
||||
await tsWatch.start();
|
||||
});
|
||||
export const runCli = async () => {
|
||||
tswatchCli.startParse();
|
||||
};
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHN3YXRjaC5jbGkuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy90c3dhdGNoLmNsaS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssT0FBTyxNQUFNLHNCQUFzQixDQUFDO0FBQ2hELE9BQU8sS0FBSyxLQUFLLE1BQU0sb0JBQW9CLENBQUM7QUFDNUMsT0FBTyxFQUFFLE1BQU0sRUFBRSxNQUFNLHNC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ts
vendored
Normal file
2
dist_ts/tswatch.logging.d.ts
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import * as plugins from './tswatch.plugins.js';
|
||||
export declare const logger: plugins.smartlog.Smartlog;
|
14
dist_ts/tswatch.logging.js
Normal file
14
dist_ts/tswatch.logging.js
Normal file
@@ -0,0 +1,14 @@
|
||||
import * as plugins from './tswatch.plugins.js';
|
||||
export const logger = new plugins.smartlog.Smartlog({
|
||||
logContext: {
|
||||
company: 'Some Company',
|
||||
companyunit: 'Some CompanyUnit',
|
||||
containerName: 'Some Containername',
|
||||
environment: 'local',
|
||||
runtime: 'node',
|
||||
zone: 'gitzone',
|
||||
},
|
||||
minimumLogLevel: 'silly',
|
||||
});
|
||||
logger.addLogDestination(new plugins.smartlogDestinationLocal.DestinationLocal());
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHN3YXRjaC5sb2dnaW5nLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvdHN3YXRjaC5sb2dnaW5nLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxPQUFPLE1BQU0sc0JBQXNCLENBQUM7QUFFaEQsTUFBTSxDQUFDLE1BQU0sTUFBTSxHQUFHLElBQUksT0FBTyxDQUFDLFFBQVEsQ0FBQyxRQUFRLENBQUM7SUFDbEQsVUFBVSxFQUFFO1FBQ1YsT0FBTyxFQUFFLGNBQWM7UUFDdkIsV0FBVyxFQUFFLGtCQUFrQjtRQUMvQixhQUFhLEVBQUUsb0JBQW9CO1FBQ25DLFdBQVcsRUFBRSxPQUFPO1FBQ3BCLE9BQU8sRUFBRSxNQUFNO1FBQ2YsSUFBSSxFQUFFLFNBQVM7S0FDaEI7SUFDRCxlQUFlLEVBQUUsT0FBTztDQUN6QixDQUFDLENBQUM7QUFFSCxNQUFNLENBQUMsaUJBQWlCLENBQUMsSUFBSSxPQUFPLENBQUMsd0JBQXdCLENBQUMsZ0JBQWdCLEVBQUUsQ0FBQyxDQUFDIn0=
|
1
dist_ts/tswatch.paths.d.ts
vendored
Normal file
1
dist_ts/tswatch.paths.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare const cwd: string;
|
3
dist_ts/tswatch.paths.js
Normal file
3
dist_ts/tswatch.paths.js
Normal file
@@ -0,0 +1,3 @@
|
||||
import * as plugins from './tswatch.plugins.js';
|
||||
export const cwd = process.cwd();
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHN3YXRjaC5wYXRocy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3Rzd2F0Y2gucGF0aHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLE9BQU8sTUFBTSxzQkFBc0IsQ0FBQztBQUVoRCxNQUFNLENBQUMsTUFBTSxHQUFHLEdBQUcsT0FBTyxDQUFDLEdBQUcsRUFBRSxDQUFDIn0=
|
16
dist_ts/tswatch.plugins.d.ts
vendored
Normal file
16
dist_ts/tswatch.plugins.d.ts
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
import * as path from 'path';
|
||||
export { path };
|
||||
import * as tsbundle from '@git.zone/tsbundle';
|
||||
export { tsbundle };
|
||||
import * as typedserver from '@api.global/typedserver';
|
||||
export { typedserver, };
|
||||
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';
|
||||
import * as taskbuffer from '@push.rocks/taskbuffer';
|
||||
export { lik, smartchok, smartcli, smartdelay, smartfile, smartlog, smartlogDestinationLocal, smartshell, taskbuffer, };
|
21
dist_ts/tswatch.plugins.js
Normal file
21
dist_ts/tswatch.plugins.js
Normal file
@@ -0,0 +1,21 @@
|
||||
// node native scope
|
||||
import * as path from 'path';
|
||||
export { path };
|
||||
// @gitzone scope
|
||||
import * as tsbundle from '@git.zone/tsbundle';
|
||||
export { tsbundle };
|
||||
// @apiglobal scope
|
||||
import * as typedserver from '@api.global/typedserver';
|
||||
export { typedserver, };
|
||||
// @pushrocks scope
|
||||
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';
|
||||
import * as taskbuffer from '@push.rocks/taskbuffer';
|
||||
export { lik, smartchok, smartcli, smartdelay, smartfile, smartlog, smartlogDestinationLocal, smartshell, taskbuffer, };
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHN3YXRjaC5wbHVnaW5zLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvdHN3YXRjaC5wbHVnaW5zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLG9CQUFvQjtBQUNwQixPQUFPLEtBQUssSUFBSSxNQUFNLE1BQU0sQ0FBQztBQUM3QixPQUFPLEVBQUUsSUFBSSxFQUFFLENBQUM7QUFFaEIsaUJBQWlCO0FBQ2pCLE9BQU8sS0FBSyxRQUFRLE1BQU0sb0JBQW9CLENBQUM7QUFDL0MsT0FBTyxFQUNMLFFBQVEsRUFDVCxDQUFBO0FBRUQsbUJBQW1CO0FBQ25CLE9BQU8sS0FBSyxXQUFXLE1BQU0seUJBQXlCLENBQUM7QUFFdkQsT0FBTyxFQUNMLFdBQVcsR0FDWixDQUFBO0FBRUQsbUJBQW1CO0FBQ25CLE9BQU8sS0FBSyxHQUFHLE1BQU0saUJBQWlCLENBQUM7QUFDdkMsT0FBTyxLQUFLLFNBQVMsTUFBTSx1QkFBdUIsQ0FBQztBQUNuRCxPQUFPLEtBQUssUUFBUSxNQUFNLHNCQUFzQixDQUFDO0FBQ2pELE9BQU8sS0FBSyxVQUFVLE1BQU0sd0JBQXdCLENBQUM7QUFDckQsT0FBTyxLQUFLLFNBQVMsTUFBTSx1QkFBdUIsQ0FBQztBQUNuRCxPQUFPLEtBQUssUUFBUSxNQUFNLHNCQUFzQixDQUFDO0FBQ2pELE9BQU8sS0FBSyx3QkFBd0IsTUFBTSx3Q0FBd0MsQ0FBQztBQUNuRixPQUFPLEtBQUssVUFBVSxNQUFNLHdCQUF3QixDQUFDO0FBQ3JELE9BQU8sS0FBSyxVQUFVLE1BQU0sd0JBQXdCLENBQUM7QUFFckQsT0FBTyxFQUNMLEdBQUcsRUFDSCxTQUFTLEVBQ1QsUUFBUSxFQUNSLFVBQVUsRUFDVixTQUFTLEVBQ1QsUUFBUSxFQUNSLHdCQUF3QixFQUN4QixVQUFVLEVBQ1YsVUFBVSxHQUNYLENBQUMifQ==
|
@@ -2,5 +2,16 @@
|
||||
"npmci": {
|
||||
"npmGlobalTools": [],
|
||||
"npmAccessLevel": "public"
|
||||
},
|
||||
"gitzone": {
|
||||
"projectType": "npm",
|
||||
"module": {
|
||||
"githost": "gitlab.com",
|
||||
"gitscope": "gitzone",
|
||||
"gitrepo": "tswatch",
|
||||
"shortDescription": "watch typescript projects during development",
|
||||
"npmPackagename": "@git.zone/tswatch",
|
||||
"license": "MIT"
|
||||
}
|
||||
}
|
||||
}
|
1608
package-lock.json
generated
1608
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
62
package.json
62
package.json
@@ -1,30 +1,54 @@
|
||||
{
|
||||
"name": "@gitzone/tswatch",
|
||||
"version": "1.0.5",
|
||||
"name": "@git.zone/tswatch",
|
||||
"version": "2.0.27",
|
||||
"private": false,
|
||||
"description": "watch typescript projects during development",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"main": "dist_ts/index.js",
|
||||
"typings": "dist_ts/index.d.ts",
|
||||
"type": "module",
|
||||
"author": "Lossless GmbH",
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"tswatch": "cli.js"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node ./cli.ts.js test --timeout 10000",
|
||||
"test2": "(tstest test/)",
|
||||
"build": "(tsbuild)",
|
||||
"format": "(gitzone format)"
|
||||
"test": "(tstest test/ --web)",
|
||||
"build": "(tsbuild --web --allowimplicitany)"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.11",
|
||||
"@gitzone/tstest": "^1.0.20",
|
||||
"@pushrocks/tapbundle": "^3.0.9",
|
||||
"@types/node": "^12.0.0",
|
||||
"tslint": "^5.16.0",
|
||||
"tslint-config-prettier": "^1.18.0"
|
||||
"@git.zone/tsbuild": "^2.2.0",
|
||||
"@git.zone/tstest": "^1.0.90",
|
||||
"@push.rocks/tapbundle": "^5.5.3",
|
||||
"@types/node": "^22.10.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@gitzone/tsrun": "^1.2.6",
|
||||
"@pushrocks/smartcli": "^3.0.7",
|
||||
"@pushrocks/smartdelay": "^2.0.3",
|
||||
"@pushrocks/smartshell": "^2.0.13"
|
||||
}
|
||||
"@api.global/typedserver": "^3.0.51",
|
||||
"@git.zone/tsbundle": "^2.1.0",
|
||||
"@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",
|
||||
"@push.rocks/taskbuffer": "^3.1.7"
|
||||
},
|
||||
"files": [
|
||||
"ts/**/*",
|
||||
"ts_web/**/*",
|
||||
"dist/**/*",
|
||||
"dist_*/**/*",
|
||||
"dist_ts/**/*",
|
||||
"dist_ts_web/**/*",
|
||||
"assets/**/*",
|
||||
"cli.js",
|
||||
"npmextra.json",
|
||||
"readme.md"
|
||||
],
|
||||
"browserslist": [
|
||||
"last 1 chrome versions"
|
||||
]
|
||||
}
|
||||
|
9561
pnpm-lock.yaml
generated
Normal file
9561
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
0
readme.hints.md
Normal file
0
readme.hints.md
Normal file
39
readme.md
Normal file
39
readme.md
Normal file
@@ -0,0 +1,39 @@
|
||||
# @git.zone/tswatch
|
||||
watch typescript projects during development
|
||||
|
||||
## Availabililty and Links
|
||||
* [npmjs.org (npm package)](https://www.npmjs.com/package/@git.zone/tswatch)
|
||||
* [gitlab.com (source)](https://gitlab.com/gitzone/tswatch)
|
||||
* [github.com (source mirror)](https://github.com/gitzone/tswatch)
|
||||
* [docs (typedoc)](https://gitzone.gitlab.io/tswatch/)
|
||||
|
||||
## Status for master
|
||||
|
||||
Status Category | Status Badge
|
||||
-- | --
|
||||
GitLab Pipelines | [](https://lossless.cloud)
|
||||
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
||||
npm | [](https://lossless.cloud)
|
||||
Snyk | [](https://lossless.cloud)
|
||||
TypeScript Support | [](https://lossless.cloud)
|
||||
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
Code Style | [](https://lossless.cloud)
|
||||
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
||||
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
||||
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
||||
Platform support | [](https://lossless.cloud) [](https://lossless.cloud)
|
||||
|
||||
## Usage
|
||||
|
||||
Use TypeScript for best in class intellisense
|
||||
|
||||
## Contribution
|
||||
|
||||
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
|
||||
|
||||
For further information read the linked docs at the top of this readme.
|
||||
|
||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||
|
||||
[](https://maintainedby.lossless.com)
|
19
test/test.ts
19
test/test.ts
@@ -1,23 +1,20 @@
|
||||
import { expect, tap } from '@pushrocks/tapbundle';
|
||||
import * as tswatch from '../ts/index';
|
||||
// tslint:disable-next-line: no-implicit-dependencies
|
||||
import { expect, expectAsync, tap } from '@push.rocks/tapbundle';
|
||||
import * as tswatch from '../ts/index.js';
|
||||
|
||||
let testTsWatchInstance: tswatch.TsWatch;
|
||||
|
||||
tap.test('should create a valid TsWatch instance', async () => {
|
||||
testTsWatchInstance = new tswatch.TsWatch({
|
||||
filePathToWatch: process.cwd(),
|
||||
commandToExecute: 'npm -v',
|
||||
timeout: 1000
|
||||
});
|
||||
testTsWatchInstance = new tswatch.TsWatch('echoSomething');
|
||||
});
|
||||
|
||||
tap.test('should start the tswatch instance', async () => {
|
||||
testTsWatchInstance.start();
|
||||
console.log('test executed');
|
||||
await testTsWatchInstance.start();
|
||||
});
|
||||
|
||||
tap.test('should run abitrary commands', async () => {
|
||||
|
||||
tap.test('should stop the instance', async (tools) => {
|
||||
tools.delayFor(2000);
|
||||
testTsWatchInstance.stop();
|
||||
});
|
||||
|
||||
tap.start();
|
||||
|
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* autocreated commitinfo by @push.rocks/commitinfo
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@git.zone/tswatch',
|
||||
version: '2.0.27',
|
||||
description: 'watch typescript projects during development'
|
||||
}
|
@@ -1,3 +1,5 @@
|
||||
export * from './tswatch.classes.tswatch';
|
||||
|
||||
import './tswatch.cli';
|
||||
import * as early from '@push.rocks/early';
|
||||
early.start('tswatch');
|
||||
export * from './tswatch.classes.tswatch.js';
|
||||
export * from './tswatch.cli.js';
|
||||
early.stop();
|
||||
|
1
ts/interfaces/index.ts
Normal file
1
ts/interfaces/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from './interfaces.watchmodes.js';
|
7
ts/interfaces/interfaces.watchmodes.ts
Normal file
7
ts/interfaces/interfaces.watchmodes.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
export type TWatchModes =
|
||||
| 'test'
|
||||
| 'node'
|
||||
| 'service'
|
||||
| 'element'
|
||||
| 'website'
|
||||
| 'echo';
|
@@ -1,80 +1,202 @@
|
||||
import * as plugins from './tswatch.plugins';
|
||||
import * as plugins from './tswatch.plugins.js';
|
||||
import * as paths from './tswatch.paths.js';
|
||||
import * as interfaces from './interfaces/index.js';
|
||||
|
||||
export interface ITsWatchConstructorOptions {
|
||||
filePathToWatch: string;
|
||||
commandToExecute: string;
|
||||
timeout?: number;
|
||||
}
|
||||
import { Watcher } from './tswatch.classes.watcher.js';
|
||||
|
||||
/**
|
||||
* handles the management of watching for foes
|
||||
*/
|
||||
export class TsWatch {
|
||||
private smartshellInstance = new plugins.smartshell.Smartshell({
|
||||
executor: 'bash'
|
||||
});
|
||||
private currentExecution: plugins.smartshell.IExecResultStreaming;
|
||||
private watcher;
|
||||
private options: ITsWatchConstructorOptions;
|
||||
public watchmode: interfaces.TWatchModes;
|
||||
public watcherMap = new plugins.lik.ObjectMap<Watcher>();
|
||||
public typedserver: plugins.typedserver.TypedServer;
|
||||
|
||||
constructor(optionsArg: ITsWatchConstructorOptions) {
|
||||
this.options = optionsArg;
|
||||
constructor(watchmodeArg: interfaces.TWatchModes) {
|
||||
this.watchmode = watchmodeArg;
|
||||
}
|
||||
|
||||
/**
|
||||
* start the file
|
||||
* starts the TsWatch instance
|
||||
*/
|
||||
public async start() {
|
||||
this.setupCleanup();
|
||||
console.log(`Looking at ${this.options.filePathToWatch} for changes`);
|
||||
this.watcher.add(this.options.filePathToWatch); // __dirname refers to the directory of this very file
|
||||
this.watcher.on('change', async (file, stat) => {
|
||||
console.log('Noticed change!');
|
||||
if (!stat) {
|
||||
console.log('deleted');
|
||||
}
|
||||
this.updateCurrentExecution();
|
||||
const tsbundle = new plugins.tsbundle.TsBundle();
|
||||
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,
|
||||
commandToExecute: 'npm run test2',
|
||||
timeout: null,
|
||||
})
|
||||
);
|
||||
break;
|
||||
case 'node':
|
||||
this.watcherMap.add(
|
||||
new Watcher({
|
||||
filePathToWatch: paths.cwd,
|
||||
commandToExecute: 'npm run test',
|
||||
timeout: null,
|
||||
})
|
||||
);
|
||||
break;
|
||||
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',
|
||||
});
|
||||
this.updateCurrentExecution();
|
||||
|
||||
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',
|
||||
});
|
||||
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,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
private async updateCurrentExecution() {
|
||||
if (this.currentExecution) {
|
||||
process.kill(-this.currentExecution.childProcess.pid);
|
||||
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 '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',
|
||||
});
|
||||
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 'service':
|
||||
this.watcherMap.add(
|
||||
new Watcher({
|
||||
filePathToWatch: plugins.path.join(paths.cwd, './ts/'),
|
||||
commandToExecute: 'npm run startTs',
|
||||
timeout: null,
|
||||
})
|
||||
);
|
||||
break;
|
||||
case 'echo':
|
||||
const tsWatchInstanceEchoSomething = new Watcher({
|
||||
filePathToWatch: plugins.path.join(paths.cwd, './ts'),
|
||||
commandToExecute: 'npm -v',
|
||||
timeout: null,
|
||||
});
|
||||
this.watcherMap.add(tsWatchInstanceEchoSomething);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
this.watcherMap.forEach(async (watcher) => {
|
||||
await watcher.start();
|
||||
});
|
||||
if (this.typedserver) {
|
||||
await this.typedserver.start();
|
||||
}
|
||||
this.currentExecution = await this.smartshellInstance.execStreaming(this.options.commandToExecute);
|
||||
this.currentExecution = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* this method sets up a clean exit strategy
|
||||
* stops the execution of any active Watchers
|
||||
*/
|
||||
private async setupCleanup() {
|
||||
const cleanup = () => {
|
||||
if (this.currentExecution) {
|
||||
process.kill(-this.currentExecution.childProcess.pid);
|
||||
public async stop() {
|
||||
if (this.typedserver) {
|
||||
await this.typedserver.stop();
|
||||
}
|
||||
};
|
||||
process.on('exit', () => {
|
||||
console.log('');
|
||||
console.log('now exiting!');
|
||||
cleanup();
|
||||
process.exit(0);
|
||||
this.watcherMap.forEach(async (watcher) => {
|
||||
await watcher.stop();
|
||||
});
|
||||
process.on('SIGINT', () => {
|
||||
console.log('');
|
||||
console.log('ok! got SIGINT We are exiting! Just cleaning up to exit neatly :)');
|
||||
cleanup();
|
||||
process.exit(0);
|
||||
});
|
||||
|
||||
// handle timeout
|
||||
if (this.options.timeout) {
|
||||
plugins.smartdelay.delayFor(this.options.timeout).then(() => {
|
||||
console.log(`timed out afer ${this.options.timeout} milliseconds! exiting!`);
|
||||
cleanup();
|
||||
process.exit(0);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
105
ts/tswatch.classes.watcher.ts
Normal file
105
ts/tswatch.classes.watcher.ts
Normal file
@@ -0,0 +1,105 @@
|
||||
import * as plugins from './tswatch.plugins.js';
|
||||
import { logger } from './tswatch.logging.js';
|
||||
|
||||
export interface IWatcherConstructorOptions {
|
||||
filePathToWatch: string;
|
||||
commandToExecute?: string;
|
||||
functionToCall?: () => Promise<any>;
|
||||
timeout?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* A watcher keeps track of one child execution
|
||||
*/
|
||||
export class Watcher {
|
||||
/**
|
||||
* used to execute shell commands
|
||||
*/
|
||||
private smartshellInstance = new plugins.smartshell.Smartshell({
|
||||
executor: 'bash',
|
||||
});
|
||||
|
||||
private currentExecution: plugins.smartshell.IExecResultStreaming;
|
||||
private smartchokWatcher = new plugins.smartchok.Smartchok([]);
|
||||
private options: IWatcherConstructorOptions;
|
||||
|
||||
constructor(optionsArg: IWatcherConstructorOptions) {
|
||||
this.options = optionsArg;
|
||||
}
|
||||
|
||||
/**
|
||||
* start the file
|
||||
*/
|
||||
public async start() {
|
||||
await this.setupCleanup();
|
||||
console.log(`Looking at ${this.options.filePathToWatch} for changes`);
|
||||
this.smartchokWatcher.add([this.options.filePathToWatch]); // __dirname refers to the directory of this very file
|
||||
await this.smartchokWatcher.start();
|
||||
const changeObservable = await this.smartchokWatcher.getObservableFor('change');
|
||||
changeObservable.subscribe(() => {
|
||||
this.updateCurrentExecution();
|
||||
});
|
||||
await this.updateCurrentExecution();
|
||||
}
|
||||
|
||||
/**
|
||||
* updates the current execution
|
||||
*/
|
||||
private async updateCurrentExecution() {
|
||||
if (this.options.commandToExecute) {
|
||||
if (this.currentExecution) {
|
||||
logger.log('ok', `reexecuting ${this.options.commandToExecute}`);
|
||||
this.currentExecution.kill();
|
||||
} else {
|
||||
logger.log('ok', `executing ${this.options.commandToExecute} for the first time`);
|
||||
}
|
||||
this.currentExecution = await this.smartshellInstance.execStreaming(
|
||||
this.options.commandToExecute
|
||||
);
|
||||
} else {
|
||||
console.log('no executionCommand set');
|
||||
}
|
||||
if (this.options.functionToCall) {
|
||||
this.options.functionToCall();
|
||||
} else {
|
||||
console.log('no functionToCall set.')
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* this method sets up a clean exit strategy
|
||||
*/
|
||||
private async setupCleanup() {
|
||||
process.on('exit', () => {
|
||||
console.log('');
|
||||
console.log('now exiting!');
|
||||
this.stop();
|
||||
process.exit(0);
|
||||
});
|
||||
process.on('SIGINT', () => {
|
||||
console.log('');
|
||||
console.log('ok! got SIGINT We are exiting! Just cleaning up to exit neatly :)');
|
||||
this.stop();
|
||||
process.exit(0);
|
||||
});
|
||||
|
||||
// handle timeout
|
||||
if (this.options.timeout) {
|
||||
plugins.smartdelay.delayFor(this.options.timeout).then(() => {
|
||||
console.log(`timed out afer ${this.options.timeout} milliseconds! exiting!`);
|
||||
this.stop();
|
||||
process.exit(0);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* stops the watcher
|
||||
*/
|
||||
public async stop() {
|
||||
await this.smartchokWatcher.stop();
|
||||
if (this.currentExecution && !this.currentExecution.childProcess.killed) {
|
||||
this.currentExecution.kill();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,24 +1,46 @@
|
||||
import * as plugins from './tswatch.plugins';
|
||||
import * as paths from './tswatch.paths';
|
||||
import * as plugins from './tswatch.plugins.js';
|
||||
import * as paths from './tswatch.paths.js';
|
||||
import { logger } from './tswatch.logging.js';
|
||||
|
||||
import { TsWatch } from './tswatch.classes.tswatch';
|
||||
import { TsWatch } from './tswatch.classes.tswatch.js';
|
||||
|
||||
const tswatchCli = new plugins.smartcli.Smartcli();
|
||||
|
||||
tswatchCli.addCommand('test').subscribe(argvArg => {
|
||||
const tsWatch = new TsWatch({
|
||||
filePathToWatch: paths.cwd,
|
||||
commandToExecute: 'npm run test2',
|
||||
timeout: (() => {
|
||||
if (argvArg.timeout) {
|
||||
console.log(`timeing out after ${argvArg.timeout}`);
|
||||
return argvArg.timeout;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
})()
|
||||
});
|
||||
tsWatch.start();
|
||||
// standard behaviour will assume gitzone setup
|
||||
tswatchCli.standardCommand().subscribe((argvArg => {
|
||||
tswatchCli.triggerCommand('npm', {});
|
||||
}))
|
||||
|
||||
tswatchCli.addCommand('element').subscribe(async (argvArg) => {
|
||||
logger.log('info', `running watch task for a gitzone element project`);
|
||||
const tsWatch = new TsWatch('element');
|
||||
await tsWatch.start();
|
||||
});
|
||||
|
||||
tswatchCli.startParse();
|
||||
tswatchCli.addCommand('npm').subscribe(async (argvArg) => {
|
||||
logger.log('info', `running watch task for a gitzone element project`);
|
||||
const tsWatch = new TsWatch('node');
|
||||
await tsWatch.start();
|
||||
});
|
||||
|
||||
tswatchCli.addCommand('service').subscribe(async (argvArg) => {
|
||||
logger.log('info', `running test task`);
|
||||
const tsWatch = new TsWatch('service');
|
||||
await tsWatch.start();
|
||||
});
|
||||
|
||||
tswatchCli.addCommand('test').subscribe(async (argvArg) => {
|
||||
logger.log('info', `running test task`);
|
||||
const tsWatch = new TsWatch('test');
|
||||
await tsWatch.start();
|
||||
});
|
||||
|
||||
tswatchCli.addCommand('website').subscribe(async (argvArg) => {
|
||||
logger.log('info', `running watch task for a gitzone website project`);
|
||||
const tsWatch = new TsWatch('website');
|
||||
await tsWatch.start();
|
||||
});
|
||||
|
||||
export const runCli = async () => {
|
||||
tswatchCli.startParse();
|
||||
};
|
||||
|
15
ts/tswatch.logging.ts
Normal file
15
ts/tswatch.logging.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import * as plugins from './tswatch.plugins.js';
|
||||
|
||||
export const logger = new plugins.smartlog.Smartlog({
|
||||
logContext: {
|
||||
company: 'Some Company',
|
||||
companyunit: 'Some CompanyUnit',
|
||||
containerName: 'Some Containername',
|
||||
environment: 'local',
|
||||
runtime: 'node',
|
||||
zone: 'gitzone',
|
||||
},
|
||||
minimumLogLevel: 'silly',
|
||||
});
|
||||
|
||||
logger.addLogDestination(new plugins.smartlogDestinationLocal.DestinationLocal());
|
@@ -1,3 +1,3 @@
|
||||
import * as plugins from './tswatch.plugins';
|
||||
import * as plugins from './tswatch.plugins.js';
|
||||
|
||||
export const cwd = process.cwd();
|
||||
|
@@ -1,14 +1,39 @@
|
||||
// node native scope
|
||||
import * as path from 'path';
|
||||
export { path };
|
||||
|
||||
// @gitzone scope
|
||||
import * as tsbundle from '@git.zone/tsbundle';
|
||||
export {
|
||||
tsbundle
|
||||
}
|
||||
|
||||
// @apiglobal scope
|
||||
import * as typedserver from '@api.global/typedserver';
|
||||
|
||||
export {
|
||||
typedserver,
|
||||
}
|
||||
|
||||
// @pushrocks scope
|
||||
import * as smartcli from '@pushrocks/smartcli';
|
||||
import * as smartdelay from '@pushrocks/smartdelay';
|
||||
import * as smartshell from '@pushrocks/smartshell';
|
||||
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';
|
||||
import * as taskbuffer from '@push.rocks/taskbuffer';
|
||||
|
||||
export { smartdelay, smartshell, smartcli };
|
||||
|
||||
// Third Pary
|
||||
import * as fileWatcher from 'filewatcher';
|
||||
|
||||
export { fileWatcher };
|
||||
export {
|
||||
lik,
|
||||
smartchok,
|
||||
smartcli,
|
||||
smartdelay,
|
||||
smartfile,
|
||||
smartlog,
|
||||
smartlogDestinationLocal,
|
||||
smartshell,
|
||||
taskbuffer,
|
||||
};
|
||||
|
14
tsconfig.json
Normal file
14
tsconfig.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"experimentalDecorators": true,
|
||||
"useDefineForClassFields": false,
|
||||
"target": "ES2022",
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"esModuleInterop": true,
|
||||
"verbatimModuleSyntax": true
|
||||
},
|
||||
"exclude": [
|
||||
"dist_*/**/*.d.ts"
|
||||
]
|
||||
}
|
10
tslint.json
10
tslint.json
@@ -1,10 +0,0 @@
|
||||
{
|
||||
"extends": ["tslint:latest", "tslint-config-prettier"],
|
||||
"rules": {
|
||||
"semicolon": [true, "always"],
|
||||
"no-console": false,
|
||||
"ordered-imports": false,
|
||||
"object-literal-sort-keys": false
|
||||
},
|
||||
"defaultSeverity": "warning"
|
||||
}
|
Reference in New Issue
Block a user