use of com.blackducksoftware.integration.hub.detect.detector.npm.model.NpmRequires in project hub-detect by blackducksoftware.
the class NpmDependencyConverter method convertPackageMapToDependencies.
public List<NpmDependency> convertPackageMapToDependencies(NpmDependency parent, Map<String, PackageLockDependency> packageLockDependencyMap) {
List<NpmDependency> children = new ArrayList<>();
if (packageLockDependencyMap == null || packageLockDependencyMap.size() == 0) {
return children;
}
for (Map.Entry<String, PackageLockDependency> packageEntry : packageLockDependencyMap.entrySet()) {
String packageName = packageEntry.getKey();
PackageLockDependency packageLockDependency = packageEntry.getValue();
NpmDependency dependency = createNpmDependency(packageName, packageLockDependency.version, packageLockDependency.dev);
dependency.setParent(parent);
children.add(dependency);
List<NpmRequires> requires = convertNameVersionMapToRequires(packageLockDependency.requires);
dependency.addAllRequires(requires);
List<NpmDependency> grandChildren = convertPackageMapToDependencies(dependency, packageLockDependency.dependencies);
dependency.addAllDependencies(grandChildren);
}
return children;
}
use of com.blackducksoftware.integration.hub.detect.detector.npm.model.NpmRequires in project hub-detect by blackducksoftware.
the class NpmDependencyConverter method convertLockFile.
public NpmDependency convertLockFile(PackageLock packageLock, Optional<PackageJson> packageJsonOptional) {
NpmDependency root = createNpmDependency(packageLock.name, packageLock.version, false);
if (packageLock.dependencies != null) {
List<NpmDependency> children = convertPackageMapToDependencies(root, packageLock.dependencies);
root.addAllDependencies(children);
}
if (packageJsonOptional.isPresent()) {
PackageJson packageJson = packageJsonOptional.get();
if (packageJson.dependencies != null) {
List<NpmRequires> rootRequires = convertNameVersionMapToRequires(packageJson.dependencies);
root.addAllRequires(rootRequires);
}
if (packageJson.devDependencies != null) {
List<NpmRequires> rootDevRequires = convertNameVersionMapToRequires(packageJson.devDependencies);
root.addAllRequires(rootDevRequires);
}
} else {
if (packageLock.dependencies != null) {
List<NpmRequires> requires = packageLock.dependencies.entrySet().stream().map(entry -> new NpmRequires(entry.getKey(), entry.getValue().version)).collect(Collectors.toList());
root.addAllRequires(requires);
}
}
return root;
}
Aggregations