@ui5/task-adaptation 1.2.0 → 1.3.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 +5 -1
- package/dist/annotationManager.d.ts +3 -3
- package/dist/annotationManager.js +15 -16
- package/dist/annotations/comparator/comparator.js +30 -26
- package/dist/annotations/comparator/diffCase.js +1 -2
- package/dist/annotations/comparator/interchangableCase.d.ts +1 -1
- package/dist/annotations/comparator/interchangableCase.js +7 -12
- package/dist/annotations/converter/metadataJsonReferenceUtil.js +7 -9
- package/dist/annotations/converter/metadataJsonUtil.js +7 -10
- package/dist/annotations/converter/ui5JsonConverter.js +5 -6
- package/dist/annotations/converter/ui5MetadataJsonUtil.js +1 -4
- package/dist/annotations/converter/ui5XmlConverter.js +4 -7
- package/dist/annotations/dataSource/dataSource.d.ts +5 -5
- package/dist/annotations/dataSource/dataSource.js +8 -8
- package/dist/annotations/dataSource/dataSourceManager.d.ts +3 -3
- package/dist/annotations/dataSource/dataSourceManager.js +8 -13
- package/dist/annotations/dataSource/dataSourceOData.d.ts +3 -3
- package/dist/annotations/dataSource/dataSourceOData.js +13 -15
- package/dist/annotations/dataSource/dataSourceODataAnnotation.d.ts +1 -1
- package/dist/annotations/dataSource/dataSourceODataAnnotation.js +5 -7
- package/dist/annotations/serviceRequestor.d.ts +3 -3
- package/dist/annotations/serviceRequestor.js +15 -13
- package/dist/annotations/transformers/convertV2ToV4.d.ts +1 -1
- package/dist/annotations/transformers/convertV2ToV4.js +7 -10
- package/dist/annotations/transformers/makeAnnotationNamespaceUnique.d.ts +1 -1
- package/dist/annotations/transformers/makeAnnotationNamespaceUnique.js +8 -11
- package/dist/annotations/transformers/removeAllSchemaNodesExceptAnnotations.d.ts +1 -1
- package/dist/annotations/transformers/removeAllSchemaNodesExceptAnnotations.js +3 -6
- package/dist/annotations/transformers/transformer.d.ts +2 -2
- package/dist/annotations/transformers/transformer.js +1 -2
- package/dist/annotations/transformers/traverseReferences.d.ts +1 -1
- package/dist/annotations/transformers/traverseReferences.js +16 -17
- package/dist/appVariantManager.d.ts +1 -1
- package/dist/appVariantManager.js +17 -20
- package/dist/baseAppManager.d.ts +2 -2
- package/dist/baseAppManager.js +18 -20
- package/dist/buildStrategy.js +2 -4
- package/dist/bundle.d.ts +25 -0
- package/dist/bundle.js +3696 -219
- package/dist/cache/annotationsCacheManager.d.ts +2 -2
- package/dist/cache/annotationsCacheManager.js +3 -5
- package/dist/cache/baseAppFilesCacheManager.d.ts +1 -1
- package/dist/cache/baseAppFilesCacheManager.js +3 -6
- package/dist/cache/cacheManager.d.ts +1 -1
- package/dist/cache/cacheManager.js +9 -12
- package/dist/i18nManager.d.ts +3 -3
- package/dist/i18nManager.js +23 -23
- package/dist/index.d.ts +6 -1
- package/dist/index.js +14 -16
- package/dist/model/annotationDiffStructureError.js +1 -4
- package/dist/model/language.js +4 -4
- package/dist/model/noAuthorizationProvidedError.js +1 -4
- package/dist/model/serverError.js +1 -4
- package/dist/model/types.d.ts +1 -1
- package/dist/model/types.js +1 -2
- package/dist/processors/abapProcessor.d.ts +5 -5
- package/dist/processors/abapProcessor.js +9 -8
- package/dist/processors/cfProcessor.d.ts +3 -3
- package/dist/processors/cfProcessor.js +7 -8
- package/dist/processors/processor.d.ts +1 -1
- package/dist/processors/processor.js +11 -15
- package/dist/repositories/abapRepoManager.d.ts +1 -1
- package/dist/repositories/abapRepoManager.js +14 -14
- package/dist/repositories/html5RepoManager.d.ts +1 -1
- package/dist/repositories/html5RepoManager.js +12 -14
- package/dist/util/cfUtil.d.ts +1 -1
- package/dist/util/cfUtil.js +12 -14
- package/dist/util/commonUtil.d.ts +2 -2
- package/dist/util/commonUtil.js +19 -32
- package/dist/util/i18nMerger.d.ts +6 -2
- package/dist/util/i18nMerger.js +10 -14
- package/dist/util/requestUtil.d.ts +1 -1
- package/dist/util/requestUtil.js +9 -12
- package/dist/util/resourceUtil.js +8 -11
- package/dist/util/urlUtil.d.ts +2 -2
- package/dist/util/urlUtil.js +3 -6
- package/dist/util/xmlUtil.js +2 -5
- package/dist/util/zipUtil.js +2 -6
- package/eslint.config.js +52 -0
- package/package.json +44 -51
- package/scripts/metadataDownloadHelper.ts +8 -7
- package/scripts/rollup/bundle.d.ts +25 -0
- package/scripts/rollup/bundleDefinition.js +11 -1
- package/scripts/{bundler.ts → rollup/bundler.ts} +6 -17
- package/scripts/rollup/overrides/sap/base/config.js +10 -0
- package/scripts/rollup/project/package.json +2 -1
- package/scripts/rollup/project/ui5.yaml +1 -1
- package/scripts/rollup/ui5Resolve.ts +14 -38
- package/scripts/rollup.ts +67 -23
- package/types/ui5.d.ts +44 -0
- package/dist/bundle-odata.js +0 -5498
- package/scripts/rollup/bundleDefinition-odata.js +0 -9
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
6
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const log =
|
|
7
|
+
import AnnotationsCacheManager from "../cache/annotationsCacheManager.js";
|
|
8
|
+
import ServerError from "../model/serverError.js";
|
|
9
|
+
import { getLogger } from "@ui5/logger";
|
|
10
|
+
import { writeTempAnnotations } from "../util/commonUtil.js";
|
|
11
|
+
const log = getLogger("@ui5/task-adaptation::ServiceRequestor");
|
|
13
12
|
function retryOnError(maxRetries) {
|
|
14
13
|
return (_target, _propertyKey, descriptor) => {
|
|
15
14
|
const originalMethod = descriptor.value;
|
|
@@ -17,11 +16,10 @@ function retryOnError(maxRetries) {
|
|
|
17
16
|
let retries = 0;
|
|
18
17
|
while (true) {
|
|
19
18
|
try {
|
|
20
|
-
|
|
21
|
-
return result;
|
|
19
|
+
return await originalMethod.apply(this, args);
|
|
22
20
|
}
|
|
23
21
|
catch (error) {
|
|
24
|
-
if (error instanceof
|
|
22
|
+
if (error instanceof ServerError) {
|
|
25
23
|
if (retries === maxRetries) {
|
|
26
24
|
throw new Error(`Error occurred: ${error.message}. Please try again if this is a temporary issue. If not, please create a ticket on CA-UI5-ABA-AIDX`);
|
|
27
25
|
}
|
|
@@ -36,18 +34,23 @@ function retryOnError(maxRetries) {
|
|
|
36
34
|
return descriptor;
|
|
37
35
|
};
|
|
38
36
|
}
|
|
39
|
-
class ServiceRequestor {
|
|
37
|
+
export default class ServiceRequestor {
|
|
38
|
+
abapRepoManager;
|
|
39
|
+
configuration;
|
|
40
40
|
constructor(configuration, abapRepoManager) {
|
|
41
41
|
this.abapRepoManager = abapRepoManager;
|
|
42
42
|
this.configuration = configuration;
|
|
43
43
|
}
|
|
44
|
+
//@ts-ignore tsx (esbuild) is not yet implemented the new decorators, but
|
|
45
|
+
//old decorators are already subject of compiler error, but it works. So we
|
|
46
|
+
//wait till esbuild implement it correctly.
|
|
44
47
|
async downloadAnnotation(uri, name, language) {
|
|
45
48
|
let cacheName = name;
|
|
46
49
|
if (language.sap) {
|
|
47
50
|
uri += `?sap-language=${language.sap}`;
|
|
48
51
|
cacheName += `-${language.sap}`;
|
|
49
52
|
}
|
|
50
|
-
const cacheManager = new
|
|
53
|
+
const cacheManager = new AnnotationsCacheManager(this.configuration, cacheName);
|
|
51
54
|
log.verbose(`Getting annotation '${cacheName}' ${language} by '${uri}'`);
|
|
52
55
|
let files;
|
|
53
56
|
if (this.configuration.enableAnnotationCache) {
|
|
@@ -60,12 +63,11 @@ class ServiceRequestor {
|
|
|
60
63
|
throw new Error(`No files were fetched for '${name}' by '${uri}'`);
|
|
61
64
|
}
|
|
62
65
|
const xml = [...files][0][1];
|
|
63
|
-
|
|
66
|
+
writeTempAnnotations(this.configuration, name, language, xml);
|
|
64
67
|
return xml;
|
|
65
68
|
}
|
|
66
69
|
}
|
|
67
70
|
__decorate([
|
|
68
71
|
retryOnError(1)
|
|
69
72
|
], ServiceRequestor.prototype, "downloadAnnotation", null);
|
|
70
|
-
exports.default = ServiceRequestor;
|
|
71
73
|
//# sourceMappingURL=serviceRequestor.js.map
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const ui5XmlConverter_1 = require("../converter/ui5XmlConverter");
|
|
6
|
-
class ConvertV2ToV4 {
|
|
1
|
+
import MetadataJsonUtil from "../converter/metadataJsonUtil.js";
|
|
2
|
+
import UI5JsonConverter from "../converter/ui5JsonConverter.js";
|
|
3
|
+
import UI5XmlConverter from "../converter/ui5XmlConverter.js";
|
|
4
|
+
export default class ConvertV2ToV4 {
|
|
7
5
|
transform({ json, xml }) {
|
|
8
|
-
if (
|
|
9
|
-
const annotationsV4 =
|
|
10
|
-
|
|
6
|
+
if (MetadataJsonUtil.getVersion(json) !== "4.0") {
|
|
7
|
+
const annotationsV4 = UI5JsonConverter.convertAnnotations(UI5XmlConverter.convertV2(xml));
|
|
8
|
+
MetadataJsonUtil.setAnnotations(json, annotationsV4);
|
|
11
9
|
}
|
|
12
10
|
return json;
|
|
13
11
|
}
|
|
14
12
|
}
|
|
15
|
-
exports.default = ConvertV2ToV4;
|
|
16
13
|
//# sourceMappingURL=convertV2ToV4.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Transformer, { TransformerInput } from "./transformer";
|
|
1
|
+
import Transformer, { TransformerInput } from "./transformer.js";
|
|
2
2
|
export default class MakeAnnotationNamespaceUnique implements Transformer {
|
|
3
3
|
transform({ json, uri }: TransformerInput): any;
|
|
4
4
|
private createReference;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const crc16_1 = require("crc/crc16");
|
|
5
|
-
class MakeAnnotationNamespaceUnique {
|
|
1
|
+
import MetadataJsonUtil from "../converter/metadataJsonUtil.js";
|
|
2
|
+
import crc16 from "crc/crc16";
|
|
3
|
+
export default class MakeAnnotationNamespaceUnique {
|
|
6
4
|
transform({ json, uri }) {
|
|
7
|
-
const uniquePart = (
|
|
5
|
+
const uniquePart = crc16(uri).toString(16);
|
|
8
6
|
// First add current schema as reference
|
|
9
|
-
const schema =
|
|
7
|
+
const schema = MetadataJsonUtil.getSchemaNode(json);
|
|
10
8
|
const references = this.getReferences(json);
|
|
11
9
|
references.push(this.createReference(schema, uri));
|
|
12
10
|
// Then rename the namespace/alias
|
|
@@ -33,12 +31,11 @@ class MakeAnnotationNamespaceUnique {
|
|
|
33
31
|
}
|
|
34
32
|
getReferences(json) {
|
|
35
33
|
const REFERENCE_NODE_NAME = "edmx:Reference";
|
|
36
|
-
const references =
|
|
34
|
+
const references = MetadataJsonUtil.getEdmx(json)[REFERENCE_NODE_NAME];
|
|
37
35
|
if (!Array.isArray(references)) {
|
|
38
|
-
|
|
36
|
+
MetadataJsonUtil.getEdmx(json)[REFERENCE_NODE_NAME] = [references];
|
|
39
37
|
}
|
|
40
|
-
return
|
|
38
|
+
return MetadataJsonUtil.getEdmx(json)[REFERENCE_NODE_NAME];
|
|
41
39
|
}
|
|
42
40
|
}
|
|
43
|
-
exports.default = MakeAnnotationNamespaceUnique;
|
|
44
41
|
//# sourceMappingURL=makeAnnotationNamespaceUnique.js.map
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const metadataJsonUtil_1 = require("../converter/metadataJsonUtil");
|
|
4
|
-
class RemoveAllSchemaNodesExceptAnnotations {
|
|
1
|
+
import MetadataJsonUtil from "../converter/metadataJsonUtil.js";
|
|
2
|
+
export default class RemoveAllSchemaNodesExceptAnnotations {
|
|
5
3
|
transform({ json }) {
|
|
6
|
-
const schema =
|
|
4
|
+
const schema = MetadataJsonUtil.getSchemaNode(json);
|
|
7
5
|
for (const key of Object.keys(schema)) {
|
|
8
6
|
if (key !== "_attributes" && key !== "Annotations") {
|
|
9
7
|
delete schema[key];
|
|
@@ -13,5 +11,4 @@ class RemoveAllSchemaNodesExceptAnnotations {
|
|
|
13
11
|
// TODO: remove also references not used in annotations
|
|
14
12
|
}
|
|
15
13
|
}
|
|
16
|
-
exports.default = RemoveAllSchemaNodesExceptAnnotations;
|
|
17
14
|
//# sourceMappingURL=removeAllSchemaNodesExceptAnnotations.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import Language from "../../model/language";
|
|
2
|
-
import ServiceRequestor from "../serviceRequestor";
|
|
1
|
+
import Language from "../../model/language.js";
|
|
2
|
+
import ServiceRequestor from "../serviceRequestor.js";
|
|
3
3
|
export interface TransformerInput {
|
|
4
4
|
uri: string;
|
|
5
5
|
json: any;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Transformer, { TransformerInput } from "../transformers/transformer";
|
|
1
|
+
import Transformer, { TransformerInput } from "../transformers/transformer.js";
|
|
2
2
|
export default class TraverseReferences implements Transformer {
|
|
3
3
|
private metadataUrl?;
|
|
4
4
|
constructor(metadataUrl?: string);
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class TraverseReferences {
|
|
1
|
+
import MetadataJsonUtil from "../converter/metadataJsonUtil.js";
|
|
2
|
+
import DataSourceODataAnnotation from "../dataSource/dataSourceODataAnnotation.js";
|
|
3
|
+
import UrlUtil from "../../util/urlUtil.js";
|
|
4
|
+
export default class TraverseReferences {
|
|
5
|
+
metadataUrl;
|
|
7
6
|
constructor(metadataUrl) {
|
|
8
7
|
this.metadataUrl = metadataUrl;
|
|
9
8
|
}
|
|
10
9
|
async transform({ json, language, serviceRequestor, uri: parentUrl }) {
|
|
11
|
-
const references =
|
|
10
|
+
const references = MetadataJsonUtil.getReferences(json).filter(TraverseReferences.isTraversable);
|
|
12
11
|
const promises = [];
|
|
13
12
|
for (const { includes, uri: relativeUrl } of references) {
|
|
14
|
-
const
|
|
13
|
+
const resourcePath = UrlUtil.getResourcePath(relativeUrl);
|
|
14
|
+
const absoluteUrl = UrlUtil.join(resourcePath, parentUrl);
|
|
15
15
|
if (this.shouldIgnoreUrl(absoluteUrl, [parentUrl, this.metadataUrl])) {
|
|
16
16
|
// If reference to metadata or its parent, don't traverse
|
|
17
17
|
continue;
|
|
18
18
|
}
|
|
19
19
|
const name = includes[0]?.namespace;
|
|
20
|
-
const dataSource = new
|
|
20
|
+
const dataSource = new DataSourceODataAnnotation(name, absoluteUrl, {}, this.metadataUrl);
|
|
21
21
|
promises.push(dataSource.downloadAnnotation(language, serviceRequestor)
|
|
22
22
|
.then(childAnnotation => ({ name, childAnnotation })));
|
|
23
23
|
}
|
|
@@ -28,14 +28,14 @@ class TraverseReferences {
|
|
|
28
28
|
return json;
|
|
29
29
|
}
|
|
30
30
|
shouldIgnoreUrl(referenceUrl, urlsToIgnore) {
|
|
31
|
-
const toResourcePath = (url) =>
|
|
31
|
+
const toResourcePath = (url) => url && UrlUtil.getResourcePath(url);
|
|
32
32
|
const isEqual = (a, b) => a && b && a.toLowerCase() === b.toLowerCase();
|
|
33
33
|
return urlsToIgnore.map(toResourcePath).some(url => isEqual(referenceUrl, url));
|
|
34
34
|
}
|
|
35
35
|
mergeAnnotations(parentJson, nestedJson) {
|
|
36
|
-
const parentAnnotations =
|
|
37
|
-
const parentMapByTarget =
|
|
38
|
-
const nestedMapByTarget =
|
|
36
|
+
const parentAnnotations = MetadataJsonUtil.getAnnotations(parentJson);
|
|
37
|
+
const parentMapByTarget = MetadataJsonUtil.mapAnnotationsPerTarget(parentJson);
|
|
38
|
+
const nestedMapByTarget = MetadataJsonUtil.mapAnnotationsPerTarget(nestedJson);
|
|
39
39
|
for (const nested of [...nestedMapByTarget].map(([target, { json }]) => ({ target, json }))) {
|
|
40
40
|
// If we found parent annotation with the same target - we extend it
|
|
41
41
|
// with missing <Annotation> nodes. If not, just add it to the end.
|
|
@@ -44,9 +44,9 @@ class TraverseReferences {
|
|
|
44
44
|
// sap/ui/model/odata/v4/ODataMetaModel.js mergeAnnotations).
|
|
45
45
|
const parent = parentMapByTarget.get(nested.target);
|
|
46
46
|
if (parent) {
|
|
47
|
-
|
|
47
|
+
MetadataJsonUtil.toArrayTransform(parent.json, "Annotation");
|
|
48
48
|
const parentTerms = parent.json.Annotation.map((item) => item._attributes.Term);
|
|
49
|
-
for (const nestedAnnotation of
|
|
49
|
+
for (const nestedAnnotation of MetadataJsonUtil.toArrayReadOnly(nested.json.Annotation)) {
|
|
50
50
|
if (!parentTerms.includes(nestedAnnotation._attributes.Term)) {
|
|
51
51
|
parent.json.Annotation.push(nestedAnnotation);
|
|
52
52
|
}
|
|
@@ -56,12 +56,11 @@ class TraverseReferences {
|
|
|
56
56
|
parentAnnotations.push(nested.json);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
-
|
|
59
|
+
MetadataJsonUtil.setAnnotations(parentJson, parentAnnotations);
|
|
60
60
|
}
|
|
61
61
|
static isTraversable(reference) {
|
|
62
62
|
const IGNORED_NAMESPACES = ["com.sap.vocabularies.", "Org.OData."];
|
|
63
63
|
return !reference.includes.some(include => IGNORED_NAMESPACES.some(namespace => include.namespace.startsWith(namespace)));
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
-
exports.default = TraverseReferences;
|
|
67
66
|
//# sourceMappingURL=traverseReferences.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IAppVariantInfo } from "./model/types";
|
|
1
|
+
import { IAppVariantInfo } from "./model/types.js";
|
|
2
2
|
export default class AppVariantManager {
|
|
3
3
|
static process(appVariantResources: any[], projectNamespace: string, taskUtil: any): Promise<IAppVariantInfo>;
|
|
4
4
|
static getAppVariantResourcesToProcess(workspace: any): Promise<any[]>;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const path_1 = require("path");
|
|
5
|
-
const commonUtil_1 = require("./util/commonUtil");
|
|
1
|
+
import ResourceUtil from "./util/resourceUtil.js";
|
|
2
|
+
import { posix as path } from "path";
|
|
3
|
+
import { renameResources } from "./util/commonUtil.js";
|
|
6
4
|
const EXTENSIONS_TO_PROCESS = "js,json,xml,html,properties,change,appdescr_variant,ctrl_variant,ctrl_variant_change,ctrl_variant_management_change,variant,fioriversion,codeChange,xmlViewChange,context";
|
|
7
|
-
class AppVariantManager {
|
|
5
|
+
export default class AppVariantManager {
|
|
8
6
|
static async process(appVariantResources, projectNamespace, taskUtil) {
|
|
9
7
|
for (const resource of appVariantResources) {
|
|
10
8
|
this.omitFiles(resource, taskUtil);
|
|
@@ -16,38 +14,38 @@ class AppVariantManager {
|
|
|
16
14
|
return workspace.byGlob(`/**/*.{${EXTENSIONS_TO_PROCESS}}`);
|
|
17
15
|
}
|
|
18
16
|
static async updateChanges(appVariantResources, projectNamespace) {
|
|
19
|
-
const changesFolder =
|
|
17
|
+
const changesFolder = ResourceUtil.getResourcePath(projectNamespace, "changes");
|
|
20
18
|
const changes = new Map();
|
|
21
19
|
const resourcesByPath = new Map();
|
|
22
20
|
let manifest;
|
|
23
21
|
for (const resource of appVariantResources) {
|
|
24
22
|
if (this.isManifestAppVariant(resource)) {
|
|
25
|
-
manifest = await
|
|
23
|
+
manifest = await ResourceUtil.getJson(resource);
|
|
26
24
|
}
|
|
27
25
|
const resourcePath = resource.getPath();
|
|
28
|
-
const basename =
|
|
26
|
+
const basename = path.dirname(resourcePath);
|
|
29
27
|
if (basename.startsWith(changesFolder)) {
|
|
30
|
-
changes.set(resourcePath, await
|
|
28
|
+
changes.set(resourcePath, await ResourceUtil.getString(resource));
|
|
31
29
|
resourcesByPath.set(resourcePath, resource);
|
|
32
30
|
}
|
|
33
31
|
}
|
|
34
32
|
this.updateRelativePaths(changes, projectNamespace);
|
|
35
33
|
this.validateManifest(manifest);
|
|
36
|
-
const renamedChanges =
|
|
34
|
+
const renamedChanges = renameResources(changes, manifest.reference, manifest.id);
|
|
37
35
|
renamedChanges.forEach((renamedContent, resourcePath) => {
|
|
38
36
|
const resource = resourcesByPath.get(resourcePath);
|
|
39
|
-
|
|
37
|
+
ResourceUtil.setString(resource, renamedContent);
|
|
40
38
|
});
|
|
41
39
|
}
|
|
42
40
|
static isManifestChange(resource) {
|
|
43
|
-
const changesManifestFolder =
|
|
41
|
+
const changesManifestFolder = path.join("changes", "manifest");
|
|
44
42
|
const resourcePath = typeof resource === "string" ? resource : resource.getPath();
|
|
45
|
-
const dirname =
|
|
43
|
+
const dirname = path.dirname(resourcePath);
|
|
46
44
|
return dirname.endsWith(changesManifestFolder);
|
|
47
45
|
}
|
|
48
46
|
static isManifestAppVariant(resource) {
|
|
49
47
|
const MANIFEST_APP_VARIANT = "manifest.appdescr_variant";
|
|
50
|
-
const basename =
|
|
48
|
+
const basename = path.basename(resource.getPath());
|
|
51
49
|
return basename === MANIFEST_APP_VARIANT;
|
|
52
50
|
}
|
|
53
51
|
static async getAppVariantInfo(appVariantResources) {
|
|
@@ -55,10 +53,10 @@ class AppVariantManager {
|
|
|
55
53
|
const manifestChanges = [];
|
|
56
54
|
for (const resource of appVariantResources) {
|
|
57
55
|
if (this.isManifestAppVariant(resource)) {
|
|
58
|
-
manifest = await
|
|
56
|
+
manifest = await ResourceUtil.getJson(resource);
|
|
59
57
|
}
|
|
60
58
|
else if (this.isManifestChange(resource)) {
|
|
61
|
-
const content = await
|
|
59
|
+
const content = await ResourceUtil.getString(resource);
|
|
62
60
|
manifestChanges.push(JSON.parse(content));
|
|
63
61
|
}
|
|
64
62
|
}
|
|
@@ -86,8 +84,8 @@ class AppVariantManager {
|
|
|
86
84
|
if (change.changeType === "appdescr_app_addAnnotationsToOData") {
|
|
87
85
|
for (const dataSource of Object.values(change.content.dataSource)) {
|
|
88
86
|
if (!dataSource.uri.startsWith("/")) {
|
|
89
|
-
const basepath =
|
|
90
|
-
dataSource.uri =
|
|
87
|
+
const basepath = path.dirname(ResourceUtil.relativeToRoot(resourcePath, projectNamespace));
|
|
88
|
+
dataSource.uri = path.join(basepath.replace(/^\//, ""), dataSource.uri);
|
|
91
89
|
}
|
|
92
90
|
}
|
|
93
91
|
changes.set(resourcePath, JSON.stringify(change));
|
|
@@ -101,5 +99,4 @@ class AppVariantManager {
|
|
|
101
99
|
}
|
|
102
100
|
}
|
|
103
101
|
}
|
|
104
|
-
exports.default = AppVariantManager;
|
|
105
102
|
//# sourceMappingURL=appVariantManager.js.map
|
package/dist/baseAppManager.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IAppVariantInfo, IProjectOptions } from "./model/types";
|
|
2
|
-
import IProcessor from "./processors/processor";
|
|
1
|
+
import { IAppVariantInfo, IProjectOptions } from "./model/types.js";
|
|
2
|
+
import IProcessor from "./processors/processor.js";
|
|
3
3
|
export interface IBaseAppResources {
|
|
4
4
|
resources: any[];
|
|
5
5
|
manifestInfo: IManifestInfo;
|
package/dist/baseAppManager.js
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
class BaseAppManager {
|
|
1
|
+
import { Applier, Change, RegistrationBuild } from "../dist/bundle.js";
|
|
2
|
+
import { dotToUnderscore, removePropertiesExtension } from "./util/commonUtil.js";
|
|
3
|
+
import BuildStrategy from "./buildStrategy.js";
|
|
4
|
+
import ResourceUtil from "./util/resourceUtil.js";
|
|
5
|
+
import { getLogger } from "@ui5/logger";
|
|
6
|
+
import { renameResources } from "./util/commonUtil.js";
|
|
7
|
+
const log = getLogger("@ui5/task-adaptation::BaseAppManager");
|
|
8
|
+
export default class BaseAppManager {
|
|
10
9
|
static async process(baseAppFiles, appVariantInfo, options, processor) {
|
|
11
10
|
const baseAppManifest = this.getBaseAppManifest(baseAppFiles);
|
|
12
11
|
const { id, version } = this.getIdVersion(baseAppManifest.content);
|
|
13
12
|
this.validateProperty(id, "sap.app/id");
|
|
14
13
|
this.validateProperty(version, "sap.app/applicationVersion/version");
|
|
15
|
-
const renamedBaseAppFiles =
|
|
14
|
+
const renamedBaseAppFiles = renameResources(baseAppFiles, appVariantInfo.reference, appVariantInfo.id);
|
|
16
15
|
const { filepath, content } = this.getBaseAppManifest(renamedBaseAppFiles);
|
|
17
16
|
await processor.updateLandscapeSpecificContent(content, renamedBaseAppFiles);
|
|
18
17
|
this.fillAppVariantIdHierarchy(processor, id, version, content);
|
|
@@ -56,7 +55,7 @@ class BaseAppManager {
|
|
|
56
55
|
return i18nNode["bundleName"].replace(sapAppId, "").replaceAll(".", "/").substring(1);
|
|
57
56
|
}
|
|
58
57
|
static extractI18NFromBundleUrl(i18nNode) {
|
|
59
|
-
return
|
|
58
|
+
return removePropertiesExtension(i18nNode["bundleUrl"]);
|
|
60
59
|
}
|
|
61
60
|
static getBaseAppManifest(baseAppFiles) {
|
|
62
61
|
const manifestContent = baseAppFiles.get("manifest.json");
|
|
@@ -79,6 +78,11 @@ class BaseAppManager {
|
|
|
79
78
|
const appVariantIdHierarchyItem = processor.createAppVariantHierarchyItem(id, version);
|
|
80
79
|
baseAppManifest["sap.ui5"].appVariantIdHierarchy.unshift(appVariantIdHierarchyItem);
|
|
81
80
|
}
|
|
81
|
+
static VALIDATION_RULES = new Map([["sap.app/id", (value) => {
|
|
82
|
+
if (!value.includes(".")) {
|
|
83
|
+
throw new Error(`The original application id '${value}' should consist of multiple segments split by dot, e.g.: original.id`);
|
|
84
|
+
}
|
|
85
|
+
}]]);
|
|
82
86
|
static validateProperty(value, property) {
|
|
83
87
|
if (!value) {
|
|
84
88
|
throw new Error(`Original application manifest should have ${property}`);
|
|
@@ -91,7 +95,7 @@ class BaseAppManager {
|
|
|
91
95
|
static async applyDescriptorChanges(baseAppManifest, { layer, changes, id }) {
|
|
92
96
|
log.verbose("Applying appVariant changes");
|
|
93
97
|
const changesContent = new Array();
|
|
94
|
-
const i18nBundleName =
|
|
98
|
+
const i18nBundleName = dotToUnderscore(id);
|
|
95
99
|
for (const change of structuredClone(changes)) {
|
|
96
100
|
if (layer) {
|
|
97
101
|
change.layer = layer;
|
|
@@ -100,7 +104,7 @@ class BaseAppManager {
|
|
|
100
104
|
this.adjustAddNewModelEnhanceWith(change, i18nBundleName);
|
|
101
105
|
}
|
|
102
106
|
if (changesContent.length > 0) {
|
|
103
|
-
const strategy = new
|
|
107
|
+
const strategy = new BuildStrategy(RegistrationBuild);
|
|
104
108
|
await Applier.applyChanges(baseAppManifest, changesContent, strategy);
|
|
105
109
|
}
|
|
106
110
|
}
|
|
@@ -125,17 +129,11 @@ class BaseAppManager {
|
|
|
125
129
|
const resources = [];
|
|
126
130
|
for (let filename of baseAppFiles.keys()) {
|
|
127
131
|
if (!IGNORE_FILES.includes(filename)) {
|
|
128
|
-
const resource =
|
|
132
|
+
const resource = ResourceUtil.createResource(filename, projectNamespace, baseAppFiles.get(filename));
|
|
129
133
|
resources.push(resource);
|
|
130
134
|
}
|
|
131
135
|
}
|
|
132
136
|
return resources;
|
|
133
137
|
}
|
|
134
138
|
}
|
|
135
|
-
exports.default = BaseAppManager;
|
|
136
|
-
BaseAppManager.VALIDATION_RULES = new Map([["sap.app/id", (value) => {
|
|
137
|
-
if (!value.includes(".")) {
|
|
138
|
-
throw new Error(`The original application id '${value}' should consist of multiple segments split by dot, e.g.: original.id`);
|
|
139
|
-
}
|
|
140
|
-
}]]);
|
|
141
139
|
//# sourceMappingURL=baseAppManager.js.map
|
package/dist/buildStrategy.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
class BuildStrategy {
|
|
1
|
+
export default class BuildStrategy {
|
|
2
|
+
registrationBuild;
|
|
4
3
|
constructor(registrationBuild) {
|
|
5
4
|
this.registrationBuild = registrationBuild;
|
|
6
5
|
}
|
|
@@ -17,5 +16,4 @@ class BuildStrategy {
|
|
|
17
16
|
return manifest;
|
|
18
17
|
}
|
|
19
18
|
}
|
|
20
|
-
exports.default = BuildStrategy;
|
|
21
19
|
//# sourceMappingURL=buildStrategy.js.map
|
package/dist/bundle.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare const RegistrationBuild: () => void;
|
|
2
|
+
|
|
3
|
+
export declare class Applier {
|
|
4
|
+
static applyChanges(manifest: any, changes: Change[], strategy: any): Promise<void>;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export declare class Change {
|
|
8
|
+
constructor(change: any);
|
|
9
|
+
getLayer(): string;
|
|
10
|
+
_oDefinition: any;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export declare class V2MetadataConverter {
|
|
14
|
+
convertXMLMetadata(jsdom: any): any;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export declare class V4MetadataConverter {
|
|
18
|
+
convertXMLMetadata(jsdom: any): any;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export declare class URI {
|
|
22
|
+
constructor(relativeUrl: string);
|
|
23
|
+
absoluteTo(url: string): string;
|
|
24
|
+
static parse(url: string): { path: string };
|
|
25
|
+
}
|