Generated dist
This commit is contained in:
+23
-9
@@ -36054,12 +36054,16 @@ class ComponentDetection {
|
|||||||
static getManifestsFromResults() {
|
static getManifestsFromResults() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
core.info("Getting manifests from results");
|
core.info("Getting manifests from results");
|
||||||
|
const results = yield fs_1.default.readFileSync(this.outputPath, 'utf8');
|
||||||
|
var json = JSON.parse(results);
|
||||||
|
return this.processComponentsToManifests(json.componentsFound);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
static processComponentsToManifests(componentsFound) {
|
||||||
// Parse the result file and add the packages to the package cache
|
// Parse the result file and add the packages to the package cache
|
||||||
const packageCache = new dependency_submission_toolkit_1.PackageCache();
|
const packageCache = new dependency_submission_toolkit_1.PackageCache();
|
||||||
const packages = [];
|
const packages = [];
|
||||||
const results = yield fs_1.default.readFileSync(this.outputPath, 'utf8');
|
componentsFound.forEach((component) => __awaiter(this, void 0, void 0, function* () {
|
||||||
var json = JSON.parse(results);
|
|
||||||
json.componentsFound.forEach((component) => __awaiter(this, void 0, void 0, function* () {
|
|
||||||
// Skip components without packageUrl
|
// Skip components without packageUrl
|
||||||
if (!component.component.packageUrl) {
|
if (!component.component.packageUrl) {
|
||||||
core.debug(`Skipping component detected without packageUrl: ${JSON.stringify({
|
core.debug(`Skipping component detected without packageUrl: ${JSON.stringify({
|
||||||
@@ -36091,6 +36095,7 @@ class ComponentDetection {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const referrerUrl = ComponentDetection.makePackageUrl(referrer.packageUrl);
|
const referrerUrl = ComponentDetection.makePackageUrl(referrer.packageUrl);
|
||||||
|
referrer.packageUrlString = referrerUrl;
|
||||||
// Skip if the generated packageUrl is empty
|
// Skip if the generated packageUrl is empty
|
||||||
if (!referrerUrl) {
|
if (!referrerUrl) {
|
||||||
core.debug(`Skipping referrer with invalid packageUrl for component: ${pkg.id}`);
|
core.debug(`Skipping referrer with invalid packageUrl for component: ${pkg.id}`);
|
||||||
@@ -36110,22 +36115,30 @@ class ComponentDetection {
|
|||||||
// Create manifests
|
// Create manifests
|
||||||
const manifests = [];
|
const manifests = [];
|
||||||
// Check the locationsFoundAt for every package and add each as a manifest
|
// Check the locationsFoundAt for every package and add each as a manifest
|
||||||
packages.forEach((pkg) => __awaiter(this, void 0, void 0, function* () {
|
this.addPackagesToManifests(packages, manifests);
|
||||||
pkg.locationsFoundAt.forEach((location) => __awaiter(this, void 0, void 0, function* () {
|
return manifests;
|
||||||
|
}
|
||||||
|
static addPackagesToManifests(packages, manifests) {
|
||||||
|
packages.forEach((pkg) => {
|
||||||
|
pkg.locationsFoundAt.forEach((location) => {
|
||||||
var _a, _b;
|
var _a, _b;
|
||||||
if (!manifests.find((manifest) => manifest.name == location)) {
|
if (!manifests.find((manifest) => manifest.name == location)) {
|
||||||
const manifest = new dependency_submission_toolkit_1.Manifest(location, location);
|
const manifest = new dependency_submission_toolkit_1.Manifest(location, location);
|
||||||
manifests.push(manifest);
|
manifests.push(manifest);
|
||||||
}
|
}
|
||||||
if (pkg.topLevelReferrers.length == 0) {
|
// Filter out self-references from topLevelReferrers
|
||||||
|
const nonSelfReferrers = pkg.topLevelReferrers.filter((referrer) => {
|
||||||
|
if (!referrer.packageUrlString)
|
||||||
|
return false;
|
||||||
|
return referrer.packageUrlString !== pkg.packageUrlString;
|
||||||
|
});
|
||||||
|
if (nonSelfReferrers.length == 0) {
|
||||||
(_a = manifests.find((manifest) => manifest.name == location)) === null || _a === void 0 ? void 0 : _a.addDirectDependency(pkg, ComponentDetection.getDependencyScope(pkg));
|
(_a = manifests.find((manifest) => manifest.name == location)) === null || _a === void 0 ? void 0 : _a.addDirectDependency(pkg, ComponentDetection.getDependencyScope(pkg));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
(_b = manifests.find((manifest) => manifest.name == location)) === null || _b === void 0 ? void 0 : _b.addIndirectDependency(pkg, ComponentDetection.getDependencyScope(pkg));
|
(_b = manifests.find((manifest) => manifest.name == location)) === null || _b === void 0 ? void 0 : _b.addIndirectDependency(pkg, ComponentDetection.getDependencyScope(pkg));
|
||||||
}
|
}
|
||||||
}));
|
});
|
||||||
}));
|
|
||||||
return manifests;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
static getDependencyScope(pkg) {
|
static getDependencyScope(pkg) {
|
||||||
@@ -36216,6 +36229,7 @@ class ComponentDetectionPackage extends dependency_submission_toolkit_1.Package
|
|||||||
this.locationsFoundAt = locationsFoundAt;
|
this.locationsFoundAt = locationsFoundAt;
|
||||||
this.containerDetailIds = containerDetailIds;
|
this.containerDetailIds = containerDetailIds;
|
||||||
this.containerLayerIds = containerLayerIds;
|
this.containerLayerIds = containerLayerIds;
|
||||||
|
this.packageUrlString = packageUrl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user