@dusted/anqst 0.1.0 → 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/README.md CHANGED
@@ -1,136 +1,160 @@
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
-
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
25
  Run via npx (preferred package workflow):
26
26
 
27
27
  ```bash
28
28
  npx @dusted/anqst <command> [args]
29
29
  ```
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
-
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
+ - New scaffolds import `AnQst` from the npm package (`import { AnQst } from "anqst";`).
42
+ - If `<WidgetName>.AnQst.d.ts` already exists, instill preserves template content and only normalizes the `AnQst` import.
43
+
44
+ - `anqst test`
45
+ - Reads `package.json.AnQst.spec`.
46
+ - Verifies the configured spec.
47
+ - On first error: prints readable error and exits `1`.
48
+ - On success: prints summary and exits `0`.
49
+
50
+ - `anqst build`
51
+ - Optional backend selection: `--backend <id>` where `<id>` is `ast` (default) or `tsc`.
52
+ - Optional designer plugin build flag (build command only):
53
+ - Accepted enable forms: `--designerplugin`, `--designerplugin=true`, `--designerplugin true`.
54
+ - Any value other than `true` is treated as false.
55
+ - Plugin build runs only when backend is `tsc` and `QWidget` generation is enabled.
56
+ - If enabled but backend is not `tsc`, build prints a warning and skips plugin build.
57
+ - If enabled but `QWidget` is not selected, build prints a warning and skips plugin build.
58
+ - Requires `ANQST_WEBBASE_DIR` environment variable; `anqst build` forwards it to CMake as `-DANQST_WEBBASE_DIR=...`.
59
+ - Optional package config: `AnQst.widgetCategory` (string). If present, Qt Designer shows the widget under that category instead of `AnQst Widgets`.
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.
87
+
88
+ - `anqst generate <specFile>`
89
+ - Optional backend selection: `--backend <id>` where `<id>` is `ast` (default) or `tsc`.
90
+ - Verifies the provided spec file and generates raw output.
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.
99
+
100
+ - `anqst verify <specFile>`
101
+ - Optional backend selection: `--backend <id>` where `<id>` is `ast` (default) or `tsc`.
102
+ - Verifies a spec file without generating artifacts.
103
+ - `--backend tsc` performs checker-backed validation using TypeScript compiler diagnostics.
104
+
105
+ - `anqst clean <path> [-f|--force]`
106
+ - `<path>` may be absolute or relative to current working directory.
107
+ - Without `--force`:
108
+ - requires `<path>/package.json` with `AnQst.spec`
109
+ - removes only widget-scoped generated folders for the referenced widget.
110
+ - With `--force`:
111
+ - removes broad generated folders under `<path>` regardless of package metadata.
112
+ - Reports grouped cleanup results: `Deleted`, `Not found`, `Failed`.
113
+ - Groups with zero entries are omitted from the output.
114
+
115
+ ## Typical usage flow (Angular widget project)
116
+
93
117
  ```bash
94
118
  # 1) in your widget project
95
119
  npx @dusted/anqst instill BurgerConstructor
96
-
97
- # 2) edit generated spec scaffold
98
- code BurgerConstructor.AnQst.d.ts
99
-
120
+
121
+ # 2) edit generated spec scaffold
122
+ code BurgerConstructor.AnQst.d.ts
123
+
100
124
  # 3) validate spec
101
125
  npx @dusted/anqst test
102
126
 
103
127
  # 4) generate and install artifacts
104
128
  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)
129
+
130
+ # or via npm scripts enriched by instill
131
+ npm run test
132
+ npm run build
133
+ ```
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)