Compare commits
176 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f7f42ff36c | |||
| 77d2e6ee57 | |||
| e8bd8da3c7 | |||
| 91b3e273de | |||
| e6a7b352f3 | |||
| 8c1b306313 | |||
| a893e7a771 | |||
| c330420eea | |||
| df8b164434 | |||
| 6af321647d | |||
| 47cd9adc8e | |||
| 721dc3b22c | |||
| 9fb3f6a872 | |||
| 5a702055f4 | |||
| ebcfbc88b2 | |||
| cd76756e89 | |||
| c269f4f7e1 | |||
| 88595335ea | |||
| 313362b795 | |||
| 0bb76f32b8 | |||
| 5c7bf83f74 | |||
| 57caa96a85 | |||
| eb64501767 | |||
| 3f90dfd1db | |||
| b5552a7f34 | |||
| 814cc70a29 | |||
| 8508eee439 | |||
| 592e1f35b2 | |||
| 94fa31a5c8 | |||
| 6b8ce469d2 | |||
| bb1038baa0 | |||
| a3db29edd7 | |||
| 2c8ed46c9e | |||
| 6c30d35de7 | |||
| 3cdd5302f8 | |||
| 42bba057cb | |||
| b9cddaa3f3 | |||
| 9ecf007767 | |||
| 660a480317 | |||
| ec268802ca | |||
| 6415a459d2 | |||
| 01bde87067 | |||
| 4f4c4a7538 | |||
| 0dee896201 | |||
| 29f7283f7a | |||
| 3eb99e1f08 | |||
| ad41fe876d | |||
| d6f3381e71 | |||
| bcbf6fc139 | |||
| f73ca7ac2f | |||
| 75acc4b768 | |||
| 83cf8594ab | |||
| 417dc4c763 | |||
| 64a86f7af3 | |||
| 1a66e76b6f | |||
| 5c04dc7729 | |||
| ecd76bc8aa | |||
| 488bd65933 | |||
| 5763858bac | |||
| a4c8e33e3a | |||
| 81941c33cb | |||
| 7605702ba7 | |||
| 2d1c037301 | |||
| b46fb0f042 | |||
| c09f82083d | |||
| ee2b01e799 | |||
| 3a7a022d69 | |||
| 9c4751cdd0 | |||
| 340efa5720 | |||
| 37f45a4912 | |||
| e72231dee1 | |||
| 54aa225880 | |||
| 98a16dd181 | |||
| d4414638b6 | |||
| 5cd5085f05 | |||
| 0b8f3d317c | |||
| 17ee959980 | |||
| 62d1fe0a35 | |||
| 915bd67b6a | |||
| 9e0765ce0b | |||
| abde25211a | |||
| e8ae4c8341 | |||
| dc6bb93349 | |||
| e2b154f392 | |||
| 993997d5fa | |||
| 52e85d61cd | |||
| b991f62af7 | |||
| 8ad26eb358 | |||
| 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 |
66
.gitea/workflows/default_nottags.yaml
Normal file
66
.gitea/workflows/default_nottags.yaml
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
name: Default (not tags)
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags-ignore:
|
||||||
|
- '**'
|
||||||
|
|
||||||
|
env:
|
||||||
|
IMAGE: code.foss.global/host.today/ht-docker-node:npmci
|
||||||
|
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@/${{gitea.repository}}.git
|
||||||
|
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
|
||||||
|
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
|
||||||
|
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
|
||||||
|
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
security:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
continue-on-error: true
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Install pnpm and npmci
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @ship.zone/npmci
|
||||||
|
|
||||||
|
- name: Run npm prepare
|
||||||
|
run: npmci npm prepare
|
||||||
|
|
||||||
|
- name: Audit production dependencies
|
||||||
|
run: |
|
||||||
|
npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
npmci command pnpm audit --audit-level=high --prod
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
- name: Audit development dependencies
|
||||||
|
run: |
|
||||||
|
npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
npmci command pnpm audit --audit-level=high --dev
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
test:
|
||||||
|
if: ${{ always() }}
|
||||||
|
needs: security
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Test stable
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
npmci npm test
|
||||||
|
|
||||||
|
- name: Test build
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
npmci npm build
|
||||||
124
.gitea/workflows/default_tags.yaml
Normal file
124
.gitea/workflows/default_tags.yaml
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
name: Default (tags)
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- '*'
|
||||||
|
|
||||||
|
env:
|
||||||
|
IMAGE: code.foss.global/host.today/ht-docker-node:npmci
|
||||||
|
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@/${{gitea.repository}}.git
|
||||||
|
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
|
||||||
|
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
|
||||||
|
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
|
||||||
|
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
security:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
continue-on-error: true
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @ship.zone/npmci
|
||||||
|
npmci npm prepare
|
||||||
|
|
||||||
|
- name: Audit production dependencies
|
||||||
|
run: |
|
||||||
|
npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
npmci command pnpm audit --audit-level=high --prod
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
- name: Audit development dependencies
|
||||||
|
run: |
|
||||||
|
npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
npmci command pnpm audit --audit-level=high --dev
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
test:
|
||||||
|
if: ${{ always() }}
|
||||||
|
needs: security
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @ship.zone/npmci
|
||||||
|
npmci npm prepare
|
||||||
|
|
||||||
|
- name: Test stable
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
npmci npm test
|
||||||
|
|
||||||
|
- name: Test build
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
npmci npm build
|
||||||
|
|
||||||
|
release:
|
||||||
|
needs: test
|
||||||
|
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @ship.zone/npmci
|
||||||
|
npmci npm prepare
|
||||||
|
|
||||||
|
- name: Release
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm publish
|
||||||
|
|
||||||
|
metadata:
|
||||||
|
needs: test
|
||||||
|
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @ship.zone/npmci
|
||||||
|
npmci npm prepare
|
||||||
|
|
||||||
|
- name: Code quality
|
||||||
|
run: |
|
||||||
|
npmci command npm install -g typescript
|
||||||
|
npmci npm install
|
||||||
|
|
||||||
|
- name: Trigger
|
||||||
|
run: npmci trigger
|
||||||
|
|
||||||
|
- name: Build docs and upload artifacts
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
pnpm install -g @git.zone/tsdoc
|
||||||
|
npmci command tsdoc
|
||||||
|
continue-on-error: true
|
||||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -3,7 +3,6 @@
|
|||||||
# artifacts
|
# artifacts
|
||||||
coverage/
|
coverage/
|
||||||
public/
|
public/
|
||||||
pages/
|
|
||||||
|
|
||||||
# installs
|
# installs
|
||||||
node_modules/
|
node_modules/
|
||||||
@@ -17,4 +16,4 @@ node_modules/
|
|||||||
dist/
|
dist/
|
||||||
dist_*/
|
dist_*/
|
||||||
|
|
||||||
# custom
|
#------# custom
|
||||||
138
.gitlab-ci.yml
138
.gitlab-ci.yml
@@ -1,138 +0,0 @@
|
|||||||
# gitzone ci_default
|
|
||||||
image: registry.gitlab.com/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
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
auditProductionDependencies:
|
|
||||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
|
||||||
stage: security
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci command npm install --production --ignore-scripts
|
|
||||||
- npmci command npm config set registry https://registry.npmjs.org
|
|
||||||
- npmci command npm audit --audit-level=high --only=prod --production
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
allow_failure: true
|
|
||||||
|
|
||||||
auditDevDependencies:
|
|
||||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
|
||||||
stage: security
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci command npm install --ignore-scripts
|
|
||||||
- npmci command npm config set registry https://registry.npmjs.org
|
|
||||||
- npmci command npm audit --audit-level=high --only=dev
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
allow_failure: true
|
|
||||||
|
|
||||||
# ====================
|
|
||||||
# test stage
|
|
||||||
# ====================
|
|
||||||
|
|
||||||
testStable:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci node install stable
|
|
||||||
- npmci npm install
|
|
||||||
- npmci npm test
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
testBuild:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci node install stable
|
|
||||||
- npmci npm install
|
|
||||||
- npmci command npm run build
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
release:
|
|
||||||
stage: release
|
|
||||||
script:
|
|
||||||
- npmci node install stable
|
|
||||||
- npmci npm publish
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
# ====================
|
|
||||||
# metadata stage
|
|
||||||
# ====================
|
|
||||||
codequality:
|
|
||||||
stage: metadata
|
|
||||||
allow_failure: true
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
script:
|
|
||||||
- npmci command npm install -g tslint typescript
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci npm install
|
|
||||||
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- priv
|
|
||||||
|
|
||||||
trigger:
|
|
||||||
stage: metadata
|
|
||||||
script:
|
|
||||||
- npmci trigger
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
pages:
|
|
||||||
stage: metadata
|
|
||||||
script:
|
|
||||||
- npmci node install lts
|
|
||||||
- npmci command npm install -g @gitzone/tsdoc
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci npm install
|
|
||||||
- npmci command tsdoc
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
artifacts:
|
|
||||||
expire_in: 1 week
|
|
||||||
paths:
|
|
||||||
- public
|
|
||||||
allow_failure: true
|
|
||||||
24
.vscode/launch.json
vendored
24
.vscode/launch.json
vendored
@@ -2,28 +2,10 @@
|
|||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"name": "current file",
|
"command": "npm test",
|
||||||
"type": "node",
|
"name": "Run npm test",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"args": [
|
"type": "node-terminal"
|
||||||
"${relativeFile}"
|
|
||||||
],
|
|
||||||
"runtimeArgs": ["-r", "@gitzone/tsrun"],
|
|
||||||
"cwd": "${workspaceRoot}",
|
|
||||||
"protocol": "inspector",
|
|
||||||
"internalConsoleOptions": "openOnSessionStart"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "test.ts",
|
|
||||||
"type": "node",
|
|
||||||
"request": "launch",
|
|
||||||
"args": [
|
|
||||||
"test/test.ts"
|
|
||||||
],
|
|
||||||
"runtimeArgs": ["-r", "@gitzone/tsrun"],
|
|
||||||
"cwd": "${workspaceRoot}",
|
|
||||||
"protocol": "inspector",
|
|
||||||
"internalConsoleOptions": "openOnSessionStart"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
356
changelog.md
Normal file
356
changelog.md
Normal file
@@ -0,0 +1,356 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
## 2026-03-03 - 3.2.1 - fix(watcher)
|
||||||
|
ensure child processes are killed and awaited during shutdown; improve cleanup handlers; bump smartshell dependency to ^3.3.2
|
||||||
|
|
||||||
|
- Await child process kill() calls in restart and stop to avoid race conditions and ensure proper termination.
|
||||||
|
- Add last-resort synchronous SIGKILL in process 'exit' handler to terminate orphaned child processes.
|
||||||
|
- Make SIGINT and timeout handlers async and await stop() to perform a clean shutdown before exiting.
|
||||||
|
- Bump @push.rocks/smartshell from ^3.3.0 to ^3.3.2 in package.json.
|
||||||
|
|
||||||
|
## 2026-02-24 - 3.2.0 - feat(bundle)
|
||||||
|
add configurable bundle output modes and bundler options (support base64ts, production builds, includeFiles, maxLineLength) and route non-default outputs to a CustomBundleHandler
|
||||||
|
|
||||||
|
- Added new ITswatchConfig fields: outputMode, bundler, production, includeFiles, maxLineLength
|
||||||
|
- tswatch now creates a CustomBundleHandler and uses it when outputMode is not 'bundle' (e.g. base64ts)
|
||||||
|
- Default bundling path now reads bundler and production from bundleConfig (defaults to 'esbuild' and false)
|
||||||
|
- Bumped dependency @git.zone/tsbundle to ^2.9.0
|
||||||
|
|
||||||
|
## 2026-02-05 - 3.1.0 - feat(dev-server)
|
||||||
|
add no-cache headers to built-in development server; update docs and bump dependencies
|
||||||
|
|
||||||
|
- Introduce noCache: true in ts/tswatch.classes.tswatch.ts to send Cache-Control: no-store, no-cache during development (prevents browser caching).
|
||||||
|
- Update documentation to describe no-caching behavior (readme.md and readme.hints.md).
|
||||||
|
- Bump dependencies: @git.zone/tstest ^3.1.8, @types/node ^25.2.1, @push.rocks/npmextra ^5.3.3, @push.rocks/taskbuffer ^4.2.0.
|
||||||
|
|
||||||
|
## 2026-01-24 - 3.0.1 - fix(deps)
|
||||||
|
downgrade @push.rocks/smartinteract to ^2.0.16
|
||||||
|
|
||||||
|
- package.json: @push.rocks/smartinteract ^2.1.0 -> ^2.0.16
|
||||||
|
|
||||||
|
## 2026-01-24 - 3.0.0 - BREAKING CHANGE(tswatch)
|
||||||
|
refactor tswatch to a config-driven design (load config from npmextra.json) and add interactive init wizard; change TsWatch public API and enhance Watcher behavior
|
||||||
|
|
||||||
|
- Switch to config-driven operation: configuration read from npmextra.json under the key @git.zone/tswatch
|
||||||
|
- Added ConfigHandler for loading/merging presets and new TswatchInit interactive wizard (runInit) to create/save configuration
|
||||||
|
- Changed TsWatch constructor to accept ITswatchConfig and added TsWatch.fromConfig(cwd?) for loading from npmextra.json
|
||||||
|
- Significant public API change: previous watchmode string-based constructor/behavior removed/rewired — consumers must migrate to new config-based usage (breaking change)
|
||||||
|
- Watcher refactor: Watcher.fromConfig, named watchers, array/single path support, debounce, restart/queue handling, runOnStart, safer start/stop behavior and execution tracking
|
||||||
|
- New TypeScript interfaces: interfaces.config.ts (ITswatchConfig, IWatcherConfig, IServerConfig, IBundleConfig); removed/changed old watchmodes types
|
||||||
|
- CLI updated to use configuration if present or launch the init wizard; added init command
|
||||||
|
- Updated tests to cover ConfigHandler, Watcher, and TsWatch config-driven behavior
|
||||||
|
- Updated dependencies and plugin usage (added @push.rocks/npmextra, @push.rocks/smartinteract; bumped several @git.zone and @push.rocks package versions)
|
||||||
|
|
||||||
|
## 2025-12-11 - 2.3.13 - fix(@push.rocks/smartwatch)
|
||||||
|
Update @push.rocks/smartwatch dependency to ^6.3.0
|
||||||
|
|
||||||
|
- Bump @push.rocks/smartwatch from ^6.2.5 to ^6.3.0 in package.json
|
||||||
|
- Dependency-only change; no source files modified
|
||||||
|
|
||||||
|
## 2025-12-11 - 2.3.12 - fix(smartwatch)
|
||||||
|
Bump @push.rocks/smartwatch from ^6.2.4 to ^6.2.5
|
||||||
|
|
||||||
|
- Updated dependency @push.rocks/smartwatch to ^6.2.5 in package.json
|
||||||
|
- No source code changes; dependency version bump only
|
||||||
|
|
||||||
|
## 2025-12-11 - 2.3.11 - fix(typedserver)
|
||||||
|
Add cross-origin security headers to element mode dev server
|
||||||
|
|
||||||
|
- Set crossOriginOpenerPolicy to 'same-origin' and crossOriginEmbedderPolicy to 'require-corp' on the TypedServer used in element mode.
|
||||||
|
- Improves security and enables cross-origin isolation (e.g. for SharedArrayBuffer) during local development.
|
||||||
|
- Applies to the development server serving ./dist_watch/ on port 3002.
|
||||||
|
|
||||||
|
## 2025-12-11 - 2.3.10 - fix(dependencies)
|
||||||
|
Bump dependency versions: @types/node to ^25.0.0 and @push.rocks/smartwatch to ^6.2.4
|
||||||
|
|
||||||
|
- Update devDependency @types/node from ^24.10.2 to ^25.0.0
|
||||||
|
- Update dependency @push.rocks/smartwatch from ^6.2.3 to ^6.2.4
|
||||||
|
|
||||||
|
## 2025-12-11 - 2.3.9 - fix(smartwatch)
|
||||||
|
Bump @push.rocks/smartwatch dependency to ^6.2.3
|
||||||
|
|
||||||
|
- Updated dependency @push.rocks/smartwatch from ^6.2.2 to ^6.2.3
|
||||||
|
- No source code changes; dependency version bump only
|
||||||
|
|
||||||
|
## 2025-12-11 - 2.3.8 - fix(@push.rocks/smartwatch)
|
||||||
|
Bump @push.rocks/smartwatch dependency to ^6.2.2
|
||||||
|
|
||||||
|
- package.json: updated @push.rocks/smartwatch from ^6.2.1 to ^6.2.2
|
||||||
|
|
||||||
|
## 2025-12-10 - 2.3.7 - fix(smartwatch)
|
||||||
|
Bump @push.rocks/smartwatch dependency to ^6.2.1
|
||||||
|
|
||||||
|
- Updated dependency @push.rocks/smartwatch from ^6.2.0 to ^6.2.1 in package.json
|
||||||
|
|
||||||
|
## 2025-12-10 - 2.3.6 - fix(dependencies)
|
||||||
|
Bump @types/node to ^24.10.2 and @push.rocks/smartwatch to ^6.2.0
|
||||||
|
|
||||||
|
- Dev dependency @types/node updated from ^24.10.1 to ^24.10.2
|
||||||
|
- Dependency @push.rocks/smartwatch updated from ^6.1.1 to ^6.2.0
|
||||||
|
|
||||||
|
## 2025-12-08 - 2.3.5 - fix(dependencies)
|
||||||
|
Update @push.rocks/smartwatch dependency to ^6.1.1
|
||||||
|
|
||||||
|
- Bump @push.rocks/smartwatch from ^6.1.0 to ^6.1.1 in package.json
|
||||||
|
- Only package.json changed; no source code modifications
|
||||||
|
|
||||||
|
## 2025-12-08 - 2.3.4 - fix(dependencies.@push.rocks/smartwatch)
|
||||||
|
Bump @push.rocks/smartwatch dependency to ^6.1.0
|
||||||
|
|
||||||
|
- Updated package.json dependency @push.rocks/smartwatch from ^6.0.0 to ^6.1.0
|
||||||
|
|
||||||
|
## 2025-12-08 - 2.3.3 - fix(dependencies)
|
||||||
|
Bump dependencies: @api.global/typedserver to ^7.11.1 and @push.rocks/smartwatch to ^6.0.0
|
||||||
|
|
||||||
|
- Updated @api.global/typedserver from ^7.11.0 to ^7.11.1 (patch).
|
||||||
|
- Updated @push.rocks/smartwatch from ^5.1.0 to ^6.0.0 (major). Verify compatibility as this may include breaking changes in that dependency.
|
||||||
|
- Change is limited to package.json (dependency version updates).
|
||||||
|
|
||||||
|
## 2025-12-08 - 2.3.2 - fix(smartwatch)
|
||||||
|
Bump @push.rocks/smartwatch dependency to ^5.1.0
|
||||||
|
|
||||||
|
- Updated dependency @push.rocks/smartwatch from ^5.0.0 to ^5.1.0 in package.json
|
||||||
|
|
||||||
|
## 2025-12-08 - 2.3.1 - fix(element)
|
||||||
|
Enable SPA fallback in element dev server
|
||||||
|
|
||||||
|
- Add spaFallback: true to the TypedServer configuration used in element mode.
|
||||||
|
- Improves developer experience for single-page apps by serving the index file for unknown routes during development and supporting client-side routing.
|
||||||
|
|
||||||
|
## 2025-12-08 - 2.3.0 - feat(typedserver)
|
||||||
|
Enable compression for element development server and update @api.global/typedserver dependency
|
||||||
|
|
||||||
|
- Enable HTTP compression (compression: true) for the element mode development server (TypedServer) to improve asset delivery during development.
|
||||||
|
- Bump dependency @api.global/typedserver from ^7.10.2 to ^7.11.0 in package.json.
|
||||||
|
|
||||||
|
## 2025-12-08 - 2.2.5 - fix(typedserver)
|
||||||
|
Update @api.global/typedserver to ^7.10.2 and remove deprecated compression options from TypedServer initialization
|
||||||
|
|
||||||
|
- Bump @api.global/typedserver dependency from ^7.4.1 to ^7.10.2.
|
||||||
|
- Remove enableCompression and preferredCompressionMethod options when creating TypedServer in element mode to be compatible with the newer API.
|
||||||
|
|
||||||
|
## 2025-12-04 - 2.2.4 - fix(dependencies)
|
||||||
|
Bump dependency versions: @api.global/typedserver, @git.zone/tsbundle, @push.rocks/smartfs, @push.rocks/taskbuffer
|
||||||
|
|
||||||
|
- Upgrade @api.global/typedserver from ^3.0.80 to ^7.4.1
|
||||||
|
- Upgrade @git.zone/tsbundle from ^2.6.2 to ^2.6.3
|
||||||
|
- Upgrade @push.rocks/smartfs from ^1.1.3 to ^1.2.0
|
||||||
|
- Upgrade @push.rocks/taskbuffer from ^3.4.0 to ^3.5.0
|
||||||
|
|
||||||
|
## 2025-12-04 - 2.2.3 - fix(tswatch.classes.watcher)
|
||||||
|
Convert directory watch paths to glob patterns for smartwatch compatibility
|
||||||
|
|
||||||
|
- Watcher: convert directory paths to recursive glob patterns before adding them to Smartwatch so directories are watched recursively (e.g. /path/to/dir/ -> /path/to/dir/**/*).
|
||||||
|
- Readme: added migration note explaining that directory paths are converted to glob patterns for smartwatch compatibility.
|
||||||
|
|
||||||
|
## 2025-12-01 - 2.2.2 - fix(core)
|
||||||
|
Replace smartchok/smartfile with smartwatch/smartfs, update watcher and plugins, and bump dependencies
|
||||||
|
|
||||||
|
- Replaced @push.rocks/smartchok with @push.rocks/smartwatch and updated Watcher to use Smartwatch (add/start/stop/getObservableFor).
|
||||||
|
- Replaced @push.rocks/smartfile with @push.rocks/smartfs and added SmartFs usage (SmartFsProviderNode) plus a listFolders helper used by TsWatch.
|
||||||
|
- Updated tswatch.plugins.ts to export smartfs and smartwatch and removed smartchok/smartfile exports.
|
||||||
|
- Updated tswatch.classes.watcher.ts and tswatch.classes.tswatch.ts to use the new smartwatch/smartfs APIs and adjusted directory listing and watcher logic accordingly.
|
||||||
|
- Bumped several devDependencies and dependencies in package.json (tsbuild, tstest, @api.global/typedserver, @git.zone/tsbundle, @git.zone/tsrun, @push.rocks/* packages).
|
||||||
|
- Documentation updates: readme.md and readme.hints.md include migration notes and Issue Reporting & Security section.
|
||||||
|
|
||||||
|
## 2025-07-29 - 2.2.1 - fix(exports)
|
||||||
|
Fix package.json exports field syntax
|
||||||
|
|
||||||
|
- Fixed exports field syntax from "./" to "." for proper module resolution
|
||||||
|
|
||||||
|
## 2025-07-29 - 2.2.0 - feat(exports)
|
||||||
|
Modernize package exports and expose watcher class
|
||||||
|
|
||||||
|
- Updated package.json to use modern exports field instead of main/typings
|
||||||
|
- Exposed TsWatch watcher class through index exports
|
||||||
|
|
||||||
|
## 2025-07-29 - 2.1.3 - fix(documentation)
|
||||||
|
Update and align documentation with internal CLI and project structure
|
||||||
|
|
||||||
|
- Refined readme.md and readme.hints.md to clearly describe the various watch modes and project setup
|
||||||
|
- Ensured the CLI command mappings in tswatch.cli.ts are documented for consistent usage
|
||||||
|
- Included update to internal commit information file for clarity
|
||||||
|
|
||||||
|
## 2025-06-26 - 2.1.2 - fix(dependencies)
|
||||||
|
Update @push.rocks/smartchok dependency to ^1.1.1
|
||||||
|
|
||||||
|
- Bump @push.rocks/smartchok version from ^1.0.34 to ^1.1.1 in package.json
|
||||||
|
|
||||||
|
## 2025-06-26 - 2.1.1 - fix(deps)
|
||||||
|
Update dependency versions and test import paths for enhanced stability
|
||||||
|
|
||||||
|
- Bump @git.zone/tsbuild from 2.2.1 to 2.6.4
|
||||||
|
- Upgrade @git.zone/tstest from 1.0.96 to 2.3.1 and update test import path
|
||||||
|
- Update @api.global/typedserver from 3.0.55 to 3.0.74
|
||||||
|
- Update @git.zone/tsbundle from 2.2.1 to 2.5.1
|
||||||
|
- Bump @push.rocks/lik from 6.1.0 to 6.2.2
|
||||||
|
- Update @push.rocks/smartfile from 11.1.6 to 11.2.5
|
||||||
|
- Upgrade @push.rocks/smartlog from 3.0.7 to 3.1.8
|
||||||
|
- Bump @push.rocks/smartshell from 3.2.2 to 3.2.3
|
||||||
|
- Upgrade @types/node from 22.12.0 to 24.0.4
|
||||||
|
- Add packageManager field in package.json for pnpm v10.11.0
|
||||||
|
|
||||||
|
## 2025-01-29 - 2.1.0 - feat(CI)
|
||||||
|
Add Continuous Integration workflows for Gitea with Docker-based setup
|
||||||
|
|
||||||
|
- Added new CI workflows for handling both regular and tagged pushes in Gitea.
|
||||||
|
- Integrated security audits and setup tasks using Docker images in the CI workflows.
|
||||||
|
- Ensured that CI includes testing, building, and releasing steps as per tag events.
|
||||||
|
|
||||||
|
## 2025-01-29 - 2.0.39 - fix(package.json)
|
||||||
|
Add pnpm overrides configuration for peek-readable package
|
||||||
|
|
||||||
|
- Added pnpm overrides section in package.json
|
||||||
|
- Specified version 5.3.1 for peek-readable package
|
||||||
|
|
||||||
|
## 2025-01-29 - 2.0.38 - fix(core)
|
||||||
|
Updated dependencies and added assetsHandler instantiation
|
||||||
|
|
||||||
|
- Updated various dependencies in package.json to latest versions.
|
||||||
|
- Added assetsHandler instantiation in TsWatch class to improve functionality.
|
||||||
|
|
||||||
|
## 2024-12-09 - 2.0.37 - fix(core)
|
||||||
|
Refactor TsWatch class to improve website execution handling
|
||||||
|
|
||||||
|
- Removed unnecessary Smartshell instance creation in TsWatch class.
|
||||||
|
- Ensured websiteExecution restarts and website bundle reloads in watcher function.
|
||||||
|
|
||||||
|
## 2024-12-09 - 2.0.36 - fix(dependencies)
|
||||||
|
Update @push.rocks/smartshell dependency version
|
||||||
|
|
||||||
|
- Upgrade @push.rocks/smartshell to version ^3.2.0 from ^3.1.0 in package.json
|
||||||
|
|
||||||
|
## 2024-12-09 - 2.0.35 - fix(core)
|
||||||
|
Fixed website watch mode execution method
|
||||||
|
|
||||||
|
- Replaced direct shell command execution with SmartExecution instance for website mode.
|
||||||
|
- Updated dependency version for @push.rocks/smartshell to ^3.1.0.
|
||||||
|
|
||||||
|
## 2024-12-04 - 2.0.34 - fix(TsWatch)
|
||||||
|
Fix reloading issue for tsfolder changes in element mode.
|
||||||
|
|
||||||
|
- Adjusted the function call from 'this.typedserver.reload()' to 'bundleAndReloadElement()' to ensure proper bundle handling in 'element' mode.
|
||||||
|
|
||||||
|
## 2024-12-04 - 2.0.33 - fix(core)
|
||||||
|
Improve async handling in TsWatch class for element and website modes
|
||||||
|
|
||||||
|
- Ensured proper asynchronous execution for 'element' and 'website' watch modes.
|
||||||
|
- Replaced console log with logger for consistency.
|
||||||
|
|
||||||
|
## 2024-12-04 - 2.0.32 - fix(core)
|
||||||
|
Minor improvements and dependency updates
|
||||||
|
|
||||||
|
- Updated dependencies for improved performance
|
||||||
|
- Refined TypeScript project watching logic
|
||||||
|
|
||||||
|
## 2024-12-04 - 2.0.31 - fix(Watcher)
|
||||||
|
Add missing logger message in Watcher class for start method
|
||||||
|
|
||||||
|
- Added a log message when starting a watcher to track file path being watched
|
||||||
|
|
||||||
|
## 2024-12-04 - 2.0.30 - fix(cli)
|
||||||
|
Fix incorrect watch mode and update npm test command.
|
||||||
|
|
||||||
|
- Updated the npm test command in .vscode/launch.json for streamlined launching.
|
||||||
|
- Corrected the watch mode from 'echoSomething' to 'echo' in test/test.ts.
|
||||||
|
|
||||||
|
## 2024-12-04 - 2.0.29 - fix(core)
|
||||||
|
No changes detected in the codebase.
|
||||||
|
|
||||||
|
|
||||||
|
## 2024-12-04 - 2.0.28 - fix(tswatch)
|
||||||
|
Add logging to notify folder watcher creation and building processes
|
||||||
|
|
||||||
|
- Logging added to notify the creation of folder watchers.
|
||||||
|
- Logging added to indicate the start of the building process for folders.
|
||||||
|
|
||||||
|
## 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.
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
process.env.CLI_CALL = 'true';
|
process.env.CLI_CALL = 'true';
|
||||||
|
|
||||||
import * as tsrun from '@gitzone/tsrun';
|
import * as tsrun from '@git.zone/tsrun';
|
||||||
tsrun.runPath('./cli.child.js', import.meta.url);
|
tsrun.runPath('./cli.child.js', import.meta.url);
|
||||||
|
|||||||
2
dist_ts/index.d.ts
vendored
2
dist_ts/index.d.ts
vendored
@@ -1,2 +0,0 @@
|
|||||||
export * from './tswatch.classes.tswatch.js';
|
|
||||||
export * from './tswatch.cli.js';
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
import * as early from '@pushrocks/early';
|
|
||||||
early.start('tswatch');
|
|
||||||
export * from './tswatch.classes.tswatch.js';
|
|
||||||
export * from './tswatch.cli.js';
|
|
||||||
early.stop();
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssS0FBSyxNQUFNLGtCQUFrQixDQUFDO0FBQzFDLEtBQUssQ0FBQyxLQUFLLENBQUMsU0FBUyxDQUFDLENBQUM7QUFDdkIsY0FBYyw4QkFBOEIsQ0FBQztBQUM3QyxjQUFjLGtCQUFrQixDQUFDO0FBQ2pDLEtBQUssQ0FBQyxJQUFJLEVBQUUsQ0FBQyJ9
|
|
||||||
1
dist_ts/interfaces/index.d.ts
vendored
1
dist_ts/interfaces/index.d.ts
vendored
@@ -1 +0,0 @@
|
|||||||
export * from './interfaces.watchmodes.js';
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
export * from './interfaces.watchmodes.js';
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi90cy9pbnRlcmZhY2VzL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGNBQWMsNEJBQTRCLENBQUMifQ==
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
export declare type TWatchModes = 'test' | 'gitzone_npm' | 'gitzone_service' | 'gitzone_element' | 'gitzone_website' | 'echoSomething';
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
export {};
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW50ZXJmYWNlcy53YXRjaG1vZGVzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vdHMvaW50ZXJmYWNlcy9pbnRlcmZhY2VzLndhdGNobW9kZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9
|
|
||||||
3
dist_ts/tswatch.classes.parcel.d.ts
vendored
3
dist_ts/tswatch.classes.parcel.d.ts
vendored
@@ -1,3 +0,0 @@
|
|||||||
export declare class Parcel {
|
|
||||||
start(): Promise<void>;
|
|
||||||
}
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
"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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHN3YXRja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BQUM7UUFFeEQsZ0RBQWdEO1FBQ2hELDZHQUE2RztRQUM3RyxNQUFNLE1BQU0sR0FBRyxNQUFNLE9BQU8sQ0FBQyxLQUFLLENBQUMsSUFBSSxDQUFDLENBQUM7SUFDM0MsQ0FBQztDQUNGO0FBakNELHdCQWlDQyJ9
|
|
||||||
17
dist_ts/tswatch.classes.tswatch.d.ts
vendored
17
dist_ts/tswatch.classes.tswatch.d.ts
vendored
@@ -1,17 +0,0 @@
|
|||||||
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>;
|
|
||||||
smartserve: plugins.smartserve.SmartServe;
|
|
||||||
constructor(watchmodeArg: interfaces.TWatchModes);
|
|
||||||
/**
|
|
||||||
* starts the TsWatch instance
|
|
||||||
*/
|
|
||||||
start(): Promise<void>;
|
|
||||||
/**
|
|
||||||
* stops the execution of any active Watchers
|
|
||||||
*/
|
|
||||||
stop(): Promise<void>;
|
|
||||||
}
|
|
||||||
@@ -1,82 +0,0 @@
|
|||||||
import * as plugins from './tswatch.plugins.js';
|
|
||||||
import * as paths from './tswatch.paths.js';
|
|
||||||
import './interfaces/index.js';
|
|
||||||
import { Watcher } from './tswatch.classes.watcher.js';
|
|
||||||
export class TsWatch {
|
|
||||||
constructor(watchmodeArg) {
|
|
||||||
this.watcherMap = new plugins.lik.ObjectMap();
|
|
||||||
this.watchmode = watchmodeArg;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* starts the TsWatch instance
|
|
||||||
*/
|
|
||||||
async start() {
|
|
||||||
switch (this.watchmode) {
|
|
||||||
case 'test':
|
|
||||||
this.watcherMap.add(new Watcher({
|
|
||||||
filePathToWatch: paths.cwd,
|
|
||||||
commandToExecute: 'npm run test2',
|
|
||||||
timeout: null,
|
|
||||||
}));
|
|
||||||
break;
|
|
||||||
case 'gitzone_npm':
|
|
||||||
this.watcherMap.add(new Watcher({
|
|
||||||
filePathToWatch: paths.cwd,
|
|
||||||
commandToExecute: 'npm run test',
|
|
||||||
timeout: null,
|
|
||||||
}));
|
|
||||||
break;
|
|
||||||
case 'gitzone_element':
|
|
||||||
// lets create a standard server
|
|
||||||
console.log('bundling TypeScript files to "dist_watch" Note: This is for development only!');
|
|
||||||
const parcel = new plugins.smartparcel.Parcel(plugins.path.join(process.cwd(), './html/index.html'), plugins.path.join(process.cwd(), './dist_watch'), 'index.html');
|
|
||||||
await parcel.watchAndServe();
|
|
||||||
break;
|
|
||||||
case 'gitzone_website':
|
|
||||||
this.watcherMap.add(new Watcher({
|
|
||||||
filePathToWatch: plugins.path.join(paths.cwd, './ts/'),
|
|
||||||
commandToExecute: 'npm run startTs',
|
|
||||||
timeout: null,
|
|
||||||
}));
|
|
||||||
// client directory
|
|
||||||
const parcelWebsite = new plugins.smartparcel.Parcel(plugins.path.join(process.cwd(), './html/index.html'), plugins.path.join(process.cwd(), './dist_serve'), 'bundle.js');
|
|
||||||
await parcelWebsite.watchAndServe();
|
|
||||||
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':
|
|
||||||
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.smartserve) {
|
|
||||||
await this.smartserve.start();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* stops the execution of any active Watchers
|
|
||||||
*/
|
|
||||||
async stop() {
|
|
||||||
if (this.smartserve) {
|
|
||||||
await this.smartserve.stop();
|
|
||||||
}
|
|
||||||
this.watcherMap.forEach(async (watcher) => {
|
|
||||||
await watcher.stop();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHN3YXRjaC5jbGFzc2VzLnRzd2F0Y2guanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy90c3dhdGNoLmNsYXNzZXMudHN3YXRjaC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssT0FBTyxNQUFNLHNCQUFzQixDQUFDO0FBQ2hELE9BQU8sS0FBSyxLQUFLLE1BQU0sb0JBQW9CLENBQUM7QUFDNUMsT0FBNEIsdUJBQXVCLENBQUM7QUFFcEQsT0FBTyxFQUFFLE9BQU8sRUFBRSxNQUFNLDhCQUE4QixDQUFDO0FBRXZELE1BQU0sT0FBTyxPQUFPO0lBS2xCLFlBQVksWUFBb0M7UUFIekMsZUFBVSxHQUFHLElBQUksT0FBTyxDQUFDLEdBQUcsQ0FBQyxTQUFTLEVBQVcsQ0FBQztRQUl2RCxJQUFJLENBQUMsU0FBUyxHQUFHLFlBQVksQ0FBQztJQUNoQyxDQUFDO0lBRUQ7O09BRUc7SUFDSSxLQUFLLENBQUMsS0FBSztRQUNoQixRQUFRLElBQUksQ0FBQyxTQUFTLEVBQUU7WUFDdEIsS0FBSyxNQUFNO2dCQUNULElBQUksQ0FBQyxVQUFVLENBQUMsR0FBRyxDQUNqQixJQUFJLE9BQU8sQ0FBQztvQkFDVixlQUFlLEVBQUUsS0FBSyxDQUFDLEdBQUc7b0JBQzFCLGdCQUFnQixFQU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DRSxNQUFNO1NBQ1Q7UUFDRCxJQUFJLENBQUMsVUFBVSxDQUFDLE9BQU8sQ0FBQyxLQUFLLEVBQUUsT0FBTyxFQUFFLEVBQUU7WUFDeEMsTUFBTSxPQUFPLENBQUMsS0FBSyxFQUFFLENBQUM7UUFDeEIsQ0FBQyxDQUFDLENBQUM7UUFDSCxJQUFJLElBQUksQ0FBQyxVQUFVLEVBQUU7WUFDbkIsTUFBTSxJQUFJLENBQUMsVUFBVSxDQUFDLEtBQUssRUFBRSxDQUFDO1NBQy9CO0lBQ0gsQ0FBQztJQUVEOztPQUVHO0lBQ0ksS0FBSyxDQUFDLElBQUk7UUFDZixJQUFJLElBQUksQ0FBQyxVQUFVLEVBQUU7WUFDbkIsTUFBTSxJQUFJLENBQUMsVUFBVSxDQUFDLElBQUksRUFBRSxDQUFDO1NBQzlCO1FBQ0QsSUFBSSxDQUFDLFVBQVUsQ0FBQyxPQUFPLENBQUMsS0FBSyxFQUFFLE9BQU8sRUFBRSxFQUFFO1lBQ3hDLE1BQU0sT0FBTyxDQUFDLElBQUksRUFBRSxDQUFDO1FBQ3ZCLENBQUMsQ0FBQyxDQUFDO0lBQ0wsQ0FBQztDQUNGIn0=
|
|
||||||
35
dist_ts/tswatch.classes.watcher.d.ts
vendored
35
dist_ts/tswatch.classes.watcher.d.ts
vendored
@@ -1,35 +0,0 @@
|
|||||||
export declare type TCommandFunction = () => Promise<void>;
|
|
||||||
export interface IWatcherConstructorOptions {
|
|
||||||
filePathToWatch: string;
|
|
||||||
commandToExecute: string | TCommandFunction;
|
|
||||||
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>;
|
|
||||||
}
|
|
||||||
@@ -1,84 +0,0 @@
|
|||||||
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 (typeof this.options.commandToExecute === 'string') {
|
|
||||||
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('cannot run execution task');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHN3YXRjaC5jbGFzc2VzLndhdGNoZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy90c3dhdGNoLmNsYXNzZXMud2F0Y2hlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssT0FB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UksRUFBRSxDQUFDO1NBQzlCO0lBQ0gsQ0FBQztDQUNGIn0=
|
|
||||||
1
dist_ts/tswatch.cli.d.ts
vendored
1
dist_ts/tswatch.cli.d.ts
vendored
@@ -1 +0,0 @@
|
|||||||
export declare const runCli: () => Promise<void>;
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
import * as plugins from './tswatch.plugins.js';
|
|
||||||
import './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.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) => {
|
|
||||||
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('gitzone_website');
|
|
||||||
await tsWatch.start();
|
|
||||||
});
|
|
||||||
export const runCli = async () => {
|
|
||||||
tswatchCli.startParse();
|
|
||||||
};
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ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UFBSSxFQUFFO0lBQy9CLFVBQVUsQ0FBQyxVQUFVLEVBQUUsQ0FBQztBQUMxQixDQUFDLENBQUMifQ==
|
|
||||||
2
dist_ts/tswatch.logging.d.ts
vendored
2
dist_ts/tswatch.logging.d.ts
vendored
@@ -1,2 +0,0 @@
|
|||||||
import * as plugins from './tswatch.plugins.js';
|
|
||||||
export declare const logger: plugins.smartlog.Smartlog;
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
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
1
dist_ts/tswatch.paths.d.ts
vendored
@@ -1 +0,0 @@
|
|||||||
export declare const cwd: string;
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
import './tswatch.plugins.js';
|
|
||||||
export const cwd = process.cwd();
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHN3YXRjaC5wYXRocy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3Rzd2F0Y2gucGF0aHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBeUIsc0JBQXNCLENBQUM7QUFFaEQsTUFBTSxDQUFDLE1BQU0sR0FBRyxHQUFHLE9BQU8sQ0FBQyxHQUFHLEVBQUUsQ0FBQyJ9
|
|
||||||
13
dist_ts/tswatch.plugins.d.ts
vendored
13
dist_ts/tswatch.plugins.d.ts
vendored
@@ -1,13 +0,0 @@
|
|||||||
import * as path from 'path';
|
|
||||||
export { path };
|
|
||||||
import * as lik from '@pushrocks/lik';
|
|
||||||
import * as smartchok from '@pushrocks/smartchok';
|
|
||||||
import * as smartcli from '@pushrocks/smartcli';
|
|
||||||
import * as smartdelay from '@pushrocks/smartdelay';
|
|
||||||
import * as smartlog from '@pushrocks/smartlog';
|
|
||||||
import * as smartlogDestinationLocal from '@pushrocks/smartlog-destination-local';
|
|
||||||
import * as smartparcel from '@pushrocks/smartparcel';
|
|
||||||
import * as smartserve from '@pushrocks/smartserve';
|
|
||||||
import * as smartshell from '@pushrocks/smartshell';
|
|
||||||
import * as taskbuffer from '@pushrocks/taskbuffer';
|
|
||||||
export { lik, smartchok, smartcli, smartdelay, smartlog, smartlogDestinationLocal, smartparcel, smartserve, smartshell, taskbuffer, };
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
import * as path from 'path';
|
|
||||||
export { path };
|
|
||||||
// @pushrocks scope
|
|
||||||
import * as lik from '@pushrocks/lik';
|
|
||||||
import * as smartchok from '@pushrocks/smartchok';
|
|
||||||
import * as smartcli from '@pushrocks/smartcli';
|
|
||||||
import * as smartdelay from '@pushrocks/smartdelay';
|
|
||||||
import * as smartlog from '@pushrocks/smartlog';
|
|
||||||
import * as smartlogDestinationLocal from '@pushrocks/smartlog-destination-local';
|
|
||||||
import * as smartparcel from '@pushrocks/smartparcel';
|
|
||||||
import * as smartserve from '@pushrocks/smartserve';
|
|
||||||
import * as smartshell from '@pushrocks/smartshell';
|
|
||||||
import * as taskbuffer from '@pushrocks/taskbuffer';
|
|
||||||
export { lik, smartchok, smartcli, smartdelay, smartlog, smartlogDestinationLocal, smartparcel, smartserve, smartshell, taskbuffer, };
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHN3YXRjaC5wbHVnaW5zLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvdHN3YXRjaC5wbHVnaW5zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxJQUFJLE1BQU0sTUFBTSxDQUFDO0FBQzdCLE9BQU8sRUFBRSxJQUFJLEVBQUUsQ0FBQztBQUVoQixtQkFBbUI7QUFDbkIsT0FBTyxLQUFLLEdBQUcsTUFBTSxnQkFBZ0IsQ0FBQztBQUN0QyxPQUFPLEtBQUssU0FBUyxNQUFNLHNCQUFzQixDQUFDO0FBQ2xELE9BQU8sS0FBSyxRQUFRLE1BQU0scUJBQXFCLENBQUM7QUFDaEQsT0FBTyxLQUFLLFVBQVUsTUFBTSx1QkFBdUIsQ0FBQztBQUNwRCxPQUFPLEtBQUssUUFBUSxNQUFNLHFCQUFxQixDQUFDO0FBQ2hELE9BQU8sS0FBSyx3QkFBd0IsTUFBTSx1Q0FBdUMsQ0FBQztBQUNsRixPQUFPLEtBQUssV0FBVyxNQUFNLHdCQUF3QixDQUFDO0FBQ3RELE9BQU8sS0FBSyxVQUFVLE1BQU0sdUJBQXVCLENBQUM7QUFDcEQsT0FBTyxLQUFLLFVBQVUsTUFBTSx1QkFBdUIsQ0FBQztBQUNwRCxPQUFPLEtBQUssVUFBVSxNQUFNLHVCQUF1QixDQUFDO0FBRXBELE9BQU8sRUFDTCxHQUFHLEVBQ0gsU0FBUyxFQUNULFFBQVEsRUFDUixVQUFVLEVBQ1YsUUFBUSxFQUNSLHdCQUF3QixFQUN4QixXQUFXLEVBQ1gsVUFBVSxFQUNWLFVBQVUsRUFDVixVQUFVLEdBQ1gsQ0FBQyJ9
|
|
||||||
@@ -1,17 +1,48 @@
|
|||||||
{
|
{
|
||||||
"npmci": {
|
"@git.zone/cli": {
|
||||||
"npmGlobalTools": [],
|
|
||||||
"npmAccessLevel": "public"
|
|
||||||
},
|
|
||||||
"gitzone": {
|
|
||||||
"projectType": "npm",
|
"projectType": "npm",
|
||||||
"module": {
|
"module": {
|
||||||
"githost": "gitlab.com",
|
"githost": "code.foss.global",
|
||||||
"gitscope": "gitzone",
|
"gitscope": "git.zone",
|
||||||
"gitrepo": "tswatch",
|
"gitrepo": "tswatch",
|
||||||
"shortDescription": "watch typescript projects during development",
|
"shortDescription": "watch typescript projects during development",
|
||||||
"npmPackagename": "@gitzone/tswatch",
|
"npmPackagename": "@git.zone/tswatch",
|
||||||
"license": "MIT"
|
"license": "MIT",
|
||||||
}
|
"description": "A development tool for automatically watching and re-compiling TypeScript projects upon detecting file changes, enhancing developer workflows.",
|
||||||
|
"keywords": [
|
||||||
|
"TypeScript",
|
||||||
|
"development",
|
||||||
|
"watcher",
|
||||||
|
"automation",
|
||||||
|
"CLI",
|
||||||
|
"build",
|
||||||
|
"npm",
|
||||||
|
"web development",
|
||||||
|
"service development",
|
||||||
|
"project monitoring",
|
||||||
|
"recompiling",
|
||||||
|
"testing",
|
||||||
|
"integration",
|
||||||
|
"continuous development",
|
||||||
|
"tooling",
|
||||||
|
"build automation",
|
||||||
|
"live reloading",
|
||||||
|
"node.js",
|
||||||
|
"development server"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"release": {
|
||||||
|
"registries": [
|
||||||
|
"https://verdaccio.lossless.digital",
|
||||||
|
"https://registry.npmjs.org"
|
||||||
|
],
|
||||||
|
"accessLevel": "public"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@git.zone/tsdoc": {
|
||||||
|
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
|
||||||
|
},
|
||||||
|
"@ship.zone/szci": {
|
||||||
|
"npmGlobalTools": []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
17765
package-lock.json
generated
17765
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
84
package.json
84
package.json
@@ -1,10 +1,11 @@
|
|||||||
{
|
{
|
||||||
"name": "@gitzone/tswatch",
|
"name": "@git.zone/tswatch",
|
||||||
"version": "1.0.64",
|
"version": "3.2.3",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "watch typescript projects during development",
|
"description": "A development tool for automatically watching and re-compiling TypeScript projects upon detecting file changes, enhancing developer workflows.",
|
||||||
"main": "dist_ts/index.js",
|
"exports": {
|
||||||
"typings": "dist_ts/index.d.ts",
|
".": "./dist_ts/index.js"
|
||||||
|
},
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"author": "Lossless GmbH",
|
"author": "Lossless GmbH",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
@@ -13,27 +14,31 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(tstest test/ --web)",
|
"test": "(tstest test/ --web)",
|
||||||
"build": "(tsbuild --web --skiplibcheck --allowimplicitany)"
|
"build": "(tsbuild --web --allowimplicitany)",
|
||||||
|
"buildDocs": "tsdoc"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.56",
|
"@git.zone/tsbuild": "^4.1.2",
|
||||||
"@gitzone/tstest": "^1.0.69",
|
"@git.zone/tstest": "^3.1.8",
|
||||||
"@pushrocks/tapbundle": "^5.0.2",
|
"@types/node": "^25.2.1"
|
||||||
"@types/node": "^17.0.21"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@gitzone/tsbundle": "^1.0.99",
|
"@api.global/typedserver": "^8.3.0",
|
||||||
"@gitzone/tsrun": "^1.2.31",
|
"@git.zone/tsbundle": "^2.9.0",
|
||||||
"@pushrocks/early": "^3.0.3",
|
"@git.zone/tsrun": "^2.0.1",
|
||||||
"@pushrocks/lik": "^5.0.4",
|
"@push.rocks/early": "^4.0.4",
|
||||||
"@pushrocks/smartchok": "^1.0.23",
|
"@push.rocks/lik": "^6.2.2",
|
||||||
"@pushrocks/smartcli": "^3.0.14",
|
"@push.rocks/npmextra": "^5.3.3",
|
||||||
"@pushrocks/smartdelay": "^2.0.13",
|
"@push.rocks/smartcli": "^4.0.20",
|
||||||
"@pushrocks/smartlog": "^2.0.44",
|
"@push.rocks/smartdelay": "^3.0.5",
|
||||||
"@pushrocks/smartlog-destination-local": "^8.0.8",
|
"@push.rocks/smartexit": "2.0.0",
|
||||||
"@pushrocks/smartserve": "^2.0.0",
|
"@push.rocks/smartfs": "^1.3.1",
|
||||||
"@pushrocks/smartshell": "^2.0.30",
|
"@push.rocks/smartinteract": "^2.0.16",
|
||||||
"@pushrocks/taskbuffer": "^2.1.17"
|
"@push.rocks/smartlog": "^3.1.10",
|
||||||
|
"@push.rocks/smartlog-destination-local": "^9.0.2",
|
||||||
|
"@push.rocks/smartshell": "^3.3.3",
|
||||||
|
"@push.rocks/smartwatch": "^6.3.0",
|
||||||
|
"@push.rocks/taskbuffer": "^4.2.0"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"ts/**/*",
|
"ts/**/*",
|
||||||
@@ -49,5 +54,38 @@
|
|||||||
],
|
],
|
||||||
"browserslist": [
|
"browserslist": [
|
||||||
"last 1 chrome versions"
|
"last 1 chrome versions"
|
||||||
]
|
],
|
||||||
|
"keywords": [
|
||||||
|
"TypeScript",
|
||||||
|
"development",
|
||||||
|
"watcher",
|
||||||
|
"automation",
|
||||||
|
"CLI",
|
||||||
|
"build",
|
||||||
|
"npm",
|
||||||
|
"web development",
|
||||||
|
"service development",
|
||||||
|
"project monitoring",
|
||||||
|
"recompiling",
|
||||||
|
"testing",
|
||||||
|
"integration",
|
||||||
|
"continuous development",
|
||||||
|
"tooling",
|
||||||
|
"build automation",
|
||||||
|
"live reloading",
|
||||||
|
"node.js",
|
||||||
|
"development server"
|
||||||
|
],
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://code.foss.global/git.zone/tswatch.git"
|
||||||
|
},
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://code.foss.global/git.zone/tswatch/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://code.foss.global/git.zone/tswatch#readme",
|
||||||
|
"pnpm": {
|
||||||
|
"overrides": {}
|
||||||
|
},
|
||||||
|
"packageManager": "pnpm@10.11.0+sha512.6540583f41cc5f628eb3d9773ecee802f4f9ef9923cc45b69890fb47991d4b092964694ec3a4f738a420c918a333062c8b925d312f42e4f0c263eb603551f977"
|
||||||
}
|
}
|
||||||
|
|||||||
9324
pnpm-lock.yaml
generated
Normal file
9324
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
94
readme.hints.md
Normal file
94
readme.hints.md
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
# tswatch Project Hints
|
||||||
|
|
||||||
|
## Core Architecture (v3.x - Config-Driven)
|
||||||
|
|
||||||
|
tswatch is now a config-driven TypeScript file watcher. Configuration is read from `npmextra.json` under the key `@git.zone/tswatch`.
|
||||||
|
|
||||||
|
### Key Classes
|
||||||
|
|
||||||
|
- **TsWatch**: Main orchestrator class, accepts `ITswatchConfig`
|
||||||
|
- **Watcher**: Handles individual file watching with debouncing and restart modes
|
||||||
|
- **ConfigHandler**: Loads and manages configuration from npmextra.json
|
||||||
|
- **TswatchInit**: Interactive wizard for creating configuration
|
||||||
|
|
||||||
|
### Configuration Structure
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"@git.zone/tswatch": {
|
||||||
|
"watchers": [
|
||||||
|
{
|
||||||
|
"name": "backend",
|
||||||
|
"watch": "./ts/**/*",
|
||||||
|
"command": "npm run startTs",
|
||||||
|
"restart": true,
|
||||||
|
"debounce": 300,
|
||||||
|
"runOnStart": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"server": {
|
||||||
|
"enabled": true,
|
||||||
|
"port": 3002,
|
||||||
|
"serveDir": "./dist_watch/",
|
||||||
|
"liveReload": true
|
||||||
|
},
|
||||||
|
"bundles": [
|
||||||
|
{
|
||||||
|
"name": "frontend",
|
||||||
|
"from": "./html/index.ts",
|
||||||
|
"to": "./dist_watch/bundle.js",
|
||||||
|
"watchPatterns": ["./ts_web/**/*"],
|
||||||
|
"triggerReload": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"preset": "element"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Available Presets
|
||||||
|
|
||||||
|
- **npm**: Watch ts/ and test/, run `npm test`
|
||||||
|
- **test**: Watch ts/ and test/, run `npm run test2`
|
||||||
|
- **service**: Watch ts/, run `npm run startTs` with restart
|
||||||
|
- **element**: Dev server on 3002, bundle ts_web, watch html
|
||||||
|
- **website**: Full stack with backend restart + frontend bundling + assets
|
||||||
|
|
||||||
|
### CLI Commands
|
||||||
|
|
||||||
|
- `tswatch` - Run with config (or launch wizard if no config)
|
||||||
|
- `tswatch init` - Force run the configuration wizard
|
||||||
|
|
||||||
|
## Key Implementation Details
|
||||||
|
|
||||||
|
- Uses `@push.rocks/smartwatch` (v6.x) for file watching - class is `Smartwatch`
|
||||||
|
- Uses `@push.rocks/smartfs` (v1.x) for filesystem operations
|
||||||
|
- Uses `@push.rocks/npmextra` for reading npmextra.json config
|
||||||
|
- Uses `@push.rocks/smartinteract` for the init wizard
|
||||||
|
- Uses `@git.zone/tsbundle` for bundling with esbuild
|
||||||
|
- Uses `@api.global/typedserver` for development server
|
||||||
|
|
||||||
|
### Watcher Features
|
||||||
|
|
||||||
|
- **Debouncing**: Configurable delay before executing (default: 300ms)
|
||||||
|
- **Restart mode**: Kill previous process before restarting (configurable)
|
||||||
|
- **Named watchers**: All watchers have names for clear logging
|
||||||
|
- **Multiple watch patterns**: Can watch multiple glob patterns
|
||||||
|
|
||||||
|
### Server Features
|
||||||
|
|
||||||
|
- Port configurable (default: 3002)
|
||||||
|
- CORS enabled
|
||||||
|
- Gzip compression
|
||||||
|
- Live reload injection (configurable)
|
||||||
|
- SPA fallback support
|
||||||
|
- No-cache headers (prevents browser caching during development)
|
||||||
|
|
||||||
|
## Project Structure
|
||||||
|
|
||||||
|
- `ts/tswatch.classes.tswatch.ts` - Main TsWatch class
|
||||||
|
- `ts/tswatch.classes.watcher.ts` - Watcher class with debounce/restart
|
||||||
|
- `ts/tswatch.classes.confighandler.ts` - Config loading
|
||||||
|
- `ts/tswatch.init.ts` - Interactive init wizard
|
||||||
|
- `ts/tswatch.cli.ts` - CLI entry point
|
||||||
|
- `ts/interfaces/interfaces.config.ts` - Type definitions
|
||||||
430
readme.md
430
readme.md
@@ -1,39 +1,411 @@
|
|||||||
# @gitzone/tswatch
|
# @git.zone/tswatch
|
||||||
watch typescript projects during development
|
|
||||||
|
|
||||||
## Availabililty and Links
|
A powerful, config-driven TypeScript file watcher that automatically recompiles and executes your project when files change. Built for modern TypeScript development with zero-config presets and deep customization options.
|
||||||
* [npmjs.org (npm package)](https://www.npmjs.com/package/@gitzone/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
|
## Issue Reporting and Security
|
||||||
|
|
||||||
Status Category | Status Badge
|
For reporting bugs, issues, or security vulnerabilities, please visit [community.foss.global/](https://community.foss.global/). This is the central community hub for all issue reporting. Developers who sign and comply with our contribution agreement and go through identification can also get a [code.foss.global/](https://code.foss.global/) account to submit Pull Requests directly.
|
||||||
-- | --
|
|
||||||
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
|
## ✨ Features
|
||||||
|
|
||||||
Use TypeScript for best in class intellisense
|
- 🔄 **Config-driven architecture** - Define watchers, bundles, and dev server in `npmextra.json`
|
||||||
|
- ⚡ **Zero-config presets** - Get started instantly with `npm`, `element`, `service`, `website`, and `test` presets
|
||||||
|
- 🧙 **Interactive wizard** - Run `tswatch init` to generate configuration interactively
|
||||||
|
- 🌐 **Built-in dev server** - Live reload, CORS, compression, SPA fallback out of the box
|
||||||
|
- 📦 **Smart bundling** - TypeScript, HTML, and assets with esbuild integration
|
||||||
|
- 🔁 **Debounced execution** - Configurable debounce prevents command spam
|
||||||
|
- 🛑 **Process management** - Automatic restart or queue mode for long-running commands
|
||||||
|
- 🎯 **Glob patterns** - Watch any files with flexible pattern matching
|
||||||
|
|
||||||
## Contribution
|
## 📦 Installation
|
||||||
|
|
||||||
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). :)
|
```bash
|
||||||
|
# Global installation (recommended for CLI usage)
|
||||||
|
pnpm install -g @git.zone/tswatch
|
||||||
|
|
||||||
For further information read the linked docs at the top of this readme.
|
# As a dev dependency
|
||||||
|
pnpm install --save-dev @git.zone/tswatch
|
||||||
|
```
|
||||||
|
|
||||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
## 🚀 Quick Start
|
||||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
|
||||||
|
|
||||||
[](https://maintainedby.lossless.com)
|
### Using the Wizard
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Run the interactive wizard to create your configuration
|
||||||
|
tswatch init
|
||||||
|
```
|
||||||
|
|
||||||
|
The wizard will guide you through creating a `npmextra.json` configuration with your chosen preset or custom watchers.
|
||||||
|
|
||||||
|
### Using Presets
|
||||||
|
|
||||||
|
If you already have a configuration, just run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
tswatch
|
||||||
|
```
|
||||||
|
|
||||||
|
This reads your config from `npmextra.json` under the `@git.zone/tswatch` key and starts watching.
|
||||||
|
|
||||||
|
## ⚙️ Configuration
|
||||||
|
|
||||||
|
tswatch uses `npmextra.json` for configuration. Add your config under the `@git.zone/tswatch` key:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"@git.zone/tswatch": {
|
||||||
|
"preset": "npm"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Available Presets
|
||||||
|
|
||||||
|
| Preset | Description |
|
||||||
|
|--------|-------------|
|
||||||
|
| `npm` | Watch `ts/` and `test/`, run `npm test` on changes |
|
||||||
|
| `test` | Watch `ts/` and `test/`, run `npm run test2` on changes |
|
||||||
|
| `service` | Watch `ts/`, restart `npm run startTs` (ideal for backend services) |
|
||||||
|
| `element` | Dev server on port 3002 + bundling for web components |
|
||||||
|
| `website` | Full-stack: backend + frontend bundling + asset processing |
|
||||||
|
|
||||||
|
### Full Configuration Schema
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"@git.zone/tswatch": {
|
||||||
|
"preset": "element",
|
||||||
|
|
||||||
|
"server": {
|
||||||
|
"enabled": true,
|
||||||
|
"port": 3002,
|
||||||
|
"serveDir": "./dist_watch/",
|
||||||
|
"liveReload": true
|
||||||
|
},
|
||||||
|
|
||||||
|
"bundles": [
|
||||||
|
{
|
||||||
|
"name": "main-bundle",
|
||||||
|
"from": "./ts_web/index.ts",
|
||||||
|
"to": "./dist_watch/bundle.js",
|
||||||
|
"watchPatterns": ["./ts_web/**/*"],
|
||||||
|
"triggerReload": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "html",
|
||||||
|
"from": "./html/index.html",
|
||||||
|
"to": "./dist_watch/index.html",
|
||||||
|
"watchPatterns": ["./html/**/*"],
|
||||||
|
"triggerReload": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
"watchers": [
|
||||||
|
{
|
||||||
|
"name": "backend-build",
|
||||||
|
"watch": "./ts/**/*",
|
||||||
|
"command": "npm run build",
|
||||||
|
"restart": false,
|
||||||
|
"debounce": 300,
|
||||||
|
"runOnStart": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "tests",
|
||||||
|
"watch": ["./ts/**/*", "./test/**/*"],
|
||||||
|
"command": "npm test",
|
||||||
|
"restart": true,
|
||||||
|
"debounce": 300,
|
||||||
|
"runOnStart": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Configuration Options
|
||||||
|
|
||||||
|
#### `ITswatchConfig`
|
||||||
|
|
||||||
|
| Option | Type | Description |
|
||||||
|
|--------|------|-------------|
|
||||||
|
| `preset` | `string` | Use a preset: `npm`, `test`, `service`, `element`, `website` |
|
||||||
|
| `watchers` | `IWatcherConfig[]` | Array of watcher configurations |
|
||||||
|
| `server` | `IServerConfig` | Development server configuration |
|
||||||
|
| `bundles` | `IBundleConfig[]` | Bundle configurations |
|
||||||
|
|
||||||
|
#### `IWatcherConfig`
|
||||||
|
|
||||||
|
| Option | Type | Default | Description |
|
||||||
|
|--------|------|---------|-------------|
|
||||||
|
| `name` | `string` | *required* | Name for logging purposes |
|
||||||
|
| `watch` | `string \| string[]` | *required* | Glob pattern(s) to watch |
|
||||||
|
| `command` | `string` | - | Shell command to execute on changes |
|
||||||
|
| `restart` | `boolean` | `true` | Kill previous process before restarting |
|
||||||
|
| `debounce` | `number` | `300` | Debounce delay in milliseconds |
|
||||||
|
| `runOnStart` | `boolean` | `true` | Run the command immediately on start |
|
||||||
|
|
||||||
|
#### `IServerConfig`
|
||||||
|
|
||||||
|
| Option | Type | Default | Description |
|
||||||
|
|--------|------|---------|-------------|
|
||||||
|
| `enabled` | `boolean` | *required* | Whether the server is enabled |
|
||||||
|
| `port` | `number` | `3002` | Server port |
|
||||||
|
| `serveDir` | `string` | `./dist_watch/` | Directory to serve |
|
||||||
|
| `liveReload` | `boolean` | `true` | Inject live reload script |
|
||||||
|
|
||||||
|
#### `IBundleConfig`
|
||||||
|
|
||||||
|
| Option | Type | Default | Description |
|
||||||
|
|--------|------|---------|-------------|
|
||||||
|
| `name` | `string` | - | Name for logging purposes |
|
||||||
|
| `from` | `string` | *required* | Entry point file |
|
||||||
|
| `to` | `string` | *required* | Output file |
|
||||||
|
| `watchPatterns` | `string[]` | - | Additional patterns to watch |
|
||||||
|
| `triggerReload` | `boolean` | `true` | Trigger server reload after bundling |
|
||||||
|
|
||||||
|
## 🛠️ CLI Commands
|
||||||
|
|
||||||
|
### `tswatch`
|
||||||
|
|
||||||
|
Runs with configuration from `npmextra.json`. If no config exists, launches the interactive wizard.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
tswatch
|
||||||
|
```
|
||||||
|
|
||||||
|
### `tswatch init`
|
||||||
|
|
||||||
|
Force-run the configuration wizard (creates or overwrites existing config).
|
||||||
|
|
||||||
|
```bash
|
||||||
|
tswatch init
|
||||||
|
```
|
||||||
|
|
||||||
|
## 💻 Programmatic API
|
||||||
|
|
||||||
|
### Basic Usage with Config
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { TsWatch } from '@git.zone/tswatch';
|
||||||
|
|
||||||
|
// Create TsWatch with inline configuration
|
||||||
|
const watcher = new TsWatch({
|
||||||
|
watchers: [
|
||||||
|
{
|
||||||
|
name: 'my-watcher',
|
||||||
|
watch: './src/**/*',
|
||||||
|
command: 'npm run build',
|
||||||
|
restart: true,
|
||||||
|
debounce: 300,
|
||||||
|
runOnStart: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
await watcher.start();
|
||||||
|
|
||||||
|
// Later: stop watching
|
||||||
|
await watcher.stop();
|
||||||
|
```
|
||||||
|
|
||||||
|
### Load from Config File
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { TsWatch } from '@git.zone/tswatch';
|
||||||
|
|
||||||
|
// Load configuration from npmextra.json
|
||||||
|
const watcher = TsWatch.fromConfig();
|
||||||
|
|
||||||
|
if (watcher) {
|
||||||
|
await watcher.start();
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Using ConfigHandler
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { ConfigHandler } from '@git.zone/tswatch';
|
||||||
|
|
||||||
|
const configHandler = new ConfigHandler();
|
||||||
|
|
||||||
|
// Check if config exists
|
||||||
|
if (configHandler.hasConfig()) {
|
||||||
|
const config = configHandler.loadConfig();
|
||||||
|
console.log(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get available presets
|
||||||
|
const presets = configHandler.getPresetNames();
|
||||||
|
console.log(presets); // ['npm', 'test', 'service', 'element', 'website']
|
||||||
|
|
||||||
|
// Get a specific preset
|
||||||
|
const npmPreset = configHandler.getPreset('npm');
|
||||||
|
```
|
||||||
|
|
||||||
|
### Using Watcher Directly
|
||||||
|
|
||||||
|
For more granular control, use the `Watcher` class:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { Watcher } from '@git.zone/tswatch';
|
||||||
|
|
||||||
|
// Create from config object
|
||||||
|
const watcher = Watcher.fromConfig({
|
||||||
|
name: 'my-watcher',
|
||||||
|
watch: ['./src/**/*', './lib/**/*'],
|
||||||
|
command: 'npm run compile',
|
||||||
|
restart: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
await watcher.start();
|
||||||
|
```
|
||||||
|
|
||||||
|
### Using Function Callbacks
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { Watcher } from '@git.zone/tswatch';
|
||||||
|
|
||||||
|
const watcher = new Watcher({
|
||||||
|
name: 'custom-handler',
|
||||||
|
filePathToWatch: './src/**/*',
|
||||||
|
functionToCall: async () => {
|
||||||
|
console.log('Files changed! Running custom logic...');
|
||||||
|
// Your custom build/test/deploy logic here
|
||||||
|
},
|
||||||
|
debounce: 500,
|
||||||
|
runOnStart: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
await watcher.start();
|
||||||
|
```
|
||||||
|
|
||||||
|
## 📁 Project Structures
|
||||||
|
|
||||||
|
### NPM Package / Node.js Library
|
||||||
|
|
||||||
|
```
|
||||||
|
project/
|
||||||
|
├── ts/ # TypeScript source files
|
||||||
|
├── test/ # Test files
|
||||||
|
├── package.json # With "test" script
|
||||||
|
└── npmextra.json # tswatch config
|
||||||
|
```
|
||||||
|
|
||||||
|
Config:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"@git.zone/tswatch": {
|
||||||
|
"preset": "npm"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Backend Service
|
||||||
|
|
||||||
|
```
|
||||||
|
project/
|
||||||
|
├── ts/ # TypeScript source files
|
||||||
|
├── package.json # With "startTs" script
|
||||||
|
└── npmextra.json
|
||||||
|
```
|
||||||
|
|
||||||
|
Config:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"@git.zone/tswatch": {
|
||||||
|
"preset": "service"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Web Component / Element
|
||||||
|
|
||||||
|
```
|
||||||
|
project/
|
||||||
|
├── ts/ # Backend TypeScript (optional)
|
||||||
|
├── ts_web/ # Frontend TypeScript
|
||||||
|
├── html/
|
||||||
|
│ ├── index.ts # Web entry point
|
||||||
|
│ └── index.html
|
||||||
|
├── dist_watch/ # Output (auto-created)
|
||||||
|
└── npmextra.json
|
||||||
|
```
|
||||||
|
|
||||||
|
Config:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"@git.zone/tswatch": {
|
||||||
|
"preset": "element"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Access your project at `http://localhost:3002`
|
||||||
|
|
||||||
|
### Full-Stack Website
|
||||||
|
|
||||||
|
```
|
||||||
|
project/
|
||||||
|
├── ts/ # Backend TypeScript
|
||||||
|
├── ts_web/ # Frontend TypeScript
|
||||||
|
│ └── index.ts
|
||||||
|
├── html/
|
||||||
|
│ └── index.html
|
||||||
|
├── assets/ # Static assets
|
||||||
|
├── dist_serve/ # Output
|
||||||
|
└── npmextra.json
|
||||||
|
```
|
||||||
|
|
||||||
|
Config:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"@git.zone/tswatch": {
|
||||||
|
"preset": "website"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## 🌐 Development Server
|
||||||
|
|
||||||
|
The built-in development server (enabled in `element` and `website` presets) features:
|
||||||
|
|
||||||
|
- **Live Reload** - Automatically refreshes browser on changes
|
||||||
|
- **No Caching** - Prevents browser caching during development (sends `Cache-Control: no-store, no-cache` headers)
|
||||||
|
- **CORS** - Cross-origin requests enabled
|
||||||
|
- **Compression** - Gzip compression for faster loading
|
||||||
|
- **SPA Fallback** - Single-page application routing support
|
||||||
|
- **Security Headers** - Cross-origin isolation headers
|
||||||
|
|
||||||
|
Default configuration:
|
||||||
|
- **Port**: 3002
|
||||||
|
- **Serve Directory**: `./dist_watch/`
|
||||||
|
- **Live Reload**: Enabled
|
||||||
|
|
||||||
|
## 🔧 Configuration Tips
|
||||||
|
|
||||||
|
1. **Use presets for common workflows** - They're battle-tested and cover most use cases
|
||||||
|
2. **Customize with explicit config** - Override preset defaults by adding explicit `watchers`, `bundles`, or `server` config
|
||||||
|
3. **Debounce wisely** - Default 300ms works well; increase for slower builds
|
||||||
|
4. **Use `restart: false`** for one-shot commands (like builds) and `restart: true` for long-running processes (like servers)
|
||||||
|
|
||||||
|
## License and Legal Information
|
||||||
|
|
||||||
|
This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [LICENSE](./LICENSE) file.
|
||||||
|
|
||||||
|
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
### Trademarks
|
||||||
|
|
||||||
|
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH or third parties, and are not included within the scope of the MIT license granted herein.
|
||||||
|
|
||||||
|
Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines or the guidelines of the respective third-party owners, and any usage must be approved in writing. Third-party trademarks used herein are the property of their respective owners and used only in a descriptive manner, e.g. for an implementation of an API or similar.
|
||||||
|
|
||||||
|
### Company Information
|
||||||
|
|
||||||
|
Task Venture Capital GmbH
|
||||||
|
Registered at District Court Bremen HRB 35230 HB, Germany
|
||||||
|
|
||||||
|
For any legal inquiries or further information, please contact us via email at hello@task.vc.
|
||||||
|
|
||||||
|
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
|
||||||
|
|||||||
107
test/test.ts
107
test/test.ts
@@ -1,20 +1,105 @@
|
|||||||
// tslint:disable-next-line: no-implicit-dependencies
|
import { expect, tap } from '@git.zone/tstest/tapbundle';
|
||||||
import { expect, expectAsync, tap } from '@pushrocks/tapbundle';
|
|
||||||
import * as tswatch from '../ts/index.js';
|
import * as tswatch from '../ts/index.js';
|
||||||
|
|
||||||
let testTsWatchInstance: tswatch.TsWatch;
|
// ============================================
|
||||||
|
// ConfigHandler Tests
|
||||||
|
// ============================================
|
||||||
|
|
||||||
tap.test('should create a valid TsWatch instance', async () => {
|
tap.test('ConfigHandler: should return all preset names', async () => {
|
||||||
testTsWatchInstance = new tswatch.TsWatch('echoSomething');
|
const configHandler = new tswatch.ConfigHandler();
|
||||||
|
const presetNames = configHandler.getPresetNames();
|
||||||
|
expect(presetNames).toContain('npm');
|
||||||
|
expect(presetNames).toContain('test');
|
||||||
|
expect(presetNames).toContain('service');
|
||||||
|
expect(presetNames).toContain('element');
|
||||||
|
expect(presetNames).toContain('website');
|
||||||
|
expect(presetNames.length).toEqual(5);
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should start the tswatch instance', async () => {
|
tap.test('ConfigHandler: should return npm preset with watchers', async () => {
|
||||||
await testTsWatchInstance.start();
|
const configHandler = new tswatch.ConfigHandler();
|
||||||
|
const preset = configHandler.getPreset('npm');
|
||||||
|
expect(preset).toBeTruthy();
|
||||||
|
expect(preset.watchers).toBeTruthy();
|
||||||
|
expect(preset.watchers.length).toBeGreaterThan(0);
|
||||||
|
expect(preset.watchers[0].name).toEqual('npm-test');
|
||||||
|
expect(preset.watchers[0].command).toEqual('npm run test');
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should stop the instance', async (tools) => {
|
tap.test('ConfigHandler: should return element preset with server', async () => {
|
||||||
tools.delayFor(2000);
|
const configHandler = new tswatch.ConfigHandler();
|
||||||
testTsWatchInstance.stop();
|
const preset = configHandler.getPreset('element');
|
||||||
|
expect(preset).toBeTruthy();
|
||||||
|
expect(preset.server).toBeTruthy();
|
||||||
|
expect(preset.server.enabled).toBeTrue();
|
||||||
|
expect(preset.server.port).toEqual(3002);
|
||||||
|
expect(preset.bundles).toBeTruthy();
|
||||||
|
expect(preset.bundles.length).toBeGreaterThan(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.start();
|
tap.test('ConfigHandler: should return null for invalid preset', async () => {
|
||||||
|
const configHandler = new tswatch.ConfigHandler();
|
||||||
|
const preset = configHandler.getPreset('invalid');
|
||||||
|
expect(preset).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('ConfigHandler: should return correct config key', async () => {
|
||||||
|
const configHandler = new tswatch.ConfigHandler();
|
||||||
|
expect(configHandler.getConfigKey()).toEqual('@git.zone/tswatch');
|
||||||
|
});
|
||||||
|
|
||||||
|
// ============================================
|
||||||
|
// Watcher Tests
|
||||||
|
// ============================================
|
||||||
|
|
||||||
|
tap.test('Watcher: should create from config with defaults', async () => {
|
||||||
|
const watcher = tswatch.Watcher.fromConfig({
|
||||||
|
name: 'test-watcher',
|
||||||
|
watch: './ts/**/*',
|
||||||
|
command: 'echo test',
|
||||||
|
});
|
||||||
|
expect(watcher).toBeInstanceOf(tswatch.Watcher);
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('Watcher: should handle array watch patterns', async () => {
|
||||||
|
const watcher = tswatch.Watcher.fromConfig({
|
||||||
|
name: 'multi-watch',
|
||||||
|
watch: ['./ts/**/*', './test/**/*'],
|
||||||
|
command: 'echo test',
|
||||||
|
});
|
||||||
|
expect(watcher).toBeInstanceOf(tswatch.Watcher);
|
||||||
|
});
|
||||||
|
|
||||||
|
// ============================================
|
||||||
|
// TsWatch Tests
|
||||||
|
// ============================================
|
||||||
|
|
||||||
|
let testTsWatch: tswatch.TsWatch;
|
||||||
|
|
||||||
|
tap.test('TsWatch: should create with minimal config', async () => {
|
||||||
|
testTsWatch = new tswatch.TsWatch({
|
||||||
|
watchers: [
|
||||||
|
{
|
||||||
|
name: 'echo-test',
|
||||||
|
watch: './ts/**/*',
|
||||||
|
command: 'echo "test"',
|
||||||
|
runOnStart: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
expect(testTsWatch).toBeInstanceOf(tswatch.TsWatch);
|
||||||
|
expect(testTsWatch.config.watchers).toBeTruthy();
|
||||||
|
expect(testTsWatch.config.watchers.length).toEqual(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('TsWatch: should start and populate watcherMap', async () => {
|
||||||
|
await testTsWatch.start();
|
||||||
|
expect(testTsWatch.watcherMap.getArray().length).toBeGreaterThan(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('TsWatch: should stop cleanly', async (tools) => {
|
||||||
|
await tools.delayFor(500);
|
||||||
|
await testTsWatch.stop();
|
||||||
|
});
|
||||||
|
|
||||||
|
export default 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: '3.2.1',
|
||||||
|
description: 'A development tool for automatically watching and re-compiling TypeScript projects upon detecting file changes, enhancing developer workflows.'
|
||||||
|
}
|
||||||
@@ -1,5 +1,11 @@
|
|||||||
import * as early from '@pushrocks/early';
|
import * as early from '@push.rocks/early';
|
||||||
early.start('tswatch');
|
early.start('tswatch');
|
||||||
|
|
||||||
export * from './tswatch.classes.tswatch.js';
|
export * from './tswatch.classes.tswatch.js';
|
||||||
|
export * from './tswatch.classes.watcher.js';
|
||||||
|
export * from './tswatch.classes.confighandler.js';
|
||||||
export * from './tswatch.cli.js';
|
export * from './tswatch.cli.js';
|
||||||
|
export * from './tswatch.init.js';
|
||||||
|
export * from './interfaces/index.js';
|
||||||
|
|
||||||
early.stop();
|
early.stop();
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
export * from './interfaces.watchmodes.js';
|
export * from './interfaces.config.js';
|
||||||
|
|||||||
71
ts/interfaces/interfaces.config.ts
Normal file
71
ts/interfaces/interfaces.config.ts
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
/**
|
||||||
|
* Configuration for a single watcher
|
||||||
|
*/
|
||||||
|
export interface IWatcherConfig {
|
||||||
|
/** Name for this watcher (used in logging) */
|
||||||
|
name: string;
|
||||||
|
/** Glob pattern(s) to watch */
|
||||||
|
watch: string | string[];
|
||||||
|
/** Shell command to execute on changes */
|
||||||
|
command?: string;
|
||||||
|
/** If true, kill previous process before restarting (default: true) */
|
||||||
|
restart?: boolean;
|
||||||
|
/** Debounce delay in ms (default: 300) */
|
||||||
|
debounce?: number;
|
||||||
|
/** If true, run the command immediately on start (default: true) */
|
||||||
|
runOnStart?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configuration for the development server
|
||||||
|
*/
|
||||||
|
export interface IServerConfig {
|
||||||
|
/** Whether the server is enabled */
|
||||||
|
enabled: boolean;
|
||||||
|
/** Server port (default: 3002) */
|
||||||
|
port?: number;
|
||||||
|
/** Directory to serve (default: ./dist_watch/) */
|
||||||
|
serveDir?: string;
|
||||||
|
/** Whether to inject live reload script (default: true) */
|
||||||
|
liveReload?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configuration for a bundle operation
|
||||||
|
*/
|
||||||
|
export interface IBundleConfig {
|
||||||
|
/** Name for this bundle (used in logging) */
|
||||||
|
name?: string;
|
||||||
|
/** Entry point file */
|
||||||
|
from: string;
|
||||||
|
/** Output file */
|
||||||
|
to: string;
|
||||||
|
/** Additional patterns to watch that trigger this bundle */
|
||||||
|
watchPatterns?: string[];
|
||||||
|
/** If true, trigger server reload after bundling (default: true) */
|
||||||
|
triggerReload?: boolean;
|
||||||
|
/** Output mode: 'bundle' writes JS, 'base64ts' writes base64-encoded TS (default: 'bundle') */
|
||||||
|
outputMode?: 'bundle' | 'base64ts';
|
||||||
|
/** Bundler to use (default: 'esbuild') */
|
||||||
|
bundler?: 'esbuild' | 'rolldown' | 'rspack';
|
||||||
|
/** Whether to produce a production build (default: false) */
|
||||||
|
production?: boolean;
|
||||||
|
/** Files to include alongside the bundle */
|
||||||
|
includeFiles?: (string | { from: string; to: string })[];
|
||||||
|
/** Max chars per line for base64ts output. 0 or undefined = unlimited */
|
||||||
|
maxLineLength?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Main tswatch configuration
|
||||||
|
*/
|
||||||
|
export interface ITswatchConfig {
|
||||||
|
/** Array of watcher configurations */
|
||||||
|
watchers?: IWatcherConfig[];
|
||||||
|
/** Development server configuration */
|
||||||
|
server?: IServerConfig;
|
||||||
|
/** Bundle configurations */
|
||||||
|
bundles?: IBundleConfig[];
|
||||||
|
/** Use a preset configuration (overridden by explicit watchers/server/bundles) */
|
||||||
|
preset?: 'element' | 'website' | 'npm' | 'service' | 'test';
|
||||||
|
}
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
export type TWatchModes =
|
|
||||||
| 'test'
|
|
||||||
| 'gitzone_npm'
|
|
||||||
| 'gitzone_service'
|
|
||||||
| 'gitzone_element'
|
|
||||||
| 'gitzone_website'
|
|
||||||
| 'echoSomething';
|
|
||||||
185
ts/tswatch.classes.confighandler.ts
Normal file
185
ts/tswatch.classes.confighandler.ts
Normal file
@@ -0,0 +1,185 @@
|
|||||||
|
import * as plugins from './tswatch.plugins.js';
|
||||||
|
import * as paths from './tswatch.paths.js';
|
||||||
|
import * as interfaces from './interfaces/index.js';
|
||||||
|
|
||||||
|
const CONFIG_KEY = '@git.zone/tswatch';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Preset configurations matching legacy watch modes
|
||||||
|
*/
|
||||||
|
const presets: Record<string, interfaces.ITswatchConfig> = {
|
||||||
|
npm: {
|
||||||
|
watchers: [
|
||||||
|
{
|
||||||
|
name: 'npm-test',
|
||||||
|
watch: ['./ts/**/*', './test/**/*'],
|
||||||
|
command: 'npm run test',
|
||||||
|
restart: true,
|
||||||
|
debounce: 300,
|
||||||
|
runOnStart: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
test: {
|
||||||
|
watchers: [
|
||||||
|
{
|
||||||
|
name: 'test2',
|
||||||
|
watch: ['./ts/**/*', './test/**/*'],
|
||||||
|
command: 'npm run test2',
|
||||||
|
restart: true,
|
||||||
|
debounce: 300,
|
||||||
|
runOnStart: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
service: {
|
||||||
|
watchers: [
|
||||||
|
{
|
||||||
|
name: 'service',
|
||||||
|
watch: './ts/**/*',
|
||||||
|
command: 'npm run startTs',
|
||||||
|
restart: true,
|
||||||
|
debounce: 300,
|
||||||
|
runOnStart: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
element: {
|
||||||
|
server: {
|
||||||
|
enabled: true,
|
||||||
|
port: 3002,
|
||||||
|
serveDir: './dist_watch/',
|
||||||
|
liveReload: true,
|
||||||
|
},
|
||||||
|
bundles: [
|
||||||
|
{
|
||||||
|
name: 'element-bundle',
|
||||||
|
from: './html/index.ts',
|
||||||
|
to: './dist_watch/bundle.js',
|
||||||
|
watchPatterns: ['./ts_web/**/*'],
|
||||||
|
triggerReload: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'html',
|
||||||
|
from: './html/index.html',
|
||||||
|
to: './dist_watch/index.html',
|
||||||
|
watchPatterns: ['./html/**/*'],
|
||||||
|
triggerReload: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
watchers: [
|
||||||
|
{
|
||||||
|
name: 'ts-build',
|
||||||
|
watch: './ts/**/*',
|
||||||
|
command: 'npm run build',
|
||||||
|
restart: false,
|
||||||
|
debounce: 300,
|
||||||
|
runOnStart: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
website: {
|
||||||
|
bundles: [
|
||||||
|
{
|
||||||
|
name: 'website-bundle',
|
||||||
|
from: './ts_web/index.ts',
|
||||||
|
to: './dist_serve/bundle.js',
|
||||||
|
watchPatterns: ['./ts_web/**/*'],
|
||||||
|
triggerReload: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'html',
|
||||||
|
from: './html/index.html',
|
||||||
|
to: './dist_serve/index.html',
|
||||||
|
watchPatterns: ['./html/**/*'],
|
||||||
|
triggerReload: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'assets',
|
||||||
|
from: './assets/',
|
||||||
|
to: './dist_serve/assets/',
|
||||||
|
watchPatterns: ['./assets/**/*'],
|
||||||
|
triggerReload: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
watchers: [
|
||||||
|
{
|
||||||
|
name: 'backend',
|
||||||
|
watch: './ts/**/*',
|
||||||
|
command: 'npm run startTs',
|
||||||
|
restart: true,
|
||||||
|
debounce: 300,
|
||||||
|
runOnStart: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles loading and managing tswatch configuration
|
||||||
|
*/
|
||||||
|
export class ConfigHandler {
|
||||||
|
private npmextra: plugins.npmextra.Npmextra;
|
||||||
|
private cwd: string;
|
||||||
|
|
||||||
|
constructor(cwdArg?: string) {
|
||||||
|
this.cwd = cwdArg || paths.cwd;
|
||||||
|
this.npmextra = new plugins.npmextra.Npmextra(this.cwd);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a tswatch configuration exists
|
||||||
|
*/
|
||||||
|
public hasConfig(): boolean {
|
||||||
|
const config = this.npmextra.dataFor<interfaces.ITswatchConfig>(CONFIG_KEY, null);
|
||||||
|
return config !== null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load configuration from npmextra.json
|
||||||
|
* If a preset is specified, merge preset defaults with user overrides
|
||||||
|
*/
|
||||||
|
public loadConfig(): interfaces.ITswatchConfig | null {
|
||||||
|
const config = this.npmextra.dataFor<interfaces.ITswatchConfig>(CONFIG_KEY, null);
|
||||||
|
|
||||||
|
if (!config) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If a preset is specified, merge it with user config
|
||||||
|
if (config.preset && presets[config.preset]) {
|
||||||
|
const preset = presets[config.preset];
|
||||||
|
return {
|
||||||
|
...preset,
|
||||||
|
...config,
|
||||||
|
// Merge arrays instead of replacing
|
||||||
|
watchers: config.watchers || preset.watchers,
|
||||||
|
bundles: config.bundles || preset.bundles,
|
||||||
|
server: config.server !== undefined ? config.server : preset.server,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a preset configuration by name
|
||||||
|
*/
|
||||||
|
public getPreset(presetName: string): interfaces.ITswatchConfig | null {
|
||||||
|
return presets[presetName] || null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all available preset names
|
||||||
|
*/
|
||||||
|
public getPresetNames(): string[] {
|
||||||
|
return Object.keys(presets);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the config key for npmextra.json
|
||||||
|
*/
|
||||||
|
public getConfigKey(): string {
|
||||||
|
return CONFIG_KEY;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,122 +3,207 @@ import * as paths from './tswatch.paths.js';
|
|||||||
import * as interfaces from './interfaces/index.js';
|
import * as interfaces from './interfaces/index.js';
|
||||||
|
|
||||||
import { Watcher } from './tswatch.classes.watcher.js';
|
import { Watcher } from './tswatch.classes.watcher.js';
|
||||||
|
import { ConfigHandler } from './tswatch.classes.confighandler.js';
|
||||||
|
import { logger } from './tswatch.logging.js';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TsWatch - Config-driven file watcher
|
||||||
|
*
|
||||||
|
* Reads configuration from npmextra.json under the key '@git.zone/tswatch'
|
||||||
|
* and sets up watchers, bundles, and dev server accordingly.
|
||||||
|
*/
|
||||||
export class TsWatch {
|
export class TsWatch {
|
||||||
public watchmode: interfaces.TWatchModes;
|
public config: interfaces.ITswatchConfig;
|
||||||
public watcherMap = new plugins.lik.ObjectMap<Watcher>();
|
public watcherMap = new plugins.lik.ObjectMap<Watcher>();
|
||||||
public smartserve: plugins.smartserve.SmartServe;
|
public typedserver: plugins.typedserver.TypedServer | null = null;
|
||||||
|
|
||||||
constructor(watchmodeArg: interfaces.TWatchModes) {
|
private tsbundle = new plugins.tsbundle.TsBundle();
|
||||||
this.watchmode = watchmodeArg;
|
private customBundleHandler = new plugins.tsbundle.CustomBundleHandler();
|
||||||
|
private htmlHandler = new plugins.tsbundle.HtmlHandler();
|
||||||
|
private assetsHandler = new plugins.tsbundle.AssetsHandler();
|
||||||
|
|
||||||
|
constructor(configArg: interfaces.ITswatchConfig) {
|
||||||
|
this.config = configArg;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create TsWatch from npmextra.json configuration
|
||||||
|
*/
|
||||||
|
public static fromConfig(cwdArg?: string): TsWatch | null {
|
||||||
|
const configHandler = new ConfigHandler(cwdArg);
|
||||||
|
const config = configHandler.loadConfig();
|
||||||
|
|
||||||
|
if (!config) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new TsWatch(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* starts the TsWatch instance
|
* starts the TsWatch instance
|
||||||
*/
|
*/
|
||||||
public async start() {
|
public async start() {
|
||||||
switch (this.watchmode) {
|
logger.log('info', 'Starting tswatch with config-driven mode');
|
||||||
case 'test':
|
|
||||||
this.watcherMap.add(
|
|
||||||
new Watcher({
|
|
||||||
filePathToWatch: paths.cwd,
|
|
||||||
commandToExecute: 'npm run test2',
|
|
||||||
timeout: null,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
case 'gitzone_npm':
|
|
||||||
this.watcherMap.add(
|
|
||||||
new Watcher({
|
|
||||||
filePathToWatch: paths.cwd,
|
|
||||||
commandToExecute: 'npm run test',
|
|
||||||
timeout: null,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
case 'gitzone_element':
|
|
||||||
// lets create a standard server
|
|
||||||
console.log(
|
|
||||||
'bundling TypeScript files to "dist_watch" Note: This is for development only!'
|
|
||||||
);
|
|
||||||
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(), './dist_watch'),
|
|
||||||
'index.html'
|
|
||||||
);
|
|
||||||
await parcel.watchAndServe(); */
|
|
||||||
break;
|
|
||||||
case 'gitzone_website':
|
|
||||||
this.watcherMap.add(
|
|
||||||
new Watcher({
|
|
||||||
filePathToWatch: plugins.path.join(paths.cwd, './ts/'),
|
|
||||||
commandToExecute: 'npm run startTs',
|
|
||||||
timeout: null,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
this.watcherMap.add(
|
|
||||||
new Watcher({
|
|
||||||
filePathToWatch: plugins.path.join(paths.cwd, './ts_web/'),
|
|
||||||
commandToExecute: 'npm run bundle',
|
|
||||||
timeout: null,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
// client directory
|
// Install global process lifecycle handlers (SIGINT, SIGTERM, etc.)
|
||||||
/* const parcelWebsite = new plugins.smartparcel.Parcel(
|
// This is the single authority for signal handling — no per-watcher handlers.
|
||||||
plugins.path.join(process.cwd(), './html/index.html'),
|
plugins.smartexit.ProcessLifecycle.install();
|
||||||
plugins.path.join(process.cwd(), './dist_serve'),
|
const exitInstance = new plugins.smartexit.SmartExit({ silent: true });
|
||||||
'bundle.js'
|
exitInstance.addCleanupFunction(async () => {
|
||||||
);
|
await this.stop();
|
||||||
await parcelWebsite.watchAndServe(); */
|
|
||||||
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':
|
|
||||||
const tsWatchInstanceEchoSomething = new Watcher({
|
|
||||||
filePathToWatch: plugins.path.join(paths.cwd, './ts'),
|
|
||||||
commandToExecute: 'npm -v',
|
|
||||||
timeout: null,
|
|
||||||
});
|
});
|
||||||
this.watcherMap.add(tsWatchInstanceEchoSomething);
|
|
||||||
break;
|
// Start server if configured
|
||||||
default:
|
if (this.config.server?.enabled) {
|
||||||
break;
|
await this.startServer();
|
||||||
}
|
}
|
||||||
this.watcherMap.forEach(async (watcher) => {
|
|
||||||
|
// Setup bundles and their watchers
|
||||||
|
if (this.config.bundles && this.config.bundles.length > 0) {
|
||||||
|
await this.setupBundles();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setup watchers from config
|
||||||
|
if (this.config.watchers && this.config.watchers.length > 0) {
|
||||||
|
await this.setupWatchers();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start all watchers
|
||||||
|
await this.watcherMap.forEach(async (watcher) => {
|
||||||
await watcher.start();
|
await watcher.start();
|
||||||
});
|
});
|
||||||
if (this.smartserve) {
|
|
||||||
await this.smartserve.start();
|
// Start server after watchers are ready
|
||||||
|
if (this.typedserver) {
|
||||||
|
await this.typedserver.start();
|
||||||
|
logger.log('ok', `Dev server started on port ${this.config.server?.port || 3002}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start the development server
|
||||||
|
*/
|
||||||
|
private async startServer() {
|
||||||
|
const serverConfig = this.config.server!;
|
||||||
|
const port = serverConfig.port || 3002;
|
||||||
|
const serveDir = serverConfig.serveDir || './dist_watch/';
|
||||||
|
|
||||||
|
logger.log('info', `Setting up dev server on port ${port}, serving ${serveDir}`);
|
||||||
|
|
||||||
|
this.typedserver = new plugins.typedserver.TypedServer({
|
||||||
|
cors: true,
|
||||||
|
injectReload: serverConfig.liveReload !== false,
|
||||||
|
serveDir: plugins.path.join(paths.cwd, serveDir),
|
||||||
|
port: port,
|
||||||
|
compression: true,
|
||||||
|
spaFallback: true,
|
||||||
|
noCache: true,
|
||||||
|
securityHeaders: {
|
||||||
|
crossOriginOpenerPolicy: 'same-origin',
|
||||||
|
crossOriginEmbedderPolicy: 'require-corp',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setup bundle watchers
|
||||||
|
*/
|
||||||
|
private async setupBundles() {
|
||||||
|
for (const bundleConfig of this.config.bundles!) {
|
||||||
|
const name = bundleConfig.name || `bundle-${bundleConfig.from}`;
|
||||||
|
logger.log('info', `Setting up bundle: ${name}`);
|
||||||
|
|
||||||
|
// Determine what patterns to watch
|
||||||
|
const watchPatterns = bundleConfig.watchPatterns || [
|
||||||
|
plugins.path.dirname(bundleConfig.from) + '/**/*',
|
||||||
|
];
|
||||||
|
|
||||||
|
// Create the bundle function
|
||||||
|
const bundleFunction = async () => {
|
||||||
|
logger.log('info', `[${name}] bundling...`);
|
||||||
|
|
||||||
|
// Determine bundle type based on file extension
|
||||||
|
const fromPath = bundleConfig.from;
|
||||||
|
const toPath = bundleConfig.to;
|
||||||
|
|
||||||
|
if (fromPath.endsWith('.html')) {
|
||||||
|
// HTML processing
|
||||||
|
await this.htmlHandler.processHtml({
|
||||||
|
from: plugins.path.join(paths.cwd, fromPath),
|
||||||
|
to: plugins.path.join(paths.cwd, toPath),
|
||||||
|
minify: false,
|
||||||
|
});
|
||||||
|
} else if (fromPath.endsWith('/') || !fromPath.includes('.')) {
|
||||||
|
// Assets directory copy
|
||||||
|
await this.assetsHandler.processAssets();
|
||||||
|
} else if (bundleConfig.outputMode && bundleConfig.outputMode !== 'bundle') {
|
||||||
|
// Non-default outputMode (e.g. base64ts) — use CustomBundleHandler
|
||||||
|
await this.customBundleHandler.processSingleBundle({
|
||||||
|
from: bundleConfig.from,
|
||||||
|
to: bundleConfig.to,
|
||||||
|
outputMode: bundleConfig.outputMode,
|
||||||
|
bundler: bundleConfig.bundler || 'esbuild',
|
||||||
|
production: bundleConfig.production || false,
|
||||||
|
includeFiles: bundleConfig.includeFiles,
|
||||||
|
maxLineLength: bundleConfig.maxLineLength,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// Standard TypeScript bundling (default)
|
||||||
|
await this.tsbundle.build(paths.cwd, fromPath, toPath, {
|
||||||
|
bundler: bundleConfig.bundler || 'esbuild',
|
||||||
|
production: bundleConfig.production || false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.log('ok', `[${name}] bundle complete`);
|
||||||
|
|
||||||
|
// Trigger reload if configured and server is running
|
||||||
|
if (bundleConfig.triggerReload !== false && this.typedserver) {
|
||||||
|
await this.typedserver.reload();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Run initial bundle
|
||||||
|
await bundleFunction();
|
||||||
|
|
||||||
|
// Create watcher for this bundle
|
||||||
|
this.watcherMap.add(
|
||||||
|
new Watcher({
|
||||||
|
name: name,
|
||||||
|
filePathToWatch: watchPatterns.map((p) => plugins.path.join(paths.cwd, p)),
|
||||||
|
functionToCall: bundleFunction,
|
||||||
|
runOnStart: false, // Already ran above
|
||||||
|
debounce: 300,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setup watchers from config
|
||||||
|
*/
|
||||||
|
private async setupWatchers() {
|
||||||
|
for (const watcherConfig of this.config.watchers!) {
|
||||||
|
logger.log('info', `Setting up watcher: ${watcherConfig.name}`);
|
||||||
|
|
||||||
|
// Convert watch paths to absolute
|
||||||
|
const watchPaths = Array.isArray(watcherConfig.watch)
|
||||||
|
? watcherConfig.watch
|
||||||
|
: [watcherConfig.watch];
|
||||||
|
|
||||||
|
const absolutePaths = watchPaths.map((p) => plugins.path.join(paths.cwd, p));
|
||||||
|
|
||||||
|
this.watcherMap.add(
|
||||||
|
new Watcher({
|
||||||
|
name: watcherConfig.name,
|
||||||
|
filePathToWatch: absolutePaths,
|
||||||
|
commandToExecute: watcherConfig.command,
|
||||||
|
restart: watcherConfig.restart ?? true,
|
||||||
|
debounce: watcherConfig.debounce ?? 300,
|
||||||
|
runOnStart: watcherConfig.runOnStart ?? true,
|
||||||
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,10 +211,10 @@ export class TsWatch {
|
|||||||
* stops the execution of any active Watchers
|
* stops the execution of any active Watchers
|
||||||
*/
|
*/
|
||||||
public async stop() {
|
public async stop() {
|
||||||
if (this.smartserve) {
|
if (this.typedserver) {
|
||||||
await this.smartserve.stop();
|
await this.typedserver.stop();
|
||||||
}
|
}
|
||||||
this.watcherMap.forEach(async (watcher) => {
|
await this.watcherMap.forEach(async (watcher) => {
|
||||||
await watcher.stop();
|
await watcher.stop();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,24 @@
|
|||||||
import * as plugins from './tswatch.plugins.js';
|
import * as plugins from './tswatch.plugins.js';
|
||||||
|
import * as interfaces from './interfaces/index.js';
|
||||||
import { logger } from './tswatch.logging.js';
|
import { logger } from './tswatch.logging.js';
|
||||||
|
|
||||||
export interface IWatcherConstructorOptions {
|
export interface IWatcherConstructorOptions {
|
||||||
filePathToWatch: string;
|
/** Name for this watcher (used in logging) */
|
||||||
|
name?: string;
|
||||||
|
/** Path(s) to watch - can be a single path or array */
|
||||||
|
filePathToWatch: string | string[];
|
||||||
|
/** Shell command to execute on changes */
|
||||||
commandToExecute?: string;
|
commandToExecute?: string;
|
||||||
|
/** Function to call on changes */
|
||||||
functionToCall?: () => Promise<any>;
|
functionToCall?: () => Promise<any>;
|
||||||
|
/** Timeout for the watcher */
|
||||||
timeout?: number;
|
timeout?: number;
|
||||||
|
/** If true, kill previous process before restarting (default: true) */
|
||||||
|
restart?: boolean;
|
||||||
|
/** Debounce delay in ms (default: 300) */
|
||||||
|
debounce?: number;
|
||||||
|
/** If true, run the command immediately on start (default: true) */
|
||||||
|
runOnStart?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -20,74 +33,162 @@ export class Watcher {
|
|||||||
});
|
});
|
||||||
|
|
||||||
private currentExecution: plugins.smartshell.IExecResultStreaming;
|
private currentExecution: plugins.smartshell.IExecResultStreaming;
|
||||||
private smartchokWatcher = new plugins.smartchok.Smartchok([], {});
|
private smartwatchInstance = new plugins.smartwatch.Smartwatch([]);
|
||||||
private options: IWatcherConstructorOptions;
|
private options: IWatcherConstructorOptions;
|
||||||
|
private debounceTimer: NodeJS.Timeout | null = null;
|
||||||
|
private isExecuting = false;
|
||||||
|
private pendingExecution = false;
|
||||||
|
|
||||||
constructor(optionsArg: IWatcherConstructorOptions) {
|
constructor(optionsArg: IWatcherConstructorOptions) {
|
||||||
this.options = optionsArg;
|
this.options = {
|
||||||
|
restart: true,
|
||||||
|
debounce: 300,
|
||||||
|
runOnStart: true,
|
||||||
|
...optionsArg,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a Watcher from config
|
||||||
|
*/
|
||||||
|
public static fromConfig(config: interfaces.IWatcherConfig): Watcher {
|
||||||
|
const watchPaths = Array.isArray(config.watch) ? config.watch : [config.watch];
|
||||||
|
return new Watcher({
|
||||||
|
name: config.name,
|
||||||
|
filePathToWatch: watchPaths,
|
||||||
|
commandToExecute: config.command,
|
||||||
|
restart: config.restart ?? true,
|
||||||
|
debounce: config.debounce ?? 300,
|
||||||
|
runOnStart: config.runOnStart ?? true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the watcher name for logging
|
||||||
|
*/
|
||||||
|
private getName(): string {
|
||||||
|
return this.options.name || 'unnamed';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* start the file
|
* start the file
|
||||||
*/
|
*/
|
||||||
public async start() {
|
public async start() {
|
||||||
|
const name = this.getName();
|
||||||
|
logger.log('info', `[${name}] starting watcher`);
|
||||||
await this.setupCleanup();
|
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
|
// Convert paths to glob patterns
|
||||||
await this.smartchokWatcher.start();
|
const paths = Array.isArray(this.options.filePathToWatch)
|
||||||
const changeObservable = await this.smartchokWatcher.getObservableFor('change');
|
? this.options.filePathToWatch
|
||||||
changeObservable.subscribe(() => {
|
: [this.options.filePathToWatch];
|
||||||
this.updateCurrentExecution();
|
|
||||||
|
const watchPatterns = paths.map((p) => {
|
||||||
|
// Convert directory path to glob pattern for smartwatch
|
||||||
|
if (p.endsWith('/')) {
|
||||||
|
return `${p}**/*`;
|
||||||
|
}
|
||||||
|
// If it's already a glob pattern, use as-is
|
||||||
|
if (p.includes('*')) {
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
// Otherwise assume it's a directory
|
||||||
|
return `${p}/**/*`;
|
||||||
});
|
});
|
||||||
await this.updateCurrentExecution();
|
|
||||||
|
logger.log('info', `[${name}] watching patterns: ${watchPatterns.join(', ')}`);
|
||||||
|
this.smartwatchInstance.add(watchPatterns);
|
||||||
|
await this.smartwatchInstance.start();
|
||||||
|
|
||||||
|
const changeObservable = await this.smartwatchInstance.getObservableFor('change');
|
||||||
|
changeObservable.subscribe(() => {
|
||||||
|
this.handleChange();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Run on start if configured
|
||||||
|
if (this.options.runOnStart) {
|
||||||
|
await this.executeCommand();
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.log('info', `[${name}] watcher started`);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* updates the current execution
|
* Handle file change with debouncing
|
||||||
*/
|
*/
|
||||||
private async updateCurrentExecution() {
|
private handleChange() {
|
||||||
|
const name = this.getName();
|
||||||
|
|
||||||
|
// Clear existing debounce timer
|
||||||
|
if (this.debounceTimer) {
|
||||||
|
clearTimeout(this.debounceTimer);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set new debounce timer
|
||||||
|
this.debounceTimer = setTimeout(async () => {
|
||||||
|
this.debounceTimer = null;
|
||||||
|
|
||||||
|
// If currently executing and not in restart mode, mark pending
|
||||||
|
if (this.isExecuting && !this.options.restart) {
|
||||||
|
logger.log('info', `[${name}] change detected, queuing execution`);
|
||||||
|
this.pendingExecution = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await this.executeCommand();
|
||||||
|
|
||||||
|
// If there was a pending execution, run it
|
||||||
|
if (this.pendingExecution) {
|
||||||
|
this.pendingExecution = false;
|
||||||
|
await this.executeCommand();
|
||||||
|
}
|
||||||
|
}, this.options.debounce);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the command or function
|
||||||
|
*/
|
||||||
|
private async executeCommand() {
|
||||||
|
const name = this.getName();
|
||||||
|
|
||||||
if (this.options.commandToExecute) {
|
if (this.options.commandToExecute) {
|
||||||
if (this.currentExecution) {
|
if (this.currentExecution && this.options.restart) {
|
||||||
logger.log('ok', `reexecuting ${this.options.commandToExecute}`);
|
logger.log('ok', `[${name}] restarting: ${this.options.commandToExecute}`);
|
||||||
this.currentExecution.kill();
|
await this.currentExecution.kill();
|
||||||
} else {
|
} else if (!this.currentExecution) {
|
||||||
logger.log('ok', `executing ${this.options.commandToExecute} for the first time`);
|
logger.log('ok', `[${name}] executing: ${this.options.commandToExecute}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.isExecuting = true;
|
||||||
this.currentExecution = await this.smartshellInstance.execStreaming(
|
this.currentExecution = await this.smartshellInstance.execStreaming(
|
||||||
this.options.commandToExecute
|
this.options.commandToExecute,
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
console.log('no executionCommand set');
|
// Track when execution completes
|
||||||
|
this.currentExecution.childProcess.on('exit', () => {
|
||||||
|
this.isExecuting = false;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.options.functionToCall) {
|
if (this.options.functionToCall) {
|
||||||
this.options.functionToCall();
|
this.isExecuting = true;
|
||||||
} else {
|
try {
|
||||||
console.log('no functionToCall set.')
|
await this.options.functionToCall();
|
||||||
|
} finally {
|
||||||
|
this.isExecuting = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* this method sets up a clean exit strategy
|
* Sets up timeout-based cleanup if configured.
|
||||||
|
* Signal handling (SIGINT/SIGTERM) is managed globally by ProcessLifecycle in TsWatch.
|
||||||
*/
|
*/
|
||||||
private async setupCleanup() {
|
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) {
|
if (this.options.timeout) {
|
||||||
plugins.smartdelay.delayFor(this.options.timeout).then(() => {
|
plugins.smartdelay.delayFor(this.options.timeout).then(async () => {
|
||||||
console.log(`timed out afer ${this.options.timeout} milliseconds! exiting!`);
|
console.log(`timed out after ${this.options.timeout} milliseconds! exiting!`);
|
||||||
this.stop();
|
await this.stop();
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -97,9 +198,14 @@ export class Watcher {
|
|||||||
* stops the watcher
|
* stops the watcher
|
||||||
*/
|
*/
|
||||||
public async stop() {
|
public async stop() {
|
||||||
await this.smartchokWatcher.stop();
|
if (this.debounceTimer) {
|
||||||
if (this.currentExecution && !this.currentExecution.childProcess.killed) {
|
clearTimeout(this.debounceTimer);
|
||||||
this.currentExecution.kill();
|
}
|
||||||
|
await this.smartwatchInstance.stop();
|
||||||
|
if (this.currentExecution) {
|
||||||
|
// Always tree-kill — even if the direct child is dead (.killed === true),
|
||||||
|
// grandchildren (e.g. tsrun, devserver) may still be running.
|
||||||
|
await this.currentExecution.kill();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,39 +3,48 @@ import * as paths from './tswatch.paths.js';
|
|||||||
import { logger } from './tswatch.logging.js';
|
import { logger } from './tswatch.logging.js';
|
||||||
|
|
||||||
import { TsWatch } from './tswatch.classes.tswatch.js';
|
import { TsWatch } from './tswatch.classes.tswatch.js';
|
||||||
|
import { ConfigHandler } from './tswatch.classes.confighandler.js';
|
||||||
|
import { runInit } from './tswatch.init.js';
|
||||||
|
|
||||||
const tswatchCli = new plugins.smartcli.Smartcli();
|
const tswatchCli = new plugins.smartcli.Smartcli();
|
||||||
|
|
||||||
// standard behaviour will assume gitzone setup
|
/**
|
||||||
|
* Standard command (no args) - run with config or launch wizard
|
||||||
|
*/
|
||||||
|
tswatchCli.standardCommand().subscribe(async (argvArg) => {
|
||||||
|
const configHandler = new ConfigHandler();
|
||||||
|
|
||||||
tswatchCli.addCommand('element').subscribe(async (argvArg) => {
|
if (configHandler.hasConfig()) {
|
||||||
logger.log('info', `running watch task for a gitzone element project`);
|
// Config exists - run with it
|
||||||
const tsWatch = new TsWatch('gitzone_element');
|
const tsWatch = TsWatch.fromConfig();
|
||||||
|
if (tsWatch) {
|
||||||
|
logger.log('info', 'Starting tswatch with configuration from npmextra.json');
|
||||||
await tsWatch.start();
|
await tsWatch.start();
|
||||||
|
} else {
|
||||||
|
logger.log('error', 'Failed to load configuration');
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// No config - launch wizard
|
||||||
|
logger.log('info', 'No tswatch configuration found in npmextra.json');
|
||||||
|
const config = await runInit();
|
||||||
|
if (config) {
|
||||||
|
// Run with the newly created config
|
||||||
|
const tsWatch = new TsWatch(config);
|
||||||
|
await tsWatch.start();
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
tswatchCli.addCommand('npm').subscribe(async (argvArg) => {
|
/**
|
||||||
logger.log('info', `running watch task for a gitzone element project`);
|
* Init command - force run wizard (overwrite existing config)
|
||||||
const tsWatch = new TsWatch('gitzone_npm');
|
*/
|
||||||
await tsWatch.start();
|
tswatchCli.addCommand('init').subscribe(async (argvArg) => {
|
||||||
});
|
logger.log('info', 'Running tswatch configuration wizard');
|
||||||
|
const config = await runInit();
|
||||||
tswatchCli.addCommand('service').subscribe(async (argvArg) => {
|
if (config) {
|
||||||
logger.log('info', `running test task`);
|
logger.log('ok', 'Configuration created successfully');
|
||||||
const tsWatch = new TsWatch('gitzone_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('gitzone_website');
|
|
||||||
await tsWatch.start();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export const runCli = async () => {
|
export const runCli = async () => {
|
||||||
|
|||||||
199
ts/tswatch.init.ts
Normal file
199
ts/tswatch.init.ts
Normal file
@@ -0,0 +1,199 @@
|
|||||||
|
import * as plugins from './tswatch.plugins.js';
|
||||||
|
import * as paths from './tswatch.paths.js';
|
||||||
|
import * as interfaces from './interfaces/index.js';
|
||||||
|
import { ConfigHandler } from './tswatch.classes.confighandler.js';
|
||||||
|
import { logger } from './tswatch.logging.js';
|
||||||
|
|
||||||
|
const CONFIG_KEY = '@git.zone/tswatch';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interactive init wizard for creating tswatch configuration
|
||||||
|
*/
|
||||||
|
export class TswatchInit {
|
||||||
|
private configHandler: ConfigHandler;
|
||||||
|
private smartInteract: plugins.smartinteract.SmartInteract;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this.configHandler = new ConfigHandler();
|
||||||
|
this.smartInteract = new plugins.smartinteract.SmartInteract([]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run the interactive init wizard
|
||||||
|
*/
|
||||||
|
public async run(): Promise<interfaces.ITswatchConfig | null> {
|
||||||
|
console.log('\n=== tswatch Configuration Wizard ===\n');
|
||||||
|
|
||||||
|
// Ask for template choice
|
||||||
|
const templateAnswer = await this.smartInteract.askQuestion({
|
||||||
|
name: 'template',
|
||||||
|
type: 'list',
|
||||||
|
message: 'Select a configuration template:',
|
||||||
|
default: 'npm',
|
||||||
|
choices: [
|
||||||
|
{ name: 'npm - Watch ts/ and test/, run npm test', value: 'npm' },
|
||||||
|
{ name: 'test - Watch ts/ and test/, run npm run test2', value: 'test' },
|
||||||
|
{ name: 'service - Watch ts/, restart npm run startTs', value: 'service' },
|
||||||
|
{ name: 'element - Dev server + bundling for web components', value: 'element' },
|
||||||
|
{ name: 'website - Full stack: backend + frontend + assets', value: 'website' },
|
||||||
|
{ name: 'custom - Configure watchers manually', value: 'custom' },
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
const template = templateAnswer.value as string;
|
||||||
|
|
||||||
|
let config: interfaces.ITswatchConfig;
|
||||||
|
|
||||||
|
if (template === 'custom') {
|
||||||
|
config = await this.runCustomWizard();
|
||||||
|
} else {
|
||||||
|
// Get preset config
|
||||||
|
const preset = this.configHandler.getPreset(template);
|
||||||
|
if (!preset) {
|
||||||
|
console.error(`Unknown template: ${template}`);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
config = { ...preset, preset: template as interfaces.ITswatchConfig['preset'] };
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save to npmextra.json
|
||||||
|
await this.saveConfig(config);
|
||||||
|
|
||||||
|
console.log('\nConfiguration saved to npmextra.json');
|
||||||
|
console.log('Run "tswatch" to start watching.\n');
|
||||||
|
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run custom configuration wizard
|
||||||
|
*/
|
||||||
|
private async runCustomWizard(): Promise<interfaces.ITswatchConfig> {
|
||||||
|
const config: interfaces.ITswatchConfig = {};
|
||||||
|
|
||||||
|
// Ask about server
|
||||||
|
const serverAnswer = await this.smartInteract.askQuestion({
|
||||||
|
name: 'enableServer',
|
||||||
|
type: 'confirm',
|
||||||
|
message: 'Enable development server?',
|
||||||
|
default: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (serverAnswer.value) {
|
||||||
|
const portAnswer = await this.smartInteract.askQuestion({
|
||||||
|
name: 'port',
|
||||||
|
type: 'input',
|
||||||
|
message: 'Server port:',
|
||||||
|
default: '3002',
|
||||||
|
});
|
||||||
|
|
||||||
|
const serveDirAnswer = await this.smartInteract.askQuestion({
|
||||||
|
name: 'serveDir',
|
||||||
|
type: 'input',
|
||||||
|
message: 'Directory to serve:',
|
||||||
|
default: './dist_watch/',
|
||||||
|
});
|
||||||
|
|
||||||
|
config.server = {
|
||||||
|
enabled: true,
|
||||||
|
port: parseInt(portAnswer.value as string, 10),
|
||||||
|
serveDir: serveDirAnswer.value as string,
|
||||||
|
liveReload: true,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add watchers
|
||||||
|
config.watchers = [];
|
||||||
|
let addMore = true;
|
||||||
|
|
||||||
|
while (addMore) {
|
||||||
|
console.log('\n--- Add a watcher ---');
|
||||||
|
|
||||||
|
const nameAnswer = await this.smartInteract.askQuestion({
|
||||||
|
name: 'name',
|
||||||
|
type: 'input',
|
||||||
|
message: 'Watcher name:',
|
||||||
|
default: `watcher-${config.watchers.length + 1}`,
|
||||||
|
});
|
||||||
|
|
||||||
|
const watchAnswer = await this.smartInteract.askQuestion({
|
||||||
|
name: 'watch',
|
||||||
|
type: 'input',
|
||||||
|
message: 'Glob pattern(s) to watch (comma-separated):',
|
||||||
|
default: './ts/**/*',
|
||||||
|
});
|
||||||
|
|
||||||
|
const commandAnswer = await this.smartInteract.askQuestion({
|
||||||
|
name: 'command',
|
||||||
|
type: 'input',
|
||||||
|
message: 'Command to execute:',
|
||||||
|
default: 'npm run test',
|
||||||
|
});
|
||||||
|
|
||||||
|
const restartAnswer = await this.smartInteract.askQuestion({
|
||||||
|
name: 'restart',
|
||||||
|
type: 'confirm',
|
||||||
|
message: 'Restart command on each change (vs queue)?',
|
||||||
|
default: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Parse watch patterns
|
||||||
|
const watchPatterns = (watchAnswer.value as string)
|
||||||
|
.split(',')
|
||||||
|
.map((p) => p.trim())
|
||||||
|
.filter((p) => p.length > 0);
|
||||||
|
|
||||||
|
config.watchers.push({
|
||||||
|
name: nameAnswer.value as string,
|
||||||
|
watch: watchPatterns.length === 1 ? watchPatterns[0] : watchPatterns,
|
||||||
|
command: commandAnswer.value as string,
|
||||||
|
restart: restartAnswer.value as boolean,
|
||||||
|
debounce: 300,
|
||||||
|
runOnStart: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const moreAnswer = await this.smartInteract.askQuestion({
|
||||||
|
name: 'addMore',
|
||||||
|
type: 'confirm',
|
||||||
|
message: 'Add another watcher?',
|
||||||
|
default: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
addMore = moreAnswer.value as boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save configuration to npmextra.json
|
||||||
|
*/
|
||||||
|
private async saveConfig(config: interfaces.ITswatchConfig): Promise<void> {
|
||||||
|
const npmextraPath = plugins.path.join(paths.cwd, 'npmextra.json');
|
||||||
|
|
||||||
|
// Read existing npmextra.json if it exists
|
||||||
|
let existingConfig: Record<string, any> = {};
|
||||||
|
try {
|
||||||
|
const smartfsInstance = new plugins.smartfs.SmartFs(new plugins.smartfs.SmartFsProviderNode());
|
||||||
|
const content = await smartfsInstance.file(npmextraPath).encoding('utf8').read() as string;
|
||||||
|
existingConfig = JSON.parse(content);
|
||||||
|
} catch {
|
||||||
|
// File doesn't exist or is invalid, start fresh
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update with new tswatch config
|
||||||
|
existingConfig[CONFIG_KEY] = config;
|
||||||
|
|
||||||
|
// Write back
|
||||||
|
const smartfsInstance = new plugins.smartfs.SmartFs(new plugins.smartfs.SmartFsProviderNode());
|
||||||
|
await smartfsInstance.file(npmextraPath).encoding('utf8').write(JSON.stringify(existingConfig, null, 2));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run the init wizard
|
||||||
|
*/
|
||||||
|
export const runInit = async (): Promise<interfaces.ITswatchConfig | null> => {
|
||||||
|
const init = new TswatchInit();
|
||||||
|
return init.run();
|
||||||
|
};
|
||||||
@@ -2,33 +2,40 @@
|
|||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
export { path };
|
export { path };
|
||||||
|
|
||||||
// @gitzone scope
|
// @git.zone scope
|
||||||
import * as tsbundle from '@gitzone/tsbundle';
|
import * as tsbundle from '@git.zone/tsbundle';
|
||||||
export {
|
export { tsbundle };
|
||||||
tsbundle
|
|
||||||
}
|
|
||||||
|
|
||||||
// @pushrocks scope
|
// @api.global scope
|
||||||
import * as lik from '@pushrocks/lik';
|
import * as typedserver from '@api.global/typedserver';
|
||||||
import * as smartchok from '@pushrocks/smartchok';
|
|
||||||
import * as smartcli from '@pushrocks/smartcli';
|
export { typedserver };
|
||||||
import * as smartdelay from '@pushrocks/smartdelay';
|
|
||||||
import * as smartlog from '@pushrocks/smartlog';
|
// @push.rocks scope
|
||||||
import * as smartlogDestinationLocal from '@pushrocks/smartlog-destination-local';
|
import * as lik from '@push.rocks/lik';
|
||||||
import * as smartparcel from '@pushrocks/smartparcel';
|
import * as npmextra from '@push.rocks/npmextra';
|
||||||
import * as smartserve from '@pushrocks/smartserve';
|
import * as smartcli from '@push.rocks/smartcli';
|
||||||
import * as smartshell from '@pushrocks/smartshell';
|
import * as smartdelay from '@push.rocks/smartdelay';
|
||||||
import * as taskbuffer from '@pushrocks/taskbuffer';
|
import * as smartexit from '@push.rocks/smartexit';
|
||||||
|
import * as smartfs from '@push.rocks/smartfs';
|
||||||
|
import * as smartinteract from '@push.rocks/smartinteract';
|
||||||
|
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 smartwatch from '@push.rocks/smartwatch';
|
||||||
|
import * as taskbuffer from '@push.rocks/taskbuffer';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
lik,
|
lik,
|
||||||
smartchok,
|
npmextra,
|
||||||
smartcli,
|
smartcli,
|
||||||
smartdelay,
|
smartdelay,
|
||||||
|
smartexit,
|
||||||
|
smartfs,
|
||||||
|
smartinteract,
|
||||||
smartlog,
|
smartlog,
|
||||||
smartlogDestinationLocal,
|
smartlogDestinationLocal,
|
||||||
smartparcel,
|
|
||||||
smartserve,
|
|
||||||
smartshell,
|
smartshell,
|
||||||
|
smartwatch,
|
||||||
taskbuffer,
|
taskbuffer,
|
||||||
};
|
};
|
||||||
|
|||||||
16
tsconfig.json
Normal file
16
tsconfig.json
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"useDefineForClassFields": false,
|
||||||
|
"target": "ES2022",
|
||||||
|
"module": "NodeNext",
|
||||||
|
"moduleResolution": "NodeNext",
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"verbatimModuleSyntax": true,
|
||||||
|
"baseUrl": ".",
|
||||||
|
"paths": {}
|
||||||
|
},
|
||||||
|
"exclude": [
|
||||||
|
"dist_*/**/*.d.ts"
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user