dart-lang / pub

The pub command line tool
https://dart.dev/tools/pub/cmd
BSD 3-Clause "New" or "Revised" License
1.04k stars 224 forks source link

add option to pub deps to show tree for single package. #2889

Open bsutton opened 3 years ago

bsutton commented 3 years ago

For a project with a large no. of dependencies it can be hard to find a single dependency and its ancestors.

It would be useful to have an option that just shows the tree for a single dependency.

e.g.

pub deps --filter=uri

Dart SDK 2.12.0-259.12.beta
Flutter SDK 1.26.0-1.0.pre
fsm2 2.0.0
|-- dcli 0.50.0-nullsaftey.1
|   |-- pubspec 1.0.0-nullsafety.0
|   |   |-- uri 1.0.0-nullsafety.0
|   |   |   |-- quiver 3.0.0

rather than what I see now :+1:

pub deps

Dart SDK 2.12.0-259.12.beta
Flutter SDK 1.26.0-1.0.pre
fsm2 2.0.0
|-- args 2.0.0
|-- build_runner 1.11.3
|   |-- build 1.6.2
|   |   |-- convert 3.0.0
|   |   |   '-- typed_data...
|   |   |-- analyzer...
|   |   |-- async...
|   |   |-- crypto...
|   |   |-- glob...
|   |   |-- logging...
|   |   |-- meta...
|   |   '-- path...
|   |-- build_config 0.4.6
|   |   |-- checked_yaml 1.0.4
|   |   |   |-- json_annotation...
|   |   |   |-- source_span...
|   |   |   '-- yaml...
|   |   |-- json_annotation 4.0.0
|   |   |-- meta...
|   |   |-- path...
|   |   |-- pubspec_parse...
|   |   '-- yaml...
|   |-- build_daemon 2.1.8
|   |   |-- built_collection 5.0.0
|   |   |-- built_value 8.0.0
|   |   |   |-- fixnum 1.0.0
|   |   |   |-- built_collection...
|   |   |   '-- collection...
|   |   |-- http_multi_server...
|   |   |-- logging...
|   |   |-- path...
|   |   |-- pedantic...
|   |   |-- pool...
|   |   |-- shelf...
|   |   |-- shelf_web_socket...
|   |   |-- stream_transform...
|   |   |-- watcher...
|   |   '-- web_socket_channel...
|   |-- build_resolvers 1.5.3
|   |   |-- analyzer...
|   |   |-- build...
|   |   |-- crypto...
|   |   |-- graphs...
|   |   |-- logging...
|   |   |-- meta...
|   |   |-- package_config...
|   |   |-- path...
|   |   |-- pool...
|   |   '-- pub_semver...
|   |-- build_runner_core 6.1.9
|   |   |-- async...
|   |   |-- build...
|   |   |-- build_config...
|   |   |-- build_resolvers...
|   |   |-- collection...
|   |   |-- convert...
|   |   |-- crypto...
|   |   |-- glob...
|   |   |-- graphs...
|   |   |-- logging...
|   |   |-- meta...
|   |   |-- package_config...
|   |   |-- path...
|   |   |-- pedantic...
|   |   |-- pool...
|   |   |-- timing...
|   |   |-- watcher...
|   |   '-- yaml...
|   |-- code_builder 3.6.0
|   |   |-- built_collection...
|   |   |-- built_value...
|   |   |-- collection...
|   |   |-- matcher...
|   |   '-- meta...
|   |-- crypto 3.0.0
|   |   |-- collection...
|   |   '-- typed_data...
|   |-- dart_style 1.3.12
|   |   |-- analyzer...
|   |   |-- args...
|   |   |-- path...
|   |   |-- pub_semver...
|   |   '-- source_span...
|   |-- graphs 0.2.0
|   |-- http_multi_server 2.2.0
|   |   '-- async...
|   |-- io 0.3.4
|   |   |-- charcode...
|   |   |-- meta...
|   |   |-- path...
|   |   '-- string_scanner...
|   |-- js 0.6.3
|   |-- logging 1.0.0
|   |-- mime 1.0.0
|   |-- pool 1.5.0
|   |   |-- async...
|   |   '-- stack_trace...
|   |-- pubspec_parse 0.1.8
|   |   |-- checked_yaml...
|   |   |-- json_annotation...
|   |   |-- pub_semver...
|   |   '-- yaml...
|   |-- shelf 1.0.0
|   |   |-- http_parser 4.0.0
|   |   |   |-- charcode...
|   |   |   |-- collection...
|   |   |   |-- source_span...
|   |   |   |-- string_scanner...
|   |   |   '-- typed_data...
|   |   |-- async...
|   |   |-- collection...
|   |   |-- path...
|   |   |-- stack_trace...
|   |   '-- stream_channel...
|   |-- shelf_web_socket 0.2.4
|   |   |-- shelf...
|   |   |-- stream_channel...
|   |   '-- web_socket_channel...
|   |-- stack_trace 1.10.0
|   |   '-- path...
|   |-- stream_transform 2.0.0
|   |-- timing 0.1.1+3
|   |   '-- json_annotation...
|   |-- watcher 1.0.0
|   |   |-- async...
|   |   |-- path...
|   |   '-- pedantic...
|   |-- web_socket_channel 1.2.0
|   |   |-- async...
|   |   |-- crypto...
|   |   '-- stream_channel...
|   |-- args...
|   |-- async...
|   |-- collection...
|   |-- glob...
|   |-- meta...
|   |-- path...
|   |-- pedantic...
|   |-- pub_semver...
|   '-- yaml...
|-- completer_ex 2.0.0
|   |-- simple_logger 1.8.0+1
|   |   |-- logging...
|   |   '-- stack_trace...
|   '-- stacktrace_impl...
|-- dcli 0.50.0-nullsaftey.1
|   |-- archive 3.0.0
|   |   |-- crypto...
|   |   '-- path...
|   |-- async 2.5.0
|   |   '-- collection...
|   |-- collection 1.15.0
|   |-- csv 5.0.0-nullsafety.0
|   |-- equatable 2.0.0-nullsafety.3
|   |   |-- collection...
|   |   '-- meta...
|   |-- file 6.0.1
|   |   |-- meta...
|   |   '-- path...
|   |-- glob 2.0.0
|   |   |-- string_scanner 1.1.0
|   |   |   |-- charcode...
|   |   |   '-- source_span...
|   |   |-- async...
|   |   |-- collection...
|   |   |-- file...
|   |   |-- path...
|   |   '-- pedantic...
|   |-- intl 0.17.0
|   |   |-- clock 1.1.0
|   |   '-- path...
|   |-- logger 1.0.0-nullsafety.0
|   |-- pedantic 1.10.0
|   |-- posix 2.0.0-nullsafety.1
|   |   '-- ffi 1.0.0
|   |-- pub_semver 2.0.0
|   |   '-- collection...
|   |-- pubspec 1.0.0-nullsafety.0
|   |   |-- uri 1.0.0-nullsafety.0
|   |   |   |-- quiver 3.0.0
|   |   |   |   '-- matcher...
|   |   |   '-- matcher...
|   |   |-- path...
|   |   |-- pub_semver...
|   |   '-- yaml...
|   |-- system_info 1.0.0
|   |   |-- file_utils 1.0.0
|   |   |   |-- globbing 1.0.0
|   |   |   |   '-- path...
|   |   |   '-- path...
|   |   '-- path...
|   |-- uuid 3.0.0-nullsafety.1
|   |   '-- crypto...
|   |-- yaml 3.0.0
|   |   |-- charcode 1.2.0
|   |   |-- collection...
|   |   |-- source_span...
|   |   '-- string_scanner...
|   |-- args...
|   |-- meta...
|   '-- path...
|-- lint 1.5.1
|-- meta 1.3.0
|-- mockito 5.0.0-nullsafety.7
|   |-- analyzer 0.41.2
|   |   |-- _fe_analyzer_shared 14.0.0
|   |   |   '-- meta...
|   |   |-- cli_util 0.3.0
|   |   |   |-- meta...
|   |   |   '-- path...
|   |   |-- args...
|   |   |-- collection...
|   |   |-- convert...
|   |   |-- crypto...
|   |   |-- glob...
|   |   |-- meta...
|   |   |-- package_config...
|   |   |-- path...
|   |   |-- pub_semver...
|   |   |-- source_span...
|   |   |-- watcher...
|   |   '-- yaml...
|   |-- matcher 0.12.10
|   |   '-- stack_trace...
|   |-- source_gen 0.9.10+2
|   |   |-- analyzer...
|   |   |-- async...
|   |   |-- build...
|   |   |-- dart_style...
|   |   |-- glob...
|   |   |-- meta...
|   |   |-- path...
|   |   |-- pedantic...
|   |   '-- source_span...
|   |-- test_api 0.2.19
|   |   |-- term_glyph 1.2.0
|   |   |-- async...
|   |   |-- boolean_selector...
|   |   |-- collection...
|   |   |-- matcher...
|   |   |-- meta...
|   |   |-- path...
|   |   |-- source_span...
|   |   |-- stack_trace...
|   |   |-- stream_channel...
|   |   '-- string_scanner...
|   |-- build...
|   |-- code_builder...
|   |-- collection...
|   |-- dart_style...
|   |-- meta...
|   '-- path...
|-- path 1.8.0
|-- stacktrace_impl 2.0.0
|   '-- path...
|-- synchronized 3.0.0
|-- test 1.16.2
|   |-- boolean_selector 2.1.0
|   |   |-- source_span...
|   |   '-- string_scanner...
|   |-- coverage 0.15.2
|   |   |-- source_maps 0.10.10
|   |   |   '-- source_span...
|   |   |-- vm_service 6.0.1
|   |   |-- args...
|   |   |-- logging...
|   |   |-- package_config...
|   |   |-- path...
|   |   '-- stack_trace...
|   |-- node_preamble 1.4.13
|   |-- package_config 1.9.3
|   |   |-- charcode...
|   |   '-- path...
|   |-- shelf_packages_handler 2.0.1
|   |   |-- path...
|   |   |-- shelf...
|   |   '-- shelf_static...
|   |-- shelf_static 0.2.9+2
|   |   |-- convert...
|   |   |-- http_parser...
|   |   |-- mime...
|   |   |-- path...
|   |   '-- shelf...
|   |-- source_span 1.8.1
|   |   |-- collection...
|   |   |-- path...
|   |   '-- term_glyph...
|   |-- stream_channel 2.1.0
|   |   '-- async...
|   |-- test_core 0.3.13
|   |   |-- source_map_stack_trace 2.1.0
|   |   |   |-- path...
|   |   |   |-- source_maps...
|   |   |   '-- stack_trace...
|   |   |-- analyzer...
|   |   |-- args...
|   |   |-- async...
|   |   |-- boolean_selector...
|   |   |-- collection...
|   |   |-- coverage...
|   |   |-- glob...
|   |   |-- io...
|   |   |-- matcher...
|   |   |-- meta...
|   |   |-- package_config...
|   |   |-- path...
|   |   |-- pedantic...
|   |   |-- pool...
|   |   |-- source_maps...
|   |   |-- source_span...
|   |   |-- stack_trace...
|   |   |-- stream_channel...
|   |   |-- test_api...
|   |   |-- vm_service...
|   |   '-- yaml...
|   |-- typed_data 1.3.0
|   |   '-- collection...
|   |-- webkit_inspection_protocol 0.7.5
|   |   '-- logging...
|   |-- analyzer...
|   |-- async...
|   |-- http_multi_server...
|   |-- io...
|   |-- js...
|   |-- path...
|   |-- pedantic...
|   |-- pool...
|   |-- shelf...
|   |-- shelf_web_socket...
|   |-- stack_trace...
|   |-- test_api...
|   |-- web_socket_channel...
|   '-- yaml...
'-- tree_iterator 2.0.0
mkustermann commented 3 years ago

