@ui5/task-adaptation 1.0.10 → 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,10 @@
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.11...HEAD).
6
+
7
+ <a name="v1.0.11"></a>
8
+ ## [v1.0.11] - 2022-03-01
6
9
 
7
10
  <a name="v1.0.10"></a>
8
11
  ## [v1.0.10] - 2021-06-04
@@ -40,6 +43,7 @@ A list of unreleased changes can be found [here](https://github.com/SAP/ui5-task
40
43
  <a name="v1.0.0"></a>
41
44
  ## v1.0.0 - 2020-12-09
42
45
 
46
+ [v1.0.11]: https://github.com/SAP/ui5-task-adaptation/compare/v1.0.10...v1.0.11
43
47
  [v1.0.10]: https://github.com/SAP/ui5-task-adaptation/compare/v1.0.9...v1.0.10
44
48
  [v1.0.9]: https://github.com/SAP/ui5-task-adaptation/compare/v1.0.8...v1.0.9
45
49
  [v1.0.8]: https://github.com/SAP/ui5-task-adaptation/compare/v1.0.7...v1.0.8
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.
package/dist/bundle.js CHANGED
@@ -1,4 +1,6 @@
1
- var window = {};'use strict';
1
+ //1.99.0
2
+ var window = {};
3
+ 'use strict';
2
4
 
3
5
  Object.defineProperty(exports, '__esModule', { value: true });
4
6
 
@@ -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,34 +739,6 @@ 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
- }
754
- }
755
- };
756
-
757
742
  var fnNow = !(typeof window != "undefined" && window.performance && performance.now && performance.timing) ? Date.now : (function () {
758
743
  var iNavigationStart = performance.timing.navigationStart;
759
744
  return function perfnow() {
@@ -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;
@@ -1354,7 +1364,7 @@ var FeLogger = BaseObject.extend("sap.suite.ui.generic.template.genericUtilities
1354
1364
 
1355
1365
  var oLogger$2 = new FeLogger("manifestMerger.MergerUil").getLogger();
1356
1366
  var mergerUtil = {
1357
- iterateAndFind: function iterateFind(oPages, sEntityKey, sPageComponent, sChildPageId) {
1367
+ iterateAndFind: function iterateFind(oPages, sEntityKey, sPageComponent, sChildPageId, sParentKey) {
1358
1368
  var oPageStructure;
1359
1369
  if (Array.isArray(oPages)) {
1360
1370
  throw new Error("Manifest should have sap.ui.generic.app.pages as Object structure and not array ");
@@ -1373,7 +1383,9 @@ var mergerUtil = {
1373
1383
  if (oPageStructure) {
1374
1384
  break;
1375
1385
  }
1376
- oPageStructure = iterateFind(oPages[sKey], sEntityKey, sPageComponent, sChildPageId);
1386
+ if (sKey === "pages" || sParentKey === "pages") {
1387
+ oPageStructure = iterateFind(oPages[sKey], sEntityKey, sPageComponent, sChildPageId, sKey);
1388
+ }
1377
1389
  } else if (sKey === "pages" && Array.isArray(oPages[sKey])) {
1378
1390
  throw new Error("Manifest should have sap.ui.generic.app.pages as Object structure and not array ");
1379
1391
  }
@@ -1455,6 +1467,9 @@ var addNewObjectPage = {
1455
1467
  "name": "sap.suite.ui.generic.template.ObjectPage"
1456
1468
  };
1457
1469
  if (oPageStructure) {
1470
+ if (oPageStructure.pages && Array.isArray(oPageStructure.pages)) {
1471
+ throw Error("Manifest should have sap.ui.generic.app.pages as Object structure and not array");
1472
+ }
1458
1473
  ObjectPath.create(["pages", sChildPageId], oPageStructure);
1459
1474
  ObjectPath.set(["pages", sChildPageId], oChangeContent.childPage.definition, oPageStructure);
1460
1475
  ObjectPath.set(["pages", sChildPageId, "component"], oComponentContent, oPageStructure);
@@ -1491,6 +1506,46 @@ var changePageConfiguration = {
1491
1506
  }
1492
1507
  };
1493
1508
 
1509
+ var _exports = {};
1510
+ function applyChange(manifest, change) {
1511
+ var _manifest$sapUi, _manifest$sapUi$routi;
1512
+ var changeContent = change.getContent();
1513
+ var pageID = changeContent === null || changeContent === void 0 ? void 0 : changeContent.page;
1514
+ 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) || ({});
1515
+ var pageSettings;
1516
+ var propertyChange = changeContent === null || changeContent === void 0 ? void 0 : changeContent.entityPropertyChange;
1517
+ if ((propertyChange === null || propertyChange === void 0 ? void 0 : propertyChange.operation) !== "UPSERT" || !(propertyChange !== null && propertyChange !== void 0 && propertyChange.propertyPath) || !(propertyChange !== null && propertyChange !== void 0 && propertyChange.propertyValue) || propertyChange !== null && propertyChange !== void 0 && propertyChange.propertyPath.startsWith("/")) {
1518
+ return manifest;
1519
+ }
1520
+ for (var p in targets) {
1521
+ if (targets[p].id === pageID) {
1522
+ var _targets$p$name;
1523
+ if ((_targets$p$name = targets[p].name) !== null && _targets$p$name !== void 0 && _targets$p$name.startsWith("sap.fe.templates.")) {
1524
+ var _targets$p, _targets$p$options;
1525
+ 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) || ({});
1526
+ break;
1527
+ }
1528
+ }
1529
+ }
1530
+ if (!pageSettings) {
1531
+ return manifest;
1532
+ }
1533
+ var propertyPath = propertyChange.propertyPath.split("/");
1534
+ if (propertyPath[0] === "controlConfiguration") {
1535
+ var annotationPath = "";
1536
+ for (var i = 1; i < propertyPath.length; i++) {
1537
+ annotationPath += (i > 1 ? "/" : "") + propertyPath[i];
1538
+ if (annotationPath.indexOf("@") > -1) {
1539
+ propertyPath = ["controlConfiguration", annotationPath].concat(propertyPath.slice(i + 1));
1540
+ break;
1541
+ }
1542
+ }
1543
+ }
1544
+ ObjectPath.set(propertyPath, propertyChange.propertyValue, pageSettings);
1545
+ return manifest;
1546
+ }
1547
+ _exports.applyChange = applyChange;
1548
+
1494
1549
  var Registration = {
1495
1550
  appdescr_ui5_addLibraries: () => Promise.resolve(AddLibrary),
1496
1551
  appdescr_app_setTitle: () => Promise.resolve(SetTitle),
@@ -1498,7 +1553,8 @@ var Registration = {
1498
1553
  appdescr_ovp_addNewCard: () => Promise.resolve(AddNewCard),
1499
1554
  appdescr_ovp_removeCard: () => Promise.resolve(DeleteCard),
1500
1555
  appdescr_ui_generic_app_addNewObjectPage: () => Promise.resolve(addNewObjectPage),
1501
- appdescr_ui_generic_app_changePageConfiguration: () => Promise.resolve(changePageConfiguration)
1556
+ appdescr_ui_generic_app_changePageConfiguration: () => Promise.resolve(changePageConfiguration),
1557
+ appdescr_fe_changePageConfiguration: () => Promise.resolve(_exports)
1502
1558
  };
1503
1559
 
1504
1560
  var RegistrationBuild = {
@@ -1510,7 +1566,8 @@ var RegistrationBuild = {
1510
1566
  appdescr_ui5_setFlexExtensionPointEnabled: () => Promise.resolve(SetFlexExtensionPointEnabled),
1511
1567
  appdescr_ui5_addNewModel: () => Promise.resolve(AddNewModel),
1512
1568
  appdescr_app_addAnnotationsToOData: () => Promise.resolve(AddAnnotationsToOData),
1513
- appdescr_app_changeInbound: () => Promise.resolve(ChangeInbound)
1569
+ appdescr_app_changeInbound: () => Promise.resolve(ChangeInbound),
1570
+ appdescr_fiori_setAbstract: () => Promise.resolve(SetAbstract)
1514
1571
  };
1515
1572
  var RegistrationCopy = Object.assign({}, Registration);
1516
1573
  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.11",
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,
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: "1.91.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 = [], defineVars = [], 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,111 @@
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
+
18
+ export default class Builder {
19
+
20
+ static async getProjectInfo(projectPaths: string[]) {
21
+ for (const cwd of projectPaths) {
22
+ try {
23
+ let options = {
24
+ cwd,
25
+ frameworkOptions: {
26
+ versionOverride: "latest"
27
+ }
28
+ };
29
+ const project = await normalizer.generateProjectTree(options);
30
+ this.validateProjectSettings(cwd);
31
+ return project;
32
+ } catch (error: any) {
33
+ log.info(`${error.message}`);
34
+ }
35
+ }
36
+ }
37
+
38
+ static validateProjectSettings(projectPath: string) {
39
+ const FRAMEWORK_TYPES = ["OpenUI5", "SAPUI5"];
40
+ const content = fs.readFileSync(path.join(projectPath, "ui5.yaml"), { encoding: "utf-8" });
41
+ const yamlJson = <any>yaml.load(content);
42
+ const framework = yamlJson["framework"];
43
+ if (!FRAMEWORK_TYPES.includes(framework.name)) {
44
+ throw new Error(`UI5 framework name is incorrect, possible values: ${FRAMEWORK_TYPES.join(" or ")}`);
45
+ }
46
+ if (!semver.valid(framework.version)) {
47
+ throw new Error(`UI5 framework version should correspond semantic version standard, e.g: 1.85.2`);
48
+ }
49
+ }
50
+
51
+ static getBundledUI5Version(destination: string) {
52
+ const bundleFilePath = path.join(process.cwd(), destination);
53
+ if (fs.existsSync(bundleFilePath)) {
54
+ const bundle = fs.readFileSync(bundleFilePath, { encoding: "utf-8" });
55
+ const version = bundle.substring(2, bundle.indexOf("\n"));
56
+ return semver.coerce(version);
57
+ }
58
+ }
59
+
60
+ static async run(destination: string): Promise<void> {
61
+ const bundledUI5Version = this.getBundledUI5Version(destination);
62
+ const project = await this.getProjectInfo(projectPaths);
63
+ if (!project) {
64
+ throw new Error("ui5.yaml is not found or incorrect");
65
+ }
66
+ const isSapUiFl = (dependency: any) => dependency.id.endsWith("/sap.ui.fl");
67
+ const sapUiFlDependency = project.dependencies.find(isSapUiFl);
68
+ if (bundledUI5Version == null || sapUiFlDependency && semver.lt(bundledUI5Version, sapUiFlDependency.version)) {
69
+ if (sapUiFlDependency.version) {
70
+ log.info(`[ROLLUP] New UI5 version ${sapUiFlDependency.version.toString()} available to bundle`);
71
+ }
72
+ const inputOptions = <rollup.RollupOptions>{
73
+ input: "bundleDefinition.js",
74
+ plugins: [
75
+ ui5({
76
+ assets: [
77
+ "/resources/sap/ui/fl/**",
78
+ "/resources/sap/suite/ui/generic/template/**"
79
+ ],
80
+ skipTransformation: [
81
+ "bundleDefinition.js",
82
+ "sap/ui/thirdparty/URI"
83
+ ],
84
+ output: destination,
85
+ project: project,
86
+ ui5version: sapUiFlDependency.version
87
+ }),
88
+ nodeResolve({
89
+ preferBuiltins: true
90
+ })
91
+ ],
92
+ external: builtins
93
+ }
94
+ const bundle = await rollup.rollup(inputOptions);
95
+
96
+ const outputOptions = <rollup.RollupOptions>{
97
+ file: destination,
98
+ format: "commonjs"
99
+ }
100
+ await bundle.write(outputOptions);
101
+ await bundle.close();
102
+ } else {
103
+ log.info(`[ROLLUP] UI5 version ${bundledUI5Version!.toString()} is already bundled`);
104
+ }
105
+
106
+ }
107
+ }
108
+
109
+ if (process.argv.length === 3) {
110
+ Builder.run(process.argv[2]);
111
+ }
@@ -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
- };