@constela/cli 0.4.0 → 0.4.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/README.md +183 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -30,6 +30,10 @@ constela compile <input> [options]
|
|
|
30
30
|
**Options:**
|
|
31
31
|
- `-o, --out <path>` - Output file path
|
|
32
32
|
- `--pretty` - Pretty-print JSON output
|
|
33
|
+
- `--json` - Output results as JSON (for tooling/AI integration)
|
|
34
|
+
- `-w, --watch` - Watch input file and recompile on changes
|
|
35
|
+
- `-v, --verbose` - Show detailed compilation progress
|
|
36
|
+
- `--debug` - Show internal debug information
|
|
33
37
|
|
|
34
38
|
**Examples:**
|
|
35
39
|
|
|
@@ -42,6 +46,114 @@ constela compile app.json --out dist/app.compiled.json
|
|
|
42
46
|
|
|
43
47
|
# Pretty-print output
|
|
44
48
|
constela compile app.json --pretty
|
|
49
|
+
|
|
50
|
+
# JSON output for AI tools
|
|
51
|
+
constela compile app.json --json
|
|
52
|
+
|
|
53
|
+
# Watch mode for development
|
|
54
|
+
constela compile app.json --watch
|
|
55
|
+
|
|
56
|
+
# Verbose output with timing
|
|
57
|
+
constela compile app.json --verbose
|
|
58
|
+
# Output:
|
|
59
|
+
# [1/3] Validating schema... OK (2ms)
|
|
60
|
+
# [2/3] Analyzing semantics... OK (1ms)
|
|
61
|
+
# [3/3] Transforming AST... OK (0ms)
|
|
62
|
+
# Compilation successful (5ms total)
|
|
63
|
+
|
|
64
|
+
# Debug information
|
|
65
|
+
constela compile app.json --debug
|
|
66
|
+
# Output:
|
|
67
|
+
# [DEBUG] Input file: app.json (1234 bytes)
|
|
68
|
+
# [DEBUG] Parse time: 1ms
|
|
69
|
+
# [DEBUG] Validate pass: 15 nodes validated (2ms)
|
|
70
|
+
# ...
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### constela validate
|
|
74
|
+
|
|
75
|
+
Validates Constela JSON files without full compilation (faster feedback).
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
constela validate [input] [options]
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
**Arguments:**
|
|
82
|
+
- `[input]` - Input DSL file (JSON) or directory with `--all`
|
|
83
|
+
|
|
84
|
+
**Options:**
|
|
85
|
+
- `-a, --all` - Validate all JSON files in directory recursively
|
|
86
|
+
- `--json` - Output results as JSON
|
|
87
|
+
|
|
88
|
+
**Examples:**
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
# Validate single file
|
|
92
|
+
constela validate app.json
|
|
93
|
+
|
|
94
|
+
# Validate all JSON files in directory
|
|
95
|
+
constela validate --all src/routes/
|
|
96
|
+
|
|
97
|
+
# JSON output for tooling
|
|
98
|
+
constela validate app.json --json
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
**Error Output with Suggestions:**
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
Error [UNDEFINED_STATE] at /view/children/0/value/name
|
|
105
|
+
|
|
106
|
+
Undefined state reference: 'count'
|
|
107
|
+
|
|
108
|
+
Did you mean 'counter'?
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### constela inspect
|
|
112
|
+
|
|
113
|
+
Inspects Constela program structure without compilation.
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
constela inspect <input> [options]
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
**Arguments:**
|
|
120
|
+
- `<input>` - Input DSL file (JSON)
|
|
121
|
+
|
|
122
|
+
**Options:**
|
|
123
|
+
- `--state` - Show only state information
|
|
124
|
+
- `--actions` - Show only actions information
|
|
125
|
+
- `--components` - Show only components information
|
|
126
|
+
- `--view` - Show only view tree
|
|
127
|
+
- `--json` - Output as JSON
|
|
128
|
+
|
|
129
|
+
**Examples:**
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
# Show all program structure
|
|
133
|
+
constela inspect app.json
|
|
134
|
+
|
|
135
|
+
# Show only state
|
|
136
|
+
constela inspect app.json --state
|
|
137
|
+
|
|
138
|
+
# JSON output
|
|
139
|
+
constela inspect app.json --json
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
**Output:**
|
|
143
|
+
|
|
144
|
+
```
|
|
145
|
+
State (2 fields):
|
|
146
|
+
count: number = 0
|
|
147
|
+
items: list = []
|
|
148
|
+
|
|
149
|
+
Actions (2):
|
|
150
|
+
increment: update count +1
|
|
151
|
+
addItem: push to items
|
|
152
|
+
|
|
153
|
+
View Tree:
|
|
154
|
+
element<div>
|
|
155
|
+
text: state.count
|
|
156
|
+
element<button> onClick=increment
|
|
45
157
|
```
|
|
46
158
|
|
|
47
159
|
### constela dev
|
|
@@ -156,6 +268,77 @@ export default {
|
|
|
156
268
|
} satisfies ConstelaConfig;
|
|
157
269
|
```
|
|
158
270
|
|
|
271
|
+
## Debugging Guide
|
|
272
|
+
|
|
273
|
+
### Using Debug Mode
|
|
274
|
+
|
|
275
|
+
Add `--debug` to any compile command to see internal processing:
|
|
276
|
+
|
|
277
|
+
```bash
|
|
278
|
+
constela compile app.json --debug
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
**Debug output includes:**
|
|
282
|
+
- File size and parse time
|
|
283
|
+
- Number of nodes validated
|
|
284
|
+
- Analysis pass details
|
|
285
|
+
- Transform timings
|
|
286
|
+
|
|
287
|
+
### Common Issues
|
|
288
|
+
|
|
289
|
+
#### UNDEFINED_STATE Error
|
|
290
|
+
|
|
291
|
+
```
|
|
292
|
+
Error [UNDEFINED_STATE] at /view/children/0/value/name
|
|
293
|
+
Undefined state reference: 'count'
|
|
294
|
+
Did you mean 'counter'?
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
**Solution:** Check your state name spelling. The error shows suggested corrections.
|
|
298
|
+
|
|
299
|
+
#### SCHEMA_INVALID Error
|
|
300
|
+
|
|
301
|
+
```
|
|
302
|
+
Error [SCHEMA_INVALID] at /view/kind
|
|
303
|
+
Invalid value: 'button'. Expected one of: element, text, if, each, component, slot, markdown, code
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
**Solution:** Use correct node kind. `kind: "element"` with `tag: "button"` for buttons.
|
|
307
|
+
|
|
308
|
+
#### Component Not Found
|
|
309
|
+
|
|
310
|
+
```
|
|
311
|
+
Error [COMPONENT_NOT_FOUND] at /view/children/0/name
|
|
312
|
+
Component 'Header' is not defined
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
**Solution:** Define the component in the `components` section or check import paths.
|
|
316
|
+
|
|
317
|
+
### Inspecting Program Structure
|
|
318
|
+
|
|
319
|
+
Use `inspect` to understand your program without compilation:
|
|
320
|
+
|
|
321
|
+
```bash
|
|
322
|
+
# See state structure
|
|
323
|
+
constela inspect app.json --state
|
|
324
|
+
|
|
325
|
+
# See view tree
|
|
326
|
+
constela inspect app.json --view
|
|
327
|
+
|
|
328
|
+
# Get JSON for tooling
|
|
329
|
+
constela inspect app.json --json | jq '.state'
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
### Browser DevTools
|
|
333
|
+
|
|
334
|
+
For runtime debugging:
|
|
335
|
+
|
|
336
|
+
1. Open DevTools → Sources tab
|
|
337
|
+
2. Find `@constela/runtime` in the source tree
|
|
338
|
+
3. Set breakpoints in action handlers
|
|
339
|
+
|
|
340
|
+
State changes are logged to console in development mode.
|
|
341
|
+
|
|
159
342
|
## Exit Codes
|
|
160
343
|
|
|
161
344
|
| Code | Description |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constela/cli",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "CLI tools for Constela UI framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"commander": "^12.0.0",
|
|
22
|
-
"@constela/
|
|
23
|
-
"@constela/
|
|
24
|
-
"@constela/
|
|
22
|
+
"@constela/core": "0.8.0",
|
|
23
|
+
"@constela/start": "1.2.25",
|
|
24
|
+
"@constela/compiler": "0.8.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/node": "^20.10.0",
|