Compare commits
32 Commits
Author | SHA1 | Date | |
---|---|---|---|
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 |
66
.gitea/workflows/default_nottags.yaml
Normal file
66
.gitea/workflows/default_nottags.yaml
Normal file
@@ -0,0 +1,66 @@
|
||||
name: Default (not tags)
|
||||
|
||||
on:
|
||||
push:
|
||||
tags-ignore:
|
||||
- '**'
|
||||
|
||||
env:
|
||||
IMAGE: code.foss.global/host.today/ht-docker-node:npmci
|
||||
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@/${{gitea.repository}}.git
|
||||
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
|
||||
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
|
||||
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
|
||||
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
|
||||
|
||||
jobs:
|
||||
security:
|
||||
runs-on: ubuntu-latest
|
||||
continue-on-error: true
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Install pnpm and npmci
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @ship.zone/npmci
|
||||
|
||||
- name: Run npm prepare
|
||||
run: npmci npm prepare
|
||||
|
||||
- name: Audit production dependencies
|
||||
run: |
|
||||
npmci command npm config set registry https://registry.npmjs.org
|
||||
npmci command pnpm audit --audit-level=high --prod
|
||||
continue-on-error: true
|
||||
|
||||
- name: Audit development dependencies
|
||||
run: |
|
||||
npmci command npm config set registry https://registry.npmjs.org
|
||||
npmci command pnpm audit --audit-level=high --dev
|
||||
continue-on-error: true
|
||||
|
||||
test:
|
||||
if: ${{ always() }}
|
||||
needs: security
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Test stable
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
npmci npm test
|
||||
|
||||
- name: Test build
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
npmci npm build
|
124
.gitea/workflows/default_tags.yaml
Normal file
124
.gitea/workflows/default_tags.yaml
Normal file
@@ -0,0 +1,124 @@
|
||||
name: Default (tags)
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
env:
|
||||
IMAGE: code.foss.global/host.today/ht-docker-node:npmci
|
||||
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@/${{gitea.repository}}.git
|
||||
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
|
||||
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
|
||||
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
|
||||
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
|
||||
|
||||
jobs:
|
||||
security:
|
||||
runs-on: ubuntu-latest
|
||||
continue-on-error: true
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Prepare
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @ship.zone/npmci
|
||||
npmci npm prepare
|
||||
|
||||
- name: Audit production dependencies
|
||||
run: |
|
||||
npmci command npm config set registry https://registry.npmjs.org
|
||||
npmci command pnpm audit --audit-level=high --prod
|
||||
continue-on-error: true
|
||||
|
||||
- name: Audit development dependencies
|
||||
run: |
|
||||
npmci command npm config set registry https://registry.npmjs.org
|
||||
npmci command pnpm audit --audit-level=high --dev
|
||||
continue-on-error: true
|
||||
|
||||
test:
|
||||
if: ${{ always() }}
|
||||
needs: security
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Prepare
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @ship.zone/npmci
|
||||
npmci npm prepare
|
||||
|
||||
- name: Test stable
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
npmci npm test
|
||||
|
||||
- name: Test build
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
npmci npm build
|
||||
|
||||
release:
|
||||
needs: test
|
||||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Prepare
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @ship.zone/npmci
|
||||
npmci npm prepare
|
||||
|
||||
- name: Release
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm publish
|
||||
|
||||
metadata:
|
||||
needs: test
|
||||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
continue-on-error: true
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Prepare
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @ship.zone/npmci
|
||||
npmci npm prepare
|
||||
|
||||
- name: Code quality
|
||||
run: |
|
||||
npmci command npm install -g typescript
|
||||
npmci npm install
|
||||
|
||||
- name: Trigger
|
||||
run: npmci trigger
|
||||
|
||||
- name: Build docs and upload artifacts
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
pnpm install -g @git.zone/tsdoc
|
||||
npmci command tsdoc
|
||||
continue-on-error: true
|
3
.gitignore
vendored
3
.gitignore
vendored
@@ -3,7 +3,6 @@
|
||||
# artifacts
|
||||
coverage/
|
||||
public/
|
||||
pages/
|
||||
|
||||
# installs
|
||||
node_modules/
|
||||
@@ -17,4 +16,4 @@ node_modules/
|
||||
dist/
|
||||
dist_*/
|
||||
|
||||
# custom
|
||||
#------# custom
|
24
.vscode/launch.json
vendored
24
.vscode/launch.json
vendored
@@ -2,28 +2,10 @@
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "current file",
|
||||
"type": "node",
|
||||
"command": "npm test",
|
||||
"name": "Run npm test",
|
||||
"request": "launch",
|
||||
"args": [
|
||||
"${relativeFile}"
|
||||
],
|
||||
"runtimeArgs": ["-r", "@git.zone/tsrun"],
|
||||
"cwd": "${workspaceRoot}",
|
||||
"protocol": "inspector",
|
||||
"internalConsoleOptions": "openOnSessionStart"
|
||||
},
|
||||
{
|
||||
"name": "test.ts",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"args": [
|
||||
"test/test.ts"
|
||||
],
|
||||
"runtimeArgs": ["-r", "@git.zone/tsrun"],
|
||||
"cwd": "${workspaceRoot}",
|
||||
"protocol": "inspector",
|
||||
"internalConsoleOptions": "openOnSessionStart"
|
||||
"type": "node-terminal"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
90
changelog.md
90
changelog.md
@@ -1,5 +1,95 @@
|
||||
# Changelog
|
||||
|
||||
## 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.
|
||||
|
||||
|
@@ -6,12 +6,37 @@
|
||||
"gitzone": {
|
||||
"projectType": "npm",
|
||||
"module": {
|
||||
"githost": "gitlab.com",
|
||||
"gitscope": "gitzone",
|
||||
"githost": "code.foss.global",
|
||||
"gitscope": "git.zone",
|
||||
"gitrepo": "tswatch",
|
||||
"shortDescription": "watch typescript projects during development",
|
||||
"npmPackagename": "@git.zone/tswatch",
|
||||
"license": "MIT"
|
||||
"license": "MIT",
|
||||
"description": "A development tool for automatically watching and re-compiling TypeScript projects upon detecting file changes, enhancing developer workflows.",
|
||||
"keywords": [
|
||||
"TypeScript",
|
||||
"development",
|
||||
"watcher",
|
||||
"automation",
|
||||
"CLI",
|
||||
"build",
|
||||
"npm",
|
||||
"web development",
|
||||
"service development",
|
||||
"project monitoring",
|
||||
"recompiling",
|
||||
"testing",
|
||||
"integration",
|
||||
"continuous development",
|
||||
"tooling",
|
||||
"build automation",
|
||||
"live reloading",
|
||||
"node.js",
|
||||
"development server"
|
||||
]
|
||||
}
|
||||
},
|
||||
"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"
|
||||
}
|
||||
}
|
63
package.json
63
package.json
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"name": "@git.zone/tswatch",
|
||||
"version": "2.0.29",
|
||||
"version": "2.1.5",
|
||||
"private": false,
|
||||
"description": "watch typescript projects during development",
|
||||
"description": "A development tool for automatically watching and re-compiling TypeScript projects upon detecting file changes, enhancing developer workflows.",
|
||||
"main": "dist_ts/index.js",
|
||||
"typings": "dist_ts/index.d.ts",
|
||||
"type": "module",
|
||||
@@ -13,27 +13,27 @@
|
||||
},
|
||||
"scripts": {
|
||||
"test": "(tstest test/ --web)",
|
||||
"build": "(tsbuild --web --allowimplicitany)"
|
||||
"build": "(tsbuild --web --allowimplicitany)",
|
||||
"buildDocs": "tsdoc"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@git.zone/tsbuild": "^2.2.0",
|
||||
"@git.zone/tstest": "^1.0.90",
|
||||
"@push.rocks/tapbundle": "^5.5.3",
|
||||
"@types/node": "^22.10.1"
|
||||
"@git.zone/tsbuild": "^2.6.4",
|
||||
"@git.zone/tstest": "^2.3.2",
|
||||
"@types/node": "^22"
|
||||
},
|
||||
"dependencies": {
|
||||
"@api.global/typedserver": "^3.0.51",
|
||||
"@git.zone/tsbundle": "^2.1.0",
|
||||
"@api.global/typedserver": "^3.0.74",
|
||||
"@git.zone/tsbundle": "^2.5.1",
|
||||
"@git.zone/tsrun": "^1.3.3",
|
||||
"@push.rocks/early": "^4.0.4",
|
||||
"@push.rocks/lik": "^6.1.0",
|
||||
"@push.rocks/smartchok": "^1.0.34",
|
||||
"@push.rocks/lik": "^6.2.2",
|
||||
"@push.rocks/smartchok": "^1.1.1",
|
||||
"@push.rocks/smartcli": "^4.0.11",
|
||||
"@push.rocks/smartdelay": "^3.0.5",
|
||||
"@push.rocks/smartfile": "^11.0.21",
|
||||
"@push.rocks/smartlog": "^3.0.7",
|
||||
"@push.rocks/smartfile": "^11.2.5",
|
||||
"@push.rocks/smartlog": "^3.1.8",
|
||||
"@push.rocks/smartlog-destination-local": "^9.0.2",
|
||||
"@push.rocks/smartshell": "^3.0.6",
|
||||
"@push.rocks/smartshell": "^3.2.3",
|
||||
"@push.rocks/taskbuffer": "^3.1.7"
|
||||
},
|
||||
"files": [
|
||||
@@ -50,5 +50,38 @@
|
||||
],
|
||||
"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"
|
||||
}
|
||||
|
6847
pnpm-lock.yaml
generated
6847
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,44 @@
|
||||
# tswatch Project Hints
|
||||
|
||||
## Core Architecture
|
||||
- tswatch is a TypeScript file watcher with multiple operation modes
|
||||
- Main class `TsWatch` orchestrates different watch modes
|
||||
- `Watcher` class handles individual file watching and command execution
|
||||
|
||||
## Available Watch Modes
|
||||
1. **npm/node** (default): Runs `npm test` on changes
|
||||
2. **test**: Runs `npm run test2` on changes
|
||||
3. **element**: Web component development with dev server on port 3002
|
||||
4. **service**: Runs `npm run startTs` for service projects
|
||||
5. **website**: Full website mode with bundling and asset processing
|
||||
6. **echo**: Test mode that runs `npm -v` (for testing)
|
||||
|
||||
## Key Implementation Details
|
||||
- Uses `@push.rocks/smartchok` for file watching
|
||||
- Uses `@git.zone/tsbundle` for bundling with esbuild
|
||||
- Uses `@api.global/typedserver` for development server in element mode
|
||||
- Element/website modes watch multiple `ts*/` directories
|
||||
- All modes support both command execution and function callbacks
|
||||
|
||||
## CLI Entry Points
|
||||
- `cli.js` -> Main CLI entry point
|
||||
- `ts/tswatch.cli.ts` -> CLI implementation with smartcli
|
||||
- Default command triggers npm mode
|
||||
|
||||
## Project Structure Expectations
|
||||
- `ts/` - Backend TypeScript files
|
||||
- `ts_web/` - Frontend TypeScript files (element/website modes)
|
||||
- `html/` - HTML templates (element/website modes)
|
||||
- `assets/` - Static assets (website mode only)
|
||||
- `dist_watch/` - Output for element mode
|
||||
- `dist_serve/` - Output for website mode
|
||||
|
||||
## Development Server Details
|
||||
- Port: 3002
|
||||
- Features: CORS, gzip compression, live reload injection
|
||||
- Only available in element mode via `typedserver` property
|
||||
|
||||
## Common Issues to Watch For
|
||||
- The test mode runs `test2` script, not `test`
|
||||
- Website mode restarts the entire server process on backend changes
|
||||
- Element mode rebuilds and reloads on any ts* folder change
|
246
readme.md
246
readme.md
@@ -1,39 +1,229 @@
|
||||
# @git.zone/tswatch
|
||||
watch typescript projects during development
|
||||
|
||||
## Availabililty and Links
|
||||
* [npmjs.org (npm package)](https://www.npmjs.com/package/@git.zone/tswatch)
|
||||
* [gitlab.com (source)](https://gitlab.com/gitzone/tswatch)
|
||||
* [github.com (source mirror)](https://github.com/gitzone/tswatch)
|
||||
* [docs (typedoc)](https://gitzone.gitlab.io/tswatch/)
|
||||
A TypeScript file watcher that automatically recompiles and executes your project when files change. Designed to streamline development workflows for various TypeScript project types.
|
||||
|
||||
## Status for master
|
||||
## Features
|
||||
|
||||
Status Category | Status Badge
|
||||
-- | --
|
||||
GitLab Pipelines | [](https://lossless.cloud)
|
||||
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
||||
npm | [](https://lossless.cloud)
|
||||
Snyk | [](https://lossless.cloud)
|
||||
TypeScript Support | [](https://lossless.cloud)
|
||||
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
Code Style | [](https://lossless.cloud)
|
||||
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
||||
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
||||
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
||||
Platform support | [](https://lossless.cloud) [](https://lossless.cloud)
|
||||
- 🔄 **Automatic recompilation** on file changes
|
||||
- 🚀 **Multiple project modes**: npm packages, web elements, services, and websites
|
||||
- 🌐 **Built-in development server** with live reload for web projects
|
||||
- ⚡ **Fast bundling** with esbuild integration
|
||||
- 🛠️ **Flexible CLI and programmatic API**
|
||||
- 📦 **Zero configuration** for standard project structures
|
||||
|
||||
## Usage
|
||||
## Prerequisites
|
||||
|
||||
Use TypeScript for best in class intellisense
|
||||
- Node.js (v14 or higher)
|
||||
- pnpm (recommended) or npm
|
||||
|
||||
## Contribution
|
||||
## Installation
|
||||
|
||||
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
|
||||
Install `@git.zone/tswatch` globally or as a development dependency:
|
||||
|
||||
For further information read the linked docs at the top of this readme.
|
||||
```bash
|
||||
# Global installation
|
||||
pnpm install -g @git.zone/tswatch
|
||||
|
||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||
# As a dev dependency
|
||||
pnpm install --save-dev @git.zone/tswatch
|
||||
```
|
||||
|
||||
[](https://maintainedby.lossless.com)
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
# Watch and run tests on changes (default behavior)
|
||||
tswatch
|
||||
|
||||
# Watch a web element project with dev server
|
||||
tswatch element
|
||||
|
||||
# Watch a service project
|
||||
tswatch service
|
||||
```
|
||||
|
||||
## CLI Commands
|
||||
|
||||
### `tswatch` or `tswatch npm`
|
||||
Watches TypeScript files and runs `npm test` on changes. This is the default mode.
|
||||
|
||||
```bash
|
||||
tswatch
|
||||
# or explicitly
|
||||
tswatch npm
|
||||
```
|
||||
|
||||
### `tswatch element`
|
||||
Sets up a development environment for web components/elements:
|
||||
- Starts a dev server on port 3002
|
||||
- Bundles TypeScript to `dist_watch/`
|
||||
- Enables live reload
|
||||
- Watches all `ts*/` folders
|
||||
|
||||
```bash
|
||||
tswatch element
|
||||
```
|
||||
|
||||
### `tswatch service`
|
||||
Watches TypeScript files in `./ts/` and runs `npm run startTs` on changes. Ideal for backend services.
|
||||
|
||||
```bash
|
||||
tswatch service
|
||||
```
|
||||
|
||||
### `tswatch website`
|
||||
Full website development mode:
|
||||
- Bundles TypeScript files to `dist_serve/`
|
||||
- Processes HTML files
|
||||
- Handles assets
|
||||
- Runs `npm run startTs` for server-side code
|
||||
|
||||
```bash
|
||||
tswatch website
|
||||
```
|
||||
|
||||
### `tswatch test`
|
||||
Runs `npm run test2` whenever files change. Useful for projects with custom test scripts.
|
||||
|
||||
```bash
|
||||
tswatch test
|
||||
```
|
||||
|
||||
## Project Structure
|
||||
|
||||
tswatch expects certain project structures depending on the mode:
|
||||
|
||||
### NPM/Node Projects
|
||||
```
|
||||
project/
|
||||
├── ts/ # TypeScript source files
|
||||
├── test/ # Test files
|
||||
└── package.json # With "test" script
|
||||
```
|
||||
|
||||
### Element Projects
|
||||
```
|
||||
project/
|
||||
├── ts/ # Backend TypeScript
|
||||
├── ts_web/ # Frontend TypeScript
|
||||
├── html/ # HTML templates
|
||||
│ └── index.ts # Entry point
|
||||
└── dist_watch/ # Output directory (auto-created)
|
||||
```
|
||||
|
||||
### Website Projects
|
||||
```
|
||||
project/
|
||||
├── ts/ # Backend TypeScript
|
||||
├── ts_web/ # Frontend TypeScript
|
||||
│ └── index.ts # Entry point
|
||||
├── html/ # HTML files
|
||||
│ └── index.html
|
||||
├── assets/ # Static assets
|
||||
└── dist_serve/ # Output directory
|
||||
```
|
||||
|
||||
## Programmatic API
|
||||
|
||||
### Basic Usage
|
||||
|
||||
```typescript
|
||||
import { TsWatch } from '@git.zone/tswatch';
|
||||
|
||||
// Create and start a watcher
|
||||
const watcher = new TsWatch('node');
|
||||
await watcher.start();
|
||||
|
||||
// Stop when done
|
||||
await watcher.stop();
|
||||
```
|
||||
|
||||
### Custom Watchers
|
||||
|
||||
```typescript
|
||||
import { Watcher } from '@git.zone/tswatch';
|
||||
|
||||
const customWatcher = new Watcher({
|
||||
filePathToWatch: './src',
|
||||
commandToExecute: 'npm run build',
|
||||
timeout: 5000 // Optional timeout in ms
|
||||
});
|
||||
|
||||
await customWatcher.start();
|
||||
```
|
||||
|
||||
### Using Function Callbacks
|
||||
|
||||
```typescript
|
||||
const watcher = new Watcher({
|
||||
filePathToWatch: './src',
|
||||
functionToCall: async () => {
|
||||
console.log('Files changed!');
|
||||
// Your custom logic here
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
## Development Server
|
||||
|
||||
Element mode includes a built-in development server:
|
||||
|
||||
- **Port**: 3002
|
||||
- **Features**: CORS enabled, gzip compression, live reload
|
||||
- **Serve directory**: `./dist_watch/`
|
||||
|
||||
Access your project at `http://localhost:3002` when running in element mode.
|
||||
|
||||
## Configuration Tips
|
||||
|
||||
1. **TypeScript Config**: Ensure your `tsconfig.json` is properly configured for your target environment
|
||||
2. **Package Scripts**: Define appropriate scripts in `package.json`:
|
||||
- `test`: For npm mode
|
||||
- `startTs`: For service/website modes
|
||||
- `build`: For general compilation
|
||||
|
||||
3. **File Organization**: Keep TypeScript files in `ts/` (backend) and `ts_web/` (frontend) directories
|
||||
|
||||
## Common Use Cases
|
||||
|
||||
### Developing a Node.js Library
|
||||
```bash
|
||||
tswatch npm
|
||||
```
|
||||
Automatically runs tests when you modify source files.
|
||||
|
||||
### Building a Web Component
|
||||
```bash
|
||||
tswatch element
|
||||
```
|
||||
Get instant feedback with live reload while developing custom elements.
|
||||
|
||||
### Creating a Backend Service
|
||||
```bash
|
||||
tswatch service
|
||||
```
|
||||
Automatically restart your service on code changes.
|
||||
|
||||
### Full-Stack Web Application
|
||||
```bash
|
||||
tswatch website
|
||||
```
|
||||
Handle both frontend and backend compilation with asset processing.
|
||||
|
||||
## License and Legal Information
|
||||
|
||||
This 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.
|
||||
|
||||
**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 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.
|
||||
|
||||
### Company Information
|
||||
|
||||
Task Venture Capital GmbH
|
||||
Registered at District court Bremen HRB 35230 HB, Germany
|
||||
|
||||
For any legal inquiries or if you require 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.
|
||||
|
@@ -1,11 +1,11 @@
|
||||
// tslint:disable-next-line: no-implicit-dependencies
|
||||
import { expect, expectAsync, tap } from '@push.rocks/tapbundle';
|
||||
import { expect, tap } from '@git.zone/tstest/tapbundle';
|
||||
import * as tswatch from '../ts/index.js';
|
||||
|
||||
let testTsWatchInstance: tswatch.TsWatch;
|
||||
|
||||
tap.test('should create a valid TsWatch instance', async () => {
|
||||
testTsWatchInstance = new tswatch.TsWatch('echoSomething');
|
||||
testTsWatchInstance = new tswatch.TsWatch('echo');
|
||||
});
|
||||
|
||||
tap.test('should start the tswatch instance', async () => {
|
||||
|
@@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@git.zone/tswatch',
|
||||
version: '2.0.29',
|
||||
description: 'watch typescript projects during development'
|
||||
version: '2.1.3',
|
||||
description: 'A development tool for automatically watching and re-compiling TypeScript projects upon detecting file changes, enhancing developer workflows.'
|
||||
}
|
||||
|
@@ -1,7 +1 @@
|
||||
export type TWatchModes =
|
||||
| 'test'
|
||||
| 'node'
|
||||
| 'service'
|
||||
| 'element'
|
||||
| 'website'
|
||||
| 'echo';
|
||||
export type TWatchModes = 'test' | 'node' | 'service' | 'element' | 'website' | 'echo';
|
||||
|
@@ -19,6 +19,7 @@ export class TsWatch {
|
||||
*/
|
||||
public async start() {
|
||||
const tsbundle = new plugins.tsbundle.TsBundle();
|
||||
const assetsHandler = new plugins.tsbundle.AssetsHandler();
|
||||
const htmlHandler = new plugins.tsbundle.HtmlHandler();
|
||||
switch (this.watchmode) {
|
||||
case 'test':
|
||||
@@ -30,7 +31,7 @@ export class TsWatch {
|
||||
filePathToWatch: paths.cwd,
|
||||
commandToExecute: 'npm run test2',
|
||||
timeout: null,
|
||||
})
|
||||
}),
|
||||
);
|
||||
break;
|
||||
case 'node':
|
||||
@@ -39,17 +40,18 @@ export class TsWatch {
|
||||
filePathToWatch: paths.cwd,
|
||||
commandToExecute: 'npm run test',
|
||||
timeout: null,
|
||||
})
|
||||
}),
|
||||
);
|
||||
break;
|
||||
case 'element':
|
||||
(async () => {
|
||||
await (async () => {
|
||||
/**
|
||||
* this strategy runs a standard server and bundles the ts files to a dist_watch directory
|
||||
*/
|
||||
// lets create a standard server
|
||||
console.log(
|
||||
'bundling TypeScript files to "dist_watch" Note: This is for development only!'
|
||||
logger.log(
|
||||
'info',
|
||||
'bundling TypeScript files to "dist_watch" Note: This is for development only!',
|
||||
);
|
||||
this.typedserver = new plugins.typedserver.TypedServer({
|
||||
cors: true,
|
||||
@@ -73,13 +75,13 @@ export class TsWatch {
|
||||
await bundleAndReloadElement();
|
||||
},
|
||||
timeout: null,
|
||||
})
|
||||
}),
|
||||
);
|
||||
|
||||
// lets get the other ts folders
|
||||
let tsfolders = await plugins.smartfile.fs.listFolders(paths.cwd);
|
||||
tsfolders = tsfolders.filter(
|
||||
(itemArg) => itemArg.startsWith('ts') && itemArg !== 'ts_web'
|
||||
(itemArg) => itemArg.startsWith('ts') && itemArg !== 'ts_web',
|
||||
);
|
||||
const smartshellInstance = new plugins.smartshell.Smartshell({
|
||||
executor: 'bash',
|
||||
@@ -92,10 +94,10 @@ export class TsWatch {
|
||||
functionToCall: async () => {
|
||||
logger.log('info', `building ${tsfolder}`);
|
||||
await smartshellInstance.exec(`(cd ${paths.cwd} && npm run build)`);
|
||||
await this.typedserver.reload();
|
||||
await bundleAndReloadElement();
|
||||
},
|
||||
timeout: null,
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -111,12 +113,13 @@ export class TsWatch {
|
||||
await bundleAndReloadElement();
|
||||
},
|
||||
timeout: null,
|
||||
})
|
||||
}),
|
||||
);
|
||||
})();
|
||||
break;
|
||||
case 'website':
|
||||
(async () => {
|
||||
await (async () => {
|
||||
const websiteExecution = new plugins.smartshell.SmartExecution('npm run startTs');
|
||||
const bundleAndReloadWebsite = async () => {
|
||||
await tsbundle.build(paths.cwd, './ts_web/index.ts', './dist_serve/bundle.js', {
|
||||
bundler: 'esbuild',
|
||||
@@ -124,18 +127,18 @@ export class TsWatch {
|
||||
};
|
||||
let tsfolders = await plugins.smartfile.fs.listFolders(paths.cwd);
|
||||
tsfolders = tsfolders.filter(
|
||||
(itemArg) => itemArg.startsWith('ts') && itemArg !== 'ts_web'
|
||||
(itemArg) => itemArg.startsWith('ts') && itemArg !== 'ts_web',
|
||||
);
|
||||
const smartshellInstance = new plugins.smartshell.Smartshell({
|
||||
executor: 'bash',
|
||||
});
|
||||
for (const tsfolder of tsfolders) {
|
||||
this.watcherMap.add(
|
||||
new Watcher({
|
||||
filePathToWatch: plugins.path.join(paths.cwd, `./${tsfolder}/`),
|
||||
commandToExecute: `npm run startTs`,
|
||||
functionToCall: async () => {
|
||||
await websiteExecution.restart();
|
||||
await bundleAndReloadWebsite();
|
||||
},
|
||||
timeout: null,
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
this.watcherMap.add(
|
||||
@@ -145,7 +148,7 @@ export class TsWatch {
|
||||
await bundleAndReloadWebsite();
|
||||
},
|
||||
timeout: null,
|
||||
})
|
||||
}),
|
||||
);
|
||||
this.watcherMap.add(
|
||||
new Watcher({
|
||||
@@ -159,7 +162,17 @@ export class TsWatch {
|
||||
await bundleAndReloadWebsite();
|
||||
},
|
||||
timeout: null,
|
||||
})
|
||||
}),
|
||||
);
|
||||
this.watcherMap.add(
|
||||
new Watcher({
|
||||
filePathToWatch: plugins.path.join(paths.cwd, './assets/'),
|
||||
functionToCall: async () => {
|
||||
await assetsHandler.processAssets();
|
||||
await bundleAndReloadWebsite();
|
||||
},
|
||||
timeout: null,
|
||||
}),
|
||||
);
|
||||
})();
|
||||
break;
|
||||
@@ -169,7 +182,7 @@ export class TsWatch {
|
||||
filePathToWatch: plugins.path.join(paths.cwd, './ts/'),
|
||||
commandToExecute: 'npm run startTs',
|
||||
timeout: null,
|
||||
})
|
||||
}),
|
||||
);
|
||||
break;
|
||||
case 'echo':
|
||||
|
@@ -31,6 +31,7 @@ export class Watcher {
|
||||
* start the file
|
||||
*/
|
||||
public async start() {
|
||||
logger.log('info', `trying to start watcher for ${this.options.filePathToWatch}`);
|
||||
await this.setupCleanup();
|
||||
console.log(`Looking at ${this.options.filePathToWatch} for changes`);
|
||||
this.smartchokWatcher.add([this.options.filePathToWatch]); // __dirname refers to the directory of this very file
|
||||
@@ -40,6 +41,7 @@ export class Watcher {
|
||||
this.updateCurrentExecution();
|
||||
});
|
||||
await this.updateCurrentExecution();
|
||||
logger.log('info', `watcher started for ${this.options.filePathToWatch}`);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,7 +56,7 @@ export class Watcher {
|
||||
logger.log('ok', `executing ${this.options.commandToExecute} for the first time`);
|
||||
}
|
||||
this.currentExecution = await this.smartshellInstance.execStreaming(
|
||||
this.options.commandToExecute
|
||||
this.options.commandToExecute,
|
||||
);
|
||||
} else {
|
||||
console.log('no executionCommand set');
|
||||
@@ -62,7 +64,7 @@ export class Watcher {
|
||||
if (this.options.functionToCall) {
|
||||
this.options.functionToCall();
|
||||
} else {
|
||||
console.log('no functionToCall set.')
|
||||
console.log('no functionToCall set.');
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -7,9 +7,9 @@ import { TsWatch } from './tswatch.classes.tswatch.js';
|
||||
const tswatchCli = new plugins.smartcli.Smartcli();
|
||||
|
||||
// standard behaviour will assume gitzone setup
|
||||
tswatchCli.standardCommand().subscribe((argvArg => {
|
||||
tswatchCli.standardCommand().subscribe((argvArg) => {
|
||||
tswatchCli.triggerCommand('npm', {});
|
||||
}))
|
||||
});
|
||||
|
||||
tswatchCli.addCommand('element').subscribe(async (argvArg) => {
|
||||
logger.log('info', `running watch task for a gitzone element project`);
|
||||
|
@@ -4,16 +4,12 @@ export { path };
|
||||
|
||||
// @gitzone scope
|
||||
import * as tsbundle from '@git.zone/tsbundle';
|
||||
export {
|
||||
tsbundle
|
||||
}
|
||||
export { tsbundle };
|
||||
|
||||
// @apiglobal scope
|
||||
import * as typedserver from '@api.global/typedserver';
|
||||
|
||||
export {
|
||||
typedserver,
|
||||
}
|
||||
export { typedserver };
|
||||
|
||||
// @pushrocks scope
|
||||
import * as lik from '@push.rocks/lik';
|
||||
|
@@ -6,9 +6,11 @@
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"esModuleInterop": true,
|
||||
"verbatimModuleSyntax": true
|
||||
"verbatimModuleSyntax": true,
|
||||
"baseUrl": ".",
|
||||
"paths": {}
|
||||
},
|
||||
"exclude": [
|
||||
"dist_*/**/*.d.ts"
|
||||
]
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user