Compare commits
22 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0dee896201 | |||
| 29f7283f7a | |||
| 3eb99e1f08 | |||
| ad41fe876d | |||
| d6f3381e71 | |||
| bcbf6fc139 | |||
| f73ca7ac2f | |||
| 75acc4b768 | |||
| 83cf8594ab | |||
| 417dc4c763 | |||
| 64a86f7af3 | |||
| 1a66e76b6f | |||
| 5c04dc7729 | |||
| ecd76bc8aa | |||
| 488bd65933 | |||
| 5763858bac | |||
| a4c8e33e3a | |||
| 81941c33cb | |||
| 7605702ba7 | |||
| 2d1c037301 | |||
| b46fb0f042 | |||
| c09f82083d |
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
|
||||
BIN
.serena/cache/typescript/document_symbols_cache_v23-06-25.pkl
vendored
Normal file
BIN
.serena/cache/typescript/document_symbols_cache_v23-06-25.pkl
vendored
Normal file
Binary file not shown.
68
.serena/project.yml
Normal file
68
.serena/project.yml
Normal file
@@ -0,0 +1,68 @@
|
||||
# language of the project (csharp, python, rust, java, typescript, go, cpp, or ruby)
|
||||
# * For C, use cpp
|
||||
# * For JavaScript, use typescript
|
||||
# Special requirements:
|
||||
# * csharp: Requires the presence of a .sln file in the project folder.
|
||||
language: typescript
|
||||
|
||||
# whether to use the project's gitignore file to ignore files
|
||||
# Added on 2025-04-07
|
||||
ignore_all_files_in_gitignore: true
|
||||
# list of additional paths to ignore
|
||||
# same syntax as gitignore, so you can use * and **
|
||||
# Was previously called `ignored_dirs`, please update your config if you are using that.
|
||||
# Added (renamed) on 2025-04-07
|
||||
ignored_paths: []
|
||||
|
||||
# whether the project is in read-only mode
|
||||
# If set to true, all editing tools will be disabled and attempts to use them will result in an error
|
||||
# Added on 2025-04-18
|
||||
read_only: false
|
||||
|
||||
|
||||
# list of tool names to exclude. We recommend not excluding any tools, see the readme for more details.
|
||||
# Below is the complete list of tools for convenience.
|
||||
# To make sure you have the latest list of tools, and to view their descriptions,
|
||||
# execute `uv run scripts/print_tool_overview.py`.
|
||||
#
|
||||
# * `activate_project`: Activates a project by name.
|
||||
# * `check_onboarding_performed`: Checks whether project onboarding was already performed.
|
||||
# * `create_text_file`: Creates/overwrites a file in the project directory.
|
||||
# * `delete_lines`: Deletes a range of lines within a file.
|
||||
# * `delete_memory`: Deletes a memory from Serena's project-specific memory store.
|
||||
# * `execute_shell_command`: Executes a shell command.
|
||||
# * `find_referencing_code_snippets`: Finds code snippets in which the symbol at the given location is referenced.
|
||||
# * `find_referencing_symbols`: Finds symbols that reference the symbol at the given location (optionally filtered by type).
|
||||
# * `find_symbol`: Performs a global (or local) search for symbols with/containing a given name/substring (optionally filtered by type).
|
||||
# * `get_current_config`: Prints the current configuration of the agent, including the active and available projects, tools, contexts, and modes.
|
||||
# * `get_symbols_overview`: Gets an overview of the top-level symbols defined in a given file.
|
||||
# * `initial_instructions`: Gets the initial instructions for the current project.
|
||||
# Should only be used in settings where the system prompt cannot be set,
|
||||
# e.g. in clients you have no control over, like Claude Desktop.
|
||||
# * `insert_after_symbol`: Inserts content after the end of the definition of a given symbol.
|
||||
# * `insert_at_line`: Inserts content at a given line in a file.
|
||||
# * `insert_before_symbol`: Inserts content before the beginning of the definition of a given symbol.
|
||||
# * `list_dir`: Lists files and directories in the given directory (optionally with recursion).
|
||||
# * `list_memories`: Lists memories in Serena's project-specific memory store.
|
||||
# * `onboarding`: Performs onboarding (identifying the project structure and essential tasks, e.g. for testing or building).
|
||||
# * `prepare_for_new_conversation`: Provides instructions for preparing for a new conversation (in order to continue with the necessary context).
|
||||
# * `read_file`: Reads a file within the project directory.
|
||||
# * `read_memory`: Reads the memory with the given name from Serena's project-specific memory store.
|
||||
# * `remove_project`: Removes a project from the Serena configuration.
|
||||
# * `replace_lines`: Replaces a range of lines within a file with new content.
|
||||
# * `replace_symbol_body`: Replaces the full definition of a symbol.
|
||||
# * `restart_language_server`: Restarts the language server, may be necessary when edits not through Serena happen.
|
||||
# * `search_for_pattern`: Performs a search for a pattern in the project.
|
||||
# * `summarize_changes`: Provides instructions for summarizing the changes made to the codebase.
|
||||
# * `switch_modes`: Activates modes by providing a list of their names
|
||||
# * `think_about_collected_information`: Thinking tool for pondering the completeness of collected information.
|
||||
# * `think_about_task_adherence`: Thinking tool for determining whether the agent is still on track with the current task.
|
||||
# * `think_about_whether_you_are_done`: Thinking tool for determining whether the task is truly completed.
|
||||
# * `write_memory`: Writes a named memory (for future reference) to Serena's project-specific memory store.
|
||||
excluded_tools: []
|
||||
|
||||
# initial prompt for the project. It will always be given to the LLM upon activating the project
|
||||
# (contrary to the memories, which are loaded on demand).
|
||||
initial_prompt: ""
|
||||
|
||||
project_name: "tswatch"
|
||||
74
changelog.md
74
changelog.md
@@ -1,5 +1,79 @@
|
||||
# Changelog
|
||||
|
||||
## 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
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
"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",
|
||||
|
||||
51
package.json
51
package.json
@@ -1,10 +1,11 @@
|
||||
{
|
||||
"name": "@git.zone/tswatch",
|
||||
"version": "2.0.38",
|
||||
"version": "2.2.4",
|
||||
"private": false,
|
||||
"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",
|
||||
"exports": {
|
||||
".": "./dist_ts/index.js"
|
||||
},
|
||||
"type": "module",
|
||||
"author": "Lossless GmbH",
|
||||
"license": "MIT",
|
||||
@@ -13,28 +14,28 @@
|
||||
},
|
||||
"scripts": {
|
||||
"test": "(tstest test/ --web)",
|
||||
"build": "(tsbuild --web --allowimplicitany)"
|
||||
"build": "(tsbuild --web --allowimplicitany)",
|
||||
"buildDocs": "tsdoc"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@git.zone/tsbuild": "^2.2.1",
|
||||
"@git.zone/tstest": "^1.0.96",
|
||||
"@push.rocks/tapbundle": "^5.5.6",
|
||||
"@types/node": "^22.12.0"
|
||||
"@git.zone/tsbuild": "^3.1.2",
|
||||
"@git.zone/tstest": "^3.1.3",
|
||||
"@types/node": "^24.10.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@api.global/typedserver": "^3.0.55",
|
||||
"@git.zone/tsbundle": "^2.2.1",
|
||||
"@git.zone/tsrun": "^1.3.3",
|
||||
"@api.global/typedserver": "^7.4.1",
|
||||
"@git.zone/tsbundle": "^2.6.3",
|
||||
"@git.zone/tsrun": "^2.0.0",
|
||||
"@push.rocks/early": "^4.0.4",
|
||||
"@push.rocks/lik": "^6.1.0",
|
||||
"@push.rocks/smartchok": "^1.0.34",
|
||||
"@push.rocks/smartcli": "^4.0.11",
|
||||
"@push.rocks/lik": "^6.2.2",
|
||||
"@push.rocks/smartcli": "^4.0.19",
|
||||
"@push.rocks/smartdelay": "^3.0.5",
|
||||
"@push.rocks/smartfile": "^11.1.6",
|
||||
"@push.rocks/smartlog": "^3.0.7",
|
||||
"@push.rocks/smartfs": "^1.2.0",
|
||||
"@push.rocks/smartlog": "^3.1.10",
|
||||
"@push.rocks/smartlog-destination-local": "^9.0.2",
|
||||
"@push.rocks/smartshell": "^3.2.2",
|
||||
"@push.rocks/taskbuffer": "^3.1.7"
|
||||
"@push.rocks/smartshell": "^3.3.0",
|
||||
"@push.rocks/smartwatch": "^5.0.0",
|
||||
"@push.rocks/taskbuffer": "^3.5.0"
|
||||
},
|
||||
"files": [
|
||||
"ts/**/*",
|
||||
@@ -71,5 +72,17 @@
|
||||
"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"
|
||||
}
|
||||
|
||||
8789
pnpm-lock.yaml
generated
8789
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,51 @@
|
||||
# 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/smartwatch` (v5.x) for file watching - class is `Smartwatch`
|
||||
- Uses `@push.rocks/smartfs` (v1.x) for directory operations - uses `SmartFs` with `SmartFsProviderNode`
|
||||
- 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
|
||||
|
||||
## Migration Notes (v2.2.x)
|
||||
- Replaced `@push.rocks/smartchok` with `@push.rocks/smartwatch` (v5.x)
|
||||
- Replaced `@push.rocks/smartfile` with `@push.rocks/smartfs` for directory listing
|
||||
- Class names: `Smartwatch` for file watching, `SmartFs` + `SmartFsProviderNode` for filesystem ops
|
||||
- Directory paths are converted to glob patterns (`/path/to/dir/` → `/path/to/dir/**/*`) for smartwatch compatibility
|
||||
|
||||
323
readme.md
323
readme.md
@@ -1,198 +1,275 @@
|
||||
# @git.zone/tswatch
|
||||
A development tool for watching and re-compiling TypeScript projects automatically upon detecting changes.
|
||||
|
||||
## Install
|
||||
A TypeScript file watcher that automatically recompiles and executes your project when files change. Designed to streamline development workflows for various TypeScript project types.
|
||||
|
||||
To install `@git.zone/tswatch`, ensure that you have a Node.js environment set up with npm. You can install the package globally or locally within a project using npm:
|
||||
## Issue Reporting and Security
|
||||
|
||||
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.
|
||||
|
||||
## Features
|
||||
|
||||
- 🔄 **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
|
||||
|
||||
## Installation
|
||||
|
||||
Install `@git.zone/tswatch` globally or as a development dependency:
|
||||
|
||||
```bash
|
||||
npm install @git.zone/tswatch
|
||||
# Global installation
|
||||
pnpm install -g @git.zone/tswatch
|
||||
|
||||
# As a dev dependency
|
||||
pnpm install --save-dev @git.zone/tswatch
|
||||
```
|
||||
|
||||
This command will install the package and enable you to use the `tswatch` command in your terminal to watch TypeScript projects.
|
||||
## Quick Start
|
||||
|
||||
## Usage
|
||||
```bash
|
||||
# Watch and run tests on changes (default behavior)
|
||||
tswatch
|
||||
|
||||
`@git.zone/tswatch` is a powerful tool designed to streamline your development workflow by monitoring your TypeScript files and automatically recompiling them when changes are detected. This utility is particularly helpful during the development phase of a TypeScript project, ensuring your project remains up-to-date, reflecting the latest changes seamlessly.
|
||||
# Watch a web element project with dev server
|
||||
tswatch element
|
||||
|
||||
### Getting Started with tswatch
|
||||
|
||||
To get started, we will explore setting up a basic watcher, integrating tswatch into a Node.js environment, utilizing advanced features, and handling multiple watchers.
|
||||
|
||||
### Setting Up a Basic Watcher
|
||||
|
||||
#### Step 1: Basic Command-Line Interface Usage
|
||||
|
||||
After installing `@git.zone/tswatch`, you can start a watcher on your TypeScript project using its command-line interface (CLI). Here's how to initiate a watcher for different project types:
|
||||
|
||||
```typescript
|
||||
import { runCli } from '@git.zone/tswatch';
|
||||
|
||||
(async () => {
|
||||
await runCli();
|
||||
})();
|
||||
# Watch a service project
|
||||
tswatch service
|
||||
```
|
||||
|
||||
The CLI supports several commands to watch different project types such as `element`, `npm`, `service`, and `website`. Here's how to use them:
|
||||
## CLI Commands
|
||||
|
||||
- **NPM Projects**: Watch a Node.js NPM project:
|
||||
### `tswatch` or `tswatch npm`
|
||||
|
||||
```bash
|
||||
tswatch npm
|
||||
```
|
||||
Watches TypeScript files and runs `npm test` on changes. This is the default mode.
|
||||
|
||||
This command will start a watcher for your node module projects. Whenever changes are detected, the specified npm scripts are executed.
|
||||
```bash
|
||||
tswatch
|
||||
# or explicitly
|
||||
tswatch npm
|
||||
```
|
||||
|
||||
- **Element Projects**: Watch an element-based architecture:
|
||||
### `tswatch element`
|
||||
|
||||
```bash
|
||||
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
|
||||
|
||||
This command sets up a development server with live reloading and bundles TypeScript files to a `dist_watch` directory.
|
||||
```bash
|
||||
tswatch element
|
||||
```
|
||||
|
||||
- **Service Projects**: Watch a service project:
|
||||
### `tswatch service`
|
||||
|
||||
```bash
|
||||
tswatch service
|
||||
```
|
||||
Watches TypeScript files in `./ts/` and runs `npm run startTs` on changes. Ideal for backend services.
|
||||
|
||||
Watches TypeScript files in a service pattern, restarting the service when changes are detected.
|
||||
```bash
|
||||
tswatch service
|
||||
```
|
||||
|
||||
- **Website Projects**: Perfect for full website projects:
|
||||
### `tswatch website`
|
||||
|
||||
```bash
|
||||
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
|
||||
|
||||
Similar to element projects but specifically designed for full websites, recompiling TypeScript files for web deployment scenarios.
|
||||
```bash
|
||||
tswatch website
|
||||
```
|
||||
|
||||
#### Step 2: Integration into a Node.js Environment
|
||||
### `tswatch test`
|
||||
|
||||
You can integrate `@git.zone/tswatch` directly into a Node.js project for automatic file watching and recompiling:
|
||||
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';
|
||||
|
||||
const startWatch = async () => {
|
||||
// Initialize watch instance for a node project
|
||||
const watchInstance = new TsWatch('node');
|
||||
await watchInstance.start();
|
||||
};
|
||||
// Create and start a watcher
|
||||
const watcher = new TsWatch('node');
|
||||
await watcher.start();
|
||||
|
||||
// Optionally, stop the watcher gracefully
|
||||
const stopWatch = async (watchInstance: TsWatch) => {
|
||||
await watchInstance.stop();
|
||||
};
|
||||
// Stop when done
|
||||
await watcher.stop();
|
||||
```
|
||||
|
||||
This setup will establish a node environment watch, automatically recompiling files as changes occur.
|
||||
### Available Watch Modes
|
||||
|
||||
### Advanced Usage: Enhancing Workflow with tswatch
|
||||
The `TsWatch` class accepts the following modes:
|
||||
|
||||
#### Starting a TypedServer with Watch Integration
|
||||
| Mode | Description |
|
||||
|------|-------------|
|
||||
| `node` | Runs `npm test` on changes (default) |
|
||||
| `test` | Runs `npm run test2` on changes |
|
||||
| `element` | Web component development with dev server |
|
||||
| `service` | Runs `npm run startTs` for services |
|
||||
| `website` | Full website mode with bundling |
|
||||
| `echo` | Test mode that runs `npm -v` |
|
||||
|
||||
For projects requiring a development server, integrate `typedserver` for handling HTTP server tasks:
|
||||
### Custom Watchers
|
||||
|
||||
For more granular control, use the `Watcher` class directly:
|
||||
|
||||
```typescript
|
||||
import { TsWatch } from '@git.zone/tswatch';
|
||||
import { Watcher } from '@git.zone/tswatch';
|
||||
|
||||
const startTypedServer = async () => {
|
||||
const watchInstance = new TsWatch('element');
|
||||
await watchInstance.start();
|
||||
const customWatcher = new Watcher({
|
||||
filePathToWatch: './src',
|
||||
commandToExecute: 'npm run build',
|
||||
timeout: 5000 // Optional timeout in ms
|
||||
});
|
||||
|
||||
// Serve a local directory using a typedserver with CORS and compression
|
||||
const server = watchInstance.typedserver;
|
||||
if (server) {
|
||||
await server.start();
|
||||
await customWatcher.start();
|
||||
```
|
||||
|
||||
### Using Function Callbacks
|
||||
|
||||
```typescript
|
||||
import { Watcher } from '@git.zone/tswatch';
|
||||
|
||||
const watcher = new Watcher({
|
||||
filePathToWatch: './src',
|
||||
functionToCall: async () => {
|
||||
console.log('Files changed!');
|
||||
// Your custom logic here
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
await watcher.start();
|
||||
```
|
||||
|
||||
This code watches for changes and serves the project locally, providing reload capabilities for smooth development.
|
||||
### Watcher Options
|
||||
|
||||
#### Step 3: Custom Watchers
|
||||
| Option | Type | Description |
|
||||
|--------|------|-------------|
|
||||
| `filePathToWatch` | `string` | Path to watch for changes |
|
||||
| `commandToExecute` | `string` | Shell command to run on changes |
|
||||
| `functionToCall` | `() => Promise<any>` | Async function to call on changes |
|
||||
| `timeout` | `number` | Optional timeout in milliseconds |
|
||||
|
||||
Beyond built-in commands, you can create custom watchers for detailed control over file monitoring and execution responses:
|
||||
## Development Server
|
||||
|
||||
```typescript
|
||||
import { Watcher } from '@git.zone/tswatch';
|
||||
Element mode includes a built-in development server:
|
||||
|
||||
const customWatcherSetup = async () => {
|
||||
const customWatcher = new Watcher({
|
||||
filePathToWatch: '/path/to/watch',
|
||||
commandToExecute: 'npm run custom-script',
|
||||
});
|
||||
- **Port**: 3002
|
||||
- **Features**: CORS enabled, gzip compression, live reload
|
||||
- **Serve directory**: `./dist_watch/`
|
||||
|
||||
// Start and stop the custom watcher as needed
|
||||
await customWatcher.start();
|
||||
await customWatcher.stop();
|
||||
};
|
||||
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
|
||||
- `test2`: For test 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
|
||||
```
|
||||
|
||||
Define specific file paths and custom shell commands with the options provided by the `Watcher` class.
|
||||
Automatically runs tests when you modify source files.
|
||||
|
||||
#### Step 4: Handling Multiple Watchers
|
||||
### Building a Web Component
|
||||
|
||||
To handle multiple directories or file sets, use the `ObjectMap` utility, efficiently managing multiple `Watcher` instances within the `TsWatch` framework:
|
||||
|
||||
```typescript
|
||||
import { TsWatch } from '@git.zone/tswatch';
|
||||
|
||||
const setupMultipleWatchers = async () => {
|
||||
const tsWatchInstance = new TsWatch('node');
|
||||
|
||||
// View active watchers through instance mapping
|
||||
tsWatchInstance.watcherMap.forEach(watcher => {
|
||||
console.log(`Watcher listening on: ${watcher.toString()}`);
|
||||
});
|
||||
|
||||
// Initiate all watchers
|
||||
await tsWatchInstance.start();
|
||||
};
|
||||
```bash
|
||||
tswatch element
|
||||
```
|
||||
|
||||
Incorporate this setup for efficiently managing complex projects with varied sources and parallel build tasks.
|
||||
Get instant feedback with live reload while developing custom elements.
|
||||
|
||||
#### Handling Timeout and Cleanup
|
||||
### Creating a Backend Service
|
||||
|
||||
`@git.zone/tswatch` includes functions to manage process exits and timeout scenarios robustly:
|
||||
|
||||
```typescript
|
||||
import { Watcher } from '@git.zone/tswatch';
|
||||
|
||||
const watcherWithTimeout = () => {
|
||||
new Watcher({
|
||||
filePathToWatch: './src/',
|
||||
timeout: 10000, // 10 seconds timeout
|
||||
commandToExecute: 'echo "Task completed"',
|
||||
}).start();
|
||||
};
|
||||
```bash
|
||||
tswatch service
|
||||
```
|
||||
|
||||
The `timeout` option ensures processes don't run indefinitely, aiding development and potential automated testing scenarios.
|
||||
Automatically restart your service on code changes.
|
||||
|
||||
### Conclusion
|
||||
### Full-Stack Web Application
|
||||
|
||||
By providing flexible configurations, a robust CLI, and deep integration capabilities, `@git.zone/tswatch` serves as a comprehensive solution for automating and optimizing your TypeScript development processes. Whether managing server-side environments or advanced web apps, using this tool will ensure your projects are always ready with the latest changes.
|
||||
```bash
|
||||
tswatch website
|
||||
```
|
||||
|
||||
Explore the various features and tailor the tool to fit your unique project requirements, leading to faster and more efficient development workflows.
|
||||
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.
|
||||
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 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.
|
||||
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
|
||||
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.
|
||||
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.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// 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;
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@git.zone/tswatch',
|
||||
version: '2.0.38',
|
||||
version: '2.2.4',
|
||||
description: 'A development tool for automatically watching and re-compiling TypeScript projects upon detecting file changes, enhancing developer workflows.'
|
||||
}
|
||||
|
||||
@@ -3,3 +3,5 @@ early.start('tswatch');
|
||||
export * from './tswatch.classes.tswatch.js';
|
||||
export * from './tswatch.cli.js';
|
||||
early.stop();
|
||||
|
||||
export * from './tswatch.classes.watcher.js';
|
||||
@@ -1,7 +1 @@
|
||||
export type TWatchModes =
|
||||
| 'test'
|
||||
| 'node'
|
||||
| 'service'
|
||||
| 'element'
|
||||
| 'website'
|
||||
| 'echo';
|
||||
export type TWatchModes = 'test' | 'node' | 'service' | 'element' | 'website' | 'echo';
|
||||
|
||||
@@ -5,6 +5,19 @@ import * as interfaces from './interfaces/index.js';
|
||||
import { Watcher } from './tswatch.classes.watcher.js';
|
||||
import { logger } from './tswatch.logging.js';
|
||||
|
||||
// Create smartfs instance for directory operations
|
||||
const smartfs = new plugins.smartfs.SmartFs(new plugins.smartfs.SmartFsProviderNode());
|
||||
|
||||
/**
|
||||
* Lists all folders in a directory
|
||||
*/
|
||||
const listFolders = async (dirPath: string): Promise<string[]> => {
|
||||
const entries = await smartfs.directory(dirPath).list();
|
||||
return entries
|
||||
.filter((entry) => entry.isDirectory)
|
||||
.map((entry) => entry.name);
|
||||
};
|
||||
|
||||
export class TsWatch {
|
||||
public watchmode: interfaces.TWatchModes;
|
||||
public watcherMap = new plugins.lik.ObjectMap<Watcher>();
|
||||
@@ -31,7 +44,7 @@ export class TsWatch {
|
||||
filePathToWatch: paths.cwd,
|
||||
commandToExecute: 'npm run test2',
|
||||
timeout: null,
|
||||
})
|
||||
}),
|
||||
);
|
||||
break;
|
||||
case 'node':
|
||||
@@ -40,7 +53,7 @@ export class TsWatch {
|
||||
filePathToWatch: paths.cwd,
|
||||
commandToExecute: 'npm run test',
|
||||
timeout: null,
|
||||
})
|
||||
}),
|
||||
);
|
||||
break;
|
||||
case 'element':
|
||||
@@ -51,7 +64,7 @@ export class TsWatch {
|
||||
// lets create a standard server
|
||||
logger.log(
|
||||
'info',
|
||||
'bundling TypeScript files to "dist_watch" Note: This is for development only!'
|
||||
'bundling TypeScript files to "dist_watch" Note: This is for development only!',
|
||||
);
|
||||
this.typedserver = new plugins.typedserver.TypedServer({
|
||||
cors: true,
|
||||
@@ -75,13 +88,13 @@ export class TsWatch {
|
||||
await bundleAndReloadElement();
|
||||
},
|
||||
timeout: null,
|
||||
})
|
||||
}),
|
||||
);
|
||||
|
||||
// lets get the other ts folders
|
||||
let tsfolders = await plugins.smartfile.fs.listFolders(paths.cwd);
|
||||
let tsfolders = await 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',
|
||||
@@ -97,7 +110,7 @@ export class TsWatch {
|
||||
await bundleAndReloadElement();
|
||||
},
|
||||
timeout: null,
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -113,7 +126,7 @@ export class TsWatch {
|
||||
await bundleAndReloadElement();
|
||||
},
|
||||
timeout: null,
|
||||
})
|
||||
}),
|
||||
);
|
||||
})();
|
||||
break;
|
||||
@@ -125,9 +138,9 @@ export class TsWatch {
|
||||
bundler: 'esbuild',
|
||||
});
|
||||
};
|
||||
let tsfolders = await plugins.smartfile.fs.listFolders(paths.cwd);
|
||||
let tsfolders = await listFolders(paths.cwd);
|
||||
tsfolders = tsfolders.filter(
|
||||
(itemArg) => itemArg.startsWith('ts') && itemArg !== 'ts_web'
|
||||
(itemArg) => itemArg.startsWith('ts') && itemArg !== 'ts_web',
|
||||
);
|
||||
for (const tsfolder of tsfolders) {
|
||||
this.watcherMap.add(
|
||||
@@ -138,7 +151,7 @@ export class TsWatch {
|
||||
await bundleAndReloadWebsite();
|
||||
},
|
||||
timeout: null,
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
this.watcherMap.add(
|
||||
@@ -148,7 +161,7 @@ export class TsWatch {
|
||||
await bundleAndReloadWebsite();
|
||||
},
|
||||
timeout: null,
|
||||
})
|
||||
}),
|
||||
);
|
||||
this.watcherMap.add(
|
||||
new Watcher({
|
||||
@@ -162,7 +175,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;
|
||||
@@ -172,7 +195,7 @@ export class TsWatch {
|
||||
filePathToWatch: plugins.path.join(paths.cwd, './ts/'),
|
||||
commandToExecute: 'npm run startTs',
|
||||
timeout: null,
|
||||
})
|
||||
}),
|
||||
);
|
||||
break;
|
||||
case 'echo':
|
||||
|
||||
@@ -20,7 +20,7 @@ export class Watcher {
|
||||
});
|
||||
|
||||
private currentExecution: plugins.smartshell.IExecResultStreaming;
|
||||
private smartchokWatcher = new plugins.smartchok.Smartchok([]);
|
||||
private smartwatchInstance = new plugins.smartwatch.Smartwatch([]);
|
||||
private options: IWatcherConstructorOptions;
|
||||
|
||||
constructor(optionsArg: IWatcherConstructorOptions) {
|
||||
@@ -34,9 +34,13 @@ export class Watcher {
|
||||
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
|
||||
await this.smartchokWatcher.start();
|
||||
const changeObservable = await this.smartchokWatcher.getObservableFor('change');
|
||||
// Convert directory path to glob pattern for smartwatch
|
||||
const watchPath = this.options.filePathToWatch.endsWith('/')
|
||||
? `${this.options.filePathToWatch}**/*`
|
||||
: `${this.options.filePathToWatch}/**/*`;
|
||||
this.smartwatchInstance.add([watchPath]);
|
||||
await this.smartwatchInstance.start();
|
||||
const changeObservable = await this.smartwatchInstance.getObservableFor('change');
|
||||
changeObservable.subscribe(() => {
|
||||
this.updateCurrentExecution();
|
||||
});
|
||||
@@ -56,7 +60,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');
|
||||
@@ -64,7 +68,7 @@ export class Watcher {
|
||||
if (this.options.functionToCall) {
|
||||
this.options.functionToCall();
|
||||
} else {
|
||||
console.log('no functionToCall set.')
|
||||
console.log('no functionToCall set.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,7 +103,7 @@ export class Watcher {
|
||||
* stops the watcher
|
||||
*/
|
||||
public async stop() {
|
||||
await this.smartchokWatcher.stop();
|
||||
await this.smartwatchInstance.stop();
|
||||
if (this.currentExecution && !this.currentExecution.childProcess.killed) {
|
||||
this.currentExecution.kill();
|
||||
}
|
||||
|
||||
@@ -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,36 +4,32 @@ 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';
|
||||
import * as smartchok from '@push.rocks/smartchok';
|
||||
import * as smartcli from '@push.rocks/smartcli';
|
||||
import * as smartdelay from '@push.rocks/smartdelay';
|
||||
import * as smartfile from '@push.rocks/smartfile';
|
||||
import * as smartfs from '@push.rocks/smartfs';
|
||||
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,
|
||||
smartchok,
|
||||
smartcli,
|
||||
smartdelay,
|
||||
smartfile,
|
||||
smartfs,
|
||||
smartlog,
|
||||
smartlogDestinationLocal,
|
||||
smartshell,
|
||||
smartwatch,
|
||||
taskbuffer,
|
||||
};
|
||||
|
||||
@@ -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