@dusted/anqst 0.1.0 → 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 CHANGED
@@ -1,136 +1,142 @@
1
- # AnQstGen
2
-
3
- Isolated TypeScript implementation of the `anqst` generator CLI npm package.
4
-
5
- ## Build and run locally
6
-
7
- ```bash
8
- npm install
9
- npm run build
10
- ```
11
-
12
- Run directly from build output:
13
-
14
- ```bash
15
- node dist/src/bin/anqst.js <command> [args]
16
- ```
17
-
18
- Optional: expose the command in your shell while developing:
19
-
20
- ```bash
21
- npm link
22
- # now you can run: anqst <command> [args]
23
- ```
24
-
25
- Run via npx (preferred package workflow):
1
+ # AnQstGen
2
+
3
+ TypeScript implementation of the `anqst` CLI generator package.
4
+
5
+ ## Build locally
26
6
 
27
7
  ```bash
28
- npx @dusted/anqst <command> [args]
8
+ npm install
9
+ npm run build
29
10
  ```
30
-
31
- ## CLI commands
32
-
33
- - `anqst instill <WidgetName>`
34
- - Must be run in a directory containing `package.json`.
35
- - Fails if `package.json.AnQst` already exists.
36
- - Adds:
37
- - `"AnQst": { "spec": "<WidgetName>.AnQst.d.ts", "generate": ["QWidget", "AngularService", "//DOM", "//node_express_ws"] }`
38
- - `build` script prefix: `npx anqst build`
39
- - `test` script prefix: `npx anqst test`
40
- - Scaffolds `<WidgetName>.AnQst.d.ts` in project root.
41
- - Installs a project-local DSL definition at `anqst-dsl/AnQst-Spec-DSL.d.ts`.
42
-
43
- - `anqst test`
44
- - Reads `package.json.AnQst.spec`.
45
- - Verifies the configured spec.
46
- - On first error: prints readable error and exits `1`.
47
- - On success: prints summary and exits `0`.
48
-
49
- - `anqst build`
50
- - Reads `package.json.AnQst.spec`.
51
- - Reads optional `package.json.AnQst.generate` string array to select emitted outputs:
52
- - `"QWidget"` enables Qt/C++ emission and embedding flow.
53
- - `"AngularService"` enables TypeScript service package emission/install.
54
- - `"node_express_ws"` enables Node/Express backend bridge package emission.
55
- - Empty list is valid and emits nothing.
56
- - `//DOM` and `//node_express_ws` remain accepted placeholders and are ignored.
57
- - Verifies and generates outputs.
58
- - Writes raw outputs to `<cwd>/generated_output`:
59
- - TypeScript package sources under `generated_output/npmpackage`
60
- - C++ widget library sources plus CMake environment under `generated_output/<WidgetName>_QtWidget`
61
- - Node/Express backend package sources under `generated_output/<WidgetName>_node_express_ws`
62
- - When `"AngularService"` is enabled:
63
- - Replaces installed TypeScript artifacts in `<cwd>/src/anqst-generated`.
64
- - When `"QWidget"` is enabled:
65
- - Writes Qt integration glue to `<cwd>/anqst-cmake/CMakeLists.txt` so Qt consumers can `add_subdirectory(...)` and link `<WidgetName>Widget`.
66
- - If an Angular project is detected (`angular.json` exists), runs a production `ng build`.
67
- - Embeds the built web bundle into the generated widget library under `generated_output/<WidgetName>_QtWidget/webapp/*`.
68
-
69
- - `anqst generate <specFile>`
70
- - Verifies the provided spec file and generates raw output.
71
- - Also applies `package.json.AnQst.generate` when `package.json` is present and contains `AnQst`.
72
- - If `"AngularService"` is enabled, installs into `src/anqst-generated`.
73
- - If `"QWidget"` is enabled, writes `anqst-cmake/CMakeLists.txt`.
74
- - If `"node_express_ws"` is enabled, emits `generated_output/<WidgetName>_node_express_ws`.
75
- - If no package config is present, defaults to emitting both QWidget and AngularService outputs.
76
- - Writes to `<cwd>/generated_output`.
77
-
78
- - `anqst verify <specFile>`
79
- - Verifies a spec file without generating artifacts.
80
-
81
- - `anqst clean <path> [-f|--force]`
82
- - `<path>` may be absolute or relative to current working directory.
83
- - Without `--force`:
84
- - requires `<path>/package.json` with `AnQst.spec`
85
- - removes only widget-scoped generated folders for the referenced widget.
86
- - With `--force`:
87
- - removes broad generated folders under `<path>` regardless of package metadata.
88
- - Reports grouped cleanup results: `Deleted`, `Not found`, `Failed`.
89
- - Groups with zero entries are omitted from the output.
90
-
91
- ## Typical usage flow (Angular widget project)
92
-
11
+
12
+ Run from build output:
13
+
14
+ ```bash
15
+ node dist/src/bin/anqst.js <command> [args]
16
+ ```
17
+
18
+ Or with npm link during development:
19
+
20
+ ```bash
21
+ npm link
22
+ anqst <command> [args]
23
+ ```
24
+
25
+ ## In-project contract
26
+
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
+ }
49
+ ```
50
+
51
+ ## CLI commands
52
+
53
+ - `anqst instill <WidgetName>`
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/*"]`
65
+
66
+ - `anqst test`
67
+ - Loads settings from `package.json.AnQst`.
68
+ - Verifies the configured spec.
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.
82
+
83
+ - `anqst generate <specFile>`
84
+ - Verifies explicit spec and emits selected outputs.
85
+ - Uses package settings targets when package `AnQst` key exists, else default targets.
86
+
87
+ - `anqst verify <specFile>`
88
+ - Verifies explicit spec only.
89
+
90
+ - `anqst clean <path> [-f|--force]`
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
+ ```
131
+
132
+ ## Typical workflow
133
+
93
134
  ```bash
