Search in sources :

Example 1 with PnpmYamlTransformer

use of com.synopsys.integration.detectable.detectables.pnpm.lockfile.process.PnpmYamlTransformer in project synopsys-detect by blackducksoftware.

the class DetectableFactory method createPnpmLockDetectable.

public PnpmLockDetectable createPnpmLockDetectable(DetectableEnvironment environment, PnpmLockOptions pnpmLockOptions) {
    PnpmYamlTransformer pnpmYamlTransformer = new PnpmYamlTransformer(pnpmLockOptions.getDependencyTypeFilter());
    PnpmLockYamlParser pnpmLockYamlParser = new PnpmLockYamlParser(pnpmYamlTransformer);
    PnpmLockExtractor pnpmLockExtractor = new PnpmLockExtractor(pnpmLockYamlParser, packageJsonFiles());
    return new PnpmLockDetectable(environment, fileFinder, pnpmLockExtractor, packageJsonFiles());
}
Also used : PnpmLockDetectable(com.synopsys.integration.detectable.detectables.pnpm.lockfile.PnpmLockDetectable) PnpmYamlTransformer(com.synopsys.integration.detectable.detectables.pnpm.lockfile.process.PnpmYamlTransformer) PnpmLockYamlParser(com.synopsys.integration.detectable.detectables.pnpm.lockfile.process.PnpmLockYamlParser) PnpmLockExtractor(com.synopsys.integration.detectable.detectables.pnpm.lockfile.PnpmLockExtractor)

Example 2 with PnpmYamlTransformer

use of com.synopsys.integration.detectable.detectables.pnpm.lockfile.process.PnpmYamlTransformer in project synopsys-detect by blackducksoftware.

the class PnpmLockExtractorTest method testNoFailureOnNullPackageJson.

@Test
public void testNoFailureOnNullPackageJson() {
    PackageJsonFiles packageJsonFiles = new PackageJsonFiles(new PackageJsonReader(new Gson()));
    EnumListFilter<PnpmDependencyType> dependencyTypeFilter = EnumListFilter.fromExcluded(PnpmDependencyType.APP);
    PnpmLockExtractor extractor = new PnpmLockExtractor(new PnpmLockYamlParser(new PnpmYamlTransformer(dependencyTypeFilter)), packageJsonFiles);
    File pnpmLockYaml = FunctionalTestFiles.asFile("/pnpm/pnpm-lock.yaml");
    Extraction extraction = extractor.extract(pnpmLockYaml, null, new PnpmLinkedPackageResolver(new File(""), packageJsonFiles));
    Assertions.assertTrue(extraction.isSuccess());
}
Also used : PnpmLinkedPackageResolver(com.synopsys.integration.detectable.detectables.pnpm.lockfile.process.PnpmLinkedPackageResolver) PackageJsonReader(com.synopsys.integration.detectable.detectables.yarn.packagejson.PackageJsonReader) PnpmYamlTransformer(com.synopsys.integration.detectable.detectables.pnpm.lockfile.process.PnpmYamlTransformer) PnpmLockYamlParser(com.synopsys.integration.detectable.detectables.pnpm.lockfile.process.PnpmLockYamlParser) Gson(com.google.gson.Gson) Extraction(com.synopsys.integration.detectable.extraction.Extraction) PackageJsonFiles(com.synopsys.integration.detectable.detectables.yarn.packagejson.PackageJsonFiles) File(java.io.File) PnpmDependencyType(com.synopsys.integration.detectable.detectables.pnpm.lockfile.model.PnpmDependencyType) PnpmLockExtractor(com.synopsys.integration.detectable.detectables.pnpm.lockfile.PnpmLockExtractor) Test(org.junit.jupiter.api.Test)

Example 3 with PnpmYamlTransformer

use of com.synopsys.integration.detectable.detectables.pnpm.lockfile.process.PnpmYamlTransformer in project synopsys-detect by blackducksoftware.

the class PnpmYamlTransformerTest method testGenerateCodeLocation.

@Test
public void testGenerateCodeLocation() throws IntegrationException {
    PnpmLockYaml pnpmLockYaml = createPnpmLockYaml();
    PnpmYamlTransformer transformer = createTransformer();
    CodeLocation codeLocation = transformer.generateCodeLocation(pnpmLockYamlFile, pnpmLockYaml, projectNameVersion, linkedPackageResolver);
    assertTrue(codeLocation.getExternalId().isPresent(), "Expected the codelocation to produce an ExternalId.");
    assertEquals("name", codeLocation.getExternalId().get().getName());
    assertEquals("version", codeLocation.getExternalId().get().getVersion());
    DependencyGraph dependencyGraph = codeLocation.getDependencyGraph();
    NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.NPMJS, dependencyGraph);
    graphAssert.hasRootSize(4);
    graphAssert.hasRootDependency("dep", "1.0.0");
    graphAssert.hasRootDependency("devDep", "2.0.0");
    graphAssert.hasRootDependency("optDep", "3.0.0");
    graphAssert.hasParentChildRelationship("dep", "1.0.0", "transitive", "1.1.0");
}
Also used : CodeLocation(com.synopsys.integration.detectable.detectable.codelocation.CodeLocation) PnpmYamlTransformer(com.synopsys.integration.detectable.detectables.pnpm.lockfile.process.PnpmYamlTransformer) NameVersionGraphAssert(com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert) PnpmLockYaml(com.synopsys.integration.detectable.detectables.pnpm.lockfile.model.PnpmLockYaml) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) Test(org.junit.jupiter.api.Test)

