@sap-ux/cf-deploy-config-writer 0.3.21 → 0.3.22

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.
@@ -58,7 +58,7 @@ class MtaConfig {
58
58
  try {
59
59
  await this.loadMTAResources();
60
60
  await this.loadMTAModules();
61
- this.mtaId = await this.mta.getMtaID();
61
+ this.mtaId = await this.mta?.getMtaID();
62
62
  }
63
63
  catch (error) {
64
64
  this.log?.error((0, i18n_1.t)('error.unableToLoadMTA', { error, mtaDir: this.mtaDir }));
@@ -105,7 +105,7 @@ class MtaConfig {
105
105
  this.log?.debug((0, i18n_1.t)('debug.mtaLoaded', { type: 'resources', size: this.resources.size }));
106
106
  }
107
107
  async loadMTAModules() {
108
- const modules = (await this.mta.getModules()) || [];
108
+ const modules = (await this.mta?.getModules()) || [];
109
109
  modules.forEach((module) => {
110
110
  if (module.type) {
111
111
  if (module.type === 'html5') {
@@ -135,7 +135,7 @@ class MtaConfig {
135
135
  const appHostName = this.resources.get(constants_1.HTML5RepoHost)?.name;
136
136
  if (appHostName) {
137
137
  const appContentModule = {
138
- name: `${this.prefix.slice(0, 100)}-app-content`,
138
+ name: `${this.prefix?.slice(0, 100)}-app-content`,
139
139
  type: 'com.sap.application.content',
140
140
  path: '.',
141
141
  requires: [
@@ -151,32 +151,32 @@ class MtaConfig {
151
151
  requires: []
152
152
  }
153
153
  };
154
- await this.mta.addModule(appContentModule);
154
+ await this.mta?.addModule(appContentModule);
155
155
  this.modules.set('com.sap.application.content:resource', appContentModule);
156
156
  this.dirty = true;
157
157
  }
158
158
  }
159
159
  async addUaa() {
160
160
  const resource = {
161
- name: `${this.prefix.slice(0, 100)}-uaa`,
161
+ name: `${this.prefix?.slice(0, 100)}-uaa`,
162
162
  type: 'org.cloudfoundry.managed-service',
163
163
  parameters: {
164
164
  'service-plan': 'application',
165
165
  service: 'xsuaa',
166
- config: { xsappname: `${this.prefix.slice(0, 100)}` + '-${space-guid}', 'tenant-mode': 'dedicated' }
166
+ config: { xsappname: `${this.prefix?.slice(0, 100)}` + '-${space-guid}', 'tenant-mode': 'dedicated' }
167
167
  }
168
168
  };
169
- await this.mta.addResource(resource);
169
+ await this.mta?.addResource(resource);
170
170
  this.resources.set('xsuaa', resource);
171
171
  this.dirty = true;
172
172
  }
173
173
  async addHtml5Runtime() {
174
174
  const resource = {
175
- name: `${this.prefix.slice(0, 100)}-html5-repo-runtime`,
175
+ name: `${this.prefix?.slice(0, 100)}-html5-repo-runtime`,
176
176
  type: 'org.cloudfoundry.managed-service',
177
177
  parameters: { 'service-plan': 'app-runtime', service: 'html5-apps-repo' }
178
178
  };
179
- await this.mta.addResource(resource);
179
+ await this.mta?.addResource(resource);
180
180
  this.resources.set('html5-apps-repo:app-runtime', resource);
181
181
  this.dirty = true;
182
182
  }
@@ -191,39 +191,39 @@ class MtaConfig {
191
191
  if (resource && !resource.parameters?.['service-name']) {
192
192
  resource.parameters = {
193
193
  ...(resource.parameters ?? {}),
194
- 'service-name': `${this.prefix.slice(0, 100)}-${serviceName}-service`
194
+ 'service-name': `${this.prefix?.slice(0, 100)}-${serviceName}-service`
195
195
  };
196
- await this.mta.updateResource(resource);
196
+ await this.mta?.updateResource(resource);
197
197
  this.resources.set(resourceName, resource);
198
198
  this.dirty = true;
199
199
  }
200
200
  }
201
201
  async addAppFrontResource() {
202
202
  const resource = {
203
- name: `${this.prefix.slice(0, 94)}-app-front`,
203
+ name: `${this.prefix?.slice(0, 94)}-app-front`,
204
204
  type: 'org.cloudfoundry.managed-service',
205
205
  parameters: {
206
206
  service: 'app-front',
207
- 'service-name': `${this.prefix.slice(0, 96)}-app-front-service`,
207
+ 'service-name': `${this.prefix?.slice(0, 96)}-app-front-service`,
208
208
  'service-plan': 'developer'
209
209
  }
210
210
  };
211
- await this.mta.addResource(resource);
211
+ await this.mta?.addResource(resource);
212
212
  this.resources.set(constants_1.ManagedAppFront, resource);
213
213
  this.dirty = true;
214
214
  }
215
215
  async addHtml5Host() {
216
- const html5host = `${this.prefix.slice(0, 100)}-repo-host`; // Need to cater for -key being added too!
216
+ const html5host = `${this.prefix?.slice(0, 100)}-repo-host`; // Need to cater for -key being added too!
217
217
  const resource = {
218
218
  name: html5host,
219
219
  type: 'org.cloudfoundry.managed-service',
220
220
  parameters: {
221
- 'service-name': `${this.prefix.slice(0, 100)}-html5-service`,
221
+ 'service-name': `${this.prefix?.slice(0, 100)}-html5-service`,
222
222
  'service-plan': 'app-host',
223
223
  service: 'html5-apps-repo'
224
224
  }
225
225
  };
226
- await this.mta.addResource(resource);
226
+ await this.mta?.addResource(resource);
227
227
  this.resources.set(constants_1.HTML5RepoHost, resource);
228
228
  this.dirty = true;
229
229
  }
@@ -233,7 +233,7 @@ class MtaConfig {
233
233
  * @param isManagedApp - If the destination service is for a managed app
234
234
  */
235
235
  async addDestinationResource(isManagedApp = false) {
236
- const destinationName = `${this.prefix.slice(0, 100)}-destination-service`;
236
+ const destinationName = `${this.prefix?.slice(0, 100)}-destination-service`;
237
237
  const resource = {
238
238
  name: destinationName,
239
239
  type: 'org.cloudfoundry.managed-service',
@@ -247,7 +247,7 @@ class MtaConfig {
247
247
  }
248
248
  }
249
249
  };
250
- await this.mta.addResource(resource);
250
+ await this.mta?.addResource(resource);
251
251
  this.resources.set('destination', resource);
252
252
  this.dirty = true;
253
253
  }
@@ -278,7 +278,7 @@ class MtaConfig {
278
278
  if (!resource.parameters?.config?.init_data?.instance?.destinations?.some((destination) => destination.Name === constants_1.UI5Destination.Name)) {
279
279
  resource.parameters.config.init_data.instance.destinations.push(constants_1.UI5Destination);
280
280
  }
281
- await this.mta.updateResource(resource);
281
+ await this.mta?.updateResource(resource);
282
282
  this.resources.set('destination', resource);
283
283
  this.dirty = true;
284
284
  }
@@ -300,7 +300,7 @@ class MtaConfig {
300
300
  if (mtaResource && !serverModule.requires?.some((ele) => ele.name === mtaResource.name)) {
301
301
  serverModule.requires = [...(serverModule.requires ?? []), ...[{ name: mtaResource.name }]];
302
302
  }
303
- await this.mta.updateModule(serverModule);
303
+ await this.mta?.updateModule(serverModule);
304
304
  this.modules.set(moduleType, serverModule);
305
305
  this.dirty = true;
306
306
  }
@@ -313,24 +313,24 @@ class MtaConfig {
313
313
  async addManagedUAAWithSecurity() {
314
314
  this.log?.debug((0, i18n_1.t)('debug.addXsuaaService'));
315
315
  const resource = {
316
- name: `${this.prefix.slice(0, 100)}-uaa`,
316
+ name: `${this.prefix?.slice(0, 100)}-uaa`,
317
317
  type: 'org.cloudfoundry.managed-service',
318
318
  parameters: {
319
319
  path: './xs-security.json',
320
320
  service: 'xsuaa',
321
- 'service-name': `${this.prefix.slice(0, 100)}-xsuaa-service`,
321
+ 'service-name': `${this.prefix?.slice(0, 100)}-xsuaa-service`,
322
322
  'service-plan': 'application',
323
323
  ...(this.modules.has('nodejs') && this.modules.has('com.sap.application.content:appfront')
324
324
  ? {
325
325
  config: {
326
- xsappname: `${this.prefix.slice(0, 100)}-\${org}-\${space}`,
326
+ xsappname: `${this.prefix?.slice(0, 100)}-\${org}-\${space}`,
327
327
  'tenant-mode': 'dedicated'
328
328
  }
329
329
  }
330
330
  : {})
331
331
  }
332
332
  };
333
- await this.mta.addResource(resource);
333
+ await this.mta?.addResource(resource);
334
334
  this.resources.set(constants_1.ManagedXSUAA, resource);
335
335
  this.dirty = true;
336
336
  }
@@ -373,7 +373,7 @@ class MtaConfig {
373
373
  this.modules.get('com.sap.application.content:destination'),
374
374
  this.modules.get('approuter.nodejs')
375
375
  ].filter((elem) => elem !== undefined)) {
376
- const destinationName = this.resources.get('destination')?.name ?? `${this.prefix.slice(0, 100)}-destination-service`;
376
+ const destinationName = this.resources.get('destination')?.name ?? `${this.prefix?.slice(0, 100)}-destination-service`;
377
377
  if (module?.requires?.findIndex((app) => app.name === destinationName) === -1) {
378
378
  if (module.type === 'approuter.nodejs') {
379
379
  module.requires.push({
@@ -389,7 +389,7 @@ class MtaConfig {
389
389
  }
390
390
  });
391
391
  }
392
- await this.mta.updateModule(module);
392
+ await this.mta?.updateModule(module);
393
393
  this.dirty = true;
394
394
  }
395
395
  }
@@ -423,9 +423,7 @@ class MtaConfig {
423
423
  // In theory, if there is more than one, it should be same!
424
424
  moduleDestinations.some((destination) => {
425
425
  cloudServiceName = destination['sap.cloud.service'] || undefined;
426
- if (cloudServiceName) {
427
- return true; // breakout
428
- }
426
+ return !!cloudServiceName;
429
427
  });
430
428
  }
431
429
  });
@@ -462,7 +460,7 @@ class MtaConfig {
462
460
  * @returns {Promise<void>} A promise that resolves when the change request has been processed.
463
461
  */
464
462
  async updateParameters(parameters) {
465
- await this.mta.updateParameters(parameters);
463
+ await this.mta?.updateParameters(parameters);
466
464
  this.dirty = true;
467
465
  }
468
466
  /**
@@ -472,7 +470,7 @@ class MtaConfig {
472
470
  * @returns {Promise<void>} A promise that resolves when the change request has been processed.
473
471
  */
474
472
  async updateBuildParams(parameters) {
475
- await this.mta.updateBuildParameters(parameters);
473
+ await this.mta?.updateBuildParameters(parameters);
476
474
  this.dirty = true;
477
475
  }
478
476
  /**
@@ -503,7 +501,7 @@ class MtaConfig {
503
501
  'target-path': `${contentModule[constants_1.MTABuildParams][constants_1.MTABuildResult]}/`.replace(/\/{2,}/g, '/') // Matches two or more consecutive slashes where at least 2 repetitions of /
504
502
  });
505
503
  }
506
- await this.mta.updateModule(contentModule);
504
+ await this.mta?.updateModule(contentModule);
507
505
  this.dirty = true;
508
506
  }
509
507
  // Add application module, if not found already
@@ -514,7 +512,7 @@ class MtaConfig {
514
512
  path: appPath,
515
513
  'build-parameters': constants_1.HTMLAppBuildParams
516
514
  };
517
- await this.mta.addModule(app);
515
+ await this.mta?.addModule(app);
518
516
  this.apps.set(appName, app);
519
517
  this.dirty = true;
520
518
  this.log?.debug((0, i18n_1.t)('debug.html5AppAdded', { appName }));
@@ -532,7 +530,7 @@ class MtaConfig {
532
530
  const packageJson = JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(this.mtaDir, app.path, project_access_1.FileName.Package), 'utf8'));
533
531
  if (packageJson && (0, project_access_1.hasDependency)(packageJson, '@sap/ux-ui5-tooling')) {
534
532
  app['build-parameters'].commands = ['npm install', 'npm run build:cf'];
535
- await this.mta.updateModule(app);
533
+ await this.mta?.updateModule(app);
536
534
  this.dirty = true;
537
535
  }
538
536
  }
@@ -550,12 +548,12 @@ class MtaConfig {
550
548
  async addConnectivityResource() {
551
549
  const serviceType = 'connectivity';
552
550
  const resourceType = types_1.CloudFoundryServiceType.Managed;
553
- const resourceName = `${this.prefix.slice(0, 100)}-connectivity`;
551
+ const resourceName = `${this.prefix?.slice(0, 100)}-connectivity`;
554
552
  const router = this.modules.get('approuter.nodejs');
555
553
  if (router) {
556
554
  if (router.requires?.findIndex((resource) => resource.name === resourceName) === -1) {
557
555
  router.requires.push({ name: resourceName });
558
- await this.mta.updateModule(router);
556
+ await this.mta?.updateModule(router);
559
557
  }
560
558
  }
561
559
  const connectivityResource = {
@@ -567,7 +565,7 @@ class MtaConfig {
567
565
  }
568
566
  };
569
567
  if (!this.resources.has(serviceType)) {
570
- await this.mta.addResource(connectivityResource);
568
+ await this.mta?.addResource(connectivityResource);
571
569
  this.resources.set(serviceType, connectivityResource);
572
570
  }
573
571
  this.dirty = true;
@@ -631,12 +629,12 @@ class MtaConfig {
631
629
  * @returns {Promise<void>} A promise that resolves when the change request has been processed.
632
630
  */
633
631
  async addAbapService(serviceName, btpService) {
634
- const newResourceName = `${this.prefix.slice(0, 24)}-abap-${serviceName.slice(0, 20)}`;
632
+ const newResourceName = `${this.prefix?.slice(0, 24)}-abap-${serviceName.slice(0, 20)}`;
635
633
  const router = this.modules.get('approuter.nodejs');
636
634
  if (router) {
637
635
  if (router.requires?.findIndex((resource) => resource.name === newResourceName) === -1) {
638
636
  router.requires.push({ name: newResourceName });
639
- await this.mta.updateModule(router);
637
+ await this.mta?.updateModule(router);
640
638
  }
641
639
  }
642
640
  const abapServiceResource = {
@@ -650,7 +648,7 @@ class MtaConfig {
650
648
  }
651
649
  };
652
650
  if (!this.resources.has(newResourceName)) {
653
- await this.mta.addResource(abapServiceResource);
651
+ await this.mta?.addResource(abapServiceResource);
654
652
  this.resources.set(newResourceName, abapServiceResource);
655
653
  }
656
654
  this.dirty = true;
@@ -693,7 +691,7 @@ class MtaConfig {
693
691
  const destinationName = this.resources.get('destination')?.name;
694
692
  if (destinationName && xsuaaName && appRuntimeName) {
695
693
  const router = {
696
- name: `${this.prefix.slice(0, 100)}-router`,
694
+ name: `${this.prefix?.slice(0, 100)}-router`,
697
695
  type: 'approuter.nodejs',
698
696
  path: fromServerGenerator ? `${constants_1.RouterModule}` : `${constants_1.CloudFoundry}/${constants_1.RouterModule}`,
699
697
  parameters: {
@@ -710,7 +708,7 @@ class MtaConfig {
710
708
  }
711
709
  ]
712
710
  };
713
- await this.mta.addModule(router);
711
+ await this.mta?.addModule(router);
714
712
  this.modules.set('approuter.nodejs', router);
715
713
  this.dirty = true;
716
714
  }
@@ -747,7 +745,7 @@ class MtaConfig {
747
745
  let destinationServiceName = this.resources.get('destination')?.name;
748
746
  if (!destinationServiceName) {
749
747
  this.log?.info((0, i18n_1.t)('info.existingDestinationNotFound'));
750
- destinationServiceName = `${this.prefix.slice(0, 100)}-destination-service`;
748
+ destinationServiceName = `${this.prefix?.slice(0, 100)}-destination-service`;
751
749
  }
752
750
  const appMtaId = this.mtaId;
753
751
  const mtaExtFilePath = (0, path_1.join)(this.mta.mtaDirPath, project_access_1.FileName.MtaExtYaml);
@@ -835,7 +833,7 @@ class MtaConfig {
835
833
  name: destName
836
834
  };
837
835
  module.parameters?.config?.destinations.push(destination);
838
- await this.mta.updateModule(module);
836
+ await this.mta?.updateModule(module);
839
837
  }
840
838
  }
841
839
  }
@@ -872,7 +870,7 @@ class MtaConfig {
872
870
  });
873
871
  }
874
872
  }
875
- await this.mta.updateResource(destinationResource);
873
+ await this.mta?.updateResource(destinationResource);
876
874
  this.resources.set('destination', destinationResource);
877
875
  // Only make additional modifications if the MTA destination is added
878
876
  await this.updateServerModule(this.modules.has('nodejs') ? 'nodejs' : 'java');
@@ -886,7 +884,7 @@ class MtaConfig {
886
884
  */
887
885
  async save() {
888
886
  if (this.dirty) {
889
- await this.mta.save();
887
+ await this.mta?.save();
890
888
  }
891
889
  return this.dirty;
892
890
  }
@@ -906,7 +904,7 @@ class MtaConfig {
906
904
  const appHostName = this.resources.get(constants_1.ManagedAppFront)?.name;
907
905
  if (appHostName) {
908
906
  const appContentModule = {
909
- name: `${this.prefix.slice(0, 100)}-app-content`,
907
+ name: `${this.prefix?.slice(0, 100)}-app-content`,
910
908
  type: 'com.sap.application.content',
911
909
  path: '.',
912
910
  requires: [
@@ -927,7 +925,7 @@ class MtaConfig {
927
925
  if (this.modules.has('nodejs')) {
928
926
  appContentModule.requires?.push({ name: constants_1.SRV_API });
929
927
  }
930
- await this.mta.addModule(appContentModule);
928
+ await this.mta?.addModule(appContentModule);
931
929
  this.modules.set('com.sap.application.content:appfront', appContentModule);
932
930
  this.dirty = true;
933
931
  }
@@ -964,7 +962,7 @@ class MtaConfig {
964
962
  const managedXSUAAServiceName = this.resources.get(constants_1.ManagedXSUAA)?.parameters?.['service-name'];
965
963
  if (destinationName && appHostName && managedXSUAAName && managedXSUAAServiceName) {
966
964
  const router = {
967
- name: `${this.prefix.slice(0, 100)}-destination-content`,
965
+ name: `${this.prefix?.slice(0, 100)}-destination-content`,
968
966
  type: 'com.sap.application.content',
969
967
  requires: [
970
968
  {
@@ -995,17 +993,17 @@ class MtaConfig {
995
993
  instance: {
996
994
  destinations: [
997
995
  {
998
- Name: `${this.prefix.slice(0, 100)}_html_repo_host`,
996
+ Name: `${this.prefix?.slice(0, 100)}_html_repo_host`,
999
997
  ServiceInstanceName: appHostServiceName,
1000
998
  ServiceKeyName: `${appHostName}-key`,
1001
- 'sap.cloud.service': `${this.prefix.slice(0, 100)}`
999
+ 'sap.cloud.service': `${this.prefix?.slice(0, 100)}`
1002
1000
  },
1003
1001
  {
1004
1002
  Authentication: 'OAuth2UserTokenExchange',
1005
- Name: `${this.prefix.slice(0, 100)}_uaa`,
1003
+ Name: `${this.prefix?.slice(0, 100)}_uaa`,
1006
1004
  ServiceInstanceName: managedXSUAAServiceName,
1007
1005
  ServiceKeyName: `${managedXSUAAName}-key`,
1008
- 'sap.cloud.service': `${this.prefix.slice(0, 100)}`
1006
+ 'sap.cloud.service': `${this.prefix?.slice(0, 100)}`
1009
1007
  }
1010
1008
  ],
1011
1009
  'existing_destinations_policy': 'update'
@@ -1016,7 +1014,7 @@ class MtaConfig {
1016
1014
  'no-source': true
1017
1015
  }
1018
1016
  };
1019
- await this.mta.addModule(router);
1017
+ await this.mta?.addModule(router);
1020
1018
  this.modules.set('com.sap.application.content:destination', router);
1021
1019
  this.dirty = true;
1022
1020
  }
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.3.21",
4
+ "version": "0.3.22",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SAP/open-ux-tools.git",
@@ -29,12 +29,12 @@
29
29
  "mem-fs": "2.1.0",
30
30
  "mem-fs-editor": "9.4.0",
31
31
  "hasbin": "1.2.3",
32
- "@sap-ux/project-access": "1.30.12",
32
+ "@sap-ux/project-access": "1.30.13",
33
33
  "@sap-ux/yaml": "0.17.0",
34
- "@sap-ux/btp-utils": "1.1.0",
34
+ "@sap-ux/btp-utils": "1.1.1",
35
35
  "@sap-ux/logger": "0.7.0",
36
- "@sap-ux/ui5-config": "0.29.2",
37
- "@sap-ux/nodejs-utils": "0.2.2"
36
+ "@sap-ux/ui5-config": "0.29.3",
37
+ "@sap-ux/nodejs-utils": "0.2.3"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@types/ejs": "3.1.2",