@dusted/anqst 0.1.2 → 1.0.0

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 CHANGED
@@ -19,9 +19,12 @@ 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 ANQSTGEN_ACTIVE_STAMP_FILE = ".anqstgen-version-active.json";
22
+ const build_stamp_1 = require("./build-stamp");
23
23
  function renderHelp() {
24
+ const version = readActiveBuildStamp();
24
25
  return [
26
+ `anqst version ${version}`,
27
+ "",
25
28
  "Usage:",
26
29
  " anqst <command> [arguments] [options]",
27
30
  "",
@@ -35,7 +38,8 @@ function renderHelp() {
35
38
  "",
36
39
  "Options:",
37
40
  " --designerplugin Build Qt Designer plugin (build command only, QWidget target required)",
38
- " -h, --help Show this help output"
41
+ " -h, --help Show this help output",
42
+ " -v, --version Print CLI version"
39
43
  ].join("\n");
40
44
  }
41
45
  function usageFor(command) {
@@ -131,27 +135,8 @@ function runTest(cwd) {
131
135
  message: verification.message
132
136
  };
133
137
  }
134
- function resolveAnQstGenRoot() {
135
- return node_path_1.default.resolve(__dirname, "..", "..");
136
- }
137
138
  function readActiveBuildStamp() {
138
- if (process.env.ANQST_BUILD_STAMP && process.env.ANQST_BUILD_STAMP.trim().length > 0) {
139
- return process.env.ANQST_BUILD_STAMP.trim();
140
- }
141
- const activePath = node_path_1.default.join(resolveAnQstGenRoot(), ANQSTGEN_ACTIVE_STAMP_FILE);
142
- if (!node_fs_1.default.existsSync(activePath)) {
143
- return "unknown_build_0";
144
- }
145
- try {
146
- const parsed = JSON.parse(node_fs_1.default.readFileSync(activePath, "utf8"));
147
- if (typeof parsed.active === "string" && parsed.active.trim().length > 0) {
148
- return parsed.active.trim();
149
- }
150
- }
151
- catch {
152
- // Fallback to deterministic unknown stamp.
153
- }
154
- return "unknown_build_0";
139
+ return build_stamp_1.ANQST_BUILD_STAMP;
155
140
  }
156
141
  function runDesignerPluginBuild(cwd, widgetName) {
157
142
  const layout = (0, layout_1.resolveGeneratedLayoutPaths)(cwd, widgetName);
@@ -191,100 +176,94 @@ function runDesignerPluginBuild(cwd, widgetName) {
191
176
  }
192
177
  function runBuild(cwd, designerPlugin = false) {
193
178
  const buildVersion = readActiveBuildStamp();
194
- process.env.ANQST_BUILD_STAMP = buildVersion;
195
- try {
196
- const specPath = (0, project_1.resolveAnQstSpecPath)(cwd);
197
- const configuredWidgetName = (0, project_1.resolveAnQstWidgetName)(cwd);
198
- const generationTargets = resolveGenerationTargetsFromCwd(cwd, true);
199
- const parsed = (0, parser_1.parseSpecFile)(specPath);
200
- (0, verify_1.verifySpec)(parsed);
201
- if (parsed.widgetName !== configuredWidgetName) {
202
- throw new errors_1.VerifyError(`Settings widgetName '${configuredWidgetName}' does not match spec namespace '${parsed.widgetName}'.`);
203
- }
204
- resetGeneratedTargets(cwd, parsed.widgetName, generationTargets);
205
- const outputs = (0, emit_1.generateOutputs)(parsed, generationTargets);
206
- (0, emit_1.writeGeneratedOutputs)(cwd, outputs);
207
- if (generationTargets.emitQWidget) {
208
- (0, emit_1.installQtIntegrationCMake)(cwd, parsed.widgetName);
209
- }
210
- const hasAngularProject = generationTargets.emitQWidget && node_fs_1.default.existsSync(node_path_1.default.join(cwd, "angular.json"));
211
- if (hasAngularProject) {
212
- const angularBuild = (0, node_child_process_1.spawnSync)("npx", ["ng", "build", "--configuration", "production"], {
213
- cwd,
214
- stdio: "inherit",
215
- shell: process.platform === "win32"
216
- });
217
- if (angularBuild.status !== 0) {
218
- throw new errors_1.VerifyError("Angular build failed while preparing embedded widget assets.");
219
- }
220
- }
221
- if (generationTargets.emitQWidget) {
222
- const embedded = (0, emit_1.installEmbeddedWebBundle)(cwd, parsed.widgetName);
223
- if (hasAngularProject && !embedded) {
224
- throw new errors_1.VerifyError("Unable to embed Angular output. Ensure ng build produced a dist bundle with index.html.");
225
- }
226
- }
227
- let designerPluginBuilt = false;
228
- if (designerPlugin) {
229
- if (!generationTargets.emitQWidget) {
230
- console.warn("[AnQst] --designerplugin requested but QWidget target is not enabled. Skipping designer plugin build.");
231
- }
232
- else {
233
- const widgetCategory = (0, project_1.resolveAnQstWidgetCategory)(cwd);
234
- (0, emit_1.installQtDesignerPluginCMake)(cwd, parsed.widgetName, { widgetCategory });
235
- runDesignerPluginBuild(cwd, parsed.widgetName);
236
- designerPluginBuilt = true;
237
- }
238
- }
239
- if (!generationTargets.emitAngularService && !generationTargets.emitQWidget && !generationTargets.emitNodeExpressWs) {
240
- return {
241
- success: true,
242
- message: [
243
- "Build completed.",
244
- ` anqst version ${buildVersion}`,
245
- " No outputs selected by AnQst.generate."
246
- ].join("\n")
247
- };
248
- }
249
- const layout = (0, layout_1.resolveGeneratedLayoutPaths)(cwd, parsed.widgetName);
250
- const detailLines = [];
251
- if (generationTargets.emitAngularService) {
252
- detailLines.push(" Target AngularService:");
253
- detailLines.push(` - Services output: ${(0, layout_1.toProjectRelative)(cwd, node_path_1.default.join(layout.frontendRoot, "services"))}`);
254
- detailLines.push(` - Types output: ${(0, layout_1.toProjectRelative)(cwd, node_path_1.default.join(layout.frontendRoot, "types"))}`);
179
+ const specPath = (0, project_1.resolveAnQstSpecPath)(cwd);
180
+ const configuredWidgetName = (0, project_1.resolveAnQstWidgetName)(cwd);
181
+ const generationTargets = resolveGenerationTargetsFromCwd(cwd, true);
182
+ const parsed = (0, parser_1.parseSpecFile)(specPath);
183
+ (0, verify_1.verifySpec)(parsed);
184
+ if (parsed.widgetName !== configuredWidgetName) {
185
+ throw new errors_1.VerifyError(`Settings widgetName '${configuredWidgetName}' does not match spec namespace '${parsed.widgetName}'.`);
186
+ }
187
+ resetGeneratedTargets(cwd, parsed.widgetName, generationTargets);
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.");
255
202
  }
256
- if (generationTargets.emitQWidget) {
257
- detailLines.push(" Target QWidget:");
258
- detailLines.push(` - Qt integration CMake: ${(0, layout_1.toProjectRelative)(cwd, node_path_1.default.join(layout.cppCmakeRoot, "CMakeLists.txt"))}`);
259
- detailLines.push(` - Widget output root: ${(0, layout_1.toProjectRelative)(cwd, layout.cppQtWidgetRoot)}`);
260
- detailLines.push(" - Embedded web assets refreshed from Angular build");
203
+ }
204
+ if (generationTargets.emitQWidget) {
205
+ const embedded = (0, emit_1.installEmbeddedWebBundle)(cwd, parsed.widgetName);
206
+ if (hasAngularProject && !embedded) {
207
+ throw new errors_1.VerifyError("Unable to embed Angular output. Ensure ng build produced a dist bundle with index.html.");
261
208
  }
262
- if (generationTargets.emitNodeExpressWs) {
263
- detailLines.push(" Target node_express_ws:");
264
- detailLines.push(` - Module output root: ${(0, layout_1.toProjectRelative)(cwd, layout.nodeExpressRoot)}`);
209
+ }
210
+ let designerPluginBuilt = false;
211
+ if (designerPlugin) {
212
+ if (!generationTargets.emitQWidget) {
213
+ console.warn("[AnQst] --designerplugin requested but QWidget target is not enabled. Skipping designer plugin build.");
265
214
  }
266
- if (designerPluginBuilt) {
267
- const pluginBinaryPath = (0, layout_1.normalizeSlashes)(node_path_1.default.join((0, layout_1.toProjectRelative)(cwd, layout.designerPluginBuildRoot), designerPluginBinaryName(parsed.widgetName)));
268
- detailLines.push(" Target QtDesignerPlugin:");
269
- detailLines.push(` - Build output: ${(0, layout_1.toProjectRelative)(cwd, layout.designerPluginBuildRoot)}`);
270
- detailLines.push(` - Plugin binary: ${pluginBinaryPath}`);
271
- detailLines.push(" - Install target dir: <QT_INSTALL_PLUGINS>/designer");
272
- detailLines.push(" - Discover QT_INSTALL_PLUGINS: qmake -query QT_INSTALL_PLUGINS");
273
- detailLines.push(` - Example install: cp ${pluginBinaryPath} \"$(qmake -query QT_INSTALL_PLUGINS)/designer/\"`);
274
- detailLines.push(` - User-local install: mkdir -p \"$HOME/.local/lib/qt5/plugins/designer\" && cp ${pluginBinaryPath} \"$HOME/.local/lib/qt5/plugins/designer/\"`);
215
+ else {
216
+ const widgetCategory = (0, project_1.resolveAnQstWidgetCategory)(cwd);
217
+ (0, emit_1.installQtDesignerPluginCMake)(cwd, parsed.widgetName, { widgetCategory });
218
+ runDesignerPluginBuild(cwd, parsed.widgetName);
219
+ designerPluginBuilt = true;
275
220
  }
221
+ }
222
+ if (!generationTargets.emitAngularService && !generationTargets.emitQWidget && !generationTargets.emitNodeExpressWs) {
276
223
  return {
277
224
  success: true,
278
225
  message: [
279
226
  "Build completed.",
280
227
  ` anqst version ${buildVersion}`,
281
- ...detailLines
228
+ " No outputs selected by AnQst.generate."
282
229
  ].join("\n")
283
230
  };
284
231
  }
285
- finally {
286
- delete process.env.ANQST_BUILD_STAMP;
232
+ const layout = (0, layout_1.resolveGeneratedLayoutPaths)(cwd, parsed.widgetName);
233
+ const detailLines = [];
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/\"`);
287
258
  }
259
+ return {
260
+ success: true,
261
+ message: [
262
+ "Build completed.",
263
+ ` anqst version ${buildVersion}`,
264
+ ...detailLines
265
+ ].join("\n")
266
+ };
288
267
  }
289
268
  function parseSpecCommandArg(commandName, specArg, extraArgs) {
290
269
  const allArgs = [specArg, ...extraArgs].filter((arg) => typeof arg === "string" && arg.length > 0);
@@ -481,6 +460,10 @@ function runCommand(command, specArg, extraArgs = []) {
481
460
  console.log(renderHelp());
482
461
  return 0;
483
462
  }
463
+ if (command === "-v" || command === "--version" || command === "version") {
464
+ console.log(`anqst version ${readActiveBuildStamp()}`);
465
+ return 0;
466
+ }
484
467
  const normalizedCommand = command === "install" ? "instill" : command;
485
468
  if (command === "install") {
486
469
  console.log(renderInstallAliasMessage());
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ANQST_BUILD_STAMP = void 0;
4
+ // Generated by scripts/build-with-stamp.js. Do not edit by hand.
5
+ exports.ANQST_BUILD_STAMP = "1.0.0/7bd720a_dirty_build_1/2026-03-29";