# Dependency tree

    library(risk.assessr)

    options(repos = "http://cran.us.r-project.org")

## Dependencies Tree

The `risk.assessr` package provides a set of functions to get dependencies and visualize dependency trees, allowing users to analyze package dependencies and identify potential conflict.

Fetch your primary dependencies from your package:

    download_and_parse_dependencies("stringr")
    #>                package    type parent_package
    #> 1                  cli Imports        stringr
    #> 2      glue (>= 1.6.1) Imports        stringr
    #> 3 lifecycle (>= 1.0.3) Imports        stringr
    #> 4             magrittr Imports        stringr
    #> 5    rlang\n(>= 1.0.0) Imports        stringr
    #> 6   stringi (>= 1.5.3) Imports        stringr
    #> 7     vctrs (>= 0.4.0) Imports        stringr

Create and visualize your dependency tree:

    dep_data <- fetch_all_dependencies("stringr")
    #> Building dependency tree for: stringr
    #> Dependency tree in progress for stringr package
    #> Dependency tree in progress for cli package
    #> Finished building for cli
    #> Dependency tree in progress for glue package
    #> Finished building for glue
    #> Dependency tree in progress for lifecycle package
    #> Dependency tree in progress for cli package
    #> Finished building for cli
    #> Dependency tree in progress for glue package
    #> Finished building for glue
    #> Dependency tree in progress for rlang package
    #> Finished building for rlang
    #> Finished building for lifecycle
    #> Dependency tree in progress for magrittr package
    #> Finished building for magrittr
    #> Dependency tree in progress for rlang package
    #> Finished building for rlang
    #> Dependency tree in progress for stringi package
    #> Finished building for stringi
    #> Dependency tree in progress for vctrs package
    #> Dependency tree in progress for cli package
    #> Finished building for cli
    #> Dependency tree in progress for glue package
    #> Finished building for glue
    #> Dependency tree in progress for lifecycle package
    #> Dependency tree in progress for cli package
    #> Dependency tree in progress for glue package
    #> Dependency tree in progress for rlang package
    #> Finished building for lifecycle
    #> Dependency tree in progress for rlang package
    #> Finished building for rlang
    #> Finished building for vctrs
    #> Finished building for stringr

    dep_data
    #> $stringr
    #> $stringr$version
    #> [1] "1.5.1"
    #>
    #> $stringr$cli
    #> $stringr$cli$version
    #> [1] "3.6.5"
    #>
    #> $stringr$cli$utils
    #> [1] "base"
    #>
    #>
    #> $stringr$glue
    #> $stringr$glue$version
    #> [1] "1.8.0"
    #>
    #> $stringr$glue$methods
    #> [1] "base"
    #>
    #>
    #> $stringr$lifecycle
    #> $stringr$lifecycle$version
    #> [1] "1.0.4"
    #>
    #> $stringr$lifecycle$cli
    #> $stringr$lifecycle$cli$version
    #> [1] "3.6.5"
    #>
    #> $stringr$lifecycle$cli$utils
    #> [1] "base"
    #>
    #>
    #> $stringr$lifecycle$glue
    #> $stringr$lifecycle$glue$version
    #> [1] "1.8.0"
    #>
    #> $stringr$lifecycle$glue$methods
    #> [1] "base"
    #>
    #>
    #> $stringr$lifecycle$rlang
    #> $stringr$lifecycle$rlang$version
    #> [1] "1.1.6"
    #>
    #> $stringr$lifecycle$rlang$utils
    #> [1] "base"
    #>
    #>
    #>
    #> $stringr$magrittr
    #> $stringr$magrittr$version
    #> [1] "2.0.4"
    #>
    #>
    #> $stringr$rlang
    #> $stringr$rlang$version
    #> [1] "1.1.6"
    #>
    #> $stringr$rlang$utils
    #> [1] "base"
    #>
    #>
    #> $stringr$stringi
    #> $stringr$stringi$version
    #> [1] "1.8.7"
    #>
    #> $stringr$stringi$tools
    #> [1] "base"
    #>
    #> $stringr$stringi$utils
    #> [1] "base"
    #>
    #> $stringr$stringi$stats
    #> [1] "base"
    #>
    #>
    #> $stringr$vctrs
    #> $stringr$vctrs$version
    #> [1] "0.6.5"
    #>
    #> $stringr$vctrs$cli
    #> $stringr$vctrs$cli$version
    #> [1] "3.6.5"
    #>
    #> $stringr$vctrs$cli$utils
    #> [1] "base"
    #>
    #>
    #> $stringr$vctrs$glue
    #> $stringr$vctrs$glue$version
    #> [1] "1.8.0"
    #>
    #> $stringr$vctrs$glue$methods
    #> [1] "base"
    #>
    #>
    #> $stringr$vctrs$lifecycle
    #> $stringr$vctrs$lifecycle$version
    #> [1] "1.0.4"
    #>
    #>
    #> $stringr$vctrs$rlang
    #> $stringr$vctrs$rlang$version
    #> [1] "1.1.6"
    #>
    #> $stringr$vctrs$rlang$utils
    #> [1] "base"

    print_tree(dep_data)
    #> └── stringr (v1.5.1)
    #>     ├── cli (v3.6.5)
    #>     │   └── utils (base)
    #>     ├── glue (v1.8.0)
    #>     │   └── methods (base)
    #>     ├── lifecycle (v1.0.4)
    #>     │   ├── cli (v3.6.5)
    #>     │   │   └── utils (base)
    #>     │   ├── glue (v1.8.0)
    #>     │   │   └── methods (base)
    #>     │   └── rlang (v1.1.6)
    #>     │       └── utils (base)
    #>     ├── magrittr (v2.0.4)
    #>     ├── rlang (v1.1.6)
    #>     │   └── utils (base)
    #>     ├── stringi (v1.8.7)
    #>     │   ├── tools (base)
    #>     │   ├── utils (base)
    #>     │   └── stats (base)
    #>     └── vctrs (v0.6.5)
    #>         ├── cli (v3.6.5)
    #>         │   └── utils (base)
    #>         ├── glue (v1.8.0)
    #>         │   └── methods (base)
    #>         ├── lifecycle (v1.0.4)
    #>         └── rlang (v1.1.6)
    #>             └── utils (base)

Check for conflicting dependency versions:

    detect_version_conflicts(dep_data)
    #> NULL