@@ -18,7 +18,7 @@ import { unmockedModulePathPatterns } from './jest.config'
|
|||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|
||||||
export default class ComponentDetection {
|
export default class ComponentDetection {
|
||||||
public static componentDetectionPath = './component-detection';
|
public static componentDetectionPath = process.platform === "win32" ? './component-detection.exe' : './component-detection';
|
||||||
public static outputPath = './output.json';
|
public static outputPath = './output.json';
|
||||||
|
|
||||||
// This is the default entry point for this class.
|
// This is the default entry point for this class.
|
||||||
@@ -30,14 +30,14 @@ export default class ComponentDetection {
|
|||||||
// Get the latest release from the component-detection repo, download the tarball, and extract it
|
// Get the latest release from the component-detection repo, download the tarball, and extract it
|
||||||
public static async downloadLatestRelease() {
|
public static async downloadLatestRelease() {
|
||||||
try {
|
try {
|
||||||
core.debug("Downloading latest release");
|
core.debug(`Downloading latest release for ${process.platform}`);
|
||||||
const downloadURL = await this.getLatestReleaseURL();
|
const downloadURL = await this.getLatestReleaseURL();
|
||||||
const blob = await (await fetch(new URL(downloadURL))).blob();
|
const blob = await (await fetch(new URL(downloadURL))).blob();
|
||||||
const arrayBuffer = await blob.arrayBuffer();
|
const arrayBuffer = await blob.arrayBuffer();
|
||||||
const buffer = Buffer.from(arrayBuffer);
|
const buffer = Buffer.from(arrayBuffer);
|
||||||
|
|
||||||
// Write the blob to a file
|
// Write the blob to a file
|
||||||
core.debug("Writing binary to file");
|
core.debug(`Writing binary to file ${this.componentDetectionPath}`);
|
||||||
await fs.writeFileSync(this.componentDetectionPath, buffer, { mode: 0o777, flag: 'w' });
|
await fs.writeFileSync(this.componentDetectionPath, buffer, { mode: 0o777, flag: 'w' });
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
core.error(error);
|
core.error(error);
|
||||||
@@ -108,7 +108,8 @@ export default class ComponentDetection {
|
|||||||
if (pkg.topLevelReferrers.length == 0) {
|
if (pkg.topLevelReferrers.length == 0) {
|
||||||
manifests.find((manifest: Manifest) => manifest.name == location)?.addDirectDependency(pkg, ComponentDetection.getDependencyScope(pkg));
|
manifests.find((manifest: Manifest) => manifest.name == location)?.addDirectDependency(pkg, ComponentDetection.getDependencyScope(pkg));
|
||||||
} else {
|
} else {
|
||||||
manifests.find((manifest: Manifest) => manifest.name == location)?.addIndirectDependency(pkg, ComponentDetection.getDependencyScope(pkg)); }
|
manifests.find((manifest: Manifest) => manifest.name == location)?.addIndirectDependency(pkg, ComponentDetection.getDependencyScope(pkg));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return manifests;
|
return manifests;
|
||||||
@@ -144,8 +145,9 @@ export default class ComponentDetection {
|
|||||||
});
|
});
|
||||||
|
|
||||||
var downloadURL: string = "";
|
var downloadURL: string = "";
|
||||||
|
const assetName = process.platform === "win32" ? "component-detection-win-x64.exe" : "component-detection-linux-x64";
|
||||||
latestRelease.data.assets.forEach((asset: any) => {
|
latestRelease.data.assets.forEach((asset: any) => {
|
||||||
if (asset.name === "component-detection-linux-x64") {
|
if (asset.name === assetName) {
|
||||||
downloadURL = asset.browser_download_url;
|
downloadURL = asset.browser_download_url;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user