@sap-ux/generator-adp 0.9.55 → 0.9.57

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.
@@ -12,6 +12,10 @@ declare class AddNewModelGenerator extends SubGeneratorBase {
12
12
  * The variant.
13
13
  */
14
14
  private variant;
15
+ /**
16
+ * The CF configuration, set when running in a CF environment.
17
+ */
18
+ private cfConfig;
15
19
  /**
16
20
  * The project path.
17
21
  */
@@ -24,15 +28,14 @@ declare class AddNewModelGenerator extends SubGeneratorBase {
24
28
  */
25
29
  constructor(args: string | string[], opts: GeneratorOpts);
26
30
  initializing(): Promise<void>;
31
+ /**
32
+ * Checks whether the project's CF target (org/space stored in ui5.yaml) matches the
33
+ * currently logged-in CF target.
34
+ */
35
+ private _checkCfTargetMismatch;
27
36
  prompting(): Promise<void>;
28
37
  writing(): Promise<void>;
29
38
  end(): void;
30
- /**
31
- * Creates the new model data.
32
- *
33
- * @returns {NewModelData} The new model data.
34
- */
35
- private _createNewModelData;
36
39
  }
37
40
  export = AddNewModelGenerator;
38
41
  //# sourceMappingURL=index.d.ts.map
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  const yeoman_ui_types_1 = require("@sap-devx/yeoman-ui-types");
6
6
  const adp_tooling_1 = require("@sap-ux/adp-tooling");
7
+ const fiori_generator_shared_1 = require("@sap-ux/fiori-generator-shared");
7
8
  const types_1 = require("../types");
8
9
  const i18n_1 = require("../utils/i18n");
9
10
  const sub_gen_base_1 = __importDefault(require("../base/sub-gen-base"));
@@ -19,6 +20,10 @@ class AddNewModelGenerator extends sub_gen_base_1.default {
19
20
  * The variant.
20
21
  */
21
22
  variant;
23
+ /**
24
+ * The CF configuration, set when running in a CF environment.
25
+ */
26
+ cfConfig;
22
27
  /**
23
28
  * The project path.
24
29
  */
@@ -37,7 +42,16 @@ class AddNewModelGenerator extends sub_gen_base_1.default {
37
42
  }
38
43
  async initializing() {
39
44
  await (0, i18n_1.initI18n)();
45
+ (0, fiori_generator_shared_1.setYeomanEnvConflicterForce)(this.env, true);
40
46
  try {
47
+ if (await (0, adp_tooling_1.isCFEnvironment)(this.projectPath)) {
48
+ this.cfConfig = (0, adp_tooling_1.loadCfConfig)(this.logger);
49
+ const loggedIn = await (0, adp_tooling_1.isLoggedInCf)(this.cfConfig, this.logger);
50
+ if (!loggedIn) {
51
+ throw new Error((0, i18n_1.t)('error.cfNotLoggedIn'));
52
+ }
53
+ await this._checkCfTargetMismatch();
54
+ }
41
55
  this._registerPrompts(new yeoman_ui_types_1.Prompts([
42
56
  { name: (0, i18n_1.t)('yuiNavSteps.addNewModelName'), description: (0, i18n_1.t)('yuiNavSteps.addNewModelDescr') }
43
57
  ]));
@@ -49,46 +63,41 @@ class AddNewModelGenerator extends sub_gen_base_1.default {
49
63
  this.logger.error(e);
50
64
  }
51
65
  }
66
+ /**
67
+ * Checks whether the project's CF target (org/space stored in ui5.yaml) matches the
68
+ * currently logged-in CF target.
69
+ */
70
+ async _checkCfTargetMismatch() {
71
+ let buildTask;
72
+ try {
73
+ const ui5Config = await (0, adp_tooling_1.readUi5Config)(this.projectPath, 'ui5.yaml');
74
+ buildTask = (0, adp_tooling_1.extractCfBuildTask)(ui5Config);
75
+ }
76
+ catch (e) {
77
+ this.logger.error(e.message);
78
+ throw new Error('CF target mismatch check failed. Check the logs for details.');
79
+ }
80
+ const orgMismatch = this.cfConfig?.org.GUID !== buildTask.org;
81
+ const spaceMismatch = this.cfConfig?.space.GUID !== buildTask.space;
82
+ if (orgMismatch || spaceMismatch) {
83
+ throw new Error((0, i18n_1.t)('error.cfTargetMismatch'));
84
+ }
85
+ }
52
86
  async prompting() {
53
87
  if (this.validationError) {
54
88
  await this.handleRuntimeCrash(this.validationError.message);
55
89
  return;
56
90
  }
57
- this.answers = await this.prompt(await (0, adp_tooling_1.getPromptsForNewModel)(this.projectPath, this.variant.layer));
91
+ this.answers = await this.prompt(await (0, adp_tooling_1.getPromptsForNewModel)(this.projectPath, this.variant.layer, this.logger));
58
92
  this.logger.log(`Current answers\n${JSON.stringify(this.answers, null, 2)}`);
59
93
  }
60
94
  async writing() {
61
- await (0, adp_tooling_1.generateChange)(this.projectPath, "appdescr_ui5_addNewModel" /* ChangeType.ADD_NEW_MODEL */, this._createNewModelData(), this.fs);
95
+ await (0, adp_tooling_1.generateChange)(this.projectPath, "appdescr_ui5_addNewModel" /* ChangeType.ADD_NEW_MODEL */, await (0, adp_tooling_1.createNewModelData)(this.projectPath, this.variant, this.answers, this.logger), this.fs);
62
96
  this.logger.log('Change written to changes folder');
63
97
  }
64
98
  end() {
65
99
  this.logger.log('Successfully created change!');
66
100
  }
67
- /**
68
- * Creates the new model data.
69
- *
70
- * @returns {NewModelData} The new model data.
71
- */
72
- _createNewModelData() {
73
- const { name, uri, modelName, version, modelSettings, addAnnotationMode } = this.answers;
74
- return {
75
- variant: this.variant,
76
- service: {
77
- name,
78
- uri,
79
- modelName,
80
- version,
81
- modelSettings
82
- },
83
- ...(addAnnotationMode && {
84
- annotation: {
85
- dataSourceName: this.answers.dataSourceName,
86
- dataSourceURI: this.answers.dataSourceURI,
87
- settings: this.answers.annotationSettings
88
- }
89
- })
90
- };
91
- }
92
101
  }
93
102
  module.exports = AddNewModelGenerator;
94
103
  //# sourceMappingURL=index.js.map
@@ -13,8 +13,8 @@
13
13
  "deployConfigDescr": "Configure deployment settings.",
14
14
  "addComponentUsagesName": "Add SAPUI5 Component Usages",
15
15
  "addComponentUsagesDescr": "Select SAPUI5 component usages.",
16
- "addNewModelName": "Add OData Service and SAPUI5 Model",
17
- "addNewModelDescr": "Select an OData service and SAPUI5 model.",
16
+ "addNewModelName": "Add Datasource and SAPUI5 Model",
17
+ "addNewModelDescr": "Select a Datasource and SAPUI5 model.",
18
18
  "addLocalAnnotationFileName": "Add Local Annotation File",
19
19
  "addLocalAnnotationFileDescr": "Select an OData service and annotation XML file.",
20
20
  "replaceODataServiceName": "Replace OData Service",
@@ -111,6 +111,7 @@
111
111
  "cfNotInstalled": "Cloud Foundry is not installed in your space. Please install it to continue.",
112
112
  "cfNotLoggedIn": "You are not logged in to Cloud Foundry. Please login to continue.",
113
113
  "cfOrgSpaceMissing": "You are logged in to the Cloud Foundry API endpoint but no organization and space are targeted. Target an organization and space to continue.",
114
+ "cfTargetMismatch": "The active Cloud Foundry session doesn't match the expected organization and space of the project.",
114
115
  "baseAppHasToBeSelected": "Base application has to be selected. Please select a base application.",
115
116
  "businessServiceHasToBeSelected": "Business service has to be selected. Please select a business service.",
116
117
  "businessServiceDoesNotExist": "The service chosen does not exist in cockpit or the user is not member of the needed space.",
@@ -1,7 +1,7 @@
1
1
  export declare enum GeneratorTypes {
2
2
  ADD_ANNOTATIONS_TO_DATA = "Add Local Annotation File",
3
3
  ADD_COMPONENT_USAGES = "Add SAPUI5 Component Usages",
4
- ADD_NEW_MODEL = "Add OData Service And SAPUI5 Model",
4
+ ADD_NEW_MODEL = "Add Datasource and SAPUI5 Model",
5
5
  CHANGE_DATA_SOURCE = "Replace OData Service"
6
6
  }
7
7
  export interface Credentials {
@@ -5,7 +5,7 @@ var GeneratorTypes;
5
5
  (function (GeneratorTypes) {
6
6
  GeneratorTypes["ADD_ANNOTATIONS_TO_DATA"] = "Add Local Annotation File";
7
7
  GeneratorTypes["ADD_COMPONENT_USAGES"] = "Add SAPUI5 Component Usages";
8
- GeneratorTypes["ADD_NEW_MODEL"] = "Add OData Service And SAPUI5 Model";
8
+ GeneratorTypes["ADD_NEW_MODEL"] = "Add Datasource and SAPUI5 Model";
9
9
  GeneratorTypes["CHANGE_DATA_SOURCE"] = "Replace OData Service";
10
10
  })(GeneratorTypes || (exports.GeneratorTypes = GeneratorTypes = {}));
11
11
  //# sourceMappingURL=types.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": "0.9.55",
6
+ "version": "0.9.57",
7
7
  "repository": {
8
8
  "type": "git",
9
9
  "url": "https://github.com/SAP/open-ux-tools.git",
@@ -30,19 +30,19 @@
30
30
  "i18next": "25.10.10",
31
31
  "yeoman-generator": "5.10.0",
32
32
  "uuid": "11.1.0",
33
- "@sap-ux/adp-tooling": "0.18.116",
33
+ "@sap-ux/adp-tooling": "0.18.118",
34
34
  "@sap-ux/axios-extension": "1.25.31",
35
35
  "@sap-ux/btp-utils": "1.1.14",
36
36
  "@sap-ux/feature-toggle": "0.3.8",
37
- "@sap-ux/inquirer-common": "0.11.36",
37
+ "@sap-ux/inquirer-common": "0.11.37",
38
38
  "@sap-ux/logger": "0.8.5",
39
39
  "@sap-ux/project-access": "1.35.20",
40
40
  "@sap-ux/store": "1.5.13",
41
41
  "@sap-ux/system-access": "0.7.7",
42
42
  "@sap-ux/project-input-validator": "0.6.76",
43
- "@sap-ux/fiori-generator-shared": "0.13.98",
43
+ "@sap-ux/fiori-generator-shared": "0.13.99",
44
44
  "@sap-ux/odata-service-writer": "0.31.7",
45
- "@sap-ux/telemetry": "0.6.98"
45
+ "@sap-ux/telemetry": "0.6.99"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@jest/types": "30.3.0",
@@ -57,7 +57,7 @@
57
57
  "fs-extra": "11.3.4",
58
58
  "rimraf": "6.1.3",
59
59
  "yeoman-test": "6.3.0",
60
- "@sap-ux/deploy-config-sub-generator": "0.5.141"
60
+ "@sap-ux/deploy-config-sub-generator": "0.5.143"
61
61
  },
62
62
  "engines": {
63
63
  "node": ">=20.x"