@sap-ux/odata-service-writer 0.27.3 → 0.27.4

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/index.js CHANGED
@@ -113,8 +113,8 @@ async function update(basePath, service, fs, updateMiddlewares = true) {
113
113
  const isServiceTypeEdmx = service.type === types_1.ServiceType.EDMX;
114
114
  await (0, manifest_1.updateManifest)(basePath, service, fs, true);
115
115
  // Dont extend/update backend and mockserver middlewares if service type is CDS
116
- if (isServiceTypeEdmx && updateMiddlewares) {
117
- await (0, update_1.updateServicesData)(basePath, paths, service, fs);
116
+ if (isServiceTypeEdmx) {
117
+ await (0, update_1.updateServicesData)(basePath, paths, service, fs, updateMiddlewares);
118
118
  }
119
119
  return fs;
120
120
  }
package/dist/update.d.ts CHANGED
@@ -20,6 +20,7 @@ export declare function addServicesData(basePath: string, paths: ProjectPaths, t
20
20
  * @param {ProjectPaths} paths - paths to the project files (package.json, ui5.yaml, ui5-local.yaml and ui5-mock.yaml)
21
21
  * @param {EdmxOdataService} service - the OData service instance
22
22
  * @param {Editor} fs - the memfs editor instance
23
+ * @param {boolean} updateMiddlewares - whether the YAML files for the service (mock-server and fiori-tools-proxy middlewares) should be updated
23
24
  */
24
- export declare function updateServicesData(basePath: string, paths: ProjectPaths, service: EdmxOdataService, fs: Editor): Promise<void>;
25
+ export declare function updateServicesData(basePath: string, paths: ProjectPaths, service: EdmxOdataService, fs: Editor, updateMiddlewares: boolean): Promise<void>;
25
26
  //# sourceMappingURL=update.d.ts.map
package/dist/update.js CHANGED
@@ -104,7 +104,7 @@ async function addServicesData(basePath, paths, templateRoot, service, fs) {
104
104
  }
105
105
  await (0, annotations_1.writeLocalServiceAnnotationXMLFiles)(fs, webappPath, templateRoot, service);
106
106
  }
107
- // service update should not trigger the package.json update
107
+ // Service is being added - update the package.json update as well, service update should not run the updates of the package.json
108
108
  if (paths.packageJson && paths.ui5Yaml) {
109
109
  (0, package_1.updatePackageJson)(paths.packageJson, fs, !!service.metadata);
110
110
  }
@@ -121,26 +121,29 @@ async function addServicesData(basePath, paths, templateRoot, service, fs) {
121
121
  * @param {ProjectPaths} paths - paths to the project files (package.json, ui5.yaml, ui5-local.yaml and ui5-mock.yaml)
122
122
  * @param {EdmxOdataService} service - the OData service instance
123
123
  * @param {Editor} fs - the memfs editor instance
124
+ * @param {boolean} updateMiddlewares - whether the YAML files for the service (mock-server and fiori-tools-proxy middlewares) should be updated
124
125
  */
125
- async function updateServicesData(basePath, paths, service, fs) {
126
+ async function updateServicesData(basePath, paths, service, fs, updateMiddlewares) {
126
127
  let ui5Config;
127
128
  let ui5LocalConfig;
128
129
  let ui5MockConfig;
129
- if (paths.ui5Yaml) {
130
- ui5Config = await ui5_config_1.UI5Config.newInstance(fs.read(paths.ui5Yaml));
131
- // Update ui5.yaml with backend middleware
132
- extendBackendMiddleware(fs, service, ui5Config, paths.ui5Yaml, true);
133
- }
134
- // Update ui5-local.yaml with backend middleware
135
- if (paths.ui5LocalYaml) {
136
- ui5LocalConfig = await ui5_config_1.UI5Config.newInstance(fs.read(paths.ui5LocalYaml));
137
- extendBackendMiddleware(fs, service, ui5LocalConfig, paths.ui5LocalYaml, true);
130
+ if (updateMiddlewares) {
131
+ if (paths.ui5Yaml) {
132
+ ui5Config = await ui5_config_1.UI5Config.newInstance(fs.read(paths.ui5Yaml));
133
+ // Update ui5.yaml with backend middleware
134
+ extendBackendMiddleware(fs, service, ui5Config, paths.ui5Yaml, true);
135
+ }
136
+ // Update ui5-local.yaml with backend middleware
137
+ if (paths.ui5LocalYaml) {
138
+ ui5LocalConfig = await ui5_config_1.UI5Config.newInstance(fs.read(paths.ui5LocalYaml));
139
+ extendBackendMiddleware(fs, service, ui5LocalConfig, paths.ui5LocalYaml, true);
140
+ }
138
141
  }
139
142
  // For update, updatable files should already exist
140
143
  if (service.metadata) {
141
144
  const webappPath = await (0, project_access_1.getWebappPath)(basePath, fs);
142
145
  // Generate mockserver only when ui5-mock.yaml already exists
143
- if (paths.ui5MockYaml && paths.ui5Yaml && ui5Config) {
146
+ if (paths.ui5MockYaml && paths.ui5Yaml && ui5Config && updateMiddlewares) {
144
147
  const config = {
145
148
  webappPath: webappPath,
146
149
  // Since ui5-mock.yaml already exists, set 'skip' to skip package.json file updates
@@ -161,14 +164,14 @@ async function updateServicesData(basePath, paths, service, fs) {
161
164
  ui5MockConfig = await ui5_config_1.UI5Config.newInstance(fs.read(paths.ui5MockYaml));
162
165
  extendBackendMiddleware(fs, service, ui5MockConfig, paths.ui5MockYaml, true);
163
166
  }
164
- if (paths.ui5LocalYaml && ui5LocalConfig) {
165
- // write ui5 local yaml if service type is not CDS
166
- fs.write(paths.ui5LocalYaml, ui5LocalConfig.toString());
167
- }
168
167
  }
169
168
  // Write metadata.xml file
170
169
  await (0, annotations_1.writeMetadata)(fs, webappPath, service);
171
170
  }
171
+ if (paths.ui5LocalYaml && ui5LocalConfig) {
172
+ // write ui5 local yaml if service type is not CDS
173
+ fs.write(paths.ui5LocalYaml, ui5LocalConfig.toString());
174
+ }
172
175
  // Write new annotations files
173
176
  await (0, annotations_1.writeRemoteServiceAnnotationXmlFiles)(fs, basePath, service.name ?? 'mainService', service.annotations);
174
177
  }
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.27.3",
12
+ "version": "0.27.4",
13
13
  "license": "Apache-2.0",
14
14
  "main": "dist/index.js",
15
15
  "files": [