@sap-ux/odata-service-writer 0.25.0 → 0.25.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.
@@ -57,7 +57,11 @@ async function setDefaultServiceModel(basePath, service, fs) {
57
57
  if (models) {
58
58
  // Filter dataSource models by dataSource property
59
59
  const servicesModels = Object.values(models).filter((model) => model.dataSource);
60
- service.model = servicesModels.length === 0 ? '' : service.model ?? service.name;
60
+ service.model =
61
+ servicesModels.length === 0 ||
62
+ servicesModels.find((serviceModel) => serviceModel.dataSource === 'mainService') // model for mainService is ""
63
+ ? ''
64
+ : service.model ?? service.name;
61
65
  }
62
66
  // No models defined, that means first one is being added, set model to ''
63
67
  service.model ??= '';
package/dist/updates.js CHANGED
@@ -203,6 +203,7 @@ function updateExistingService(webappPath, dataSourceKey, dataSource, fs) {
203
203
  * @param {string} webappPath - the webapp path of an existing UI5 application
204
204
  * @param {Manifest} manifest - the manifest.json of the application
205
205
  * @param {Editor} fs - the memfs editor instance
206
+ * @returns modified manifest object.
206
207
  */
207
208
  async function updateExistingServices(webappPath, manifest, fs) {
208
209
  const dataSources = manifest?.['sap.app']?.dataSources;
@@ -219,7 +220,7 @@ async function updateExistingServices(webappPath, manifest, fs) {
219
220
  }
220
221
  }
221
222
  }
222
- fs.writeJSON((0, path_1.join)(webappPath, 'manifest.json'), manifest);
223
+ return manifest;
223
224
  }
224
225
  /**
225
226
  * Internal function that updates the manifest.json based on the given service configuration.
@@ -235,13 +236,12 @@ async function updateManifest(basePath, service, fs) {
235
236
  const manifest = fs.readJSON(manifestPath);
236
237
  const appProp = 'sap.app';
237
238
  const appid = manifest?.[appProp]?.id;
238
- // Check and update existing services
239
- await updateExistingServices(webappPath, manifest, fs);
240
- const modifiedManifest = fs.readJSON(manifestPath);
241
239
  // Throw if required property is not found manifest.json
242
240
  if (!appid) {
243
241
  throw new Error((0, i18n_1.t)('error.requiredProjectPropertyNotFound', { property: `'${appProp}'.id`, path: manifestPath }));
244
242
  }
243
+ // Check and update existing services
244
+ const modifiedManifest = await updateExistingServices(webappPath, manifest, fs);
245
245
  // Add or update manifest.json with service
246
246
  enhanceManifest(service, modifiedManifest);
247
247
  fs.writeJSON(manifestPath, modifiedManifest);
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "bugs": {
10
10
  "url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Aodata-service-writer"
11
11
  },
12
- "version": "0.25.0",
12
+ "version": "0.25.2",
13
13
  "license": "Apache-2.0",
14
14
  "main": "dist/index.js",
15
15
  "files": [
@@ -38,7 +38,7 @@
38
38
  "@types/semver": "7.5.2",
39
39
  "fs-extra": "10.0.0",
40
40
  "lodash": "4.17.21",
41
- "@sap-ux/project-access": "1.28.9"
41
+ "@sap-ux/project-access": "1.28.10"
42
42
  },
43
43
  "engines": {
44
44
  "node": ">=18.x"