Giter VIP home page Giter VIP logo

pubviz's Introduction

Visualize package dependencies in your Dart project

Pub Package package publisher CI

Make sure you run pub get or pub upgrade in your target project directory.

Example

Here's an example of pubviz run on itself.

Installing

Activate pubviz.

$ dart pub global activate pubviz

Use

If you have configured your PATH correctly, you can run pubviz directly.

$ pubviz

Otherwise, you can use the pub global command.

$ dart pub global run pubviz

Generate and open an html file for the package on the current path.

$ pubviz open

Should open your default browser to something like:

sample

Print GraphViz dot format to command line for a package on a specified path.

$ pubviz --format=dot print /path/to/http_package

You should see output something like:

digraph G {
  node [fontname=Helvetica];
  edge [fontname=Helvetica, fontcolor=gray];

  http [label="http
0.9.2+3",fontsize=18,style=bold,shape=box,margin="0.25,0.15"];
  http -> path [label=">=0.9.0 <2.0.0",penwidth=2];
  http -> stack_trace [label=">=0.9.1 <0.10.0",penwidth=2];
  http -> unittest [label=">=0.9.0 <0.10.0",penwidth=2,style=dashed];

  path [label="path
1.0.0",shape=box,margin="0.25,0.15",style=bold];

  stack_trace [label="stack_trace
0.9.1",shape=box,margin="0.25,0.15",style=bold];
  stack_trace -> path [label=">=1.0.0-rc.1 <2.0.0"];

  unittest [label="unittest
0.9.3",style=bold];
  unittest -> stack_trace [label=">=0.9.0 <0.10.0",color=gray];
}

Generate PDF, PNG and other files

GraphViz tool allows dot format to be converted to various types of outputs like PNG, PDF or SVG.

In order to export pubviz data to PNG file you need to install GraphViz package on your machine (see detailed installation instructions).

On macOS:

brew install graphviz

On Windows:

winget install graphviz

Then you can save the pubviz output to a file and convert it with dot command to desired output type, e.g.:

pubviz --format=dot print > output.dot
dot -Tpdf output.dot -o output.pdf

The full list of possible output types is available on the GraphViz website.

pubviz -? prints help

$ pubviz -?
Usage: pubviz [<args>] <command> [<package path>]

Commands:
  open   Populate a temporary file with the content and open it.
  print  Print the output to stdout.

Arguments:
  -f, --format=<format>
            [dot]                  Generate a GraphViz dot file
            [html] (default)       Wrap the GraphViz dot format in an HTML template which renders it.

  -i, --ignore-packages            A comma separated list of packages to exclude in the output.
  -o, --[no-]flag-outdated         Check pub.dev for lasted packages and flag those that are outdated.
  -d, --direct-dependencies        Include only direct dependencies.
  -p, --production-dependencies    Include only production (non-dev) dependencies.
  -v, --version                    Print the version of pubviz and exit.
  -?, --help                       Print this help content.

If <package path> is omitted, the current directory is used.

pubviz's People

Contributors

azenla avatar bryonmarks avatar dependabot[bot] avatar felangel avatar fox32 avatar jorgecoca avatar kevmoo avatar orestesgaolin avatar zoechigist avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pubviz's Issues

Option to include only direct dependencies

As a developer, I want to be able to generate a dependency graph which includes only direct dependencies in order to reduce complexity and allow me to focus on only packages which I directly reference/import in my project.

Proposal: Add -d flag for direct dependencies

Usage: pubviz [<args>] <command> [<package path>]

Commands:
  open   Populate a temporary file with the content and open it.
  print  Print the output to stdout.

Arguments:
  -f, --format=<format>
            [dot]                   Generate a GraphViz dot file
            [html] (default)        Wrap the GraphViz dot format in an HTML template which renders it.

  -i, --ignore-packages             A comma seperated list of packages to exclude in the output.
  -o, --[no-]flag-outdated          Check pub.dev for lasted packages and flag those that are outdated.
  -d, --[no-]direct-dependencies    Include only direct dependencies.
  -?, --help                        Print this help content.

If <package path> is omitted, the current directory is used.

Stack trace with bad .pub dir

The pubviz tool appears to be failing on the current master branch for polymer:

*********$ pub global run pubviz open
Unhandled exception:
The null object does not have a setter 'isPrimary='.

NoSuchMethodError: method not found: 'isPrimary='
Receiver: null
Arguments: [true]
#0      Object._noSuchMethod (dart:core-patch/object_patch.dart:42)
#1      Object.noSuchMethod (dart:core-patch/object_patch.dart:45)
#2      VizRoot._update (package:pubviz/src/viz_root.dart:65)
#3      VizRoot.forDirectory.<forDirectory_async_body> (package:pubviz/src/viz_root.dart:49)
#4      _RootZone.runUnary (dart:async/zone.dart:1149)
#5      _Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:495)
#6      _Future._propagateToListeners (dart:async/future_impl.dart:581)
#7      _Future._complete (dart:async/future_impl.dart:363)
#8      _SyncCompleter.complete (dart:async/future_impl.dart:52)
#9      _getReferencedPackages.<_getReferencedPackages_async_body> (package:pubviz/src/viz_root.dart)
#10     _RootZone.runUnary (dart:async/zone.dart:1149)
#11     _Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:495)
#12     _Future._propagateToListeners (dart:async/future_impl.dart:581)
#13     _Future._completeWithValue (dart:async/future_impl.dart:373)
#14     Future.wait.<anonymous closure> (dart:async/future.dart:299)
#15     _RootZone.runUnary (dart:async/zone.dart:1149)
#16     _Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:495)
#17     _Future._propagateToListeners (dart:async/future_impl.dart:581)
#18     _Future._complete (dart:async/future_impl.dart:363)
#19     _SyncCompleter.complete (dart:async/future_impl.dart:52)
#20     _getReferencedPackages.<_getReferencedPackages_async_body>.<anonymous closure>.<<anonymous closure>_async_body> (package:pubviz/src/viz_root.dart)
#21     _RootZone.runUnary (dart:async/zone.dart:1149)
#22     _Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:495)
#23     _Future._propagateToListeners (dart:async/future_impl.dart:581)
#24     _Future._complete (dart:async/future_impl.dart:363)
#25     _SyncCompleter.complete (dart:async/future_impl.dart:52)
#26     VizPackage.forDirectory.<forDirectory_async_body> (package:pubviz/src/viz_package.dart)
#27     _RootZone.runUnary (dart:async/zone.dart:1149)
#28     _Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:495)
#29     _Future._propagateToListeners (dart:async/future_impl.dart:581)
#30     _Future._complete (dart:async/future_impl.dart:363)
#31     _SyncCompleter.complete (dart:async/future_impl.dart:52)
#32     _openYaml.<_openYaml_async_body> (package:pubviz/src/viz_package.dart)
#33     _RootZone.runUnary (dart:async/zone.dart:1149)
#34     _Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:495)
#35     _Future._propagateToListeners (dart:async/future_impl.dart:581)
#36     _Future._completeWithValue (dart:async/future_impl.dart:373)
#37     _Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:427)
#38     _microtaskLoop (dart:async/schedule_microtask.dart:41)
#39     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50)
#40     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:96)
#41     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:149)

Option to ignore dev deps

Awesome tool, thanks!

I'd like to eliminate all dev dependencies in one swell foop. Rather than listing deps in --ignore-packages, how about an option to --ignore-dev-deps?

Update:
Here's the command to ignore all packages pulled in by a single dev dependency, package:test:
pubviz open --ignore-packages test,shelf_static,shelf_web_socket,http_multi_server,matcher,source_map_stack_trace,web_socket_channel,boolean_selector,pub_semver

It took several iterations to derive that. It is probably only valid for package:test version 0.12.6, and even for that version other packages could be eliminated (barback, glob, yaml are required by other packages as well as test). Letting the tool find all non-root packages with no incoming deps, eliminating them, and iterating would be faster. I dunno know how hard that is in practice for the general case with many dev deps. I only had one.

Some usebility improvments for big graphs

I currently have quite a big dependcy graph in an application. I have so many edges, version constraints and packages that some parts are very hard to read. Especially when many edges cross each other.
It would be nice if one could click on a package and highlight all incomming and outgoing edges and their constraints.

However I don't know if the current graph library support something like this.

Allow to ignore packages

There are several packages which only add clutter but no value to the output like

  • args
  • path
  • logging
    ...

It would make the generated output much more readable.

Docs: explain how to convert dot output to other formats

Hey there! I was trying to figure out how to export pubviz dot data to some format like png or pdf and it took me some time to understand how to do it with graphviz.

Would you like me to add some short description in the readme how to handle pubviz output? If not then that's fine, but wanted to ask before creating a PR.

Extremely large dependency trees cause a memory failure

For packages with very large dependency trees, the file is generated but the page cannot be loaded. Instead, this error is shown:

abort("Cannot enlarge memory arrays. Either (1) compile with  -s TOTAL_MEMORY=X  with X higher than the current value 16777216, (2) compile with  -s ALLOW_MEMORY_GROWTH=1  which adjusts the size at runtime but prevents some optimizations, (3) set Module.TOTAL_MEMORY to a higher value before the program runs, or if you want malloc to return NULL (0) instead of this abort, compile with  -s ABORTING_MALLOC=0 ") at Error
    at Ga (https://kevmoo.github.io/pubviz/viz.js:49:124)
    at Fa (https://kevmoo.github.io/pubviz/viz.js:49:22)
    at v (https://kevmoo.github.io/pubviz/viz.js:1172:101)
    at Function.ba [as Wa] (https://kevmoo.github.io/pubviz/viz.js:34:488)
    at vc (https://kevmoo.github.io/pubviz/viz.js:1093:402)
    at M4 (https://kevmoo.github.io/pubviz/viz.js:1157:7144)
    at bK (https://kevmoo.github.io/pubviz/viz.js:1148:184533)
    at aK (https://kevmoo.github.io/pubviz/viz.js:1148:184286)
    at Rg (https://kevmoo.github.io/pubviz/viz.js:1147:242859)
    at yi (https://kevmoo.github.io/pubviz/viz.js:1153:66518)
If this abort() is unexpected, build with -s ASSERTIONS=1 which can give more information.

'isPrimary=' was called on null.

Calling either pubviz print or pubviz open results in this stack trace:

NoSuchMethodError: The setter 'isPrimary=' was called on null.
Receiver: null
Tried calling: isPrimary=true
dart:core                              Object.noSuchMethod
package:pubviz/src/viz_root.dart 73    VizRoot._update
package:pubviz/src/viz_root.dart 57    VizRoot.forDirectory
===== asynchronous gap ===========================
dart:async                             _Completer.completeError
package:pubviz/src/viz_root.dart       VizRoot.forDirectory
===== asynchronous gap ===========================
dart:async                             _asyncThenWrapperHelper
package:pubviz/src/viz_root.dart 20    VizRoot.forDirectory
http://localhost:51252/pubviz.dart 40  main.<fn>
===== asynchronous gap ===========================
dart:async                             new Future.microtask
http://localhost:51252/pubviz.dart 39  main.<fn>
package:stack_trace                    Chain.capture
http://localhost:51252/pubviz.dart 39  main

My details:

pub global activate pubviz
Package pubviz is currently active at version 2.4.2.

pub --version
Pub 2.0.0-dev.31.0

dart --version
Dart VM version: 2.0.0-dev.31.0 (Tue Feb 27 17:21:40 2018 +0100) on "windows_x64"

Null-Safety View

Would be cool to have a view that shows which packages already have a null-safety ready version available. This would help to find packages deeper in the dependency tree which might be target for contributions.

Add new argument to select destination of HTML report

Hi @kevmoo ๐Ÿ‘‹

I was wondering if there's any special reason to not having an option to select where the HTML report is being generated. I think this would be great for CI/CD environments, so consumers could publish their results into an archive repository.

If you agree to this feature, I can start working on a pull request. Let me know.

Thanks!

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.