@ui5/task-adaptation 1.0.10 → 1.0.12

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,13 @@
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.10...HEAD).
5
+ A list of unreleased changes can be found [here](https://github.com/SAP/ui5-task-adaptation/compare/v1.0.12...HEAD).
6
+
7
+ <a name="v1.0.12"></a>
8
+ ## [v1.0.12] - 2022-11-16
9
+
10
+ <a name="v1.0.11"></a>
11
+ ## [v1.0.11] - 2022-03-01
6
12
 
7
13
  <a name="v1.0.10"></a>
8
14
  ## [v1.0.10] - 2021-06-04
@@ -40,6 +46,8 @@ A list of unreleased changes can be found [here](https://github.com/SAP/ui5-task
40
46
  <a name="v1.0.0"></a>
41
47
  ## v1.0.0 - 2020-12-09
42
48
 
49
+ [v1.0.12]: https://github.com/SAP/ui5-task-adaptation/compare/v1.0.11...v1.0.12
50
+ [v1.0.11]: https://github.com/SAP/ui5-task-adaptation/compare/v1.0.10...v1.0.11
43
51
  [v1.0.10]: https://github.com/SAP/ui5-task-adaptation/compare/v1.0.9...v1.0.10
44
52
  [v1.0.9]: https://github.com/SAP/ui5-task-adaptation/compare/v1.0.8...v1.0.9
45
53
  [v1.0.8]: https://github.com/SAP/ui5-task-adaptation/compare/v1.0.7...v1.0.8
package/README.md CHANGED
@@ -1,8 +1,10 @@
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://app.travis-ci.com/github/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.
6
8
 
7
9
  ## How to obtain support
8
10
  In case you need any support, please create a GitHub issue.
package/dist/bundle.js CHANGED
@@ -1,4 +1,6 @@
1
- var window = {};'use strict';
1
+ //1.108.0
2
+ var window = {};
3
+ 'use strict';
2
4
 
3
5
  Object.defineProperty(exports, '__esModule', { value: true });
4
6
 
@@ -31,7 +33,7 @@ var Change = function (oFile) {
31
33
  };
32
34
  Change.prototype.getChangeType = function () {
33
35
  if (this._oDefinition) {
34
- return this._oDefinition.changeType;
36
+ return this._oDefinition.flexObjectMetadata ? this._oDefinition.flexObjectMetadata.changeType : this._oDefinition.changeType;
35
37
  }
36
38
  };
37
39
  Change.prototype.getLayer = function () {
@@ -157,13 +159,13 @@ function setPropValueByPath(oEntityProp, oRoot) {
157
159
  }
158
160
  ObjectPath.set(aPath, oEntityProp.propertyValue, oRoot);
159
161
  }
160
- function changePropertyValueByPath (oChanges, oRootPath) {
161
- if (Array.isArray(oChanges)) {
162
- oChanges.forEach(function (oEntityProp) {
162
+ function changePropertyValueByPath (vChanges, oRootPath) {
163
+ if (Array.isArray(vChanges)) {
164
+ vChanges.forEach(function (oEntityProp) {
163
165
  setPropValueByPath(oEntityProp, oRootPath);
164
166
  });
165
167
  } else {
166
- setPropValueByPath(oChanges, oRootPath);
168
+ setPropValueByPath(vChanges, oRootPath);
167
169
  }
168
170
  }
169
171
 
@@ -253,10 +255,8 @@ function checkIdNamespaceCompliance(sId, oChange) {
253
255
  throw new Error("Id " + sId + " must not start with reserved " + layer_prefixes[sKey]);
254
256
  }
255
257
  });
256
- } else {
257
- if (!sId.startsWith(sPrefix)) {
258
- throw new Error("Id " + sId + " must start with " + sPrefix);
259
- }
258
+ } else if (!sId.startsWith(sPrefix)) {
259
+ throw new Error("Id " + sId + " must start with " + sPrefix);
260
260
  }
261
261
  }
262
262
  function getNamespacePrefixForLayer(sLayer) {
@@ -643,6 +643,19 @@ var ChangeInbound = {
643
643
  }
644
644
  };
645
645
 
646
+ var SetAbstract = {
647
+ applyChange: function (oManifest, oChange) {
648
+ if (!oChange.getContent().hasOwnProperty("abstract")) {
649
+ throw new Error("No abstract in change content provided");
650
+ }
651
+ if (oChange.getContent().abstract !== false) {
652
+ throw new Error("The current change value of property abstract is '" + oChange.getContent().abstract + "'. Only allowed value for property abstract is boolean 'false'");
653
+ }
654
+ ObjectPath.set(["sap.fiori", "abstract"], oChange.getContent().abstract, oManifest);
655
+ return oManifest;
656
+ }
657
+ };
658
+
646
659
  function _mergeExistingLibrary(oManifestLib, oChangeLib) {
647
660
  var oUpdatedLibrary = {};
648
661
  if (oChangeLib.minVersion) {
@@ -726,31 +739,10 @@ var DeleteCard = {
726
739
  }
727
740
  };
728
741
 
729
- var BaseObject$1;
730
- var Interface = function (oObject, aMethods, _bReturnFacade) {
731
- if (!oObject) {
732
- return oObject;
733
- }
734
- BaseObject$1 = BaseObject$1 || sap.ui.requireSync("sap/ui/base/Object");
735
- function fCreateDelegator(oObject, sMethodName) {
736
- return function () {
737
- var tmp = oObject[sMethodName].apply(oObject, arguments);
738
- if (_bReturnFacade) {
739
- return this;
740
- } else {
741
- return tmp instanceof BaseObject$1 ? tmp.getInterface() : tmp;
742
- }
743
- };
744
- }
745
- if (!aMethods) {
746
- return {};
747
- }
748
- var sMethodName;
749
- for (var i = 0, ml = aMethods.length; i < ml; i++) {
750
- sMethodName = aMethods[i];
751
- if (!oObject[sMethodName] || typeof oObject[sMethodName] === "function") {
752
- this[sMethodName] = fCreateDelegator(oObject, sMethodName);
753
- }
742
+ var fnAssert = function (bResult, vMessage) {
743
+ if (!bResult) {
744
+ var sMessage = typeof vMessage === "function" ? vMessage() : vMessage;
745
+ console.assert(bResult, sMessage);
754
746
  }
755
747
  };
756
748
 
@@ -1003,13 +995,6 @@ Log.getLogger = function (sComponent, iDefaultLogLevel) {
1003
995
  return new Logger(sComponent);
1004
996
  };
1005
997
 
1006
- var fnAssert = function (bResult, vMessage) {
1007
- if (!bResult) {
1008
- var sMessage = typeof vMessage === "function" ? vMessage() : vMessage;
1009
- console.assert(bResult, sMessage);
1010
- }
1011
- };
1012
-
1013
998
  var fnUniqueSort = function (aArray) {
1014
999
  fnAssert(Array.isArray(aArray), "uniqueSort: input parameter must be an Array");
1015
1000
  var iLength = aArray.length;
@@ -1251,7 +1236,7 @@ var BaseObject = Metadata.createClass("sap.ui.base.Object", {
1251
1236
  });
1252
1237
  BaseObject.prototype.destroy = function () {};
1253
1238
  BaseObject.prototype.getInterface = function () {
1254
- var oInterface = new Interface(this, this.getMetadata().getAllPublicMethods());
1239
+ var oInterface = new BaseObject._Interface(this, this.getMetadata().getAllPublicMethods());
1255
1240
  this.getInterface = function () {
1256
1241
  return oInterface;
1257
1242
  };
@@ -1277,6 +1262,31 @@ BaseObject.prototype.isA = function (vTypeName) {
1277
1262
  BaseObject.isA = function (oObject, vTypeName) {
1278
1263
  return oObject instanceof BaseObject && oObject.isA(vTypeName);
1279
1264
  };
1265
+ BaseObject._Interface = function (oObject, aMethods, _bReturnFacade) {
1266
+ if (!oObject) {
1267
+ return oObject;
1268
+ }
1269
+ function fCreateDelegator(oObject, sMethodName) {
1270
+ return function () {
1271
+ var tmp = oObject[sMethodName].apply(oObject, arguments);
1272
+ if (_bReturnFacade) {
1273
+ return this;
1274
+ } else {
1275
+ return tmp instanceof BaseObject ? tmp.getInterface() : tmp;
1276
+ }
1277
+ };
1278
+ }
1279
+ if (!aMethods) {
1280
+ return {};
1281
+ }
1282
+ var sMethodName;
1283
+ for (var i = 0, ml = aMethods.length; i < ml; i++) {
1284
+ sMethodName = aMethods[i];
1285
+ if (!oObject[sMethodName] || typeof oObject[sMethodName] === "function") {
1286
+ this[sMethodName] = fCreateDelegator(oObject, sMethodName);
1287
+ }
1288
+ }
1289
+ };
1280
1290
 
1281
1291
  var class2type = {};
1282
1292
  var hasOwn = class2type.hasOwnProperty;
@@ -1342,7 +1352,8 @@ function getMethods(sClassName, oLog) {
1342
1352
  oLog.addLogListener(oListener);
1343
1353
  },
1344
1354
  getLogger: function () {
1345
- return oLog.getLogger(sFullClassName);
1355
+ var oRet = oLog.getLogger(sFullClassName);
1356
+ return oRet;
1346
1357
  }
1347
1358
  };
1348
1359
  }
@@ -1354,7 +1365,7 @@ var FeLogger = BaseObject.extend("sap.suite.ui.generic.template.genericUtilities
1354
1365
 
1355
1366
  var oLogger$2 = new FeLogger("manifestMerger.MergerUil").getLogger();
1356
1367
  var mergerUtil = {
1357
- iterateAndFind: function iterateFind(oPages, sEntityKey, sPageComponent, sChildPageId) {
1368
+ iterateAndFind: function iterateFind(oPages, sEntityKey, sPageComponent, sChildPageId, sParentKey) {
1358
1369
  var oPageStructure;
1359
1370
  if (Array.isArray(oPages)) {
1360
1371
  throw new Error("Manifest should have sap.ui.generic.app.pages as Object structure and not array ");
@@ -1373,7 +1384,9 @@ var mergerUtil = {
1373
1384
  if (oPageStructure) {
1374
1385
  break;
1375
1386
  }
1376
- oPageStructure = iterateFind(oPages[sKey], sEntityKey, sPageComponent, sChildPageId);
1387
+ if (sKey === "pages" || sParentKey === "pages") {
1388
+ oPageStructure = iterateFind(oPages[sKey], sEntityKey, sPageComponent, sChildPageId, sKey);
1389
+ }
1377
1390
  } else if (sKey === "pages" && Array.isArray(oPages[sKey])) {
1378
1391
  throw new Error("Manifest should have sap.ui.generic.app.pages as Object structure and not array ");
1379
1392
  }
@@ -1455,6 +1468,9 @@ var addNewObjectPage = {
1455
1468
  "name": "sap.suite.ui.generic.template.ObjectPage"
1456
1469
  };
1457
1470
  if (oPageStructure) {
1471
+ if (oPageStructure.pages && Array.isArray(oPageStructure.pages)) {
1472
+ throw Error("Manifest should have sap.ui.generic.app.pages as Object structure and not array");
1473
+ }
1458
1474
  ObjectPath.create(["pages", sChildPageId], oPageStructure);
1459
1475
  ObjectPath.set(["pages", sChildPageId], oChangeContent.childPage.definition, oPageStructure);
1460
1476
  ObjectPath.set(["pages", sChildPageId, "component"], oComponentContent, oPageStructure);
@@ -1491,6 +1507,48 @@ var changePageConfiguration = {
1491
1507
  }
1492
1508
  };
1493
1509
 
1510
+ var _exports = {};
1511
+ function applyChange(manifest, change) {
1512
+ var _manifest$sapUi, _manifest$sapUi$routi;
1513
+ var changeContent = change.getContent();
1514
+ var pageID = changeContent === null || changeContent === void 0 ? void 0 : changeContent.page;
1515
+ var targets = ((_manifest$sapUi = manifest["sap.ui5"]) === null || _manifest$sapUi === void 0 ? void 0 : (_manifest$sapUi$routi = _manifest$sapUi.routing) === null || _manifest$sapUi$routi === void 0 ? void 0 : _manifest$sapUi$routi.targets) || ({});
1516
+ var pageSettings;
1517
+ var propertyChange = changeContent === null || changeContent === void 0 ? void 0 : changeContent.entityPropertyChange;
1518
+ if ((propertyChange === null || propertyChange === void 0 ? void 0 : propertyChange.operation) !== "UPSERT" || !(propertyChange !== null && propertyChange !== void 0 && propertyChange.propertyPath) || (propertyChange === null || propertyChange === void 0 ? void 0 : propertyChange.propertyValue) === undefined || propertyChange !== null && propertyChange !== void 0 && propertyChange.propertyPath.startsWith("/")) {
1519
+ Log.error("Change content is not a valid");
1520
+ return manifest;
1521
+ }
1522
+ for (var p in targets) {
1523
+ if (targets[p].id === pageID) {
1524
+ var _targets$p$name;
1525
+ if ((_targets$p$name = targets[p].name) !== null && _targets$p$name !== void 0 && _targets$p$name.startsWith("sap.fe.templates.")) {
1526
+ var _targets$p, _targets$p$options;
1527
+ pageSettings = ((_targets$p = targets[p]) === null || _targets$p === void 0 ? void 0 : (_targets$p$options = _targets$p.options) === null || _targets$p$options === void 0 ? void 0 : _targets$p$options.settings) || ({});
1528
+ break;
1529
+ }
1530
+ }
1531
+ }
1532
+ if (!pageSettings) {
1533
+ Log.error(("No Fiori elements page with ID ").concat(pageID, " found in routing targets."));
1534
+ return manifest;
1535
+ }
1536
+ var propertyPath = propertyChange.propertyPath.split("/");
1537
+ if (propertyPath[0] === "controlConfiguration") {
1538
+ var annotationPath = "";
1539
+ for (var i = 1; i < propertyPath.length; i++) {
1540
+ annotationPath += (i > 1 ? "/" : "") + propertyPath[i];
1541
+ if (annotationPath.indexOf("@") > -1) {
1542
+ propertyPath = ["controlConfiguration", annotationPath].concat(propertyPath.slice(i + 1));
1543
+ break;
1544
+ }
1545
+ }
1546
+ }
1547
+ ObjectPath.set(propertyPath, propertyChange.propertyValue, pageSettings);
1548
+ return manifest;
1549
+ }
1550
+ _exports.applyChange = applyChange;
1551
+
1494
1552
  var Registration = {
1495
1553
  appdescr_ui5_addLibraries: () => Promise.resolve(AddLibrary),
1496
1554
  appdescr_app_setTitle: () => Promise.resolve(SetTitle),
@@ -1498,7 +1556,8 @@ var Registration = {
1498
1556
  appdescr_ovp_addNewCard: () => Promise.resolve(AddNewCard),
1499
1557
  appdescr_ovp_removeCard: () => Promise.resolve(DeleteCard),
1500
1558
  appdescr_ui_generic_app_addNewObjectPage: () => Promise.resolve(addNewObjectPage),
1501
- appdescr_ui_generic_app_changePageConfiguration: () => Promise.resolve(changePageConfiguration)
1559
+ appdescr_ui_generic_app_changePageConfiguration: () => Promise.resolve(changePageConfiguration),
1560
+ appdescr_fe_changePageConfiguration: () => Promise.resolve(_exports)
1502
1561
  };
1503
1562
 
1504
1563
  var RegistrationBuild = {
@@ -1510,7 +1569,8 @@ var RegistrationBuild = {
1510
1569
  appdescr_ui5_setFlexExtensionPointEnabled: () => Promise.resolve(SetFlexExtensionPointEnabled),
1511
1570
  appdescr_ui5_addNewModel: () => Promise.resolve(AddNewModel),
1512
1571
  appdescr_app_addAnnotationsToOData: () => Promise.resolve(AddAnnotationsToOData),
1513
- appdescr_app_changeInbound: () => Promise.resolve(ChangeInbound)
1572
+ appdescr_app_changeInbound: () => Promise.resolve(ChangeInbound),
1573
+ appdescr_fiori_setAbstract: () => Promise.resolve(SetAbstract)
1514
1574
  };
1515
1575
  var RegistrationCopy = Object.assign({}, Registration);
1516
1576
  var RegistrationBuild$1 = Object.assign(RegistrationCopy, RegistrationBuild);
package/dist/index.js CHANGED
@@ -11,39 +11,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  const appVariantManager_1 = require("./appVariantManager");
13
13
  const baseAppManager_1 = require("./baseAppManager");
14
- const html5RepoManager_1 = require("./html5RepoManager");
15
- const resourceUtil_1 = require("./util/resourceUtil");
14
+ const updateCache_1 = require("./updateCache");
16
15
  /**
17
16
  * Creates an appVariant bundle from the provided resources.
18
17
  */
19
18
  module.exports = ({ workspace, options, taskUtil }) => {
20
19
  function process(workspace, taskUtil) {
21
20
  return __awaiter(this, void 0, void 0, function* () {
22
- const baseAppFiles = getBaseAppFiles(options.configuration);
21
+ const baseAppFiles = updateCache_1.default(options.configuration);
23
22
  const appVariantResources = yield appVariantManager_1.default.getAppVariantResources(workspace);
24
23
  const appVariantInfo = appVariantManager_1.default.process(appVariantResources, options.projectNamespace, taskUtil);
25
24
  const baseAppResources = yield baseAppManager_1.default.process(yield baseAppFiles, yield appVariantInfo, options);
26
25
  yield Promise.all(appVariantResources.concat(baseAppResources).map(resource => workspace.write(resource)));
27
26
  });
28
27
  }
29
- function getBaseAppFiles(configuration) {
30
- return __awaiter(this, void 0, void 0, function* () {
31
- let result = new Map();
32
- if (!configuration.ignoreCache) {
33
- result = yield resourceUtil_1.default.readTemp(configuration);
34
- }
35
- if (result.size === 0) {
36
- const [metadata, baseAppFiles] = yield Promise.all([
37
- html5RepoManager_1.default.getMetadata(configuration),
38
- html5RepoManager_1.default.getBaseAppFiles(configuration)
39
- ]);
40
- const metadataMap = new Map([[resourceUtil_1.default.METADATA_FILENAME, JSON.stringify(metadata)]]);
41
- yield resourceUtil_1.default.writeTemp(configuration, new Map([...baseAppFiles, ...metadataMap]));
42
- return baseAppFiles;
43
- }
44
- return result;
45
- });
46
- }
47
28
  return process(workspace, taskUtil);
48
29
  };
49
30
  //# sourceMappingURL=index.js.map
@@ -6,7 +6,6 @@ export interface IConfiguration {
6
6
  spaceGuid?: string;
7
7
  orgGuid?: string;
8
8
  sapCloudService?: string;
9
- ignoreCache?: boolean;
10
9
  }
11
10
  export interface IProjectOptions {
12
11
  configuration: IConfiguration;
@@ -2,4 +2,4 @@ import { IConfiguration } from "./model/types";
2
2
  /**
3
3
  * Updates temporary stored original app files
4
4
  */
5
- export default function (configuration: IConfiguration): Promise<boolean>;
5
+ export default function (configuration: IConfiguration): Promise<Map<string, string>>;
@@ -23,11 +23,13 @@ function default_1(configuration) {
23
23
  const metadata = yield metadataPromise;
24
24
  if (metadata.changedOn !== (tempMetadata === null || tempMetadata === void 0 ? void 0 : tempMetadata.changedOn)) {
25
25
  const baseAppFiles = yield html5RepoManager_1.default.getBaseAppFiles(configuration);
26
- baseAppFiles.set(resourceUtil_1.default.METADATA_FILENAME, JSON.stringify(metadata));
27
- yield resourceUtil_1.default.writeTemp(configuration, baseAppFiles);
28
- return true;
26
+ const metadataMap = new Map([[resourceUtil_1.default.METADATA_FILENAME, JSON.stringify(metadata)]]);
27
+ yield resourceUtil_1.default.writeTemp(configuration, new Map([...baseAppFiles, ...metadataMap]));
28
+ return baseAppFiles;
29
+ }
30
+ else {
31
+ return resourceUtil_1.default.readTemp(configuration);
29
32
  }
30
- return false;
31
33
  });
32
34
  }
33
35
  exports.default = default_1;
@@ -9,29 +9,24 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- const node_fetch_1 = require("node-fetch");
12
+ const axios_1 = require("axios");
13
13
  class RequestUtil {
14
14
  static get(uri, options) {
15
- return node_fetch_1.default(uri, options).then(res => res.json());
15
+ return axios_1.default.get(uri, options).then(response => response.data);
16
16
  }
17
17
  static download(token, appHostId, uri) {
18
18
  return __awaiter(this, void 0, void 0, function* () {
19
19
  if (!token) {
20
20
  throw new Error("HTML5 token is undefined");
21
21
  }
22
- const response = yield node_fetch_1.default(uri, {
22
+ return axios_1.default.get(uri, {
23
+ responseType: "arraybuffer",
23
24
  headers: {
24
25
  "Content-Type": "application/json",
25
26
  "Authorization": "Bearer " + token,
26
27
  "x-app-host-id": appHostId
27
28
  }
28
- });
29
- return new Promise((resolve, reject) => {
30
- const data = [];
31
- response.body.on("error", err => reject(err));
32
- response.body.on("data", block => data.push(block));
33
- response.body.on("end", () => resolve(Buffer.concat(data)));
34
- });
29
+ }).then(response => response.data);
35
30
  });
36
31
  }
37
32
  }
package/package.json CHANGED
@@ -1,19 +1,20 @@
1
1
  {
2
2
  "name": "@ui5/task-adaptation",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "description": "Custom task for ui5-builder which allows building UI5 Flexibility Adaptation Projects for SAP BTP, Cloud Foundry environment",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "test": "npm run build && npm run coverage",
8
8
  "dev": "mocha --no-timeouts -r ts-node/register 'test/**/*.spec.ts'",
9
- "coverage": "nyc node_modules/.bin/mocha -r ts-node/register 'test/**/*.spec.ts'",
10
- "coverage-verbose": "nyc --reporter=html --reporter=text node_modules/.bin/mocha -r ts-node/register 'test/**/*.spec.ts'",
9
+ "perf": "mocha --no-timeouts -r ts-node/register 'test/**/*.perf.ts'",
10
+ "coverage": "nyc mocha -r ts-node/register 'test/**/*.spec.ts'",
11
+ "coverage-verbose": "nyc --reporter=html --reporter=text mocha -r ts-node/register 'test/**/*.spec.ts'",
11
12
  "preversion": "npm test",
12
13
  "version": "git-chglog --next-tag v$npm_package_version -o CHANGELOG.md && git add CHANGELOG.md",
13
14
  "postversion": "git push --follow-tags",
14
15
  "release-note": "git-chglog -c .chglog/release-config.yml v$npm_package_version",
15
- "rollup": "rollup -c rollup.config.js",
16
- "build": "npm run rollup && tsc -p ."
16
+ "rollup": "ts-node scripts/rollup.ts ./dist/bundle.js",
17
+ "build": "npm run rollup && tsc -p ./"
17
18
  },
18
19
  "repository": {
19
20
  "type": "git",
@@ -31,39 +32,42 @@
31
32
  "author": "SAP SE",
32
33
  "license": "Apache-2.0",
33
34
  "dependencies": {
34
- "@buxlabs/amd-to-es6": "^0.16.0",
35
- "@rollup/plugin-node-resolve": "^13.0.0",
36
- "@sap/cf-tools": "^1.1.1",
35
+ "@buxlabs/amd-to-es6": "^0.16.1",
36
+ "@rollup/plugin-node-resolve": "^13.0.4",
37
+ "@sap/cf-tools": "^2.0.1",
37
38
  "@ui5/fs": "^2.0.6",
38
39
  "@ui5/logger": "^2.0.1",
39
- "@ui5/project": "^2.3.1",
40
+ "@ui5/project": "^2.6.0",
40
41
  "adm-zip": "^0.5.5",
41
42
  "amdextract": "^3.0.0",
43
+ "axios": "^0.25.0",
42
44
  "builtin-modules": "^3.2.0",
43
45
  "js-yaml": "^4.1.0",
44
- "node-fetch": "^2.6.1",
45
46
  "rimraf": "^3.0.2",
46
- "rollup": "^2.50.0",
47
+ "rollup": "^2.56.3",
47
48
  "semver": "^7.3.5",
48
49
  "temp-dir": "^2.0.0"
49
50
  },
50
51
  "devDependencies": {
51
52
  "@istanbuljs/nyc-config-typescript": "^1.0.1",
52
53
  "@types/adm-zip": "^0.4.34",
53
- "@types/chai": "^4.2.18",
54
- "@types/mocha": "^8.2.2",
55
- "@types/node-fetch": "^2.5.10",
56
- "@types/request": "^2.48.5",
57
- "@types/rimraf": "^3.0.0",
58
- "@types/sinon": "^10.0.0",
54
+ "@types/chai": "^4.2.21",
55
+ "@types/chai-as-promised": "^7.1.4",
56
+ "@types/js-yaml": "^4.0.3",
57
+ "@types/mocha": "^9.1.0",
58
+ "@types/rimraf": "^3.0.2",
59
+ "@types/semver": "^7.3.8",
60
+ "@types/sinon": "^10.0.2",
59
61
  "chai": "^4.3.4",
60
- "mocha": "^8.4.0",
62
+ "chai-as-promised": "^7.1.1",
63
+ "chalk": "^4.1.2",
64
+ "mocha": "^9.2.0",
61
65
  "mock-require": "^3.0.3",
62
66
  "nyc": "^15.1.0",
63
- "sinon": "^11.1.0",
67
+ "sinon": "^11.1.2",
64
68
  "source-map-support": "^0.5.19",
65
- "ts-node": "^10.0.0",
66
- "typescript": "^4.2.4"
69
+ "ts-node": "^10.4.0",
70
+ "typescript": "^4.3.5"
67
71
  },
68
72
  "nyc": {
69
73
  "reporter": [
@@ -79,10 +83,10 @@
79
83
  "test/**",
80
84
  "lib/processors/jsdoc/lib/**",
81
85
  "dist/**",
82
- "rollup.config.js",
83
- "rollup/**",
84
86
  "src/model/types.ts",
85
- "src/util/requestUtil.ts"
87
+ "src/util/requestUtil.ts",
88
+ "scripts/**/*.js",
89
+ "scripts/git/octokitUtil.ts"
86
90
  ],
87
91
  "check-coverage": true,
88
92
  "statements": 85,
@@ -33,7 +33,9 @@ sap.ui.define([
33
33
  */
34
34
  Change.prototype.getChangeType = function () {
35
35
  if (this._oDefinition) {
36
- return this._oDefinition.changeType;
36
+ return this._oDefinition.flexObjectMetadata
37
+ ? this._oDefinition.flexObjectMetadata.changeType
38
+ : this._oDefinition.changeType
37
39
  }
38
40
  };
39
41
 
@@ -43,7 +45,7 @@ sap.ui.define([
43
45
  *
44
46
  * @public
45
47
  */
46
- Change.prototype.getLayer = function () {
48
+ Change.prototype.getLayer = function () {
47
49
  return this._oDefinition.layer;
48
50
  };
49
51
 
@@ -0,0 +1,16 @@
1
+ /*!
2
+ * OpenUI5
3
+ * (c) Copyright 2009-2020 SAP SE or an SAP affiliate company.
4
+ * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
5
+ */
6
+
7
+ sap.ui.define([
8
+
9
+ ], function (
10
+
11
+ ) {
12
+ var FlexObjectFactory = function () {
13
+ };
14
+
15
+ return FlexObjectFactory;
16
+ }, true);
File without changes
@@ -3,9 +3,11 @@ specVersion: "2.2"
3
3
  type: application
4
4
  metadata:
5
5
  name: rollup
6
+ allowSapInternal: true
6
7
  framework:
7
8
  name: SAPUI5
8
- version: 1.89.0
9
+ version: "0.0.0"
9
10
  libraries:
10
11
  - name: sap.ui.fl
11
12
  - name: sap.suite.ui.generic.template
13
+ - name: sap.fe.core
@@ -0,0 +1,134 @@
1
+ import * as crypto from "crypto";
2
+ import * as fs from "fs";
3
+ import * as path from "path";
4
+ import * as stream from "stream";
5
+
6
+ import { promisify } from "util";
7
+
8
+ const convertAMDtoES6 = require("@buxlabs/amd-to-es6");
9
+ const log = require("@ui5/logger").getLogger("rollup-plugin-ui5-resolve-task-adaptation");
10
+ const { resourceFactory } = require("@ui5/fs");
11
+
12
+
13
+ export default function (options: any) {
14
+
15
+ let dependencies: any;
16
+
17
+ const skipTransformation = (id: string) => !options.skipTransformation?.includes(id);
18
+
19
+ return {
20
+
21
+ name: "ui5-resolve",
22
+
23
+ buildStart: async (_: any) => {
24
+
25
+ dependencies = resourceFactory.createCollectionsForTree(options.project, {}).dependencies;
26
+
27
+ const pipe = promisify(stream.pipeline);
28
+ const resources: any[] = await Promise.all(options.assets.map((asset: string) => dependencies.byGlob(asset)));
29
+ const writePromises = [].concat(...resources).map((resource: any) => {
30
+ const file = `./dist${resource.getPath()}`;
31
+ const folder = path.dirname(file);
32
+ if (!fs.existsSync(folder)) {
33
+ fs.mkdirSync(folder, { recursive: true });
34
+ }
35
+ if (fs.existsSync(file)) {
36
+ fs.unlinkSync(file);
37
+ }
38
+ return pipe(resource.getStream(), fs.createWriteStream(file));
39
+ });
40
+ await Promise.all(writePromises);
41
+ },
42
+
43
+
44
+ /*
45
+ * Right before writing result to dist
46
+ */
47
+ renderChunk: (code: string) => {
48
+ return `//${options.ui5version}\nvar window = {};\n${code}`;
49
+ },
50
+
51
+
52
+ resolveId: (source: string, importer: string) => {
53
+ log.verbose(`resolveId: ${source} from ${importer}`);
54
+ if (importer && source.startsWith(".")) {
55
+ source = path.posix.join(path.dirname(importer), source);
56
+ }
57
+ log.verbose(" --> resolve to: " + source);
58
+ return source;
59
+ },
60
+
61
+
62
+ load: async (id: string) => {
63
+ log.verbose(`load: ${id}`);
64
+
65
+ if (!dependencies) {
66
+ dependencies = resourceFactory.createCollectionsForTree(options.project, {}).dependencies;
67
+ }
68
+
69
+ const localFile = path.join(__dirname, id);
70
+ if (fs.existsSync(localFile)) {
71
+ log.info(`Using local file "${id}"`);
72
+ return fs.readFileSync(localFile, {
73
+ encoding: "utf8"
74
+ });
75
+ }
76
+
77
+ const localOverride = path.resolve(__dirname, "overrides", id + ".js");
78
+ if (fs.existsSync(localOverride)) {
79
+ log.info(`Using local override for "${id}"`);
80
+ return fs.readFileSync(localOverride, { encoding: "utf8" });
81
+ }
82
+
83
+ const resource = await dependencies.byPath(`/resources/${id}.js`);
84
+ return resource.getString();
85
+ },
86
+
87
+
88
+ transform: (code: string, id: string): string | undefined => {
89
+ const skipped = !skipTransformation(id);
90
+ log.verbose(`transform: ${id} ${skipped ? "skipped" : ""}`);
91
+ if (skipped) {
92
+ return;
93
+ }
94
+
95
+ code = replaceRequireAsync(code);
96
+
97
+ code = code
98
+ .replace(/sap\.ui\.define/g, "define")
99
+ .replace(/\, \/\* bExport\= \*\/ true\)/g, ")")
100
+ .replace(/},.*(true|false)\);$/g, "});")
101
+ .replace(/},.*(true|false)\);(\n\/\/# sourceMappingURL=)*/g, "});\n//# sourceMappingURL=");
102
+ return convertAMDtoES6(code);
103
+ }
104
+
105
+ };
106
+ };
107
+
108
+
109
+ function replaceRequireAsync(code: string) {
110
+ const requireAsyncPattern = /requireAsync((.bind\(this, ")|(\("))+(?<url>[\/\w]*)"\)/mg;
111
+ let match, defineUrls = new Array<string>(), defineVars = new Array<string>(), matches = new Map();
112
+ while (match = requireAsyncPattern.exec(code)) {
113
+ if (match.groups?.url) {
114
+ const varaibleName = match.groups.url.split("/").pop() + crypto.randomBytes(16).toString("hex");
115
+ defineUrls.push(`"${match.groups.url}"`);
116
+ defineVars.push(varaibleName);
117
+ const value = match[0].includes("requireAsync.bind")
118
+ ? `() => Promise.resolve(${varaibleName})`
119
+ : varaibleName;
120
+ matches.set(match[0], value);
121
+ }
122
+ }
123
+ if (defineUrls.length > 0 && defineVars.length > 0) {
124
+ matches.forEach((value, key) => code = code.replace(key, value));
125
+ code = replaceRequireAsyncWith(code, `"sap/ui/fl/requireAsync"`, defineUrls);
126
+ code = replaceRequireAsyncWith(code, "requireAsync", defineVars);
127
+ }
128
+ return code;
129
+ }
130
+
131
+
132
+ function replaceRequireAsyncWith(code: string, requireAsyncSearchKeyword: string, inserts: string[]) {
133
+ return code.replace(requireAsyncSearchKeyword, inserts.join(",\n\t"));
134
+ }
@@ -0,0 +1,114 @@
1
+ import * as fs from "fs";
2
+ import * as path from "path";
3
+
4
+ import * as builtins from "builtin-modules";
5
+ import { nodeResolve } from "@rollup/plugin-node-resolve";
6
+ import * as rollup from "rollup";
7
+ import * as semver from "semver";
8
+ import * as yaml from "js-yaml";
9
+ import ui5 from "./rollup/ui5Resolve";
10
+
11
+ const { normalizer } = require("@ui5/project");
12
+ const log = require("@ui5/logger").getLogger("rollup-plugin-ui5-resolve-task-adaptation");
13
+
14
+ const projectPaths = [
15
+ path.resolve(__dirname, "rollup", "project")
16
+ ];
17
+ const LATEST_VERSION_PLACEHOLDER = "0.0.0";
18
+
19
+ export default class Builder {
20
+
21
+ static async getProjectInfo(projectPaths: string[]) {
22
+ for (const cwd of projectPaths) {
23
+ try {
24
+ const options = <any>{
25
+ cwd
26
+ };
27
+ const version = this.validateProjectSettings(cwd);
28
+ if (version === LATEST_VERSION_PLACEHOLDER) {
29
+ options.frameworkOptions = {
30
+ versionOverride: "latest"
31
+ }
32
+ }
33
+ return normalizer.generateProjectTree(options);
34
+ } catch (error: any) {
35
+ log.info(`${error.message}`);
36
+ }
37
+ }
38
+ }
39
+
40
+ static validateProjectSettings(projectPath: string): string {
41
+ const FRAMEWORK_TYPES = ["OpenUI5", "SAPUI5"];
42
+ const content = fs.readFileSync(path.join(projectPath, "ui5.yaml"), { encoding: "utf-8" });
43
+ const yamlJson = <any>yaml.load(content);
44
+ const framework = yamlJson["framework"];
45
+ if (!FRAMEWORK_TYPES.includes(framework.name)) {
46
+ throw new Error(`UI5 framework name is incorrect, possible values: ${FRAMEWORK_TYPES.join(" or ")}`);
47
+ }
48
+ if (!semver.valid(framework.version)) {
49
+ throw new Error(`UI5 framework version should correspond semantic version standard, e.g: 1.85.2`);
50
+ }
51
+ return framework.version;
52
+ }
53
+
54
+ static getBundledUI5Version(destination: string) {
55
+ const bundleFilePath = path.join(process.cwd(), destination);
56
+ if (fs.existsSync(bundleFilePath)) {
57
+ const bundle = fs.readFileSync(bundleFilePath, { encoding: "utf-8" });
58
+ const version = bundle.substring(2, bundle.indexOf("\n"));
59
+ return semver.coerce(version);
60
+ }
61
+ }
62
+
63
+ static async run(destination: string): Promise<void> {
64
+ const bundledUI5Version = this.getBundledUI5Version(destination);
65
+ const project = await this.getProjectInfo(projectPaths);
66
+ if (!project) {
67
+ throw new Error("ui5.yaml is not found or incorrect");
68
+ }
69
+ const isSapUiFl = (dependency: any) => dependency.id.endsWith("/sap.ui.fl");
70
+ const sapUiFlDependency = project.dependencies.find(isSapUiFl);
71
+ if (bundledUI5Version == null || sapUiFlDependency && semver.neq(bundledUI5Version, sapUiFlDependency.version)) {
72
+ if (sapUiFlDependency.version) {
73
+ log.info(`Using UI5 version ${sapUiFlDependency.version.toString()} to bundle`);
74
+ }
75
+ const inputOptions = <rollup.RollupOptions>{
76
+ input: "bundleDefinition.js",
77
+ plugins: [
78
+ ui5({
79
+ assets: [
80
+ "/resources/sap/ui/fl/**",
81
+ "/resources/sap/suite/ui/generic/template/**"
82
+ ],
83
+ skipTransformation: [
84
+ "bundleDefinition.js",
85
+ "sap/ui/thirdparty/URI"
86
+ ],
87
+ output: destination,
88
+ project: project,
89
+ ui5version: sapUiFlDependency.version
90
+ }),
91
+ nodeResolve({
92
+ preferBuiltins: true
93
+ })
94
+ ],
95
+ external: builtins
96
+ }
97
+ const bundle = await rollup.rollup(inputOptions);
98
+
99
+ const outputOptions = <rollup.RollupOptions>{
100
+ file: destination,
101
+ format: "commonjs"
102
+ }
103
+ await bundle.write(outputOptions);
104
+ await bundle.close();
105
+ } else {
106
+ log.info(`UI5 version ${bundledUI5Version!.toString()} is already bundled`);
107
+ }
108
+
109
+ }
110
+ }
111
+
112
+ if (process.argv.length === 3) {
113
+ Builder.run(process.argv[2]);
114
+ }
@@ -1,164 +0,0 @@
1
- //@ts-check
2
- const path = require("path");
3
- const fs = require("fs");
4
- const stream = require("stream");
5
- const { promisify } = require("util");
6
- const pipe = promisify(stream.pipeline);
7
- const yaml = require("js-yaml");
8
- const semver = require("semver");
9
- const crypto = require("crypto");
10
-
11
- const convertAMDtoES6 = require("@buxlabs/amd-to-es6");
12
-
13
- const log = require("@ui5/logger").getLogger("rollup-plugin-ui5-resolve-task-adaptation");
14
- //@ts-ignore
15
- const { normalizer } = require("@ui5/project");
16
- const { resourceFactory } = require("@ui5/fs");
17
-
18
-
19
- module.exports = (options) => {
20
-
21
- const skipTransformation = (id) => !options.skipTransformation.includes(id);
22
-
23
- async function getProject(projectPaths) {
24
- for (const { cwd, useLatestVersion } of projectPaths) {
25
- try {
26
- let options = { cwd };
27
- if (useLatestVersion) {
28
- options.frameworkOptions = {
29
- versionOverride: "latest"
30
- }
31
- }
32
- const project = await normalizer.generateProjectTree(options);
33
- validateProjectSettings(cwd);
34
- return project;
35
- } catch (error) {
36
- log.info(`${error.message}`);
37
- }
38
- }
39
- }
40
-
41
- function validateProjectSettings(projectPath) {
42
- const FRAMEWORK_TYPES = ["OpenUI5", "SAPUI5"];
43
- const content = fs.readFileSync(path.join(projectPath, "ui5.yaml"), { encoding: "utf-8" });
44
- const framework = yaml.load(content)["framework"];
45
- if (!FRAMEWORK_TYPES.includes(framework.name)) {
46
- throw new Error(`UI5 framework name is incorrect, possible values: ${FRAMEWORK_TYPES.join(" or ")}`);
47
- }
48
- if (!semver.valid(framework.version)) {
49
- throw new Error(`UI5 framework version should correspond semantic version standard, e.g: 1.85.2`);
50
- }
51
- }
52
-
53
-
54
- return {
55
-
56
- name: "ui5-resolve",
57
-
58
- buildStart: async (buildOptions) => {
59
-
60
- const project = await getProject(options.projectPaths);
61
- this.dependencies = resourceFactory.createCollectionsForTree(project, {}).dependencies;
62
-
63
- const resources = await Promise.all(options.assets.map(asset => this.dependencies.byGlob(asset)));
64
- const writePromises = [].concat(...resources).map(resource => {
65
- const file = `./dist${resource.getPath()}`;
66
- const folder = path.dirname(file);
67
- if (!fs.existsSync(folder)) {
68
- fs.mkdirSync(folder, { recursive: true });
69
- }
70
- if (fs.existsSync(file)) {
71
- fs.unlinkSync(file);
72
- }
73
- return pipe(resource.getStream(), fs.createWriteStream(file));
74
- });
75
- await Promise.all(writePromises);
76
- },
77
-
78
-
79
- /*
80
- * Right before writing result to dist
81
- */
82
- renderChunk: async (code) => {
83
- return "var window = {};" + code;
84
- },
85
-
86
-
87
- resolveId: (source, importer) => {
88
- log.verbose(`resolveId: ${source} from ${importer}`);
89
- if (importer && source.startsWith(".")) {
90
- source = path.posix.join(path.dirname(importer), source);
91
- }
92
- log.verbose(" --> resolve to: " + source);
93
- return source;
94
- },
95
-
96
-
97
- load: async (id) => {
98
- log.verbose(`load: ${id}`);
99
-
100
- const localFile = path.join(process.cwd(), id);
101
- if (fs.existsSync(localFile)) {
102
- log.info(`Using local file "${localFile}"`);
103
- return fs.readFileSync(localFile, {
104
- encoding: "utf8"
105
- });
106
- }
107
-
108
- const localOverride = path.resolve(__dirname, "overrides", id + ".js");
109
- if (fs.existsSync(localOverride)) {
110
- log.info(`Using local override for "${id}"`);
111
- return fs.readFileSync(localOverride, {
112
- encoding: "utf8"
113
- });
114
- }
115
-
116
- const resource = await this.dependencies.byPath(`/resources/${id}.js`);
117
- return resource.getString();
118
- },
119
-
120
-
121
- transform: (code, id) => {
122
- const skipped = !skipTransformation(id);
123
- log.verbose(`transform: ${id} ${skipped ? "skipped" : ""}`);
124
- if (skipped) {
125
- return;
126
- }
127
-
128
- code = replaceRequireAsync(code);
129
-
130
- code = code
131
- .replace(/sap\.ui\.define/g, "define")
132
- .replace(/\, \/\* bExport\= \*\/ true\)/g, ")")
133
- .replace(/}, true\);$/g, "});");
134
- return convertAMDtoES6(code);
135
- }
136
-
137
- };
138
- };
139
-
140
-
141
- function replaceRequireAsync(code) {
142
- const requireAsyncPattern = /requireAsync((.bind\(this, ")|(\("))+(?<url>[\/\w]*)"\)/mg;
143
- let match, defineUrls = [], defineVars = [], matches = new Map();
144
- while (match = requireAsyncPattern.exec(code)) {
145
- const varaibleName = match.groups.url.split("/").pop() + crypto.randomBytes(16).toString("hex");
146
- defineUrls.push(`"${match.groups.url}"`);
147
- defineVars.push(varaibleName);
148
- const value = match[0].includes("requireAsync.bind")
149
- ? `() => Promise.resolve(${varaibleName})`
150
- : varaibleName;
151
- matches.set(match[0], value);
152
- }
153
- if (defineUrls.length > 0 && defineVars.length > 0) {
154
- matches.forEach((value, key) => code = code.replace(key, value));
155
- code = replaceRequireAsyncWith(code, `"sap/ui/fl/requireAsync"`, defineUrls);
156
- code = replaceRequireAsyncWith(code, "requireAsync", defineVars);
157
- }
158
- return code;
159
- }
160
-
161
-
162
- function replaceRequireAsyncWith(code, requireAsyncSearchKeyword, inserts) {
163
- return code.replace(requireAsyncSearchKeyword, inserts.join(",\n\t"));
164
- }
package/rollup.config.js DELETED
@@ -1,40 +0,0 @@
1
- //@ts-check
2
- const path = require("path");
3
- const ui5 = require("./rollup/ui5-resolve");
4
- const builtins = require("builtin-modules");
5
- const { nodeResolve } = require("@rollup/plugin-node-resolve");
6
-
7
- module.exports = {
8
- input: "./rollup/bundle-def.js",
9
- plugins: [
10
- ui5({
11
- assets: [
12
- "/resources/sap/ui/fl/**",
13
- "/resources/sap/suite/ui/generic/template/**"
14
- ],
15
- skipTransformation: [
16
- "./rollup/bundle-def.js",
17
- "sap/ui/thirdparty/URI"
18
- ],
19
- projectPaths: [
20
- {
21
- cwd: path.resolve(__dirname, "..", "..", ".."),
22
- },
23
- {
24
- cwd: path.resolve(__dirname, "rollup", "project"),
25
- useLatestVersion: true
26
- }
27
- ]
28
- }),
29
- nodeResolve({
30
- preferBuiltins: true
31
- })
32
- ],
33
- external: builtins,
34
- output: [
35
- {
36
- file: "./dist/bundle.js",
37
- format: "commonjs"
38
- }
39
- ]
40
- };