Skip to content

Commit a855a13

Browse files
authored
[ui5-builder][INTERNAL] manifestCreator: log verbose for apf (#501)
library /sap/apf has both a Component.js and a .library file. This can't be solved due to backward compatibility. Therefore the log level was decreased from error to verbose.
1 parent 041c89f commit a855a13

File tree

2 files changed

+119
-0
lines changed

2 files changed

+119
-0
lines changed

packages/builder/lib/processors/manifestCreator.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ async function createManifest(libraryResource, libBundle, descriptorVersion, _in
164164
const relativePath = comp.getPath().slice(prefix.length);
165165
if ( relativePath.lastIndexOf("/") >= 0 ) {
166166
result.push( relativePath.slice(0, relativePath.lastIndexOf("/")) );
167+
} else if ( prefix === "/resources/sap/apf/" ) {
168+
log.verbose("Package %s contains both '*.library' and 'Component.js'. " +
169+
"This is a known issue but can't be solved due to backward compatibility.", comp.getPath());
167170
} else if ( prefix !== "/resources/sap/ui/core/" ) {
168171
log.error("Package %s contains both '*.library' and 'Component.js'. " +
169172
"This is not supported by manifests, therefore the component won't be " +
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
const test = require("ava");
2+
const sinon = require("sinon");
3+
const mock = require("mock-require");
4+
5+
const manifestCreator = require("../../../lib/processors/manifestCreator");
6+
7+
const libraryContent = `<?xml version="1.0" encoding="UTF-8" ?>
8+
<library xmlns="http://www.sap.com/sap.ui.library.xsd" >
9+
<name>library.e</name>
10+
<vendor>SAP SE</vendor>
11+
<copyright>my copyright</copyright>
12+
<version>1.0.0</version>
13+
<documentation>Library E</documentation>
14+
15+
<dependencies>
16+
<dependency>
17+
<libraryName>sap.ui.core</libraryName>
18+
</dependency>
19+
</dependencies>
20+
</library>`;
21+
22+
const expectedManifestContent = `{
23+
"_version": "1.9.0",
24+
"sap.app": {
25+
"id": "library.e",
26+
"type": "library",
27+
"embeds": [],
28+
"applicationVersion": {
29+
"version": "1.0.0"
30+
},
31+
"title": "Library E",
32+
"description": "Library E",
33+
"resources": "resources.json",
34+
"offline": true
35+
},
36+
"sap.ui": {
37+
"technology": "UI5",
38+
"supportedThemes": []
39+
},
40+
"sap.ui5": {
41+
"dependencies": {
42+
"libs": {
43+
"sap.ui.core": {}
44+
}
45+
},
46+
"library": {
47+
"i18n": false
48+
}
49+
}
50+
}`;
51+
52+
test.afterEach.always((t) => {
53+
mock.stopAll();
54+
sinon.restore();
55+
});
56+
57+
test("default manifest creation", async (t) => {
58+
const libraryResource = {
59+
getPath: () => {
60+
return "/resources/sap/ui/mine/.library";
61+
},
62+
getString: async () => {
63+
return libraryContent;
64+
},
65+
_project: {
66+
dependencies: [{
67+
metadata: {
68+
name: "sap.ui.core"
69+
}
70+
}]
71+
}
72+
};
73+
74+
const result = await manifestCreator({libraryResource, resources: [], options: {}});
75+
t.is(await result.getString(), expectedManifestContent, "Correct result returned");
76+
});
77+
78+
test.serial("manifest creation for sap/apf", async (t) => {
79+
const logger = require("@ui5/logger");
80+
const verboseLogStub = sinon.stub();
81+
const myLoggerInstance = {
82+
verbose: verboseLogStub
83+
};
84+
sinon.stub(logger, "getLogger").returns(myLoggerInstance);
85+
const manifestCreatorWithStub = mock.reRequire("../../../lib/processors/manifestCreator");
86+
87+
88+
const libraryResource = {
89+
getPath: () => {
90+
return "/resources/sap/apf/.library";
91+
},
92+
getString: async () => {
93+
return libraryContent;
94+
},
95+
_project: {
96+
dependencies: [{
97+
metadata: {
98+
name: "sap.ui.core"
99+
}
100+
}]
101+
}
102+
};
103+
104+
const componentResource = {
105+
getPath: () => {
106+
return "/resources/sap/apf/Component.js";
107+
}
108+
};
109+
110+
const result = await manifestCreatorWithStub({libraryResource, resources: [componentResource], options: {}});
111+
t.is(await result.getString(), expectedManifestContent, "Correct result returned");
112+
113+
t.is(verboseLogStub.callCount, 8);
114+
t.is(verboseLogStub.firstCall.args[0], "Package %s contains both '*.library' and 'Component.js'. This is a known issue but can't be solved due to backward compatibility.");
115+
t.is(verboseLogStub.firstCall.args[1], "/resources/sap/apf/Component.js");
116+
});

0 commit comments

Comments
 (0)