@sap-ux/odata-service-writer 0.16.4 → 0.17.0
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 +9 -32
- package/package.json +4 -3
- package/templates/add/ui5-mock.yaml +0 -6
package/dist/index.js
CHANGED
|
@@ -24,6 +24,8 @@ const i18n_1 = require("./i18n");
|
|
|
24
24
|
const types_1 = require("./types");
|
|
25
25
|
Object.defineProperty(exports, "OdataVersion", { enumerable: true, get: function () { return types_1.OdataVersion; } });
|
|
26
26
|
Object.defineProperty(exports, "ServiceType", { enumerable: true, get: function () { return types_1.ServiceType; } });
|
|
27
|
+
const project_access_1 = require("@sap-ux/project-access");
|
|
28
|
+
const mockserver_config_writer_1 = require("@sap-ux/mockserver-config-writer");
|
|
27
29
|
/**
|
|
28
30
|
* Ensures the existence of the given files in the provided base path. If a file in the provided list does not exit, an error would be thrown.
|
|
29
31
|
*
|
|
@@ -63,34 +65,6 @@ function findProjectFiles(basePath, fs) {
|
|
|
63
65
|
});
|
|
64
66
|
}
|
|
65
67
|
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
|
-
}
|
|
94
68
|
/**
|
|
95
69
|
* Writes the odata service related file updates to an existing UI5 project specified by the base path.
|
|
96
70
|
*
|
|
@@ -142,10 +116,13 @@ function generate(basePath, service, fs) {
|
|
|
142
116
|
if (service.metadata) {
|
|
143
117
|
// copy existing `ui5.yaml` as starting point for ui5-mock.yaml
|
|
144
118
|
if (paths.ui5Yaml && ui5Config) {
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
119
|
+
const webappPath = yield (0, project_access_1.getWebappPath)(basePath);
|
|
120
|
+
const config = {
|
|
121
|
+
webappPath: webappPath,
|
|
122
|
+
ui5MockYamlConfig: { path: service.path }
|
|
123
|
+
};
|
|
124
|
+
yield (0, mockserver_config_writer_1.generateMockserverConfig)(basePath, config, fs);
|
|
125
|
+
// add mockserver middleware to ui5-local.yaml
|
|
149
126
|
if (ui5LocalConfig) {
|
|
150
127
|
ui5LocalConfig.addMockServerMiddleware(service.path);
|
|
151
128
|
}
|
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.
|
|
12
|
+
"version": "0.17.0",
|
|
13
13
|
"license": "Apache-2.0",
|
|
14
14
|
"main": "dist/index.js",
|
|
15
15
|
"files": [
|
|
@@ -27,7 +27,8 @@
|
|
|
27
27
|
"mem-fs-editor": "9.4.0",
|
|
28
28
|
"prettify-xml": "1.2.0",
|
|
29
29
|
"semver": "7.5.4",
|
|
30
|
-
"@sap-ux/
|
|
30
|
+
"@sap-ux/mockserver-config-writer": "0.5.0",
|
|
31
|
+
"@sap-ux/ui5-config": "0.22.2"
|
|
31
32
|
},
|
|
32
33
|
"devDependencies": {
|
|
33
34
|
"@types/ejs": "3.1.2",
|
|
@@ -37,7 +38,7 @@
|
|
|
37
38
|
"@types/semver": "7.5.2",
|
|
38
39
|
"fs-extra": "10.0.0",
|
|
39
40
|
"lodash": "4.17.21",
|
|
40
|
-
"@sap-ux/project-access": "1.19.
|
|
41
|
+
"@sap-ux/project-access": "1.19.13"
|
|
41
42
|
},
|
|
42
43
|
"engines": {
|
|
43
44
|
"node": ">=18.x"
|