Skip to content

Commit 3495b4b

Browse files
committed
Debugging failure
1 parent 5f373a4 commit 3495b4b

File tree

4 files changed

+82
-91
lines changed

4 files changed

+82
-91
lines changed

componentDetection.ts

Lines changed: 40 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -57,57 +57,52 @@ export default class ComponentDetection {
5757

5858
private static async getManifestsFromResults(): Promise<Manifest[]| undefined> {
5959
core.info("Getting manifests from results");
60-
try {
61-
// Parse the result file and add the packages to the package cache
62-
const packageCache = new PackageCache();
63-
const packages: Array<ComponentDetectionPackage>= [];
64-
65-
const results = await fs.readFileSync(this.outputPath, 'utf8');
60+
// Parse the result file and add the packages to the package cache
61+
const packageCache = new PackageCache();
62+
const packages: Array<ComponentDetectionPackage>= [];
63+
64+
const results = await fs.readFileSync(this.outputPath, 'utf8');
65+
66+
var json: any = JSON.parse(results);
67+
json.componentsFound.forEach(async (component: any) => {
68+
const packageUrl = ComponentDetection.makePackageUrl(component.component.packageUrl);
6669

67-
var json: any = JSON.parse(results);
68-
json.componentsFound.forEach(async (component: any) => {
69-
const packageUrl = ComponentDetection.makePackageUrl(component.component.packageUrl);
70-
71-
if (!packageCache.hasPackage(packageUrl)) {
72-
const pkg = new ComponentDetectionPackage(packageUrl, component.component.id,
73-
component.isDevelopmentDependency,component.topLevelReferrers,component.locationsFoundAt, component.containerDetailIds, component.containerLayerIds);
74-
packageCache.addPackage(pkg);
75-
packages.push(pkg);
70+
if (!packageCache.hasPackage(packageUrl)) {
71+
const pkg = new ComponentDetectionPackage(packageUrl, component.component.id,
72+
component.isDevelopmentDependency,component.topLevelReferrers,component.locationsFoundAt, component.containerDetailIds, component.containerLayerIds);
73+
packageCache.addPackage(pkg);
74+
packages.push(pkg);
75+
}
76+
});
77+
78+
// Set the transitive dependencies
79+
core.debug("Sorting out transitive dependencies");
80+
packages.forEach(async (pkg: ComponentDetectionPackage) => {
81+
pkg.topLevelReferrers.forEach(async (referrer: any) => {
82+
const referrerPackage = packageCache.lookupPackage(ComponentDetection.makePackageUrl(referrer.packageUrl));
83+
if (referrerPackage) {
84+
referrerPackage.dependsOn(pkg);
7685
}
7786
});
87+
});
7888

79-
// Set the transitive dependencies
80-
core.debug("Sorting out transitive dependencies");
81-
packages.forEach(async (pkg: ComponentDetectionPackage) => {
82-
pkg.topLevelReferrers.forEach(async (referrer: any) => {
83-
const referrerPackage = packageCache.lookupPackage(ComponentDetection.makePackageUrl(referrer.packageUrl));
84-
if (referrerPackage) {
85-
referrerPackage.dependsOn(pkg);
86-
}
87-
});
88-
});
89+
// Create manifests
90+
const manifests: Array<Manifest> = [];
8991

90-
// Create manifests
91-
const manifests: Array<Manifest> = [];
92-
93-
// Check the locationsFoundAt for every package and add each as a manifest
94-
packages.forEach(async (pkg: ComponentDetectionPackage) => {
95-
pkg.locationsFoundAt.forEach(async (location: any) => {
96-
if (!manifests[location.filePath]) {
97-
const manifest = new Manifest(location.filePath, location.filePath);
98-
manifests.push(manifest);
99-
}
100-
if (pkg.topLevelReferrers.length == 0) {
101-
manifests.find((manifest: Manifest) => manifest.file == location.filePath)?.addDirectDependency(pkg, ComponentDetection.getDependencyScope(pkg));
102-
} else {
103-
manifests.find((manifest: Manifest) => manifest.file == location.filePath)?.addIndirectDependency(pkg, ComponentDetection.getDependencyScope(pkg)); }
104-
});
92+
// Check the locationsFoundAt for every package and add each as a manifest
93+
packages.forEach(async (pkg: ComponentDetectionPackage) => {
94+
pkg.locationsFoundAt.forEach(async (location: any) => {
95+
if (!manifests[location.filePath]) {
96+
const manifest = new Manifest(location.filePath, location.filePath);
97+
manifests.push(manifest);
98+
}
99+
if (pkg.topLevelReferrers.length == 0) {
100+
manifests.find((manifest: Manifest) => manifest.file == location.filePath)?.addDirectDependency(pkg, ComponentDetection.getDependencyScope(pkg));
101+
} else {
102+
manifests.find((manifest: Manifest) => manifest.file == location.filePath)?.addIndirectDependency(pkg, ComponentDetection.getDependencyScope(pkg)); }
105103
});
106-
return manifests;
107-
} catch (error: any) {
108-
core.error(error);
109-
return undefined;
110-
}
104+
});
105+
return manifests;
111106
}
112107

113108
private static getDependencyScope(pkg: ComponentDetectionPackage) {

dist/index.js

Lines changed: 40 additions & 45 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ async function run() {
2626
id: github.context.runId.toString()
2727
});
2828

29+
core.debug(`Manifests: ${manifests}`);
2930
manifests?.forEach(manifest => {
3031
snapshot.addManifest(manifest);
3132
});

0 commit comments

Comments
 (0)