@sap-ux/adp-tooling 0.12.47 → 0.12.49

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.
@@ -3,6 +3,24 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addXmlFragment = exports.isAddXMLChange = exports.tryFixChange = exports.moduleNameContentMap = void 0;
4
4
  const path_1 = require("path");
5
5
  const project_access_1 = require("@sap-ux/project-access");
6
+ const ejs_1 = require("ejs");
7
+ const crypto_1 = require("crypto");
8
+ const OBJECT_PAGE_CUSTOM_SECTION = 'OBJECT_PAGE_CUSTOM_SECTION';
9
+ const fragmentTemplateDefinitions = {
10
+ [OBJECT_PAGE_CUSTOM_SECTION]: {
11
+ path: 'common/op-custom-section.xml',
12
+ getData: () => {
13
+ const uuid = (0, crypto_1.randomBytes)(4).toString('hex');
14
+ return {
15
+ ids: {
16
+ objectPageSection: `op-section-${uuid}`,
17
+ objectPageSubSection: `op-subsection-${uuid}`,
18
+ hBox: `hbox-${uuid}`
19
+ }
20
+ };
21
+ }
22
+ }
23
+ };
6
24
  /**
7
25
  * A mapping object that defines how to extract change content data from changes based on their type.
8
26
  */
@@ -55,9 +73,20 @@ exports.isAddXMLChange = isAddXMLChange;
55
73
  function addXmlFragment(basePath, change, fs, logger) {
56
74
  const { fragmentPath } = change.content;
57
75
  const fullPath = (0, path_1.join)(basePath, project_access_1.DirName.Changes, fragmentPath);
76
+ const templateConfig = fragmentTemplateDefinitions[change.content?.templateName ?? ''];
58
77
  try {
59
- const fragmentTemplatePath = (0, path_1.join)(__dirname, '../../templates/rta', "fragment.xml" /* TemplateFileName.Fragment */);
60
- fs.copy(fragmentTemplatePath, fullPath);
78
+ if (templateConfig) {
79
+ const fragmentTemplatePath = (0, path_1.join)(__dirname, '../../templates/rta', templateConfig.path);
80
+ const text = fs.read(fragmentTemplatePath);
81
+ const template = (0, ejs_1.render)(text, templateConfig.getData());
82
+ fs.write(fullPath, template);
83
+ }
84
+ else {
85
+ // copy default fragment template
86
+ const templateName = 'fragment.xml'; /* TemplateFileName.Fragment */
87
+ const fragmentTemplatePath = (0, path_1.join)(__dirname, '../../templates/rta', templateName);
88
+ fs.copy(fragmentTemplatePath, fullPath);
89
+ }
61
90
  logger.info(`XML Fragment "${fragmentPath}" was created`);
62
91
  }
63
92
  catch (error) {
package/dist/types.d.ts CHANGED
@@ -160,6 +160,7 @@ export interface AddXMLChange extends CommonChangeProperties {
160
160
  targetAggregation: string;
161
161
  index: number;
162
162
  fragmentPath: string;
163
+ templateName?: string;
163
164
  };
164
165
  selector: {
165
166
  id: string;
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "bugs": {
10
10
  "url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Aadp-tooling"
11
11
  },
12
- "version": "0.12.47",
12
+ "version": "0.12.49",
13
13
  "license": "Apache-2.0",
14
14
  "author": "@SAP/ux-tools-team",
15
15
  "main": "dist/index.js",
@@ -36,7 +36,7 @@
36
36
  "@sap-ux/btp-utils": "0.15.2",
37
37
  "@sap-ux/inquirer-common": "0.4.6",
38
38
  "@sap-ux/logger": "0.6.0",
39
- "@sap-ux/project-access": "1.27.2",
39
+ "@sap-ux/project-access": "1.27.3",
40
40
  "@sap-ux/project-input-validator": "0.3.3",
41
41
  "@sap-ux/system-access": "0.5.11",
42
42
  "@sap-ux/ui5-config": "0.24.1"
@@ -52,7 +52,7 @@
52
52
  "@types/supertest": "2.0.12",
53
53
  "@types/uuid": "10.0.0",
54
54
  "dotenv": "16.3.1",
55
- "express": "4.19.2",
55
+ "express": "4.21.0",
56
56
  "nock": "13.4.0",
57
57
  "rimraf": "5.0.5",
58
58
  "supertest": "6.3.3",
@@ -0,0 +1,17 @@
1
+ <!-- Use stable and unique IDs!-->
2
+ <core:FragmentDefinition
3
+ xmlns:uxap="sap.uxap"
4
+ xmlns:core='sap.ui.core'
5
+ xmlns='sap.m'
6
+ >
7
+ <uxap:ObjectPageSection
8
+ id="<%- ids.objectPageSection %>"
9
+ title="New custom section"
10
+ >
11
+ <uxap:ObjectPageSubSection id="<%- ids.objectPageSubSection %>">
12
+ <HBox id="<%- ids.hBox %>">
13
+ <!-- add your xml here -->
14
+ </HBox>
15
+ </uxap:ObjectPageSubSection>
16
+ </uxap:ObjectPageSection>
17
+ </core:FragmentDefinition>