Remove leading slashes from top manifests

This commit is contained in:
Lewis Jones
2025-07-09 12:16:21 +01:00
parent 7d147e8b5f
commit 6d25ae13f5
+9 -6
View File
@@ -153,28 +153,31 @@ export default class ComponentDetection {
private static addPackagesToManifests(packages: Array<ComponentDetectionPackage>, manifests: Array<Manifest>, dependencyGraphs: DependencyGraphs): void { private static addPackagesToManifests(packages: Array<ComponentDetectionPackage>, manifests: Array<Manifest>, dependencyGraphs: DependencyGraphs): void {
packages.forEach((pkg: ComponentDetectionPackage) => { packages.forEach((pkg: ComponentDetectionPackage) => {
pkg.locationsFoundAt.forEach((location: any) => { pkg.locationsFoundAt.forEach((location: any) => {
if (!manifests.find((manifest: Manifest) => manifest.name == location)) { // Use the normalized path (remove leading slash if present)
const manifest = new Manifest(location, location); const normalizedLocation = location.startsWith('/') ? location.substring(1) : location;
if (!manifests.find((manifest: Manifest) => manifest.name == normalizedLocation)) {
const manifest = new Manifest(normalizedLocation, normalizedLocation);
manifests.push(manifest); manifests.push(manifest);
} }
const depGraphEntry = dependencyGraphs[location]; const depGraphEntry = dependencyGraphs[normalizedLocation];
if (!depGraphEntry) { if (!depGraphEntry) {
core.warning(`No dependency graph entry found for manifest location: ${location}`); core.warning(`No dependency graph entry found for manifest location: ${normalizedLocation}`);
return; // Skip this location if not found in dependencyGraphs return; // Skip this location if not found in dependencyGraphs
} }
const directDependencies = depGraphEntry.explicitlyReferencedComponentIds; const directDependencies = depGraphEntry.explicitlyReferencedComponentIds;
if (directDependencies.includes(pkg.id)) { if (directDependencies.includes(pkg.id)) {
manifests manifests
.find((manifest: Manifest) => manifest.name == location) .find((manifest: Manifest) => manifest.name == normalizedLocation)
?.addDirectDependency( ?.addDirectDependency(
pkg, pkg,
ComponentDetection.getDependencyScope(pkg) ComponentDetection.getDependencyScope(pkg)
); );
} else { } else {
manifests manifests
.find((manifest: Manifest) => manifest.name == location) .find((manifest: Manifest) => manifest.name == normalizedLocation)
?.addIndirectDependency( ?.addIndirectDependency(
pkg, pkg,
ComponentDetection.getDependencyScope(pkg) ComponentDetection.getDependencyScope(pkg)