@git.zone/tswatch 2.3.13 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist_ts/00_commitinfo_data.js +2 -2
- package/dist_ts/index.d.ts +4 -1
- package/dist_ts/index.js +5 -2
- package/dist_ts/interfaces/index.d.ts +1 -1
- package/dist_ts/interfaces/index.js +2 -2
- package/dist_ts/interfaces/interfaces.config.d.ts +58 -0
- package/dist_ts/interfaces/interfaces.config.js +2 -0
- package/dist_ts/tswatch.classes.confighandler.d.ts +30 -0
- package/dist_ts/tswatch.classes.confighandler.js +172 -0
- package/dist_ts/tswatch.classes.tswatch.d.ts +28 -3
- package/dist_ts/tswatch.classes.tswatch.js +135 -165
- package/dist_ts/tswatch.classes.watcher.d.ts +31 -3
- package/dist_ts/tswatch.classes.watcher.js +105 -25
- package/dist_ts/tswatch.cli.js +39 -28
- package/dist_ts/tswatch.init.d.ts +25 -0
- package/dist_ts/tswatch.init.js +168 -0
- package/dist_ts/tswatch.plugins.d.ts +3 -1
- package/dist_ts/tswatch.plugins.js +7 -5
- package/npmextra.json +12 -6
- package/package.json +21 -15
- package/readme.hints.md +88 -46
- package/readme.md +284 -149
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/index.ts +6 -2
- package/ts/interfaces/index.ts +1 -1
- package/ts/interfaces/interfaces.config.ts +61 -0
- package/ts/tswatch.classes.confighandler.ts +185 -0
- package/ts/tswatch.classes.tswatch.ts +161 -197
- package/ts/tswatch.classes.watcher.ts +134 -23
- package/ts/tswatch.cli.ts +37 -31
- package/ts/tswatch.init.ts +199 -0
- package/ts/tswatch.plugins.ts +7 -3
- package/dist_ts/interfaces/interfaces.watchmodes.d.ts +0 -1
- package/dist_ts/interfaces/interfaces.watchmodes.js +0 -2
- package/ts/interfaces/interfaces.watchmodes.ts +0 -1
package/readme.md
CHANGED
|
@@ -1,176 +1,264 @@
|
|
|
1
1
|
# @git.zone/tswatch
|
|
2
2
|
|
|
3
|
-
A TypeScript file watcher that automatically recompiles and executes your project when files change.
|
|
3
|
+
A powerful, config-driven TypeScript file watcher that automatically recompiles and executes your project when files change. Built for modern TypeScript development with zero-config presets and deep customization options.
|
|
4
4
|
|
|
5
5
|
## Issue Reporting and Security
|
|
6
6
|
|
|
7
7
|
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.
|
|
8
8
|
|
|
9
|
-
## Features
|
|
9
|
+
## ✨ Features
|
|
10
10
|
|
|
11
|
-
- 🔄 **
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
11
|
+
- 🔄 **Config-driven architecture** - Define watchers, bundles, and dev server in `npmextra.json`
|
|
12
|
+
- ⚡ **Zero-config presets** - Get started instantly with `npm`, `element`, `service`, `website`, and `test` presets
|
|
13
|
+
- 🧙 **Interactive wizard** - Run `tswatch init` to generate configuration interactively
|
|
14
|
+
- 🌐 **Built-in dev server** - Live reload, CORS, compression, SPA fallback out of the box
|
|
15
|
+
- 📦 **Smart bundling** - TypeScript, HTML, and assets with esbuild integration
|
|
16
|
+
- 🔁 **Debounced execution** - Configurable debounce prevents command spam
|
|
17
|
+
- 🛑 **Process management** - Automatic restart or queue mode for long-running commands
|
|
18
|
+
- 🎯 **Glob patterns** - Watch any files with flexible pattern matching
|
|
17
19
|
|
|
18
|
-
## Installation
|
|
19
|
-
|
|
20
|
-
Install `@git.zone/tswatch` globally or as a development dependency:
|
|
20
|
+
## 📦 Installation
|
|
21
21
|
|
|
22
22
|
```bash
|
|
23
|
-
# Global installation
|
|
23
|
+
# Global installation (recommended for CLI usage)
|
|
24
24
|
pnpm install -g @git.zone/tswatch
|
|
25
25
|
|
|
26
26
|
# As a dev dependency
|
|
27
27
|
pnpm install --save-dev @git.zone/tswatch
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
-
## Quick Start
|
|
31
|
-
|
|
32
|
-
```bash
|
|
33
|
-
# Watch and run tests on changes (default behavior)
|
|
34
|
-
tswatch
|
|
30
|
+
## 🚀 Quick Start
|
|
35
31
|
|
|
36
|
-
|
|
37
|
-
tswatch element
|
|
32
|
+
### Using the Wizard
|
|
38
33
|
|
|
39
|
-
|
|
40
|
-
|
|
34
|
+
```bash
|
|
35
|
+
# Run the interactive wizard to create your configuration
|
|
36
|
+
tswatch init
|
|
41
37
|
```
|
|
42
38
|
|
|
43
|
-
|
|
39
|
+
The wizard will guide you through creating a `npmextra.json` configuration with your chosen preset or custom watchers.
|
|
44
40
|
|
|
45
|
-
###
|
|
41
|
+
### Using Presets
|
|
46
42
|
|
|
47
|
-
|
|
43
|
+
If you already have a configuration, just run:
|
|
48
44
|
|
|
49
45
|
```bash
|
|
50
46
|
tswatch
|
|
51
|
-
# or explicitly
|
|
52
|
-
tswatch npm
|
|
53
47
|
```
|
|
54
48
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
Sets up a development environment for web components/elements:
|
|
58
|
-
- Starts a dev server on port 3002
|
|
59
|
-
- Bundles TypeScript to `dist_watch/`
|
|
60
|
-
- Enables live reload
|
|
61
|
-
- Watches all `ts*/` folders
|
|
49
|
+
This reads your config from `npmextra.json` under the `@git.zone/tswatch` key and starts watching.
|
|
62
50
|
|
|
63
|
-
|
|
64
|
-
tswatch element
|
|
65
|
-
```
|
|
51
|
+
## ⚙️ Configuration
|
|
66
52
|
|
|
67
|
-
|
|
53
|
+
tswatch uses `npmextra.json` for configuration. Add your config under the `@git.zone/tswatch` key:
|
|
68
54
|
|
|
69
|
-
|
|
55
|
+
```json
|
|
56
|
+
{
|
|
57
|
+
"@git.zone/tswatch": {
|
|
58
|
+
"preset": "npm"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
```
|
|
70
62
|
|
|
71
|
-
|
|
72
|
-
|
|
63
|
+
### Available Presets
|
|
64
|
+
|
|
65
|
+
| Preset | Description |
|
|
66
|
+
|--------|-------------|
|
|
67
|
+
| `npm` | Watch `ts/` and `test/`, run `npm test` on changes |
|
|
68
|
+
| `test` | Watch `ts/` and `test/`, run `npm run test2` on changes |
|
|
69
|
+
| `service` | Watch `ts/`, restart `npm run startTs` (ideal for backend services) |
|
|
70
|
+
| `element` | Dev server on port 3002 + bundling for web components |
|
|
71
|
+
| `website` | Full-stack: backend + frontend bundling + asset processing |
|
|
72
|
+
|
|
73
|
+
### Full Configuration Schema
|
|
74
|
+
|
|
75
|
+
```json
|
|
76
|
+
{
|
|
77
|
+
"@git.zone/tswatch": {
|
|
78
|
+
"preset": "element",
|
|
79
|
+
|
|
80
|
+
"server": {
|
|
81
|
+
"enabled": true,
|
|
82
|
+
"port": 3002,
|
|
83
|
+
"serveDir": "./dist_watch/",
|
|
84
|
+
"liveReload": true
|
|
85
|
+
},
|
|
86
|
+
|
|
87
|
+
"bundles": [
|
|
88
|
+
{
|
|
89
|
+
"name": "main-bundle",
|
|
90
|
+
"from": "./ts_web/index.ts",
|
|
91
|
+
"to": "./dist_watch/bundle.js",
|
|
92
|
+
"watchPatterns": ["./ts_web/**/*"],
|
|
93
|
+
"triggerReload": true
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"name": "html",
|
|
97
|
+
"from": "./html/index.html",
|
|
98
|
+
"to": "./dist_watch/index.html",
|
|
99
|
+
"watchPatterns": ["./html/**/*"],
|
|
100
|
+
"triggerReload": true
|
|
101
|
+
}
|
|
102
|
+
],
|
|
103
|
+
|
|
104
|
+
"watchers": [
|
|
105
|
+
{
|
|
106
|
+
"name": "backend-build",
|
|
107
|
+
"watch": "./ts/**/*",
|
|
108
|
+
"command": "npm run build",
|
|
109
|
+
"restart": false,
|
|
110
|
+
"debounce": 300,
|
|
111
|
+
"runOnStart": true
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"name": "tests",
|
|
115
|
+
"watch": ["./ts/**/*", "./test/**/*"],
|
|
116
|
+
"command": "npm test",
|
|
117
|
+
"restart": true,
|
|
118
|
+
"debounce": 300,
|
|
119
|
+
"runOnStart": true
|
|
120
|
+
}
|
|
121
|
+
]
|
|
122
|
+
}
|
|
123
|
+
}
|
|
73
124
|
```
|
|
74
125
|
|
|
75
|
-
###
|
|
126
|
+
### Configuration Options
|
|
76
127
|
|
|
77
|
-
|
|
78
|
-
- Bundles TypeScript files to `dist_serve/`
|
|
79
|
-
- Processes HTML files
|
|
80
|
-
- Handles assets
|
|
81
|
-
- Runs `npm run startTs` for server-side code
|
|
128
|
+
#### `ITswatchConfig`
|
|
82
129
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
130
|
+
| Option | Type | Description |
|
|
131
|
+
|--------|------|-------------|
|
|
132
|
+
| `preset` | `string` | Use a preset: `npm`, `test`, `service`, `element`, `website` |
|
|
133
|
+
| `watchers` | `IWatcherConfig[]` | Array of watcher configurations |
|
|
134
|
+
| `server` | `IServerConfig` | Development server configuration |
|
|
135
|
+
| `bundles` | `IBundleConfig[]` | Bundle configurations |
|
|
86
136
|
|
|
87
|
-
|
|
137
|
+
#### `IWatcherConfig`
|
|
88
138
|
|
|
89
|
-
|
|
139
|
+
| Option | Type | Default | Description |
|
|
140
|
+
|--------|------|---------|-------------|
|
|
141
|
+
| `name` | `string` | *required* | Name for logging purposes |
|
|
142
|
+
| `watch` | `string \| string[]` | *required* | Glob pattern(s) to watch |
|
|
143
|
+
| `command` | `string` | - | Shell command to execute on changes |
|
|
144
|
+
| `restart` | `boolean` | `true` | Kill previous process before restarting |
|
|
145
|
+
| `debounce` | `number` | `300` | Debounce delay in milliseconds |
|
|
146
|
+
| `runOnStart` | `boolean` | `true` | Run the command immediately on start |
|
|
90
147
|
|
|
91
|
-
|
|
92
|
-
tswatch test
|
|
93
|
-
```
|
|
148
|
+
#### `IServerConfig`
|
|
94
149
|
|
|
95
|
-
|
|
150
|
+
| Option | Type | Default | Description |
|
|
151
|
+
|--------|------|---------|-------------|
|
|
152
|
+
| `enabled` | `boolean` | *required* | Whether the server is enabled |
|
|
153
|
+
| `port` | `number` | `3002` | Server port |
|
|
154
|
+
| `serveDir` | `string` | `./dist_watch/` | Directory to serve |
|
|
155
|
+
| `liveReload` | `boolean` | `true` | Inject live reload script |
|
|
96
156
|
|
|
97
|
-
|
|
157
|
+
#### `IBundleConfig`
|
|
98
158
|
|
|
99
|
-
|
|
159
|
+
| Option | Type | Default | Description |
|
|
160
|
+
|--------|------|---------|-------------|
|
|
161
|
+
| `name` | `string` | - | Name for logging purposes |
|
|
162
|
+
| `from` | `string` | *required* | Entry point file |
|
|
163
|
+
| `to` | `string` | *required* | Output file |
|
|
164
|
+
| `watchPatterns` | `string[]` | - | Additional patterns to watch |
|
|
165
|
+
| `triggerReload` | `boolean` | `true` | Trigger server reload after bundling |
|
|
100
166
|
|
|
101
|
-
|
|
102
|
-
project/
|
|
103
|
-
├── ts/ # TypeScript source files
|
|
104
|
-
├── test/ # Test files
|
|
105
|
-
└── package.json # With "test" script
|
|
106
|
-
```
|
|
167
|
+
## 🛠️ CLI Commands
|
|
107
168
|
|
|
108
|
-
###
|
|
169
|
+
### `tswatch`
|
|
109
170
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
├── html/ # HTML templates
|
|
115
|
-
│ └── index.ts # Entry point
|
|
116
|
-
└── dist_watch/ # Output directory (auto-created)
|
|
171
|
+
Runs with configuration from `npmextra.json`. If no config exists, launches the interactive wizard.
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
tswatch
|
|
117
175
|
```
|
|
118
176
|
|
|
119
|
-
###
|
|
177
|
+
### `tswatch init`
|
|
120
178
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
│ └── index.ts # Entry point
|
|
126
|
-
├── html/ # HTML files
|
|
127
|
-
│ └── index.html
|
|
128
|
-
├── assets/ # Static assets
|
|
129
|
-
└── dist_serve/ # Output directory
|
|
179
|
+
Force-run the configuration wizard (creates or overwrites existing config).
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
tswatch init
|
|
130
183
|
```
|
|
131
184
|
|
|
132
|
-
## Programmatic API
|
|
185
|
+
## 💻 Programmatic API
|
|
133
186
|
|
|
134
|
-
### Basic Usage
|
|
187
|
+
### Basic Usage with Config
|
|
135
188
|
|
|
136
189
|
```typescript
|
|
137
190
|
import { TsWatch } from '@git.zone/tswatch';
|
|
138
191
|
|
|
139
|
-
// Create
|
|
140
|
-
const watcher = new TsWatch(
|
|
192
|
+
// Create TsWatch with inline configuration
|
|
193
|
+
const watcher = new TsWatch({
|
|
194
|
+
watchers: [
|
|
195
|
+
{
|
|
196
|
+
name: 'my-watcher',
|
|
197
|
+
watch: './src/**/*',
|
|
198
|
+
command: 'npm run build',
|
|
199
|
+
restart: true,
|
|
200
|
+
debounce: 300,
|
|
201
|
+
runOnStart: true,
|
|
202
|
+
},
|
|
203
|
+
],
|
|
204
|
+
});
|
|
205
|
+
|
|
141
206
|
await watcher.start();
|
|
142
207
|
|
|
143
|
-
//
|
|
208
|
+
// Later: stop watching
|
|
144
209
|
await watcher.stop();
|
|
145
210
|
```
|
|
146
211
|
|
|
147
|
-
###
|
|
212
|
+
### Load from Config File
|
|
148
213
|
|
|
149
|
-
|
|
214
|
+
```typescript
|
|
215
|
+
import { TsWatch } from '@git.zone/tswatch';
|
|
150
216
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
| `node` | Runs `npm test` on changes (default) |
|
|
154
|
-
| `test` | Runs `npm run test2` on changes |
|
|
155
|
-
| `element` | Web component development with dev server |
|
|
156
|
-
| `service` | Runs `npm run startTs` for services |
|
|
157
|
-
| `website` | Full website mode with bundling |
|
|
158
|
-
| `echo` | Test mode that runs `npm -v` |
|
|
217
|
+
// Load configuration from npmextra.json
|
|
218
|
+
const watcher = TsWatch.fromConfig();
|
|
159
219
|
|
|
160
|
-
|
|
220
|
+
if (watcher) {
|
|
221
|
+
await watcher.start();
|
|
222
|
+
}
|
|
223
|
+
```
|
|
161
224
|
|
|
162
|
-
|
|
225
|
+
### Using ConfigHandler
|
|
226
|
+
|
|
227
|
+
```typescript
|
|
228
|
+
import { ConfigHandler } from '@git.zone/tswatch';
|
|
229
|
+
|
|
230
|
+
const configHandler = new ConfigHandler();
|
|
231
|
+
|
|
232
|
+
// Check if config exists
|
|
233
|
+
if (configHandler.hasConfig()) {
|
|
234
|
+
const config = configHandler.loadConfig();
|
|
235
|
+
console.log(config);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// Get available presets
|
|
239
|
+
const presets = configHandler.getPresetNames();
|
|
240
|
+
console.log(presets); // ['npm', 'test', 'service', 'element', 'website']
|
|
241
|
+
|
|
242
|
+
// Get a specific preset
|
|
243
|
+
const npmPreset = configHandler.getPreset('npm');
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### Using Watcher Directly
|
|
247
|
+
|
|
248
|
+
For more granular control, use the `Watcher` class:
|
|
163
249
|
|
|
164
250
|
```typescript
|
|
165
251
|
import { Watcher } from '@git.zone/tswatch';
|
|
166
252
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
253
|
+
// Create from config object
|
|
254
|
+
const watcher = Watcher.fromConfig({
|
|
255
|
+
name: 'my-watcher',
|
|
256
|
+
watch: ['./src/**/*', './lib/**/*'],
|
|
257
|
+
command: 'npm run compile',
|
|
258
|
+
restart: true,
|
|
171
259
|
});
|
|
172
260
|
|
|
173
|
-
await
|
|
261
|
+
await watcher.start();
|
|
174
262
|
```
|
|
175
263
|
|
|
176
264
|
### Using Function Callbacks
|
|
@@ -179,79 +267,126 @@ await customWatcher.start();
|
|
|
179
267
|
import { Watcher } from '@git.zone/tswatch';
|
|
180
268
|
|
|
181
269
|
const watcher = new Watcher({
|
|
182
|
-
|
|
270
|
+
name: 'custom-handler',
|
|
271
|
+
filePathToWatch: './src/**/*',
|
|
183
272
|
functionToCall: async () => {
|
|
184
|
-
console.log('Files changed!');
|
|
185
|
-
// Your custom logic here
|
|
186
|
-
}
|
|
273
|
+
console.log('Files changed! Running custom logic...');
|
|
274
|
+
// Your custom build/test/deploy logic here
|
|
275
|
+
},
|
|
276
|
+
debounce: 500,
|
|
277
|
+
runOnStart: true,
|
|
187
278
|
});
|
|
188
279
|
|
|
189
280
|
await watcher.start();
|
|
190
281
|
```
|
|
191
282
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
| Option | Type | Description |
|
|
195
|
-
|--------|------|-------------|
|
|
196
|
-
| `filePathToWatch` | `string` | Path to watch for changes |
|
|
197
|
-
| `commandToExecute` | `string` | Shell command to run on changes |
|
|
198
|
-
| `functionToCall` | `() => Promise<any>` | Async function to call on changes |
|
|
199
|
-
| `timeout` | `number` | Optional timeout in milliseconds |
|
|
200
|
-
|
|
201
|
-
## Development Server
|
|
283
|
+
## 📁 Project Structures
|
|
202
284
|
|
|
203
|
-
|
|
285
|
+
### NPM Package / Node.js Library
|
|
204
286
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
287
|
+
```
|
|
288
|
+
project/
|
|
289
|
+
├── ts/ # TypeScript source files
|
|
290
|
+
├── test/ # Test files
|
|
291
|
+
├── package.json # With "test" script
|
|
292
|
+
└── npmextra.json # tswatch config
|
|
293
|
+
```
|
|
208
294
|
|
|
209
|
-
|
|
295
|
+
Config:
|
|
296
|
+
```json
|
|
297
|
+
{
|
|
298
|
+
"@git.zone/tswatch": {
|
|
299
|
+
"preset": "npm"
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
```
|
|
210
303
|
|
|
211
|
-
|
|
304
|
+
### Backend Service
|
|
212
305
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
306
|
+
```
|
|
307
|
+
project/
|
|
308
|
+
├── ts/ # TypeScript source files
|
|
309
|
+
├── package.json # With "startTs" script
|
|
310
|
+
└── npmextra.json
|
|
311
|
+
```
|
|
219
312
|
|
|
220
|
-
|
|
313
|
+
Config:
|
|
314
|
+
```json
|
|
315
|
+
{
|
|
316
|
+
"@git.zone/tswatch": {
|
|
317
|
+
"preset": "service"
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
```
|
|
221
321
|
|
|
222
|
-
|
|
322
|
+
### Web Component / Element
|
|
223
323
|
|
|
224
|
-
|
|
324
|
+
```
|
|
325
|
+
project/
|
|
326
|
+
├── ts/ # Backend TypeScript (optional)
|
|
327
|
+
├── ts_web/ # Frontend TypeScript
|
|
328
|
+
├── html/
|
|
329
|
+
│ ├── index.ts # Web entry point
|
|
330
|
+
│ └── index.html
|
|
331
|
+
├── dist_watch/ # Output (auto-created)
|
|
332
|
+
└── npmextra.json
|
|
333
|
+
```
|
|
225
334
|
|
|
226
|
-
|
|
227
|
-
|
|
335
|
+
Config:
|
|
336
|
+
```json
|
|
337
|
+
{
|
|
338
|
+
"@git.zone/tswatch": {
|
|
339
|
+
"preset": "element"
|
|
340
|
+
}
|
|
341
|
+
}
|
|
228
342
|
```
|
|
229
343
|
|
|
230
|
-
|
|
344
|
+
Access your project at `http://localhost:3002`
|
|
231
345
|
|
|
232
|
-
###
|
|
346
|
+
### Full-Stack Website
|
|
233
347
|
|
|
234
|
-
```
|
|
235
|
-
|
|
348
|
+
```
|
|
349
|
+
project/
|
|
350
|
+
├── ts/ # Backend TypeScript
|
|
351
|
+
├── ts_web/ # Frontend TypeScript
|
|
352
|
+
│ └── index.ts
|
|
353
|
+
├── html/
|
|
354
|
+
│ └── index.html
|
|
355
|
+
├── assets/ # Static assets
|
|
356
|
+
├── dist_serve/ # Output
|
|
357
|
+
└── npmextra.json
|
|
236
358
|
```
|
|
237
359
|
|
|
238
|
-
|
|
360
|
+
Config:
|
|
361
|
+
```json
|
|
362
|
+
{
|
|
363
|
+
"@git.zone/tswatch": {
|
|
364
|
+
"preset": "website"
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
```
|
|
239
368
|
|
|
240
|
-
|
|
369
|
+
## 🌐 Development Server
|
|
241
370
|
|
|
242
|
-
|
|
243
|
-
tswatch service
|
|
244
|
-
```
|
|
371
|
+
The built-in development server (enabled in `element` and `website` presets) features:
|
|
245
372
|
|
|
246
|
-
Automatically
|
|
373
|
+
- **Live Reload** - Automatically refreshes browser on changes
|
|
374
|
+
- **CORS** - Cross-origin requests enabled
|
|
375
|
+
- **Compression** - Gzip compression for faster loading
|
|
376
|
+
- **SPA Fallback** - Single-page application routing support
|
|
377
|
+
- **Security Headers** - Cross-origin isolation headers
|
|
247
378
|
|
|
248
|
-
|
|
379
|
+
Default configuration:
|
|
380
|
+
- **Port**: 3002
|
|
381
|
+
- **Serve Directory**: `./dist_watch/`
|
|
382
|
+
- **Live Reload**: Enabled
|
|
249
383
|
|
|
250
|
-
|
|
251
|
-
tswatch website
|
|
252
|
-
```
|
|
384
|
+
## 🔧 Configuration Tips
|
|
253
385
|
|
|
254
|
-
|
|
386
|
+
1. **Use presets for common workflows** - They're battle-tested and cover most use cases
|
|
387
|
+
2. **Customize with explicit config** - Override preset defaults by adding explicit `watchers`, `bundles`, or `server` config
|
|
388
|
+
3. **Debounce wisely** - Default 300ms works well; increase for slower builds
|
|
389
|
+
4. **Use `restart: false`** for one-shot commands (like builds) and `restart: true` for long-running processes (like servers)
|
|
255
390
|
|
|
256
391
|
## License and Legal Information
|
|
257
392
|
|
package/ts/00_commitinfo_data.ts
CHANGED
package/ts/index.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import * as early from '@push.rocks/early';
|
|
2
2
|
early.start('tswatch');
|
|
3
|
+
|
|
3
4
|
export * from './tswatch.classes.tswatch.js';
|
|
5
|
+
export * from './tswatch.classes.watcher.js';
|
|
6
|
+
export * from './tswatch.classes.confighandler.js';
|
|
4
7
|
export * from './tswatch.cli.js';
|
|
5
|
-
|
|
8
|
+
export * from './tswatch.init.js';
|
|
9
|
+
export * from './interfaces/index.js';
|
|
6
10
|
|
|
7
|
-
|
|
11
|
+
early.stop();
|
package/ts/interfaces/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './interfaces.
|
|
1
|
+
export * from './interfaces.config.js';
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration for a single watcher
|
|
3
|
+
*/
|
|
4
|
+
export interface IWatcherConfig {
|
|
5
|
+
/** Name for this watcher (used in logging) */
|
|
6
|
+
name: string;
|
|
7
|
+
/** Glob pattern(s) to watch */
|
|
8
|
+
watch: string | string[];
|
|
9
|
+
/** Shell command to execute on changes */
|
|
10
|
+
command?: string;
|
|
11
|
+
/** If true, kill previous process before restarting (default: true) */
|
|
12
|
+
restart?: boolean;
|
|
13
|
+
/** Debounce delay in ms (default: 300) */
|
|
14
|
+
debounce?: number;
|
|
15
|
+
/** If true, run the command immediately on start (default: true) */
|
|
16
|
+
runOnStart?: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Configuration for the development server
|
|
21
|
+
*/
|
|
22
|
+
export interface IServerConfig {
|
|
23
|
+
/** Whether the server is enabled */
|
|
24
|
+
enabled: boolean;
|
|
25
|
+
/** Server port (default: 3002) */
|
|
26
|
+
port?: number;
|
|
27
|
+
/** Directory to serve (default: ./dist_watch/) */
|
|
28
|
+
serveDir?: string;
|
|
29
|
+
/** Whether to inject live reload script (default: true) */
|
|
30
|
+
liveReload?: boolean;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Configuration for a bundle operation
|
|
35
|
+
*/
|
|
36
|
+
export interface IBundleConfig {
|
|
37
|
+
/** Name for this bundle (used in logging) */
|
|
38
|
+
name?: string;
|
|
39
|
+
/** Entry point file */
|
|
40
|
+
from: string;
|
|
41
|
+
/** Output file */
|
|
42
|
+
to: string;
|
|
43
|
+
/** Additional patterns to watch that trigger this bundle */
|
|
44
|
+
watchPatterns?: string[];
|
|
45
|
+
/** If true, trigger server reload after bundling (default: true) */
|
|
46
|
+
triggerReload?: boolean;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Main tswatch configuration
|
|
51
|
+
*/
|
|
52
|
+
export interface ITswatchConfig {
|
|
53
|
+
/** Array of watcher configurations */
|
|
54
|
+
watchers?: IWatcherConfig[];
|
|
55
|
+
/** Development server configuration */
|
|
56
|
+
server?: IServerConfig;
|
|
57
|
+
/** Bundle configurations */
|
|
58
|
+
bundles?: IBundleConfig[];
|
|
59
|
+
/** Use a preset configuration (overridden by explicit watchers/server/bundles) */
|
|
60
|
+
preset?: 'element' | 'website' | 'npm' | 'service' | 'test';
|
|
61
|
+
}
|