@bytefaceinc/web-lang 0.1.1
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/LICENSE +21 -0
- package/README.md +277 -0
- package/bin/web.js +10 -0
- package/compiler.js +4602 -0
- package/docs/cli.md +657 -0
- package/docs/compiler.md +1433 -0
- package/docs/error-handling.md +863 -0
- package/docs/getting-started.md +805 -0
- package/docs/language-guide.md +945 -0
- package/lib/cli/commands/compile.js +127 -0
- package/lib/cli/commands/init.js +172 -0
- package/lib/cli/commands/screenshot.js +257 -0
- package/lib/cli/commands/watch.js +458 -0
- package/lib/cli/compile-service.js +19 -0
- package/lib/cli/compile-worker.js +32 -0
- package/lib/cli/compiler-runner.js +37 -0
- package/lib/cli/index.js +154 -0
- package/lib/cli/init-service.js +204 -0
- package/lib/cli/screenshot-artifacts.js +81 -0
- package/lib/cli/screenshot-service.js +153 -0
- package/lib/cli/shared.js +261 -0
- package/lib/cli/targets.js +199 -0
- package/lib/cli/watch-settings.js +37 -0
- package/package.json +50 -0
package/docs/cli.md
ADDED
|
@@ -0,0 +1,657 @@
|
|
|
1
|
+
# WEB CLI
|
|
2
|
+
|
|
3
|
+
The WEB CLI has four jobs:
|
|
4
|
+
|
|
5
|
+
- initialize a new WEB project in the current directory or one target directory
|
|
6
|
+
- compile `.web` source files into matching HTML and CSS files
|
|
7
|
+
- render a compiled `.web` page to a screenshot image
|
|
8
|
+
- watch one `.web` source and rebuild it automatically on change
|
|
9
|
+
|
|
10
|
+
The command is exposed as:
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
web
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
This package exposes the CLI binary from `bin/web.js`.
|
|
17
|
+
|
|
18
|
+
## Quick Start
|
|
19
|
+
|
|
20
|
+
Initialize a starter project in a clean directory:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
web init
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Initialize the current directory explicitly:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
web init .
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Initialize a new `website` folder and create it if it does not exist yet:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
web init website
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Compile a single file:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
web home.web
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Compile the same file without writing the extension:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
web home
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Compile every `.web` file in the current directory:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
web .
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Compile matching files from another directory:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
web ./code/*
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Render a screenshot using the default full-page mode:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
web screenshot home.web
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Render a JPG at a specific viewport size and device scale factor:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
web screenshot home.web --jpg 1080 1080 2
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Watch a file and recompile it automatically:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
web watch home.web
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Watch a file and capture a baseline screenshot plus timed snapshots every 5 minutes:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
web watch home.web -s
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
If no argument is provided and `layout.web` exists in the current working directory, the CLI compiles `layout.web` automatically.
|
|
87
|
+
|
|
88
|
+
When `web init` runs, the CLI also creates `web-lang-agents.md` in the chosen project root by combining `getting-started.md`, `cli.md`, and `compiler.md` in that order. The goal is to give local agents one up-to-date context document to load quickly.
|
|
89
|
+
|
|
90
|
+
## Installation and Invocation
|
|
91
|
+
|
|
92
|
+
From this repo, the command is registered in `package.json` as:
|
|
93
|
+
|
|
94
|
+
```json
|
|
95
|
+
{
|
|
96
|
+
"bin": {
|
|
97
|
+
"web": "./bin/web.js"
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Common ways to run it during development:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
node bin/web.js init
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
node bin/web.js init website
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
npm link
|
|
114
|
+
web init
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
npm link
|
|
119
|
+
web init website
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
node bin/web.js home.web
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
npm link
|
|
128
|
+
web home.web
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
npm link
|
|
133
|
+
web screenshot home.web
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
npm link
|
|
138
|
+
web watch home.web -s
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Commands
|
|
142
|
+
|
|
143
|
+
### 1. Init
|
|
144
|
+
|
|
145
|
+
The init command scaffolds a starter WEB project in the current working directory or in one target directory, generates a local agent context document, and compiles the starter page immediately.
|
|
146
|
+
|
|
147
|
+
Basic form:
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
web init
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
web init .
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
web init website
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Behavior:
|
|
162
|
+
|
|
163
|
+
- Uses the current working directory when you omit the target.
|
|
164
|
+
- Accepts one directory target such as `.` or `website`.
|
|
165
|
+
- Creates the target directory automatically when it does not exist yet.
|
|
166
|
+
- Creates `index.web` with a simple intro banner.
|
|
167
|
+
- Creates `web-lang-agents.md` by combining `getting-started.md`, `cli.md`, and `compiler.md` from the packaged docs.
|
|
168
|
+
- Compiles the starter page into `index.html` and `index.css`.
|
|
169
|
+
- Refuses to overwrite existing `index.web`, `index.html`, `index.css`, or `web-lang-agents.md` files in the target directory.
|
|
170
|
+
|
|
171
|
+
Example:
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
web init .
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
web init website
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Notes:
|
|
182
|
+
|
|
183
|
+
- Run `web init` against a clean target directory.
|
|
184
|
+
- The generated `web-lang-agents.md` is meant for local agent context, not browser output.
|
|
185
|
+
- After `web init`, you can keep working in `index.web` or replace it with your own page structure.
|
|
186
|
+
- If the target directory already exists, WEB scaffolds inside it instead of creating a nested project name automatically.
|
|
187
|
+
|
|
188
|
+
### 2. Compile
|
|
189
|
+
|
|
190
|
+
These forms all route through the compile command even when you do not write `compile` explicitly.
|
|
191
|
+
|
|
192
|
+
The following are equivalent:
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
web home.web
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
web compile home.web
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### 3. Screenshot
|
|
203
|
+
|
|
204
|
+
The screenshot command compiles one `.web` source, writes the matching HTML and CSS outputs, then opens the compiled HTML in a headless browser and captures an image.
|
|
205
|
+
|
|
206
|
+
Basic form:
|
|
207
|
+
|
|
208
|
+
```bash
|
|
209
|
+
web screenshot home.web
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
Explicit JPG viewport capture:
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
web screenshot home.web --jpg 1080 1080 2
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
Syntax:
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
web screenshot <source> [--jpg|--png] [width height [deviceScaleFactor]]
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
Behavior:
|
|
225
|
+
|
|
226
|
+
- Accepts one resolved `.web` source at a time.
|
|
227
|
+
- Uses the same file and bare-name resolution rules as the compile command.
|
|
228
|
+
- Writes `home.html` and `home.css` next to the source file.
|
|
229
|
+
- Writes the screenshot image into `./web-lang-screenshots` rooted at the current working directory.
|
|
230
|
+
- Creates `./web-lang-screenshots` automatically when it does not exist yet.
|
|
231
|
+
- Appends a human-readable local timestamp to each screenshot filename.
|
|
232
|
+
- Uses `jpg` by default.
|
|
233
|
+
- If no width and height are provided, the command uses a `1600px` wide viewport, keeps the default device scale factor of `1`, and captures the full page.
|
|
234
|
+
- If width and height are provided, the command captures the current viewport instead of forcing `fullPage`.
|
|
235
|
+
|
|
236
|
+
Examples:
|
|
237
|
+
|
|
238
|
+
```bash
|
|
239
|
+
web screenshot home
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
```bash
|
|
243
|
+
web screenshot home.web --png 1440 900
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
web screenshot home.web --jpg 1080 1080 2
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
Notes:
|
|
251
|
+
|
|
252
|
+
- The first numeric argument is the viewport width.
|
|
253
|
+
- The second numeric argument is the viewport height.
|
|
254
|
+
- The optional third numeric argument is the browser `deviceScaleFactor`.
|
|
255
|
+
- A higher `deviceScaleFactor` produces a sharper image with more output pixels.
|
|
256
|
+
|
|
257
|
+
### 4. Watch
|
|
258
|
+
|
|
259
|
+
The watch command watches one resolved `.web` source, recompiles it when the source changes, and stays alive until the session is idle long enough to shut itself down.
|
|
260
|
+
|
|
261
|
+
Basic form:
|
|
262
|
+
|
|
263
|
+
```bash
|
|
264
|
+
web watch home.web
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
Watch with timed screenshots:
|
|
268
|
+
|
|
269
|
+
```bash
|
|
270
|
+
web watch home.web -s
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
Syntax:
|
|
274
|
+
|
|
275
|
+
```bash
|
|
276
|
+
web watch <source> [-screenshot|-s]
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
Behavior:
|
|
280
|
+
|
|
281
|
+
- Accepts exactly one resolved `.web` source.
|
|
282
|
+
- Uses the same file and bare-name resolution rules as the compile command.
|
|
283
|
+
- Performs an initial compile when the watch session starts.
|
|
284
|
+
- Recompiles the source whenever the watched file changes.
|
|
285
|
+
- Stops automatically after 1 hour with no recent source activity.
|
|
286
|
+
- Prints a verbose exit summary explaining why the watch session ended.
|
|
287
|
+
- With `-s` or `-screenshot`, captures one baseline screenshot after the first successful compile and then keeps capturing snapshots every 5 minutes.
|
|
288
|
+
- Uses the same `./web-lang-screenshots` workspace and timestamped filename pattern as `web screenshot`.
|
|
289
|
+
|
|
290
|
+
Examples:
|
|
291
|
+
|
|
292
|
+
```bash
|
|
293
|
+
web watch home
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
```bash
|
|
297
|
+
web watch home.web
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
```bash
|
|
301
|
+
web watch home.web -s
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
```bash
|
|
305
|
+
web watch home.web -screenshot
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
Notes:
|
|
309
|
+
|
|
310
|
+
- Watch mode currently supports one source file at a time.
|
|
311
|
+
- Periodic screenshots do not reset the idle timer.
|
|
312
|
+
- If the source file keeps changing, the watch session stays alive and keeps rebuilding.
|
|
313
|
+
|
|
314
|
+
## Compile Target Forms
|
|
315
|
+
|
|
316
|
+
### 1. Compile one explicit file
|
|
317
|
+
|
|
318
|
+
```bash
|
|
319
|
+
web landing.web
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
Behavior:
|
|
323
|
+
|
|
324
|
+
- Resolves the path relative to the current working directory.
|
|
325
|
+
- Accepts only files ending in `.web`.
|
|
326
|
+
- Writes outputs next to the source file.
|
|
327
|
+
|
|
328
|
+
Example result:
|
|
329
|
+
|
|
330
|
+
- `landing.web` -> `landing.html`
|
|
331
|
+
- `landing.web` -> `landing.css`
|
|
332
|
+
|
|
333
|
+
### 2. Compile one file by bare name
|
|
334
|
+
|
|
335
|
+
```bash
|
|
336
|
+
web landing
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
Behavior:
|
|
340
|
+
|
|
341
|
+
- If `landing.web` exists in the current working directory, it is used.
|
|
342
|
+
- This convenience only applies when the target has no extension.
|
|
343
|
+
- If the file does not exist, the CLI reports a target issue.
|
|
344
|
+
|
|
345
|
+
### 3. Compile a directory
|
|
346
|
+
|
|
347
|
+
```bash
|
|
348
|
+
web .
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
Behavior:
|
|
352
|
+
|
|
353
|
+
- Compiles direct `.web` files in that directory.
|
|
354
|
+
- Does not recurse into nested folders.
|
|
355
|
+
- Ignores non-`.web` files.
|
|
356
|
+
|
|
357
|
+
Example:
|
|
358
|
+
|
|
359
|
+
```text
|
|
360
|
+
project/
|
|
361
|
+
home.web
|
|
362
|
+
about.web
|
|
363
|
+
notes.txt
|
|
364
|
+
code/
|
|
365
|
+
contact.web
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
`web .` compiles:
|
|
369
|
+
|
|
370
|
+
- `home.web`
|
|
371
|
+
- `about.web`
|
|
372
|
+
|
|
373
|
+
It does not compile:
|
|
374
|
+
|
|
375
|
+
- `notes.txt`
|
|
376
|
+
- `code/contact.web`
|
|
377
|
+
|
|
378
|
+
### 4. Compile a glob
|
|
379
|
+
|
|
380
|
+
```bash
|
|
381
|
+
web ./code/*
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
Behavior:
|
|
385
|
+
|
|
386
|
+
- Supports `*`, `?`, and character ranges like `[ab]`.
|
|
387
|
+
- Matches are resolved relative to the current working directory.
|
|
388
|
+
- Matching directories are expanded into direct `.web` files inside them.
|
|
389
|
+
- Matching files are compiled only if they end in `.web`.
|
|
390
|
+
|
|
391
|
+
Notes:
|
|
392
|
+
|
|
393
|
+
- In shells like `zsh`, the shell may expand the glob before the CLI receives it. That still works.
|
|
394
|
+
- If the shell does not expand the glob, the CLI expands it itself.
|
|
395
|
+
|
|
396
|
+
## Output Rules
|
|
397
|
+
|
|
398
|
+
The compile command writes outputs next to each source file using the same base name.
|
|
399
|
+
|
|
400
|
+
Examples:
|
|
401
|
+
|
|
402
|
+
- `home.web` -> `home.html` and `home.css`
|
|
403
|
+
- `pages/about.web` -> `pages/about.html` and `pages/about.css`
|
|
404
|
+
- `src/marketing/hero.web` -> `src/marketing/hero.html` and `src/marketing/hero.css`
|
|
405
|
+
|
|
406
|
+
The generated HTML links to the matching CSS filename for that source file.
|
|
407
|
+
|
|
408
|
+
The screenshot command writes image artifacts into a dedicated screenshot workspace rooted at the current working directory.
|
|
409
|
+
|
|
410
|
+
Examples:
|
|
411
|
+
|
|
412
|
+
- `home.web` -> `web-lang-screenshots/home-YYYY-MM-DD_HH-mm-ss-SSS.jpg`
|
|
413
|
+
- `home.web` with `--png` -> `web-lang-screenshots/home-YYYY-MM-DD_HH-mm-ss-SSS.png`
|
|
414
|
+
- `pages/about.web` -> `web-lang-screenshots/pages/about-YYYY-MM-DD_HH-mm-ss-SSS.jpg`
|
|
415
|
+
|
|
416
|
+
The command still writes `home.html` and `home.css` first, because the screenshot is taken from the compiled page.
|
|
417
|
+
|
|
418
|
+
When the source file lives inside the current working directory, the CLI preserves its relative folder structure inside `web-lang-screenshots` to avoid filename collisions.
|
|
419
|
+
If two captures happen with the same timestamp label, the CLI adds a numeric suffix instead of overwriting the earlier image.
|
|
420
|
+
|
|
421
|
+
The watch command uses the same screenshot workspace and filename pattern when `-s` or `-screenshot` is enabled.
|
|
422
|
+
|
|
423
|
+
## User Experience
|
|
424
|
+
|
|
425
|
+
### Header
|
|
426
|
+
|
|
427
|
+
At startup, the CLI prints a header with:
|
|
428
|
+
|
|
429
|
+
- the CLI name
|
|
430
|
+
- the current version
|
|
431
|
+
- the number of WEB sources being compiled
|
|
432
|
+
- the current working directory
|
|
433
|
+
|
|
434
|
+
### Progress display
|
|
435
|
+
|
|
436
|
+
For each compile step, the CLI shows progress like:
|
|
437
|
+
|
|
438
|
+
```text
|
|
439
|
+
[1/3] Compiling home.web
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
When stdout is attached to a TTY, this line is animated with a spinner while compilation is running.
|
|
443
|
+
|
|
444
|
+
When stdout is not a TTY, the CLI prints static progress lines instead of animation. This makes logs and CI output cleaner.
|
|
445
|
+
|
|
446
|
+
### Per-step success line
|
|
447
|
+
|
|
448
|
+
On success, the compile flow prints:
|
|
449
|
+
|
|
450
|
+
- input file
|
|
451
|
+
- output HTML path
|
|
452
|
+
- output CSS path
|
|
453
|
+
- compile duration
|
|
454
|
+
|
|
455
|
+
It also prints per-file stats:
|
|
456
|
+
|
|
457
|
+
- DOM node count
|
|
458
|
+
- CSS rule count
|
|
459
|
+
- head entry count
|
|
460
|
+
- script block count
|
|
461
|
+
- source size
|
|
462
|
+
- total output size
|
|
463
|
+
|
|
464
|
+
The screenshot flow adds a second render step and prints:
|
|
465
|
+
|
|
466
|
+
- screenshot image path
|
|
467
|
+
- render duration
|
|
468
|
+
- format
|
|
469
|
+
- viewport or full-page mode
|
|
470
|
+
- device scale factor
|
|
471
|
+
- image size in bytes
|
|
472
|
+
|
|
473
|
+
The watch flow prints:
|
|
474
|
+
|
|
475
|
+
- an initial watch header describing the watched file, idle timeout, and screenshot mode
|
|
476
|
+
- a compile step each time the watched file changes
|
|
477
|
+
- a screenshot step when the baseline capture or periodic snapshots run
|
|
478
|
+
- a verbose exit block when the session stops because there was no recent source activity
|
|
479
|
+
|
|
480
|
+
### Summary block
|
|
481
|
+
|
|
482
|
+
After the compile command finishes, the CLI prints totals for:
|
|
483
|
+
|
|
484
|
+
- succeeded files
|
|
485
|
+
- failed files
|
|
486
|
+
- skipped targets
|
|
487
|
+
- total source bytes
|
|
488
|
+
- total output bytes
|
|
489
|
+
- total DOM nodes
|
|
490
|
+
- total CSS rules
|
|
491
|
+
- total head entries
|
|
492
|
+
- total script blocks
|
|
493
|
+
- total duration
|
|
494
|
+
|
|
495
|
+
After the screenshot command finishes, the CLI prints a focused summary for the single capture:
|
|
496
|
+
|
|
497
|
+
- source path
|
|
498
|
+
- generated HTML path
|
|
499
|
+
- generated CSS path
|
|
500
|
+
- image path
|
|
501
|
+
- image format
|
|
502
|
+
- capture mode
|
|
503
|
+
- viewport size and device scale factor
|
|
504
|
+
- measured page size
|
|
505
|
+
- image bytes
|
|
506
|
+
- compile stats
|
|
507
|
+
- total duration
|
|
508
|
+
|
|
509
|
+
After the watch command finishes because of inactivity, the CLI prints:
|
|
510
|
+
|
|
511
|
+
- the shutdown reason
|
|
512
|
+
- the watched source
|
|
513
|
+
- the idle threshold that was reached
|
|
514
|
+
- the last observed source activity time
|
|
515
|
+
- the last successful compile time
|
|
516
|
+
- the last failed compile details, when present
|
|
517
|
+
- the number of successful builds
|
|
518
|
+
- the number of failed builds
|
|
519
|
+
- the number of screenshots captured, when screenshot mode was enabled
|
|
520
|
+
- the total elapsed watch-session time
|
|
521
|
+
|
|
522
|
+
## Help and Version
|
|
523
|
+
|
|
524
|
+
Show usage help:
|
|
525
|
+
|
|
526
|
+
```bash
|
|
527
|
+
web --help
|
|
528
|
+
```
|
|
529
|
+
|
|
530
|
+
or
|
|
531
|
+
|
|
532
|
+
```bash
|
|
533
|
+
web -h
|
|
534
|
+
```
|
|
535
|
+
|
|
536
|
+
Show the CLI version:
|
|
537
|
+
|
|
538
|
+
```bash
|
|
539
|
+
web --version
|
|
540
|
+
```
|
|
541
|
+
|
|
542
|
+
or
|
|
543
|
+
|
|
544
|
+
```bash
|
|
545
|
+
web -v
|
|
546
|
+
```
|
|
547
|
+
|
|
548
|
+
Show command-specific help:
|
|
549
|
+
|
|
550
|
+
```bash
|
|
551
|
+
web init --help
|
|
552
|
+
```
|
|
553
|
+
|
|
554
|
+
```bash
|
|
555
|
+
web screenshot --help
|
|
556
|
+
```
|
|
557
|
+
|
|
558
|
+
```bash
|
|
559
|
+
web compile --help
|
|
560
|
+
```
|
|
561
|
+
|
|
562
|
+
```bash
|
|
563
|
+
web watch --help
|
|
564
|
+
```
|
|
565
|
+
|
|
566
|
+
## Exit Behavior
|
|
567
|
+
|
|
568
|
+
The CLI exits with code `0` when all requested targets resolve cleanly and all compiles succeed.
|
|
569
|
+
|
|
570
|
+
The CLI exits with code `1` when:
|
|
571
|
+
|
|
572
|
+
- no input targets are available
|
|
573
|
+
- init arguments are invalid
|
|
574
|
+
- an init target resolves to a file instead of a directory
|
|
575
|
+
- init would overwrite existing scaffold files
|
|
576
|
+
- one or more targets cannot be resolved
|
|
577
|
+
- one or more compiles fail
|
|
578
|
+
- screenshot arguments are invalid
|
|
579
|
+
- screenshot rendering fails
|
|
580
|
+
- watch arguments are invalid
|
|
581
|
+
- an unexpected runtime error occurs
|
|
582
|
+
|
|
583
|
+
The watch command exits with code `0` when it stops normally due to inactivity after at least one successful build.
|
|
584
|
+
|
|
585
|
+
The watch command exits with code `1` when it never produces a successful build before the session ends.
|
|
586
|
+
|
|
587
|
+
## Target Resolution Details
|
|
588
|
+
|
|
589
|
+
Targets are collected, normalized, and deduplicated before compilation.
|
|
590
|
+
|
|
591
|
+
This means:
|
|
592
|
+
|
|
593
|
+
- passing the same file more than once still compiles it once
|
|
594
|
+
- files from multiple targets are merged into one compile set
|
|
595
|
+
- final compile order is sorted by path
|
|
596
|
+
|
|
597
|
+
For `web screenshot`, the resolved target set must contain exactly one `.web` source. If a glob or directory resolves to more than one file, the CLI stops and explains the mismatch instead of guessing.
|
|
598
|
+
|
|
599
|
+
For `web watch`, the resolved target set must also contain exactly one `.web` source.
|
|
600
|
+
|
|
601
|
+
Example:
|
|
602
|
+
|
|
603
|
+
```bash
|
|
604
|
+
web home.web . ./pages/*
|
|
605
|
+
```
|
|
606
|
+
|
|
607
|
+
If `home.web` is also included by `.` or `./pages/*`, it will still only compile once.
|
|
608
|
+
|
|
609
|
+
## Error Reporting
|
|
610
|
+
|
|
611
|
+
The CLI distinguishes between two kinds of problems:
|
|
612
|
+
|
|
613
|
+
### Target issues
|
|
614
|
+
|
|
615
|
+
These happen before compilation starts.
|
|
616
|
+
|
|
617
|
+
Examples:
|
|
618
|
+
|
|
619
|
+
- a path does not exist
|
|
620
|
+
- a glob matches no `.web` files
|
|
621
|
+
- a directory contains no `.web` files
|
|
622
|
+
|
|
623
|
+
These are reported under a `Target issues` section and count toward `Skipped` in the summary.
|
|
624
|
+
|
|
625
|
+
### Compile failures
|
|
626
|
+
|
|
627
|
+
These happen after a `.web` file is selected for compilation.
|
|
628
|
+
|
|
629
|
+
Examples:
|
|
630
|
+
|
|
631
|
+
- syntax errors
|
|
632
|
+
- semantic errors from the compiler
|
|
633
|
+
- unexpected worker failures
|
|
634
|
+
|
|
635
|
+
These are reported per file and count toward `Failed` in the summary.
|
|
636
|
+
|
|
637
|
+
## Relationship to `node compiler.js`
|
|
638
|
+
|
|
639
|
+
The CLI and the legacy script mode are intentionally different:
|
|
640
|
+
|
|
641
|
+
- `node compiler.js` reads `layout.web` and writes `index.html` plus `styles.css`
|
|
642
|
+
- `web home.web` reads `home.web` and writes `home.html` plus `home.css`
|
|
643
|
+
|
|
644
|
+
Use the CLI when you want arbitrary `.web` filenames or multi-file compilation.
|
|
645
|
+
|
|
646
|
+
## Current Limitations
|
|
647
|
+
|
|
648
|
+
The current CLI behavior is intentionally simple:
|
|
649
|
+
|
|
650
|
+
- `web init` accepts at most one directory target
|
|
651
|
+
- directory compilation is not recursive
|
|
652
|
+
- there are no custom output directory flags yet
|
|
653
|
+
- watch mode supports one `.web` source at a time
|
|
654
|
+
- watch screenshots always use the default screenshot render settings
|
|
655
|
+
- there are no quiet or JSON output modes yet
|
|
656
|
+
|
|
657
|
+
If those features are added later, this document should be updated alongside `bin/web.js`.
|