@dusted/anqst 0.1.1 → 0.1.2
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 +99 -117
- package/dist/src/app.js +119 -194
- package/dist/src/{backend/tsc/debug-dump.js → debug-dump.js} +2 -1
- package/dist/src/emit.js +42 -66
- package/dist/src/layout.js +70 -0
- package/dist/src/parser.js +16 -1
- package/dist/src/{backend/tsc/program.js → program.js} +1 -1
- package/dist/src/project.js +220 -137
- package/dist/src/verify.js +9 -1
- package/index.d.ts +1 -0
- package/package.json +7 -2
- package/spec/AnQst-Spec-DSL.d.ts +2 -2
- package/dist/src/backend/ast/emit.js +0 -5
- package/dist/src/backend/ast/index.js +0 -13
- package/dist/src/backend/ast/parser.js +0 -5
- package/dist/src/backend/ast/verify.js +0 -5
- package/dist/src/backend/index.js +0 -16
- package/dist/src/backend/tsc/emit-cpp.js +0 -13
- package/dist/src/backend/tsc/emit-node.js +0 -13
- package/dist/src/backend/tsc/index.js +0 -41
- package/dist/src/backend/tsc/parser.js +0 -19
- package/dist/src/backend/tsc/verify.js +0 -13
- package/dist/src/backend/types.js +0 -2
- /package/dist/src/{backend/tsc/typegraph.js → typegraph.js} +0 -0
package/README.md
CHANGED
|
@@ -1,160 +1,142 @@
|
|
|
1
1
|
# AnQstGen
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
TypeScript implementation of the `anqst` CLI generator package.
|
|
4
4
|
|
|
5
|
-
## Build
|
|
5
|
+
## Build locally
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
8
|
npm install
|
|
9
9
|
npm run build
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
-
Run
|
|
12
|
+
Run from build output:
|
|
13
13
|
|
|
14
14
|
```bash
|
|
15
15
|
node dist/src/bin/anqst.js <command> [args]
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
Or with npm link during development:
|
|
19
19
|
|
|
20
20
|
```bash
|
|
21
21
|
npm link
|
|
22
|
-
|
|
22
|
+
anqst <command> [args]
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
## In-project contract
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
AnQst-generated artifacts are consolidated under one project-root directory:
|
|
28
|
+
|
|
29
|
+
- `./AnQst`
|
|
30
|
+
|
|
31
|
+
`package.json` stores a settings path string:
|
|
32
|
+
|
|
33
|
+
```json
|
|
34
|
+
{
|
|
35
|
+
"AnQst": "./AnQst/<WidgetName>.settings.json"
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Settings file (`./AnQst/<WidgetName>.settings.json`) owns project-local AnQst configuration:
|
|
40
|
+
|
|
41
|
+
```json
|
|
42
|
+
{
|
|
43
|
+
"layoutVersion": 2,
|
|
44
|
+
"widgetName": "<WidgetName>",
|
|
45
|
+
"spec": "./AnQst/<WidgetName>.AnQst.d.ts",
|
|
46
|
+
"generate": ["QWidget", "AngularService", "node_express_ws"],
|
|
47
|
+
"widgetCategory": "AnQst Widgets"
|
|
48
|
+
}
|
|
29
49
|
```
|
|
30
50
|
|
|
31
51
|
## CLI commands
|
|
32
52
|
|
|
33
53
|
- `anqst instill <WidgetName>`
|
|
34
|
-
-
|
|
35
|
-
-
|
|
36
|
-
|
|
37
|
-
-
|
|
38
|
-
- `
|
|
39
|
-
- `
|
|
40
|
-
-
|
|
41
|
-
|
|
42
|
-
|
|
54
|
+
- Initializes `./AnQst`.
|
|
55
|
+
- Creates:
|
|
56
|
+
- `./AnQst/<WidgetName>.AnQst.d.ts`
|
|
57
|
+
- `./AnQst/<WidgetName>.settings.json`
|
|
58
|
+
- `./AnQst/.gitignore`
|
|
59
|
+
- `./AnQst/README.md`
|
|
60
|
+
- Updates `package.json`:
|
|
61
|
+
- `AnQst` string path to settings file.
|
|
62
|
+
- build hooks: `postinstall`, `prebuild`, `prestart` (all run `npx anqst build`).
|
|
63
|
+
- Updates `tsconfig.json` (when present):
|
|
64
|
+
- `compilerOptions.paths["anqst-generated/*"] = ["AnQst/generated/frontend/<WidgetName>_Angular/*"]`
|
|
43
65
|
|
|
44
66
|
- `anqst test`
|
|
45
|
-
-
|
|
67
|
+
- Loads settings from `package.json.AnQst`.
|
|
46
68
|
- Verifies the configured spec.
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
-
|
|
51
|
-
-
|
|
52
|
-
-
|
|
53
|
-
|
|
54
|
-
-
|
|
55
|
-
-
|
|
56
|
-
|
|
57
|
-
-
|
|
58
|
-
-
|
|
59
|
-
-
|
|
60
|
-
- On success, CMake build output remains in `anqst-cmake/build-designerplugin`.
|
|
61
|
-
- On success, build summary also prints the plugin binary path, a Qt install-path copy hint (`qmake -query QT_INSTALL_PLUGINS` then copy into `<QT_INSTALL_PLUGINS>/designer`), and a user-local install example (`$HOME/.local/lib/qt5/plugins/designer`).
|
|
62
|
-
- Plugin icon generation (if favicon exists):
|
|
63
|
-
- Search order: `dist/**/favicon.ico` first, then `res/favicon.ico`, `src/favicon.ico`, `favicon.ico`.
|
|
64
|
-
- `favicon.ico` is converted to PNG for Designer plugin resources and wired as the widget icon.
|
|
65
|
-
- Plugin build invokes `cmake` from PATH and forces `Release` configuration.
|
|
66
|
-
- If plugin CMake configure/build fails, `anqst build` fails.
|
|
67
|
-
- Reads `package.json.AnQst.spec`.
|
|
68
|
-
- Reads optional `package.json.AnQst.generate` string array to select emitted outputs:
|
|
69
|
-
- `"QWidget"` enables Qt/C++ emission and embedding flow.
|
|
70
|
-
- `"AngularService"` enables TypeScript service package emission/install.
|
|
71
|
-
- `"node_express_ws"` enables Node/Express backend bridge package emission.
|
|
72
|
-
- Empty list is valid and emits nothing.
|
|
73
|
-
- `//DOM` and `//node_express_ws` remain accepted placeholders and are ignored.
|
|
74
|
-
- Verifies and generates outputs.
|
|
75
|
-
- Writes raw outputs to `<cwd>/generated_output`:
|
|
76
|
-
- TypeScript package sources under `generated_output/npmpackage`
|
|
77
|
-
- C++ widget library sources plus CMake environment under `generated_output/<WidgetName>_QtWidget`
|
|
78
|
-
- Node/Express backend package sources under `generated_output/<WidgetName>_node_express_ws`
|
|
79
|
-
- When `"AngularService"` is enabled:
|
|
80
|
-
- Replaces installed TypeScript artifacts in `<cwd>/src/anqst-generated`.
|
|
81
|
-
- When `"QWidget"` is enabled:
|
|
82
|
-
- Writes Qt integration glue to `<cwd>/anqst-cmake/CMakeLists.txt` so Qt consumers can `add_subdirectory(...)` and link `<WidgetName>Widget`.
|
|
83
|
-
- If an Angular project is detected (`angular.json` exists), runs a production `ng build`.
|
|
84
|
-
- Embeds the built web bundle into the generated widget library under `generated_output/<WidgetName>_QtWidget/webapp/*`.
|
|
85
|
-
- `--backend tsc` uses TypeScript compiler APIs and currently emits a subset: `QWidget` and `node_express_ws`.
|
|
86
|
-
- `AngularService` emission is not implemented for `tsc` backend yet.
|
|
69
|
+
|
|
70
|
+
- `anqst build [--designerplugin[=true|false]]`
|
|
71
|
+
- Loads settings from `package.json.AnQst`.
|
|
72
|
+
- Verifies spec and regenerates selected targets.
|
|
73
|
+
- Writes only under `./AnQst/generated`.
|
|
74
|
+
- Removes selected target roots before regeneration (no stale generated files).
|
|
75
|
+
- If `QWidget` is enabled and `angular.json` exists:
|
|
76
|
+
- runs production Angular build
|
|
77
|
+
- embeds built web assets into generated Qt widget `webapp/`.
|
|
78
|
+
- If `--designerplugin` is enabled:
|
|
79
|
+
- requires `ANQST_WEBBASE_DIR`
|
|
80
|
+
- emits plugin sources in `./AnQst/generated/backend/cpp/qt/<WidgetName>_widget/designerPlugin`
|
|
81
|
+
- runs CMake configure/build in plugin `build/` subdir.
|
|
87
82
|
|
|
88
83
|
- `anqst generate <specFile>`
|
|
89
|
-
-
|
|
90
|
-
-
|
|
91
|
-
- Also applies `package.json.AnQst.generate` when `package.json` is present and contains `AnQst`.
|
|
92
|
-
- If `"AngularService"` is enabled, installs into `src/anqst-generated`.
|
|
93
|
-
- If `"QWidget"` is enabled, writes `anqst-cmake/CMakeLists.txt`.
|
|
94
|
-
- If `"node_express_ws"` is enabled, emits `generated_output/<WidgetName>_node_express_ws`.
|
|
95
|
-
- If no package config is present, defaults to emitting both QWidget and AngularService outputs.
|
|
96
|
-
- Writes to `<cwd>/generated_output`.
|
|
97
|
-
- `--backend tsc` uses TypeScript compiler APIs and currently emits a subset: `QWidget` and `node_express_ws`.
|
|
98
|
-
- `AngularService` emission is not implemented for `tsc` backend yet.
|
|
84
|
+
- Verifies explicit spec and emits selected outputs.
|
|
85
|
+
- Uses package settings targets when package `AnQst` key exists, else default targets.
|
|
99
86
|
|
|
100
87
|
- `anqst verify <specFile>`
|
|
101
|
-
-
|
|
102
|
-
- Verifies a spec file without generating artifacts.
|
|
103
|
-
- `--backend tsc` performs checker-backed validation using TypeScript compiler diagnostics.
|
|
88
|
+
- Verifies explicit spec only.
|
|
104
89
|
|
|
105
90
|
- `anqst clean <path> [-f|--force]`
|
|
106
|
-
-
|
|
107
|
-
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
91
|
+
- Without `--force`: resolves settings under `<path>` and removes widget-scoped generated roots.
|
|
92
|
+
- With `--force`: removes `<path>/AnQst/generated`.
|
|
93
|
+
- Prints grouped cleanup summary (`Deleted`, `Not found`, `Failed`).
|
|
94
|
+
|
|
95
|
+
## Generated structure
|
|
96
|
+
|
|
97
|
+
```text
|
|
98
|
+
<project-root>/
|
|
99
|
+
AnQst/
|
|
100
|
+
<WidgetName>.AnQst.d.ts
|
|
101
|
+
<WidgetName>.settings.json
|
|
102
|
+
.gitignore
|
|
103
|
+
README.md
|
|
104
|
+
generated/
|
|
105
|
+
frontend/
|
|
106
|
+
<WidgetName>_Angular/
|
|
107
|
+
backend/
|
|
108
|
+
node/
|
|
109
|
+
express/
|
|
110
|
+
<WidgetName>_anQst/
|
|
111
|
+
cpp/
|
|
112
|
+
cmake/
|
|
113
|
+
CMakeLists.txt
|
|
114
|
+
qt/
|
|
115
|
+
<WidgetName>_widget/
|
|
116
|
+
CMakeLists.txt
|
|
117
|
+
<WidgetName>.qrc
|
|
118
|
+
<WidgetName>.cpp
|
|
119
|
+
include/
|
|
120
|
+
webapp/
|
|
121
|
+
designerPlugin/
|
|
122
|
+
CMakeLists.txt
|
|
123
|
+
<WidgetName>DesignerPlugin.cpp
|
|
124
|
+
designerplugin.qrc
|
|
125
|
+
plugin-icon.png
|
|
126
|
+
build/
|
|
127
|
+
<WidgetName>DesignerPlugin.(so|dylib|dll)
|
|
128
|
+
debug/
|
|
129
|
+
intermediate/
|
|
130
|
+
```
|
|
114
131
|
|
|
115
|
-
## Typical
|
|
132
|
+
## Typical workflow
|
|
116
133
|
|
|
117
134
|
```bash
|
|
118
|
-
# 1) in your widget project
|
|
119
135
|
npx @dusted/anqst instill BurgerConstructor
|
|
120
136
|
|
|
121
|
-
#
|
|
122
|
-
code BurgerConstructor.AnQst.d.ts
|
|
137
|
+
# edit spec
|
|
138
|
+
code AnQst/BurgerConstructor.AnQst.d.ts
|
|
123
139
|
|
|
124
|
-
# 3) validate spec
|
|
125
140
|
npx @dusted/anqst test
|
|
126
|
-
|
|
127
|
-
# 4) generate and install artifacts
|
|
128
141
|
npx @dusted/anqst build
|
|
129
|
-
|
|
130
|
-
# or via npm scripts enriched by instill
|
|
131
|
-
npm run test
|
|
132
|
-
npm run build
|
|
133
142
|
```
|
|
134
|
-
|
|
135
|
-
## Generated output structure
|
|
136
|
-
|
|
137
|
-
When generation succeeds:
|
|
138
|
-
|
|
139
|
-
- `generated_output/npmpackage/package.json`
|
|
140
|
-
- `generated_output/npmpackage/index.ts`
|
|
141
|
-
- `generated_output/npmpackage/services.ts`
|
|
142
|
-
- `generated_output/npmpackage/types.ts`
|
|
143
|
-
- `generated_output/npmpackage/index.js`
|
|
144
|
-
- `generated_output/npmpackage/services.js`
|
|
145
|
-
- `generated_output/npmpackage/types.js`
|
|
146
|
-
- `generated_output/npmpackage/types/index.d.ts`
|
|
147
|
-
- `generated_output/npmpackage/types/services.d.ts`
|
|
148
|
-
- `generated_output/npmpackage/types/types.d.ts`
|
|
149
|
-
- `generated_output/<WidgetName>_QtWidget/CMakeLists.txt`
|
|
150
|
-
- `generated_output/<WidgetName>_QtWidget/<WidgetName>.qrc`
|
|
151
|
-
- `generated_output/<WidgetName>_QtWidget/include/<WidgetName>.h`
|
|
152
|
-
- `generated_output/<WidgetName>_QtWidget/include/<WidgetName>Types.h`
|
|
153
|
-
- `generated_output/<WidgetName>_QtWidget/<WidgetName>.cpp`
|
|
154
|
-
- `generated_output/<WidgetName>_QtWidget/webapp/*` (embedded Angular build artifacts)
|
|
155
|
-
- Generated CMake links the widget library target (`<WidgetName>Widget`) against `anqstwebhostbase`.
|
|
156
|
-
- `anqst-cmake/CMakeLists.txt` (consumer-facing CMake entrypoint that triggers on-demand Angular/anqst build)
|
|
157
|
-
|
|
158
|
-
And after `anqst build`:
|
|
159
|
-
|
|
160
|
-
- `src/anqst-generated/*` (installed TypeScript artifacts, replaced on each build)
|