Skip to content

Commit

Permalink
Handling sub-components of the root component the same as all other c…
Browse files Browse the repository at this point in the history
…omponents.

Signed-off-by: Roland Asmann <[email protected]>
  • Loading branch information
malice00 committed Sep 10, 2024
1 parent 67732da commit 6ea244b
Showing 1 changed file with 1 addition and 35 deletions.
36 changes: 1 addition & 35 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -557,41 +557,7 @@ function addMetadata(parentComponent = {}, options = {}, context = {}) {
}
}
if (parentComponent?.components) {
const parentFullName = componentToSimpleFullName(parentComponent);
const subComponents = [];
const addedSubComponents = {};
for (const comp of parentComponent.components) {
cleanParentComponent(comp);
if (comp.name && comp.type) {
const fullName = componentToSimpleFullName(comp);
// Fixes #479
// Prevent the parent component from also appearing as a sub-component
// We cannot use purl or bom-ref here since they would not match
// purl - could have application on one side and a different type
// bom-ref could have qualifiers on one side
// Ignore components that have the same name as the parent component but with latest as the version.
// These are default components created based on directory names
if (
fullName !== parentFullName &&
!(
(comp.name === parentComponent.name ||
comp.name === `${parentComponent.name}:latest`) &&
comp.version === "latest"
)
) {
if (!comp["bom-ref"]) {
comp["bom-ref"] = `pkg:${comp.type}/${decodeURIComponent(
fullName,
)}`;
}
if (!addedSubComponents[comp["bom-ref"]]) {
subComponents.push(comp);
addedSubComponents[comp["bom-ref"]] = true;
}
}
}
} // for
parentComponent.components = subComponents;
parentComponent.components = listComponents(options, {}, parentComponent.components);
}
metadata.component = parentComponent;
}
Expand Down

0 comments on commit 6ea244b

Please sign in to comment.