@ui5/task-adaptation 1.3.3 → 1.4.1

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.
@@ -13,7 +13,7 @@ export interface IConfiguration {
13
13
  enableAnnotationCache?: boolean;
14
14
  enableBetaFeatures?: boolean;
15
15
  writeTempFiles?: any;
16
- connections?: (AbapTarget & IAbapTargetMeta)[];
16
+ target?: AbapTarget & IAbapTargetMeta;
17
17
  }
18
18
  export interface IAbapTargetMeta {
19
19
  name?: string;
@@ -2,8 +2,6 @@ import type { AbapServiceProvider } from "@sap-ux/axios-extension";
2
2
  import { IConfiguration } from "../model/types.js";
3
3
  export default class AbapProvider {
4
4
  private provider;
5
- get({ connections, destination }: IConfiguration): Promise<AbapServiceProvider>;
6
- private static validateAndGetTargetConfiguration;
7
- private static validateConnectionConfiguration;
8
- private createProvider;
5
+ get({ target, destination }: IConfiguration): Promise<AbapServiceProvider>;
6
+ private static validateAndGetAbapTarget;
9
7
  }
@@ -3,67 +3,35 @@ import BtpUtils from "@sap-ux/btp-utils";
3
3
  import { getLogger } from "@ui5/logger";
4
4
  import { validateObject } from "../util/commonUtil.js";
5
5
  const log = getLogger("@ui5/task-adaptation::AbapProvider");
6
+ log.debug = (message) => log.verbose(message);
6
7
  export default class AbapProvider {
7
8
  provider = null;
8
- async get({ connections, destination }) {
9
+ async get({ target, destination }) {
9
10
  if (!this.provider) {
10
- AbapProvider.validateConnectionConfiguration(connections, destination);
11
- // we try to detect is it either destination for BAS or url for IDE
12
- let targetConfiguration = AbapProvider.validateAndGetTargetConfiguration(connections);
13
- if (targetConfiguration) {
14
- this.provider = await this.createProvider(targetConfiguration);
15
- }
16
- else if (destination) {
17
- // still if no suitable connections found, we assume that it's
18
- // old config with destination
19
- this.provider = await this.createProvider({ destination });
20
- }
21
- else {
22
- // if no suitible configs found - throw error
23
- const environment = BtpUtils.isAppStudio() ? "SAP Business Application Studio" : "local IDE";
24
- throw new Error(`ABAP connection configuration for ${environment} is not provided`);
11
+ const abapTarget = AbapProvider.validateAndGetAbapTarget(target, destination);
12
+ if (abapTarget) {
13
+ this.provider = await createAbapServiceProvider(abapTarget, { ignoreCertErrors: abapTarget.ignoreCertErrors }, true, log);
25
14
  }
26
15
  }
27
- return this.provider;
28
- }
29
- static validateAndGetTargetConfiguration(connections) {
30
- // we're trying to detect is it destination for BAS or url for IDE
31
- const abapTargetProperties = BtpUtils.isAppStudio() ? ["destination"] : ["url"];
32
- if (connections) {
33
- for (const connection of connections) {
34
- try {
35
- validateObject(connection, abapTargetProperties, "should be specified in ui5.yaml configuration/target");
36
- }
37
- catch (error) {
38
- continue;
39
- }
40
- return connection;
41
- }
16
+ if (!this.provider) {
17
+ throw new Error("Target should be specified in ui5.yaml configuration to connect the ABAP system");
42
18
  }
19
+ return this.provider;
43
20
  }
44
- static validateConnectionConfiguration(connections, destination) {
45
- // then abap connection config either old destination propery, or new
46
- // connections/destination for BAS or connections/url for IDE
47
- if (!connections && !destination) {
48
- throw new Error("ABAP connections should be specified in ui5.yaml configuration");
49
- }
50
- if (destination) {
51
- log.warn("Deprecated, use connections/destination configuration instead, see README.md");
21
+ static validateAndGetAbapTarget(target, destination) {
22
+ if (target) {
23
+ // if target configuration appears, we validate that it should be
24
+ // either target/destination for BAS or target/url for IDE we're
25
+ // trying to detect is it destination for BAS or url for IDE
26
+ const abapTargetProperties = BtpUtils.isAppStudio() ? ["destination"] : ["url"];
27
+ validateObject(target, abapTargetProperties, "should be specified in ui5.yaml configuration/target");
28
+ return target;
52
29
  }
53
- // if connections configuration appears, we validate that it should be
54
- // either connections/destination for BAS or connections/url for IDE
55
- if (connections && !AbapProvider.validateAndGetTargetConfiguration(connections)) {
56
- throw new Error("ABAP connection settings should be specified in ui5.yaml configuration");
30
+ else if (destination) {
31
+ log.warn("Destination is deprecated, use target/destination configuration instead");
32
+ return { destination };
57
33
  }
58
- // no connections and destination the same time to avoid ambiguity
59
- if (connections && destination) {
60
- throw new Error("Either destination or connections should be presented in configuration, not both");
61
- }
62
- }
63
- createProvider(abapTarget) {
64
- // createAbapServiceProvider requires log.debug, which is not implemented in ui5 logger.
65
- log.debug = (message) => log.verbose(message);
66
- return createAbapServiceProvider(abapTarget, { ignoreCertErrors: abapTarget.ignoreCertErrors }, true, log);
34
+ throw new Error("Target should be specified in ui5.yaml configuration to connect the ABAP system");
67
35
  }
68
36
  }
69
37
  //# sourceMappingURL=abapProvider.js.map
@@ -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);
@@ -1,4 +1,3 @@
1
- /// <reference path="../../types/ui5.d.ts" />
2
1
  import * as Resource from "@ui5/fs/Resource";
3
2
  import { IAppVariantInfo } from "../model/types.js";
4
3
  type Resource = typeof Resource;
@@ -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 {
@@ -1,2 +1 @@
1
- /// <reference types="node" />
2
1
  export declare function unzipZipEntries(zip: Buffer): Promise<Map<string, string>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ui5/task-adaptation",
3
- "version": "1.3.3",
3
+ "version": "1.4.1",
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": {
@@ -33,23 +33,24 @@
33
33
  "author": "SAP SE",
34
34
  "license": "Apache-2.0",
35
35
  "dependencies": {
36
- "@sap-ux/axios-extension": "^1.13.1",
37
- "@sap-ux/btp-utils": "^0.14.4",
38
- "@sap-ux/store": "^0.6.0",
39
- "@sap-ux/system-access": "^0.4.2",
36
+ "@sap-ux/axios-extension": "^1.16.6",
37
+ "@sap-ux/btp-utils": "^0.15.2",
38
+ "@sap-ux/store": "^0.9.1",
39
+ "@sap-ux/system-access": "^0.5.11",
40
40
  "@sap/cf-tools": "^3.2.0",
41
- "@ui5/fs": "^3.0.5",
42
- "@ui5/logger": "^3.0.0",
41
+ "@ui5/fs": "^4.0.1",
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",
@@ -61,7 +62,7 @@
61
62
  "@types/mocha": "^9.1.0",
62
63
  "@types/semver": "^7.3.8",
63
64
  "@types/sinon": "^10.0.16",
64
- "@ui5/project": "^3.9.0",
65
+ "@ui5/project": "^4.0.3",
65
66
  "amdextract": "^3.0.0",
66
67
  "builtin-modules": "^3.2.0",
67
68
  "c8": "^9.1.0",
@@ -80,7 +81,7 @@
80
81
  "nyc": "^15.1.0",
81
82
  "rollup": "^4.9.6",
82
83
  "semver": "^7.3.5",
83
- "sinon": "^17.0.1",
84
+ "sinon": "^18.0.1",
84
85
  "source-map-support": "^0.5.19",
85
86
  "tsx": "^4.7.1",
86
87
  "typescript": "^5.4.2",
@@ -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.1
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
  };
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();