@sap-ux/odata-service-writer 0.27.35 → 0.27.36
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/update.js +53 -26
- package/package.json +1 -1
package/dist/update.js
CHANGED
|
@@ -63,49 +63,73 @@ function extendBackendMiddleware(fs, service, ui5Config, ui5ConfigPath, update =
|
|
|
63
63
|
fs.write(ui5ConfigPath, ui5Config.toString());
|
|
64
64
|
}
|
|
65
65
|
/**
|
|
66
|
-
*
|
|
67
|
-
* Mockserver configuration for services and annotations are written using dataSources from manifest.json.
|
|
68
|
-
* At the end, XML files for service annotations are created.
|
|
66
|
+
* Updates UI5 YAML configurations with backend middleware.
|
|
69
67
|
*
|
|
70
|
-
* @param
|
|
71
|
-
* @param
|
|
72
|
-
* @param
|
|
73
|
-
* @
|
|
74
|
-
* @param {Editor} fs - the memfs editor instance
|
|
68
|
+
* @param fs - the memfs editor instance
|
|
69
|
+
* @param service - the OData service instance
|
|
70
|
+
* @param paths - paths to the project files
|
|
71
|
+
* @returns Object containing ui5Config and ui5LocalConfig instances
|
|
75
72
|
*/
|
|
76
|
-
async function
|
|
73
|
+
async function updateUI5YamlConfigs(fs, service, paths) {
|
|
77
74
|
let ui5Config;
|
|
78
75
|
let ui5LocalConfig;
|
|
79
|
-
let ui5MockConfig;
|
|
80
76
|
if (paths.ui5Yaml) {
|
|
81
77
|
ui5Config = await ui5_config_1.UI5Config.newInstance(fs.read(paths.ui5Yaml));
|
|
82
|
-
// Update ui5.yaml with backend middleware
|
|
83
78
|
extendBackendMiddleware(fs, service, ui5Config, paths.ui5Yaml);
|
|
84
|
-
// Update ui5-local.yaml with backend middleware
|
|
85
79
|
if (paths.ui5LocalYaml) {
|
|
86
80
|
ui5LocalConfig = await ui5_config_1.UI5Config.newInstance(fs.read(paths.ui5LocalYaml));
|
|
87
81
|
extendBackendMiddleware(fs, service, ui5LocalConfig, paths.ui5LocalYaml);
|
|
88
82
|
}
|
|
89
83
|
}
|
|
84
|
+
return { ui5Config, ui5LocalConfig };
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Generates mockserver configuration and updates related YAML files.
|
|
88
|
+
*
|
|
89
|
+
* @param basePath - the root path of an existing UI5 application
|
|
90
|
+
* @param paths - paths to the project files
|
|
91
|
+
* @param service - the OData service instance
|
|
92
|
+
* @param webappPath - path to webapp folder
|
|
93
|
+
* @param ui5LocalConfig - ui5-local.yaml configuration
|
|
94
|
+
* @param fs - the memfs editor instance
|
|
95
|
+
*/
|
|
96
|
+
async function generateAndUpdateMockserverConfig(basePath, paths, service, webappPath, ui5LocalConfig, fs) {
|
|
97
|
+
const config = {
|
|
98
|
+
webappPath: webappPath,
|
|
99
|
+
ui5MockYamlConfig: {}
|
|
100
|
+
};
|
|
101
|
+
if (config.ui5MockYamlConfig && service.name && service.externalServices?.length) {
|
|
102
|
+
config.ui5MockYamlConfig.resolveExternalServiceReferences = {
|
|
103
|
+
[service.name]: true
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
await (0, mockserver_config_writer_1.generateMockserverConfig)(basePath, config, fs);
|
|
107
|
+
await generateMockserverMiddlewareBasedOnUi5MockYaml(fs, paths.ui5Yaml, paths.ui5LocalYaml, ui5LocalConfig);
|
|
108
|
+
if (paths.ui5MockYaml) {
|
|
109
|
+
const ui5MockConfig = await ui5_config_1.UI5Config.newInstance(fs.read(paths.ui5MockYaml));
|
|
110
|
+
extendBackendMiddleware(fs, service, ui5MockConfig, paths.ui5MockYaml);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Adds services data to ui5-*.yaml files.
|
|
115
|
+
* Mockserver configuration for services and annotations are written using dataSources from manifest.json.
|
|
116
|
+
* At the end, XML files for service annotations are created.
|
|
117
|
+
*
|
|
118
|
+
* @param {string} basePath - the root path of an existing UI5 application
|
|
119
|
+
* @param {ProjectPaths} paths - paths to the project files (package.json, ui5.yaml, ui5-local.yaml and ui5-mock.yaml)
|
|
120
|
+
* @param {string} templateRoot - path to the file templates
|
|
121
|
+
* @param {EdmxOdataService} service - the OData service instance
|
|
122
|
+
* @param {Editor} fs - the memfs editor instance
|
|
123
|
+
*/
|
|
124
|
+
async function addServicesData(basePath, paths, templateRoot, service, fs) {
|
|
125
|
+
const { ui5Config, ui5LocalConfig } = await updateUI5YamlConfigs(fs, service, paths);
|
|
126
|
+
const webappPath = await (0, project_access_1.getWebappPath)(basePath, fs);
|
|
90
127
|
if (service.metadata) {
|
|
91
|
-
const webappPath = await (0, project_access_1.getWebappPath)(basePath, fs);
|
|
92
128
|
if (paths.ui5Yaml && ui5Config) {
|
|
93
|
-
|
|
94
|
-
webappPath: webappPath
|
|
95
|
-
};
|
|
96
|
-
// Generate mockserver middleware for ui5-mock.yaml
|
|
97
|
-
await (0, mockserver_config_writer_1.generateMockserverConfig)(basePath, config, fs);
|
|
98
|
-
// Update ui5-local.yaml with mockserver middleware from newly created/updated ui5-mock.yaml
|
|
99
|
-
await generateMockserverMiddlewareBasedOnUi5MockYaml(fs, paths.ui5Yaml, paths.ui5LocalYaml, ui5LocalConfig);
|
|
100
|
-
// Update ui5-mock.yaml with backend middleware
|
|
101
|
-
if (paths.ui5MockYaml) {
|
|
102
|
-
ui5MockConfig = await ui5_config_1.UI5Config.newInstance(fs.read(paths.ui5MockYaml));
|
|
103
|
-
extendBackendMiddleware(fs, service, ui5MockConfig, paths.ui5MockYaml);
|
|
104
|
-
}
|
|
129
|
+
await generateAndUpdateMockserverConfig(basePath, paths, service, webappPath, ui5LocalConfig, fs);
|
|
105
130
|
}
|
|
106
131
|
await (0, annotations_1.writeLocalServiceAnnotationXMLFiles)(fs, webappPath, templateRoot, service);
|
|
107
132
|
}
|
|
108
|
-
// Service is being added - update the package.json update as well, service update should not run the updates of the package.json
|
|
109
133
|
if (paths.packageJson && paths.ui5Yaml) {
|
|
110
134
|
(0, package_1.updatePackageJson)(paths.packageJson, fs, !!service.metadata);
|
|
111
135
|
}
|
|
@@ -113,6 +137,9 @@ async function addServicesData(basePath, paths, templateRoot, service, fs) {
|
|
|
113
137
|
fs.write(paths.ui5LocalYaml, ui5LocalConfig.toString());
|
|
114
138
|
}
|
|
115
139
|
await (0, annotations_1.writeRemoteServiceAnnotationXmlFiles)(fs, basePath, service.name ?? 'mainService', service.annotations);
|
|
140
|
+
if (service.externalServices && webappPath) {
|
|
141
|
+
(0, data_1.writeExternalServiceMetadata)(fs, webappPath, service.externalServices, service.name, service.path);
|
|
142
|
+
}
|
|
116
143
|
}
|
|
117
144
|
/**
|
|
118
145
|
* Updates services data in ui5-*.yaml files.
|
package/package.json
CHANGED