@ui5/task-adaptation 1.3.1 → 1.3.3

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.
Files changed (97) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/README.md +18 -0
  3. package/dist/annotationManager.d.ts +18 -0
  4. package/dist/annotationManager.js +79 -0
  5. package/dist/annotations/comparator/comparator.d.ts +47 -0
  6. package/dist/annotations/comparator/comparator.js +283 -0
  7. package/dist/annotations/comparator/diffCase.d.ts +4 -0
  8. package/dist/annotations/comparator/diffCase.js +2 -0
  9. package/dist/annotations/comparator/interchangableCase.d.ts +25 -0
  10. package/dist/annotations/comparator/interchangableCase.js +60 -0
  11. package/dist/annotations/converter/metadataJsonReferenceUtil.d.ts +12 -0
  12. package/dist/annotations/converter/metadataJsonReferenceUtil.js +48 -0
  13. package/dist/annotations/converter/metadataJsonUtil.d.ts +30 -0
  14. package/dist/annotations/converter/metadataJsonUtil.js +70 -0
  15. package/dist/annotations/converter/ui5JsonConverter.d.ts +21 -0
  16. package/dist/annotations/converter/ui5JsonConverter.js +252 -0
  17. package/dist/annotations/converter/ui5MetadataJsonUtil.d.ts +3 -0
  18. package/dist/annotations/converter/ui5MetadataJsonUtil.js +10 -0
  19. package/dist/annotations/converter/ui5XmlConverter.d.ts +5 -0
  20. package/dist/annotations/converter/ui5XmlConverter.js +14 -0
  21. package/dist/annotations/dataSource/dataSource.d.ts +34 -0
  22. package/dist/annotations/dataSource/dataSource.js +62 -0
  23. package/dist/annotations/dataSource/dataSourceManager.d.ts +12 -0
  24. package/dist/annotations/dataSource/dataSourceManager.js +45 -0
  25. package/dist/annotations/dataSource/dataSourceOData.d.ts +17 -0
  26. package/dist/annotations/dataSource/dataSourceOData.js +45 -0
  27. package/dist/annotations/dataSource/dataSourceODataAnnotation.d.ts +6 -0
  28. package/dist/annotations/dataSource/dataSourceODataAnnotation.js +16 -0
  29. package/dist/annotations/serviceRequestor.d.ts +9 -0
  30. package/dist/annotations/serviceRequestor.js +73 -0
  31. package/dist/annotations/transformers/convertV2ToV4.d.ts +4 -0
  32. package/dist/annotations/transformers/convertV2ToV4.js +13 -0
  33. package/dist/annotations/transformers/makeAnnotationNamespaceUnique.d.ts +6 -0
  34. package/dist/annotations/transformers/makeAnnotationNamespaceUnique.js +41 -0
  35. package/dist/annotations/transformers/removeAllSchemaNodesExceptAnnotations.d.ts +4 -0
  36. package/dist/annotations/transformers/removeAllSchemaNodesExceptAnnotations.js +14 -0
  37. package/dist/annotations/transformers/transformer.d.ts +12 -0
  38. package/dist/annotations/transformers/transformer.js +2 -0
  39. package/dist/annotations/transformers/traverseReferences.d.ts +9 -0
  40. package/dist/annotations/transformers/traverseReferences.js +66 -0
  41. package/dist/appVariantManager.d.ts +12 -0
  42. package/dist/appVariantManager.js +102 -0
  43. package/dist/baseAppManager.d.ts +29 -0
  44. package/dist/baseAppManager.js +139 -0
  45. package/dist/buildStrategy.d.ts +7 -0
  46. package/dist/buildStrategy.js +19 -0
  47. package/dist/bundle.d.ts +25 -0
  48. package/dist/bundle.js +7146 -0
  49. package/dist/cache/annotationsCacheManager.d.ts +8 -0
  50. package/dist/cache/annotationsCacheManager.js +16 -0
  51. package/dist/cache/baseAppFilesCacheManager.d.ts +6 -0
  52. package/dist/cache/baseAppFilesCacheManager.js +12 -0
  53. package/dist/cache/cacheManager.d.ts +16 -0
  54. package/dist/cache/cacheManager.js +65 -0
  55. package/dist/i18nManager.d.ts +43 -0
  56. package/dist/i18nManager.js +203 -0
  57. package/dist/index.d.ts +6 -0
  58. package/dist/index.js +25 -0
  59. package/dist/model/annotationDiffStructureError.d.ts +3 -0
  60. package/dist/model/annotationDiffStructureError.js +8 -0
  61. package/dist/model/configuration.d.ts +21 -0
  62. package/dist/model/configuration.js +2 -0
  63. package/dist/model/language.d.ts +13 -0
  64. package/dist/model/language.js +37 -0
  65. package/dist/model/serverError.d.ts +3 -0
  66. package/dist/model/serverError.js +6 -0
  67. package/dist/model/types.d.ts +105 -0
  68. package/dist/model/types.js +2 -0
  69. package/dist/processors/abapProcessor.d.ts +21 -0
  70. package/dist/processors/abapProcessor.js +39 -0
  71. package/dist/processors/cfProcessor.d.ts +17 -0
  72. package/dist/processors/cfProcessor.js +45 -0
  73. package/dist/processors/processor.d.ts +7 -0
  74. package/dist/processors/processor.js +32 -0
  75. package/dist/repositories/abapProvider.d.ts +9 -0
  76. package/dist/repositories/abapProvider.js +69 -0
  77. package/dist/repositories/abapRepoManager.d.ts +11 -0
  78. package/dist/repositories/abapRepoManager.js +71 -0
  79. package/dist/repositories/html5RepoManager.d.ts +11 -0
  80. package/dist/repositories/html5RepoManager.js +87 -0
  81. package/dist/util/cfUtil.d.ts +30 -0
  82. package/dist/util/cfUtil.js +171 -0
  83. package/dist/util/commonUtil.d.ts +13 -0
  84. package/dist/util/commonUtil.js +118 -0
  85. package/dist/util/i18nMerger.d.ts +32 -0
  86. package/dist/util/i18nMerger.js +99 -0
  87. package/dist/util/requestUtil.d.ts +6 -0
  88. package/dist/util/requestUtil.js +36 -0
  89. package/dist/util/resourceUtil.d.ts +11 -0
  90. package/dist/util/resourceUtil.js +62 -0
  91. package/dist/util/urlUtil.d.ts +4 -0
  92. package/dist/util/urlUtil.js +18 -0
  93. package/dist/util/xmlUtil.d.ts +4 -0
  94. package/dist/util/xmlUtil.js +21 -0
  95. package/dist/util/zipUtil.d.ts +2 -0
  96. package/dist/util/zipUtil.js +16 -0
  97. package/package.json +8 -3
