@ui5/task-adaptation 1.4.3 → 1.5.0

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.
Files changed (50) hide show
  1. package/CHANGELOG.md +6 -2
  2. package/README.md +16 -12
  3. package/dist/annotationManager.d.ts +1 -1
  4. package/dist/annotationManager.js +5 -8
  5. package/dist/annotations/serviceRequestor.js +3 -15
  6. package/dist/appVariantManager.d.ts +16 -11
  7. package/dist/appVariantManager.js +56 -83
  8. package/dist/baseAppManager.d.ts +16 -16
  9. package/dist/baseAppManager.js +57 -80
  10. package/dist/bundle.js +58 -42
  11. package/dist/cache/cacheHolder.d.ts +18 -0
  12. package/dist/cache/cacheHolder.js +80 -0
  13. package/dist/i18nManager.js +11 -9
  14. package/dist/index.js +34 -9
  15. package/dist/model/appVariantIdHierarchyItem.d.ts +5 -0
  16. package/dist/model/appVariantIdHierarchyItem.js +2 -0
  17. package/dist/model/language.d.ts +3 -3
  18. package/dist/model/language.js +11 -4
  19. package/dist/model/types.d.ts +2 -0
  20. package/dist/processors/abapProcessor.d.ts +5 -5
  21. package/dist/processors/abapProcessor.js +19 -7
  22. package/dist/processors/cfProcessor.d.ts +4 -4
  23. package/dist/processors/cfProcessor.js +28 -12
  24. package/dist/processors/processor.d.ts +4 -2
  25. package/dist/processors/processor.js +2 -4
  26. package/dist/repositories/abapRepoManager.d.ts +3 -1
  27. package/dist/repositories/abapRepoManager.js +24 -5
  28. package/dist/util/cfUtil.js +1 -1
  29. package/dist/util/commonUtil.d.ts +4 -2
  30. package/dist/util/commonUtil.js +105 -32
  31. package/dist/util/filesUtil.d.ts +17 -0
  32. package/dist/util/filesUtil.js +49 -0
  33. package/dist/util/i18nMerger.d.ts +15 -20
  34. package/dist/util/i18nMerger.js +46 -64
  35. package/dist/util/renamingHandlers/manifestHandler.d.ts +6 -0
  36. package/dist/util/renamingHandlers/manifestHandler.js +20 -0
  37. package/dist/util/renamingHandlers/renamingHandler.d.ts +4 -0
  38. package/dist/util/renamingHandlers/renamingHandler.js +2 -0
  39. package/dist/util/resourceUtil.d.ts +3 -1
  40. package/dist/util/resourceUtil.js +15 -2
  41. package/eslint.config.js +2 -5
  42. package/package.json +18 -12
  43. package/scripts/test-integration-prep.sh +4 -0
  44. package/types/ui5.d.ts +10 -0
  45. package/dist/cache/annotationsCacheManager.d.ts +0 -8
  46. package/dist/cache/annotationsCacheManager.js +0 -16
  47. package/dist/cache/baseAppFilesCacheManager.d.ts +0 -6
  48. package/dist/cache/baseAppFilesCacheManager.js +0 -12
  49. package/dist/cache/cacheManager.d.ts +0 -16
  50. package/dist/cache/cacheManager.js +0 -65
package/dist/bundle.js CHANGED
@@ -99,7 +99,13 @@ var AddLibrary = {
99
99
  };
100
100
 
101
101
  var CondenserClassification = {
102
- LastOneWins: "lastOneWins"};
102
+ LastOneWins: "lastOneWins",
103
+ Reverse: "reverse",
104
+ Move: "move",
105
+ Create: "create",
106
+ Destroy: "destroy",
107
+ Update: "update"
108
+ };
103
109
 
