@ui5/task-adaptation 1.0.21 → 1.0.23
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 +5 -1
- package/dist/annotationManager.d.ts +3 -4
- package/dist/annotationManager.js +20 -56
- package/dist/annotations/oDataModel.d.ts +20 -0
- package/dist/annotations/oDataModel.js +46 -0
- package/dist/annotations/oDataV2Model.d.ts +4 -0
- package/dist/annotations/oDataV2Model.js +13 -0
- package/dist/annotations/serviceRequestor.d.ts +17 -0
- package/dist/annotations/serviceRequestor.js +36 -0
- package/dist/appVariantManager.js +1 -1
- package/dist/i18nManager.d.ts +11 -10
- package/dist/i18nManager.js +19 -19
- package/dist/index.js +2 -0
- package/dist/model/language.d.ts +13 -0
- package/dist/model/language.js +37 -0
- package/dist/model/types.d.ts +1 -1
- package/dist/processors/abapProcessor.js +2 -2
- package/dist/repositories/abapRepoManager.js +2 -1
- package/dist/util/cfUtil.js +1 -1
- package/dist/util/commonUtil.d.ts +1 -0
- package/dist/util/commonUtil.js +13 -1
- package/dist/util/jsonDiffUtil.d.ts +14 -3
- package/dist/util/jsonDiffUtil.js +29 -9
- package/package.json +4 -3
- package/scripts/metadataDownloadHelper.ts +85 -0
- package/scripts/rollup.ts +0 -9
- package/dist/bundle-resourceBundle.js +0 -692
- package/scripts/rollup/bundleDefinition-resourceBundle.js +0 -5
- package/scripts/rollup/overrides/sap/base/i18n/Localization.js +0 -1
- package/scripts/rollup/overrides/sap/base/string/formatMessage.js +0 -1
- package/scripts/rollup/overrides/sap/base/util/Properties.js +0 -1
- package/scripts/rollup/overrides/sap/base/util/merge.js +0 -1
|
@@ -1,22 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DiffTypeEnum = void 0;
|
|
3
4
|
const jsonDiff = require("json-diff");
|
|
4
5
|
const annotationDiffStructureError_1 = require("../model/annotationDiffStructureError");
|
|
6
|
+
var DiffTypeEnum;
|
|
7
|
+
(function (DiffTypeEnum) {
|
|
8
|
+
DiffTypeEnum[DiffTypeEnum["MINUS"] = 0] = "MINUS";
|
|
9
|
+
DiffTypeEnum[DiffTypeEnum["PLUS"] = 1] = "PLUS";
|
|
10
|
+
DiffTypeEnum[DiffTypeEnum["DELTA"] = 2] = "DELTA";
|
|
11
|
+
})(DiffTypeEnum = exports.DiffTypeEnum || (exports.DiffTypeEnum = {}));
|
|
5
12
|
class JsonDiffUtil {
|
|
6
|
-
static diff(jsonA, jsonB
|
|
13
|
+
static diff(jsonA, jsonB, options = {
|
|
14
|
+
throwErrorOnDiffStructure: true,
|
|
15
|
+
restoreOriginalValue: false
|
|
16
|
+
}) {
|
|
7
17
|
const json = jsonDiff.diff(jsonA, jsonB, { full: true, sort: false });
|
|
8
|
-
const properties = this.findDiffsAndRestoreStructure(json);
|
|
18
|
+
const properties = this.findDiffsAndRestoreStructure(json, options);
|
|
9
19
|
return {
|
|
10
20
|
json,
|
|
11
21
|
properties
|
|
12
22
|
};
|
|
13
23
|
}
|
|
14
|
-
static findDiffsAndRestoreStructure(object) {
|
|
24
|
+
static findDiffsAndRestoreStructure(object, options) {
|
|
15
25
|
const properties = new Set();
|
|
16
|
-
this.traverseDiffRecursive(properties, { object }, "object");
|
|
26
|
+
this.traverseDiffRecursive(properties, { object }, "object", options);
|
|
17
27
|
return properties;
|
|
18
28
|
}
|
|
19
|
-
static traverseDiffRecursive(properties, object, property) {
|
|
29
|
+
static traverseDiffRecursive(properties, object, property, options) {
|
|
20
30
|
const current = object[property];
|
|
21
31
|
if (typeof current !== "object") {
|
|
22
32
|
return;
|
|
@@ -29,10 +39,17 @@ class JsonDiffUtil {
|
|
|
29
39
|
// This is a sign from json-diff plugin, that the property contains differences.
|
|
30
40
|
// We will remove these signs, to restore the original structure
|
|
31
41
|
if (item[0] === "~") {
|
|
32
|
-
this.traverseDiffRecursive(properties, item, 1);
|
|
42
|
+
this.traverseDiffRecursive(properties, item, 1, options);
|
|
33
43
|
}
|
|
34
44
|
else if (item[0] === "+" || item[0] === "-") {
|
|
35
|
-
|
|
45
|
+
if (options.throwErrorOnDiffStructure) {
|
|
46
|
+
throw new annotationDiffStructureError_1.default(item[1]);
|
|
47
|
+
}
|
|
48
|
+
properties.add({
|
|
49
|
+
object: object[property],
|
|
50
|
+
property: i,
|
|
51
|
+
type: item[0] === "+" ? DiffTypeEnum.PLUS : DiffTypeEnum.MINUS
|
|
52
|
+
});
|
|
36
53
|
}
|
|
37
54
|
}
|
|
38
55
|
}
|
|
@@ -40,11 +57,14 @@ class JsonDiffUtil {
|
|
|
40
57
|
else {
|
|
41
58
|
for (const key of Object.keys(current)) {
|
|
42
59
|
if (key == "__old" || key == "__new") {
|
|
43
|
-
|
|
60
|
+
if (options.restoreOriginalValue) {
|
|
61
|
+
object[property] = current["__old"];
|
|
62
|
+
}
|
|
63
|
+
properties.add({ object, property, type: DiffTypeEnum.DELTA });
|
|
44
64
|
break;
|
|
45
65
|
}
|
|
46
66
|
else {
|
|
47
|
-
this.traverseDiffRecursive(properties, current, key);
|
|
67
|
+
this.traverseDiffRecursive(properties, current, key, options);
|
|
48
68
|
}
|
|
49
69
|
}
|
|
50
70
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ui5/task-adaptation",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.23",
|
|
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": {
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
"prepublishOnly": "git push --follow-tags",
|
|
15
15
|
"release-note": "git-chglog -c .chglog/release-config.yml v$npm_package_version",
|
|
16
16
|
"rollup": "npx ts-node scripts/rollup.ts",
|
|
17
|
-
"build": "npm run rollup && tsc -p ./"
|
|
17
|
+
"build": "npm run rollup && tsc -p ./",
|
|
18
|
+
"download-metadata": "npx ts-node scripts/metadataDownloadHelper.ts"
|
|
18
19
|
},
|
|
19
20
|
"repository": {
|
|
20
21
|
"type": "git",
|
|
@@ -40,7 +41,7 @@
|
|
|
40
41
|
"@ui5/project": "^2.6.0",
|
|
41
42
|
"adm-zip": "^0.5.5",
|
|
42
43
|
"amdextract": "^3.0.0",
|
|
43
|
-
"axios": "^1.6.
|
|
44
|
+
"axios": "^1.6.2",
|
|
44
45
|
"builtin-modules": "^3.2.0",
|
|
45
46
|
"dotenv": "^16.0.3",
|
|
46
47
|
"js-yaml": "^4.1.0",
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import * as dotenv from "dotenv";
|
|
2
|
+
import * as fs from "fs/promises";
|
|
3
|
+
import { Agent } from "https";
|
|
4
|
+
import RequestUtil from "../src/util/requestUtil";
|
|
5
|
+
|
|
6
|
+
dotenv.config();
|
|
7
|
+
const httpsAgent = new Agent({ rejectUnauthorized: false });
|
|
8
|
+
|
|
9
|
+
export default class MetadataDownloadHelper {
|
|
10
|
+
|
|
11
|
+
static async readAllUrls() {
|
|
12
|
+
await fs.readdir("./test/resources/annotations/inline", { encoding: "utf8" });
|
|
13
|
+
const resultsObject = JSON.parse(await fs.readFile("./test/resources/allReleasedODataServices.json", { encoding: "utf8" }));
|
|
14
|
+
return this.exractUrlsFromResponse(resultsObject);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
static async fetchAllUrls(host: string) {
|
|
18
|
+
const REQUEST_OPTIONS_JSON = {
|
|
19
|
+
headers: {
|
|
20
|
+
"Content-Type": "application/json; charset=utf-8",
|
|
21
|
+
'Cookie': process.env.cookie,
|
|
22
|
+
},
|
|
23
|
+
httpsAgent
|
|
24
|
+
};
|
|
25
|
+
const url = "/sap/bc/ui2/app_index?sap.fiori/cloudDevAdaptationStatus=released&fields=sap.app/id,sap.app/dataSources/OData/uri";
|
|
26
|
+
const response = await RequestUtil.get(host + url, REQUEST_OPTIONS_JSON);
|
|
27
|
+
const allUris = this.exractUrlsFromResponse(response);
|
|
28
|
+
for (const [index, url] of allUris.entries()) {
|
|
29
|
+
try {
|
|
30
|
+
const metadataFile = await this.fetchMetadataFileByUri(host, url);
|
|
31
|
+
if (typeof metadataFile === "object") {
|
|
32
|
+
console.error(`Received object instead of xml file with content: ${JSON.stringify(metadataFile)}`)
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
// @ts-ignore
|
|
36
|
+
await fs.writeFile(`test/resources/metadata/download/${index}__${url.replaceAll("/", "_")}.xml`, metadataFile, { encoding: "utf8" });
|
|
37
|
+
} catch (e: any) {
|
|
38
|
+
console.error(`Error fetching metadata file with url ${url} with error \n\n ${e}`);
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
private static exractUrlsFromResponse(resultsObject: any) {
|
|
45
|
+
let allUrls: string[] = [];
|
|
46
|
+
resultsObject.results.map((value: any) => {
|
|
47
|
+
allUrls = allUrls.concat(value["sap.app/dataSources/OData/uri"]);
|
|
48
|
+
});
|
|
49
|
+
return allUrls;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
static readMetadataFileByFilePath(filePath: string) {
|
|
53
|
+
return fs.readFile(filePath, { encoding: "utf8" });
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
static fetchMetadataFileByUri(host: string, uri: string) {
|
|
57
|
+
const REQUEST_OPTIONS_XML = {
|
|
58
|
+
headers: {
|
|
59
|
+
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
|
|
60
|
+
'Cookie': process.env.cookie,
|
|
61
|
+
},
|
|
62
|
+
httpsAgent
|
|
63
|
+
};
|
|
64
|
+
uri = uri.endsWith("/") ? `${uri}$metadata` : `${uri}/$metadata`;
|
|
65
|
+
return RequestUtil.get(host + uri, REQUEST_OPTIONS_XML);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Get the command line arguments
|
|
70
|
+
const args = process.argv;
|
|
71
|
+
|
|
72
|
+
// Find the index of the `--host=` argument
|
|
73
|
+
const hostArgIndex = args.findIndex(arg => arg.startsWith('--host='));
|
|
74
|
+
|
|
75
|
+
// If the `--host=` argument is found
|
|
76
|
+
if (hostArgIndex !== -1) {
|
|
77
|
+
// Extract the value of the `--host=` argument
|
|
78
|
+
const hostArg = args[hostArgIndex];
|
|
79
|
+
const host = hostArg.split('=')[1];
|
|
80
|
+
|
|
81
|
+
// Use the `host` variable as needed
|
|
82
|
+
MetadataDownloadHelper.fetchAllUrls(host);
|
|
83
|
+
} else {
|
|
84
|
+
console.info("Please provide missing host parameter");
|
|
85
|
+
}
|
package/scripts/rollup.ts
CHANGED
|
@@ -73,15 +73,6 @@ export default class Builder {
|
|
|
73
73
|
[
|
|
74
74
|
"sap/ui/thirdparty/URI"
|
|
75
75
|
]);
|
|
76
|
-
await Bundler.run(
|
|
77
|
-
project,
|
|
78
|
-
"bundleDefinition-resourceBundle.js",
|
|
79
|
-
"./dist/bundle-resourceBundle.js",
|
|
80
|
-
"/sap.ui.core",
|
|
81
|
-
[
|
|
82
|
-
"/resources/sap/base/**"
|
|
83
|
-
]
|
|
84
|
-
);
|
|
85
76
|
}
|
|
86
77
|
}
|
|
87
78
|
|