@sap-ux/generator-adp 1.0.37 → 1.0.39

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.
@@ -84,6 +84,10 @@ export default class extends Generator {
84
84
  * Indicates if the current environment is a CF environment.
85
85
  */
86
86
  private isCfEnv;
87
+ /**
88
+ * Tracks whether the writing phase failed, to prevent end() from overwriting a failure result.
89
+ */
90
+ private writingFailed;
87
91
  /**
88
92
  * Indicates if the user is logged in to CF.
89
93
  */
@@ -23,6 +23,7 @@ const index_js_1 = require("../telemetry/index.js");
23
23
  const steps_js_1 = require("../utils/steps.js");
24
24
  const subgenHelpers_js_1 = require("../utils/subgenHelpers.js");
25
25
  const templates_js_1 = require("../utils/templates.js");
26
+ const write_result_js_1 = require("../utils/write-result.js");
26
27
  const workspace_js_1 = require("../utils/workspace.js");
27
28
  const layer_js_1 = require("./layer.js");
28
29
  const attributes_js_1 = require("./questions/attributes.js");
@@ -119,6 +120,10 @@ class default_1 extends yeoman_generator_1.default {
119
120
  * Indicates if the current environment is a CF environment.
120
121
  */
121
122
  isCfEnv = false;
123
+ /**
124
+ * Tracks whether the writing phase failed, to prevent end() from overwriting a failure result.
125
+ */
126
+ writingFailed = false;
122
127
  /**
123
128
  * Indicates if the user is logged in to CF.
124
129
  */
@@ -336,7 +341,12 @@ class default_1 extends yeoman_generator_1.default {
336
341
  await (0, adp_tooling_1.generate)(this._getProjectPath(), config, this.fs);
337
342
  }
338
343
  catch (e) {
339
- this.logger.error(`Writing phase failed: ${e}`);
344
+ const message = e instanceof Error ? e.message : String(e);
345
+ this.logger.error(`Writing phase failed: ${message}`);
346
+ this.writingFailed = true;
347
+ if (this.jsonInput?.id) {
348
+ (0, write_result_js_1.writeResult)(this.jsonInput.id, `Failure: ${message}`);
349
+ }
340
350
  throw new Error((0, i18n_js_1.t)('error.updatingApp'));
341
351
  }
342
352
  finally {
@@ -356,6 +366,10 @@ class default_1 extends yeoman_generator_1.default {
356
366
  }
357
367
  async end() {
358
368
  const projectPath = this._getProjectPath();
369
+ // Report the generated project path back to the BAS orchestrator once files are written to disk.
370
+ if (this.jsonInput?.id && !this.writingFailed) {
371
+ (0, write_result_js_1.writeResult)(this.jsonInput.id, projectPath);
372
+ }
359
373
  const data = fiori_generator_shared_1.TelemetryHelper.createTelemetryData({
360
374
  appType: 'generator-adp',
361
375
  ...this.options.telemetryData,
@@ -253,6 +253,12 @@ export interface ExtensionProjectData {
253
253
  * generator configurations. The json is passed as an CLI argument.
254
254
  */
255
255
  export interface JsonInput {
256
+ /**
257
+ * Correlation key sent by the SAP Business Application Studio orchestrator. When present, the
258
+ * generation outcome (project path on success, `Failure: <message>` on error) is written back
259
+ * under this key so the orchestrator can poll the result of an async headless generation.
260
+ */
261
+ id?: string;
256
262
  system: string;
257
263
  client?: string;
258
264
  username?: string;
@@ -21,7 +21,8 @@ function isJsonInput(value) {
21
21
  if (!isPlainObject(value)) {
22
22
  return false;
23
23
  }
24
- return (isString(value.system) &&
24
+ return (isOptionalString(value.id) &&
25
+ isString(value.system) &&
25
26
  isString(value.application) &&
26
27
  isOptionalString(value.applicationTitle) &&
27
28
  isOptionalString(value.client) &&
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Absolute path of the file the SAP Business Application Studio orchestrator polls for
3
+ * headless generation results. Each result is stored under the correlation `id` supplied
4
+ * in the generator JSON input.
5
+ */
6
+ export declare const RESULT_FILE_PATH = "/home/user/tmpProjectTemplate.json";
7
+ /**
8
+ * Writes the outcome of a headless generation run to the orchestrator result file, keyed by
9
+ * the correlation `id` from the JSON input. Existing entries are preserved; a missing or
10
+ * malformed result file is treated as empty. The result file is a best-effort side channel:
11
+ * a write failure is swallowed so it never masks the actual generation outcome.
12
+ *
13
+ * @param {string} id - The correlation key supplied by the orchestrator in the JSON input.
14
+ * @param {string} result - The generated project path on success, or `Failure: <message>` on error.
15
+ */
16
+ export declare function writeResult(id: string, result: string): void;
17
+ //# sourceMappingURL=write-result.d.ts.map
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RESULT_FILE_PATH = void 0;
4
+ exports.writeResult = writeResult;
5
+ const node_fs_1 = require("node:fs");
6
+ /**
7
+ * Absolute path of the file the SAP Business Application Studio orchestrator polls for
8
+ * headless generation results. Each result is stored under the correlation `id` supplied
9
+ * in the generator JSON input.
10
+ */
11
+ exports.RESULT_FILE_PATH = '/home/user/tmpProjectTemplate.json';
12
+ /**
13
+ * Writes the outcome of a headless generation run to the orchestrator result file, keyed by
14
+ * the correlation `id` from the JSON input. Existing entries are preserved; a missing or
15
+ * malformed result file is treated as empty. The result file is a best-effort side channel:
16
+ * a write failure is swallowed so it never masks the actual generation outcome.
17
+ *
18
+ * @param {string} id - The correlation key supplied by the orchestrator in the JSON input.
19
+ * @param {string} result - The generated project path on success, or `Failure: <message>` on error.
20
+ */
21
+ function writeResult(id, result) {
22
+ let fileContent = {};
23
+ if ((0, node_fs_1.existsSync)(exports.RESULT_FILE_PATH)) {
24
+ try {
25
+ const parsed = JSON.parse((0, node_fs_1.readFileSync)(exports.RESULT_FILE_PATH, 'utf-8'));
26
+ if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {
27
+ // Safe after the runtime object check; the file only ever holds a flat id -> result map.
28
+ fileContent = parsed;
29
+ }
30
+ }
31
+ catch {
32
+ fileContent = {};
33
+ }
34
+ }
35
+ fileContent[id] = result;
36
+ try {
37
+ (0, node_fs_1.writeFileSync)(exports.RESULT_FILE_PATH, JSON.stringify(fileContent));
38
+ }
39
+ catch {
40
+ // Best-effort side channel; never let a failed result write break generation.
41
+ }
42
+ }
43
+ //# sourceMappingURL=write-result.js.map
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "displayName": "SAPUI5 Adaptation Project",
4
4
  "homepage": "https://help.sap.com/viewer/584e0bcbfd4a4aff91c815cefa0bce2d/Cloud/en-US/ada9567b767941aba8d49fdb4fdedea7.html",
5
5
  "description": "Adaptation project allows you to create an app variant for an existing SAP Fiori elements-based or SAPUI5 freestyle application, without changing the original application.",
6
- "version": "1.0.37",
6
+ "version": "1.0.39",
7
7
  "repository": {
8
8
  "type": "git",
9
9
  "url": "https://github.com/SAP/open-ux-tools.git",
@@ -30,7 +30,7 @@
30
30
  "i18next": "25.10.10",
31
31
  "yeoman-generator": "5.10.0",
32
32
  "uuid": "11.1.1",
33
- "@sap-ux/adp-tooling": "1.0.35",
33
+ "@sap-ux/adp-tooling": "1.0.36",
34
34
  "@sap-ux/axios-extension": "2.0.7",
35
35
  "@sap-ux/btp-utils": "2.0.5",
36
36
  "@sap-ux/feature-toggle": "1.0.5",
@@ -49,7 +49,7 @@
49
49
  "@jest/types": "30.4.1",
50
50
  "@types/fs-extra": "11.0.4",
51
51
  "@types/inquirer": "8.2.6",
52
- "@types/vscode": "1.106.1",
52
+ "@types/vscode": "1.109.0",
53
53
  "@types/yeoman-environment": "2.10.11",
54
54
  "@types/yeoman-generator": "5.2.14",
55
55
  "@types/yeoman-test": "4.0.6",
@@ -58,7 +58,7 @@
58
58
  "fs-extra": "11.3.5",
59
59
  "rimraf": "6.1.3",
60
60
  "yeoman-test": "6.3.0",
61
- "@sap-ux/deploy-config-sub-generator": "1.0.47"
61
+ "@sap-ux/deploy-config-sub-generator": "1.0.48"
62
62
  },
63
63
  "engines": {
64
64
  "node": ">=22.x"