104
110
  var SetTitle = {
105
111
  applyChange(oManifest) {
@@ -959,10 +965,14 @@ var mergerUtil = {
959
965
  };
960
966
 
961
967
  var Layer = {
968
+ USER: "USER",
969
+ PUBLIC: "PUBLIC",
962
970
  CUSTOMER: "CUSTOMER",
963
971
  CUSTOMER_BASE: "CUSTOMER_BASE",
964
972
  PARTNER: "PARTNER",
965
- VENDOR: "VENDOR"};
973
+ VENDOR: "VENDOR",
974
+ BASE: "BASE"
975
+ };
966
976
 
967
977
  function checkObjectProperties(oChangeObject, aObjects, aMandatoryProperties, aSupportedProperties, oSupportedPropertyPattern, oSupportedPropertyTypes) {
968
978
  aObjects.forEach(function (sObject) {
@@ -1183,6 +1193,8 @@ var addNewObjectPage = {
1183
1193
  mergerUtil.consistencyCheck(oChangeContent, "ADD", aSupportedProperties);
1184
1194
  var sParentEntitySet = oChangeContent.parentPage.entitySet;
1185
1195
  var sParentComponent = oChangeContent.parentPage.component;
1196
+ var pages = oManifest["sap.ui.generic.app"]["pages"];
1197
+ oManifest["sap.ui.generic.app"]["pages"] = mergerUtil.transformPagesToMapStructure(pages);
1186
1198
  var oPageStructure = mergerUtil.iterateAndFind(oManifest["sap.ui.generic.app"], sParentEntitySet, sParentComponent, sChildPageId);
1187
1199
  var oComponentContent = {
1188
1200
  "name": "sap.suite.ui.generic.template.ObjectPage"
@@ -1454,15 +1466,23 @@ var FlexCustomData = {
1454
1466
 
1455
1467
  function AnnotationChange () {}
1456
1468
 
1457
- var ChangeHandlerStorage = {
1458
- getAnnotationChangeHandler: function () {},
1459
- getChangeHandler: function () {}
1469
+ function VariantChange () {}
1470
+
1471
+ function VariantManagementChange () {}
1472
+
1473
+ var VariantManagementState = {
1474
+ getChangeInformationProvider: function () {}
1460
1475
  };
1461
1476
 
1462
- var ChangeHandlerRegistration731747ee8b925499a260b98af83836c7 = {
1477
+ var ChangeHandlerRegistration = {
1463
1478
  waitForChangeHandlerRegistration: function () {}
1464
1479
  };
1465
1480
 
1481
+ var ChangeHandlerStorage = {
1482
+ getAnnotationChangeHandler: function () {},
1483
+ getChangeHandler: function () {}
1484
+ };
1485
+
1466
1486
  var FlUtils = {
1467
1487
  getChangeFromChangesMap: function () {}
1468
1488
  };
@@ -1473,6 +1493,9 @@ function isDependencyStillValid(oChange, bHasChangeApplyFinishedCustomData) {
1473
1493
  }
1474
1494
  return true;
1475
1495
  }
1496
+ function isVariantRelated(mPropertyBag) {
1497
+ return mPropertyBag.flexObject instanceof VariantChange || mPropertyBag.flexObject instanceof VariantManagementChange;
1498
+ }
1476
1499
  const Utils = {
1477
1500
  getControlIfTemplateAffected(oChange, oControl, mPropertyBag) {
1478
1501
  const oModifier = mPropertyBag.modifier;
@@ -1505,9 +1528,10 @@ const Utils = {
1505
1528
  return ChangeHandlerStorage.getAnnotationChangeHandler({
1506
1529
  changeType: sChangeType
1507
1530
  });
1531
+ } else if (isVariantRelated(mPropertyBag)) {
1532
+ return VariantManagementState.getChangeInformationProvider(mPropertyBag.flexObject);
1508
1533
  } else if (mPropertyBag.control) {
1509
1534
  const sLibraryName = await mPropertyBag.modifier.getLibraryName(mPropertyBag.control);
1510
- const ChangeHandlerRegistration = await ChangeHandlerRegistration731747ee8b925499a260b98af83836c7;
1511
1535
  await ChangeHandlerRegistration.waitForChangeHandlerRegistration(sLibraryName);
1512
1536
  const sLayer = mPropertyBag.layer || mPropertyBag.flexObject?.getLayer();
1513
1537
  return ChangeHandlerStorage.getChangeHandler(sChangeType, mPropertyBag.controlType, mPropertyBag.control, mPropertyBag.modifier, sLayer);
@@ -1560,16 +1584,7 @@ const Utils = {
1560
1584
  }
1561
1585
  };
1562
1586
 
1563
- var FlexObjectFactory = function () {};
1564
-
1565
- var CHANGES_NAMESPACE = "$sap.ui.fl.changes";
1566
- function getDescriptorChanges(oManifest) {
1567
- var aAppDescriptorChangesRaw = oManifest && oManifest.getEntry && oManifest.getEntry(CHANGES_NAMESPACE) && oManifest.getEntry(CHANGES_NAMESPACE).descriptor || [];
1568
- return aAppDescriptorChangesRaw.map(function (oChange) {
1569
- return FlexObjectFactory.createAppDescriptorChange(oChange);
1570
- });
1571
- }
1572
- var Applier = {
1587
+ const Applier = {
1573
1588
  async applyChanges(oUpdatedManifest, aAppDescriptorChanges, mStrategy) {
1574
1589
  const aChangeHandlers = [];
1575
1590
  for (const oAppDescriptorChange of aAppDescriptorChanges) {
@@ -1590,17 +1605,6 @@ var Applier = {
1590
1605
  }
1591
1606
  });
1592
1607
  return oUpdatedManifest;
1593
- },
1594
- applyChangesIncludedInManifest(oManifest, mStrategy) {
1595
- var aDescriptorChanges = getDescriptorChanges(oManifest);
1596
- var oManifestJSON = oManifest.getJson();
1597
- delete oManifestJSON[CHANGES_NAMESPACE];
1598
- if (aDescriptorChanges.length > 0) {
1599
- return this.applyChanges(oManifestJSON, aDescriptorChanges, mStrategy).then(function () {
1600
- return;
1601
- });
1602
- }
1603
- return Promise.resolve();
1604
1608
  }
1605
1609
  };
1606
1610
 
@@ -3978,10 +3982,10 @@ const PROPERTIES_PATTERNS = {
3978
3982
  customType: "^false$"
3979
3983
  };
3980
3984
  const SUPPORTED_TYPES = {
3981
- uri: "string",
3982
- type: "string",
3985
+ uri: typeof "string",
3986
+ type: typeof "string",
3983
3987
  settings: typeof ({}),
3984
- dataSourceCustom: "boolean",
3988
+ dataSourceCustom: typeof false,
3985
3989
  annotations: typeof []
3986
3990
  };
3987
3991
  function isDataSourceIdExistingInManifest(oManifestDataSources, sDataSourceId) {
@@ -5592,7 +5596,7 @@ function getDesigntimePropertyAsArray(sValue) {
5592
5596
  const m = (/\$([-a-z0-9A-Z._]+)(?::([^$]*))?\$/).exec(sValue);
5593
5597
  return m && m[2] ? m[2].split(/,/) : null;
5594
5598
  }
5595
- const A_RTL_LOCALES = getDesigntimePropertyAsArray("$cldr-rtl-locales:ar,fa,he$") || [];
5599
+ const A_RTL_LOCALES = ["ar", "ar_EG", "ar_SA", "fa", "he"];
5596
5600
  const _coreI18nLocales = getDesigntimePropertyAsArray("$core-i18n-locales:,ar,bg,ca,cnr,cs,cy,da,de,el,en,en_GB,es,es_MX,et,fi,fr,fr_CA,hi,hr,hu,id,it,iw,ja,kk,ko,lt,lv,mk,ms,nl,no,pl,pt,pt_PT,ro,ru,sh,sk,sl,sr,sv,th,tr,uk,vi,zh_CN,zh_TW$");
5597
5601
  function fromSAPLogonLanguage(sSAPLogonLanguage) {
5598
5602
  let oLanguageTag;
@@ -5931,7 +5935,9 @@ var Type = {
5931
5935
  Reference: "Reference",
5932
5936
  Literal: "Literal",
5933
5937
  Variable: "Variable",
5934
- Call: "Call"};
5938
+ Call: "Call",
5939
+ Custom: "Custom"
5940
+ };
5935
5941
  var Op = {
5936
5942
  Equal: "==",
5937
5943
  NotEqual: "!=",
@@ -6453,6 +6459,7 @@ _Helper = {
6453
6459
  }
6454
6460
  return sContentID === oRequest.$ContentID;
6455
6461
  }
6462
+ oClone.decomposed = true;
6456
6463
  oClone.error = _Helper.clone(oError.error);
6457
6464
  oClone.requestUrl = sServiceUrl + oRequest.url;
6458
6465
  oClone.resourcePath = oRequest.$resourcePath;
@@ -6596,13 +6603,22 @@ _Helper = {
6596
6603
  });
6597
6604
  });
6598
6605
  },
6599
- fireChange: function (mChangeListeners, sPropertyPath, vValue, bForceUpdate) {
6600
- var aListeners = mChangeListeners[sPropertyPath], i;
6601
- if (aListeners) {
6602
- for (i = 0; i < aListeners.length; i += 1) {
6603
- aListeners[i].onChange(vValue, bForceUpdate);
6606
+ fireChange: function (mChangeListeners, sPropertyPath, vValue, bForceUpdate, bInArray) {
6607
+ function inform(aChangeListeners, vValue0) {
6608
+ for (let i = 0; i < aChangeListeners.length; i += 1) {
6609
+ aChangeListeners[i].onChange(vValue0, bForceUpdate);
6604
6610
  }
6605
6611
  }
6612
+ if (!mChangeListeners) {
6613
+ return;
6614
+ }
6615
+ if ((sPropertyPath in mChangeListeners)) {
6616
+ inform(mChangeListeners[sPropertyPath], vValue);
6617
+ }
6618
+ if (bInArray) {
6619
+ sPropertyPath += "/";
6620
+ Object.keys(mChangeListeners).filter(sPath => sPath.startsWith(sPropertyPath)).forEach(sPathInArray => inform(mChangeListeners[sPathInArray]));
6621
+ }
6606
6622
  },
6607
6623
  fireChanges: function (mChangeListeners, sPath, oValue, bRemoved) {
6608
6624
  Object.keys(oValue).forEach(function (sProperty) {
@@ -7228,7 +7244,7 @@ _Helper = {
7228
7244
  _Helper.setPrivateAnnotation(oTarget, "predicate", _Helper.getPrivateAnnotation(oSource, "predicate"));
7229
7245
  } else if (Array.isArray(vSourceProperty)) {
7230
7246
  oTarget[sProperty] = vSourceProperty;
7231
- _Helper.fireChange(mChangeListeners, sPropertyPath, vSourceProperty);
7247
+ _Helper.fireChange(mChangeListeners, sPropertyPath, vSourceProperty, false, true);
7232
7248
  } else if (vSourceProperty && typeof vSourceProperty === "object") {
7233
7249
  vTargetProperty = oTarget[sProperty] = _Helper.updateAll(mChangeListeners, sPropertyPath, vTargetProperty || ({}), vSourceProperty);
7234
7250
  _Helper.fireChange(mChangeListeners, sPropertyPath, vTargetProperty);
@@ -7252,7 +7268,7 @@ _Helper = {
7252
7268
  if ((sProperty in oNewObject) || sProperty[0] === "#") {
7253
7269
  if (Array.isArray(vNewProperty)) {
7254
7270
  oOldObject[sProperty] = vNewProperty;
7255
- _Helper.fireChange(mChangeListeners, sPropertyPath, vNewProperty);
7271
+ _Helper.fireChange(mChangeListeners, sPropertyPath, vNewProperty, false, true);
7256
7272
  } else if (vNewProperty && typeof vNewProperty === "object") {
7257
7273
  if (vOldProperty) {
7258
7274
  _Helper.updateExisting(mChangeListeners, sPropertyPath, vOldProperty, vNewProperty);
@@ -7373,9 +7389,9 @@ _Helper = {
7373
7389
  _Helper.setPrivateAnnotation(oTarget, "predicate", sSourcePredicate);
7374
7390
  }
7375
7391
  } else if (Array.isArray(vSourceProperty)) {
7376
- if (!(vTargetProperty && vTargetProperty.$postBodyCollection)) {
7392
+ if (!vTargetProperty?.$postBodyCollection) {
7377
7393
  oTarget[sProperty] = vSourceProperty;
7378
- _Helper.fireChange(mChangeListeners, sPropertyPath, vSourceProperty);
7394
+ _Helper.fireChange(mChangeListeners, sPropertyPath, vSourceProperty, false, true);
7379
7395
  }
7380
7396
  } else if (vSourceProperty && typeof vSourceProperty === "object" && !sProperty.includes("@")) {
7381
7397
  oTarget[sProperty] = update(sPropertyPath, vSelected, vTargetProperty || ({}), vSourceProperty);
@@ -0,0 +1,18 @@
1
+ export default class CacheHolder {
2
+ private static TEMP_TASK_DIR;
3
+ private static getTempDir;
4
+ static read(repoName: string, token: string): Map<string, string> | undefined;
5
+ static write(repoName: string, token: string, files: Map<string, string>): Promise<void>;
6
+ private static isValid;
7
+ /**
8
+ * Clears cached files by repo name and token
9
+ */
10
+ static delete(...paths: string[]): void;
11
+ /**
12
+ * Clears all cached files
13
+ */
14
+ static clear(): void;
15
+ private static deleteDir;
16
+ static clearOutdatedExcept(repoName?: string, maxAgeMs?: number): Promise<void>;
17
+ }
18
+ export declare function cached(): (_target: any, _propertyKey: string, descriptor: PropertyDescriptor) => void;
@@ -0,0 +1,80 @@
1
+ import * as fs from "fs";
2
+ import * as fsPromises from "fs/promises";
3
+ import * as path from "path";
4
+ import ResourceUtil from "../util/resourceUtil.js";
5
+ import encodeFilename from "filenamify";
6
+ import { getLogger } from "@ui5/logger";
7
+ import tempDir from "temp-dir";
8
+ const log = getLogger("@ui5/task-adaptation::CacheHolder");
9
+ export default class CacheHolder {
10
+ static TEMP_TASK_DIR = "ui5-task-adaptation";
11
+ static getTempDir(...paths) {
12
+ return path.join(tempDir, this.TEMP_TASK_DIR, ...paths.map(part => encodeFilename(part, { replacement: "_" })));
13
+ }
14
+ static read(repoName, token) {
15
+ const directory = this.getTempDir(repoName, token);
16
+ if (this.isValid(repoName, "repoName") && this.isValid(token, "token") && fs.existsSync(directory)) {
17
+ return ResourceUtil.read(directory);
18
+ }
19
+ }
20
+ static async write(repoName, token, files) {
21
+ this.delete(repoName);
22
+ if (this.isValid(repoName, "repoName") && this.isValid(token, "token")) {
23
+ await ResourceUtil.write(this.getTempDir(repoName, token), files);
24
+ }
25
+ }
26
+ static isValid(value, name) {
27
+ if (value == null || value === "") {
28
+ log.warn(`No '${name}' provided, skipping cache write`);
29
+ return false;
30
+ }
31
+ return true;
32
+ }
33
+ /**
34
+ * Clears cached files by repo name and token
35
+ */
36
+ static delete(...paths) {
37
+ this.deleteDir(this.getTempDir(...paths));
38
+ }
39
+ /**
40
+ * Clears all cached files
41
+ */
42
+ static clear() {
43
+ this.deleteDir(path.join(tempDir, this.TEMP_TASK_DIR));
44
+ }
45
+ static deleteDir(directory) {
46
+ if (fs.existsSync(directory)) {
47
+ fs.rmSync(directory, { recursive: true, force: true });
48
+ }
49
+ }
50
+ static async clearOutdatedExcept(repoName, maxAgeMs = 1000 * 60 * 60 * 24 * 30) {
51
+ const MAX_AGE = Date.now() - maxAgeMs; // 30 days by default
52
+ const directory = this.getTempDir();
53
+ if (!fs.existsSync(directory)) {
54
+ return;
55
+ }
56
+ const entries = await fsPromises.readdir(directory);
57
+ for (let entry of entries) {
58
+ const repoCacheDirectory = path.join(directory, entry);
59
+ const stats = await fsPromises.lstat(repoCacheDirectory);
60
+ if (stats.isDirectory() && stats.ctimeMs < MAX_AGE && (!repoName || entry !== encodeFilename(repoName))) {
61
+ await fsPromises.rm(repoCacheDirectory, { recursive: true, force: true });
62
+ }
63
+ }
64
+ }
65
+ }
66
+ export function cached() {
67
+ return function (_target, _propertyKey, descriptor) {
68
+ const originalValue = descriptor.value;
69
+ descriptor.value = async function (...args) {
70
+ let files = CacheHolder.read(args[0], args[1]);
71
+ CacheHolder.clearOutdatedExcept(args[0]);
72
+ if (files == null) {
73
+ files = await originalValue.apply(this, args);
74
+ await CacheHolder.write(args[0], args[1], files);
75
+ }
76
+ return files;
77
+ };
78
+ };
79
+ }
80
+ //# sourceMappingURL=cacheHolder.js.map
@@ -2,6 +2,7 @@ import Comparator from "./annotations/comparator/comparator.js";
2
2
  import AnnotationDiffStructureError from "./model/annotationDiffStructureError.js";
3
3
  import { getUniqueName } from "./util/commonUtil.js";
4
4
  import { join } from "path/posix"; // Ensure standardized dir separators to ensure Windows compatibility
5
+ import { slugify } from "transliteration";
5
6
  // To generate keys, english language is more common, so compare all other
6
7
  // languages with it
7
8
  export class PropertyValue {
@@ -69,15 +70,17 @@ export class I18nFileContent {
69
70
  const files = new Map();
70
71
  if (this.hasTranslations()) {
71
72
  this.properties.forEach((i18nLines, language) => {
72
- let filename = "i18n";
73
- if (language.i18n) {
74
- filename += "_" + language.i18n;
73
+ if (language.isDefault) {
74
+ createI18nFile("i18n", i18nLines);
75
75
  }
76
- const filepath = join(i18nPathName, filename + ".properties");
77
- files.set(filepath, [...i18nLines].map(([key, value]) => `${key}=${value}`).join("\n"));
76
+ createI18nFile("i18n_" + language.i18n, i18nLines);
78
77
  });
79
78
  }
80
79
  return files;
80
+ function createI18nFile(filename, i18nLines) {
81
+ const filepath = join(i18nPathName, filename + ".properties");
82
+ files.set(filepath, [...i18nLines].map(([key, value]) => `${key}=${value}`).toSorted().join("\n"));
83
+ }
81
84
  }
82
85
  }
83
86
  export default class I18nManager {
@@ -128,7 +131,7 @@ export default class I18nManager {
128
131
  properties file again. And then compare with the next language and so on
129
132
  and so on */
130
133
  let defaultAnnotation = I18nManager.extractDefaultLanguageAnnotation(annotationJsons);
131
- if (annotationJsons.size > 0 && defaultAnnotation) {
134
+ if (defaultAnnotation && annotationJsons.size > 0) {
132
135
  defaultAnnotation = await this.populate([...annotationJsons], defaultAnnotation);
133
136
  }
134
137
  return defaultAnnotation;
@@ -152,7 +155,6 @@ export default class I18nManager {
152
155
  return p;
153
156
  }
154
157
  static extractDefaultLanguageAnnotation(annotationJsons) {
155
- let json = null;
156
158
  for (const [language, json] of annotationJsons) {
157
159
  if (language.isDefault) {
158
160
  annotationJsons.delete(language);
@@ -160,7 +162,7 @@ export default class I18nManager {
160
162
  }
161
163
  }
162
164
  const language = [...annotationJsons.keys()][0];
163
- json = annotationJsons.get(language);
165
+ let json = annotationJsons.get(language);
164
166
  annotationJsons.delete(language);
165
167
  return { json, language };
166
168
  }
@@ -188,7 +190,7 @@ export default class I18nManager {
188
190
  if (typeof value !== "string") {
189
191
  throw new Error("Failed to create unique key from: " + JSON.stringify(value));
190
192
  }
191
- const propertyName = value.replace(/\W/gi, "_").toUpperCase();
193
+ const propertyName = slugify(value, { separator: "_", uppercase: true }).replace(/\W/gi, "_");
192
194
  const key = getUniqueName([...this.existingKeys.keys()], propertyName);
193
195
  this.existingKeys.add(key);
194
196
  return key;
package/dist/index.js CHANGED
@@ -1,9 +1,11 @@
1
1
  import * as dotenv from "dotenv";
2
2
  import { logBetaUsage, logBuilderVersion } from "./util/commonUtil.js";
3
- import AppVariantManager from "./appVariantManager.js";
4
- import BaseAppManager from "./baseAppManager.js";
5
- import I18NMerger from "./util/i18nMerger.js";
3
+ import AppVariant from "./appVariantManager.js";
4
+ import BaseApp from "./baseAppManager.js";
5
+ import I18nMerger from "./util/i18nMerger.js";
6
+ import ResourceUtil from "./util/resourceUtil.js";
6
7
  import { determineProcessor } from "./processors/processor.js";
8
+ import FilesUtil from "./util/filesUtil.js";
7
9
  /**
8
10
  * Creates an appVariant bundle from the provided resources.
9
11
  */
@@ -13,12 +15,35 @@ export default ({ workspace, options, taskUtil }) => {
13
15
  logBuilderVersion();
14
16
  logBetaUsage();
15
17
  const processor = determineProcessor(options.configuration);
16
- const appVariantResources = await AppVariantManager.getAppVariantResourcesToProcess(workspace);
17
- const appVariantInfo = await AppVariantManager.process(appVariantResources, options.projectNamespace, taskUtil);
18
- const baseAppFiles = await processor.getBaseAppFiles(appVariantInfo.reference);
19
- const { resources, manifestInfo } = await BaseAppManager.process(baseAppFiles, appVariantInfo, options, processor);
20
- const mergedResources = await I18NMerger.mergeI18NFiles(resources, appVariantResources, options.projectNamespace, manifestInfo.i18nPath, appVariantInfo, taskUtil);
21
- await Promise.all(mergedResources.map(resource => workspace.write(resource)));
18
+ const adaptationProject = await AppVariant.fromWorkspace(workspace, options.projectNamespace);
19
+ const appVariantIdHierarchy = await processor.getAppVariantIdHierarchy(adaptationProject.reference);
20
+ // appVariantIdHierarchy contains original application on bottom and the
21
+ // latest app variant on top. We reverse the list to process original
22
+ // application first and then app variants in chronological order.
23
+ const reversedHierarchy = appVariantIdHierarchy.toReversed();
24
+ const fetchFilesPromises = reversedHierarchy.map(({ repoName, cachebusterToken }) => processor.fetch(repoName, cachebusterToken));
25
+ fetchFilesPromises.push(Promise.resolve(adaptationProject.files));
26
+ const adapt = async (baseAppFiles, appVariantFiles) => {
27
+ const baseApp = BaseApp.fromFiles(baseAppFiles);
28
+ const appVariant = AppVariant.fromFiles(appVariantFiles);
29
+ const adaptedFiles = await baseApp.adapt(appVariant, processor);
30
+ return I18nMerger.merge(adaptedFiles, baseApp.i18nPath, appVariant);
31
+ };
32
+ let files = await fetchFilesPromises.reduce(async (previousFiles, currentFiles) => {
33
+ return adapt(await previousFiles, await currentFiles);
34
+ }, fetchFilesPromises.shift());
35
+ if (files) {
36
+ const references = appVariantIdHierarchy.map(item => item.appVariantId);
37
+ files = FilesUtil.filter(files);
38
+ files = FilesUtil.rename(files, references, adaptationProject.id);
39
+ adaptationProject.omitDeletedResources(files, options.projectNamespace, taskUtil);
40
+ const writePromises = new Array();
41
+ files.forEach((content, filename) => {
42
+ const resource = ResourceUtil.createResource(filename, options.projectNamespace, content);
43
+ writePromises.push(workspace.write(resource));
44
+ });
45
+ await Promise.all(writePromises);
46
+ }
22
47
  }
23
48
  return process(workspace, taskUtil);
24
49
  };
@@ -0,0 +1,5 @@
1
+ export default interface IAppVariantIdHierarchyItem {
2
+ appVariantId: string;
3
+ repoName: string;
4
+ cachebusterToken: string;
5
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=appVariantIdHierarchyItem.js.map
@@ -1,8 +1,8 @@
1
1
  export default class Language {
2
- sap: string;
3
- i18n: string;
2
+ readonly sap: string;
3
+ readonly i18n: string;
4
4
  isDefault: boolean;
5
- constructor(sap: string, i18n: string);
5
+ constructor(sap: string, i18n: string, isDefault?: boolean);
6
6
  /**
7
7
  * Create a language array from languages in configuration and default language.
8
8
  * @param languages Typically an array of objects. Probably could be undefined.
@@ -1,11 +1,12 @@
1
+ const DEFAULT_LANGUAGE = "en";
1
2
  export default class Language {
2
3
  sap;
3
4
  i18n;
4
5
  isDefault;
5
- constructor(sap, i18n) {
6
+ constructor(sap, i18n, isDefault = false) {
6
7
  this.sap = sap;
7
8
  this.i18n = i18n;
8
- this.isDefault = sap === "";
9
+ this.isDefault = isDefault;
9
10
  }
10
11
  /**
11
12
  * Create a language array from languages in configuration and default language.
@@ -14,7 +15,6 @@ export default class Language {
14
15
  * followed by the passed config languages.
15
16
  */
16
17
  static create(languages) {
17
- const defaultLanguage = new Language("", "");
18
18
  let configLanguages = [];
19
19
  if (languages !== undefined) {
20
20
  configLanguages = languages.map(item => {
@@ -30,7 +30,14 @@ export default class Language {
30
30
  }
31
31
  });
32
32
  }
33
- return [defaultLanguage, ...configLanguages];
33
+ let defaultLanguage = configLanguages.find(language => language.sap.toLowerCase() === DEFAULT_LANGUAGE) ?? configLanguages[0];
34
+ if (defaultLanguage) {
35
+ defaultLanguage.isDefault = true;
36
+ }
37
+ else {
38
+ return [new Language(DEFAULT_LANGUAGE.toUpperCase(), DEFAULT_LANGUAGE, true), ...configLanguages];
39
+ }
40
+ return configLanguages;
34
41
  }
35
42
  ;
36
43
  }
@@ -60,11 +60,13 @@ export interface IChange {
60
60
  texts?: IChangeText;
61
61
  layer?: string;
62
62
  content?: IChangeContent;
63
+ filename: string;
63
64
  }
64
65
  export interface IChangeText {
65
66
  i18n: string;
66
67
  }
67
68
  export interface IChangeContent {
69
+ dataSource?: any;
68
70
  bundleUrl?: string;
69
71
  fallbackLocale?: string;
70
72
  modelId?: string;
@@ -1,17 +1,17 @@
1
1
  import AbapRepoManager from "../repositories/abapRepoManager.js";
2
2
  import AnnotationManager from "../annotationManager.js";
3
- import BaseAppFilesCacheManager from "../cache/baseAppFilesCacheManager.js";
3
+ import IAppVariantIdHierarchyItem from "../model/appVariantIdHierarchyItem.js";
4
4
  import { IConfiguration } from "../model/types.js";
5
5
  import IProcessor from "./processor.js";
6
6
  export default class AbapProcessor implements IProcessor {
7
7
  private abapRepoManager;
8
8
  private configuration;
9
- private cacheManager;
10
9
  private annotationManager;
11
- constructor(configuration: IConfiguration, cacheManager: BaseAppFilesCacheManager, abapRepoManager: AbapRepoManager, annotationManager: AnnotationManager);
12
- getBaseAppFiles(baseAppId: string): Promise<Map<string, string>>;
10
+ constructor(configuration: IConfiguration, abapRepoManager: AbapRepoManager, annotationManager: AnnotationManager);
11
+ getAppVariantIdHierarchy(appId: string): Promise<IAppVariantIdHierarchyItem[]>;
12
+ fetch(repoName: string, _cachebusterToken: string): Promise<Map<string, string>>;
13
13
  validateConfiguration(): void;
14
- updateLandscapeSpecificContent(renamedBaseAppManifest: any, baseAppFiles?: Map<string, string>): Promise<void>;
14
+ updateLandscapeSpecificContent(baseAppManifest: any, baseAppFiles: Map<string, string>, appVariantId: string): Promise<void>;
15
15
  getConfigurationType(): string;
16
16
  createAppVariantHierarchyItem(appVariantId: string, version: string): {
17
17
  appVariantId: string;
@@ -1,26 +1,35 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
1
7
  import Language from "../model/language.js";
8
+ import { cached } from "../cache/cacheHolder.js";
2
9
  import { validateObject } from "../util/commonUtil.js";
3
10
  export default class AbapProcessor {
4
11
  abapRepoManager;
5
12
  configuration;
6
- cacheManager;
7
13
  annotationManager;
8
- constructor(configuration, cacheManager, abapRepoManager, annotationManager) {
14
+ constructor(configuration, abapRepoManager, annotationManager) {
9
15
  this.configuration = configuration;
10
16
  this.abapRepoManager = abapRepoManager;
11
- this.cacheManager = cacheManager;
12
17
  this.annotationManager = annotationManager;
13
18
  }
14
- getBaseAppFiles(baseAppId) {
15
- return this.cacheManager.getFiles(() => this.abapRepoManager.getMetadata(baseAppId), () => this.abapRepoManager.downloadBaseAppFiles());
19
+ getAppVariantIdHierarchy(appId) {
20
+ return this.abapRepoManager.getAppVariantIdHierarchy(appId);
21
+ }
22
+ fetch(repoName, _cachebusterToken) {
23
+ return this.abapRepoManager.fetch(repoName);
16
24
  }
17
25
  validateConfiguration() {
18
26
  // validate general app config
19
27
  const properties = ["appName"];
20
28
  validateObject(this.configuration, properties, "should be specified in ui5.yaml configuration");
21
29
  }
22
- async updateLandscapeSpecificContent(renamedBaseAppManifest, baseAppFiles) {
23
- const files = await this.annotationManager.process(renamedBaseAppManifest, (Language.create(this.configuration.languages)));
30
+ async updateLandscapeSpecificContent(baseAppManifest, baseAppFiles, appVariantId) {
31
+ const languages = Language.create(this.configuration.languages);
32
+ const files = await this.annotationManager.process(baseAppManifest, languages, appVariantId);
24
33
  if (baseAppFiles) {
25
34
  files.forEach((value, key) => baseAppFiles.set(key, value));
26
35
  }
@@ -36,4 +45,7 @@ export default class AbapProcessor {
36
45
  };
37
46
  }
38
47
  }
48
+ __decorate([
49
+ cached()
50
+ ], AbapProcessor.prototype, "fetch", null);
39
51
  //# sourceMappingURL=abapProcessor.js.map
@@ -1,11 +1,11 @@
1
- import BaseAppFilesCacheManager from "../cache/baseAppFilesCacheManager.js";
1
+ import IAppInfo from "../model/appVariantIdHierarchyItem.js";
2
2
  import { IConfiguration } from "../model/types.js";
3
3
  import IProcessor from "./processor.js";
4
4
  export default class CFProcessor implements IProcessor {
5
5
  private configuration;
6
- private cacheManager;
7
- constructor(configuration: IConfiguration, cacheManager: BaseAppFilesCacheManager);
8
- getBaseAppFiles(): Promise<Map<string, string>>;
6
+ constructor(configuration: IConfiguration);
7
+ getAppVariantIdHierarchy(appId: string): Promise<IAppInfo[]>;
8
+ fetch(_repoName: string, _cachebusterToken: string): Promise<Map<string, string>>;
9
9
  validateConfiguration(): void;
10
10
  updateLandscapeSpecificContent(renamedBaseAppManifest: any): Promise<void>;
11
11
  private updateCloudPlatform;