Compare commits
267 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 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 | |||
| 4cf71d2edc | |||
| 0eec0c04e8 | |||
| ef5d4d2a9c | |||
| f05481a267 | |||
| d66a88538a | |||
| 1c1a110ca3 | |||
| 3f7790e8c8 | |||
| 2018b27a4b | |||
| 3b8ac18a6c | |||
| e36af800a3 | |||
| 76b810663f | |||
| 9950661a36 | |||
| 6fa461aff5 | |||
| 4ca73a77f9 | |||
| 2d4d243454 | |||
| f77f36312f | |||
| c508c85473 | |||
| 50a0cadd11 | |||
| d5cb794ea6 | |||
| 3bb65bedf6 | |||
| 53147a8812 | |||
| c63a5f88d5 | |||
| f039ace7bc | |||
| bbc34ad98b | |||
| c699954d08 | |||
| 1c84726ed8 | |||
| c589e20222 | |||
| f170cb8909 | |||
| ca1d058789 | |||
| 4423631fa9 | |||
| 5e62fa2124 | |||
| 8ef3b47e76 | |||
| ed91da6e3f | |||
| 7b777ea1a9 | |||
| faec3d38bc | |||
| a2ff76dc78 | |||
| 7e973c906a | |||
| 6c109cb381 | |||
| 2266813faf | |||
| bf7a2c9146 | |||
| 1a4ada879d | |||
| 0046985b82 | |||
| d876b09337 | |||
| f48ba50236 | |||
| f04833d5b5 | |||
| 073685e683 | |||
| b91b3e0a0c | |||
| 12d31533f5 | |||
| f9b8a356e4 | |||
| 408b6f8fc5 | |||
| 80dd3ee970 | |||
| 717e1d29ed | |||
| a8254e6962 | |||
| 35ee69981d | |||
| bd66e9a897 | |||
| fc356e62f4 | |||
| a34d98b840 | |||
| 9525f28507 | |||
| 787aae63d7 | |||
| bf2a32a5d5 | |||
| 7ced66fc28 | |||
| d01905ae99 | |||
| 59c744cc5e | |||
| 4d23145529 | |||
| 27e0d7588d | |||
| 88d4bf6be0 | |||
| d4f8215f35 | |||
| 85f72feeb9 | |||
| bd4ccbd215 | |||
| 79940cec3f | |||
| e20508ffbc | |||
| 21b962b9a8 | |||
| f673e8577b | |||
| e4278ed270 | |||
| 8ae0f960ac | |||
| c9a3b996cb | |||
| d81d19008a | |||
| e4ef6bad8f | |||
| 2873314742 | |||
| e26fa92744 | |||
| 995f296319 | |||
| e7866dadb7 | |||
| 9302e78f86 | |||
| 0a302bee95 | |||
| deb5e1daf9 | |||
| 5fe27ee706 | |||
| b73807baf0 | |||
| 1e71fc24d5 | |||
| e8071e76a1 | |||
| b11d03dd41 | |||
| 72297d2f58 | |||
| 71b900ac47 | |||
| f6d06edced | |||
| 3e98005843 | |||
| 7c4673a5b6 | |||
| 99ec82ab55 | |||
| 1f0c1964dd | |||
| 828229872d |
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
|
||||
14
.gitignore
vendored
14
.gitignore
vendored
@@ -3,17 +3,17 @@
|
||||
# artifacts
|
||||
coverage/
|
||||
public/
|
||||
pages/
|
||||
|
||||
# installs
|
||||
node_modules/
|
||||
|
||||
# caches and builds
|
||||
# caches
|
||||
.yarn/
|
||||
.cache/
|
||||
dist/
|
||||
dist_web/
|
||||
dist_serve/
|
||||
dist_ts_web/
|
||||
.rpt2_cache
|
||||
|
||||
# custom
|
||||
# builds
|
||||
dist/
|
||||
dist_*/
|
||||
|
||||
#------# custom
|
||||
125
.gitlab-ci.yml
125
.gitlab-ci.yml
@@ -1,125 +0,0 @@
|
||||
# gitzone standard
|
||||
image: hosttoday/ht-docker-node:npmci
|
||||
|
||||
cache:
|
||||
paths:
|
||||
- .npmci_cache/
|
||||
key: "$CI_BUILD_STAGE"
|
||||
|
||||
stages:
|
||||
- security
|
||||
- test
|
||||
- release
|
||||
- metadata
|
||||
|
||||
# ====================
|
||||
# security stage
|
||||
# ====================
|
||||
mirror:
|
||||
stage: security
|
||||
script:
|
||||
- npmci git mirror
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
snyk:
|
||||
stage: security
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci command npm install -g snyk
|
||||
- npmci command npm install --ignore-scripts
|
||||
- npmci command snyk test
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
# ====================
|
||||
# test stage
|
||||
# ====================
|
||||
|
||||
testLTS:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install lts
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
testSTABLE:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
release:
|
||||
stage: release
|
||||
script:
|
||||
- npmci node install stable
|
||||
- npmci npm publish
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
# ====================
|
||||
# metadata stage
|
||||
# ====================
|
||||
codequality:
|
||||
stage: metadata
|
||||
image: docker:stable
|
||||
allow_failure: true
|
||||
services:
|
||||
- docker:stable-dind
|
||||
script:
|
||||
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
|
||||
- docker run
|
||||
--env SOURCE_CODE="$PWD"
|
||||
--volume "$PWD":/code
|
||||
--volume /var/run/docker.sock:/var/run/docker.sock
|
||||
"registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
|
||||
artifacts:
|
||||
paths: [codeclimate.json]
|
||||
tags:
|
||||
- docker
|
||||
- priv
|
||||
|
||||
trigger:
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci trigger
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
pages:
|
||||
image: hosttoday/ht-docker-node:npmci
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci command npm install -g typedoc typescript
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
only:
|
||||
- tags
|
||||
artifacts:
|
||||
expire_in: 1 week
|
||||
paths:
|
||||
- public
|
||||
allow_failure: true
|
||||
11
.vscode/launch.json
vendored
Normal file
11
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"command": "npm test",
|
||||
"name": "Run npm test",
|
||||
"request": "launch",
|
||||
"type": "node-terminal"
|
||||
}
|
||||
]
|
||||
}
|
||||
26
.vscode/settings.json
vendored
Normal file
26
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"json.schemas": [
|
||||
{
|
||||
"fileMatch": ["/npmextra.json"],
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"npmci": {
|
||||
"type": "object",
|
||||
"description": "settings for npmci"
|
||||
},
|
||||
"gitzone": {
|
||||
"type": "object",
|
||||
"description": "settings for gitzone",
|
||||
"properties": {
|
||||
"projectType": {
|
||||
"type": "string",
|
||||
"enum": ["website", "element", "service", "npm", "wcc"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
340
changelog.md
Normal file
340
changelog.md
Normal file
@@ -0,0 +1,340 @@
|
||||
# Changelog
|
||||
|
||||
## 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.
|
||||
4
cli.child.ts
Normal file
4
cli.child.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env node
|
||||
process.env.CLI_CALL = 'true';
|
||||
import * as cliTool from './ts/index.js';
|
||||
cliTool.runCli();
|
||||
3
cli.js
3
cli.js
@@ -1,3 +1,4 @@
|
||||
#!/usr/bin/env node
|
||||
process.env.CLI_CALL = 'true';
|
||||
require('./dist/index');
|
||||
const cliTool = await import('./dist_ts/index.js');
|
||||
cliTool.runCli();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env node
|
||||
process.env.CLI_CALL = 'true';
|
||||
require('@gitzone/tsrun');
|
||||
require('./ts/index');
|
||||
|
||||
import * as tsrun from '@git.zone/tsrun';
|
||||
tsrun.runPath('./cli.child.js', import.meta.url);
|
||||
|
||||
@@ -1,16 +1,48 @@
|
||||
{
|
||||
"npmci": {
|
||||
"npmGlobalTools": [],
|
||||
"npmAccessLevel": "public"
|
||||
},
|
||||
"gitzone": {
|
||||
"@git.zone/cli": {
|
||||
"projectType": "npm",
|
||||
"module": {
|
||||
"githost": "gitlab.com",
|
||||
"gitscope": "gitzone",
|
||||
"githost": "code.foss.global",
|
||||
"gitscope": "git.zone",
|
||||
"gitrepo": "tswatch",
|
||||
"shortDescription": "watch typescript projects during development",
|
||||
"npmPackagename": "@gitzone/tswatch",
|
||||
"license": "MIT"
|
||||
"npmPackagename": "@git.zone/tswatch",
|
||||
"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": []
|
||||
}
|
||||
}
|
||||
1967
package-lock.json
generated
1967
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
101
package.json
101
package.json
@@ -1,37 +1,90 @@
|
||||
{
|
||||
"name": "@gitzone/tswatch",
|
||||
"version": "1.0.14",
|
||||
"name": "@git.zone/tswatch",
|
||||
"version": "3.1.0",
|
||||
"private": false,
|
||||
"description": "watch typescript projects during development",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"description": "A development tool for automatically watching and re-compiling TypeScript projects upon detecting file changes, enhancing developer workflows.",
|
||||
"exports": {
|
||||
".": "./dist_ts/index.js"
|
||||
},
|
||||
"type": "module",
|
||||
"author": "Lossless GmbH",
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"tswatch": "cli.js"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "(tstest test/)",
|
||||
"build": "(tsbuild)",
|
||||
"format": "(gitzone format)"
|
||||
"test": "(tstest test/ --web)",
|
||||
"build": "(tsbuild --web --allowimplicitany)",
|
||||
"buildDocs": "tsdoc"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.11",
|
||||
"@gitzone/tstest": "^1.0.22",
|
||||
"@pushrocks/tapbundle": "^3.0.9",
|
||||
"@types/node": "^12.0.2",
|
||||
"tslint": "^5.16.0",
|
||||
"tslint-config-prettier": "^1.18.0"
|
||||
"@git.zone/tsbuild": "^4.1.2",
|
||||
"@git.zone/tstest": "^3.1.8",
|
||||
"@types/node": "^25.2.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@gitzone/tsrun": "^1.2.6",
|
||||
"@pushrocks/early": "^3.0.3",
|
||||
"@pushrocks/lik": "^3.0.5",
|
||||
"@pushrocks/smartchok": "^1.0.18",
|
||||
"@pushrocks/smartcli": "^3.0.7",
|
||||
"@pushrocks/smartdelay": "^2.0.3",
|
||||
"@pushrocks/smartlog": "^2.0.19",
|
||||
"@pushrocks/smartlog-destination-local": "^7.0.5",
|
||||
"@pushrocks/smartshell": "^2.0.17"
|
||||
}
|
||||
"@api.global/typedserver": "^8.3.0",
|
||||
"@git.zone/tsbundle": "^2.8.3",
|
||||
"@git.zone/tsrun": "^2.0.1",
|
||||
"@push.rocks/early": "^4.0.4",
|
||||
"@push.rocks/lik": "^6.2.2",
|
||||
"@push.rocks/npmextra": "^5.3.3",
|
||||
"@push.rocks/smartcli": "^4.0.20",
|
||||
"@push.rocks/smartdelay": "^3.0.5",
|
||||
"@push.rocks/smartfs": "^1.3.1",
|
||||
"@push.rocks/smartinteract": "^2.0.16",
|
||||
"@push.rocks/smartlog": "^3.1.10",
|
||||
"@push.rocks/smartlog-destination-local": "^9.0.2",
|
||||
"@push.rocks/smartshell": "^3.3.0",
|
||||
"@push.rocks/smartwatch": "^6.3.0",
|
||||
"@push.rocks/taskbuffer": "^4.2.0"
|
||||
},
|
||||
"files": [
|
||||
"ts/**/*",
|
||||
"ts_web/**/*",
|
||||
"dist/**/*",
|
||||
"dist_*/**/*",
|
||||
"dist_ts/**/*",
|
||||
"dist_ts_web/**/*",
|
||||
"assets/**/*",
|
||||
"cli.js",
|
||||
"npmextra.json",
|
||||
"readme.md"
|
||||
],
|
||||
"browserslist": [
|
||||
"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"
|
||||
}
|
||||
|
||||
10342
pnpm-lock.yaml
generated
Normal file
10342
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
|
||||
425
readme.md
425
readme.md
@@ -1,26 +1,411 @@
|
||||
# @gitzone/tswatch
|
||||
watch typescript projects during development
|
||||
# @git.zone/tswatch
|
||||
|
||||
## Availabililty and Links
|
||||
* [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/)
|
||||
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.
|
||||
|
||||
## Status for master
|
||||
[](https://gitlab.com/gitzone/tswatch/commits/master)
|
||||
[](https://gitlab.com/gitzone/tswatch/commits/master)
|
||||
[](https://www.npmjs.com/package/@gitzone/tswatch)
|
||||
[](https://snyk.io/test/npm/@gitzone/tswatch)
|
||||
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
[](https://prettier.io/)
|
||||
## Issue Reporting and Security
|
||||
|
||||
## Usage
|
||||
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.
|
||||
|
||||
For further information read the linked docs at the top of this readme.
|
||||
## ✨ Features
|
||||
|
||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
||||
- 🔄 **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
|
||||
|
||||
[](https://maintainedby.lossless.com)
|
||||
## 📦 Installation
|
||||
|
||||
```bash
|
||||
# Global installation (recommended for CLI usage)
|
||||
pnpm install -g @git.zone/tswatch
|
||||
|
||||
# As a dev dependency
|
||||
pnpm install --save-dev @git.zone/tswatch
|
||||
```
|
||||
|
||||
## 🚀 Quick Start
|
||||
|
||||
### 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.
|
||||
|
||||
109
test/test.ts
109
test/test.ts
@@ -1,20 +1,105 @@
|
||||
// tslint:disable-next-line: no-implicit-dependencies
|
||||
import { expect, tap } from '@pushrocks/tapbundle';
|
||||
import * as tswatch from '../ts/index';
|
||||
import { expect, tap } from '@git.zone/tstest/tapbundle';
|
||||
import * as tswatch from '../ts/index.js';
|
||||
|
||||
let testTsWatchInstance: tswatch.TsWatch;
|
||||
// ============================================
|
||||
// ConfigHandler Tests
|
||||
// ============================================
|
||||
|
||||
tap.test('should create a valid TsWatch instance', async () => {
|
||||
testTsWatchInstance = new tswatch.TsWatch('echoSomething');
|
||||
tap.test('ConfigHandler: should return all preset names', async () => {
|
||||
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 () => {
|
||||
await testTsWatchInstance.start();
|
||||
tap.test('ConfigHandler: should return npm preset with watchers', async () => {
|
||||
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) => {
|
||||
tools.delayFor(2000);
|
||||
testTsWatchInstance.stop();
|
||||
tap.test('ConfigHandler: should return element preset with server', async () => {
|
||||
const configHandler = new tswatch.ConfigHandler();
|
||||
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.1.0',
|
||||
description: 'A development tool for automatically watching and re-compiling TypeScript projects upon detecting file changes, enhancing developer workflows.'
|
||||
}
|
||||
12
ts/index.ts
12
ts/index.ts
@@ -1,5 +1,11 @@
|
||||
import * as early from '@pushrocks/early';
|
||||
import * as early from '@push.rocks/early';
|
||||
early.start('tswatch');
|
||||
export * from './tswatch.classes.tswatch';
|
||||
import './tswatch.cli';
|
||||
|
||||
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.init.js';
|
||||
export * from './interfaces/index.js';
|
||||
|
||||
early.stop();
|
||||
|
||||
@@ -1 +1 @@
|
||||
export * from './interfaces.watchmodes';
|
||||
export * from './interfaces.config.js';
|
||||
|
||||
61
ts/interfaces/interfaces.config.ts
Normal file
61
ts/interfaces/interfaces.config.ts
Normal file
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 +0,0 @@
|
||||
export type TWatchModes = 'test' | 'gitzone_npm' | 'gitzone_service' | '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;
|
||||
}
|
||||
}
|
||||
@@ -1,74 +1,199 @@
|
||||
import * as plugins from './tswatch.plugins';
|
||||
import * as paths from './tswatch.paths';
|
||||
import * as interfaces from './interfaces';
|
||||
import * as plugins from './tswatch.plugins.js';
|
||||
import * as paths from './tswatch.paths.js';
|
||||
import * as interfaces from './interfaces/index.js';
|
||||
|
||||
import { Watcher } from './tswatch.classes.watcher';
|
||||
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 {
|
||||
public watchmode: interfaces.TWatchModes;
|
||||
public watcherMap = new plugins.lik.Objectmap<Watcher>();
|
||||
public config: interfaces.ITswatchConfig;
|
||||
public watcherMap = new plugins.lik.ObjectMap<Watcher>();
|
||||
public typedserver: plugins.typedserver.TypedServer | null = null;
|
||||
|
||||
constructor(watchmodeArg: interfaces.TWatchModes) {
|
||||
this.watchmode = watchmodeArg;
|
||||
private tsbundle = new plugins.tsbundle.TsBundle();
|
||||
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
|
||||
*/
|
||||
public 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_website':
|
||||
// server directory
|
||||
this.watcherMap.add(
|
||||
new Watcher({
|
||||
filePathToWatch: plugins.path.join(paths.cwd, './ts/'),
|
||||
commandToExecute: 'npm run start',
|
||||
timeout: null
|
||||
})
|
||||
);
|
||||
|
||||
// client directory
|
||||
this.watcherMap.add(new Watcher({
|
||||
filePathToWatch: plugins.path.join(paths.cwd, './ts_web/'),
|
||||
commandToExecute: 'npm run build',
|
||||
timeout: null
|
||||
}));
|
||||
break;
|
||||
case 'echoSomething':
|
||||
const tsWatchInstanceEchoSomething = new Watcher({
|
||||
filePathToWatch: paths.cwd,
|
||||
commandToExecute: 'npm -v',
|
||||
timeout: null
|
||||
});
|
||||
this.watcherMap.add(tsWatchInstanceEchoSomething);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
logger.log('info', 'Starting tswatch with config-driven mode');
|
||||
|
||||
// Start server if configured
|
||||
if (this.config.server?.enabled) {
|
||||
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();
|
||||
});
|
||||
|
||||
// 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 {
|
||||
// TypeScript bundling
|
||||
await this.tsbundle.build(paths.cwd, fromPath, toPath, {
|
||||
bundler: 'esbuild',
|
||||
});
|
||||
}
|
||||
|
||||
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,
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* stops the execution of any active Watchers
|
||||
*/
|
||||
public async stop() {
|
||||
this.watcherMap.forEach(async watcher => {
|
||||
if (this.typedserver) {
|
||||
await this.typedserver.stop();
|
||||
}
|
||||
await this.watcherMap.forEach(async (watcher) => {
|
||||
await watcher.stop();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,77 +1,199 @@
|
||||
import * as plugins from './tswatch.plugins';
|
||||
import { logger } from './tswatch.logging';
|
||||
import * as plugins from './tswatch.plugins.js';
|
||||
import * as interfaces from './interfaces/index.js';
|
||||
import { logger } from './tswatch.logging.js';
|
||||
|
||||
export interface IWatcherConstructorOptions {
|
||||
filePathToWatch: string;
|
||||
commandToExecute: 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;
|
||||
/** Function to call on changes */
|
||||
functionToCall?: () => Promise<any>;
|
||||
/** Timeout for the watcher */
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* A watcher keeps track of one child execution
|
||||
*/
|
||||
export class Watcher {
|
||||
/**
|
||||
* used to execute shell commands
|
||||
*/
|
||||
private smartshellInstance = new plugins.smartshell.Smartshell({
|
||||
executor: 'bash'
|
||||
executor: 'bash',
|
||||
});
|
||||
|
||||
private currentExecution: plugins.smartshell.IExecResultStreaming;
|
||||
private smartchokWatcher = new plugins.smartchok.Smartchok([], {});
|
||||
private smartwatchInstance = new plugins.smartwatch.Smartwatch([]);
|
||||
private options: IWatcherConstructorOptions;
|
||||
private debounceTimer: NodeJS.Timeout | null = null;
|
||||
private isExecuting = false;
|
||||
private pendingExecution = false;
|
||||
|
||||
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
|
||||
*/
|
||||
public async start() {
|
||||
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();
|
||||
const name = this.getName();
|
||||
logger.log('info', `[${name}] starting watcher`);
|
||||
await this.setupCleanup();
|
||||
|
||||
// Convert paths to glob patterns
|
||||
const paths = Array.isArray(this.options.filePathToWatch)
|
||||
? this.options.filePathToWatch
|
||||
: [this.options.filePathToWatch];
|
||||
|
||||
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}/**/*`;
|
||||
});
|
||||
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() {
|
||||
if (this.currentExecution) {
|
||||
logger.log('ok', `reexecuting ${this.options.commandToExecute}`);
|
||||
process.kill(-this.currentExecution.childProcess.pid);
|
||||
} else {
|
||||
logger.log('ok', `executing ${this.options.commandToExecute} for the first time`);
|
||||
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.currentExecution && this.options.restart) {
|
||||
logger.log('ok', `[${name}] restarting: ${this.options.commandToExecute}`);
|
||||
this.currentExecution.kill();
|
||||
} else if (!this.currentExecution) {
|
||||
logger.log('ok', `[${name}] executing: ${this.options.commandToExecute}`);
|
||||
}
|
||||
|
||||
this.isExecuting = true;
|
||||
this.currentExecution = await this.smartshellInstance.execStreaming(
|
||||
this.options.commandToExecute,
|
||||
);
|
||||
|
||||
// Track when execution completes
|
||||
this.currentExecution.childProcess.on('exit', () => {
|
||||
this.isExecuting = false;
|
||||
});
|
||||
}
|
||||
|
||||
if (this.options.functionToCall) {
|
||||
this.isExecuting = true;
|
||||
try {
|
||||
await this.options.functionToCall();
|
||||
} finally {
|
||||
this.isExecuting = false;
|
||||
}
|
||||
}
|
||||
this.currentExecution = await this.smartshellInstance.execStreaming(
|
||||
this.options.commandToExecute
|
||||
);
|
||||
this.currentExecution = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* this method sets up a clean exit strategy
|
||||
*/
|
||||
private async setupCleanup() {
|
||||
const cleanup = () => {
|
||||
if (this.currentExecution) {
|
||||
process.kill(-this.currentExecution.childProcess.pid);
|
||||
}
|
||||
};
|
||||
process.on('exit', () => {
|
||||
console.log('');
|
||||
console.log('now exiting!');
|
||||
cleanup();
|
||||
this.stop();
|
||||
process.exit(0);
|
||||
});
|
||||
process.on('SIGINT', () => {
|
||||
console.log('');
|
||||
console.log('ok! got SIGINT We are exiting! Just cleaning up to exit neatly :)');
|
||||
cleanup();
|
||||
this.stop();
|
||||
process.exit(0);
|
||||
});
|
||||
|
||||
@@ -79,19 +201,22 @@ export class Watcher {
|
||||
if (this.options.timeout) {
|
||||
plugins.smartdelay.delayFor(this.options.timeout).then(() => {
|
||||
console.log(`timed out afer ${this.options.timeout} milliseconds! exiting!`);
|
||||
cleanup();
|
||||
this.stop();
|
||||
process.exit(0);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* stops the watcher
|
||||
*/
|
||||
public async stop() {
|
||||
await this.smartchokWatcher.stop();
|
||||
if (this.currentExecution) {
|
||||
process.kill(-this.currentExecution.childProcess.pid);
|
||||
if (this.debounceTimer) {
|
||||
clearTimeout(this.debounceTimer);
|
||||
}
|
||||
await this.smartwatchInstance.stop();
|
||||
if (this.currentExecution && !this.currentExecution.childProcess.killed) {
|
||||
this.currentExecution.kill();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,52 @@
|
||||
import * as plugins from './tswatch.plugins';
|
||||
import * as paths from './tswatch.paths';
|
||||
import { logger } from './tswatch.logging';
|
||||
import * as plugins from './tswatch.plugins.js';
|
||||
import * as paths from './tswatch.paths.js';
|
||||
import { logger } from './tswatch.logging.js';
|
||||
|
||||
import { TsWatch } from './tswatch.classes.tswatch';
|
||||
import { TsWatch } from './tswatch.classes.tswatch.js';
|
||||
import { ConfigHandler } from './tswatch.classes.confighandler.js';
|
||||
import { runInit } from './tswatch.init.js';
|
||||
|
||||
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('test').subscribe(async argvArg => {
|
||||
logger.log('info', `running test task`);
|
||||
const tsWatch = new TsWatch('test');
|
||||
await tsWatch.start();
|
||||
if (configHandler.hasConfig()) {
|
||||
// Config exists - run with it
|
||||
const tsWatch = TsWatch.fromConfig();
|
||||
if (tsWatch) {
|
||||
logger.log('info', 'Starting tswatch with configuration from npmextra.json');
|
||||
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('website').subscribe(async argvArg => {
|
||||
logger.log('info', `running watch task for a gitzone website project`);
|
||||
const tsWatch = new TsWatch('gitzone_website');
|
||||
await tsWatch.start();
|
||||
/**
|
||||
* Init command - force run wizard (overwrite existing config)
|
||||
*/
|
||||
tswatchCli.addCommand('init').subscribe(async (argvArg) => {
|
||||
logger.log('info', 'Running tswatch configuration wizard');
|
||||
const config = await runInit();
|
||||
if (config) {
|
||||
logger.log('ok', 'Configuration created successfully');
|
||||
}
|
||||
});
|
||||
|
||||
tswatchCli.startParse();
|
||||
export const runCli = async () => {
|
||||
tswatchCli.startParse();
|
||||
};
|
||||
|
||||
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();
|
||||
};
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as plugins from './tswatch.plugins';
|
||||
import * as plugins from './tswatch.plugins.js';
|
||||
|
||||
export const logger = new plugins.smartlog.Smartlog({
|
||||
logContext: {
|
||||
@@ -7,9 +7,9 @@ export const logger = new plugins.smartlog.Smartlog({
|
||||
containerName: 'Some Containername',
|
||||
environment: 'local',
|
||||
runtime: 'node',
|
||||
zone: 'gitzone'
|
||||
zone: 'gitzone',
|
||||
},
|
||||
minimumLogLevel: 'silly'
|
||||
minimumLogLevel: 'silly',
|
||||
});
|
||||
|
||||
logger.addLogDestination(new plugins.smartlogDestinationLocal.DestinationLocal());
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import * as plugins from './tswatch.plugins';
|
||||
import * as plugins from './tswatch.plugins.js';
|
||||
|
||||
export const cwd = process.cwd();
|
||||
|
||||
@@ -1,13 +1,39 @@
|
||||
// node native scope
|
||||
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 smartshell from '@pushrocks/smartshell';
|
||||
// @git.zone scope
|
||||
import * as tsbundle from '@git.zone/tsbundle';
|
||||
export { tsbundle };
|
||||
|
||||
export { lik, smartchok, smartcli, smartdelay, smartlog, smartlogDestinationLocal, smartshell };
|
||||
// @api.global scope
|
||||
import * as typedserver from '@api.global/typedserver';
|
||||
|
||||
export { typedserver };
|
||||
|
||||
// @push.rocks scope
|
||||
import * as lik from '@push.rocks/lik';
|
||||
import * as npmextra from '@push.rocks/npmextra';
|
||||
import * as smartcli from '@push.rocks/smartcli';
|
||||
import * as smartdelay from '@push.rocks/smartdelay';
|
||||
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 {
|
||||
lik,
|
||||
npmextra,
|
||||
smartcli,
|
||||
smartdelay,
|
||||
smartfs,
|
||||
smartinteract,
|
||||
smartlog,
|
||||
smartlogDestinationLocal,
|
||||
smartshell,
|
||||
smartwatch,
|
||||
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"
|
||||
]
|
||||
}
|
||||
17
tslint.json
17
tslint.json
@@ -1,17 +0,0 @@
|
||||
{
|
||||
"extends": ["tslint:latest", "tslint-config-prettier"],
|
||||
"rules": {
|
||||
"semicolon": [true, "always"],
|
||||
"no-console": false,
|
||||
"ordered-imports": false,
|
||||
"object-literal-sort-keys": false,
|
||||
"member-ordering": {
|
||||
"options":{
|
||||
"order": [
|
||||
"static-method"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"defaultSeverity": "warning"
|
||||
}
|
||||
Reference in New Issue
Block a user