@sap-ux/mockserver-config-writer 0.0.4 → 0.0.6
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
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -25,10 +25,10 @@ const ui5_mock_yaml_1 = require("./ui5-mock-yaml");
|
|
|
25
25
|
function generateMockserverConfig(basePath, data, fs) {
|
|
26
26
|
return __awaiter(this, void 0, void 0, function* () {
|
|
27
27
|
if (!fs) {
|
|
28
|
-
fs = mem_fs_editor_1.create(mem_fs_1.create());
|
|
28
|
+
fs = (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
|
|
29
29
|
}
|
|
30
|
-
package_json_1.enhancePackageJson(fs, basePath, data.packageJsonConfig);
|
|
31
|
-
yield ui5_mock_yaml_1.enhanceYaml(fs, basePath, data.webappPath, data.ui5MockYamlConfig);
|
|
30
|
+
(0, package_json_1.enhancePackageJson)(fs, basePath, data.packageJsonConfig);
|
|
31
|
+
yield (0, ui5_mock_yaml_1.enhanceYaml)(fs, basePath, data.webappPath, data.ui5MockYamlConfig);
|
|
32
32
|
return fs;
|
|
33
33
|
});
|
|
34
34
|
}
|
|
@@ -42,10 +42,10 @@ exports.generateMockserverConfig = generateMockserverConfig;
|
|
|
42
42
|
*/
|
|
43
43
|
function removeMockserverConfig(basePath, fs) {
|
|
44
44
|
if (!fs) {
|
|
45
|
-
fs = mem_fs_editor_1.create(mem_fs_1.create());
|
|
45
|
+
fs = (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
|
|
46
46
|
}
|
|
47
|
-
package_json_1.removeFromPackageJson(fs, basePath);
|
|
48
|
-
ui5_mock_yaml_1.removeUi5MockYaml(fs, basePath);
|
|
47
|
+
(0, package_json_1.removeFromPackageJson)(fs, basePath);
|
|
48
|
+
(0, ui5_mock_yaml_1.removeUi5MockYaml)(fs, basePath);
|
|
49
49
|
return fs;
|
|
50
50
|
}
|
|
51
51
|
exports.removeMockserverConfig = removeMockserverConfig;
|
|
@@ -10,7 +10,7 @@ const path_1 = require("path");
|
|
|
10
10
|
* @param config - optional config for mockserver
|
|
11
11
|
*/
|
|
12
12
|
function enhancePackageJson(fs, basePath, config) {
|
|
13
|
-
const packageJsonPath = path_1.join(basePath, 'package.json');
|
|
13
|
+
const packageJsonPath = (0, path_1.join)(basePath, 'package.json');
|
|
14
14
|
const packageJson = fs.readJSON(packageJsonPath);
|
|
15
15
|
enhanceDependencies(packageJson, config === null || config === void 0 ? void 0 : config.mockserverModule, config === null || config === void 0 ? void 0 : config.mockserverVersion);
|
|
16
16
|
enhanceScripts(fs, packageJson);
|
|
@@ -100,7 +100,7 @@ function replaceConfig(startScript, configStartIndex) {
|
|
|
100
100
|
*/
|
|
101
101
|
function removeFromPackageJson(fs, basePath) {
|
|
102
102
|
var _a, _b, _c, _d;
|
|
103
|
-
const packageJsonPath = path_1.join(basePath, 'package.json');
|
|
103
|
+
const packageJsonPath = (0, path_1.join)(basePath, 'package.json');
|
|
104
104
|
const packageJson = fs.readJSON(packageJsonPath);
|
|
105
105
|
(_a = packageJson.scripts) === null || _a === void 0 ? true : delete _a['start-mock'];
|
|
106
106
|
if (packageJson.scripts && Object.keys(packageJson.scripts).length === 0) {
|
|
@@ -36,15 +36,15 @@ const app_info_1 = require("../app-info");
|
|
|
36
36
|
function enhanceYaml(fs, basePath, webappPath, config) {
|
|
37
37
|
var _a, _b;
|
|
38
38
|
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
-
const ui5MockYamlPath = path_1.join(basePath, 'ui5-mock.yaml');
|
|
39
|
+
const ui5MockYamlPath = (0, path_1.join)(basePath, 'ui5-mock.yaml');
|
|
40
40
|
let mockConfig;
|
|
41
|
-
const manifest = fs.readJSON(path_1.join(webappPath, 'manifest.json'));
|
|
42
|
-
const mockserverPath = (config === null || config === void 0 ? void 0 : config.path) || ((_a = app_info_1.getMainServiceDataSource(manifest)) === null || _a === void 0 ? void 0 : _a.uri);
|
|
41
|
+
const manifest = fs.readJSON((0, path_1.join)(webappPath, 'manifest.json'));
|
|
42
|
+
const mockserverPath = (config === null || config === void 0 ? void 0 : config.path) || ((_a = (0, app_info_1.getMainServiceDataSource)(manifest)) === null || _a === void 0 ? void 0 : _a.uri);
|
|
43
43
|
if (fs.exists(ui5MockYamlPath)) {
|
|
44
44
|
mockConfig = yield updateUi5MockYamlConfig(fs, ui5MockYamlPath, mockserverPath);
|
|
45
45
|
}
|
|
46
46
|
else {
|
|
47
|
-
mockConfig = fs.exists(path_1.join(basePath, 'ui5.yaml'))
|
|
47
|
+
mockConfig = fs.exists((0, path_1.join)(basePath, 'ui5.yaml'))
|
|
48
48
|
? yield generateUi5MockYamlBasedOnUi5Yaml(fs, basePath, mockserverPath)
|
|
49
49
|
: yield generateNewUi5MockYamlConfig(((_b = manifest['sap.app']) === null || _b === void 0 ? void 0 : _b.id) || '', mockserverPath);
|
|
50
50
|
}
|
|
@@ -77,7 +77,7 @@ function updateUi5MockYamlConfig(fs, ui5MockYamlPath, path) {
|
|
|
77
77
|
*/
|
|
78
78
|
function generateUi5MockYamlBasedOnUi5Yaml(fs, basePath, path) {
|
|
79
79
|
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
-
const ui5MockYamlConfig = yield ui5_config_1.UI5Config.newInstance(fs.read(path_1.join(basePath, 'ui5.yaml')));
|
|
80
|
+
const ui5MockYamlConfig = yield ui5_config_1.UI5Config.newInstance(fs.read((0, path_1.join)(basePath, 'ui5.yaml')));
|
|
81
81
|
ui5MockYamlConfig.updateCustomMiddleware(yield getNewMockserverMiddleware(path));
|
|
82
82
|
return ui5MockYamlConfig;
|
|
83
83
|
});
|
|
@@ -123,7 +123,7 @@ function getNewMockserverMiddleware(path) {
|
|
|
123
123
|
* @param basePath - path to project root, where package.json and ui5.yaml is
|
|
124
124
|
*/
|
|
125
125
|
function removeUi5MockYaml(fs, basePath) {
|
|
126
|
-
const ui5MockYamlPath = path_1.join(basePath, 'ui5-mock.yaml');
|
|
126
|
+
const ui5MockYamlPath = (0, path_1.join)(basePath, 'ui5-mock.yaml');
|
|
127
127
|
if (fs.exists(ui5MockYamlPath)) {
|
|
128
128
|
fs.delete(ui5MockYamlPath);
|
|
129
129
|
}
|
package/dist/prompt/index.js
CHANGED
|
@@ -18,13 +18,13 @@ function getMockserverConfigQuestions(params) {
|
|
|
18
18
|
var _a, _b;
|
|
19
19
|
const question = {
|
|
20
20
|
name: 'path',
|
|
21
|
-
message: __1.t('questions.pathToMock')
|
|
21
|
+
message: (0, __1.t)('questions.pathToMock')
|
|
22
22
|
};
|
|
23
23
|
if (params === null || params === void 0 ? void 0 : params.webappPath) {
|
|
24
|
-
const fs = params.fs || mem_fs_editor_1.create(mem_fs_1.create());
|
|
25
|
-
const manifest = JSON.parse(fs.read(path_1.join(params.webappPath, 'manifest.json')));
|
|
26
|
-
const mainDataSourceUri = ((_a = app_info_1.getMainServiceDataSource(manifest)) === null || _a === void 0 ? void 0 : _a.uri) || '';
|
|
27
|
-
const oDataSources = app_info_1.getODataSources(manifest);
|
|
24
|
+
const fs = params.fs || (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
|
|
25
|
+
const manifest = JSON.parse(fs.read((0, path_1.join)(params.webappPath, 'manifest.json')));
|
|
26
|
+
const mainDataSourceUri = ((_a = (0, app_info_1.getMainServiceDataSource)(manifest)) === null || _a === void 0 ? void 0 : _a.uri) || '';
|
|
27
|
+
const oDataSources = (0, app_info_1.getODataSources)(manifest);
|
|
28
28
|
const choices = [];
|
|
29
29
|
for (const dsName in oDataSources) {
|
|
30
30
|
choices.push({
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sap-ux/mockserver-config-writer",
|
|
3
3
|
"description": "Add or update configuration for SAP Fiori tools mockserver",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.6",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/SAP/open-ux-tools.git",
|
|
@@ -19,13 +19,13 @@
|
|
|
19
19
|
"!dist/**/*.map"
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@sap-ux/ui5-config": "0.16.
|
|
22
|
+
"@sap-ux/ui5-config": "0.16.4",
|
|
23
23
|
"i18next": "20.3.2",
|
|
24
24
|
"mem-fs": "2.1.0",
|
|
25
25
|
"mem-fs-editor": "9.4.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@sap-ux/project-access": "1.
|
|
28
|
+
"@sap-ux/project-access": "1.1.3",
|
|
29
29
|
"@types/mem-fs": "1.1.2",
|
|
30
30
|
"@types/mem-fs-editor": "7.0.1",
|
|
31
31
|
"@types/prompts": "2.0.14",
|