Skip to content

Commit 17cf0ca

Browse files
authored
Merge pull request #150 from cap-js-community/fix/cdm-build
CDM - small fixes and output format
2 parents efc5cf2 + 1a28350 commit 17cf0ca

File tree

4 files changed

+19
-9
lines changed

4 files changed

+19
-9
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,12 @@ The CDM Builder allows to build a CDM file `cdm.json` from apps, roles and porta
432432

433433
- Build CDM: `cdm-build`
434434

435-
The generated CDM is generated at `app/cdm.json` and can be included into HTML5 Repository automatically
436-
when copied at `resources/cdm.json` during build time.
435+
The generated CDM is (per default) generated at `app/cdm.json`.
436+
437+
### Options:
438+
439+
- `-f, --force`: Overwrite existing CDM file. Default is `false`
440+
- `-t, --target`: Specify target path for generated CDM file. Default is `app/cdm.json`
437441

438442
## Support, Feedback, Contributing
439443

bin/cdm-build.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ process.argv = process.argv.map((arg) => {
1515
return arg.toLowerCase();
1616
});
1717

18-
program.version(packageJSON.version, "-v, --version").usage("[options]").option("-f, --force", "Force generation");
18+
program
19+
.version(packageJSON.version, "-v, --version")
20+
.usage("[options]")
21+
.option("-f, --force", "Force generation")
22+
.option("-t, --target <target>", "Target path");
1923

2024
program.unknownOption = function () {};
2125
program.parse(process.argv);

src/cdm-build/CDMBuilder.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class CDMBuilder {
6464
this.addRoles(cdm, roles);
6565
if (!this.options.skipWrite) {
6666
fs.mkdirSync(path.dirname(this.targetPath), { recursive: true });
67-
fs.writeFileSync(this.targetPath, JSON.stringify(cdm, null, 2));
67+
fs.writeFileSync(this.targetPath, JSON.stringify(Object.values(cdm.payload).flat(), null, 2));
6868
}
6969
return cdm;
7070
}
@@ -171,7 +171,7 @@ class CDMBuilder {
171171
cdm.payload.spaces.push(space);
172172
let index = 1;
173173
for (const group of cdm.payload.groups || []) {
174-
const pageId = `${this.namespace}-page${cdm.payload.groups.length > 1 ? `-${index++}` : ""}\`;`;
174+
const pageId = `${this.namespace}-page${cdm.payload.groups.length > 1 ? `-${index++}` : ""}`;
175175
cdm.payload.pages.push({
176176
_version: this.version,
177177
identification: {
@@ -221,11 +221,12 @@ class CDMBuilder {
221221
},
222222
},
223223
tags: {
224+
keywords: [],
224225
technicalAttributes: ["APPTYPE_HOMEPAGE"],
225226
},
226227
},
227228
"sap.integration": {
228-
urlTemplateId: `${this.namespace}-urltemplate.home`,
229+
urlTemplateId: `${this.namespace}-urltemplate-home`,
229230
urlTemplateParams: { path: "" },
230231
},
231232
"sap.ui": {

test/cdm-build/__snapshots__/cdm-build.test.js.snap

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,14 @@ exports[`CDM Builder Build 1`] = `
3131
},
3232
},
3333
"tags": {
34+
"keywords": [],
3435
"technicalAttributes": [
3536
"APPTYPE_HOMEPAGE",
3637
],
3738
},
3839
},
3940
"sap.integration": {
40-
"urlTemplateId": "common-urltemplate.home",
41+
"urlTemplateId": "common-urltemplate-home",
4142
"urlTemplateParams": {
4243
"path": "",
4344
},
@@ -221,7 +222,7 @@ exports[`CDM Builder Build 1`] = `
221222
"_version": "3.2.0",
222223
"identification": {
223224
"entityType": "page",
224-
"id": "common-page\`;",
225+
"id": "common-page",
225226
"title": "{{title}}",
226227
},
227228
"payload": {
@@ -309,7 +310,7 @@ exports[`CDM Builder Build 1`] = `
309310
"payload": {
310311
"contentNodes": [
311312
{
312-
"id": "common-page\`;",
313+
"id": "common-page",
313314
"type": "page",
314315
},
315316
],

0 commit comments

Comments
 (0)