@dusted/anqst 1.0.0 → 1.0.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/dist/src/app.js +102 -77
- package/dist/src/build-stamp.js +1 -1
- package/dist/src/emit.js +8 -2
- package/package.json +2 -3
- package/spec/AnQst-Spec-DSL.d.ts +3 -2
package/dist/src/app.js
CHANGED
|
@@ -19,7 +19,7 @@ const project_1 = require("./project");
|
|
|
19
19
|
const layout_1 = require("./layout");
|
|
20
20
|
const parser_1 = require("./parser");
|
|
21
21
|
const verify_1 = require("./verify");
|
|
22
|
-
const
|
|
22
|
+
const ANQSTGEN_ACTIVE_STAMP_FILE = ".anqstgen-version-active.json";
|
|
23
23
|
function renderHelp() {
|
|
24
24
|
const version = readActiveBuildStamp();
|
|
25
25
|
return [
|
|
@@ -135,8 +135,27 @@ function runTest(cwd) {
|
|
|
135
135
|
message: verification.message
|
|
136
136
|
};
|
|
137
137
|
}
|
|
138
|
+
function resolveAnQstGenRoot() {
|
|
139
|
+
return node_path_1.default.resolve(__dirname, "..", "..");
|
|
140
|
+
}
|
|
138
141
|
function readActiveBuildStamp() {
|
|
139
|
-
|
|
142
|
+
if (process.env.ANQST_BUILD_STAMP && process.env.ANQST_BUILD_STAMP.trim().length > 0) {
|
|
143
|
+
return process.env.ANQST_BUILD_STAMP.trim();
|
|
144
|
+
}
|
|
145
|
+
const activePath = node_path_1.default.join(resolveAnQstGenRoot(), ANQSTGEN_ACTIVE_STAMP_FILE);
|
|
146
|
+
if (!node_fs_1.default.existsSync(activePath)) {
|
|
147
|
+
return "unknown_build_0";
|
|
148
|
+
}
|
|
149
|
+
try {
|
|
150
|
+
const parsed = JSON.parse(node_fs_1.default.readFileSync(activePath, "utf8"));
|
|
151
|
+
if (typeof parsed.active === "string" && parsed.active.trim().length > 0) {
|
|
152
|
+
return parsed.active.trim();
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
catch {
|
|
156
|
+
// Fallback to deterministic unknown stamp.
|
|
157
|
+
}
|
|
158
|
+
return "unknown_build_0";
|
|
140
159
|
}
|
|
141
160
|
function runDesignerPluginBuild(cwd, widgetName) {
|
|
142
161
|
const layout = (0, layout_1.resolveGeneratedLayoutPaths)(cwd, widgetName);
|
|
@@ -176,94 +195,100 @@ function runDesignerPluginBuild(cwd, widgetName) {
|
|
|
176
195
|
}
|
|
177
196
|
function runBuild(cwd, designerPlugin = false) {
|
|
178
197
|
const buildVersion = readActiveBuildStamp();
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
const outputs = (0, emit_1.generateOutputs)(parsed, generationTargets);
|
|
189
|
-
(0, emit_1.writeGeneratedOutputs)(cwd, outputs);
|
|
190
|
-
if (generationTargets.emitQWidget) {
|
|
191
|
-
(0, emit_1.installQtIntegrationCMake)(cwd, parsed.widgetName);
|
|
192
|
-
}
|
|
193
|
-
const hasAngularProject = generationTargets.emitQWidget && node_fs_1.default.existsSync(node_path_1.default.join(cwd, "angular.json"));
|
|
194
|
-
if (hasAngularProject) {
|
|
195
|
-
const angularBuild = (0, node_child_process_1.spawnSync)("npx", ["ng", "build", "--configuration", "production"], {
|
|
196
|
-
cwd,
|
|
197
|
-
stdio: "inherit",
|
|
198
|
-
shell: process.platform === "win32"
|
|
199
|
-
});
|
|
200
|
-
if (angularBuild.status !== 0) {
|
|
201
|
-
throw new errors_1.VerifyError("Angular build failed while preparing embedded widget assets.");
|
|
198
|
+
process.env.ANQST_BUILD_STAMP = buildVersion;
|
|
199
|
+
try {
|
|
200
|
+
const specPath = (0, project_1.resolveAnQstSpecPath)(cwd);
|
|
201
|
+
const configuredWidgetName = (0, project_1.resolveAnQstWidgetName)(cwd);
|
|
202
|
+
const generationTargets = resolveGenerationTargetsFromCwd(cwd, true);
|
|
203
|
+
const parsed = (0, parser_1.parseSpecFile)(specPath);
|
|
204
|
+
(0, verify_1.verifySpec)(parsed);
|
|
205
|
+
if (parsed.widgetName !== configuredWidgetName) {
|
|
206
|
+
throw new errors_1.VerifyError(`Settings widgetName '${configuredWidgetName}' does not match spec namespace '${parsed.widgetName}'.`);
|
|
202
207
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
if (
|
|
207
|
-
|
|
208
|
+
resetGeneratedTargets(cwd, parsed.widgetName, generationTargets);
|
|
209
|
+
const outputs = (0, emit_1.generateOutputs)(parsed, generationTargets);
|
|
210
|
+
(0, emit_1.writeGeneratedOutputs)(cwd, outputs);
|
|
211
|
+
if (generationTargets.emitQWidget) {
|
|
212
|
+
(0, emit_1.installQtIntegrationCMake)(cwd, parsed.widgetName);
|
|
208
213
|
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
+
const hasAngularProject = generationTargets.emitQWidget && node_fs_1.default.existsSync(node_path_1.default.join(cwd, "angular.json"));
|
|
215
|
+
if (hasAngularProject) {
|
|
216
|
+
const angularBuild = (0, node_child_process_1.spawnSync)("npx", ["ng", "build", "--configuration", "production"], {
|
|
217
|
+
cwd,
|
|
218
|
+
stdio: "inherit",
|
|
219
|
+
shell: process.platform === "win32"
|
|
220
|
+
});
|
|
221
|
+
if (angularBuild.status !== 0) {
|
|
222
|
+
throw new errors_1.VerifyError("Angular build failed while preparing embedded widget assets.");
|
|
223
|
+
}
|
|
214
224
|
}
|
|
215
|
-
|
|
216
|
-
const
|
|
217
|
-
(
|
|
218
|
-
|
|
219
|
-
|
|
225
|
+
if (generationTargets.emitQWidget) {
|
|
226
|
+
const embedded = (0, emit_1.installEmbeddedWebBundle)(cwd, parsed.widgetName);
|
|
227
|
+
if (hasAngularProject && !embedded) {
|
|
228
|
+
throw new errors_1.VerifyError("Unable to embed Angular output. Ensure ng build produced a dist bundle with index.html.");
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
let designerPluginBuilt = false;
|
|
232
|
+
if (designerPlugin) {
|
|
233
|
+
if (!generationTargets.emitQWidget) {
|
|
234
|
+
console.warn("[AnQst] --designerplugin requested but QWidget target is not enabled. Skipping designer plugin build.");
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
const widgetCategory = (0, project_1.resolveAnQstWidgetCategory)(cwd);
|
|
238
|
+
(0, emit_1.installQtDesignerPluginCMake)(cwd, parsed.widgetName, { widgetCategory });
|
|
239
|
+
runDesignerPluginBuild(cwd, parsed.widgetName);
|
|
240
|
+
designerPluginBuilt = true;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
if (!generationTargets.emitAngularService && !generationTargets.emitQWidget && !generationTargets.emitNodeExpressWs) {
|
|
244
|
+
return {
|
|
245
|
+
success: true,
|
|
246
|
+
message: [
|
|
247
|
+
"Build completed.",
|
|
248
|
+
` anqst version ${buildVersion}`,
|
|
249
|
+
" No outputs selected by AnQst.generate."
|
|
250
|
+
].join("\n")
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
const layout = (0, layout_1.resolveGeneratedLayoutPaths)(cwd, parsed.widgetName);
|
|
254
|
+
const detailLines = [];
|
|
255
|
+
if (generationTargets.emitAngularService) {
|
|
256
|
+
detailLines.push(" Target AngularService:");
|
|
257
|
+
detailLines.push(` - Services output: ${(0, layout_1.toProjectRelative)(cwd, node_path_1.default.join(layout.frontendRoot, "services"))}`);
|
|
258
|
+
detailLines.push(` - Types output: ${(0, layout_1.toProjectRelative)(cwd, node_path_1.default.join(layout.frontendRoot, "types"))}`);
|
|
259
|
+
}
|
|
260
|
+
if (generationTargets.emitQWidget) {
|
|
261
|
+
detailLines.push(" Target QWidget:");
|
|
262
|
+
detailLines.push(` - Qt integration CMake: ${(0, layout_1.toProjectRelative)(cwd, node_path_1.default.join(layout.cppCmakeRoot, "CMakeLists.txt"))}`);
|
|
263
|
+
detailLines.push(` - Widget output root: ${(0, layout_1.toProjectRelative)(cwd, layout.cppQtWidgetRoot)}`);
|
|
264
|
+
detailLines.push(" - Embedded web assets refreshed from Angular build");
|
|
265
|
+
}
|
|
266
|
+
if (generationTargets.emitNodeExpressWs) {
|
|
267
|
+
detailLines.push(" Target node_express_ws:");
|
|
268
|
+
detailLines.push(` - Module output root: ${(0, layout_1.toProjectRelative)(cwd, layout.nodeExpressRoot)}`);
|
|
269
|
+
}
|
|
270
|
+
if (designerPluginBuilt) {
|
|
271
|
+
const pluginBinaryPath = (0, layout_1.normalizeSlashes)(node_path_1.default.join((0, layout_1.toProjectRelative)(cwd, layout.designerPluginBuildRoot), designerPluginBinaryName(parsed.widgetName)));
|
|
272
|
+
detailLines.push(" Target QtDesignerPlugin:");
|
|
273
|
+
detailLines.push(` - Build output: ${(0, layout_1.toProjectRelative)(cwd, layout.designerPluginBuildRoot)}`);
|
|
274
|
+
detailLines.push(` - Plugin binary: ${pluginBinaryPath}`);
|
|
275
|
+
detailLines.push(" - Install target dir: <QT_INSTALL_PLUGINS>/designer");
|
|
276
|
+
detailLines.push(" - Discover QT_INSTALL_PLUGINS: qmake -query QT_INSTALL_PLUGINS");
|
|
277
|
+
detailLines.push(` - Example install: cp ${pluginBinaryPath} \"$(qmake -query QT_INSTALL_PLUGINS)/designer/\"`);
|
|
278
|
+
detailLines.push(` - User-local install: mkdir -p \"$HOME/.local/lib/qt5/plugins/designer\" && cp ${pluginBinaryPath} \"$HOME/.local/lib/qt5/plugins/designer/\"`);
|
|
220
279
|
}
|
|
221
|
-
}
|
|
222
|
-
if (!generationTargets.emitAngularService && !generationTargets.emitQWidget && !generationTargets.emitNodeExpressWs) {
|
|
223
280
|
return {
|
|
224
281
|
success: true,
|
|
225
282
|
message: [
|
|
226
283
|
"Build completed.",
|
|
227
284
|
` anqst version ${buildVersion}`,
|
|
228
|
-
|
|
285
|
+
...detailLines
|
|
229
286
|
].join("\n")
|
|
230
287
|
};
|
|
231
288
|
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
if (generationTargets.emitAngularService) {
|
|
235
|
-
detailLines.push(" Target AngularService:");
|
|
236
|
-
detailLines.push(` - Services output: ${(0, layout_1.toProjectRelative)(cwd, node_path_1.default.join(layout.frontendRoot, "services"))}`);
|
|
237
|
-
detailLines.push(` - Types output: ${(0, layout_1.toProjectRelative)(cwd, node_path_1.default.join(layout.frontendRoot, "types"))}`);
|
|
238
|
-
}
|
|
239
|
-
if (generationTargets.emitQWidget) {
|
|
240
|
-
detailLines.push(" Target QWidget:");
|
|
241
|
-
detailLines.push(` - Qt integration CMake: ${(0, layout_1.toProjectRelative)(cwd, node_path_1.default.join(layout.cppCmakeRoot, "CMakeLists.txt"))}`);
|
|
242
|
-
detailLines.push(` - Widget output root: ${(0, layout_1.toProjectRelative)(cwd, layout.cppQtWidgetRoot)}`);
|
|
243
|
-
detailLines.push(" - Embedded web assets refreshed from Angular build");
|
|
244
|
-
}
|
|
245
|
-
if (generationTargets.emitNodeExpressWs) {
|
|
246
|
-
detailLines.push(" Target node_express_ws:");
|
|
247
|
-
detailLines.push(` - Module output root: ${(0, layout_1.toProjectRelative)(cwd, layout.nodeExpressRoot)}`);
|
|
248
|
-
}
|
|
249
|
-
if (designerPluginBuilt) {
|
|
250
|
-
const pluginBinaryPath = (0, layout_1.normalizeSlashes)(node_path_1.default.join((0, layout_1.toProjectRelative)(cwd, layout.designerPluginBuildRoot), designerPluginBinaryName(parsed.widgetName)));
|
|
251
|
-
detailLines.push(" Target QtDesignerPlugin:");
|
|
252
|
-
detailLines.push(` - Build output: ${(0, layout_1.toProjectRelative)(cwd, layout.designerPluginBuildRoot)}`);
|
|
253
|
-
detailLines.push(` - Plugin binary: ${pluginBinaryPath}`);
|
|
254
|
-
detailLines.push(" - Install target dir: <QT_INSTALL_PLUGINS>/designer");
|
|
255
|
-
detailLines.push(" - Discover QT_INSTALL_PLUGINS: qmake -query QT_INSTALL_PLUGINS");
|
|
256
|
-
detailLines.push(` - Example install: cp ${pluginBinaryPath} \"$(qmake -query QT_INSTALL_PLUGINS)/designer/\"`);
|
|
257
|
-
detailLines.push(` - User-local install: mkdir -p \"$HOME/.local/lib/qt5/plugins/designer\" && cp ${pluginBinaryPath} \"$HOME/.local/lib/qt5/plugins/designer/\"`);
|
|
289
|
+
finally {
|
|
290
|
+
delete process.env.ANQST_BUILD_STAMP;
|
|
258
291
|
}
|
|
259
|
-
return {
|
|
260
|
-
success: true,
|
|
261
|
-
message: [
|
|
262
|
-
"Build completed.",
|
|
263
|
-
` anqst version ${buildVersion}`,
|
|
264
|
-
...detailLines
|
|
265
|
-
].join("\n")
|
|
266
|
-
};
|
|
267
292
|
}
|
|
268
293
|
function parseSpecCommandArg(commandName, specArg, extraArgs) {
|
|
269
294
|
const allArgs = [specArg, ...extraArgs].filter((arg) => typeof arg === "string" && arg.length > 0);
|
package/dist/src/build-stamp.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ANQST_BUILD_STAMP = void 0;
|
|
4
4
|
// Generated by scripts/build-with-stamp.js. Do not edit by hand.
|
|
5
|
-
exports.ANQST_BUILD_STAMP = "
|
|
5
|
+
exports.ANQST_BUILD_STAMP = "unknown/unknown_build_0/1970-01-01";
|
package/dist/src/emit.js
CHANGED
|
@@ -1080,7 +1080,13 @@ function renderCppStub(spec, cppTypes) {
|
|
|
1080
1080
|
lines.push(` }`);
|
|
1081
1081
|
}
|
|
1082
1082
|
}
|
|
1083
|
-
lines.push(` return
|
|
1083
|
+
lines.push(` return QVariantMap{`);
|
|
1084
|
+
lines.push(` {QStringLiteral("code"), QStringLiteral("HandlerNotRegisteredError")},`);
|
|
1085
|
+
lines.push(` {QStringLiteral("message"), QStringLiteral("No Call mapping found.")},`);
|
|
1086
|
+
lines.push(` {QStringLiteral("service"), service},`);
|
|
1087
|
+
lines.push(` {QStringLiteral("member"), member},`);
|
|
1088
|
+
lines.push(` {QStringLiteral("requestId"), QString()}`);
|
|
1089
|
+
lines.push(` };`);
|
|
1084
1090
|
lines.push(`}`);
|
|
1085
1091
|
lines.push("");
|
|
1086
1092
|
lines.push(`void ${widgetClassName}::handleGeneratedEmitter(const QString& service, const QString& member, const QVariantList& args) {`);
|
|
@@ -3273,7 +3279,7 @@ public:
|
|
|
3273
3279
|
" <widget class=\\"${widgetClass}\\" name=\\"${widgetName.toLowerCase()}\\">\\n"
|
|
3274
3280
|
" <property name=\\"minimumSize\\">\\n"
|
|
3275
3281
|
" <size>\\n"
|
|
3276
|
-
" <width>
|
|
3282
|
+
" <width>0</width>\\n"
|
|
3277
3283
|
" <height>128</height>\\n"
|
|
3278
3284
|
" </size>\\n"
|
|
3279
3285
|
" </property>\\n"
|
package/package.json
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dusted/anqst",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Opinionated backend generator for webapps.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"nodejs",
|
|
7
7
|
"qt",
|
|
8
8
|
"angular",
|
|
9
|
-
"webapp"
|
|
10
|
-
"apigenerator"
|
|
9
|
+
"webapp"
|
|
11
10
|
],
|
|
12
11
|
"homepage": "https://github.com/DusteDdk/AnQst#readme",
|
|
13
12
|
"bugs": {
|
package/spec/AnQst-Spec-DSL.d.ts
CHANGED
|
@@ -18,12 +18,12 @@ export namespace AnQst {
|
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* Declare service `InterfaceName`
|
|
21
|
-
*
|
|
21
|
+
*
|
|
22
22
|
* @remarks
|
|
23
23
|
* Multiple allowed.
|
|
24
24
|
* Affords developers of advanced widgets the ability to create domain-informed categories.
|
|
25
25
|
* - Duplicate method declarations with identical parameter lists are invalid in normative AnQst-Spec input.
|
|
26
|
-
*
|
|
26
|
+
*
|
|
27
27
|
* @example
|
|
28
28
|
* export interface UserService extends Widget.Service { }
|
|
29
29
|
* // Generates UserService.
|
|
@@ -83,6 +83,7 @@ export namespace AnQst {
|
|
|
83
83
|
* - throw -> failure
|
|
84
84
|
* - rejected promise -> failure
|
|
85
85
|
* - Parent: `MethodName` call returns with result.
|
|
86
|
+
* - Generated C++ Slot methods do not expose `ok/error` out parameters.
|
|
86
87
|
* - Default Slot timeout is 1000ms.
|
|
87
88
|
* Note: One active handler, calling will replace existing and is valid and allowed.
|
|
88
89
|
* @example
|