use of com.synopsys.integration.detectable.detectables.npm.lockfile.model.NpmProject 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);
}
use of com.synopsys.integration.detectable.detectables.npm.lockfile.model.NpmProject in project synopsys-detect by blackducksoftware.
the class NpmWithoutRequiresExcludesTest method testDevDependencyExcluded.
@Test
public void testDevDependencyExcluded() {
PackageLock packageLock = new PackageLock();
packageLock.dependencies = new HashMap<>();
List<NpmDependency> resolvedDependencies = new ArrayList<>();
resolvedDependencies.add(new NpmDependency("example", "1.0.0", true, true));
NpmProject npmProject = new NpmProject(Strings.EMPTY, Strings.EMPTY, Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), resolvedDependencies);
NpmLockfileGraphTransformer graphTransformer = new NpmLockfileGraphTransformer(EnumListFilter.fromExcluded(NpmDependencyType.DEV, NpmDependencyType.PEER));
DependencyGraph graph = graphTransformer.transform(packageLock, npmProject, Collections.emptyList());
GraphAssert graphAssert = new GraphAssert(Forge.NPMJS, graph);
graphAssert.hasRootSize(0);
}
Aggregations