@sap-ux/odata-service-writer 1.0.9 → 1.0.11

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.
@@ -1,7 +1,9 @@
1
1
  import { join, normalize, posix } from 'node:path';
2
2
  import { XMLParser } from 'fast-xml-parser';
3
3
  import { t } from '../i18n.js';
4
- import prettifyXml from 'prettify-xml';
4
+ // xml-formatter types are not callable under NodeNext; cast to function type once so call sites are clean
5
+ import _fmt from 'xml-formatter';
6
+ const xmlFormatter = _fmt;
5
7
  import { getWebappPath, DirName } from '@sap-ux/project-access';
6
8
  /**
7
9
  * Updates the cds index or service file with the provided annotations.
@@ -154,7 +156,12 @@ export async function writeLocalServiceAnnotationXMLFiles(fs, webappPath, templa
154
156
  export async function writeMetadata(fs, webappPath, service) {
155
157
  if (service.metadata) {
156
158
  // mainService should be used in case there is no name defined for service
157
- fs.write(join(webappPath, DirName.LocalService, service.name ?? 'mainService', 'metadata.xml'), prettifyXml(service.metadata, { indent: 4 }));
159
+ fs.write(join(webappPath, DirName.LocalService, service.name ?? 'mainService', 'metadata.xml'), xmlFormatter(service.metadata, {
160
+ indentation: ' ',
161
+ lineSeparator: '\n',
162
+ collapseContent: true,
163
+ throwOnFailure: false
164
+ }));
158
165
  }
159
166
  }
160
167
  /**
@@ -199,12 +206,22 @@ export async function writeRemoteServiceAnnotationXmlFiles(fs, basePath, service
199
206
  for (const annotationName in edmxAnnotations) {
200
207
  const annotation = edmxAnnotations[annotationName];
201
208
  if (annotation?.xml) {
202
- fs.write(join(webappPath, DirName.LocalService, serviceName, `${annotation.name}.xml`), prettifyXml(annotation.xml, { indent: 4 }));
209
+ fs.write(join(webappPath, DirName.LocalService, serviceName, `${annotation.name}.xml`), xmlFormatter(annotation.xml, {
210
+ indentation: ' ',
211
+ lineSeparator: '\n',
212
+ collapseContent: true,
213
+ throwOnFailure: false
214
+ }));
203
215
  }
204
216
  }
205
217
  }
206
218
  else if (edmxAnnotations?.xml) {
207
- fs.write(join(webappPath, DirName.LocalService, serviceName, `${edmxAnnotations.name}.xml`), prettifyXml(edmxAnnotations.xml, { indent: 4 }));
219
+ fs.write(join(webappPath, DirName.LocalService, serviceName, `${edmxAnnotations.name}.xml`), xmlFormatter(edmxAnnotations.xml, {
220
+ indentation: ' ',
221
+ lineSeparator: '\n',
222
+ collapseContent: true,
223
+ throwOnFailure: false
224
+ }));
208
225
  }
209
226
  }
210
227
  /**
@@ -1,6 +1,8 @@
1
1
  import { join } from 'node:path';
2
2
  import { join as joinPosix } from 'node:path/posix';
3
- import prettifyXml from 'prettify-xml';
3
+ // xml-formatter types are not callable under NodeNext; cast to function type once so call sites are clean
4
+ import _fmt from 'xml-formatter';
5
+ const xmlFormatter = _fmt;
4
6
  import { convert } from '@sap-ux/annotation-converter';
5
7
  import { parse } from '@sap-ux/edmx-parser';
6
8
  import { DirName } from '@sap-ux/project-access';
@@ -37,7 +39,12 @@ export function writeExternalServiceMetadata(fs, webappPath, externalServices, s
37
39
  filePathSegments.push('metadata.xml');
38
40
  const path = join(...filePathSegments);
39
41
  if (reference.metadata) {
40
- fs.write(path, prettifyXml(reference.metadata, { indent: INDENT_SIZE }));
42
+ fs.write(path, xmlFormatter(reference.metadata, {
43
+ indentation: ' ',
44
+ lineSeparator: '\n',
45
+ collapseContent: true,
46
+ throwOnFailure: false
47
+ }));
41
48
  }
42
49
  }
43
50
  }
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "bugs": {
11
11
  "url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Aodata-service-writer"
12
12
  },
13
- "version": "1.0.9",
13
+ "version": "1.0.11",
14
14
  "license": "Apache-2.0",
15
15
  "main": "dist/index.js",
16
16
  "files": [
@@ -21,21 +21,21 @@
21
21
  "!dist/**/*.map"
22
22
  ],
23
23
  "dependencies": {
24
- "@sap-ux/edmx-parser": "0.10.0",
25
24
  "@sap-ux/annotation-converter": "0.10.21",
25
+ "@sap-ux/edmx-parser": "0.10.0",
26
26
  "ejs": "3.1.10",
27
27
  "fast-xml-parser": "5.8.0",
28
28
  "i18next": "25.10.10",
29
29
  "mem-fs": "2.1.0",
30
30
  "mem-fs-editor": "9.4.0",
31
- "prettify-xml": "1.2.0",
32
- "semver": "7.7.4",
33
- "@sap-ux/project-access": "2.1.3",
34
- "@sap-ux/ui5-config": "1.0.3",
35
- "@sap-ux/mockserver-config-writer": "1.0.7"
31
+ "semver": "7.8.4",
32
+ "xml-formatter": "3.7.0",
33
+ "@sap-ux/mockserver-config-writer": "1.0.9",
34
+ "@sap-ux/project-access": "2.1.5",
35
+ "@sap-ux/ui5-config": "1.0.4"
36
36
  },
37
37
  "devDependencies": {
38
- "@jest/globals": "30.3.0",
38
+ "@jest/globals": "30.4.1",
39
39
  "@sap-ux/vocabularies-types": "0.15.0",
40
40
  "@types/ejs": "3.1.5",
41
41
  "@types/fs-extra": "11.0.4",
@@ -44,7 +44,7 @@
44
44
  "@types/semver": "7.7.1",
45
45
  "fs-extra": "11.3.5",
46
46
  "lodash": "4.18.1",
47
- "@sap-ux/axios-extension": "2.0.4"
47
+ "@sap-ux/axios-extension": "2.0.5"
48
48
  },
49
49
  "engines": {
50
50
  "node": ">=22.x"