- Notifications
You must be signed in to change notification settings - Fork0
generates a dependency graph for a go or php project
License
windler/godepg
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
godepg
generates a dependency graph for a go or php project usinggraphviz
. A dependency graph generated bygodepg
using aconfig looks like the following:
Currently, the following technologies are supported:
- go
- php (composer)
- php (psr4)
In order to generate graphs you have to installgraphviz
go get github.com/windler/godepg
Make sure that your$GOROOT
is set and is present in your path
export PATH=$PATH:$GOROOT/bin
For each language there is a subcommand. Typegodepg <language> -h
to see a list of available options.
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)
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)
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
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
.
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
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
Attribute | Type | Language | Description |
---|---|---|---|
language | string | all | the language to use |
filter | array | all | filters node names (hide) |
depth | int | all | max depth of the graph |
output | string | all | output file of the png (and dot file) |
edgestylepattern | map string -> (map string -> string) | all | apply 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"" . |
edgestyle | map string -> string | all | apply edge attributes |
nodestyle | map string -> string | all | apply node attributes |
graphstyle | map string -> string | all | apply graph attributes |
project | string | php | the project the use (relative to wd) |
exclude | array | php | folders to ignore |
stopat | array | php | print node but dont scan/print dependencies |
package | string | go | package name to scan |
nogopackages | bool | go | hide go packges in graph |
mypackagesonly | bool | go | only show subpackages of the scanned package |
Following, you can find sample outputs.
Samples for thews package package.
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
godepg go -p github.com/windler/ws -m
godepg go -p github.com/windler/ws -n -f=ui -f=/git
Samples for a freshLaravel installation calledsample
.
godepg php-composer -p /home/windler/projects/sample -s=laravel
godepg php-composer -p /home/windler/projects/sample -f=symfony
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
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
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:
Field | Description |
---|---|
Package | The name of the scanned package |
Count | Number of found dependencies |
Dependencies | Array of packages |
DependencyType | Type of the dependencies (dependency or dependent) |