@@ -0,0 +1,118 @@
1
+ import * as Log from "@ui5/logger";
2
+ import * as fs from "fs";
3
+ import { fileURLToPath } from "url";
4
+ import { posix as path } from "path";
5
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
6
+ const log = Log.getLogger("rollup-plugin-ui5-resolve-task-adaptation");
7
+ export function dotToUnderscore(value) {
8
+ return value.replace(/\./g, "_");
9
+ }
10
+ export function validateObject(options, properties, message) {
11
+ for (const property of properties) {
12
+ if (!options[property]) {
13
+ throw new Error(`'${String(property)}' ${message}`);
14
+ }
15
+ }
16
+ }
17
+ export function escapeRegex(update) {
18
+ return update.replaceAll(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
19
+ }
20
+ export function renameResources(files, search, replacement) {
21
+ // The current regex works if the old Id is contained in the new Id, given
22
+ // that they do not have the same beginning.
23
+ // more complete alternative: /((?<!newIdStart)|(?!newIdEnd))oldId/g
24
+ let escapedSearch;
25
+ if (replacement.includes(search)) {
26
+ const [before] = replacement.split(search);
27
+ // Matches a position in the string that is not immediately preceded by
28
+ // the string "before". Since we won't replace anyway, we should also
29
+ // ignore one with the slashes.
30
+ const escapedBefore = escapeRegex(before).replaceAll("\\.", "[\\./]");
31
+ escapedSearch = `(?<!${escapedBefore})${escapeRegex(search)}`;
32
+ }
33
+ else {
34
+ escapedSearch = escapeRegex(search);
35
+ }
36
+ const dotToSlash = (update) => update.replaceAll(".", "\/");
37
+ const replaces = [
38
+ {
39
+ regexp: new RegExp(escapedSearch, "g"),
40
+ replacement
41
+ },
42
+ {
43
+ regexp: new RegExp(dotToSlash(escapedSearch), "g"),
44
+ replacement: dotToSlash(replacement)
45
+ }
46
+ ];
47
+ files.forEach((content, filepath, map) => {
48
+ map.set(filepath, replaces.reduce((p, c) => p.replace(c.regexp, c.replacement), content));
49
+ });
50
+ return files;
51
+ }
52
+ export function insertInArray(array, index, insert) {
53
+ array.splice(index, 0, insert);
54
+ }
55
+ export function writeTempAnnotations({ writeTempFiles }, name, language, content) {
56
+ const TEMP_DIST_FOLDER = path.join(process.cwd(), "dist-debug", name);
57
+ if (writeTempFiles) {
58
+ if (!fs.existsSync(TEMP_DIST_FOLDER)) {
59
+ fs.mkdirSync(TEMP_DIST_FOLDER, { recursive: true });
60
+ }
61
+ if (language) {
62
+ name += "-" + language.i18n;
63
+ }
64
+ fs.writeFileSync(path.join(TEMP_DIST_FOLDER, name + ".xml"), content);
65
+ }
66
+ }
67
+ export function removePropertiesExtension(filePath) {
68
+ const lastIndexOf = filePath.lastIndexOf(".properties");
69
+ return filePath.substring(0, lastIndexOf);
70
+ }
71
+ export function traverse(json, paths, callback) {
72
+ for (const key of Object.keys(json)) {
73
+ const internPaths = [...paths];
74
+ internPaths.push(key);
75
+ if (typeof json[key] === "object") {
76
+ if (Array.isArray(json[key])) {
77
+ const array = json[key];
78
+ for (let i = 0; i < array.length; i++) {
79
+ if (typeof array[i] === "object") {
80
+ traverse(array[i], internPaths, callback);
81
+ }
82
+ else {
83
+ callback(array, i, internPaths);
84
+ }
85
+ }
86
+ }
87
+ else {
88
+ traverse(json[key], internPaths, callback);
89
+ }
90
+ }
91
+ else {
92
+ callback(json, key, internPaths);
93
+ }
94
+ }
95
+ }
96
+ export function logBuilderVersion() {
97
+ try {
98
+ const packageJson = fs.readFileSync(path.join(__dirname, "../../package.json"), { encoding: "utf-8" });
99
+ const packageJsonVersion = JSON.parse(packageJson).version;
100
+ log.info(`Running app-variant-bundler-build with version ${packageJsonVersion}`);
101
+ }
102
+ catch (e) {
103
+ // do nothing
104
+ }
105
+ }
106
+ export function logBetaUsage() {
107
+ log.info("Beta features enabled");
108
+ }
109
+ export function getUniqueName(existingNames, template) {
110
+ let suffix = -1;
111
+ let suffixString;
112
+ do {
113
+ suffixString = suffix === -1 ? "" : suffix;
114
+ suffix++;
115
+ } while (existingNames.includes(template + suffixString));
116
+ return template + suffixString;
117
+ }
118
+ //# sourceMappingURL=commonUtil.js.map
@@ -0,0 +1,32 @@
1
+ /// <reference path="../../types/ui5.d.ts" />
2
+ import * as Resource from "@ui5/fs/Resource";
3
+ import { IAppVariantInfo } from "../model/types.js";
4
+ type Resource = typeof Resource;
5
+ export default class I18NMerger {
6
+ static analyzeAppVariantManifestChanges(rootFolder: string, tranlsationRegexPattern: string, { changes }: IAppVariantInfo): {
7
+ mergePathsRegex: RegExp[];
8
+ copyPathsRegex: RegExp[];
9
+ };
10
+ static mergeI18NFiles(baseAppResources: any[], appVariantResources: any[], projectNamespace: string, baseAppManifestI18NPath: string, appVariantInfo: IAppVariantInfo, taskUtil: any): Promise<(typeof Resource)[]>;
11
+ /**
12
+ * Merge/Append base property file with property file from app variant
13
+ * FIXME Currently merge could duplicate keys which causes undefined
14
+ * behavior => Existing keys which are in merge content must be removed =>
15
+ * Actually only descriptor texts are relevant for merge which always have
16
+ * app variant Id as prefix => If we filter on them we do not need to remove
17
+ * existing overwritten keys (as there should be none)
18
+ */
19
+ private static mergePropertiesFiles;
20
+ /**
21
+ * update the path of app variant property file so it will be copied into
22
+ <app_variant_id> folder
23
+ */
24
+ private static moveToAppVarSubfolder;
25
+ /**
26
+ * create new i18n file in case e.g. translation file does not exist in base
27
+ * app but in variant and copy of translation file is needed
28
+ */
29
+ private static createFile;
30
+ private static mergeFiles;
31
+ }
32
+ export {};
@@ -0,0 +1,99 @@
1
+ import { dotToUnderscore, escapeRegex, removePropertiesExtension } from "./commonUtil.js";
2
+ import ResourceUtil from "./resourceUtil.js";
3
+ import { posix as path } from "path";
4
+ export default class I18NMerger {
5
+ static analyzeAppVariantManifestChanges(rootFolder, tranlsationRegexPattern, { changes }) {
6
+ // check which files need to be copied and which files need to be merged and copied
7
+ // this is necessary because lrep does not support multiple enhanceWith with multiple locations
8
+ const mergePaths = new Set();
9
+ const copyPaths = new Set();
10
+ changes.forEach((change) => {
11
+ const i18nPathWithExtension = change.content?.bundleUrl || change.texts?.i18n;
12
+ if (i18nPathWithExtension) {
13
+ // build regex to match specific + language related files
14
+ const i18nPath = removePropertiesExtension(i18nPathWithExtension);
15
+ const resourcePath = path.join(rootFolder, i18nPath);
16
+ const regex = new RegExp(escapeRegex(resourcePath) + tranlsationRegexPattern);
17
+ if (change.changeType.includes("addNewModelEnhanceWith")) {
18
+ copyPaths.add(regex);
19
+ }
20
+ else {
21
+ mergePaths.add(regex);
22
+ }
23
+ }
24
+ });
25
+ return { mergePathsRegex: [...mergePaths.values()], copyPathsRegex: [...copyPaths.values()] };
26
+ }
27
+ static async mergeI18NFiles(baseAppResources, appVariantResources, projectNamespace, baseAppManifestI18NPath, appVariantInfo, taskUtil) {
28
+ const aggregatedResourceFilesMap = new Map(baseAppResources.map(baseAppResource => [baseAppResource.getPath(), baseAppResource]));
29
+ const i18nTargetFolder = dotToUnderscore(appVariantInfo.id);
30
+ const rootFolder = ResourceUtil.getRootFolder(projectNamespace);
31
+ const tranlsationRegexPattern = "((_[a-z]{2,3})?(_[a-zA-Z]{2,3}(_[a-zA-Z]{2,20})?)?)\.properties$";
32
+ const { copyPathsRegex: copyPathsValues, mergePathsRegex: mergePathsValues } = this.analyzeAppVariantManifestChanges(rootFolder, tranlsationRegexPattern, appVariantInfo);
33
+ for (const appVariantResource of appVariantResources) {
34
+ const appVariantResourcePath = appVariantResource.getPath();
35
+ if (appVariantResourcePath.endsWith(".properties")) {
36
+ // merge/copy logic
37
+ // check if file matches with regex in merge/copy
38
+ const mergePathMatch = mergePathsValues.map(path => appVariantResourcePath.match(path)).find(match => match);
39
+ const shouldMergeFile = !!mergePathMatch;
40
+ const shouldCopyFile = copyPathsValues.map(path => appVariantResourcePath.match(path)).find(match => match);
41
+ if (shouldMergeFile) {
42
+ let baseAppI18NPath = `${rootFolder}/${baseAppManifestI18NPath}${mergePathMatch[1] || ""}.properties`;
43
+ await this.mergePropertiesFiles(aggregatedResourceFilesMap, appVariantResource, baseAppI18NPath);
44
+ }
45
+ // Resource for to be copied file already exists so we only have to adjust path
46
+ // Otherwise we have to omit it. We always change the path to avoid omitting a base app file
47
+ this.moveToAppVarSubfolder(appVariantResource, rootFolder, i18nTargetFolder);
48
+ if (!shouldCopyFile) {
49
+ taskUtil.setTag(appVariantResource, taskUtil.STANDARD_TAGS.OmitFromBuildResult, true);
50
+ }
51
+ }
52
+ aggregatedResourceFilesMap.set(appVariantResource.getPath(), appVariantResource);
53
+ }
54
+ return Array.from(aggregatedResourceFilesMap.values());
55
+ }
56
+ /**
57
+ * Merge/Append base property file with property file from app variant
58
+ * FIXME Currently merge could duplicate keys which causes undefined
59
+ * behavior => Existing keys which are in merge content must be removed =>
60
+ * Actually only descriptor texts are relevant for merge which always have
61
+ * app variant Id as prefix => If we filter on them we do not need to remove
62
+ * existing overwritten keys (as there should be none)
63
+ */
64
+ static async mergePropertiesFiles(aggregatedResourceFilesMap, variantResource, baseAppI18NPath) {
65
+ const baseAppI18NFile = aggregatedResourceFilesMap.get(baseAppI18NPath);
66
+ if (baseAppI18NFile) {
67
+ await this.mergeFiles(baseAppI18NFile, variantResource);
68
+ }
69
+ else {
70
+ // create the merge target file if it missing in base app. Maybe the language does not exist in the base app.
71
+ // Since the file might also be copied we do not just change the path of it but create another resource
72
+ await this.createFile(aggregatedResourceFilesMap, baseAppI18NPath, variantResource);
73
+ }
74
+ }
75
+ /**
76
+ * update the path of app variant property file so it will be copied into
77
+ <app_variant_id> folder
78
+ */
79
+ static moveToAppVarSubfolder(variantResource, rootFolder, i18nBundleName) {
80
+ const relativeFilePath = variantResource.getPath().substring(rootFolder.length);
81
+ const newResourcePath = path.join(rootFolder, i18nBundleName, relativeFilePath);
82
+ variantResource.setPath(newResourcePath);
83
+ }
84
+ /**
85
+ * create new i18n file in case e.g. translation file does not exist in base
86
+ * app but in variant and copy of translation file is needed
87
+ */
88
+ static async createFile(aggregatedResourceFilesMap, path, resource) {
89
+ const createdFile = await resource.clone();
90
+ createdFile.setPath(path);
91
+ aggregatedResourceFilesMap.set(path, createdFile);
92
+ }
93
+ static async mergeFiles(baseFile, variantFile) {
94
+ const variantFileContent = await variantFile.getString();
95
+ const mergedFileContent = await baseFile.getString();
96
+ baseFile.setString(`${mergedFileContent}\n\n#App variant specific text file\n\n${variantFileContent}`);
97
+ }
98
+ }
99
+ //# sourceMappingURL=i18nMerger.js.map
@@ -0,0 +1,6 @@
1
+ export default class RequestUtil {
2
+ static head(url: string): Promise<any>;
3
+ static get(url: string, options?: any): Promise<any>;
4
+ static request(url: string, method: Function, options?: any): Promise<any>;
5
+ private static handleError;
6
+ }
@@ -0,0 +1,36 @@
1
+ import axios from "axios";
2
+ import ServerError from "../model/serverError.js";
3
+ export default class RequestUtil {
4
+ static async head(url) {
5
+ return this.request(url, axios.head);
6
+ }
7
+ static async get(url, options) {
8
+ return this.request(url, axios.get, options);
9
+ }
10
+ static async request(url, method, options) {
11
+ try {
12
+ return await method(url, options);
13
+ }
14
+ catch (error) {
15
+ this.handleError(error, url);
16
+ }
17
+ }
18
+ static handleError(error, uri) {
19
+ if (error.response) {
20
+ // HTTP Status Code > 2xx
21
+ if (error.response.status >= 500) {
22
+ throw new ServerError(uri, error);
23
+ }
24
+ else {
25
+ throw new Error(`Unexpected response received from '${uri}': ${error.response.status} ${error.response.data ?? ""}`);
26
+ }
27
+ }
28
+ else if (error.request) {
29
+ throw new Error(`No response was received from '${uri}': ${error.code}`);
30
+ }
31
+ else {
32
+ throw new Error(`Error sending request to '${uri}': ${error.code}`);
33
+ }
34
+ }
35
+ }
36
+ //# sourceMappingURL=requestUtil.js.map
@@ -0,0 +1,11 @@
1
+ export default class ResourceUtil {
2
+ static getRootFolder(projectNamespace?: string): string;
3
+ static relativeToRoot(resourcePath: string, projectNamespace?: string): string;
4
+ static getResourcePath(projectNamespace?: string, ...paths: string[]): string;
5
+ static write(dir: string, files: Map<string, string>): Promise<void[]>;
6
+ static read(rootFolder: string, folder: string, files: Map<string, string>, exclude?: string[]): void;
7
+ static getString(resource: any): Promise<string>;
8
+ static getJson(resource: any): Promise<any>;
9
+ static setString(resource: any, str: string): void;
10
+ static createResource(filename: string, projectNamespace: string, content: string): any;
11
+ }
@@ -0,0 +1,62 @@
1
+ import * as fs from "fs";
2
+ import * as resourceFactory from "@ui5/fs/resourceFactory";
3
+ import { posix as path } from "path";
4
+ const UTF8 = "utf8";
5
+ export default class ResourceUtil {
6
+ static getRootFolder(projectNamespace) {
7
+ const newPath = ["/resources"];
8
+ if (projectNamespace) {
9
+ newPath.push(projectNamespace);
10
+ }
11
+ return path.join(...newPath);
12
+ }
13
+ static relativeToRoot(resourcePath, projectNamespace) {
14
+ const rootFolder = ResourceUtil.getRootFolder(projectNamespace);
15
+ return path.relative(rootFolder, resourcePath);
16
+ }
17
+ static getResourcePath(projectNamespace, ...paths) {
18
+ return path.join(this.getRootFolder(projectNamespace), ...paths);
19
+ }
20
+ static write(dir, files) {
21
+ const fsTarget = resourceFactory.createAdapter({
22
+ fsBasePath: dir,
23
+ virBasePath: "/"
24
+ });
25
+ const promises = [];
26
+ files.forEach((string, filename) => {
27
+ const resource = resourceFactory.createResource({ path: "/" + filename, string });
28
+ promises.push(fsTarget.write(resource));
29
+ });
30
+ return Promise.all(promises);
31
+ }
32
+ static read(rootFolder, folder, files, exclude = []) {
33
+ const entries = fs.readdirSync(folder);
34
+ for (let entry of entries) {
35
+ const entryPath = path.join(folder, entry);
36
+ const stats = fs.lstatSync(entryPath);
37
+ if (stats.isFile() && !exclude.some(filepath => entryPath.endsWith(filepath))) {
38
+ const normalized = entryPath.substring(rootFolder.length + 1);
39
+ files.set(normalized, fs.readFileSync(entryPath, { encoding: "utf-8" }));
40
+ }
41
+ else if (stats.isDirectory()) {
42
+ this.read(rootFolder, entryPath, files, exclude);
43
+ }
44
+ }
45
+ }
46
+ static getString(resource) {
47
+ return resource.getBuffer().then((buffer) => buffer.toString(UTF8));
48
+ }
49
+ static getJson(resource) {
50
+ return resource.getBuffer().then((buffer) => JSON.parse(buffer.toString(UTF8)));
51
+ }
52
+ static setString(resource, str) {
53
+ resource.setBuffer(Buffer.from(str, UTF8));
54
+ }
55
+ static createResource(filename, projectNamespace, content) {
56
+ return resourceFactory.createResource({
57
+ path: this.getResourcePath(projectNamespace, filename),
58
+ string: content
59
+ });
60
+ }
61
+ }
62
+ //# sourceMappingURL=resourceUtil.js.map
@@ -0,0 +1,4 @@
1
+ export default class UrlUtil {
2
+ static join(relativeUrl: string, parentUrl: string): string;
3
+ static getResourcePath(url: string): string;
4
+ }
@@ -0,0 +1,18 @@
1
+ import { URI } from "../../dist/bundle.js";
2
+ export default class UrlUtil {
3
+ static join(relativeUrl, parentUrl) {
4
+ // Remove trailing slash, otherwise url join can be incorrect Remove
5
+ // trailing slash, otherwise url join can be incorrect Annotation URLs
6
+ // defined in manifest might end with .../$value/ or .../$value and both
7
+ // are accepted by Gateway and produce the same content with same
8
+ // relative URLs. The first case is actually incorrect and we have to
9
+ // sanitize the same way as UI5. We also trim urls domain/host, because
10
+ // we need to substitute it with destination to download later.
11
+ return new URI(relativeUrl).absoluteTo(parentUrl.replace(/\/$/, "")).toString();
12
+ }
13
+ static getResourcePath(url) {
14
+ // Trim urls domain/host.
15
+ return URI.parse(url).path;
16
+ }
17
+ }
18
+ //# sourceMappingURL=urlUtil.js.map
@@ -0,0 +1,4 @@
1
+ export default class XmlUtil {
2
+ static jsonToXml(json: any): string;
3
+ static xmlToJson(xml: string): any;
4
+ }
@@ -0,0 +1,21 @@
1
+ import * as convert from "xml-js";
2
+ const XML_OPTIONS = { compact: true, spaces: 4 };
3
+ export default class XmlUtil {
4
+ static jsonToXml(json) {
5
+ return convert.json2xml(json, {
6
+ ...XML_OPTIONS, attributeValueFn: (val) => val
7
+ .replaceAll("&quot;", "\"")
8
+ .replaceAll("&", "&amp;")
9
+ .replaceAll("<", "&lt;")
10
+ .replaceAll("\"", "&quot;")
11
+ .replaceAll("'", "&apos;")
12
+ });
13
+ }
14
+ static xmlToJson(xml) {
15
+ return JSON.parse(convert.xml2json(xml, {
16
+ ...XML_OPTIONS, attributeValueFn: (val) => val
17
+ .replaceAll("&quot;", "\"")
18
+ }));
19
+ }
20
+ }
21
+ //# sourceMappingURL=xmlUtil.js.map
@@ -0,0 +1,2 @@
1
+ /// <reference types="node" />
2
+ export declare function unzipZipEntries(zip: Buffer): Promise<Map<string, string>>;
@@ -0,0 +1,16 @@
1
+ import AdmZip from "adm-zip";
2
+ export async function unzipZipEntries(zip) {
3
+ let admZip;
4
+ try {
5
+ admZip = new AdmZip(zip);
6
+ const entries = admZip.getEntries();
7
+ return mapEntries(entries);
8
+ }
9
+ catch (error) {
10
+ throw new Error("Failed to parse zip content from HTML5 Repository: " + error.message);
11
+ }
12
+ }
13
+ function mapEntries(entries) {
14
+ return new Map(entries.filter(entry => !entry.isDirectory).map(entry => [entry.entryName, entry.getData().toString("utf8")]));
15
+ }
16
+ //# sourceMappingURL=zipUtil.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ui5/task-adaptation",
3
- "version": "1.3.1",
3
+ "version": "1.3.3",
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": {
@@ -9,7 +9,7 @@
9
9
  "dev": "UI5_LOG_LVL=error mocha --no-timeouts --no-warnings --import=tsx --loader=esmock 'test/**/*.spec.ts'",
10
10
  "perf": "UI5_LOG_LVL=error mocha --no-timeouts --no-warnings --import=tsx --loader=esmock 'test/**/*.perf.ts'",
11
11
  "coverage": "npx c8 npm run dev",
12
- "preversion": "",
12
+ "preversion": "npm test",
13
13
  "version": "git-chglog --next-tag v$npm_package_version -o CHANGELOG.md && git add CHANGELOG.md",
14
14
  "prepublishOnly": "git push --follow-tags",
15
15
  "release-note": "git-chglog -c .chglog/release-config.yml v$npm_package_version",
@@ -33,6 +33,10 @@
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
40
  "@sap/cf-tools": "^3.2.0",
37
41
  "@ui5/fs": "^3.0.5",
38
42
  "@ui5/logger": "^3.0.0",
@@ -104,7 +108,8 @@
104
108
  "scripts/git/octokitUtil.ts",
105
109
  "*/**/*.d.ts",
106
110
  "src/annotations/comparator/diffCase.ts",
107
- "src/annotations/transformers/transformer.ts"
111
+ "src/annotations/transformers/transformer.ts",
112
+ "src/model/configuration.ts"
108
113
  ],
109
114
  "check-coverage": true,
110
115
  "statements": 85,