use of com.synopsys.integration.detectable.detectables.lerna.LernaPackageDiscoverer in project synopsys-detect by blackducksoftware.
the class DetectableFactory method createLernaDetectable.
public LernaDetectable createLernaDetectable(DetectableEnvironment environment, LernaResolver lernaResolver, NpmLockfileOptions npmLockfileOptions, LernaOptions lernaOptions, YarnLockOptions yarnLockOptions) {
LernaPackageDiscoverer lernaPackageDiscoverer = new LernaPackageDiscoverer(executableRunner, gson, lernaOptions.getExcludedPackages(), lernaOptions.getIncludedPackages());
LernaPackager lernaPackager = new LernaPackager(fileFinder, packageJsonReader(), yarnLockParser(), npmLockfilePackager(npmLockfileOptions), yarnPackager(yarnLockOptions), lernaOptions.getLernaPackageTypeFilter());
LernaExtractor lernaExtractor = new LernaExtractor(lernaPackageDiscoverer, lernaPackager);
return new LernaDetectable(environment, fileFinder, lernaResolver, lernaExtractor);
}
use of com.synopsys.integration.detectable.detectables.lerna.LernaPackageDiscoverer in project synopsys-detect by blackducksoftware.
the class LernaPackageDiscovererTest method discoverLernaPackages.
@Test
void discoverLernaPackages() throws ExecutableRunnerException {
File workingDirectory = new File("workingDir");
ExecutableTarget lernaExecutable = ExecutableTarget.forCommand("lerna");
DetectableExecutableRunner executableRunner = Mockito.mock(DetectableExecutableRunner.class);
Mockito.when(executableRunner.execute(Mockito.any(Executable.class))).thenReturn(new ExecutableOutput(0, String.join(System.lineSeparator(), "[", " {", " \"name\": \"@lerna/packageA\",", " \"version\": \"1.2.3\",", " \"private\": false,", " \"location\": \"/source/packages/packageA\"", " },", " {", " \"name\": \"@lerna/packageB\",", " \"version\": \"3.2.1\",", " \"private\": true,", " \"location\": \"/source/packages/packageB\"", " },", " {", " \"name\": \"@lerna/packageC\",", " \"version\": \"1.1.1\",", " \"private\": true,", " \"location\": \"/source/packages/packageC\"", " }", "]"), ""));
Gson gson = new GsonBuilder().setPrettyPrinting().create();
LernaPackageDiscoverer lernaPackageDiscoverer = new LernaPackageDiscoverer(executableRunner, gson, Collections.singletonList("@lerna/packageC"), new LinkedList<>());
List<LernaPackage> lernaPackages = lernaPackageDiscoverer.discoverLernaPackages(workingDirectory, lernaExecutable);
Assertions.assertEquals(2, lernaPackages.size(), "Expected to find two Lerna packages.");
LernaPackage lernaPackageA = lernaPackages.get(0);
Assertions.assertEquals("@lerna/packageA", lernaPackageA.getName());
Assertions.assertEquals("1.2.3", lernaPackageA.getVersion());
Assertions.assertFalse(lernaPackageA.isPrivate());
Assertions.assertEquals("/source/packages/packageA", lernaPackageA.getLocation());
LernaPackage lernaPackageB = lernaPackages.get(1);
Assertions.assertEquals("@lerna/packageB", lernaPackageB.getName());
Assertions.assertEquals("3.2.1", lernaPackageB.getVersion());
Assertions.assertTrue(lernaPackageB.isPrivate());
Assertions.assertEquals("/source/packages/packageB", lernaPackageB.getLocation());
}
Aggregations