Update tests
This commit is contained in:
@@ -1,13 +1,17 @@
|
||||
import {downloadLatestRelease, getManifestsFromResults, runComponentDetection} from './componentDetection';
|
||||
import ComponentDetection from './componentDetection';
|
||||
import fs from 'fs';
|
||||
|
||||
test('Downloads CLI', async () => {
|
||||
downloadLatestRelease();
|
||||
ComponentDetection.downloadLatestRelease();
|
||||
expect(fs.existsSync(ComponentDetection.componentDetectionPath));
|
||||
});
|
||||
|
||||
test('Runs CLI', async () => {
|
||||
runComponentDetection('./test');
|
||||
ComponentDetection.runComponentDetection('./test');
|
||||
expect(fs.existsSync(ComponentDetection.outputPath));
|
||||
});
|
||||
|
||||
test('Parses CLI output', async () => {
|
||||
getManifestsFromResults();
|
||||
var manifests = await ComponentDetection.getManifestsFromResults();
|
||||
expect(manifests?.length == 2);
|
||||
});
|
||||
@@ -18,8 +18,8 @@ import { unmockedModulePathPatterns } from './jest.config'
|
||||
dotenv.config();
|
||||
|
||||
export default class ComponentDetection {
|
||||
protected static componentDetectionPath = './component-detection';
|
||||
protected static outputPath = './output.json';
|
||||
public static componentDetectionPath = './component-detection';
|
||||
public static outputPath = './output.json';
|
||||
|
||||
// This is the default entry point for this class.
|
||||
static async scanAndGetManifests(path: string): Promise<Manifest[] | undefined> {
|
||||
@@ -28,7 +28,7 @@ export default class ComponentDetection {
|
||||
return await this.getManifestsFromResults();
|
||||
}
|
||||
// Get the latest release from the component-detection repo, download the tarball, and extract it
|
||||
private static async downloadLatestRelease() {
|
||||
public static async downloadLatestRelease() {
|
||||
try {
|
||||
core.debug("Downloading latest release");
|
||||
const downloadURL = await this.getLatestReleaseURL();
|
||||
@@ -45,7 +45,7 @@ export default class ComponentDetection {
|
||||
}
|
||||
|
||||
// Run the component-detection CLI on the path specified
|
||||
private static async runComponentDetection(path: string) {
|
||||
public static async runComponentDetection(path: string) {
|
||||
core.info("Running component-detection");
|
||||
|
||||
try {
|
||||
@@ -64,7 +64,7 @@ export default class ComponentDetection {
|
||||
return parameters;
|
||||
}
|
||||
|
||||
private static async getManifestsFromResults(): Promise<Manifest[]| undefined> {
|
||||
public static async getManifestsFromResults(): Promise<Manifest[]| undefined> {
|
||||
core.info("Getting manifests from results");
|
||||
// Parse the result file and add the packages to the package cache
|
||||
const packageCache = new PackageCache();
|
||||
|
||||
10
dist/componentDetection.d.ts
generated
vendored
10
dist/componentDetection.d.ts
generated
vendored
@@ -1,12 +1,12 @@
|
||||
import { Manifest } from '@github/dependency-submission-toolkit';
|
||||
export default class ComponentDetection {
|
||||
protected static componentDetectionPath: string;
|
||||
protected static outputPath: string;
|
||||
static componentDetectionPath: string;
|
||||
static outputPath: string;
|
||||
static scanAndGetManifests(path: string): Promise<Manifest[] | undefined>;
|
||||
private static downloadLatestRelease;
|
||||
private static runComponentDetection;
|
||||
static downloadLatestRelease(): Promise<void>;
|
||||
static runComponentDetection(path: string): Promise<void>;
|
||||
private static getComponentDetectionParameters;
|
||||
private static getManifestsFromResults;
|
||||
static getManifestsFromResults(): Promise<Manifest[] | undefined>;
|
||||
private static getDependencyScope;
|
||||
private static makePackageUrl;
|
||||
private static getLatestReleaseURL;
|
||||
|
||||
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user