/cc @sigurdm @jonasfj Could you find an appropriate area label?

jonasfj commented 3 years ago

Transfering to the pub repository.

sigurdm commented 3 years ago

I rarely use the pub deps command myself, but I can see how it might make it easier to analyze the dependencies.

I guess part of the problem here is that the dependency graph is not really a tree (possibly not even a DAG), making it hard to read the output.

Perhaps we could output the graph in graphviz dot format or something similar - enabling a graphic representation of the graph that might be easier to interpret.

bsutton commented 3 years ago

My use case was to find why a specific package was included.

I had a conflict and was trying to establish why.

My long experience with maven was essentially the same. A full view of the entire dependency tree was rarely used in my experience.

I really want to see an inverse tree starting from the passed dependency.

The current textual tree format is fine once inverted.

On Tue, 23 Feb 2021, 8:29 pm Sigurd Meldgaard, notifications@github.com wrote:

I rarely use the pub deps command myself, but I can see how it might make it easier to analyze the dependencies.

I guess part of the problem here is that the dependency graph is not really a tree (possibly not even a DAG), making it hard to read the output.

Perhaps we could output the graph in graphviz dot https://www.graphviz.org/ format or something similar - enabling a graphic representation of the graph that might be easier to interpret.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dart-lang/pub/issues/2889#issuecomment-784033789, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAG32OB6X6WVE5HXQMNNICLTANYRHANCNFSM4X4JIIAA .

sigurdm commented 3 years ago

Do you want it inverted, or just having it "pruned" to the relevant parts? I guess you always want to start with the root package?

bsutton commented 3 years ago

Inverted would be good but it could be confusing when the full view isn't.

Pruned would be sufficient.

On Tue, 23 Feb 2021, 10:40 pm Sigurd Meldgaard, notifications@github.com wrote:

Do you want it inverted, or just having it "pruned" to the relevant parts? I guess you always want to start with the root package?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dart-lang/pub/issues/2889#issuecomment-784140443, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAG32OEPDPCQXHHZU4I5UDTTAOH2BANCNFSM4X4JIIAA .