@ui5/task-adaptation 1.1.0 → 1.1.2
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 +9 -1
- package/README.md +1 -1
- package/dist/annotationManager.d.ts +0 -3
- package/dist/annotationManager.js +8 -43
- package/dist/annotations/comparator/comparator.d.ts +47 -0
- package/dist/annotations/comparator/comparator.js +276 -0
- package/dist/annotations/comparator/diffCase.d.ts +4 -0
- package/dist/annotations/comparator/diffCase.js +3 -0
- package/dist/annotations/comparator/interchangableCase.d.ts +25 -0
- package/dist/annotations/comparator/interchangableCase.js +65 -0
- package/dist/annotations/converter/metadataJsonReferenceUtil.d.ts +12 -0
- package/dist/annotations/converter/metadataJsonReferenceUtil.js +50 -0
- package/dist/annotations/converter/metadataJsonUtil.d.ts +30 -0
- package/dist/annotations/converter/metadataJsonUtil.js +73 -0
- package/dist/annotations/converter/ui5JsonConverter.d.ts +21 -0
- package/dist/annotations/converter/ui5JsonConverter.js +253 -0
- package/dist/annotations/converter/ui5MetadataJsonUtil.d.ts +3 -0
- package/dist/annotations/converter/ui5MetadataJsonUtil.js +13 -0
- package/dist/annotations/converter/ui5XmlConverter.d.ts +5 -0
- package/dist/annotations/converter/ui5XmlConverter.js +17 -0
- package/dist/annotations/dataSource/dataSource.d.ts +34 -0
- package/dist/annotations/dataSource/dataSource.js +62 -0
- package/dist/annotations/dataSource/dataSourceManager.d.ts +13 -0
- package/dist/annotations/dataSource/dataSourceManager.js +58 -0
- package/dist/annotations/dataSource/dataSourceOData.d.ts +17 -0
- package/dist/annotations/dataSource/dataSourceOData.js +47 -0
- package/dist/annotations/dataSource/dataSourceODataAnnotation.d.ts +6 -0
- package/dist/annotations/dataSource/dataSourceODataAnnotation.js +14 -0
- package/dist/annotations/dataSource/dataSourceODataAnnotationBeta.d.ts +6 -0
- package/dist/annotations/dataSource/dataSourceODataAnnotationBeta.js +18 -0
- package/dist/annotations/serviceRequestor.d.ts +1 -9
- package/dist/annotations/serviceRequestor.js +52 -17
- package/dist/annotations/transformers/convertV2ToV4.d.ts +4 -0
- package/dist/annotations/transformers/convertV2ToV4.js +16 -0
- package/dist/annotations/transformers/makeAnnotationNamespaceUnique.d.ts +6 -0
- package/dist/annotations/transformers/makeAnnotationNamespaceUnique.js +44 -0
- package/dist/annotations/transformers/removeAllSchemaNodesExceptAnnotations.d.ts +4 -0
- package/dist/annotations/transformers/removeAllSchemaNodesExceptAnnotations.js +17 -0
- package/dist/annotations/transformers/transformer.d.ts +12 -0
- package/dist/annotations/transformers/transformer.js +3 -0
- package/dist/annotations/transformers/traverseReferences.d.ts +9 -0
- package/dist/annotations/transformers/traverseReferences.js +67 -0
- package/dist/appVariantManager.d.ts +4 -2
- package/dist/appVariantManager.js +44 -18
- package/dist/baseAppManager.d.ts +2 -1
- package/dist/baseAppManager.js +26 -31
- package/dist/bundle-odata.js +5498 -0
- package/dist/bundle.js +1786 -13
- package/dist/i18nManager.d.ts +5 -7
- package/dist/i18nManager.js +29 -32
- package/dist/index.js +4 -3
- package/dist/model/annotationDiffStructureError.js +2 -0
- package/dist/model/language.js +1 -1
- package/dist/model/serverError.d.ts +3 -0
- package/dist/model/serverError.js +9 -0
- package/dist/model/types.d.ts +13 -2
- package/dist/repositories/abapRepoManager.js +2 -2
- package/dist/util/commonUtil.d.ts +7 -0
- package/dist/util/commonUtil.js +72 -18
- package/dist/util/i18nMerger.d.ts +1 -1
- package/dist/util/i18nMerger.js +3 -4
- package/dist/util/requestUtil.js +4 -0
- package/dist/util/resourceUtil.d.ts +3 -0
- package/dist/util/resourceUtil.js +14 -1
- package/dist/util/urlUtil.d.ts +4 -0
- package/dist/util/urlUtil.js +21 -0
- package/package.json +9 -6
- package/scripts/bundler.ts +4 -33
- package/scripts/metadataDownloadHelper.ts +7 -5
- package/scripts/rollup/bundleDefinition-odata.js +9 -0
- package/scripts/rollup/overrides/sap/ui/performance/Measurement.js +4 -0
- package/scripts/rollup/ui5Resolve.ts +34 -5
- package/scripts/rollup.ts +12 -3
- package/dist/annotations/oDataModel.d.ts +0 -20
- package/dist/annotations/oDataModel.js +0 -46
- package/dist/annotations/oDataV2Model.d.ts +0 -4
- package/dist/annotations/oDataV2Model.js +0 -13
- package/dist/util/jsonDiffUtil.d.ts +0 -28
- package/dist/util/jsonDiffUtil.js +0 -74
- package/scripts/rollup/overrides/sap/ui/thirdparty/URI.js +0 -16
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const dataSource_1 = require("./dataSource");
|
|
4
|
+
const traverseReferences_1 = require("../transformers/traverseReferences");
|
|
5
|
+
class DataSourceODataAnnotation extends dataSource_1.default {
|
|
6
|
+
constructor(name, uri, dataSourceJson, metadataUrl) {
|
|
7
|
+
super(name, uri);
|
|
8
|
+
this.dataSourceJson = dataSourceJson;
|
|
9
|
+
this.jsonTransformers = [
|
|
10
|
+
new traverseReferences_1.default(metadataUrl)
|
|
11
|
+
];
|
|
12
|
+
}
|
|
13
|
+
updateManifest() {
|
|
14
|
+
this.dataSourceJson.uri = this.getFilename();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.default = DataSourceODataAnnotation;
|
|
18
|
+
//# sourceMappingURL=dataSourceODataAnnotationBeta.js.map
|
|
@@ -1,17 +1,9 @@
|
|
|
1
1
|
import AbapRepoManager from "../repositories/abapRepoManager";
|
|
2
2
|
import { IConfiguration } from "../model/types";
|
|
3
3
|
import Language from "../model/language";
|
|
4
|
-
export interface ILanguageXmlContent {
|
|
5
|
-
language: Language;
|
|
6
|
-
xml: string;
|
|
7
|
-
}
|
|
8
|
-
export interface ILanguageJsonContent {
|
|
9
|
-
language: Language;
|
|
10
|
-
json: any;
|
|
11
|
-
}
|
|
12
4
|
export default class ServiceRequestor {
|
|
13
5
|
private abapRepoManager;
|
|
14
6
|
private configuration;
|
|
15
7
|
constructor(configuration: IConfiguration, abapRepoManager: AbapRepoManager);
|
|
16
|
-
downloadAnnotation(uri: string, name: string, language: Language): Promise<
|
|
8
|
+
downloadAnnotation(uri: string, name: string, language: Language): Promise<string>;
|
|
17
9
|
}
|
|
@@ -1,36 +1,71 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
2
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
9
|
const annotationsCacheManager_1 = require("../cache/annotationsCacheManager");
|
|
10
|
+
const serverError_1 = require("../model/serverError");
|
|
11
|
+
const commonUtil_1 = require("../util/commonUtil");
|
|
4
12
|
const log = require("@ui5/logger").getLogger("@ui5/task-adaptation::ServiceRequestor");
|
|
13
|
+
function retryOnError(maxRetries) {
|
|
14
|
+
return (_target, _propertyKey, descriptor) => {
|
|
15
|
+
const originalMethod = descriptor.value;
|
|
16
|
+
descriptor.value = async function (...args) {
|
|
17
|
+
let retries = 0;
|
|
18
|
+
while (true) {
|
|
19
|
+
try {
|
|
20
|
+
const result = await originalMethod.apply(this, args);
|
|
21
|
+
return result;
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
if (error instanceof serverError_1.default) {
|
|
25
|
+
if (retries === maxRetries) {
|
|
26
|
+
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
|
+
}
|
|
28
|
+
retries++;
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
throw new Error(`Failed to fetch annotation by '${args[0]}': ${error.message}`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
return descriptor;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
5
39
|
class ServiceRequestor {
|
|
6
40
|
constructor(configuration, abapRepoManager) {
|
|
7
41
|
this.abapRepoManager = abapRepoManager;
|
|
8
42
|
this.configuration = configuration;
|
|
9
43
|
}
|
|
10
44
|
async downloadAnnotation(uri, name, language) {
|
|
45
|
+
let cacheName = name;
|
|
11
46
|
if (language.sap) {
|
|
12
47
|
uri += `?sap-language=${language.sap}`;
|
|
13
|
-
|
|
48
|
+
cacheName += `-${language.sap}`;
|
|
14
49
|
}
|
|
15
|
-
const cacheManager = new annotationsCacheManager_1.default(this.configuration,
|
|
16
|
-
log.verbose(`Getting annotation '${
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
files = await this.abapRepoManager.downloadAnnotationFile(uri);
|
|
24
|
-
}
|
|
25
|
-
if (!files || files.size === 0) {
|
|
26
|
-
throw new Error(`No files were fetched for '${name}' by '${uri}'`);
|
|
27
|
-
}
|
|
28
|
-
return { language, xml: [...files][0][1] };
|
|
50
|
+
const cacheManager = new annotationsCacheManager_1.default(this.configuration, cacheName);
|
|
51
|
+
log.verbose(`Getting annotation '${cacheName}' ${language} by '${uri}'`);
|
|
52
|
+
let files;
|
|
53
|
+
if (this.configuration.enableAnnotationCache) {
|
|
54
|
+
files = await cacheManager.getFiles(() => this.abapRepoManager.getAnnotationMetadata(uri), () => this.abapRepoManager.downloadAnnotationFile(uri));
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
files = await this.abapRepoManager.downloadAnnotationFile(uri);
|
|
29
58
|
}
|
|
30
|
-
|
|
31
|
-
throw new Error(`
|
|
59
|
+
if (!files || files.size === 0) {
|
|
60
|
+
throw new Error(`No files were fetched for '${name}' by '${uri}'`);
|
|
32
61
|
}
|
|
62
|
+
const xml = [...files][0][1];
|
|
63
|
+
(0, commonUtil_1.writeTempAnnotations)(this.configuration, name, language, xml);
|
|
64
|
+
return xml;
|
|
33
65
|
}
|
|
34
66
|
}
|
|
67
|
+
__decorate([
|
|
68
|
+
retryOnError(1)
|
|
69
|
+
], ServiceRequestor.prototype, "downloadAnnotation", null);
|
|
35
70
|
exports.default = ServiceRequestor;
|
|
36
71
|
//# sourceMappingURL=serviceRequestor.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const metadataJsonUtil_1 = require("../converter/metadataJsonUtil");
|
|
4
|
+
const ui5JsonConverter_1 = require("../converter/ui5JsonConverter");
|
|
5
|
+
const ui5XmlConverter_1 = require("../converter/ui5XmlConverter");
|
|
6
|
+
class ConvertV2ToV4 {
|
|
7
|
+
transform({ json, xml }) {
|
|
8
|
+
if (metadataJsonUtil_1.default.getVersion(json) !== "4.0") {
|
|
9
|
+
const annotationsV4 = ui5JsonConverter_1.default.convertAnnotations(ui5XmlConverter_1.default.convertV2(xml));
|
|
10
|
+
metadataJsonUtil_1.default.setAnnotations(json, annotationsV4);
|
|
11
|
+
}
|
|
12
|
+
return json;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.default = ConvertV2ToV4;
|
|
16
|
+
//# sourceMappingURL=convertV2ToV4.js.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const metadataJsonUtil_1 = require("../converter/metadataJsonUtil");
|
|
4
|
+
const crc16_1 = require("crc/crc16");
|
|
5
|
+
class MakeAnnotationNamespaceUnique {
|
|
6
|
+
transform({ json, uri }) {
|
|
7
|
+
const uniquePart = (0, crc16_1.default)(uri).toString(16);
|
|
8
|
+
// First add current schema as reference
|
|
9
|
+
const schema = metadataJsonUtil_1.default.getSchemaNode(json);
|
|
10
|
+
const references = this.getReferences(json);
|
|
11
|
+
references.push(this.createReference(schema, uri));
|
|
12
|
+
// Then rename the namespace/alias
|
|
13
|
+
schema._attributes.Namespace += "." + uniquePart;
|
|
14
|
+
delete schema._attributes["Alias"];
|
|
15
|
+
return json;
|
|
16
|
+
}
|
|
17
|
+
createReference(schema, uri) {
|
|
18
|
+
const attributes = {
|
|
19
|
+
Namespace: schema._attributes.Namespace
|
|
20
|
+
};
|
|
21
|
+
if (schema._attributes.Alias) {
|
|
22
|
+
attributes.Alias = schema._attributes.Alias;
|
|
23
|
+
}
|
|
24
|
+
;
|
|
25
|
+
return {
|
|
26
|
+
_attributes: {
|
|
27
|
+
Uri: uri
|
|
28
|
+
},
|
|
29
|
+
"edmx:Include": {
|
|
30
|
+
_attributes: attributes
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
getReferences(json) {
|
|
35
|
+
const REFERENCE_NODE_NAME = "edmx:Reference";
|
|
36
|
+
const references = metadataJsonUtil_1.default.getEdmx(json)[REFERENCE_NODE_NAME];
|
|
37
|
+
if (!Array.isArray(references)) {
|
|
38
|
+
metadataJsonUtil_1.default.getEdmx(json)[REFERENCE_NODE_NAME] = [references];
|
|
39
|
+
}
|
|
40
|
+
return metadataJsonUtil_1.default.getEdmx(json)[REFERENCE_NODE_NAME];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.default = MakeAnnotationNamespaceUnique;
|
|
44
|
+
//# sourceMappingURL=makeAnnotationNamespaceUnique.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const metadataJsonUtil_1 = require("../converter/metadataJsonUtil");
|
|
4
|
+
class RemoveAllSchemaNodesExceptAnnotations {
|
|
5
|
+
transform({ json }) {
|
|
6
|
+
const schema = metadataJsonUtil_1.default.getSchemaNode(json);
|
|
7
|
+
for (const key of Object.keys(schema)) {
|
|
8
|
+
if (key !== "_attributes" && key !== "Annotations") {
|
|
9
|
+
delete schema[key];
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return json;
|
|
13
|
+
// TODO: remove also references not used in annotations
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.default = RemoveAllSchemaNodesExceptAnnotations;
|
|
17
|
+
//# sourceMappingURL=removeAllSchemaNodesExceptAnnotations.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import Language from "../../model/language";
|
|
2
|
+
import ServiceRequestor from "../serviceRequestor";
|
|
3
|
+
export interface TransformerInput {
|
|
4
|
+
uri: string;
|
|
5
|
+
json: any;
|
|
6
|
+
xml: string;
|
|
7
|
+
language: Language;
|
|
8
|
+
serviceRequestor: ServiceRequestor;
|
|
9
|
+
}
|
|
10
|
+
export default interface Transformer {
|
|
11
|
+
transform(input: TransformerInput): any;
|
|
12
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import Transformer, { TransformerInput } from "../transformers/transformer";
|
|
2
|
+
export default class TraverseReferences implements Transformer {
|
|
3
|
+
private metadataUrl?;
|
|
4
|
+
constructor(metadataUrl?: string);
|
|
5
|
+
transform({ json, language, serviceRequestor, uri: parentUrl }: TransformerInput): Promise<void>;
|
|
6
|
+
private shouldIgnoreUrl;
|
|
7
|
+
private mergeAnnotations;
|
|
8
|
+
private static isTraversable;
|
|
9
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const metadataJsonUtil_1 = require("../converter/metadataJsonUtil");
|
|
4
|
+
const dataSourceODataAnnotationBeta_1 = require("../dataSource/dataSourceODataAnnotationBeta");
|
|
5
|
+
const urlUtil_1 = require("../../util/urlUtil");
|
|
6
|
+
class TraverseReferences {
|
|
7
|
+
constructor(metadataUrl) {
|
|
8
|
+
this.metadataUrl = metadataUrl;
|
|
9
|
+
}
|
|
10
|
+
async transform({ json, language, serviceRequestor, uri: parentUrl }) {
|
|
11
|
+
const references = metadataJsonUtil_1.default.getReferences(json).filter(TraverseReferences.isTraversable);
|
|
12
|
+
const promises = [];
|
|
13
|
+
for (const { includes, uri: relativeUrl } of references) {
|
|
14
|
+
const absoluteUrl = urlUtil_1.default.join(urlUtil_1.default.getResourcePath(relativeUrl), parentUrl);
|
|
15
|
+
if (this.shouldIgnoreUrl(absoluteUrl, [parentUrl, this.metadataUrl])) {
|
|
16
|
+
// If reference to metadata or its parent, don't traverse
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
const name = includes[0]?.namespace;
|
|
20
|
+
const dataSource = new dataSourceODataAnnotationBeta_1.default(name, absoluteUrl, {}, this.metadataUrl);
|
|
21
|
+
promises.push(dataSource.downloadAnnotation(language, serviceRequestor)
|
|
22
|
+
.then(childAnnotation => ({ name, childAnnotation })));
|
|
23
|
+
}
|
|
24
|
+
const childAnnotations = await Promise.all(promises);
|
|
25
|
+
for (const { childAnnotation } of childAnnotations) {
|
|
26
|
+
this.mergeAnnotations(json, childAnnotation);
|
|
27
|
+
}
|
|
28
|
+
return json;
|
|
29
|
+
}
|
|
30
|
+
shouldIgnoreUrl(referenceUrl, urlsToIgnore) {
|
|
31
|
+
const toResourcePath = (url) => urlUtil_1.default.getResourcePath(url);
|
|
32
|
+
const isEqual = (a, b) => a && b && a.toLowerCase() === b.toLowerCase();
|
|
33
|
+
return urlsToIgnore.map(toResourcePath).some(url => isEqual(referenceUrl, url));
|
|
34
|
+
}
|
|
35
|
+
mergeAnnotations(parentJson, nestedJson) {
|
|
36
|
+
const parentAnnotations = metadataJsonUtil_1.default.getAnnotations(parentJson);
|
|
37
|
+
const parentMapByTarget = metadataJsonUtil_1.default.mapAnnotationsPerTarget(parentJson);
|
|
38
|
+
const nestedMapByTarget = metadataJsonUtil_1.default.mapAnnotationsPerTarget(nestedJson);
|
|
39
|
+
for (const nested of [...nestedMapByTarget].map(([target, { json }]) => ({ target, json }))) {
|
|
40
|
+
// If we found parent annotation with the same target - we extend it
|
|
41
|
+
// with missing <Annotation> nodes. If not, just add it to the end.
|
|
42
|
+
// Annotations do not have a merge logic If same target & term is in
|
|
43
|
+
// parent and nested, parent wins (same logic as UI5 in
|
|
44
|
+
// sap/ui/model/odata/v4/ODataMetaModel.js mergeAnnotations).
|
|
45
|
+
const parent = parentMapByTarget.get(nested.target);
|
|
46
|
+
if (parent) {
|
|
47
|
+
metadataJsonUtil_1.default.toArrayTransform(parent.json, "Annotation");
|
|
48
|
+
const parentTerms = parent.json.Annotation.map((item) => item._attributes.Term);
|
|
49
|
+
for (const nestedAnnotation of metadataJsonUtil_1.default.toArrayReadOnly(nested.json.Annotation)) {
|
|
50
|
+
if (!parentTerms.includes(nestedAnnotation._attributes.Term)) {
|
|
51
|
+
parent.json.Annotation.push(nestedAnnotation);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
parentAnnotations.push(nested.json);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
metadataJsonUtil_1.default.setAnnotations(parentJson, parentAnnotations);
|
|
60
|
+
}
|
|
61
|
+
static isTraversable(reference) {
|
|
62
|
+
const IGNORED_NAMESPACES = ["com.sap.vocabularies.", "Org.OData."];
|
|
63
|
+
return !reference.includes.some(include => IGNORED_NAMESPACES.some(namespace => include.namespace.startsWith(namespace)));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.default = TraverseReferences;
|
|
67
|
+
//# sourceMappingURL=traverseReferences.js.map
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { IAppVariantInfo } from "./model/types";
|
|
2
2
|
export default class AppVariantManager {
|
|
3
3
|
static process(appVariantResources: any[], projectNamespace: string, taskUtil: any): Promise<IAppVariantInfo>;
|
|
4
|
-
static
|
|
5
|
-
static
|
|
4
|
+
static getAppVariantResourcesToProcess(workspace: any): Promise<any[]>;
|
|
5
|
+
static updateChanges(appVariantResources: any[], projectNamespace: string): Promise<void>;
|
|
6
6
|
private static isManifestChange;
|
|
7
7
|
private static isManifestAppVariant;
|
|
8
8
|
static getAppVariantInfo(appVariantResources: any[]): Promise<IAppVariantInfo>;
|
|
9
|
+
private static validateManifest;
|
|
10
|
+
private static updateRelativePaths;
|
|
9
11
|
private static omitFiles;
|
|
10
12
|
}
|
|
@@ -3,24 +3,27 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const resourceUtil_1 = require("./util/resourceUtil");
|
|
4
4
|
const path_1 = require("path");
|
|
5
5
|
const commonUtil_1 = require("./util/commonUtil");
|
|
6
|
-
const
|
|
6
|
+
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
7
|
class AppVariantManager {
|
|
8
8
|
static async process(appVariantResources, projectNamespace, taskUtil) {
|
|
9
|
-
const appVariantInfo = await this.getAppVariantInfo(appVariantResources);
|
|
10
9
|
for (const resource of appVariantResources) {
|
|
11
10
|
this.omitFiles(resource, taskUtil);
|
|
12
11
|
}
|
|
13
|
-
await this.
|
|
14
|
-
return
|
|
12
|
+
await this.updateChanges(appVariantResources, projectNamespace);
|
|
13
|
+
return this.getAppVariantInfo(appVariantResources);
|
|
15
14
|
}
|
|
16
|
-
static
|
|
17
|
-
return workspace.byGlob(`/**/*.{${
|
|
15
|
+
static getAppVariantResourcesToProcess(workspace) {
|
|
16
|
+
return workspace.byGlob(`/**/*.{${EXTENSIONS_TO_PROCESS}}`);
|
|
18
17
|
}
|
|
19
|
-
static async
|
|
18
|
+
static async updateChanges(appVariantResources, projectNamespace) {
|
|
20
19
|
const changesFolder = resourceUtil_1.default.getResourcePath(projectNamespace, "changes");
|
|
21
20
|
const changes = new Map();
|
|
22
21
|
const resourcesByPath = new Map();
|
|
22
|
+
let manifest;
|
|
23
23
|
for (const resource of appVariantResources) {
|
|
24
|
+
if (this.isManifestAppVariant(resource)) {
|
|
25
|
+
manifest = await resourceUtil_1.default.getJson(resource);
|
|
26
|
+
}
|
|
24
27
|
const resourcePath = resource.getPath();
|
|
25
28
|
const basename = path_1.posix.dirname(resourcePath);
|
|
26
29
|
if (basename.startsWith(changesFolder)) {
|
|
@@ -28,7 +31,9 @@ class AppVariantManager {
|
|
|
28
31
|
resourcesByPath.set(resourcePath, resource);
|
|
29
32
|
}
|
|
30
33
|
}
|
|
31
|
-
|
|
34
|
+
this.updateRelativePaths(changes, projectNamespace);
|
|
35
|
+
this.validateManifest(manifest);
|
|
36
|
+
const renamedChanges = (0, commonUtil_1.renameResources)(changes, manifest.reference, manifest.id);
|
|
32
37
|
renamedChanges.forEach((renamedContent, resourcePath) => {
|
|
33
38
|
const resource = resourcesByPath.get(resourcePath);
|
|
34
39
|
resourceUtil_1.default.setString(resource, renamedContent);
|
|
@@ -36,7 +41,8 @@ class AppVariantManager {
|
|
|
36
41
|
}
|
|
37
42
|
static isManifestChange(resource) {
|
|
38
43
|
const changesManifestFolder = path_1.posix.join("changes", "manifest");
|
|
39
|
-
const
|
|
44
|
+
const resourcePath = typeof resource === "string" ? resource : resource.getPath();
|
|
45
|
+
const dirname = path_1.posix.dirname(resourcePath);
|
|
40
46
|
return dirname.endsWith(changesManifestFolder);
|
|
41
47
|
}
|
|
42
48
|
static isManifestAppVariant(resource) {
|
|
@@ -49,22 +55,42 @@ class AppVariantManager {
|
|
|
49
55
|
const manifestChanges = [];
|
|
50
56
|
for (const resource of appVariantResources) {
|
|
51
57
|
if (this.isManifestAppVariant(resource)) {
|
|
52
|
-
manifest = await resourceUtil_1.default.
|
|
58
|
+
manifest = await resourceUtil_1.default.getJson(resource);
|
|
53
59
|
}
|
|
54
60
|
else if (this.isManifestChange(resource)) {
|
|
55
61
|
const content = await resourceUtil_1.default.getString(resource);
|
|
56
62
|
manifestChanges.push(JSON.parse(content));
|
|
57
63
|
}
|
|
58
64
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
this.validateManifest(manifest);
|
|
66
|
+
return {
|
|
67
|
+
id: manifest.id,
|
|
68
|
+
reference: manifest.reference,
|
|
69
|
+
layer: manifest.layer,
|
|
70
|
+
changes: manifestChanges.concat(manifest.content)
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
static validateManifest(manifest) {
|
|
74
|
+
if (!manifest) {
|
|
75
|
+
throw new Error("Adaptation project should contain manifest.appdescr_variant");
|
|
66
76
|
}
|
|
67
|
-
|
|
77
|
+
}
|
|
78
|
+
// TODO In future this should be handled by merger which needs to know change and target location
|
|
79
|
+
static updateRelativePaths(changes, projectNamespace) {
|
|
80
|
+
changes.forEach((jsonString, resourcePath) => {
|
|
81
|
+
if (this.isManifestChange(resourcePath)) {
|
|
82
|
+
const change = JSON.parse(jsonString);
|
|
83
|
+
if (change.changeType === "appdescr_app_addAnnotationsToOData") {
|
|
84
|
+
for (const dataSource of Object.values(change.content.dataSource)) {
|
|
85
|
+
if (!dataSource.uri.startsWith("/")) {
|
|
86
|
+
const basepath = path_1.posix.dirname(resourceUtil_1.default.relativeToRoot(resourcePath, projectNamespace));
|
|
87
|
+
dataSource.uri = path_1.posix.join(basepath.replace(/^\//, ""), dataSource.uri);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
changes.set(resourcePath, JSON.stringify(change));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
});
|
|
68
94
|
}
|
|
69
95
|
static omitFiles(resource, taskUtil) {
|
|
70
96
|
if (this.isManifestAppVariant(resource) || this.isManifestChange(resource)) {
|
package/dist/baseAppManager.d.ts
CHANGED
|
@@ -21,8 +21,9 @@ export default class BaseAppManager {
|
|
|
21
21
|
private static extractI18NFromBundleUrl;
|
|
22
22
|
private static getBaseAppManifest;
|
|
23
23
|
private static fillAppVariantIdHierarchy;
|
|
24
|
+
private static VALIDATION_RULES;
|
|
24
25
|
static validateProperty(value: string, property: string): void;
|
|
25
|
-
static applyDescriptorChanges(baseAppManifest: any,
|
|
26
|
+
static applyDescriptorChanges(baseAppManifest: any, { layer, changes, id }: IAppVariantInfo): Promise<void>;
|
|
26
27
|
private static adjustAddNewModelEnhanceWith;
|
|
27
28
|
static writeToWorkspace(baseAppFiles: Map<string, string>, projectNamespace: string): any[];
|
|
28
29
|
}
|
package/dist/baseAppManager.js
CHANGED
|
@@ -3,15 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const commonUtil_1 = require("./util/commonUtil");
|
|
4
4
|
const buildStrategy_1 = require("./buildStrategy");
|
|
5
5
|
const resourceUtil_1 = require("./util/resourceUtil");
|
|
6
|
-
const path_1 = require("path");
|
|
7
6
|
const commonUtil_2 = require("./util/commonUtil");
|
|
8
7
|
const { RegistrationBuild, Applier, Change } = require("../dist/bundle");
|
|
9
|
-
const resourceFactory = require("@ui5/fs/lib/resourceFactory");
|
|
10
8
|
const log = require("@ui5/logger").getLogger("@ui5/task-adaptation::BaseAppManager");
|
|
11
9
|
class BaseAppManager {
|
|
12
10
|
static async process(baseAppFiles, appVariantInfo, options, processor) {
|
|
13
11
|
const baseAppManifest = this.getBaseAppManifest(baseAppFiles);
|
|
14
12
|
const { id, version } = this.getIdVersion(baseAppManifest.content);
|
|
13
|
+
this.validateProperty(id, "sap.app/id");
|
|
14
|
+
this.validateProperty(version, "sap.app/applicationVersion/version");
|
|
15
15
|
const renamedBaseAppFiles = (0, commonUtil_2.renameResources)(baseAppFiles, appVariantInfo.reference, appVariantInfo.id);
|
|
16
16
|
const { filepath, content } = this.getBaseAppManifest(renamedBaseAppFiles);
|
|
17
17
|
await processor.updateLandscapeSpecificContent(content, renamedBaseAppFiles);
|
|
@@ -59,19 +59,17 @@ class BaseAppManager {
|
|
|
59
59
|
return (0, commonUtil_1.removePropertiesExtension)(i18nNode["bundleUrl"]);
|
|
60
60
|
}
|
|
61
61
|
static getBaseAppManifest(baseAppFiles) {
|
|
62
|
-
|
|
63
|
-
if (
|
|
62
|
+
const manifestContent = baseAppFiles.get("manifest.json");
|
|
63
|
+
if (manifestContent) {
|
|
64
64
|
return {
|
|
65
|
-
content: JSON.parse(
|
|
66
|
-
filepath
|
|
65
|
+
content: JSON.parse(manifestContent),
|
|
66
|
+
filepath: "manifest.json"
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
69
|
throw new Error("Original application should have manifest.json in root folder");
|
|
70
70
|
}
|
|
71
71
|
static fillAppVariantIdHierarchy(processor, id, version, baseAppManifest) {
|
|
72
72
|
log.verbose("Filling up app variant hierarchy in manifest.json");
|
|
73
|
-
this.validateProperty(id, "sap.app/id");
|
|
74
|
-
this.validateProperty(version, "sap.app/applicationVersion/version");
|
|
75
73
|
if (baseAppManifest["sap.ui5"] == null) {
|
|
76
74
|
baseAppManifest["sap.ui5"] = {};
|
|
77
75
|
}
|
|
@@ -85,25 +83,24 @@ class BaseAppManager {
|
|
|
85
83
|
if (!value) {
|
|
86
84
|
throw new Error(`Original application manifest should have ${property}`);
|
|
87
85
|
}
|
|
86
|
+
let validatationRule = this.VALIDATION_RULES.get(property);
|
|
87
|
+
if (validatationRule) {
|
|
88
|
+
validatationRule(value);
|
|
89
|
+
}
|
|
88
90
|
}
|
|
89
|
-
static async applyDescriptorChanges(baseAppManifest,
|
|
91
|
+
static async applyDescriptorChanges(baseAppManifest, { layer, changes, id }) {
|
|
90
92
|
log.verbose("Applying appVariant changes");
|
|
91
|
-
const strategy = new buildStrategy_1.default(RegistrationBuild);
|
|
92
|
-
const { manifest } = appVariantInfo;
|
|
93
|
-
const allChanges = [
|
|
94
|
-
...manifest.content,
|
|
95
|
-
...appVariantInfo.manifestChanges
|
|
96
|
-
];
|
|
97
93
|
const changesContent = new Array();
|
|
98
|
-
const i18nBundleName = (0, commonUtil_1.dotToUnderscore)(
|
|
99
|
-
for (const change of structuredClone(
|
|
100
|
-
if (
|
|
101
|
-
change.layer =
|
|
94
|
+
const i18nBundleName = (0, commonUtil_1.dotToUnderscore)(id);
|
|
95
|
+
for (const change of structuredClone(changes)) {
|
|
96
|
+
if (layer) {
|
|
97
|
+
change.layer = layer;
|
|
102
98
|
}
|
|
103
|
-
this.adjustAddNewModelEnhanceWith(change, i18nBundleName);
|
|
104
99
|
changesContent.push(new Change(change));
|
|
100
|
+
this.adjustAddNewModelEnhanceWith(change, i18nBundleName);
|
|
105
101
|
}
|
|
106
102
|
if (changesContent.length > 0) {
|
|
103
|
+
const strategy = new buildStrategy_1.default(RegistrationBuild);
|
|
107
104
|
await Applier.applyChanges(baseAppManifest, changesContent, strategy);
|
|
108
105
|
}
|
|
109
106
|
}
|
|
@@ -121,17 +118,14 @@ class BaseAppManager {
|
|
|
121
118
|
}
|
|
122
119
|
static writeToWorkspace(baseAppFiles, projectNamespace) {
|
|
123
120
|
const IGNORE_FILES = [
|
|
124
|
-
"
|
|
125
|
-
"
|
|
126
|
-
"
|
|
121
|
+
"manifest-bundle.zip",
|
|
122
|
+
"Component-preload.js",
|
|
123
|
+
"sap-ui-cachebuster-info.json"
|
|
127
124
|
];
|
|
128
125
|
const resources = [];
|
|
129
126
|
for (let filename of baseAppFiles.keys()) {
|
|
130
127
|
if (!IGNORE_FILES.includes(filename)) {
|
|
131
|
-
const resource =
|
|
132
|
-
path: getPath(filename, projectNamespace),
|
|
133
|
-
string: baseAppFiles.get(filename)
|
|
134
|
-
});
|
|
128
|
+
const resource = resourceUtil_1.default.createResource(filename, projectNamespace, baseAppFiles.get(filename));
|
|
135
129
|
resources.push(resource);
|
|
136
130
|
}
|
|
137
131
|
}
|
|
@@ -139,8 +133,9 @@ class BaseAppManager {
|
|
|
139
133
|
}
|
|
140
134
|
}
|
|
141
135
|
exports.default = BaseAppManager;
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
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
|
+
}]]);
|
|
146
141
|
//# sourceMappingURL=baseAppManager.js.map
|