@sap-ux/cf-deploy-config-writer 0.2.10 → 0.2.12

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.
@@ -157,8 +157,6 @@ async function generateDeployConfig(cfAppConfig, fs) {
157
157
  // Generate MTA Config, LCAP will generate the mta.yaml on the fly so we don't care about it!
158
158
  if (!config.lcapMode) {
159
159
  await generateMTAFile(config, fs);
160
- await (0, utils_1.generateSupportingConfig)(config, fs);
161
- await updateMtaConfig(config, fs);
162
160
  }
163
161
  // Generate HTML5 config
164
162
  await appendCloudFoundryConfigurations(config, fs);
@@ -175,6 +173,7 @@ async function generateDeployConfig(cfAppConfig, fs) {
175
173
  * @param fs reference to a mem-fs editor
176
174
  */
177
175
  async function generateMTAFile(cfConfig, fs) {
176
+ // Step1. Create mta.yaml
178
177
  if (!cfConfig.mtaId) {
179
178
  if (cfConfig.isCap) {
180
179
  await (0, mta_config_1.generateCAPMTA)({ ...cfConfig, mtaPath: cfConfig.rootPath }, fs);
@@ -185,14 +184,18 @@ async function generateMTAFile(cfConfig, fs) {
185
184
  cfConfig.mtaId = cfConfig.appId;
186
185
  cfConfig.mtaPath = cfConfig.rootPath;
187
186
  }
187
+ // Step2. Append the approuter and destination to mta.yaml
188
+ await appendAppRouter(cfConfig, fs);
189
+ // Step3. Create any missing resources like package.json / xs-security.json / .gitignore
190
+ await (0, utils_1.generateSupportingConfig)(cfConfig, fs);
188
191
  }
189
192
  /**
190
- * Updates the MTA configuration file.
193
+ * Updates the MTA configuration file with the app router and destination.
191
194
  *
192
195
  * @param cfConfig writer configuration
193
196
  * @param fs reference to a mem-fs editor
194
197
  */
195
- async function updateMtaConfig(cfConfig, fs) {
198
+ async function appendAppRouter(cfConfig, fs) {
196
199
  const mtaInstance = await (0, mta_config_1.getMtaConfig)(cfConfig.rootPath);
197
200
  if (mtaInstance) {
198
201
  await mtaInstance.addRoutingModules({
@@ -203,23 +206,13 @@ async function updateMtaConfig(cfConfig, fs) {
203
206
  const appModule = cfConfig.appId;
204
207
  const appRelativePath = (0, utils_1.toPosixPath)((0, path_1.relative)(cfConfig.rootPath, cfConfig.appPath));
205
208
  await mtaInstance.addApp(appModule, appRelativePath ?? '.');
206
- if (mtaInstance.hasAppFrontendRouter()) {
207
- cfConfig.addAppFrontendRouter = true;
208
- }
209
- await (0, mta_config_1.addMtaDeployParameters)(mtaInstance);
210
209
  if ((cfConfig.addMtaDestination && cfConfig.isCap) || cfConfig.destinationName === constants_1.DefaultMTADestination) {
211
210
  // If the destination instance identifier is passed, create a destination instance
212
211
  cfConfig.destinationName =
213
212
  cfConfig.destinationName === constants_1.DefaultMTADestination
214
213
  ? mtaInstance.getFormattedPrefix(constants_1.ResourceMTADestination)
215
214
  : cfConfig.destinationName;
216
- if (cfConfig.addAppFrontendRouter) {
217
- // Append destination directly to app frontend
218
- await mtaInstance.appendAppfrontCAPDestination(cfConfig.destinationName);
219
- }
220
- else {
221
- await mtaInstance.appendInstanceBasedDestination(cfConfig.destinationName);
222
- }
215
+ await mtaInstance.addDestinationToAppRouter(cfConfig.destinationName);
223
216
  // This is required where a managed or standalone router hasn't been added yet to mta.yaml
224
217
  if (!mtaInstance.hasManagedXsuaaResource()) {
225
218
  cfConfig.destinationAuthentication = btp_utils_1.Authentication.NO_AUTHENTICATION;
@@ -227,7 +220,9 @@ async function updateMtaConfig(cfConfig, fs) {
227
220
  }
228
221
  cleanupStandaloneRoutes(cfConfig, mtaInstance, fs);
229
222
  await saveMta(cfConfig, mtaInstance);
223
+ // Modify existing config, required in later steps
230
224
  cfConfig.cloudServiceName = mtaInstance.cloudServiceName;
225
+ cfConfig.addAppFrontendRouter = mtaInstance.hasAppFrontendRouter();
231
226
  }
232
227
  }
233
228
  /**
@@ -2,7 +2,7 @@ import { type Editor } from 'mem-fs-editor';
2
2
  import { type Logger } from '@sap-ux/logger';
3
3
  import { type CFBaseConfig } from '../types';
4
4
  /**
5
- * Add a standalone | managed | app frontend approuter to an empty target folder.
5
+ * Add a standalone | managed | frontend app router to an empty target folder.
6
6
  *
7
7
  * @param config writer configuration
8
8
  * @param fs an optional reference to a mem-fs editor
@@ -4,15 +4,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.generateBaseConfig = generateBaseConfig;
7
+ const path_1 = require("path");
7
8
  const mem_fs_1 = require("mem-fs");
8
9
  const mem_fs_editor_1 = require("mem-fs-editor");
9
10
  const utils_1 = require("../utils");
10
11
  const logger_helper_1 = __importDefault(require("../logger-helper"));
11
12
  const mta_config_1 = require("../mta-config");
12
- const path_1 = require("path");
13
13
  const i18n_1 = require("../i18n");
14
14
  /**
15
- * Add a standalone | managed | app frontend approuter to an empty target folder.
15
+ * Add a standalone | managed | frontend app router to an empty target folder.
16
16
  *
17
17
  * @param config writer configuration
18
18
  * @param fs an optional reference to a mem-fs editor
@@ -33,7 +33,7 @@ async function generateBaseConfig(config, fs, logger) {
33
33
  }
34
34
  (0, mta_config_1.createMTA)(config);
35
35
  await (0, mta_config_1.addRoutingConfig)(config, fs);
36
- (0, utils_1.addSupportingConfig)(config, fs);
36
+ await (0, utils_1.generateSupportingConfig)(config, fs);
37
37
  logger_helper_1.default.logger?.debug(`CF Config ${JSON.stringify(config, null, 2)}`);
38
38
  return fs;
39
39
  }
@@ -28,18 +28,6 @@ export declare function toMtaModuleName(appId: string): string;
28
28
  * @param config writer configuration
29
29
  */
30
30
  export declare function createMTA(config: MTABaseConfig): void;
31
- /**
32
- * Add the build parameters to the MTA configuration.
33
- *
34
- * @param mtaInstance MTA instance
35
- */
36
- export declare function addMtaBuildParams(mtaInstance: MtaConfig): Promise<void>;
37
- /**
38
- * Add the deployment parameters to the MTA configuration.
39
- *
40
- * @param mtaInstance MTA instance
41
- */
42
- export declare function addMtaDeployParameters(mtaInstance: MtaConfig): Promise<void>;
43
31
  /**
44
32
  * Validate MTA binary is available.
45
33
  *
@@ -57,7 +45,7 @@ export declare function doesCDSBinaryExist(): void;
57
45
  */
58
46
  export declare function validateMtaConfig(config: CFBaseConfig): void;
59
47
  /**
60
- * Add standalone | managed | appfront approuter to the target folder.
48
+ * Add standalone | managed | frontend app router to the target folder.
61
49
  *
62
50
  * @param config writer configuration
63
51
  * @param fs reference to a mem-fs editor
@@ -21,8 +21,6 @@ exports.getMtaId = getMtaId;
21
21
  exports.getMtaConfig = getMtaConfig;
22
22
  exports.toMtaModuleName = toMtaModuleName;
23
23
  exports.createMTA = createMTA;
24
- exports.addMtaBuildParams = addMtaBuildParams;
25
- exports.addMtaDeployParameters = addMtaDeployParameters;
26
24
  exports.doesMTABinaryExist = doesMTABinaryExist;
27
25
  exports.doesCDSBinaryExist = doesCDSBinaryExist;
28
26
  exports.validateMtaConfig = validateMtaConfig;
@@ -87,41 +85,18 @@ function toMtaModuleName(appId) {
87
85
  * @param config writer configuration
88
86
  */
89
87
  function createMTA(config) {
88
+ const mtaId = `${config.mtaId.slice(0, 128)}`;
90
89
  const mtaTemplate = (0, fs_1.readFileSync)((0, utils_1.getTemplatePath)(`app/${project_access_1.FileName.MtaYaml}`), 'utf-8');
91
90
  const mtaContents = (0, ejs_1.render)(mtaTemplate, {
92
- id: `${config.mtaId.slice(0, 128)}`,
91
+ id: mtaId,
93
92
  mtaDescription: config.mtaDescription ?? constants_1.MTADescription,
94
93
  mtaVersion: config.mtaVersion ?? constants_1.MTAVersion
95
94
  });
95
+ config.mtaId = mtaId;
96
96
  // Written to disk immediately! Subsequent calls are dependent on it being on the file system i.e mta-lib.
97
97
  (0, fs_1.writeFileSync)((0, path_1.join)(config.mtaPath, project_access_1.FileName.MtaYaml), mtaContents);
98
98
  logger_helper_1.default.logger?.debug((0, i18n_1.t)('debug.mtaCreated', { mtaPath: config.mtaPath }));
99
99
  }
100
- /**
101
- * Add the build parameters to the MTA configuration.
102
- *
103
- * @param mtaInstance MTA instance
104
- */
105
- async function addMtaBuildParams(mtaInstance) {
106
- let params = await mtaInstance.getBuildParameters();
107
- params = { ...(params || {}), ...{} };
108
- params['before-all'] ||= [];
109
- const buildParams = { builder: 'custom', commands: ['npm install'] };
110
- params['before-all'].push(buildParams);
111
- await mtaInstance.updateBuildParams(params);
112
- }
113
- /**
114
- * Add the deployment parameters to the MTA configuration.
115
- *
116
- * @param mtaInstance MTA instance
117
- */
118
- async function addMtaDeployParameters(mtaInstance) {
119
- let params = await mtaInstance.getParameters();
120
- params = { ...(params || {}), ...{} };
121
- params[constants_1.deployMode] = 'html5-repo';
122
- params[constants_1.enableParallelDeployments] = true;
123
- await mtaInstance.updateParameters(params);
124
- }
125
100
  /**
126
101
  * Validate MTA binary is available.
127
102
  *
@@ -189,7 +164,7 @@ async function createCAPMTAAppFrontend(config, fs) {
189
164
  logger_helper_1.default.logger?.debug((0, i18n_1.t)('debug.mtaCreated', { mtaPath: config.mtaPath }));
190
165
  }
191
166
  /**
192
- * Add standalone approuter to the target folder.
167
+ * Add standalone app router to the target folder.
193
168
  *
194
169
  * @param cfConfig writer configuration
195
170
  * @param mtaInstance MTA configuration instance
@@ -223,7 +198,7 @@ async function addStandaloneRouter(cfConfig, mtaInstance, fs) {
223
198
  }
224
199
  }
225
200
  /**
226
- * Add standalone | managed | appfront approuter to the target folder.
201
+ * Add standalone | managed | frontend app router to the target folder.
227
202
  *
228
203
  * @param config writer configuration
229
204
  * @param fs reference to a mem-fs editor
@@ -237,7 +212,6 @@ async function addRoutingConfig(config, fs) {
237
212
  else {
238
213
  await mtaConfigInstance.addRouterType({ routerType: config.routerType, addMissingModules: false });
239
214
  }
240
- await addMtaDeployParameters(mtaConfigInstance);
241
215
  await mtaConfigInstance.save();
242
216
  logger_helper_1.default.logger?.debug((0, i18n_1.t)('debug.capMtaUpdated'));
243
217
  }
@@ -236,19 +236,26 @@ export declare class MtaConfig {
236
236
  key: string;
237
237
  value: string;
238
238
  }): Promise<void>;
239
+ /**
240
+ * Add a destination to the approuter.
241
+ *
242
+ * @param cfDestination The name of the destination to be appended
243
+ * @returns {void}
244
+ */
245
+ addDestinationToAppRouter(cfDestination: string | undefined): Promise<void>;
239
246
  /**
240
247
  * Add destination to App Frontend router.
241
248
  *
242
249
  * @param cfDestination Then name of the destination to be appended
243
250
  */
244
- appendAppfrontCAPDestination(cfDestination: string | undefined): Promise<void>;
251
+ private appendAppfrontCAPDestination;
245
252
  /**
246
253
  * Append a destination instance to the mta.yaml file, required by consumers of CAP services when using Standalone or Managed approuter.
247
254
  *
248
255
  * @param {string} cfDestination The new destination instance name
249
256
  * @returns {Promise<void>} A promise that resolves when the change request has been processed
250
257
  */
251
- appendInstanceBasedDestination(cfDestination: string | undefined): Promise<void>;
258
+ private appendInstanceBasedDestination;
252
259
  /**
253
260
  * Save changes to the mta.yaml file.
254
261
  *
@@ -280,11 +287,21 @@ export declare class MtaConfig {
280
287
  */
281
288
  getFormattedPrefix(formatString: string): string;
282
289
  /**
283
- * Retrieve the app-content module, different types can be found.
290
+ * Retrieve the app-content module, different types can be found depending on the router type configuration.
284
291
  *
285
292
  * @returns {mta.Module} return the app-content module
286
293
  */
287
294
  private getAppContentModule;
295
+ /**
296
+ * Add the build parameters to the MTA configuration.
297
+ *
298
+ */
299
+ addMtaBuildParameters(): Promise<void>;
300
+ /**
301
+ * Add the deployment parameters to the MTA configuration.
302
+ *
303
+ */
304
+ addMtaDeployParameters(): Promise<void>;
288
305
  }
289
306
  /**
290
307
  * Returns true if there's an MTA configuration file in the supplied directory.
@@ -520,6 +520,7 @@ class MtaConfig {
520
520
  this.log?.debug((0, i18n_1.t)('debug.html5AppAdded', { appName }));
521
521
  }
522
522
  await this.syncHtml5Apps();
523
+ await this.addMtaDeployParameters();
523
524
  }
524
525
  async syncHtml5Apps() {
525
526
  // Need to handle where existing HTML5 apps are added by `cds` which follow a different naming convention when added to mta
@@ -596,6 +597,7 @@ class MtaConfig {
596
597
  }
597
598
  await this.cleanupModules();
598
599
  }
600
+ await this.addMtaDeployParameters();
599
601
  }
600
602
  /**
601
603
  * Append different routers to mta configuration.
@@ -801,6 +803,21 @@ class MtaConfig {
801
803
  }
802
804
  }
803
805
  }
806
+ /**
807
+ * Add a destination to the approuter.
808
+ *
809
+ * @param cfDestination The name of the destination to be appended
810
+ * @returns {void}
811
+ */
812
+ async addDestinationToAppRouter(cfDestination) {
813
+ if (this.hasAppFrontendRouter()) {
814
+ // Append destination directly to app frontend
815
+ await this.appendAppfrontCAPDestination(cfDestination);
816
+ }
817
+ else {
818
+ await this.appendInstanceBasedDestination(cfDestination);
819
+ }
820
+ }
804
821
  /**
805
822
  * Add destination to App Frontend router.
806
823
  *
@@ -1039,7 +1056,7 @@ class MtaConfig {
1039
1056
  return (0, util_1.format)(formatString, this.prefix).replace(/[^\w-]/g, '_');
1040
1057
  }
1041
1058
  /**
1042
- * Retrieve the app-content module, different types can be found.
1059
+ * Retrieve the app-content module, different types can be found depending on the router type configuration.
1043
1060
  *
1044
1061
  * @returns {mta.Module} return the app-content module
1045
1062
  */
@@ -1048,6 +1065,30 @@ class MtaConfig {
1048
1065
  return (this.modules.get('com.sap.application.content:resource') ??
1049
1066
  this.modules.get('com.sap.application.content:appfront'));
1050
1067
  }
1068
+ /**
1069
+ * Add the build parameters to the MTA configuration.
1070
+ *
1071
+ */
1072
+ async addMtaBuildParameters() {
1073
+ const params = (await this.getBuildParameters()) ?? {};
1074
+ params['before-all'] ??= [];
1075
+ params['before-all'].push({
1076
+ builder: 'custom',
1077
+ commands: ['npm install']
1078
+ });
1079
+ await this.updateBuildParams(params);
1080
+ }
1081
+ /**
1082
+ * Add the deployment parameters to the MTA configuration.
1083
+ *
1084
+ */
1085
+ async addMtaDeployParameters() {
1086
+ let params = await this.getParameters();
1087
+ params = { ...(params ?? {}), ...{} };
1088
+ params[constants_1.deployMode] = 'html5-repo';
1089
+ params[constants_1.enableParallelDeployments] = true;
1090
+ await this.updateParameters(params);
1091
+ }
1051
1092
  }
1052
1093
  exports.MtaConfig = MtaConfig;
1053
1094
  /**
package/dist/utils.d.ts CHANGED
@@ -1,7 +1,7 @@
1
+ import type { Editor } from 'mem-fs-editor';
1
2
  import { type Authentication, type Destinations } from '@sap-ux/btp-utils';
2
3
  import { type Manifest } from '@sap-ux/project-access';
3
- import type { Editor } from 'mem-fs-editor';
4
- import { type MTABaseConfig, type CFConfig, type CFBaseConfig, type CFAppConfig } from './types';
4
+ import { type MTABaseConfig, type CFBaseConfig, type CFAppConfig } from './types';
5
5
  /**
6
6
  * Read manifest file for processing.
7
7
  *
@@ -56,13 +56,14 @@ export declare function getBTPDestinations(): Promise<Destinations>;
56
56
  */
57
57
  export declare function validateVersion(mtaVersion?: string): boolean;
58
58
  /**
59
- * Append xs-security.json to project folder.
59
+ * Appends xs-security.json to the project folder.
60
60
  *
61
- * @param root0 MTA base configuration
62
- * @param root0.mtaPath Path to the MTA project
63
- * @param root0.mtaId MTA ID
64
- * @param fs reference to a mem-fs editor
65
- * @param addTenant If true, append tenant to the xs-security.json file
61
+ * @param {MTABaseConfig} config - MTA base configuration
62
+ * @param {string} config.mtaPath - Path to the MTA project
63
+ * @param {string} config.mtaId - MTA ID
64
+ * @param {Editor} fs - Reference to a mem-fs editor
65
+ * @param {boolean} [addTenant] - If true, append tenant to the xs-security.json file
66
+ * @returns {void}
66
67
  */
67
68
  export declare function addXSSecurityConfig({ mtaPath, mtaId }: MTABaseConfig, fs: Editor, addTenant?: boolean): void;
68
69
  /**
@@ -73,12 +74,13 @@ export declare function addXSSecurityConfig({ mtaPath, mtaId }: MTABaseConfig, f
73
74
  */
74
75
  export declare function addGitIgnore(targetPath: string, fs: Editor): void;
75
76
  /**
76
- * Append server package.json to project folder.
77
+ * Appends server package.json to the project folder.
77
78
  *
78
- * @param root0 MTA base configuration
79
- * @param root0.mtaPath Path to the MTA project
80
- * @param root0.mtaId MTA ID
81
- * @param fs reference to a mem-fs editor
79
+ * @param {MTABaseConfig} config - MTA base configuration
80
+ * @param {string} config.mtaPath - Path to the MTA project
81
+ * @param {string} config.mtaId - MTA ID
82
+ * @param {Editor} fs - Reference to a mem-fs editor
83
+ * @returns {void}
82
84
  */
83
85
  export declare function addRootPackage({ mtaPath, mtaId }: MTABaseConfig, fs: Editor): void;
84
86
  /**
@@ -93,15 +95,9 @@ export declare function addCommonPackageDependencies(targetPath: string, fs: Edi
93
95
  *
94
96
  * @param config writer configuration
95
97
  * @param fs reference to a mem-fs editor
98
+ * @param addTenant If true, append tenant to the xs-security.json file
96
99
  */
97
- export declare function generateSupportingConfig(config: CFConfig, fs: Editor): Promise<void>;
98
- /**
99
- * Add supporting configuration to the target folder.
100
- *
101
- * @param config writer configuration
102
- * @param fs reference to a mem-fs editor
103
- */
104
- export declare function addSupportingConfig(config: MTABaseConfig, fs: Editor): void;
100
+ export declare function generateSupportingConfig(config: MTABaseConfig, fs: Editor, addTenant?: boolean): Promise<void>;
105
101
  /**
106
102
  * Update the writer configuration with defaults.
107
103
  *
package/dist/utils.js CHANGED
@@ -12,7 +12,6 @@ exports.addGitIgnore = addGitIgnore;
12
12
  exports.addRootPackage = addRootPackage;
13
13
  exports.addCommonPackageDependencies = addCommonPackageDependencies;
14
14
  exports.generateSupportingConfig = generateSupportingConfig;
15
- exports.addSupportingConfig = addSupportingConfig;
16
15
  exports.setMtaDefaults = setMtaDefaults;
17
16
  exports.updateRootPackage = updateRootPackage;
18
17
  exports.enforceValidRouterConfig = enforceValidRouterConfig;
@@ -21,10 +20,10 @@ exports.runCommand = runCommand;
21
20
  exports.fileExists = fileExists;
22
21
  const path_1 = require("path");
23
22
  const semver_1 = require("semver");
23
+ const nodejs_utils_1 = require("@sap-ux/nodejs-utils");
24
24
  const btp_utils_1 = require("@sap-ux/btp-utils");
25
25
  const project_access_1 = require("@sap-ux/project-access");
26
26
  const constants_1 = require("./constants");
27
- const nodejs_utils_1 = require("@sap-ux/nodejs-utils");
28
27
  let cachedDestinationsList = {};
29
28
  /**
30
29
  * Read manifest file for processing.
@@ -107,13 +106,14 @@ function validateVersion(mtaVersion) {
107
106
  return true;
108
107
  }
109
108
  /**
110
- * Append xs-security.json to project folder.
109
+ * Appends xs-security.json to the project folder.
111
110
  *
112
- * @param root0 MTA base configuration
113
- * @param root0.mtaPath Path to the MTA project
114
- * @param root0.mtaId MTA ID
115
- * @param fs reference to a mem-fs editor
116
- * @param addTenant If true, append tenant to the xs-security.json file
111
+ * @param {MTABaseConfig} config - MTA base configuration
112
+ * @param {string} config.mtaPath - Path to the MTA project
113
+ * @param {string} config.mtaId - MTA ID
114
+ * @param {Editor} fs - Reference to a mem-fs editor
115
+ * @param {boolean} [addTenant] - If true, append tenant to the xs-security.json file
116
+ * @returns {void}
117
117
  */
118
118
  function addXSSecurityConfig({ mtaPath, mtaId }, fs, addTenant = true) {
119
119
  fs.copyTpl(getTemplatePath(`common/${project_access_1.FileName.XSSecurityJson}`), (0, path_1.join)(mtaPath, project_access_1.FileName.XSSecurityJson), {
@@ -131,16 +131,17 @@ function addGitIgnore(targetPath, fs) {
131
131
  fs.copyTpl(getTemplatePath('gitignore.tmpl'), (0, path_1.join)(targetPath, project_access_1.FileName.DotGitIgnore), {});
132
132
  }
133
133
  /**
134
- * Append server package.json to project folder.
134
+ * Appends server package.json to the project folder.
135
135
  *
136
- * @param root0 MTA base configuration
137
- * @param root0.mtaPath Path to the MTA project
138
- * @param root0.mtaId MTA ID
139
- * @param fs reference to a mem-fs editor
136
+ * @param {MTABaseConfig} config - MTA base configuration
137
+ * @param {string} config.mtaPath - Path to the MTA project
138
+ * @param {string} config.mtaId - MTA ID
139
+ * @param {Editor} fs - Reference to a mem-fs editor
140
+ * @returns {void}
140
141
  */
141
142
  function addRootPackage({ mtaPath, mtaId }, fs) {
142
143
  fs.copyTpl(getTemplatePath(project_access_1.FileName.Package), (0, path_1.join)(mtaPath, project_access_1.FileName.Package), {
143
- mtaId: mtaId
144
+ mtaId
144
145
  });
145
146
  }
146
147
  /**
@@ -158,33 +159,20 @@ async function addCommonPackageDependencies(targetPath, fs) {
158
159
  *
159
160
  * @param config writer configuration
160
161
  * @param fs reference to a mem-fs editor
162
+ * @param addTenant If true, append tenant to the xs-security.json file
161
163
  */
162
- async function generateSupportingConfig(config, fs) {
163
- const mtaConfig = { mtaId: config.mtaId, mtaPath: config.rootPath };
164
- if (mtaConfig.mtaId && !fileExists(fs, (0, path_1.join)(config.rootPath, project_access_1.FileName.Package))) {
165
- addRootPackage(mtaConfig, fs);
164
+ async function generateSupportingConfig(config, fs, addTenant = true) {
165
+ if (config.mtaId && !fs.exists((0, path_1.join)(config.mtaPath, 'package.json'))) {
166
+ addRootPackage(config, fs);
166
167
  }
167
- if ((config.addManagedAppRouter || config.addAppFrontendRouter) &&
168
- mtaConfig.mtaId &&
169
- !fileExists(fs, (0, path_1.join)(config.rootPath, project_access_1.FileName.XSSecurityJson))) {
170
- addXSSecurityConfig(mtaConfig, fs, true);
168
+ if (config.mtaId && !fs.exists((0, path_1.join)(config.mtaPath, project_access_1.FileName.XSSecurityJson))) {
169
+ addXSSecurityConfig(config, fs, addTenant);
171
170
  }
172
171
  // Be a good citizen and add a .gitignore if missing from the existing project root
173
- if (!fileExists(fs, (0, path_1.join)(config.rootPath, project_access_1.FileName.DotGitIgnore))) {
174
- addGitIgnore(config.rootPath, fs);
172
+ if (!fs.exists((0, path_1.join)(config.mtaPath, '.gitignore'))) {
173
+ addGitIgnore(config.mtaPath, fs);
175
174
  }
176
175
  }
177
- /**
178
- * Add supporting configuration to the target folder.
179
- *
180
- * @param config writer configuration
181
- * @param fs reference to a mem-fs editor
182
- */
183
- function addSupportingConfig(config, fs) {
184
- addRootPackage(config, fs);
185
- addGitIgnore(config.mtaPath, fs);
186
- addXSSecurityConfig(config, fs);
187
- }
188
176
  /**
189
177
  * Update the writer configuration with defaults.
190
178
  *
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": "0.2.10",
4
+ "version": "0.2.12",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SAP/open-ux-tools.git",
@@ -1,5 +1,5 @@
1
1
  {
2
- "name": "mta-project",
2
+ "name": "<%- mtaId %>",
3
3
  "version": "0.0.1",
4
4
  "description": "Build and deployment scripts",
5
5
  "scripts": {