@ui5/task-adaptation 1.0.18 → 1.0.19
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/appVariantManager.d.ts +2 -0
- package/dist/appVariantManager.js +15 -15
- package/dist/util/commonUtil.js +17 -12
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
All notable changes to this project will be documented in this file.
|
|
3
3
|
This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
|
4
4
|
|
|
5
|
-
A list of unreleased changes can be found [here](https://github.com/SAP/ui5-task-adaptation/compare/v1.0.
|
|
5
|
+
A list of unreleased changes can be found [here](https://github.com/SAP/ui5-task-adaptation/compare/v1.0.19...HEAD).
|
|
6
|
+
|
|
7
|
+
<a name="v1.0.19"></a>
|
|
8
|
+
## [v1.0.19] - 2023-11-16
|
|
6
9
|
|
|
7
10
|
<a name="v1.0.18"></a>
|
|
8
11
|
## [v1.0.18] - 2023-11-10
|
|
@@ -52,6 +55,7 @@ A list of unreleased changes can be found [here](https://github.com/SAP/ui5-task
|
|
|
52
55
|
<a name="v1.0.0"></a>
|
|
53
56
|
## v1.0.0 - 2020-12-09
|
|
54
57
|
|
|
58
|
+
[v1.0.19]: https://github.com/SAP/ui5-task-adaptation/compare/v1.0.18...v1.0.19
|
|
55
59
|
[v1.0.18]: https://github.com/SAP/ui5-task-adaptation/compare/v1.0.17...v1.0.18
|
|
56
60
|
[v1.0.17]: https://github.com/SAP/ui5-task-adaptation/compare/v1.0.16...v1.0.17
|
|
57
61
|
[v1.0.16]: https://github.com/SAP/ui5-task-adaptation/compare/v1.0.11...v1.0.16
|
|
@@ -3,6 +3,8 @@ export default class AppVariantManager {
|
|
|
3
3
|
static process(appVariantResources: any[], projectNamespace: string, taskUtil: any): Promise<IAppVariantInfo>;
|
|
4
4
|
static getAppVariantResources(workspace: any): Promise<any[]>;
|
|
5
5
|
static renameChanges(appVariantResources: any[], projectNamespace: string, appVariantInfo: IAppVariantInfo): Promise<void>;
|
|
6
|
+
private static isManifestChange;
|
|
7
|
+
private static isManifestAppVariant;
|
|
6
8
|
static getAppVariantInfo(appVariantResources: any[]): Promise<IAppVariantInfo>;
|
|
7
9
|
static writeI18nToModule(resource: any, projectNamespace: string, i18nBundleName: string): void;
|
|
8
10
|
private static omitFiles;
|
|
@@ -4,10 +4,7 @@ const commonUtil_1 = require("./util/commonUtil");
|
|
|
4
4
|
const resourceUtil_1 = require("./util/resourceUtil");
|
|
5
5
|
const path_1 = require("path");
|
|
6
6
|
const log = require("@ui5/logger").getLogger("@ui5/task-adaptation::AppVariantManager");
|
|
7
|
-
const OMIT_FILES = ["manifest.appdescr_variant"];
|
|
8
|
-
const OMIT_FOLDERS = [];
|
|
9
7
|
const EXTENSIONS = "js,json,xml,html,properties,change,appdescr_variant";
|
|
10
|
-
const MANIFEST_APP_VARIANT = "manifest.appdescr_variant";
|
|
11
8
|
class AppVariantManager {
|
|
12
9
|
static async process(appVariantResources, projectNamespace, taskUtil) {
|
|
13
10
|
const appVariantInfo = await this.getAppVariantInfo(appVariantResources);
|
|
@@ -41,20 +38,26 @@ class AppVariantManager {
|
|
|
41
38
|
resourceUtil_1.default.setString(resource, renamedContent);
|
|
42
39
|
});
|
|
43
40
|
}
|
|
44
|
-
static
|
|
41
|
+
static isManifestChange(resource) {
|
|
45
42
|
const changesManifestFolder = path_1.posix.join("changes", "manifest");
|
|
43
|
+
const dirname = path_1.posix.dirname(resource.getPath());
|
|
44
|
+
return dirname.endsWith(changesManifestFolder);
|
|
45
|
+
}
|
|
46
|
+
static isManifestAppVariant(resource) {
|
|
47
|
+
const MANIFEST_APP_VARIANT = "manifest.appdescr_variant";
|
|
48
|
+
const basename = path_1.posix.basename(resource.getPath());
|
|
49
|
+
return basename === MANIFEST_APP_VARIANT;
|
|
50
|
+
}
|
|
51
|
+
static async getAppVariantInfo(appVariantResources) {
|
|
46
52
|
let manifest;
|
|
47
53
|
const manifestChanges = [];
|
|
48
54
|
for (const resource of appVariantResources) {
|
|
49
|
-
|
|
50
|
-
const dirname = path_1.posix.dirname(resource.getPath());
|
|
51
|
-
const basename = path_1.posix.basename(resourcePath);
|
|
52
|
-
if (basename === MANIFEST_APP_VARIANT) {
|
|
55
|
+
if (this.isManifestAppVariant(resource)) {
|
|
53
56
|
manifest = await resourceUtil_1.default.getString(resource).then(JSON.parse);
|
|
54
57
|
}
|
|
55
|
-
else if (
|
|
56
|
-
const
|
|
57
|
-
manifestChanges.push(JSON.parse(
|
|
58
|
+
else if (this.isManifestChange(resource)) {
|
|
59
|
+
const content = await resourceUtil_1.default.getString(resource);
|
|
60
|
+
manifestChanges.push(JSON.parse(content));
|
|
58
61
|
}
|
|
59
62
|
}
|
|
60
63
|
if (manifest) {
|
|
@@ -74,10 +77,7 @@ class AppVariantManager {
|
|
|
74
77
|
}
|
|
75
78
|
}
|
|
76
79
|
static omitFiles(resource, taskUtil) {
|
|
77
|
-
|
|
78
|
-
const filename = path_1.posix.basename(resource.getPath());
|
|
79
|
-
if (OMIT_FILES.includes(filename) ||
|
|
80
|
-
OMIT_FOLDERS.some(folder => dirname.endsWith(folder))) {
|
|
80
|
+
if (this.isManifestAppVariant(resource) || this.isManifestChange(resource)) {
|
|
81
81
|
taskUtil.setTag(resource, taskUtil.STANDARD_TAGS.OmitFromBuildResult, true);
|
|
82
82
|
}
|
|
83
83
|
}
|
package/dist/util/commonUtil.js
CHANGED
|
@@ -18,29 +18,34 @@ function renameResources(files, search, replacement) {
|
|
|
18
18
|
// The current regex works if the old Id is contained in the new Id, given
|
|
19
19
|
// that they do not have the same beginning.
|
|
20
20
|
// more complete alternative: /((?<!newIdStart)|(?!newIdEnd))oldId/g
|
|
21
|
+
let escapedSearch;
|
|
21
22
|
if (replacement.includes(search)) {
|
|
22
23
|
const [before, _] = replacement.split(search);
|
|
23
24
|
// Matches a position in the string that is not immediately preceded by
|
|
24
25
|
// the string "before".
|
|
25
|
-
|
|
26
|
+
escapedSearch = `(?<!${escapeRegexSpecialChars(before)})${escapeRegexSpecialChars(search)}`;
|
|
26
27
|
}
|
|
27
28
|
else {
|
|
28
|
-
|
|
29
|
+
escapedSearch = escapeRegexSpecialChars(search);
|
|
29
30
|
}
|
|
30
31
|
const dotToSlash = (update) => update.replaceAll(".", "\/");
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
regexp: new RegExp(dotToSlash(search), "g"),
|
|
38
|
-
replacement: dotToSlash(replacement)
|
|
32
|
+
const replace = (content) => content.replace(new RegExp(escapedSearch, "g"), replacement);
|
|
33
|
+
const replaceWithSlashesOnly = (content) => {
|
|
34
|
+
if (!search.includes(".")) {
|
|
35
|
+
return content;
|
|
39
36
|
}
|
|
40
|
-
|
|
37
|
+
let searchWithSlashes = dotToSlash(escapedSearch);
|
|
38
|
+
return content.replace(new RegExp(searchWithSlashes, "g"), dotToSlash(replacement));
|
|
39
|
+
};
|
|
41
40
|
const renamed = new Map();
|
|
42
41
|
files.forEach((content, filepath) => {
|
|
43
|
-
|
|
42
|
+
// Finds the id with dots (test.id) or without dots (id) and replaces it
|
|
43
|
+
content = replace(content);
|
|
44
|
+
// Only if the id has dots, these dots will be replaced with slashes
|
|
45
|
+
// first, and then it will search for the id with slashes and replace
|
|
46
|
+
// with the appVariantId also with slashes
|
|
47
|
+
content = replaceWithSlashesOnly(content);
|
|
48
|
+
renamed.set(filepath, content);
|
|
44
49
|
});
|
|
45
50
|
return renamed;
|
|
46
51
|
}
|
package/package.json
CHANGED