94
- # 1) in your widget project
95
135
  npx @dusted/anqst instill BurgerConstructor
96
-
97
- # 2) edit generated spec scaffold
98
- code BurgerConstructor.AnQst.d.ts
99
-
100
- # 3) validate spec
101
- npx @dusted/anqst test
102
136
 
103
- # 4) generate and install artifacts
137
+ # edit spec
138
+ code AnQst/BurgerConstructor.AnQst.d.ts
139
+
140
+ npx @dusted/anqst test
104
141
  npx @dusted/anqst build
105
-
106
- # or via npm scripts enriched by instill
107
- npm run test
108
- npm run build
109
- ```
110
-
111
- ## Generated output structure
112
-
113
- When generation succeeds:
114
-
115
- - `generated_output/npmpackage/package.json`
116
- - `generated_output/npmpackage/index.ts`
117
- - `generated_output/npmpackage/services.ts`
118
- - `generated_output/npmpackage/types.ts`
119
- - `generated_output/npmpackage/index.js`
120
- - `generated_output/npmpackage/services.js`
121
- - `generated_output/npmpackage/types.js`
122
- - `generated_output/npmpackage/types/index.d.ts`
123
- - `generated_output/npmpackage/types/services.d.ts`
124
- - `generated_output/npmpackage/types/types.d.ts`
125
- - `generated_output/<WidgetName>_QtWidget/CMakeLists.txt`
126
- - `generated_output/<WidgetName>_QtWidget/<WidgetName>.qrc`
127
- - `generated_output/<WidgetName>_QtWidget/include/<WidgetName>.h`
128
- - `generated_output/<WidgetName>_QtWidget/include/<WidgetName>Types.h`
129
- - `generated_output/<WidgetName>_QtWidget/<WidgetName>.cpp`
130
- - `generated_output/<WidgetName>_QtWidget/webapp/*` (embedded Angular build artifacts)
131
- - Generated CMake links the widget library target (`<WidgetName>Widget`) against `anqstwebhostbase`.
132
- - `anqst-cmake/CMakeLists.txt` (consumer-facing CMake entrypoint that triggers on-demand Angular/anqst build)
133
-
134
- And after `anqst build`:
135
-
136
- - `src/anqst-generated/*` (installed TypeScript artifacts, replaced on each build)
142
+ ```