@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.
@@ -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
- "name": "@ui5/task-adaptation",
3
- "version": "1.5.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
- "perf": "UI5_LOG_LVL=error mocha --no-timeouts --no-warnings --import=tsx --loader=esmock 'test/lib/**/*.perf.ts'",
11
- "integration": "UI5_LOG_LVL=error mocha --reporter-option maxDiffSize=0 --no-timeouts --no-warnings --import=tsx --loader=esmock 'test/lib/**/*.int.ts'",
12
- "coverage": "c8 npm run dev",
13
- "preversion": "npm test",
14
- "version": "git-chglog --next-tag v$npm_package_version -o CHANGELOG.md && git add CHANGELOG.md",
15
- "prepublishOnly": "git push --follow-tags",
16
- "release-note": "git-chglog -c .chglog/release-config.yml v$npm_package_version",
17
- "rollup": "tsx scripts/rollup.ts",
18
- "build": "npm run rollup && tsc -p ./",
19
- "download-metadata": "tsx scripts/metadataDownloadHelper.ts",
20
- "integration-setup": "scripts/test-integration-prep.sh"
21
- },
22
- "repository": {
23
- "type": "git",
24
- "url": "https://github.com/SAP/ui5-task-adaptation.git"
25
- },
26
- "keywords": [
27
- "adaptation",
28
- "ui5",
29
- "builder",
30
- "tools",
31
- "business",
32
- "application",
33
- "studio"
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
- "author": "SAP SE",
36
- "license": "Apache-2.0",
37
- "dependencies": {
38
- "@sap-ux/axios-extension": "^1.16.6",
39
- "@sap-ux/btp-utils": "^1.0.2",
40
- "@sap-ux/store": "^0.9.1",
41
- "@sap-ux/system-access": "^0.5.11",
42
- "@sap/cf-tools": "^3.2.0",
43
- "@ui5/fs": "^4.0.1",
44
- "@ui5/logger": "^4.0.1",
45
- "adm-zip": "^0.5.5",
46
- "axios": "^1.8.3",
47
- "crc": "^4.3.2",
48
- "dotenv": "^16.0.3",
49
- "filenamify": "^6.0.0",
50
- "jsdom": "^23.0.1",
51
- "temp-dir": "^2.0.0",
52
- "transliteration": "^2.3.5",
53
- "xml-js": "^1.6.11"
54
- },
55
- "devDependencies": {
56
- "@buxlabs/amd-to-es6": "^0.16.3",
57
- "@rollup/plugin-node-resolve": "^15.3.0",
58
- "@types/adm-zip": "^0.4.34",
59
- "@types/chai": "^4.2.21",
60
- "@types/chai-as-promised": "^7.1.4",
61
- "@types/js-yaml": "^4.0.3",
62
- "@types/jsdom": "^21.1.6",
63
- "@types/lodash": "^4.14.196",
64
- "@types/mocha": "^9.1.0",
65
- "@types/semver": "^7.3.8",
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
- export default class config {
2
- config = new Map();
3
- static get Type() {
4
- return {
5
- String: "string"
6
- }
7
- }
8
- static get({ name }) {
9
- return name === "sapUiLogLevel" ? "Error" : undefined;
10
- }
11
- static getWritableInstance() {
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
- config.get(obj.name);
35
+ internalConfig.get(obj.name);
15
36
  },
16
37
  set(name, obj) {
17
- config.set(name, obj);
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
@@ -119,8 +119,7 @@ export default class Builder {
119
119
  "bundleDefinition.js",
120
120
  "./dist/bundle.js",
121
121
  [
122
- "sap/ui/performance/Measurement",
123
- "sap/base/config"
122
+ "sap/ui/performance/Measurement"
124
123
  ]
125
124
  );
126
125
  this.copyTypeDefinition();