@sap-ux/cf-deploy-config-writer 0.1.19 → 0.1.21
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/cf-writer/cap-config.js +3 -2
- package/dist/mta-config/mta.js +23 -8
- package/dist/utils.d.ts +2 -2
- package/dist/utils.js +2 -2
- package/package.json +2 -2
|
@@ -29,10 +29,11 @@ async function generateCAPConfig(config, fs, logger) {
|
|
|
29
29
|
}
|
|
30
30
|
logger?.debug(`Generate CAP configuration using: \n ${JSON.stringify(config)}`);
|
|
31
31
|
await validateConfig(config);
|
|
32
|
-
|
|
33
|
-
(0, mta_config_1.createCAPMTA)(config.mtaPath,
|
|
32
|
+
// Run `cds` add against the project, it will append whatever it needs
|
|
33
|
+
(0, mta_config_1.createCAPMTA)(config.mtaPath, [constants_1.CDSXSUAAService, constants_1.CDSDestinationService, constants_1.CDSHTML5RepoService]);
|
|
34
34
|
await (0, utils_1.addRoutingConfig)(config, fs);
|
|
35
35
|
await (0, utils_1.updateRootPackage)({ mtaId: config.mtaId, rootPath: config.mtaPath }, fs);
|
|
36
|
+
logger_helper_1.default.logger?.debug((0, i18n_1.t)('debug.capMtaCreated'));
|
|
36
37
|
return fs;
|
|
37
38
|
}
|
|
38
39
|
/**
|
package/dist/mta-config/mta.js
CHANGED
|
@@ -125,7 +125,7 @@ class MtaConfig {
|
|
|
125
125
|
if (!this.resources.has(constants_1.HTML5RepoHost)) {
|
|
126
126
|
await this.addHtml5Host();
|
|
127
127
|
}
|
|
128
|
-
//
|
|
128
|
+
// Set up the basic module template, artifacts will be added in another step
|
|
129
129
|
const appHostName = this.resources.get(constants_1.HTML5RepoHost)?.name;
|
|
130
130
|
if (appHostName) {
|
|
131
131
|
const deployer = {
|
|
@@ -411,23 +411,38 @@ class MtaConfig {
|
|
|
411
411
|
async addApp(appModule, appPath) {
|
|
412
412
|
// If an existing content module exists whether standalone/managed, append the new artifact
|
|
413
413
|
const contentModule = this.modules.get('com.sap.application.content:resource');
|
|
414
|
+
let isHTML5AlreadyExisting = false; // False by default
|
|
414
415
|
if (contentModule) {
|
|
415
416
|
contentModule[constants_1.MTABuildParams] = contentModule[constants_1.MTABuildParams] ?? {};
|
|
416
417
|
contentModule[constants_1.MTABuildParams][constants_1.MTABuildResult] =
|
|
417
418
|
contentModule[constants_1.MTABuildParams]?.[constants_1.MTABuildResult] ?? `resources`; // Default
|
|
418
419
|
contentModule[constants_1.MTABuildParams].requires = contentModule[constants_1.MTABuildParams].requires ?? [];
|
|
419
|
-
|
|
420
|
+
const artifactName = `${appModule.slice(0, 128)}.zip`;
|
|
421
|
+
// The name of the HTML5 app will always be the artifact name
|
|
422
|
+
if (contentModule[constants_1.MTABuildParams].requires?.findIndex((app) => app.artifacts?.includes?.(artifactName)) !== -1) {
|
|
423
|
+
isHTML5AlreadyExisting = true;
|
|
424
|
+
}
|
|
425
|
+
else {
|
|
420
426
|
contentModule[constants_1.MTABuildParams].requires.push({
|
|
421
427
|
name: appModule.slice(0, 128),
|
|
422
|
-
artifacts: [
|
|
423
|
-
'target-path': `${contentModule[constants_1.MTABuildParams][constants_1.MTABuildResult]}
|
|
428
|
+
artifacts: [artifactName],
|
|
429
|
+
'target-path': `${contentModule[constants_1.MTABuildParams][constants_1.MTABuildResult]}/`.replace(/\/{2,}/g, '/') // Matches two or more consecutive slashes where at least 2 repetitions of /
|
|
424
430
|
});
|
|
425
431
|
}
|
|
426
432
|
await this.mta.updateModule(contentModule);
|
|
433
|
+
this.dirty = true;
|
|
427
434
|
}
|
|
428
|
-
//
|
|
429
|
-
const
|
|
430
|
-
|
|
435
|
+
// Need to handle where existing HTML5 apps are added by `cds` which follow a different naming convention when added to mta
|
|
436
|
+
const modules = await this.mta.getModules();
|
|
437
|
+
for (const module of modules) {
|
|
438
|
+
if (module.type === 'html5' && module.name.endsWith(appModule) && isHTML5AlreadyExisting) {
|
|
439
|
+
module['build-parameters'] = constants_1.HTMLAppBuildParams;
|
|
440
|
+
await this.mta.updateModule(module);
|
|
441
|
+
this.dirty = true;
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
// Add application module, if not found already
|
|
445
|
+
if (!isHTML5AlreadyExisting && !this.apps.get(appModule)) {
|
|
431
446
|
const app = {
|
|
432
447
|
name: appModule.slice(0, 128),
|
|
433
448
|
type: 'html5',
|
|
@@ -436,8 +451,8 @@ class MtaConfig {
|
|
|
436
451
|
};
|
|
437
452
|
await this.mta.addModule(app);
|
|
438
453
|
this.apps.set(appModule, app);
|
|
454
|
+
this.dirty = true;
|
|
439
455
|
}
|
|
440
|
-
this.dirty = true;
|
|
441
456
|
}
|
|
442
457
|
/**
|
|
443
458
|
* Append the connectivity service to the list of resources.
|
package/dist/utils.d.ts
CHANGED
|
@@ -117,10 +117,10 @@ export declare function setMtaDefaults(config: CFBaseConfig): void;
|
|
|
117
117
|
/**
|
|
118
118
|
* Update the root package.json with scripts to deploy the MTA.
|
|
119
119
|
*
|
|
120
|
-
* @param {object} Options
|
|
120
|
+
* @param {object} Options Input params
|
|
121
121
|
* @param {string} Options.mtaId - MTA ID to be written to package.json
|
|
122
122
|
* @param {string} Options.rootPath - MTA project path
|
|
123
|
-
* @param fs
|
|
123
|
+
* @param fs - reference to a mem-fs editor
|
|
124
124
|
*/
|
|
125
125
|
export declare function updateRootPackage({ mtaId, rootPath }: {
|
|
126
126
|
mtaId: string;
|
package/dist/utils.js
CHANGED
|
@@ -252,10 +252,10 @@ function setMtaDefaults(config) {
|
|
|
252
252
|
/**
|
|
253
253
|
* Update the root package.json with scripts to deploy the MTA.
|
|
254
254
|
*
|
|
255
|
-
* @param {object} Options
|
|
255
|
+
* @param {object} Options Input params
|
|
256
256
|
* @param {string} Options.mtaId - MTA ID to be written to package.json
|
|
257
257
|
* @param {string} Options.rootPath - MTA project path
|
|
258
|
-
* @param fs
|
|
258
|
+
* @param fs - reference to a mem-fs editor
|
|
259
259
|
*/
|
|
260
260
|
async function updateRootPackage({ mtaId, rootPath }, fs) {
|
|
261
261
|
const packageExists = fs.exists((0, path_1.join)(rootPath, project_access_1.FileName.Package));
|
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.1.
|
|
4
|
+
"version": "0.1.21",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/SAP/open-ux-tools.git",
|
|
@@ -29,7 +29,7 @@
|
|
|
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.29.
|
|
32
|
+
"@sap-ux/project-access": "1.29.15",
|
|
33
33
|
"@sap-ux/yaml": "0.16.0",
|
|
34
34
|
"@sap-ux/btp-utils": "1.0.1",
|
|
35
35
|
"@sap-ux/logger": "0.6.0",
|