Search in sources :

Example 1 with NpmDependencyConverter

use of com.synopsys.integration.detectable.detectables.npm.lockfile.NpmDependencyConverter in project synopsys-detect by blackducksoftware.

the class NpmLockfilePackager method parseAndTransform.

public NpmPackagerResult parseAndTransform(@Nullable String packageJsonText, String lockFileText, List<NameVersion> externalDependencies) {
    PackageJson packageJson = Optional.ofNullable(packageJsonText).map(content -> gson.fromJson(content, PackageJson.class)).orElse(null);
    PackageLock packageLock = gson.fromJson(lockFileText, PackageLock.class);
    NpmDependencyConverter dependencyConverter = new NpmDependencyConverter(externalIdFactory);
    NpmProject project = dependencyConverter.convertLockFile(packageLock, packageJson);
    DependencyGraph dependencyGraph = graphTransformer.transform(packageLock, project, externalDependencies);
    ExternalId projectId = projectIdTransformer.transform(packageJson, packageLock);
    CodeLocation codeLocation = new CodeLocation(dependencyGraph, projectId);
    return new NpmPackagerResult(projectId.getName(), projectId.getVersion(), codeLocation);
}
Also used : DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) ArrayList(java.util.ArrayList) PackageJson(com.synopsys.integration.detectable.detectables.npm.packagejson.model.PackageJson) Nullable(org.jetbrains.annotations.Nullable) NameVersion(com.synopsys.integration.util.NameVersion) List(java.util.List) CodeLocation(com.synopsys.integration.detectable.detectable.codelocation.CodeLocation) NpmDependencyConverter(com.synopsys.integration.detectable.detectables.npm.lockfile.NpmDependencyConverter) Gson(com.google.gson.Gson) NpmProject(com.synopsys.integration.detectable.detectables.npm.lockfile.model.NpmProject) NpmPackagerResult(com.synopsys.integration.detectable.detectables.npm.lockfile.result.NpmPackagerResult) Optional(java.util.Optional) ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) PackageLock(com.synopsys.integration.detectable.detectables.npm.lockfile.model.PackageLock) PackageLock(com.synopsys.integration.detectable.detectables.npm.lockfile.model.PackageLock) CodeLocation(com.synopsys.integration.detectable.detectable.codelocation.CodeLocation) NpmProject(com.synopsys.integration.detectable.detectables.npm.lockfile.model.NpmProject) ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) NpmDependencyConverter(com.synopsys.integration.detectable.detectables.npm.lockfile.NpmDependencyConverter) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) PackageJson(com.synopsys.integration.detectable.detectables.npm.packagejson.model.PackageJson) NpmPackagerResult(com.synopsys.integration.detectable.detectables.npm.lockfile.result.NpmPackagerResult)

Aggregations

Gson (com.google.gson.Gson)1 DependencyGraph (com.synopsys.integration.bdio.graph.DependencyGraph)1 ExternalId (com.synopsys.integration.bdio.model.externalid.ExternalId)1 ExternalIdFactory (com.synopsys.integration.bdio.model.externalid.ExternalIdFactory)1 CodeLocation (com.synopsys.integration.detectable.detectable.codelocation.CodeLocation)1 NpmDependencyConverter (com.synopsys.integration.detectable.detectables.npm.lockfile.NpmDependencyConverter)1 NpmProject (com.synopsys.integration.detectable.detectables.npm.lockfile.model.NpmProject)1 PackageLock (com.synopsys.integration.detectable.detectables.npm.lockfile.model.PackageLock)1 NpmPackagerResult (com.synopsys.integration.detectable.detectables.npm.lockfile.result.NpmPackagerResult)1 PackageJson (com.synopsys.integration.detectable.detectables.npm.packagejson.model.PackageJson)1 NameVersion (com.synopsys.integration.util.NameVersion)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Optional (java.util.Optional)1 Nullable (org.jetbrains.annotations.Nullable)1