@ui5/task-adaptation 1.0.8 → 1.0.11

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/CHANGELOG.md CHANGED
@@ -2,7 +2,16 @@
2
2
  All notable changes to this project will be documented in this file.
3
3
  This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
4
4
 
5
- A list of unreleased changes can be found [here](https://github.com/SAP/ui5-task-adaptation/compare/v1.0.8...HEAD).
5
+ A list of unreleased changes can be found [here](https://github.com/SAP/ui5-task-adaptation/compare/v1.0.11...HEAD).
6
+
7
+ <a name="v1.0.11"></a>
8
+ ## [v1.0.11] - 2022-03-01
9
+
10
+ <a name="v1.0.10"></a>
11
+ ## [v1.0.10] - 2021-06-04
12
+
13
+ <a name="v1.0.9"></a>
14
+ ## [v1.0.9] - 2021-05-10
6
15
 
7
16
  <a name="v1.0.8"></a>
8
17
  ## [v1.0.8] - 2021-04-26
@@ -34,6 +43,9 @@ A list of unreleased changes can be found [here](https://github.com/SAP/ui5-task
34
43
  <a name="v1.0.0"></a>
35
44
  ## v1.0.0 - 2020-12-09
36
45
 
46
+ [v1.0.11]: https://github.com/SAP/ui5-task-adaptation/compare/v1.0.10...v1.0.11
47
+ [v1.0.10]: https://github.com/SAP/ui5-task-adaptation/compare/v1.0.9...v1.0.10
48
+ [v1.0.9]: https://github.com/SAP/ui5-task-adaptation/compare/v1.0.8...v1.0.9
37
49
  [v1.0.8]: https://github.com/SAP/ui5-task-adaptation/compare/v1.0.7...v1.0.8
38
50
  [v1.0.7]: https://github.com/SAP/ui5-task-adaptation/compare/v1.0.6...v1.0.7
39
51
  [v1.0.6]: https://github.com/SAP/ui5-task-adaptation/compare/v1.0.5...v1.0.6
package/README.md CHANGED
@@ -1,8 +1,34 @@
1
1
  # ui5-task-adaptation
2
2
  [![REUSE status](https://api.reuse.software/badge/github.com/SAP/ui5-task-adaptation)](https://api.reuse.software/info/github.com/SAP/ui5-task-adaptation)
3
+ [![Build Status](https://app.travis-ci.com/SAP/ui5-task-adaptation.svg?branch=main)](https://travis-ci.org/SAP/ui5-task-adaptation)
4
+ [![npm version](https://badge.fury.io/js/@ui5%2Ftask-adaptation.svg)](https://badge.fury.io/js/@ui5%2Ftask-adaptation)
3
5
 
4
6
  ## Description
5
- A custom task for [ui5-builder](https://github.com/SAP/ui5-builder) that allows building UI5 Flexibility adaptation projects for the SAP BTP, Cloud Foundry environment. Note: This feature is still in development and not available yet.
7
+ A custom task for [ui5-builder](https://github.com/SAP/ui5-builder) that allows building [UI5 Flexibility adaptation projects](https://help.sap.com/viewer/584e0bcbfd4a4aff91c815cefa0bce2d/Cloud/en-US/019b0c38a6b043d1a66b11d992eed290.html) for SAP BTP, Cloud Foundry environment.
8
+
9
+ ## How to specify a UI5 version
10
+ ui5-task-adaptation is based on the UI5 implementation. In order to use a certain UI5 version, go to a module that contains the ui5.yaml and edit the ui5.yaml specifying the desired UI5 version (1.89.0 in the example below):
11
+
12
+ ```yaml
13
+ ---
14
+ specVersion: "2.2"
15
+ type: application
16
+ metadata:
17
+ name: example
18
+ framework:
19
+ name: SAPUI5
20
+ version: 1.89.0
21
+ libraries:
22
+ - name: sap.ui.fl
23
+ - name: sap.suite.ui.generic.template
24
+ ```
25
+
26
+ open a terminal and execute:
27
+
28
+ ```shell
29
+ npm run build-ui5
30
+ ```
31
+
6
32
 
7
33
  ## How to obtain support
8
34
  In case you need any support, please create a GitHub issue.
@@ -1,11 +1,12 @@
1
- import { IAppVariantInfo, IChange, IProjectOptions } from "./model/types";
1
+ import { IAppVariantInfo, IAppVariantManifest, IProjectOptions } from "./model/types";
2
2
  export default class BaseAppManager {
3
3
  static process(baseAppFiles: Map<string, string>, appVariantInfo: IAppVariantInfo, options: IProjectOptions): Promise<any[]>;
4
- static renameBaseApp(baseAppFiles: Map<string, string>, search: string, replacement: string): void;
4
+ private static getManifestInfo;
5
+ static renameBaseApp(baseAppFiles: Map<string, string>, search: string, replacement: string): Map<string, string>;
5
6
  private static getBaseAppManifest;
6
7
  private static updateCloudPlatform;
7
8
  private static fillAppVariantIdHierarchy;
8
9
  private static validateProperty;
9
- static applyDescriptorChanges(baseAppManifest: any, changes: IChange[], i18nBundleName: string): Promise<void>;
10
+ static applyDescriptorChanges(baseAppManifest: any, appVariantManifest: IAppVariantManifest, i18nBundleName: string): Promise<void>;
10
11
  static writeToWorkspace(baseAppFiles: Map<string, string>, projectNamespace: string): any[];
11
12
  }
@@ -19,16 +19,24 @@ const log = require("@ui5/logger").getLogger("@ui5/task-adaptation::BaseAppManag
19
19
  class BaseAppManager {
20
20
  static process(baseAppFiles, appVariantInfo, options) {
21
21
  return __awaiter(this, void 0, void 0, function* () {
22
- const { filepath, content } = this.getBaseAppManifest(baseAppFiles);
23
- this.renameBaseApp(baseAppFiles, appVariantInfo.reference, appVariantInfo.id);
22
+ const baseAppManifest = this.getBaseAppManifest(baseAppFiles);
23
+ const { id, version } = this.getManifestInfo(baseAppManifest.content);
24
+ const renamedBaseAppFiles = this.renameBaseApp(baseAppFiles, appVariantInfo.reference, appVariantInfo.id);
25
+ const { filepath, content } = this.getBaseAppManifest(renamedBaseAppFiles);
24
26
  this.updateCloudPlatform(content, options.configuration);
25
- this.fillAppVariantIdHierarchy(content);
27
+ this.fillAppVariantIdHierarchy(id, version, content);
26
28
  const i18nBundleName = commonUtil_1.replaceDots(appVariantInfo.id);
27
- yield this.applyDescriptorChanges(content, appVariantInfo.manifest.content, i18nBundleName);
28
- baseAppFiles.set(filepath, JSON.stringify(content));
29
- return this.writeToWorkspace(baseAppFiles, options.projectNamespace);
29
+ yield this.applyDescriptorChanges(content, appVariantInfo.manifest, i18nBundleName);
30
+ renamedBaseAppFiles.set(filepath, JSON.stringify(content));
31
+ return this.writeToWorkspace(renamedBaseAppFiles, options.projectNamespace);
30
32
  });
31
33
  }
34
+ static getManifestInfo(manifest) {
35
+ var _a, _b, _c;
36
+ const id = (_a = manifest["sap.app"]) === null || _a === void 0 ? void 0 : _a.id;
37
+ const version = (_c = (_b = manifest["sap.app"]) === null || _b === void 0 ? void 0 : _b.applicationVersion) === null || _c === void 0 ? void 0 : _c.version;
38
+ return { id, version };
39
+ }
32
40
  static renameBaseApp(baseAppFiles, search, replacement) {
33
41
  log.verbose("Renaming base app resources to appVariant id");
34
42
  const dotToSlash = (update) => update.split(".").join("\/");
@@ -43,9 +51,11 @@ class BaseAppManager {
43
51
  replacement: dotToSlash(replacement)
44
52
  }
45
53
  ];
46
- baseAppFiles.forEach((content, filepath, map) => {
47
- map.set(filepath, replaces.reduce((p, c) => p.replace(c.regexp, c.replacement), content));
54
+ const renamed = new Map();
55
+ baseAppFiles.forEach((content, filepath) => {
56
+ renamed.set(filepath, replaces.reduce((p, c) => p.replace(c.regexp, c.replacement), content));
48
57
  });
58
+ return renamed;
49
59
  }
50
60
  static getBaseAppManifest(baseAppFiles) {
51
61
  let filepath = [...baseAppFiles.keys()].find(filepath => filepath.endsWith("manifest.json"));
@@ -74,31 +84,35 @@ class BaseAppManager {
74
84
  delete baseAppManifest["sap.cloud"];
75
85
  }
76
86
  }
77
- static fillAppVariantIdHierarchy(baseAppManifest) {
78
- var _a, _b, _c;
87
+ static fillAppVariantIdHierarchy(id, version, baseAppManifest) {
79
88
  log.verbose("Filling up app variant hierarchy in manifest.json");
80
- const id = (_a = baseAppManifest["sap.app"]) === null || _a === void 0 ? void 0 : _a.id;
81
- const version = (_c = (_b = baseAppManifest["sap.app"]) === null || _b === void 0 ? void 0 : _b.applicationVersion) === null || _c === void 0 ? void 0 : _c.version;
82
89
  this.validateProperty(id, "sap.app/id");
83
90
  this.validateProperty(version, "sap.app/applicationVersion/version");
84
91
  if (baseAppManifest["sap.ui5"] == null) {
85
92
  baseAppManifest["sap.ui5"] = {};
86
93
  }
87
- baseAppManifest["sap.ui5"].appVariantIdHierarchy = [{
88
- appVariantId: id,
89
- version
90
- }];
94
+ if (baseAppManifest["sap.ui5"].appVariantIdHierarchy == null) {
95
+ baseAppManifest["sap.ui5"].appVariantIdHierarchy = [];
96
+ }
97
+ baseAppManifest["sap.ui5"].appVariantIdHierarchy.unshift({
98
+ appVariantId: id,
99
+ version
100
+ });
91
101
  }
92
102
  static validateProperty(value, property) {
93
103
  if (!value) {
94
104
  throw new Error(`Original application manifest should have ${property}`);
95
105
  }
96
106
  }
97
- static applyDescriptorChanges(baseAppManifest, changes, i18nBundleName) {
107
+ static applyDescriptorChanges(baseAppManifest, appVariantManifest, i18nBundleName) {
108
+ var _a, _b;
98
109
  return __awaiter(this, void 0, void 0, function* () {
99
110
  log.verbose("Applying appVariant changes");
100
111
  const strategy = new buildStrategy_1.default(RegistrationBuild, ApplyUtil, i18nBundleName);
101
- const changesContent = changes === null || changes === void 0 ? void 0 : changes.map((change) => new Change(change));
112
+ if (appVariantManifest.layer) {
113
+ (_a = appVariantManifest.content) === null || _a === void 0 ? void 0 : _a.forEach(item => item.layer = appVariantManifest.layer);
114
+ }
115
+ const changesContent = (_b = appVariantManifest.content) === null || _b === void 0 ? void 0 : _b.map((change) => new Change(change));
102
116
  if (changesContent) {
103
117
  yield Applier.applyChanges(baseAppManifest, changesContent, strategy);
104
118
  }