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

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.
@@ -133,7 +133,7 @@ async function createCAPMTAAppFrontend(config, fs) {
133
133
  mtaVersion: config.mtaVersion ?? MTAVersion
134
134
  });
135
135
  // Add missing configurations
136
- addXSSecurityConfig(config, fs, false);
136
+ addXSSecurityConfig(config, fs);
137
137
  LoggerHelper.logger?.debug(t('debug.mtaCreated', { mtaPath: config.mtaPath }));
138
138
  }
139
139
  /**
@@ -161,7 +161,7 @@ export class MtaConfig {
161
161
  path: './xs-security.json',
162
162
  'service-name': `${this.prefix?.slice(0, MAX_MTA_PREFIX_LENGTH)}-xsuaa-service`,
163
163
  config: {
164
- xsappname: `${this.prefix?.slice(0, MAX_MTA_PREFIX_LENGTH)}` + '-${space-guid}',
164
+ xsappname: `${this.prefix?.slice(0, MAX_MTA_PREFIX_LENGTH)}-\${org}-\${space}`,
165
165
  'tenant-mode': 'dedicated'
166
166
  }
167
167
  }
@@ -338,14 +338,10 @@ export class MtaConfig {
338
338
  service: 'xsuaa',
339
339
  'service-name': `${this.prefix?.slice(0, MAX_MTA_PREFIX_LENGTH)}-xsuaa-service`,
340
340
  'service-plan': 'application',
341
- ...(this.modules.has('nodejs') && this.modules.has('com.sap.application.content:appfront')
342
- ? {
343
- config: {
344
- xsappname: `${this.prefix?.slice(0, MAX_MTA_PREFIX_LENGTH)}-\${org}-\${space}`,
345
- 'tenant-mode': 'dedicated'
346
- }
347
- }
348
- : {})
341
+ config: {
342
+ xsappname: `${this.prefix?.slice(0, MAX_MTA_PREFIX_LENGTH)}-\${org}-\${space}`,
343
+ 'tenant-mode': 'dedicated'
344
+ }
349
345
  }
350
346
  };
351
347
  await this.mta?.addResource(resource);
package/dist/utils.d.ts CHANGED
@@ -76,11 +76,9 @@ export declare function validateVersion(mtaVersion?: string): boolean;
76
76
  *
77
77
  * @param config MTA base configuration
78
78
  * @param config.mtaPath Path to the MTA project
79
- * @param config.mtaId MTA ID used for security configuration
80
79
  * @param fs Reference to a mem-fs editor
81
- * @param addTenant If true, append tenant configuration to the xs-security.json file (default: true)
82
80
  */
83
- export declare function addXSSecurityConfig({ mtaPath, mtaId }: MTABaseConfig, fs: Editor, addTenant?: boolean): void;
81
+ export declare function addXSSecurityConfig({ mtaPath }: MTABaseConfig, fs: Editor): void;
84
82
  /**
85
83
  * Appends .gitignore to project folder.
86
84
  *
@@ -109,9 +107,8 @@ export declare function addCommonPackageDependencies(targetPath: string, fs: Edi
109
107
  *
110
108
  * @param config Writer configuration
111
109
  * @param fs Reference to a mem-fs editor
112
- * @param addTenant If true, append tenant configuration to the xs-security.json file (default: true)
113
110
  */
114
- export declare function generateSupportingConfig(config: MTABaseConfig, fs: Editor, addTenant?: boolean): Promise<void>;
111
+ export declare function generateSupportingConfig(config: MTABaseConfig, fs: Editor): Promise<void>;
115
112
  /**
116
113
  * Update the writer configuration with defaults.
117
114
  *
package/dist/utils.js CHANGED
@@ -3,7 +3,7 @@ import { coerce, satisfies } from 'semver';
3
3
  import { CommandRunner } from '@sap-ux/nodejs-utils';
4
4
  import { isAppStudio, listDestinations, isFullUrlDestination } from '@sap-ux/btp-utils';
5
5
  import { addPackageDevDependency, FileName, updatePackageScript } from '@sap-ux/project-access';
6
- import { MTAVersion, UI5Package, UI5PackageVersion, UI5TaskZipperPackage, UI5TaskZipperPackageVersion, rootDeployMTAScript, undeployMTAScript, Rimraf, RimrafVersion, MbtPackageVersion, MbtPackage, MTABuildScript, CDSDKPackage, CDSPackage, MAX_MTA_PREFIX_LENGTH } from './constants.js';
6
+ import { MTAVersion, UI5Package, UI5PackageVersion, UI5TaskZipperPackage, UI5TaskZipperPackageVersion, rootDeployMTAScript, undeployMTAScript, Rimraf, RimrafVersion, MbtPackageVersion, MbtPackage, MTABuildScript, CDSDKPackage, CDSPackage } from './constants.js';
7
7
  import { fileURLToPath } from 'node:url';
8
8
  /**
9
9
  * Read manifest file for processing.
@@ -104,15 +104,10 @@ export function validateVersion(mtaVersion) {
104
104
  *
105
105
  * @param config MTA base configuration
106
106
  * @param config.mtaPath Path to the MTA project
107
- * @param config.mtaId MTA ID used for security configuration
108
107
  * @param fs Reference to a mem-fs editor
109
- * @param addTenant If true, append tenant configuration to the xs-security.json file (default: true)
110
108
  */
111
- export function addXSSecurityConfig({ mtaPath, mtaId }, fs, addTenant = true) {
112
- fs.copyTpl(getTemplatePath(`common/${FileName.XSSecurityJson}`), join(mtaPath, FileName.XSSecurityJson), {
113
- id: mtaId.slice(0, MAX_MTA_PREFIX_LENGTH),
114
- addTenant
115
- });
109
+ export function addXSSecurityConfig({ mtaPath }, fs) {
110
+ fs.copyTpl(getTemplatePath(`common/${FileName.XSSecurityJson}`), join(mtaPath, FileName.XSSecurityJson), {});
116
111
  }
117
112
  /**
118
113
  * Appends .gitignore to project folder.
@@ -151,14 +146,13 @@ export async function addCommonPackageDependencies(targetPath, fs) {
151
146
  *
152
147
  * @param config Writer configuration
153
148
  * @param fs Reference to a mem-fs editor
154
- * @param addTenant If true, append tenant configuration to the xs-security.json file (default: true)
155
149
  */
156
- export async function generateSupportingConfig(config, fs, addTenant = true) {
150
+ export async function generateSupportingConfig(config, fs) {
157
151
  if (config.mtaId && !fs.exists(join(config.mtaPath, 'package.json'))) {
158
152
  addRootPackage(config, fs);
159
153
  }
160
154
  if (config.mtaId && !fs.exists(join(config.mtaPath, FileName.XSSecurityJson))) {
161
- addXSSecurityConfig(config, fs, addTenant);
155
+ addXSSecurityConfig(config, fs);
162
156
  }
163
157
  // Be a good citizen and add a .gitignore if missing from the existing project root
164
158
  if (!fs.exists(join(config.mtaPath, '.gitignore'))) {
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.10",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SAP/open-ux-tools.git",
@@ -1,7 +1,6 @@
1
- {<% if (addTenant) { %>
2
- "xsappname": "<%- id %>",
3
- "tenant-mode": "dedicated",<% } %>
1
+ {
4
2
  "description": "Security profile of called application",
5
3
  "scopes": [],
4
+ "attributes": [],
6
5
  "role-templates": []
7
6
  }