52 lines
2.3 KiB
Markdown
52 lines
2.3 KiB
Markdown
# 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
|