@sap-ux/odata-service-writer 0.16.3 → 0.16.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 +29 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -63,6 +63,34 @@ function findProjectFiles(basePath, fs) {
|
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
65
|
exports.findProjectFiles = findProjectFiles;
|
|
66
|
+
/**
|
|
67
|
+
* Generate annotations config, using `dataSources` read manifest.json.
|
|
68
|
+
*
|
|
69
|
+
* @param {string} basePath - the root path of an existing UI5 application
|
|
70
|
+
* @param {Editor} [fs] - the memfs editor instance
|
|
71
|
+
* @returns {Promise<Array<{ localPath: string, urlPath: string }>>} An array with annotations config
|
|
72
|
+
*/
|
|
73
|
+
function generateODataAnnotationConfig(basePath, fs) {
|
|
74
|
+
var _a, _b;
|
|
75
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
76
|
+
const manifest = fs.readJSON((0, path_1.join)(basePath, 'webapp', 'manifest.json'));
|
|
77
|
+
const result = {};
|
|
78
|
+
const dataSources = (_b = (_a = manifest === null || manifest === void 0 ? void 0 : manifest['sap.app']) === null || _a === void 0 ? void 0 : _a.dataSources) !== null && _b !== void 0 ? _b : {};
|
|
79
|
+
for (const dataSource in dataSources) {
|
|
80
|
+
if (dataSources[dataSource].uri && dataSources[dataSource].type === 'ODataAnnotation') {
|
|
81
|
+
result[dataSource] = dataSources[dataSource];
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
const annotationSource = Object.values(result);
|
|
85
|
+
return annotationSource.map((annotation) => {
|
|
86
|
+
var _a;
|
|
87
|
+
return ({
|
|
88
|
+
localPath: `./webapp/${(_a = annotation.settings) === null || _a === void 0 ? void 0 : _a.localUri}`,
|
|
89
|
+
urlPath: annotation.uri
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
}
|
|
66
94
|
/**
|
|
67
95
|
* Writes the odata service related file updates to an existing UI5 project specified by the base path.
|
|
68
96
|
*
|
|
@@ -115,7 +143,7 @@ function generate(basePath, service, fs) {
|
|
|
115
143
|
// copy existing `ui5.yaml` as starting point for ui5-mock.yaml
|
|
116
144
|
if (paths.ui5Yaml && ui5Config) {
|
|
117
145
|
const ui5MockConfig = yield ui5_config_1.UI5Config.newInstance(ui5Config.toString());
|
|
118
|
-
ui5MockConfig.addMockServerMiddleware(service.path);
|
|
146
|
+
ui5MockConfig.addMockServerMiddleware(service.path, yield generateODataAnnotationConfig(basePath, fs));
|
|
119
147
|
fs.write((0, path_1.join)((0, path_1.dirname)(paths.ui5Yaml), 'ui5-mock.yaml'), ui5MockConfig.toString());
|
|
120
148
|
// also add mockserver middleware to ui5-local.yaml
|
|
121
149
|
if (ui5LocalConfig) {
|
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.16.
|
|
12
|
+
"version": "0.16.4",
|
|
13
13
|
"license": "Apache-2.0",
|
|
14
14
|
"main": "dist/index.js",
|
|
15
15
|
"files": [
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@types/semver": "7.5.2",
|
|
38
38
|
"fs-extra": "10.0.0",
|
|
39
39
|
"lodash": "4.17.21",
|
|
40
|
-
"@sap-ux/project-access": "1.19.
|
|
40
|
+
"@sap-ux/project-access": "1.19.6"
|
|
41
41
|
},
|
|
42
42
|
"engines": {
|
|
43
43
|
"node": ">=18.x"
|