Skip to content

Commit 5f8d362

Browse files
committed
[INTERNAL] generateVersionInfo: Only process dependencies of type 'library'
Ignore any other project types, even if the project contains a .library file. Currently, projects of type 'module' will return null as their namespace, which is then incorrectly used as a string in the constructed glob pattern. Projects of type 'library' always provide a valid namespace.
1 parent a5e789a commit 5f8d362

File tree

2 files changed

+46
-8
lines changed

2 files changed

+46
-8
lines changed

lib/tasks/generateVersionInfo.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ const MANIFEST_JSON = "manifest.json";
2323
* @returns {Promise<undefined>} Promise resolving with <code>undefined</code> once data has been written
2424
*/
2525
export default async ({workspace, dependencies, options: {rootProject, pattern}}) => {
26-
const resources = await dependencies.byGlob(pattern);
26+
let resources = await dependencies.byGlob(pattern);
27+
28+
resources = resources.filter((res) => res.getProject()?.getType() === "library");
2729

2830
const libraryInfosPromises = resources.map((dotLibResource) => {
2931
const namespace = dotLibResource.getProject().getNamespace();

test/lib/tasks/generateVersionInfo.js

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ const projectCache = {};
1212
*
1313
* @param {string[]} names e.g. ["lib", "a"]
1414
* @param {string} [version="3.0.0-<library name>"] Project version
15+
* @param {string} [type="library"] Project type
1516
* @returns {object} Project mock
1617
*/
17-
const createProjectMetadata = (names, version) => {
18+
const createProjectMetadata = (names, version, type) => {
1819
const key = names.join(".");
1920

2021
// Cache projects in order to return same object instance
@@ -26,11 +27,11 @@ const createProjectMetadata = (names, version) => {
2627
return projectCache[key] = {
2728
getName: () => key,
2829
getNamespace: () => names.join("/"),
29-
getVersion: () => version || "3.0.0-" + key
30+
getVersion: () => version || "3.0.0-" + key,
31+
getType: () => type || "library"
3032
};
3133
};
3234

33-
3435
function createWorkspace() {
3536
return resourceFactory.createAdapter({
3637
virBasePath: "/",
@@ -42,9 +43,9 @@ function createDependencies(oOptions = {
4243
virBasePath: "/resources/",
4344
fsBasePath: path.join(__dirname, "..", "..", "fixtures", "sap.ui.core-evo", "main", "src")
4445
}) {
45-
oOptions = Object.assign(oOptions, {
46+
oOptions = Object.assign({
4647
project: createProjectMetadata(["test", "lib3"], "3.0.0")
47-
});
48+
}, oOptions);
4849
return resourceFactory.createAdapter(oOptions);
4950
}
5051

@@ -246,9 +247,9 @@ const createResources = async (dependencies, resourceFactory, names, deps, embed
246247
function createDepWorkspace(names, oOptions = {
247248
virBasePath: "/resources"
248249
}) {
249-
oOptions = Object.assign(oOptions, {
250+
oOptions = Object.assign({
250251
project: createProjectMetadata(names)
251-
});
252+
}, oOptions);
252253
return resourceFactory.createAdapter(oOptions);
253254
}
254255

@@ -1146,3 +1147,38 @@ test.serial("integration: Library with manifest with invalid dependency", async
11461147
"This might prevent some UI5 runtime performance optimizations from taking effect. " +
11471148
"Please double check your project's dependency configuration.");
11481149
});
1150+
1151+
test.serial("integration: Library of type 'module'", async (t) => {
1152+
const {infoLogStub} = t.context;
1153+
const workspace = createWorkspace();
1154+
1155+
await createDotLibrary(workspace, resourceFactory, ["test", "lib"]);
1156+
1157+
// dependencies
1158+
const dependencies = createDepWorkspace(["module", "x"], {
1159+
virBasePath: "/",
1160+
project: createProjectMetadata(["module", "x"], "1.0.0", "module")
1161+
});
1162+
1163+
// lib.a
1164+
await createResources(dependencies, resourceFactory, ["module", "x"], [{name: "non.existing"}]);
1165+
1166+
1167+
const oOptions = {
1168+
options: {
1169+
projectName: "Test Lib",
1170+
pattern: "/resources/**/.library",
1171+
rootProject: createProjectMetadata(["myname"], "1.33.7")
1172+
},
1173+
workspace,
1174+
dependencies
1175+
};
1176+
await assertCreatedVersionInfo(t, {
1177+
"name": "myname",
1178+
"scmRevision": "",
1179+
"version": "1.33.7",
1180+
"libraries": [],
1181+
}, oOptions);
1182+
1183+
t.is(infoLogStub.callCount, 0);
1184+
});

0 commit comments

Comments
 (0)