Giter Site home page Giter Site logo

oleksandrkucherenko / dependencies.graphviz Goto Github PK

View Code? Open in Web Editor NEW
2.0 3.0 0.0 806 KB

Gradle Dependencies Logs Parser. Allows building visualization of the dependency graph with limiting scope to a specific "search" string (default search string is: `com.fasterxml.jackson`).

License: MIT License

JavaScript 100.00%
analysis vscode graphviz graphviz-dot gradle visualization jackson jackson-json jackson-json-processor jackson-databind

dependencies.graphviz's Introduction

Visualize Gradle Dependencies

Preview

Preview

Pre-requirements

Clone project. Than install all required tools:

# requirements
#
# Install NVM, latest node
#
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash
nvm install --lts
nvm use --lts
#
# Install DirEnv
#
curl -sfL https://direnv.net/install.sh | bash
#
# Install Yarn
#
curl -s https://raw.githubusercontent.com/tophat/yvm/master/scripts/install.js | node
yvm list-remote
#
# Install GraphViz tool
#
brew install graphviz

Configure direnv properly and than install the project dependencies.

#
# Install all required packages
#
cd dependencies.graphviz
direnv allow
yarn

Usage

# collect project dependencies into file
# cd ~/src/android-project
./gradlew :project:app:dependencies | tee dependencies.log

# extract graph of dependencies from log file (com.fasterxml.jackson)
./index.dependencies.js dependencies.log --dot --simplify | tee jackson.dot

# extract graph of Moshi dependency usage (com.squareup.moshi:moshi)
./index.dependencies.js dependencies.log --dot --simplify --find com.squareup.moshi | tee moshi.dot

# convert graph to image
dot jackson.dot -Tpdf -o jackson.pdf
dot jackson.dot -Tsvg -o jackson.svg
dot jackson.dot -Tpng -o jackson.png

Get Help

./index.dependencies.js --help 

Output:

Usage: index.dependencies.js gradle_dependencies_log

Options:
      --version   Show version number                                  [boolean]
  -f, --find                                  [default: "com.fasterxml.jackson"]
      --help      Show help                                            [boolean]
  -v, --verbose   Publish debug information                            [boolean]
  -d, --dot       Print GraphViz dot graph instead                     [boolean]
  -s, --simplify  Remove version information from dependencies         [boolean]
  -l, --left      force graph building from left-to-right, instead of
                  top-to-bottom                                        [boolean]

Do analysis

Install vsCode. brew cask install visual-studio-code

code --install-extension joaompinto.vscode-graphviz
code --install-extension vscode-interactive-graphviz

Open VsCode and inside it open .dot file. Cmd+Shift+A type: Graphviz and select Graphviz Interactive: preview.

On graph node click you will see a selected path.

Preview

Segmentation

In several cases we may need extraction of a graph for the one gradle task only. Unfortinately gradle do not give us this option, we can extract dependencies only by modules.

With small tricks is possible to limit the scope:

# extract from full log lines: 211573-216480 and produce shorter log
sed -n '211573,216480p' full-dependency.log >shorter-dependency.log

# produce graph from shorter log
./index.dependendencies.js shorter-dependency.log --simplify --dot >shorter.dot

Troubleshooting

My VsCode configuration

# code --list-extensions

bierner.markdown-mermaid
codezombiech.gitignore
dbaeumer.vscode-eslint
EditorConfig.EditorConfig
esbenp.prettier-vscode
joaompinto.vscode-graphviz
k--kato.intellij-idea-keybindings
tintinweb.graphviz-interactive-preview
yzhang.markdown-all-in-one

Apply NodeJs automatically on project folder entrance

# create extension file
touch ~/.direnvrc

#
# register new method in .diremvrc
#
echo "" >>~/.direnvrc
echo "use_nodejs() {" >>~/.direnvrc
echo "    NODE_VERSION=\"\$1\"" >>~/.direnvrc
echo "    type nvm >/dev/null 2>&1 || . ~/.nvm/nvm.sh" >>~/.direnvrc
echo "    nvm use \"\$NODE_VERSION\"" >>~/.direnvrc
echo "}" >>~/.direnvrc
echo "" >>~/.direnvrc

# apply method call
echo "use nodejs" >>.envrc

# re-enable direnv for folder after changes
direnv allow

refs:

dependencies.graphviz's People

Contributors

oleksandrkucherenko avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.