Example 4 with PnpmYamlTransformer

use of com.synopsys.integration.detectable.detectables.pnpm.lockfile.process.PnpmYamlTransformer in project synopsys-detect by blackducksoftware.

the class PnpmYamlTransformerTest method testNoFailureOnNullNameVersion.

@Test
public void testNoFailureOnNullNameVersion() throws IntegrationException {
    PnpmLockYaml pnpmLockYaml = createPnpmLockYaml();
    PnpmYamlTransformer transformer = createTransformer();
    transformer.generateCodeLocation(pnpmLockYamlFile, pnpmLockYaml, null, linkedPackageResolver);
}
Also used : PnpmYamlTransformer(com.synopsys.integration.detectable.detectables.pnpm.lockfile.process.PnpmYamlTransformer) PnpmLockYaml(com.synopsys.integration.detectable.detectables.pnpm.lockfile.model.PnpmLockYaml) Test(org.junit.jupiter.api.Test)

Example 5 with PnpmYamlTransformer

use of com.synopsys.integration.detectable.detectables.pnpm.lockfile.process.PnpmYamlTransformer in project synopsys-detect by blackducksoftware.

the class PnpmYamlTransformerTest method testExcludeOptionalDependencies.

@Test
public void testExcludeOptionalDependencies() throws IntegrationException {
    PnpmLockYaml pnpmLockYaml = createPnpmLockYaml();
    PnpmYamlTransformer transformer = createTransformer(PnpmDependencyType.OPTIONAL);
    DependencyGraph dependencyGraph = transformer.generateCodeLocation(pnpmLockYamlFile, pnpmLockYaml, projectNameVersion, linkedPackageResolver).getDependencyGraph();
    NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.NPMJS, dependencyGraph);
    graphAssert.hasRootSize(3);
    graphAssert.hasNoDependency("optDep", "3.0.0");
}
Also used : PnpmYamlTransformer(com.synopsys.integration.detectable.detectables.pnpm.lockfile.process.PnpmYamlTransformer) NameVersionGraphAssert(com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert) PnpmLockYaml(com.synopsys.integration.detectable.detectables.pnpm.lockfile.model.PnpmLockYaml) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) Test(org.junit.jupiter.api.Test)

Aggregations

PnpmYamlTransformer (com.synopsys.integration.detectable.detectables.pnpm.lockfile.process.PnpmYamlTransformer)10 Test (org.junit.jupiter.api.Test)9 PnpmLockYaml (com.synopsys.integration.detectable.detectables.pnpm.lockfile.model.PnpmLockYaml)7 DependencyGraph (com.synopsys.integration.bdio.graph.DependencyGraph)5 NameVersionGraphAssert (com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert)5 PnpmLockYamlParser (com.synopsys.integration.detectable.detectables.pnpm.lockfile.process.PnpmLockYamlParser)3 Gson (com.google.gson.Gson)2 CodeLocation (com.synopsys.integration.detectable.detectable.codelocation.CodeLocation)2 PnpmLockExtractor (com.synopsys.integration.detectable.detectables.pnpm.lockfile.PnpmLockExtractor)2 PnpmDependencyType (com.synopsys.integration.detectable.detectables.pnpm.lockfile.model.PnpmDependencyType)2 PnpmLinkedPackageResolver (com.synopsys.integration.detectable.detectables.pnpm.lockfile.process.PnpmLinkedPackageResolver)2 PackageJsonFiles (com.synopsys.integration.detectable.detectables.yarn.packagejson.PackageJsonFiles)2 PackageJsonReader (com.synopsys.integration.detectable.detectables.yarn.packagejson.PackageJsonReader)2 File (java.io.File)2 ExternalId (com.synopsys.integration.bdio.model.externalid.ExternalId)1 EnumListFilter (com.synopsys.integration.detectable.detectable.util.EnumListFilter)1 PnpmLockDetectable (com.synopsys.integration.detectable.detectables.pnpm.lockfile.PnpmLockDetectable)1 Extraction (com.synopsys.integration.detectable.extraction.Extraction)1 FunctionalTestFiles (com.synopsys.integration.detectable.util.FunctionalTestFiles)1 IntegrationException (com.synopsys.integration.exception.IntegrationException)1