@sap-ux/cf-deploy-config-writer 1.0.8 → 1.0.9

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.
@@ -195,31 +195,33 @@ export async function generateMTAFile(cfConfig, fs) {
195
195
  */
196
196
  async function appendAppRouter(cfConfig, fs) {
197
197
  const mtaInstance = await getMtaConfig(cfConfig.rootPath);
198
- if (mtaInstance) {
199
- await mtaInstance.addRoutingModules({
200
- isManagedApp: cfConfig.addManagedAppRouter,
201
- isAppFrontApp: cfConfig.addAppFrontendRouter,
202
- addMissingModules: !cfConfig.addAppFrontendRouter
203
- });
204
- const appModule = cfConfig.appId;
205
- const appRelativePath = toPosixPath(relative(cfConfig.rootPath, cfConfig.appPath));
206
- await mtaInstance.addApp(appModule, appRelativePath ?? '.');
207
- if ((cfConfig.addMtaDestination && cfConfig.isCap) || cfConfig.destinationName === DefaultMTADestination) {
208
- // If the destination instance identifier is passed, create a destination instance
209
- cfConfig.destinationName =
210
- cfConfig.destinationName === DefaultMTADestination ? SRV_API : cfConfig.destinationName;
211
- await mtaInstance.addDestinationToAppRouter(cfConfig.destinationName);
212
- // This is required where a managed or standalone router hasn't been added yet to mta.yaml
213
- if (!mtaInstance.hasManagedXsuaaResource()) {
214
- cfConfig.destinationAuthentication = Authentication.NO_AUTHENTICATION;
215
- }
216
- }
217
- cleanupStandaloneRoutes(cfConfig, mtaInstance, fs);
218
- await saveMta(cfConfig, mtaInstance);
219
- // Modify existing config, required in later steps
220
- cfConfig.cloudServiceName = mtaInstance.cloudServiceName;
221
- cfConfig.addAppFrontendRouter = mtaInstance.hasAppFrontendRouter();
198
+ if (!mtaInstance) {
199
+ return;
200
+ }
201
+ await mtaInstance.addRoutingModules({
202
+ isManagedApp: cfConfig.addManagedAppRouter,
203
+ isAppFrontApp: cfConfig.addAppFrontendRouter,
204
+ addMissingModules: !cfConfig.addAppFrontendRouter
205
+ });
206
+ const appRelativePath = toPosixPath(relative(cfConfig.rootPath, cfConfig.appPath));
207
+ await mtaInstance.addApp(cfConfig.appId, appRelativePath ?? '.');
208
+ // Resolve destination name before any mutations DefaultMTADestination is a sentinel for "use SRV_API"
209
+ const shouldAddDestination = (!!cfConfig.addMtaDestination && !!cfConfig.isCap) || cfConfig.destinationName === DefaultMTADestination;
210
+ const destinationNameForMta = cfConfig.destinationName === DefaultMTADestination ? SRV_API : cfConfig.destinationName;
211
+ const resolvedDestinationName = shouldAddDestination ? destinationNameForMta : cfConfig.destinationName;
212
+ if (shouldAddDestination) {
213
+ await mtaInstance.addDestinationToAppRouter(resolvedDestinationName);
214
+ }
215
+ cleanupStandaloneRoutes(cfConfig, mtaInstance, fs);
216
+ // Apply all config mutations together once MTA state is finalised
217
+ cfConfig.destinationName = resolvedDestinationName;
218
+ // Required where a managed or standalone router hasn't been added yet to mta.yaml
219
+ if (shouldAddDestination && !mtaInstance.hasManagedXsuaaResource()) {
220
+ cfConfig.destinationAuthentication = Authentication.NO_AUTHENTICATION;
222
221
  }
222
+ cfConfig.cloudServiceName = mtaInstance.cloudServiceName;
223
+ cfConfig.addAppFrontendRouter = mtaInstance.hasAppFrontendRouter();
224
+ await saveMta(cfConfig, mtaInstance);
223
225
  }
224
226
  /**
225
227
  * Cleans up standalone routes in a Cloud Foundry application configuration.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sap-ux/cf-deploy-config-writer",
3
3
  "description": "Add or amend Cloud Foundry and ABAP deployment configuration for SAP projects",
4
- "version": "1.0.8",
4
+ "version": "1.0.9",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SAP/open-ux-tools.git",
@@ -30,12 +30,12 @@
30
30
  "mem-fs": "2.1.0",
31
31
  "mem-fs-editor": "9.4.0",
32
32
  "hasbin": "1.2.3",
33
- "@sap-ux/project-access": "2.1.2",
34
- "@sap-ux/yaml": "1.0.1",
35
33
  "@sap-ux/btp-utils": "2.0.2",
36
34
  "@sap-ux/logger": "1.0.1",
35
+ "@sap-ux/project-access": "2.1.2",
37
36
  "@sap-ux/ui5-config": "1.0.3",
38
- "@sap-ux/nodejs-utils": "1.0.3"
37
+ "@sap-ux/nodejs-utils": "1.0.3",
38
+ "@sap-ux/yaml": "1.0.1"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@jest/globals": "30.3.0",