@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/dist/src/app.js CHANGED
@@ -13,20 +13,13 @@ const node_path_1 = __importDefault(require("node:path"));
13
13
  const node_fs_1 = __importDefault(require("node:fs"));
14
14
  const node_child_process_1 = require("node:child_process");
15
15
  const errors_1 = require("./errors");
16
+ const debug_dump_1 = require("./debug-dump");
16
17
  const emit_1 = require("./emit");
17
18
  const project_1 = require("./project");
18
- const backend_1 = require("./backend");
19
+ const layout_1 = require("./layout");
20
+ const parser_1 = require("./parser");
21
+ const verify_1 = require("./verify");
19
22
  const ANQSTGEN_ACTIVE_STAMP_FILE = ".anqstgen-version-active.json";
20
- function generationTargetsForBackend(backendId, targets) {
21
- if (backendId !== "tsc")
22
- return targets;
23
- // tsc backend currently supports QWidget and node_express_ws emitters only.
24
- return {
25
- emitQWidget: targets.emitQWidget,
26
- emitAngularService: false,
27
- emitNodeExpressWs: targets.emitNodeExpressWs
28
- };
29
- }
30
23
  function renderHelp() {
31
24
  return [
32
25
  "Usage:",
@@ -34,15 +27,14 @@ function renderHelp() {
34
27
  "",
35
28
  "Commands:",
36
29
  " instill <WidgetName> Initialize AnQst in current npm project",
37
- " test Verify package.json AnQst spec",
38
- " build [--backend <id>] [--designerplugin[=true|false]] Generate artifacts from package.json AnQst spec",
39
- " generate <specFile> [--backend <id>] Generate artifacts from explicit spec file",
40
- " verify <specFile> [--backend <id>] Verify explicit spec file only",
30
+ " test Verify AnQst spec from package settings",
31
+ " build [--designerplugin[=true|false]] Generate artifacts from package settings",
32
+ " generate <specFile> Generate artifacts from explicit spec file",
33
+ " verify <specFile> Verify explicit spec file only",
41
34
  " clean <path> [-f|--force] Remove generated artifacts under path",
42
35
  "",
43
36
  "Options:",
44
- " --backend <id> Backend for build/generate/verify: ast|tsc",
45
- " --designerplugin Build Qt Designer plugin (build command only, tsc + QWidget)",
37
+ " --designerplugin Build Qt Designer plugin (build command only, QWidget target required)",
46
38
  " -h, --help Show this help output"
47
39
  ].join("\n");
48
40
  }
@@ -50,81 +42,90 @@ function usageFor(command) {
50
42
  if (command === "instill")
51
43
  return "Usage: anqst instill <WidgetName>";
52
44
  if (command === "build")
53
- return "Usage: anqst build [--backend <id>] [--designerplugin[=true|false]]";
45
+ return "Usage: anqst build [--designerplugin[=true|false]]";
54
46
  if (command === "verify")
55
- return "Usage: anqst verify <specFile> [--backend <id>]";
47
+ return "Usage: anqst verify <specFile>";
56
48
  if (command === "generate")
57
- return "Usage: anqst generate <specFile> [--backend <id>]";
49
+ return "Usage: anqst generate <specFile>";
58
50
  if (command === "clean")
59
51
  return "Usage: anqst clean <path> [-f|--force]";
60
52
  return renderHelp();
61
53
  }
62
- function runVerify(specArg, backendId = "ast") {
63
- const specPath = node_path_1.default.resolve(process.cwd(), specArg);
64
- const backend = (0, backend_1.resolveBackend)(backendId);
65
- const parsed = backend.parseSpecFile(specPath);
66
- const verification = backend.verifySpec(parsed);
67
- return {
68
- success: true,
69
- message: verification.message
70
- };
71
- }
72
- function runGenerate(specArg, backendId = "ast") {
73
- const cwd = process.cwd();
74
- const specPath = node_path_1.default.resolve(cwd, specArg);
75
- const backend = (0, backend_1.resolveBackend)(backendId);
76
- const parsed = backend.parseSpecFile(specPath);
77
- const verification = backend.verifySpec(parsed);
78
- const generationTargets = generationTargetsForBackend(backend.id, resolveGenerationTargetsFromCwd(cwd));
79
- const outputs = backend.generateOutputs(parsed, generationTargets);
80
- if (backend.emitsArtifacts) {
81
- (0, emit_1.writeGeneratedOutputs)(cwd, outputs);
82
- if (generationTargets.emitAngularService) {
83
- (0, emit_1.installTypeScriptOutputs)(cwd);
84
- }
85
- if (generationTargets.emitQWidget) {
86
- (0, emit_1.installQtIntegrationCMake)(cwd, parsed.widgetName);
87
- }
54
+ function resetGeneratedTargets(cwd, widgetName, targets) {
55
+ const layout = (0, layout_1.resolveGeneratedLayoutPaths)(cwd, widgetName);
56
+ const roots = new Set();
57
+ if (targets.emitAngularService) {
58
+ roots.add(layout.frontendRoot);
88
59
  }
89
- else {
90
- const relativeSpecFile = normalizeSlashes(node_path_1.default.relative(cwd, specPath));
91
- return {
92
- success: true,
93
- verificationMessage: verification.message,
94
- message: `\nAnQst spec ${relativeSpecFile} built.\n Backend '${backend.id}' is a non-emitting skeleton. No artifacts were generated.\n`
95
- };
60
+ if (targets.emitNodeExpressWs) {
61
+ roots.add(layout.nodeExpressRoot);
62
+ }
63
+ if (targets.emitQWidget) {
64
+ roots.add(layout.cppQtWidgetRoot);
65
+ roots.add(layout.cppCmakeRoot);
66
+ }
67
+ if ((0, debug_dump_1.isDebugEnabled)()) {
68
+ roots.add(layout.debugIntermediateRoot);
96
69
  }
97
- const relativeSpecFile = normalizeSlashes(node_path_1.default.relative(cwd, specPath));
98
- const relativeTypeScriptInstallPath = normalizeSlashes(node_path_1.default.relative(cwd, node_path_1.default.join(cwd, "src", "anqst-generated")));
99
- const relativeCppLibraryPath = normalizeSlashes(node_path_1.default.relative(cwd, node_path_1.default.join(cwd, "generated_output", `${parsed.widgetName}_QtWidget`)));
100
- const relativeNodeModulePath = normalizeSlashes(node_path_1.default.relative(cwd, node_path_1.default.join(cwd, "generated_output", `${parsed.widgetName}_node_express_ws`)));
101
- const serviceList = parsed.services.map((s) => s.name).join(", ");
70
+ for (const root of roots) {
71
+ node_fs_1.default.rmSync(root, { recursive: true, force: true });
72
+ }
73
+ }
74
+ function buildGenerateSummary(cwd, specPath, widgetName, generationTargets) {
75
+ const layout = (0, layout_1.resolveGeneratedLayoutPaths)(cwd, widgetName);
76
+ const relativeSpecFile = (0, layout_1.normalizeSlashes)(node_path_1.default.relative(cwd, specPath));
77
+ const servicePath = (0, layout_1.toProjectRelative)(cwd, node_path_1.default.join(layout.frontendRoot, "services"));
78
+ const typePath = (0, layout_1.toProjectRelative)(cwd, node_path_1.default.join(layout.frontendRoot, "types"));
79
+ const widgetRootPath = (0, layout_1.toProjectRelative)(cwd, layout.cppQtWidgetRoot);
80
+ const nodePath = (0, layout_1.toProjectRelative)(cwd, layout.nodeExpressRoot);
102
81
  const messageLines = [];
103
82
  messageLines.push(`AnQst spec ${relativeSpecFile} built.`);
104
83
  if (generationTargets.emitAngularService) {
105
- messageLines.push(` Services ${serviceList} are available from ${relativeTypeScriptInstallPath}/services.`);
106
- messageLines.push(` Generated types are available from ${relativeTypeScriptInstallPath}/types.`);
84
+ messageLines.push(` Services are available from ${servicePath}.`);
85
+ messageLines.push(` Generated types are available from ${typePath}.`);
107
86
  }
108
87
  if (generationTargets.emitQWidget) {
109
- messageLines.push(` Widget library available in ${relativeCppLibraryPath}.`);
88
+ messageLines.push(` Widget library available in ${widgetRootPath}.`);
110
89
  }
111
90
  if (generationTargets.emitNodeExpressWs) {
112
- messageLines.push(` Node Express WS module available in ${relativeNodeModulePath}.`);
91
+ messageLines.push(` Node Express WS module available in ${nodePath}.`);
113
92
  }
114
93
  if (!generationTargets.emitAngularService && !generationTargets.emitQWidget && !generationTargets.emitNodeExpressWs) {
115
94
  messageLines.push(" No outputs selected by AnQst.generate.");
116
95
  }
96
+ return `\n${messageLines.join("\n")}\n`;
97
+ }
98
+ function runVerify(specArg) {
99
+ const specPath = node_path_1.default.resolve(process.cwd(), specArg);
100
+ const parsed = (0, parser_1.parseSpecFile)(specPath);
101
+ const verification = (0, verify_1.verifySpec)(parsed);
102
+ return {
103
+ success: true,
104
+ message: verification.message
105
+ };
106
+ }
107
+ function runGenerate(specArg) {
108
+ const cwd = process.cwd();
109
+ const specPath = node_path_1.default.resolve(cwd, specArg);
110
+ const parsed = (0, parser_1.parseSpecFile)(specPath);
111
+ const verification = (0, verify_1.verifySpec)(parsed);
112
+ const generationTargets = resolveGenerationTargetsFromCwd(cwd);
113
+ resetGeneratedTargets(cwd, parsed.widgetName, generationTargets);
114
+ const outputs = (0, emit_1.generateOutputs)(parsed, generationTargets);
115
+ (0, emit_1.writeGeneratedOutputs)(cwd, outputs);
116
+ if (generationTargets.emitQWidget) {
117
+ (0, emit_1.installQtIntegrationCMake)(cwd, parsed.widgetName);
118
+ }
117
119
  return {
118
120
  success: true,
119
121
  verificationMessage: verification.message,
120
- message: `\n${messageLines.join("\n")}\n`
122
+ message: buildGenerateSummary(cwd, specPath, parsed.widgetName, generationTargets)
121
123
  };
122
124
  }
123
125
  function runTest(cwd) {
124
126
  const specPath = (0, project_1.resolveAnQstSpecPath)(cwd);
125
- const backend = (0, backend_1.resolveBackend)("ast");
126
- const parsed = backend.parseSpecFile(specPath);
127
- const verification = backend.verifySpec(parsed);
127
+ const parsed = (0, parser_1.parseSpecFile)(specPath);
128
+ const verification = (0, verify_1.verifySpec)(parsed);
128
129
  return {
129
130
  success: true,
130
131
  message: verification.message
@@ -152,9 +153,10 @@ function readActiveBuildStamp() {
152
153
  }
153
154
  return "unknown_build_0";
154
155
  }
155
- function runDesignerPluginBuild(cwd) {
156
- const pluginSourceDir = node_path_1.default.join(cwd, "anqst-cmake", "designerplugin");
157
- const pluginBuildDir = node_path_1.default.join(cwd, "anqst-cmake", "build-designerplugin");
156
+ function runDesignerPluginBuild(cwd, widgetName) {
157
+ const layout = (0, layout_1.resolveGeneratedLayoutPaths)(cwd, widgetName);
158
+ const pluginSourceDir = layout.designerPluginRoot;
159
+ const pluginBuildDir = layout.designerPluginBuildRoot;
158
160
  const webBaseDir = process.env.ANQST_WEBBASE_DIR?.trim();
159
161
  if (!webBaseDir) {
160
162
  throw new errors_1.VerifyError("Missing ANQST_WEBBASE_DIR environment variable for --designerplugin build.");
@@ -187,33 +189,26 @@ function runDesignerPluginBuild(cwd) {
187
189
  throw new errors_1.VerifyError("CMake build failed while compiling Qt Designer plugin.");
188
190
  }
189
191
  }
190
- function runBuild(cwd, backendId = "ast", designerPlugin = false) {
192
+ function runBuild(cwd, designerPlugin = false) {
191
193
  const buildVersion = readActiveBuildStamp();
192
194
  process.env.ANQST_BUILD_STAMP = buildVersion;
193
195
  try {
194
- const backend = (0, backend_1.resolveBackend)(backendId);
195
196
  const specPath = (0, project_1.resolveAnQstSpecPath)(cwd);
196
- const generationTargets = generationTargetsForBackend(backend.id, resolveGenerationTargetsFromCwd(cwd, true));
197
- const parsed = backend.parseSpecFile(specPath);
198
- backend.verifySpec(parsed);
199
- const outputs = backend.generateOutputs(parsed, generationTargets);
200
- if (backend.emitsArtifacts) {
201
- (0, emit_1.writeGeneratedOutputs)(cwd, outputs);
202
- if (generationTargets.emitAngularService) {
203
- (0, emit_1.installTypeScriptOutputs)(cwd);
204
- }
205
- if (generationTargets.emitQWidget) {
206
- (0, emit_1.installQtIntegrationCMake)(cwd, parsed.widgetName);
207
- }
208
- }
209
- else {
210
- return {
211
- success: true,
212
- message: `Build completed: backend '${backend.id}' is a non-emitting skeleton; no artifacts were generated`
213
- };
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);
214
209
  }
215
210
  const hasAngularProject = generationTargets.emitQWidget && node_fs_1.default.existsSync(node_path_1.default.join(cwd, "angular.json"));
216
- if (hasAngularProject && generationTargets.emitQWidget) {
211
+ if (hasAngularProject) {
217
212
  const angularBuild = (0, node_child_process_1.spawnSync)("npx", ["ng", "build", "--configuration", "production"], {
218
213
  cwd,
219
214
  stdio: "inherit",
@@ -231,16 +226,13 @@ function runBuild(cwd, backendId = "ast", designerPlugin = false) {
231
226
  }
232
227
  let designerPluginBuilt = false;
233
228
  if (designerPlugin) {
234
- if (backend.id !== "tsc") {
235
- console.warn("[AnQst] --designerplugin is only supported with --backend tsc. Skipping designer plugin build.");
236
- }
237
- else if (!generationTargets.emitQWidget) {
229
+ if (!generationTargets.emitQWidget) {
238
230
  console.warn("[AnQst] --designerplugin requested but QWidget target is not enabled. Skipping designer plugin build.");
239
231
  }
240
232
  else {
241
233
  const widgetCategory = (0, project_1.resolveAnQstWidgetCategory)(cwd);
242
234
  (0, emit_1.installQtDesignerPluginCMake)(cwd, parsed.widgetName, { widgetCategory });
243
- runDesignerPluginBuild(cwd);
235
+ runDesignerPluginBuild(cwd, parsed.widgetName);
244
236
  designerPluginBuilt = true;
245
237
  }
246
238
  }
@@ -254,31 +246,32 @@ function runBuild(cwd, backendId = "ast", designerPlugin = false) {
254
246
  ].join("\n")
255
247
  };
256
248
  }
249
+ const layout = (0, layout_1.resolveGeneratedLayoutPaths)(cwd, parsed.widgetName);
257
250
  const detailLines = [];
258
251
  if (generationTargets.emitAngularService) {
259
252
  detailLines.push(" Target AngularService:");
260
- detailLines.push(" - Services output: src/anqst-generated/services");
261
- detailLines.push(" - Types output: src/anqst-generated/types");
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"))}`);
262
255
  }
263
256
  if (generationTargets.emitQWidget) {
264
257
  detailLines.push(" Target QWidget:");
265
- detailLines.push(" - Qt integration CMake: anqst-cmake/CMakeLists.txt");
266
- detailLines.push(` - Widget output root: generated_output/${parsed.widgetName}_QtWidget`);
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)}`);
267
260
  detailLines.push(" - Embedded web assets refreshed from Angular build");
268
261
  }
269
262
  if (generationTargets.emitNodeExpressWs) {
270
263
  detailLines.push(" Target node_express_ws:");
271
- detailLines.push(` - Module output root: generated_output/${parsed.widgetName}_node_express_ws`);
264
+ detailLines.push(` - Module output root: ${(0, layout_1.toProjectRelative)(cwd, layout.nodeExpressRoot)}`);
272
265
  }
273
266
  if (designerPluginBuilt) {
274
- const pluginBinaryPath = normalizeSlashes(node_path_1.default.join("anqst-cmake", "build-designerplugin", designerPluginBinaryName(parsed.widgetName)));
267
+ const pluginBinaryPath = (0, layout_1.normalizeSlashes)(node_path_1.default.join((0, layout_1.toProjectRelative)(cwd, layout.designerPluginBuildRoot), designerPluginBinaryName(parsed.widgetName)));
275
268
  detailLines.push(" Target QtDesignerPlugin:");
276
- detailLines.push(" - Build output: anqst-cmake/build-designerplugin");
269
+ detailLines.push(` - Build output: ${(0, layout_1.toProjectRelative)(cwd, layout.designerPluginBuildRoot)}`);
277
270
  detailLines.push(` - Plugin binary: ${pluginBinaryPath}`);
278
271
  detailLines.push(" - Install target dir: <QT_INSTALL_PLUGINS>/designer");
279
272
  detailLines.push(" - Discover QT_INSTALL_PLUGINS: qmake -query QT_INSTALL_PLUGINS");
280
- detailLines.push(` - Example install: cp ${pluginBinaryPath} "$(qmake -query QT_INSTALL_PLUGINS)/designer/"`);
281
- detailLines.push(` - User-local install: mkdir -p "$HOME/.local/lib/qt5/plugins/designer" && cp ${pluginBinaryPath} "$HOME/.local/lib/qt5/plugins/designer/"`);
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/\"`);
282
275
  }
283
276
  return {
284
277
  success: true,
@@ -293,75 +286,26 @@ function runBuild(cwd, backendId = "ast", designerPlugin = false) {
293
286
  delete process.env.ANQST_BUILD_STAMP;
294
287
  }
295
288
  }
296
- function parseBackendCommandArgs(commandName, specArg, extraArgs, requireSpec) {
289
+ function parseSpecCommandArg(commandName, specArg, extraArgs) {
297
290
  const allArgs = [specArg, ...extraArgs].filter((arg) => typeof arg === "string" && arg.length > 0);
298
- let backendId = "ast";
299
291
  const positional = [];
300
- for (let i = 0; i < allArgs.length; i += 1) {
301
- const arg = allArgs[i];
302
- if (arg === "--backend") {
303
- const value = allArgs[i + 1];
304
- if (!value || value.startsWith("-")) {
305
- throw new Error(`Missing value for --backend. ${usageFor(commandName)}`);
306
- }
307
- if (!(0, backend_1.isBackendId)(value)) {
308
- throw new Error(`Unknown backend '${value}'. Allowed backends: ast, tsc.`);
309
- }
310
- backendId = value;
311
- i += 1;
312
- continue;
313
- }
314
- if (arg.startsWith("--backend=")) {
315
- const value = arg.slice("--backend=".length);
316
- if (!(0, backend_1.isBackendId)(value)) {
317
- throw new Error(`Unknown backend '${value}'. Allowed backends: ast, tsc.`);
318
- }
319
- backendId = value;
320
- continue;
321
- }
292
+ for (const arg of allArgs) {
322
293
  if (arg.startsWith("-")) {
323
294
  throw new Error(`Unknown ${commandName} flag '${arg}'. ${usageFor(commandName)}`);
324
295
  }
325
296
  positional.push(arg);
326
297
  }
327
- if (requireSpec) {
328
- if (positional.length !== 1) {
329
- throw new Error(usageFor(commandName));
330
- }
331
- return { backendId, specArg: positional[0] };
332
- }
333
- if (positional.length > 0) {
334
- throw new Error(`Unexpected extra argument '${positional[0]}'. ${usageFor(commandName)}`);
298
+ if (positional.length !== 1) {
299
+ throw new Error(usageFor(commandName));
335
300
  }
336
- return { backendId };
301
+ return positional[0];
337
302
  }
338
303
  function parseBuildCommandArgs(specArg, extraArgs) {
339
304
  const allArgs = [specArg, ...extraArgs].filter((arg) => typeof arg === "string" && arg.length > 0);
340
- let backendId = "ast";
341
305
  let designerPlugin = false;
342
306
  const positional = [];
343
307
  for (let i = 0; i < allArgs.length; i += 1) {
344
308
  const arg = allArgs[i];
345
- if (arg === "--backend") {
346
- const value = allArgs[i + 1];
347
- if (!value || value.startsWith("-")) {
348
- throw new Error(`Missing value for --backend. ${usageFor("build")}`);
349
- }
350
- if (!(0, backend_1.isBackendId)(value)) {
351
- throw new Error(`Unknown backend '${value}'. Allowed backends: ast, tsc.`);
352
- }
353
- backendId = value;
354
- i += 1;
355
- continue;
356
- }
357
- if (arg.startsWith("--backend=")) {
358
- const value = arg.slice("--backend=".length);
359
- if (!(0, backend_1.isBackendId)(value)) {
360
- throw new Error(`Unknown backend '${value}'. Allowed backends: ast, tsc.`);
361
- }
362
- backendId = value;
363
- continue;
364
- }
365
309
  if (arg === "--designerplugin") {
366
310
  const value = allArgs[i + 1];
367
311
  if (value && !value.startsWith("-")) {
@@ -386,7 +330,7 @@ function parseBuildCommandArgs(specArg, extraArgs) {
386
330
  if (positional.length > 0) {
387
331
  throw new Error(`Unexpected extra argument '${positional[0]}'. ${usageFor("build")}`);
388
332
  }
389
- return { backendId, designerPlugin };
333
+ return { designerPlugin };
390
334
  }
391
335
  function parseCleanCommandArgs(specArg, extraArgs) {
392
336
  const allArgs = [specArg, ...extraArgs].filter((arg) => typeof arg === "string" && arg.length > 0);
@@ -442,7 +386,7 @@ function formatCleanResult(targetRoot, rows) {
442
386
  const notFound = rows.filter((row) => row.status === "not_found");
443
387
  const failed = rows.filter((row) => row.status === "failed");
444
388
  const lines = [];
445
- lines.push(`[AnQst] Clean summary for ${normalizeSlashes(targetRoot)}`);
389
+ lines.push(`[AnQst] Clean summary for ${(0, layout_1.normalizeSlashes)(targetRoot)}`);
446
390
  if (deleted.length > 0) {
447
391
  lines.push(` Deleted (${deleted.length})`);
448
392
  for (const row of deleted)
@@ -464,14 +408,14 @@ function resolveGenerationTargetsFromCwd(cwd, requirePackageAnQst = false) {
464
408
  const packagePath = node_path_1.default.join(cwd, "package.json");
465
409
  if (!node_fs_1.default.existsSync(packagePath)) {
466
410
  if (requirePackageAnQst) {
467
- throw new errors_1.VerifyError("No package.json: Can only build AnQst inside an npm project.");
411
+ throw new errors_1.VerifyError("No package.json: AnQst commands must run inside an npm project.");
468
412
  }
469
413
  return toGenerationTargets([...project_1.DEFAULT_ANQST_GENERATE_TARGETS]);
470
414
  }
471
415
  const packageJson = JSON.parse(node_fs_1.default.readFileSync(packagePath, "utf8"));
472
416
  if (packageJson.AnQst === undefined) {
473
417
  if (requirePackageAnQst) {
474
- throw new errors_1.VerifyError("Missing package.json key 'AnQst.spec'. Run 'anqst instill <WidgetName>' first.");
418
+ throw new errors_1.VerifyError("Missing package.json key 'AnQst'. Run 'anqst instill <WidgetName>' first.");
475
419
  }
476
420
  return toGenerationTargets([...project_1.DEFAULT_ANQST_GENERATE_TARGETS]);
477
421
  }
@@ -484,40 +428,24 @@ function toGenerationTargets(targets) {
484
428
  emitNodeExpressWs: targets.includes("node_express_ws")
485
429
  };
486
430
  }
487
- function resolveAnQstSpecFromPackage(targetRoot) {
488
- const packagePath = node_path_1.default.join(targetRoot, "package.json");
489
- if (!node_fs_1.default.existsSync(packagePath)) {
490
- throw new Error(`No package.json with an AnQst key found at '${normalizeSlashes(targetRoot)}'. Use 'anqst clean ${normalizeSlashes(targetRoot)} --force' to clean anyway.`);
491
- }
492
- const packageJson = JSON.parse(node_fs_1.default.readFileSync(packagePath, "utf8"));
493
- const spec = packageJson.AnQst?.spec;
494
- if (!spec || spec.trim().length === 0) {
495
- throw new Error(`No package.json with an AnQst key found at '${normalizeSlashes(targetRoot)}'. Use 'anqst clean ${normalizeSlashes(targetRoot)} --force' to clean anyway.`);
496
- }
497
- return node_path_1.default.resolve(targetRoot, spec);
498
- }
499
431
  function runClean(pathArg, force) {
500
432
  const targetRoot = node_path_1.default.resolve(process.cwd(), pathArg);
501
- const broadDirs = [
502
- "generated_output",
503
- node_path_1.default.join("src", "anqst-generated"),
504
- "anqst-cmake"
505
- ];
506
433
  if (force) {
507
- const rows = runCleanup(targetRoot, broadDirs);
434
+ const rows = runCleanup(targetRoot, [(0, layout_1.normalizeSlashes)(node_path_1.default.join("AnQst", "generated"))]);
508
435
  return {
509
436
  success: true,
510
437
  message: formatCleanResult(targetRoot, rows),
511
438
  hadFailures: rows.some((row) => row.status === "failed")
512
439
  };
513
440
  }
514
- const specPath = resolveAnQstSpecFromPackage(targetRoot);
515
- const parsed = (0, backend_1.resolveBackend)("ast").parseSpecFile(specPath);
441
+ const context = (0, project_1.resolveAnQstSettings)(targetRoot);
442
+ const layout = (0, layout_1.resolveGeneratedLayoutPaths)(targetRoot, context.settings.widgetName);
516
443
  const widgetDirs = [
517
- node_path_1.default.join("generated_output", `${parsed.widgetName}_QtWidget`),
518
- node_path_1.default.join("generated_output", `${parsed.widgetName}_node_express_ws`),
519
- node_path_1.default.join("src", "anqst-generated"),
520
- "anqst-cmake"
444
+ (0, layout_1.normalizeSlashes)(node_path_1.default.relative(targetRoot, layout.frontendRoot)),
445
+ (0, layout_1.normalizeSlashes)(node_path_1.default.relative(targetRoot, layout.nodeExpressRoot)),
446
+ (0, layout_1.normalizeSlashes)(node_path_1.default.relative(targetRoot, layout.cppQtWidgetRoot)),
447
+ (0, layout_1.normalizeSlashes)(node_path_1.default.relative(targetRoot, layout.cppCmakeRoot)),
448
+ (0, layout_1.normalizeSlashes)(node_path_1.default.relative(targetRoot, layout.debugIntermediateRoot))
521
449
  ];
522
450
  const rows = runCleanup(targetRoot, widgetDirs);
523
451
  return {
@@ -526,9 +454,6 @@ function runClean(pathArg, force) {
526
454
  hadFailures: rows.some((row) => row.status === "failed")
527
455
  };
528
456
  }
529
- function normalizeSlashes(inputPath) {
530
- return inputPath.split(node_path_1.default.sep).join("/");
531
- }
532
457
  function designerPluginBinaryName(widgetName) {
533
458
  const targetName = `${widgetName}DesignerPlugin`;
534
459
  if (process.platform === "win32") {
@@ -576,19 +501,19 @@ function runCommand(command, specArg, extraArgs = []) {
576
501
  }
577
502
  if (normalizedCommand === "build") {
578
503
  const parsedArgs = parseBuildCommandArgs(specArg, extraArgs);
579
- const res = runBuild(process.cwd(), parsedArgs.backendId, parsedArgs.designerPlugin);
504
+ const res = runBuild(process.cwd(), parsedArgs.designerPlugin);
580
505
  console.log(res.message);
581
506
  return 0;
582
507
  }
583
508
  if (normalizedCommand === "verify") {
584
- const parsedArgs = parseBackendCommandArgs("verify", specArg, extraArgs, true);
585
- const res = runVerify(parsedArgs.specArg, parsedArgs.backendId);
509
+ const specArgParsed = parseSpecCommandArg("verify", specArg, extraArgs);
510
+ const res = runVerify(specArgParsed);
586
511
  console.log(res.message);
587
512
  return 0;
588
513
  }
589
514
  if (normalizedCommand === "generate") {
590
- const parsedArgs = parseBackendCommandArgs("generate", specArg, extraArgs, true);
591
- const res = runGenerate(parsedArgs.specArg, parsedArgs.backendId);
515
+ const specArgParsed = parseSpecCommandArg("generate", specArg, extraArgs);
516
+ const res = runGenerate(specArgParsed);
592
517
  if (res.verificationMessage) {
593
518
  console.log(res.verificationMessage);
594
519
  }
@@ -9,11 +9,12 @@ exports.inspectText = inspectText;
9
9
  const node_fs_1 = __importDefault(require("node:fs"));
10
10
  const node_path_1 = __importDefault(require("node:path"));
11
11
  const node_util_1 = __importDefault(require("node:util"));
12
+ const layout_1 = require("./layout");
12
13
  function isDebugEnabled() {
13
14
  return process.env.ANQST_DEBUG === "true";
14
15
  }
15
16
  function baseIntermediateDir(cwd) {
16
- return node_path_1.default.join(cwd, "generated_output", "intermediate");
17
+ return (0, layout_1.anqstDebugIntermediateRootDir)(cwd);
17
18
  }
18
19
  function writeDebugFile(cwd, relativePath, content) {
19
20
  if (!isDebugEnabled())