@ui5/task-adaptation 1.5.0 → 1.5.2-rc.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.
- package/CHANGELOG.md +8 -4
- package/dist/annotationManager.d.ts +1 -2
- package/dist/annotationManager.js +4 -8
- package/dist/appVariantManager.d.ts +15 -0
- package/dist/appVariantManager.js +49 -6
- package/dist/baseAppManager.d.ts +9 -1
- package/dist/baseAppManager.js +56 -16
- package/dist/bundle.js +97 -59
- package/dist/index.js +40 -17
- package/dist/model/configuration.d.ts +1 -0
- package/dist/processors/abapProcessor.d.ts +1 -1
- package/dist/processors/abapProcessor.js +2 -2
- package/dist/processors/cfProcessor.d.ts +3 -1
- package/dist/processors/cfProcessor.js +51 -2
- package/dist/processors/processor.d.ts +1 -1
- package/dist/util/cfUtil.d.ts +47 -0
- package/dist/util/cfUtil.js +121 -0
- package/dist/util/commonUtil.d.ts +1 -3
- package/dist/util/commonUtil.js +8 -104
- package/dist/util/filesUtil.d.ts +11 -12
- package/dist/util/filesUtil.js +65 -31
- package/dist/util/i18nMerger.js +3 -3
- package/dist/util/movingHandler/fileMoveHandler.d.ts +8 -0
- package/dist/util/movingHandler/fileMoveHandler.js +77 -0
- package/dist/util/renamingHandlers/{manifestHandler.d.ts → manifestRenamingHandler.d.ts} +1 -1
- package/dist/util/renamingHandlers/{manifestHandler.js → manifestRenamingHandler.js} +2 -2
- package/dist/util/renamingUtil.d.ts +3 -0
- package/dist/util/renamingUtil.js +111 -0
- package/package.json +124 -126
- package/scripts/rollup/overrides/sap/base/config.js +52 -14
- package/scripts/rollup.ts +1 -2
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { getLogger } from "@ui5/logger";
|
|
2
|
+
const log = getLogger("@ui5/task-adaptation::RenamingUtil");
|
|
3
|
+
export function rename(content, references, replacement) {
|
|
4
|
+
return renameMap(content, new Map(references.map(ref => [ref, replacement])), [replacement]);
|
|
5
|
+
}
|
|
6
|
+
export function renameMap(content, references, ignoreInStrings) {
|
|
7
|
+
const ignoredReferenceKeys = [];
|
|
8
|
+
for (const [key, value] of references) {
|
|
9
|
+
if (value.includes(".") !== key.includes(".")) {
|
|
10
|
+
ignoredReferenceKeys.push(key);
|
|
11
|
+
references.delete(key);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
if (ignoredReferenceKeys.length > 0) {
|
|
15
|
+
log.info(`Ignored renaming: ${ignoredReferenceKeys.join(", ")}`);
|
|
16
|
+
}
|
|
17
|
+
const searchTerms = [...references.keys()];
|
|
18
|
+
if (!content || !searchTerms || searchTerms.length === 0) {
|
|
19
|
+
return content;
|
|
20
|
+
}
|
|
21
|
+
const dotToSlash = (str) => str.replaceAll(".", "\/");
|
|
22
|
+
// We don't want to replace in adaptation project ids
|
|
23
|
+
ignoreInStrings.push(...ignoreInStrings, ...ignoreInStrings.map(dotToSlash));
|
|
24
|
+
let start = 0;
|
|
25
|
+
while (true) {
|
|
26
|
+
// If we don't replace some strings in the content - we find all of them
|
|
27
|
+
// and then don't replace inside their start and end indices.
|
|
28
|
+
const ignoredStrings = ignoreInStrings.map(string => {
|
|
29
|
+
return findAllOccurrences(content, string, start).map(i => ({ start: i, end: i + string.length }));
|
|
30
|
+
}).filter(arr => arr.length > 0) || [];
|
|
31
|
+
// We find the next search index with dots and slashes. Then we replace
|
|
32
|
+
// the nearest one and start search again in the next loop step.
|
|
33
|
+
const indices = new Array();
|
|
34
|
+
for (const searchTerm of searchTerms) {
|
|
35
|
+
const searchTermSlash = dotToSlash(searchTerm);
|
|
36
|
+
indices.push({
|
|
37
|
+
i: content.indexOf(searchTerm, start),
|
|
38
|
+
replacement: references.get(searchTerm),
|
|
39
|
+
searchTerm
|
|
40
|
+
}, {
|
|
41
|
+
i: content.indexOf(searchTermSlash, start),
|
|
42
|
+
replacement: dotToSlash(references.get(searchTerm)),
|
|
43
|
+
searchTerm: searchTermSlash
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
const found = indices.filter(({ i }) => i > -1);
|
|
47
|
+
if (found.length === 0) {
|
|
48
|
+
return content;
|
|
49
|
+
}
|
|
50
|
+
const inBetween = (intervals, i) => {
|
|
51
|
+
for (const interval of intervals) {
|
|
52
|
+
for (const { start, end } of interval) {
|
|
53
|
+
if (i >= start && i <= end) {
|
|
54
|
+
return { start, end };
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
// If we found two strings with the same index, we take the longest one
|
|
60
|
+
// to replace, e.g.: app.variant and app.variant2 has the same index,
|
|
61
|
+
// but we don't want to replace the first one with customer.app.variant,
|
|
62
|
+
// otherwise we get customer.app.variant2, which we don't need. We need
|
|
63
|
+
// to replace the whole app.variant2 with customer.app.variant.
|
|
64
|
+
const findCurrentReplace = (found) => {
|
|
65
|
+
const result = new Map();
|
|
66
|
+
for (const entry of found) {
|
|
67
|
+
const existing = result.get(entry.i);
|
|
68
|
+
if (!existing || entry.searchTerm.length >= existing.searchTerm.length) {
|
|
69
|
+
result.set(entry.i, entry);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return [...result.values()].sort((a, b) => a.i - b.i)[0];
|
|
73
|
+
};
|
|
74
|
+
// Ignore if search is in i18n key: replace "id" in "{{id.key}}" with
|
|
75
|
+
// "customer.id" and we need only the next one in string
|
|
76
|
+
found.forEach(index => index.inBetween = inBetween(ignoredStrings, index.i));
|
|
77
|
+
// There might be a situation when we found something in ignored
|
|
78
|
+
// substrings and the index could be the nearest, but after that the
|
|
79
|
+
// next index might be the actual find to replace, so we first of all
|
|
80
|
+
// ignore all the ignored substring findings and get the next actual
|
|
81
|
+
// replacement. But if there are only ignored substrings found, we take
|
|
82
|
+
// the first one just to skip it and go further.
|
|
83
|
+
const currentReplace = findCurrentReplace(found);
|
|
84
|
+
if (currentReplace.inBetween) {
|
|
85
|
+
start = currentReplace.inBetween.end;
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
content = content.substring(0, currentReplace.i)
|
|
89
|
+
+ currentReplace.replacement
|
|
90
|
+
+ content.substring(currentReplace.i + currentReplace.searchTerm.length);
|
|
91
|
+
start = currentReplace.i + currentReplace.replacement.length;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
export function renameResources(files, search, replacement) {
|
|
96
|
+
return new Map([...files].map(([filepath, content]) => [filepath, rename(content, search, replacement)]));
|
|
97
|
+
}
|
|
98
|
+
function findAllOccurrences(string, substring, start) {
|
|
99
|
+
if (!substring) {
|
|
100
|
+
return [];
|
|
101
|
+
}
|
|
102
|
+
const indices = [];
|
|
103
|
+
let index = start;
|
|
104
|
+
while ((index = string.indexOf(substring, index)) !== -1) {
|
|
105
|
+
indices.push(index);
|
|
106
|
+
index += substring.length; // shift from current finding
|
|
107
|
+
}
|
|
108
|
+
return indices;
|
|
109
|
+
}
|
|
110
|
+
;
|
|
111
|
+
//# sourceMappingURL=renamingUtil.js.map
|
package/package.json
CHANGED
|
@@ -1,129 +1,127 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
2
|
+
"name": "@ui5/task-adaptation",
|
|
3
|
+
"version": "1.5.2-rc.0",
|
|
4
|
+
"description": "Custom task for ui5-builder which allows building UI5 Flexibility Adaptation Projects for SAP BTP, Cloud Foundry environment",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "npm run lint && npm run build && npm run coverage",
|
|
8
|
+
"lint": "eslint ./src ./test/lib",
|
|
9
|
+
"dev": "UI5_LOG_LVL=error mocha --no-timeouts --no-warnings --import=tsx --loader=esmock 'test/lib/**/*.spec.ts'",
|
|
10
|
+
"coverage": "c8 npm run dev",
|
|
11
|
+
"preversion": "npm test",
|
|
12
|
+
"version": "git-chglog --next-tag v$npm_package_version -o CHANGELOG.md && git add CHANGELOG.md",
|
|
13
|
+
"prepublishOnly": "git push --follow-tags",
|
|
14
|
+
"release-note": "git-chglog -c .chglog/release-config.yml v$npm_package_version",
|
|
15
|
+
"rollup": "tsx scripts/rollup.ts",
|
|
16
|
+
"build": "npm run rollup && tsc -p ./",
|
|
17
|
+
"download-metadata": "tsx scripts/metadataDownloadHelper.ts"
|
|
18
|
+
},
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "https://github.com/SAP/ui5-task-adaptation.git"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"adaptation",
|
|
25
|
+
"ui5",
|
|
26
|
+
"builder",
|
|
27
|
+
"tools",
|
|
28
|
+
"business",
|
|
29
|
+
"application",
|
|
30
|
+
"studio"
|
|
31
|
+
],
|
|
32
|
+
"author": "SAP SE",
|
|
33
|
+
"license": "Apache-2.0",
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@sap-ux/axios-extension": "^1.16.6",
|
|
36
|
+
"@sap-ux/btp-utils": "^1.0.2",
|
|
37
|
+
"@sap-ux/store": "^0.9.1",
|
|
38
|
+
"@sap-ux/system-access": "^0.5.11",
|
|
39
|
+
"@sap/cf-tools": "^3.2.2",
|
|
40
|
+
"@ui5/fs": "^4.0.1",
|
|
41
|
+
"@ui5/logger": "^4.0.1",
|
|
42
|
+
"adm-zip": "^0.5.5",
|
|
43
|
+
"axios": "^1.8.3",
|
|
44
|
+
"crc": "^4.3.2",
|
|
45
|
+
"dotenv": "^16.0.3",
|
|
46
|
+
"filenamify": "^6.0.0",
|
|
47
|
+
"jsdom": "^23.0.1",
|
|
48
|
+
"temp-dir": "^2.0.0",
|
|
49
|
+
"transliteration": "^2.3.5",
|
|
50
|
+
"xml-js": "^1.6.11"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@buxlabs/amd-to-es6": "^0.16.3",
|
|
54
|
+
"@rollup/plugin-node-resolve": "^15.3.0",
|
|
55
|
+
"@types/adm-zip": "^0.4.34",
|
|
56
|
+
"@types/chai": "^4.2.21",
|
|
57
|
+
"@types/chai-as-promised": "^7.1.4",
|
|
58
|
+
"@types/js-yaml": "^4.0.3",
|
|
59
|
+
"@types/jsdom": "^21.1.6",
|
|
60
|
+
"@types/lodash": "^4.14.196",
|
|
61
|
+
"@types/mocha": "^9.1.0",
|
|
62
|
+
"@types/semver": "^7.3.8",
|
|
63
|
+
"@types/sinon": "^10.0.16",
|
|
64
|
+
"@ui5/builder": "^4.0.3",
|
|
65
|
+
"@ui5/project": "^4.0.3",
|
|
66
|
+
"amdextract": "^3.0.0",
|
|
67
|
+
"builtin-modules": "^3.2.0",
|
|
68
|
+
"c8": "^10.1.3",
|
|
69
|
+
"chai": "^4.3.4",
|
|
70
|
+
"chai-as-promised": "^7.1.1",
|
|
71
|
+
"eslint": "^9.22.0",
|
|
72
|
+
"eslint-plugin-import": "^2.31.0",
|
|
73
|
+
"esmock": "^2.6.3",
|
|
74
|
+
"glob": "^10.3.10",
|
|
75
|
+
"js-yaml": "^4.1.0",
|
|
76
|
+
"meriyah": "^6.0.3",
|
|
77
|
+
"minimatch": "^9.0.3",
|
|
78
|
+
"mocha": "^11.1.0",
|
|
79
|
+
"mock-require": "^3.0.3",
|
|
80
|
+
"rollup": "^4.24.0",
|
|
81
|
+
"semver": "^7.3.5",
|
|
82
|
+
"sinon": "^18.0.1",
|
|
83
|
+
"source-map-support": "^0.5.19",
|
|
84
|
+
"tsx": "^4.7.1",
|
|
85
|
+
"typescript": "^5.4.2",
|
|
86
|
+
"typescript-eslint": "^8.26.1"
|
|
87
|
+
},
|
|
88
|
+
"c8": {
|
|
89
|
+
"src": "./src",
|
|
90
|
+
"all": true,
|
|
91
|
+
"reporter": [
|
|
92
|
+
"lcov",
|
|
93
|
+
"text",
|
|
94
|
+
"text-summary"
|
|
34
95
|
],
|
|
35
|
-
"
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
"
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
"@types/sinon": "^10.0.16",
|
|
67
|
-
"@ui5/builder": "^4.0.3",
|
|
68
|
-
"@ui5/project": "^4.0.3",
|
|
69
|
-
"amdextract": "^3.0.0",
|
|
70
|
-
"builtin-modules": "^3.2.0",
|
|
71
|
-
"c8": "^10.1.3",
|
|
72
|
-
"chai": "^4.3.4",
|
|
73
|
-
"chai-as-promised": "^7.1.1",
|
|
74
|
-
"eslint": "^9.22.0",
|
|
75
|
-
"eslint-plugin-import": "^2.31.0",
|
|
76
|
-
"esmock": "^2.6.3",
|
|
77
|
-
"glob": "^10.3.10",
|
|
78
|
-
"js-yaml": "^4.1.0",
|
|
79
|
-
"meriyah": "^6.0.3",
|
|
80
|
-
"minimatch": "^9.0.3",
|
|
81
|
-
"mocha": "^11.1.0",
|
|
82
|
-
"mock-require": "^3.0.3",
|
|
83
|
-
"rollup": "^4.24.0",
|
|
84
|
-
"semver": "^7.3.5",
|
|
85
|
-
"sinon": "^18.0.1",
|
|
86
|
-
"source-map-support": "^0.5.19",
|
|
87
|
-
"tsx": "^4.7.1",
|
|
88
|
-
"typescript": "^5.4.2",
|
|
89
|
-
"typescript-eslint": "^8.26.1"
|
|
90
|
-
},
|
|
91
|
-
"c8": {
|
|
92
|
-
"src": "./src",
|
|
93
|
-
"all": true,
|
|
94
|
-
"reporter": [
|
|
95
|
-
"lcov",
|
|
96
|
-
"text",
|
|
97
|
-
"text-summary"
|
|
98
|
-
],
|
|
99
|
-
"exclude": [
|
|
100
|
-
".eslintrc.js",
|
|
101
|
-
"docs/**",
|
|
102
|
-
"jsdocs/**",
|
|
103
|
-
"coverage/**",
|
|
104
|
-
"test/**",
|
|
105
|
-
"lib/processors/jsdoc/lib/**",
|
|
106
|
-
"dist/**",
|
|
107
|
-
"src/model/types.ts",
|
|
108
|
-
"src/util/requestUtil.ts",
|
|
109
|
-
"scripts/**/*.js",
|
|
110
|
-
"scripts/git/octokitUtil.ts",
|
|
111
|
-
"*/**/*.d.ts",
|
|
112
|
-
"src/annotations/comparator/diffCase.ts",
|
|
113
|
-
"src/annotations/transformers/transformer.ts",
|
|
114
|
-
"src/model/configuration.ts",
|
|
115
|
-
"src/model/appVariantIdHierarchyItem.ts"
|
|
116
|
-
],
|
|
117
|
-
"check-coverage": true,
|
|
118
|
-
"statements": 85,
|
|
119
|
-
"branches": 70,
|
|
120
|
-
"functions": 90,
|
|
121
|
-
"lines": 85
|
|
122
|
-
},
|
|
123
|
-
"types": "dist/index.d.ts",
|
|
124
|
-
"type": "module",
|
|
125
|
-
"optionalDependencies": {
|
|
126
|
-
"@rollup/rollup-linux-x64-gnu": "^4.28.1",
|
|
127
|
-
"@rollup/rollup-linux-x64-musl": "^4.28.1"
|
|
128
|
-
}
|
|
96
|
+
"exclude": [
|
|
97
|
+
".eslintrc.js",
|
|
98
|
+
"docs/**",
|
|
99
|
+
"jsdocs/**",
|
|
100
|
+
"coverage/**",
|
|
101
|
+
"test/**",
|
|
102
|
+
"lib/processors/jsdoc/lib/**",
|
|
103
|
+
"dist/**",
|
|
104
|
+
"src/model/types.ts",
|
|
105
|
+
"src/util/requestUtil.ts",
|
|
106
|
+
"src/util/renamingHandlers/renamingHandler.ts",
|
|
107
|
+
"scripts/**/*.js",
|
|
108
|
+
"scripts/git/octokitUtil.ts",
|
|
109
|
+
"*/**/*.d.ts",
|
|
110
|
+
"src/annotations/comparator/diffCase.ts",
|
|
111
|
+
"src/annotations/transformers/transformer.ts",
|
|
112
|
+
"src/model/configuration.ts",
|
|
113
|
+
"src/model/appVariantIdHierarchyItem.ts"
|
|
114
|
+
],
|
|
115
|
+
"check-coverage": true,
|
|
116
|
+
"statements": 85,
|
|
117
|
+
"branches": 70,
|
|
118
|
+
"functions": 90,
|
|
119
|
+
"lines": 85
|
|
120
|
+
},
|
|
121
|
+
"types": "dist/index.d.ts",
|
|
122
|
+
"type": "module",
|
|
123
|
+
"optionalDependencies": {
|
|
124
|
+
"@rollup/rollup-linux-x64-gnu": "^4.28.1",
|
|
125
|
+
"@rollup/rollup-linux-x64-musl": "^4.28.1"
|
|
126
|
+
}
|
|
129
127
|
}
|
|
@@ -1,21 +1,59 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
/*!
|
|
2
|
+
* ${copyright}
|
|
3
|
+
*/
|
|
4
|
+
sap.ui.define([
|
|
5
|
+
], (
|
|
6
|
+
) => {
|
|
7
|
+
"use strict";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The base Configuration.
|
|
11
|
+
*
|
|
12
|
+
* @author SAP SE
|
|
13
|
+
* @version ${version}
|
|
14
|
+
* @private
|
|
15
|
+
* @ui5-restricted sap.ui.core, sap.fl, sap.ui.intergration, sap.ui.export
|
|
16
|
+
* @alias module:sap/base/config
|
|
17
|
+
* @borrows module:sap/base/config/_Configuration.get as get
|
|
18
|
+
* @borrows module:sap/base/config/_Configuration.Type as Type
|
|
19
|
+
* @namespace
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
const _Configuration = { _: {} };
|
|
23
|
+
|
|
24
|
+
const internalConfig = new Map();
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Returns a writable base configuration instance
|
|
28
|
+
* @returns {module:sap/base/config} The writable base configuration
|
|
29
|
+
* @private
|
|
30
|
+
* @ui5-restricted sap.ui.core, sap.fl
|
|
31
|
+
*/
|
|
32
|
+
_Configuration.getWritableInstance = () => {
|
|
12
33
|
return {
|
|
13
34
|
get(obj) {
|
|
14
|
-
|
|
35
|
+
internalConfig.get(obj.name);
|
|
15
36
|
},
|
|
16
37
|
set(name, obj) {
|
|
17
|
-
|
|
38
|
+
internalConfig.set(name, obj);
|
|
18
39
|
}
|
|
19
40
|
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Attaches the <code>fnFunction</code> event handler to the {@link #event:invalidated invalidated} event
|
|
45
|
+
*
|
|
46
|
+
* @param {function} fnFunction The function to be called when the event occurs
|
|
47
|
+
* @private
|
|
48
|
+
*/
|
|
49
|
+
function attachInvalidated() {
|
|
20
50
|
}
|
|
21
|
-
|
|
51
|
+
_Configuration._.attachInvalidated = attachInvalidated;
|
|
52
|
+
|
|
53
|
+
const origInvalidate = _Configuration._.invalidate;
|
|
54
|
+
_Configuration._.invalidate = () => {
|
|
55
|
+
origInvalidate();
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
return _Configuration;
|
|
59
|
+
});
|
package/scripts/rollup.ts
CHANGED