Compare commits

...

16 Commits
v2.1.1 ... main

Author SHA1 Message Date
0dee896201 v2.2.4
Some checks failed
Default (tags) / security (push) Successful in 53s
Default (tags) / test (push) Failing after 41s
Default (tags) / release (push) Has been skipped
Default (tags) / metadata (push) Has been skipped
2025-12-04 16:15:38 +00:00
29f7283f7a fix(dependencies): Bump dependency versions: @api.global/typedserver, @git.zone/tsbundle, @push.rocks/smartfs, @push.rocks/taskbuffer 2025-12-04 16:15:38 +00:00
3eb99e1f08 v2.2.3
Some checks failed
Default (tags) / security (push) Successful in 48s
Default (tags) / test (push) Failing after 37s
Default (tags) / release (push) Has been skipped
Default (tags) / metadata (push) Has been skipped
2025-12-04 08:30:05 +00:00
ad41fe876d fix(tswatch.classes.watcher): Convert directory watch paths to glob patterns for smartwatch compatibility 2025-12-04 08:30:05 +00:00
d6f3381e71 v2.2.2
Some checks failed
Default (tags) / security (push) Successful in 41s
Default (tags) / test (push) Failing after 39s
Default (tags) / release (push) Has been skipped
Default (tags) / metadata (push) Has been skipped
2025-12-01 12:03:00 +00:00
bcbf6fc139 fix(core): Replace smartchok/smartfile with smartwatch/smartfs, update watcher and plugins, and bump dependencies 2025-12-01 12:03:00 +00:00
f73ca7ac2f fix(exports): correct package.json exports field syntax
Some checks failed
Default (tags) / security (push) Successful in 32s
Default (tags) / test (push) Successful in 52s
Default (tags) / release (push) Failing after 57s
Default (tags) / metadata (push) Successful in 57s
2025-07-29 17:50:59 +00:00
75acc4b768 feat(exports): modernize package exports and expose watcher class
Some checks failed
Default (tags) / security (push) Successful in 49s
Default (tags) / test (push) Successful in 1m7s
Default (tags) / release (push) Failing after 1m18s
Default (tags) / metadata (push) Successful in 1m26s
2025-07-29 17:46:28 +00:00
83cf8594ab 2.1.5
Some checks failed
Default (tags) / security (push) Successful in 44s
Default (tags) / test (push) Successful in 1m5s
Default (tags) / release (push) Failing after 1m10s
Default (tags) / metadata (push) Successful in 1m17s
2025-07-29 17:34:00 +00:00
417dc4c763 fix(dependencies): update 2025-07-29 17:33:57 +00:00
64a86f7af3 2.1.4
Some checks failed
Default (tags) / security (push) Successful in 47s
Default (tags) / test (push) Successful in 1m5s
Default (tags) / release (push) Failing after 1m14s
Default (tags) / metadata (push) Successful in 1m21s
2025-07-29 17:32:55 +00:00
1a66e76b6f 2.1.3
Some checks failed
Default (tags) / security (push) Successful in 50s
Default (tags) / test (push) Successful in 1m1s
Default (tags) / release (push) Failing after 48s
Default (tags) / metadata (push) Successful in 53s
2025-07-29 17:32:32 +00:00
5c04dc7729 fix(documentation): Update and align documentation with internal CLI and project structure 2025-07-29 17:32:32 +00:00
ecd76bc8aa update readme 2025-07-10 14:33:10 +00:00
488bd65933 2.1.2
Some checks failed
Default (tags) / security (push) Successful in 51s
Default (tags) / test (push) Successful in 53s
Default (tags) / release (push) Failing after 50s
Default (tags) / metadata (push) Successful in 56s
2025-06-26 23:17:15 +00:00
5763858bac fix(dependencies): Update @push.rocks/smartchok dependency to ^1.1.1 2025-06-26 23:17:15 +00:00
12 changed files with 3847 additions and 1846 deletions

Binary file not shown.

68
.serena/project.yml Normal file
View 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"

View File

@@ -1,5 +1,52 @@
# 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

View File

@@ -1,10 +1,11 @@
{
"name": "@git.zone/tswatch",
"version": "2.1.1",
"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",
@@ -17,24 +18,24 @@
"buildDocs": "tsdoc"
},
"devDependencies": {
"@git.zone/tsbuild": "^2.6.4",
"@git.zone/tstest": "^2.3.1",
"@types/node": "^24.0.4"
"@git.zone/tsbuild": "^3.1.2",
"@git.zone/tstest": "^3.1.3",
"@types/node": "^24.10.1"
},
"dependencies": {
"@api.global/typedserver": "^3.0.74",
"@git.zone/tsbundle": "^2.5.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.2.2",
"@push.rocks/smartchok": "^1.0.34",
"@push.rocks/smartcli": "^4.0.11",
"@push.rocks/smartcli": "^4.0.19",
"@push.rocks/smartdelay": "^3.0.5",
"@push.rocks/smartfile": "^11.2.5",
"@push.rocks/smartlog": "^3.1.8",
"@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.3",
"@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/**/*",

5131
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -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

322
readme.md
View File

@@ -1,199 +1,275 @@
# @git.zone/tswatch
A development tool for watching and re-compiling TypeScript projects automatically upon detecting changes.
A TypeScript file watcher that automatically recompiles and executes your project when files change. Designed to streamline development workflows for various TypeScript project types.
## Install
## Issue Reporting and Security
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:
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.

View File

@@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@git.zone/tswatch',
version: '2.1.1',
version: '2.2.4',
description: 'A development tool for automatically watching and re-compiling TypeScript projects upon detecting file changes, enhancing developer workflows.'
}

View File

@@ -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';

View File

@@ -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>();
@@ -79,7 +92,7 @@ export class TsWatch {
);
// 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',
);
@@ -125,7 +138,7 @@ 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',
);

View File

@@ -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();
});
@@ -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();
}

View File

@@ -13,23 +13,23 @@ 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,
};