jsgui3-server 0.0.138 → 0.0.140
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/AGENTS.md +87 -0
- package/README.md +12 -0
- package/docs/GUIDE_TO_AGENTIC_WORKFLOWS_BY_GROK.md +19 -0
- package/docs/advanced-usage-examples.md +1360 -0
- package/docs/agent-development-guide.md +386 -0
- package/docs/api-reference.md +916 -0
- package/docs/broken-functionality-tracker.md +285 -0
- package/docs/bundling-system-deep-dive.md +525 -0
- package/docs/cli-reference.md +393 -0
- package/docs/comprehensive-documentation.md +1403 -0
- package/docs/configuration-reference.md +808 -0
- package/docs/controls-development.md +859 -0
- package/docs/documentation-review/CURRENT_REVIEW.md +95 -0
- package/docs/function-publishers-json-apis.md +847 -0
- package/docs/getting-started-with-json.md +518 -0
- package/docs/minification-compression-sourcemaps-status.md +482 -0
- package/docs/minification-compression-sourcemaps-test-results.md +205 -0
- package/docs/publishers-guide.md +313 -0
- package/docs/resources-guide.md +615 -0
- package/docs/serve-helpers.md +406 -0
- package/docs/simple-server-api-design.md +13 -0
- package/docs/system-architecture.md +275 -0
- package/docs/troubleshooting.md +698 -0
- package/examples/json/README.md +115 -0
- package/examples/json/basic-api/README.md +345 -0
- package/examples/json/basic-api/server.js +199 -0
- package/examples/json/simple-api/README.md +125 -0
- package/examples/json/simple-api/diagnostic-report.json +73 -0
- package/examples/json/simple-api/diagnostic-test.js +433 -0
- package/examples/json/simple-api/server-debug.md +58 -0
- package/examples/json/simple-api/server.js +91 -0
- package/examples/json/simple-api/test.js +215 -0
- package/http/responders/static/Static_Route_HTTP_Responder.js +1 -2
- package/package.json +19 -8
- package/publishers/helpers/assigners/static-compressed-response-buffers/Single_Control_Webpage_Server_Static_Compressed_Response_Buffers_Assigner.js +65 -12
- package/publishers/helpers/preparers/static/bundle/Static_Routes_Responses_Webpage_Bundle_Preparer.js +6 -1
- package/publishers/http-function-publisher.js +59 -38
- package/publishers/http-webpage-publisher.js +48 -1
- package/resources/processors/bundlers/js/esbuild/Advanced_JS_Bundler_Using_ESBuild.js +38 -146
- package/resources/processors/bundlers/js/esbuild/Core_JS_Non_Minifying_Bundler_Using_ESBuild.js +54 -5
- package/resources/processors/bundlers/js/esbuild/Core_JS_Single_File_Minifying_Bundler_Using_ESBuild.js +36 -4
- package/serve-factory.js +36 -9
- package/server.js +10 -4
- package/test-report.json +0 -0
- package/tests/README.md +250 -0
- package/tests/assigners.test.js +316 -0
- package/tests/bundlers.test.js +329 -0
- package/tests/configuration-validation.test.js +530 -0
- package/tests/content-analysis.test.js +641 -0
- package/tests/end-to-end.test.js +496 -0
- package/tests/error-handling.test.js +746 -0
- package/tests/performance.test.js +653 -0
- package/tests/publishers.test.js +395 -0
- package/tests/temp_invalid.js +7 -0
- package/tests/temp_invalid_utf8.js +1 -0
- package/tests/temp_malformed.js +10 -0
- package/tests/test-runner.js +261 -0
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
# CLI Reference
|
|
2
|
+
|
|
3
|
+
## When to Read
|
|
4
|
+
|
|
5
|
+
This document provides comprehensive reference for the JSGUI3 Server command-line interface. Read this when:
|
|
6
|
+
- You need detailed information about CLI commands and options
|
|
7
|
+
- You're automating server startup in scripts or CI/CD pipelines
|
|
8
|
+
- You want to understand all available CLI configuration options
|
|
9
|
+
- You're troubleshooting CLI-related issues
|
|
10
|
+
- You need to integrate JSGUI3 Server with other tools
|
|
11
|
+
|
|
12
|
+
**Note:** For basic usage, see [README.md](../README.md). For programmatic server usage, see [docs/comprehensive-documentation.md](docs/comprehensive-documentation.md).
|
|
13
|
+
|
|
14
|
+
## Overview
|
|
15
|
+
|
|
16
|
+
The JSGUI3 Server CLI provides a simple command-line interface for starting and managing servers. It's designed for development, testing, and simple deployment scenarios.
|
|
17
|
+
|
|
18
|
+
## Command Syntax
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
node cli.js [command] [options]
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Commands
|
|
25
|
+
|
|
26
|
+
### serve (Default Command)
|
|
27
|
+
|
|
28
|
+
Starts a JSGUI3 Server instance with automatic client discovery.
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# Basic usage - auto-discovers client.js
|
|
32
|
+
node cli.js serve
|
|
33
|
+
|
|
34
|
+
# With port specification
|
|
35
|
+
node cli.js serve --port 3000
|
|
36
|
+
|
|
37
|
+
# With host binding
|
|
38
|
+
node cli.js serve --host 127.0.0.1 --port 8080
|
|
39
|
+
|
|
40
|
+
# With root directory override
|
|
41
|
+
node cli.js serve --root ./my-app --port 3000
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
**Options:**
|
|
45
|
+
- `--port <n>`: Server port number (default: 8080, 0 = ephemeral/random port)
|
|
46
|
+
- `--host <addr>`: IPv4 address to bind to (default: all interfaces)
|
|
47
|
+
- `--root <path>`: Project root directory (default: current working directory)
|
|
48
|
+
|
|
49
|
+
### help
|
|
50
|
+
|
|
51
|
+
Displays help information and available commands.
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
node cli.js --help
|
|
55
|
+
node cli.js help
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### version
|
|
59
|
+
|
|
60
|
+
Displays the version information.
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
node cli.js --version
|
|
64
|
+
node cli.js version
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Environment Variables
|
|
68
|
+
|
|
69
|
+
The CLI respects the following environment variables:
|
|
70
|
+
|
|
71
|
+
### PORT
|
|
72
|
+
Server port number. Takes precedence over `--port` option.
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
PORT=3000 node cli.js serve
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### HOST
|
|
79
|
+
Server host binding. Takes precedence over `--host` option.
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
HOST=127.0.0.1 node cli.js serve
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### JSGUI_DEBUG
|
|
86
|
+
Enables debug mode with verbose logging and source maps.
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
JSGUI_DEBUG=1 node cli.js serve
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
**Values:**
|
|
93
|
+
- `1`, `true`, `yes` → Enable debug mode
|
|
94
|
+
- `0`, `false`, `no` → Disable debug mode (default)
|
|
95
|
+
|
|
96
|
+
## Client Discovery
|
|
97
|
+
|
|
98
|
+
The CLI automatically discovers client files in the following order:
|
|
99
|
+
|
|
100
|
+
1. **Explicit path**: If specified in server configuration
|
|
101
|
+
2. **Current directory**: `./client.js`
|
|
102
|
+
3. **Source directory**: `./src/client.js`
|
|
103
|
+
4. **App directory**: `./app/client.js`
|
|
104
|
+
|
|
105
|
+
## Configuration Resolution
|
|
106
|
+
|
|
107
|
+
The CLI resolves configuration in this order (later sources override earlier ones):
|
|
108
|
+
|
|
109
|
+
1. **Default values**: Built-in defaults
|
|
110
|
+
2. **Environment variables**: `PORT`, `HOST`, `JSGUI_DEBUG`
|
|
111
|
+
3. **Command-line options**: `--port`, `--host`, `--root`
|
|
112
|
+
4. **Configuration files**: `jsgui.config.js` (if present)
|
|
113
|
+
|
|
114
|
+
## Examples
|
|
115
|
+
|
|
116
|
+
### Development Server
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
# Start development server with debug logging
|
|
120
|
+
JSGUI_DEBUG=1 node cli.js serve --port 3000
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Production Server
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
# Start production server on specific port
|
|
127
|
+
PORT=80 HOST=0.0.0.0 node cli.js serve
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Ephemeral Port
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
# Use random available port (useful for testing)
|
|
134
|
+
node cli.js serve --port 0
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Custom Root Directory
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
# Serve from different directory
|
|
141
|
+
node cli.js serve --root ../other-project --port 3000
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Error Handling
|
|
145
|
+
|
|
146
|
+
### Common Exit Codes
|
|
147
|
+
|
|
148
|
+
- **0**: Success
|
|
149
|
+
- **1**: General error (configuration, startup failure)
|
|
150
|
+
- **2**: Invalid arguments
|
|
151
|
+
|
|
152
|
+
### Error Messages
|
|
153
|
+
|
|
154
|
+
The CLI provides clear, actionable error messages:
|
|
155
|
+
|
|
156
|
+
```
|
|
157
|
+
jsgui3-server: Control not found
|
|
158
|
+
|
|
159
|
+
Looking for a control to serve but none was specified.
|
|
160
|
+
|
|
161
|
+
Did you mean to:
|
|
162
|
+
- Create a client.js file in the current directory
|
|
163
|
+
- Specify a different root directory with --root
|
|
164
|
+
- Check that your client.js exports a control
|
|
165
|
+
|
|
166
|
+
Current directory: /path/to/project
|
|
167
|
+
Searched for: client.js, src/client.js, app/client.js
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## Integration Examples
|
|
171
|
+
|
|
172
|
+
### NPM Scripts
|
|
173
|
+
|
|
174
|
+
```json
|
|
175
|
+
{
|
|
176
|
+
"scripts": {
|
|
177
|
+
"dev": "JSGUI_DEBUG=1 node cli.js serve --port 3000",
|
|
178
|
+
"start": "node cli.js serve --port 80",
|
|
179
|
+
"test": "node cli.js serve --port 0"
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Docker
|
|
185
|
+
|
|
186
|
+
```dockerfile
|
|
187
|
+
FROM node:18-alpine
|
|
188
|
+
WORKDIR /app
|
|
189
|
+
COPY package*.json ./
|
|
190
|
+
RUN npm ci --only=production
|
|
191
|
+
COPY . .
|
|
192
|
+
EXPOSE 8080
|
|
193
|
+
CMD ["node", "cli.js", "serve", "--host", "0.0.0.0"]
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Systemd Service
|
|
197
|
+
|
|
198
|
+
```ini
|
|
199
|
+
[Unit]
|
|
200
|
+
Description=JSGUI3 Server
|
|
201
|
+
After=network.target
|
|
202
|
+
|
|
203
|
+
[Service]
|
|
204
|
+
Type=simple
|
|
205
|
+
User=jsgui
|
|
206
|
+
WorkingDirectory=/opt/jsgui3-server
|
|
207
|
+
ExecStart=/usr/bin/node cli.js serve --host 0.0.0.0 --port 80
|
|
208
|
+
Restart=always
|
|
209
|
+
|
|
210
|
+
[Install]
|
|
211
|
+
WantedBy=multi-user.target
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### CI/CD Pipeline
|
|
215
|
+
|
|
216
|
+
```yaml
|
|
217
|
+
# GitHub Actions example
|
|
218
|
+
- name: Start JSGUI3 Server
|
|
219
|
+
run: |
|
|
220
|
+
npm install
|
|
221
|
+
node cli.js serve --port 3000 &
|
|
222
|
+
sleep 5
|
|
223
|
+
curl http://localhost:3000
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
## Troubleshooting
|
|
227
|
+
|
|
228
|
+
### Server Won't Start
|
|
229
|
+
|
|
230
|
+
**Check port availability:**
|
|
231
|
+
```bash
|
|
232
|
+
# Find process using port
|
|
233
|
+
lsof -i :8080
|
|
234
|
+
netstat -ano | findstr :8080
|
|
235
|
+
|
|
236
|
+
# Use different port
|
|
237
|
+
node cli.js serve --port 3000
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
**Check permissions:**
|
|
241
|
+
```bash
|
|
242
|
+
# Low ports require root on Unix
|
|
243
|
+
sudo node cli.js serve --port 80
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### Client Not Found
|
|
247
|
+
|
|
248
|
+
**Verify file structure:**
|
|
249
|
+
```bash
|
|
250
|
+
ls -la client.js
|
|
251
|
+
# or
|
|
252
|
+
ls -la src/client.js
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
**Check exports:**
|
|
256
|
+
```javascript
|
|
257
|
+
// client.js should export controls
|
|
258
|
+
const jsgui = require('jsgui3-client');
|
|
259
|
+
// ... control definitions
|
|
260
|
+
module.exports = jsgui; // Must export jsgui object
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
### Debug Mode Issues
|
|
264
|
+
|
|
265
|
+
**Enable verbose logging:**
|
|
266
|
+
```bash
|
|
267
|
+
JSGUI_DEBUG=1 node cli.js serve
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
**Check for missing dependencies:**
|
|
271
|
+
```bash
|
|
272
|
+
npm ls jsgui3-client
|
|
273
|
+
npm ls jsgui3-html
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
## Advanced Usage
|
|
277
|
+
|
|
278
|
+
### Custom Configuration File
|
|
279
|
+
|
|
280
|
+
Create `jsgui.config.js`:
|
|
281
|
+
|
|
282
|
+
```javascript
|
|
283
|
+
module.exports = {
|
|
284
|
+
port: 3000,
|
|
285
|
+
host: 'localhost',
|
|
286
|
+
debug: process.env.NODE_ENV === 'development',
|
|
287
|
+
// Additional server options
|
|
288
|
+
};
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### Programmatic Usage
|
|
292
|
+
|
|
293
|
+
```javascript
|
|
294
|
+
const { spawn } = require('child_process');
|
|
295
|
+
|
|
296
|
+
function startServer(options = {}) {
|
|
297
|
+
const args = ['cli.js', 'serve'];
|
|
298
|
+
|
|
299
|
+
if (options.port) args.push('--port', options.port);
|
|
300
|
+
if (options.host) args.push('--host', options.host);
|
|
301
|
+
|
|
302
|
+
const server = spawn('node', args, {
|
|
303
|
+
stdio: 'inherit',
|
|
304
|
+
env: {
|
|
305
|
+
...process.env,
|
|
306
|
+
JSGUI_DEBUG: options.debug ? '1' : '0'
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
return server;
|
|
311
|
+
}
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
## Performance Tuning
|
|
315
|
+
|
|
316
|
+
### Memory Usage
|
|
317
|
+
|
|
318
|
+
```bash
|
|
319
|
+
# Monitor memory usage
|
|
320
|
+
node --max-old-space-size=512 cli.js serve
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
### Connection Limits
|
|
324
|
+
|
|
325
|
+
```bash
|
|
326
|
+
# Limit concurrent connections (system dependent)
|
|
327
|
+
ulimit -n 1024
|
|
328
|
+
node cli.js serve
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
## Security Considerations
|
|
332
|
+
|
|
333
|
+
### Host Binding
|
|
334
|
+
|
|
335
|
+
```bash
|
|
336
|
+
# Bind only to localhost for development
|
|
337
|
+
node cli.js serve --host 127.0.0.1
|
|
338
|
+
|
|
339
|
+
# Bind to all interfaces for production (use firewall)
|
|
340
|
+
node cli.js serve --host 0.0.0.0
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
### Environment Variables
|
|
344
|
+
|
|
345
|
+
Avoid hardcoding sensitive information:
|
|
346
|
+
|
|
347
|
+
```bash
|
|
348
|
+
# Use environment variables for sensitive config
|
|
349
|
+
DATABASE_URL=postgres://... node cli.js serve
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
## Migration from Direct Server Usage
|
|
353
|
+
|
|
354
|
+
### Before (Direct Server)
|
|
355
|
+
|
|
356
|
+
```javascript
|
|
357
|
+
const Server = require('jsgui3-server');
|
|
358
|
+
const { MyControl } = require('./client').controls;
|
|
359
|
+
|
|
360
|
+
Server.serve({ ctrl: MyControl, port: 3000 });
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
### After (CLI)
|
|
364
|
+
|
|
365
|
+
```bash
|
|
366
|
+
# Same functionality via CLI
|
|
367
|
+
node cli.js serve --port 3000
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
### Benefits of CLI Migration
|
|
371
|
+
|
|
372
|
+
- **Standardization**: Consistent startup across environments
|
|
373
|
+
- **Scripting**: Easy integration with other tools
|
|
374
|
+
- **Monitoring**: Standard process management
|
|
375
|
+
- **Deployment**: Simplified containerization and orchestration
|
|
376
|
+
|
|
377
|
+
## Future Enhancements
|
|
378
|
+
|
|
379
|
+
### Planned Features
|
|
380
|
+
|
|
381
|
+
- **Hot Reload**: Automatic restart on file changes
|
|
382
|
+
- **Multi-Instance**: Load balancing across multiple processes
|
|
383
|
+
- **Health Checks**: Built-in health monitoring endpoints
|
|
384
|
+
- **Configuration Validation**: Automatic config file validation
|
|
385
|
+
- **Plugin System**: Extensible command system
|
|
386
|
+
|
|
387
|
+
### Backward Compatibility
|
|
388
|
+
|
|
389
|
+
All current CLI functionality will remain available. New features will be additive, ensuring existing scripts and automation continue to work.
|
|
390
|
+
|
|
391
|
+
---
|
|
392
|
+
|
|
393
|
+
This CLI reference provides comprehensive information for using JSGUI3 Server from the command line. For programmatic server control, see the Server API documentation.
|