Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

generates a dependency graph for a go or php project

License

NotificationsYou must be signed in to change notification settings

windler/godepg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Report CardCircleCIcodebeat badge

godepg

godepg generates a dependency graph for a go or php project usinggraphviz. A dependency graph generated bygodepg using aconfig looks like the following:godepg dep graph

Currently, the following technologies are supported:

  • go
  • php (composer)
  • php (psr4)

TOC

  1. Prerequisites
  2. Installation
  3. Usage
  4. Generate graphs
  5. Examples
  6. Print dependencies

Prerequisites

In order to generate graphs you have to installgraphviz

Installation

go get github.com/windler/godepg

Make sure that your$GOROOT is set and is present in your path

export PATH=$PATH:$GOROOT/bin

Usage

For each language there is a subcommand. Typegodepg <language> -h to see a list of available options.

GO

godepg go -h
OPTIONS:   -o file, --output file         destination file to write png to   -p package, --package package  the package to analyze   -n, --no-go-packages           hide gos buildin packages   -d value, --depth value        limit the depth of the graph (default: -1)   -f value, --filter value       filter package name   -m, --my-packages-only         show only subpackages of scanned package   -i package, --info package     shows the dependenciesfor a package   --inverse                      shows all packages that depend on the package rather than its dependencies   --format value                 formats the dependencies output (--info)

PHP (composer)

godepg php-composer -h
OPTIONS:   -o file, --output file         destination file to write png to   -p project, --project project  the project to analyze   -f value, --filter value       filter project name   -s value, --stop-at value      dont scan dependencies of package name (pattern)   -d value, --depth value        limit the depth of the graph (default: -1)

PHP (psr4)

godepg php-psr4 -h
OPTIONS:   -o file     destination file to write png to   -p project  the project to analyze   -f value    filter project name   -s value    dont scan dependencies of package name (pattern)   -d value    limit the depth of the graph (default: -1)   -e value    exclude folder

Generate graphs

All graphs are written to~/godepg/<pkg>_timestamp.png if option-o is not present. You can change the home directory by setting the envGODEPG_HOME.

Generate Graphs using yaml file

When no language subcommand is specified,godepg will try to read a config file namedgodepg.yml to generate a dependy graph. You can also specify the config file with the option--file. Following, there is a sample config file:

language:php-composeroutput:/home/windler/projects/sample/deps.pngstopat:-laravelfilter:-php-tinkerdepth:3

Styling graphs using config

If you are using a config file you can also apply anydot attributes to style your graph. Example:

language:php-composeroutput:/home/windler/projects/sample/deps.pngfilter:-phpdepth:3edgestylepattern:"":arrowhead:opencolor:whitefontcolor:whitesplines:curvedsample:arrowhead:veefontname:Courierstyle:dashednodestyle:fillcolor:"#336699"style:filledfontcolor:whitefontname:Couriershape:rectanglegraphstyle:bgcolor:"#333333"

After creating a config file, you can always update your current dependy graph using

cd /home/windler/projects/samplegodepg

or

godepg --file /home/windler/projects/sample/godepg.yml

Available attributes

AttributeTypeLanguageDescription
languagestringallthe language to use
filterarrayallfilters node names (hide)
depthintallmax depth of the graph
outputstringalloutput file of the png (and dot file)
edgestylepatternmap string -> (map string -> string)allapply dot attributes to edges. The first map key is a pattern on which nodes the attributes should be applied. If all nodes should be applied use"".
edgestylemap string -> stringallapply edge attributes
nodestylemap string -> stringallapply node attributes
graphstylemap string -> stringallapply graph attributes
projectstringphpthe project the use (relative to wd)
excludearrayphpfolders to ignore
stopatarrayphpprint node but dont scan/print dependencies
packagestringgopackage name to scan
nogopackagesboolgohide go packges in graph
mypackagesonlyboolgoonly show subpackages of the scanned package

Examples

Following, you can find sample outputs.

GO

Samples for thews package package.

Without go internal packages and specific output file

godepg go -p github.com/windler/ws -o~/ws_package.png -n

or

cd /user/windler/go/src/github.com/windler/wsgodepg go -p. -o~/ws_package.png -n

ws no go packages

Only sub packages

godepg go -p github.com/windler/ws -m

ws only sub

Without go internal packages and custom filter

godepg go -p github.com/windler/ws -n -f=ui -f=/git

ws custom filter

PHP

Samples for a freshLaravel installation calledsample.

Dont show laravels dependencies

godepg php-composer -p /home/windler/projects/sample -s=laravel

rpi no laravel

Hide symfony dependecies

godepg php-composer -p /home/windler/projects/sample -f=symfony

rpi no laravel

Print dependencies (GO only)

You can also just print information about the dependencies of a package by using option-i:

godepg go -p github.com/windler/ws -i github.com/windler/ws/app/configThere are 7 dependencies for package github.com/windler/ws/app/config:0: github.com/windler/ws/app/commands1: gopkg.in/yaml.v22: io/ioutil3: log4: os5: os/user6: strings

Get Dependents

If you would like to see a list of packages that depend on a specific package, just add the--inverse option:

godepg go -p github.com/windler/ws -i github.com/windler/ws/app/config --inverseThere are 1 dependents for package github.com/windler/ws/app/config:0: github.com/windler/ws

Modify output

You can modify the output by passing atemplate using--format:

godepg go -p github.com/windler/ws -i github.com/windler/ws --format "Deps: {{.Count}}"Deps: 5

You can use the following fields:

FieldDescription
PackageThe name of the scanned package
CountNumber of found dependencies
DependenciesArray of packages
DependencyTypeType of the dependencies (dependency or dependent)

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp