@ui5/task-adaptation 1.4.0 → 1.4.2

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.
@@ -69,6 +69,9 @@ export function removePropertiesExtension(filePath) {
69
69
  return filePath.substring(0, lastIndexOf);
70
70
  }
71
71
  export function traverse(json, paths, callback) {
72
+ if (!json) {
73
+ return;
74
+ }
72
75
  for (const key of Object.keys(json)) {
73
76
  const internPaths = [...paths];
74
77
  internPaths.push(key);
@@ -5,7 +5,7 @@ export default class RequestUtil {
5
5
  return this.request(url, axios.head);
6
6
  }
7
7
  static async get(url, options) {
8
- return this.request(url, axios.get, options);
8
+ return this.request(url, axios.get, options).then(response => response.data);
9
9
  }
10
10
  static async request(url, method, options) {
11
11
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ui5/task-adaptation",
3
- "version": "1.4.0",
3
+ "version": "1.4.2",
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": {
@@ -41,15 +41,16 @@
41
41
  "@ui5/fs": "^4.0.1",
42
42
  "@ui5/logger": "^4.0.1",
43
43
  "adm-zip": "^0.5.5",
44
- "axios": "^1.6.2",
44
+ "axios": "^1.7.9",
45
45
  "crc": "^4.3.2",
46
46
  "dotenv": "^16.0.3",
47
47
  "jsdom": "^23.0.1",
48
+ "meriyah": "^6.0.3",
48
49
  "temp-dir": "^2.0.0",
49
50
  "xml-js": "^1.6.11"
50
51
  },
51
52
  "devDependencies": {
52
- "@buxlabs/amd-to-es6": "^0.16.1",
53
+ "@buxlabs/amd-to-es6": "^0.16.3",
53
54
  "@istanbuljs/nyc-config-typescript": "^1.0.1",
54
55
  "@rollup/plugin-node-resolve": "^15.2.3",
55
56
  "@types/adm-zip": "^0.4.34",
@@ -0,0 +1,22 @@
1
+ import { parse } from "meriyah";
2
+ import { traverse } from "../../src/util/commonUtil.js";
3
+
4
+ export default function convert(content: string) {
5
+ return [
6
+ extractEsmClass
7
+ ].reduce((result, converter) => converter(result), content);
8
+ }
9
+
10
+ function extractEsmClass(content: string) {
11
+ const result = parse(content, { ranges: true });
12
+ let classCode: { start: number, end: number } | undefined;
13
+ traverse(result, [], (json, key) => {
14
+ if (key === "type" && json[key] === "ClassDeclaration") {
15
+ if (classCode) {
16
+ throw new Error("Only one class declaration per module is allowed");
17
+ }
18
+ classCode = json;
19
+ }
20
+ });
21
+ return classCode && "export default " + content.substring(classCode.start, classCode.end) || content;
22
+ }
@@ -1,4 +1,5 @@
1
1
  export default class config {
2
+ config = new Map();
2
3
  static get Type() {
3
4
  return {
4
5
  String: "string"
@@ -7,4 +8,14 @@ export default class config {
7
8
  static get({ name }) {
8
9
  return name === "sapUiLogLevel" ? "Error" : undefined;
9
10
  }
11
+ static getWritableInstance() {
12
+ return {
13
+ get(obj) {
14
+ config.get(obj.name);
15
+ },
16
+ set(name, obj) {
17
+ config.set(name, obj);
18
+ }
19
+ }
20
+ }
10
21
  }
@@ -6,7 +6,7 @@ metadata:
6
6
  allowSapInternal: true
7
7
  framework:
8
8
  name: SAPUI5
9
- version: 0.0.0
9
+ version: 1.131.0
10
10
  libraries:
11
11
  - name: sap.ui.fl
12
12
  - name: sap.suite.ui.generic.template
@@ -4,6 +4,7 @@ import * as path from "path";
4
4
 
5
5
  //@ts-ignore
6
6
  import convertAMDtoES6 from "@buxlabs/amd-to-es6";
7
+ import convertAMDtoESM from "./amdToEsm.js";
7
8
  import { dirname } from "node:path";
8
9
  import { fileURLToPath } from "node:url";
9
10
  import { getLogger } from "@ui5/logger";
@@ -93,7 +94,11 @@ export default function (options: any) {
93
94
  .replace(/\, \/\* bExport\= \*\/ true\)/g, ")")
94
95
  .replace(/},.*(true|false)\);$/g, "});")
95
96
  .replace(/},.*(true|false)\);(\n\/\/# sourceMappingURL=)*/g, "});\n//# sourceMappingURL=");
96
- return convertAMDtoES6(code);
97
+ try {
98
+ return convertAMDtoES6(code);
99
+ } catch (_: any) {
100
+ return convertAMDtoESM(code);
101
+ }
97
102
  }
98
103
 
99
104
  };
@@ -114,6 +119,7 @@ function transform(code: string, id: string) {
114
119
  function replaceRequireAsync(code: string) {
115
120
  const requireAsyncPattern = /requireAsync((.bind\(this, ")|(\("))+(?<url>[\/\w]*)"\)/mg;
116
121
  let match, defineUrls = new Array<string>(), defineVars = new Array<string>(), matches = new Map();
122
+ // eslint-disable-next-line no-cond-assign
117
123
  while (match = requireAsyncPattern.exec(code)) {
118
124
  if (match.groups?.url) {
119
125
  const varaibleName = match.groups.url.split("/").pop() + crypto.randomBytes(16).toString("hex");
package/scripts/rollup.ts CHANGED
@@ -120,7 +120,7 @@ export default class Builder {
120
120
  "./dist/bundle.js",
121
121
  [
122
122
  "sap/ui/performance/Measurement",
123
- "sap/base/config.js"
123
+ "sap/base/config"
124
124
  ]
125
125
  );
126
126
  this.copyTypeDefinition();