Add task app.tree #4261

Merged
merged 1 commit into from Feb 4, 2016

Projects

None yet

7 participants

@liveforeverx
Contributor

Task to show dependency tree of an application.

@josevalim
Member

Thank you! ❤️ 💚 💙 💛 💜

@lexmag lexmag and 1 other commented on an outdated diff Feb 4, 2016
lib/mix/lib/mix/tasks/app.tree.ex
@@ -0,0 +1,70 @@
+defmodule Mix.Tasks.App.Tree do
+ use Mix.Task
+
+ @shortdoc "Analyses the current Mix project and prints dependency tree on terminal."
@lexmag
lexmag Feb 4, 2016 Member

Probably we need to remove terminal wording, it's just a particular case when Mix.shell is set to IO.

@liveforeverx
liveforeverx Feb 4, 2016 Contributor

Have thought, but do not know, how really reword it. What would be right wording for it?

@lexmag lexmag commented on an outdated diff Feb 4, 2016
lib/mix/lib/mix/tasks/app.tree.ex
@@ -0,0 +1,70 @@
+defmodule Mix.Tasks.App.Tree do
+ use Mix.Task
+
+ @shortdoc "Analyses the current Mix project and prints dependency tree on terminal."
+
+ @moduledoc """
+ Analyses the current Mix project and prints dependency tree on terminal.
+
+ ## Command line options
+
+ * `--exclude` - exclude dependencies, which you do not want to see in a tree
+
+ ## Example of use
+
+ mix deps.tree --exclude logger,elixir
@lexmag
lexmag Feb 4, 2016 Member

I think we should implement --exclude option without String.split/2 but by using :keep, that's what we do for mix test --exclude and --include options.

@liveforeverx liveforeverx Add task app.tree
Task to show dependency tree of an application
d981051
@josevalim josevalim merged commit 2ea28f3 into elixir-lang:master Feb 4, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@josevalim
Member

❤️ 💚 💙 💛 💜

@alco
Member
alco commented Feb 4, 2016

I just tried this on master and it explodes in a project that hasn't been compiled:

$ mix app.tree
** (CaseClauseError) no case clause matching: {:error, {'no such file or directory', 'hashids.app'}}
    (mix) lib/mix/tasks/app.tree.ex:37: Mix.Tasks.App.Tree.load/1
    (mix) lib/mix/tasks/app.tree.ex:32: Mix.Tasks.App.Tree.deps/2
    (mix) lib/mix/tasks/app.tree.ex:28: Mix.Tasks.App.Tree.run/1
    (mix) lib/mix/cli.ex:58: Mix.CLI.run_task/2
    (elixir) lib/code.ex:363: Code.require_file/2
@alco alco commented on the diff Feb 4, 2016
lib/mix/lib/mix/tasks/app.tree.ex
@@ -0,0 +1,67 @@
+defmodule Mix.Tasks.App.Tree do
+ use Mix.Task
+
+ @shortdoc "Analyses the current Mix project and sends dependency tree to mix shell."
+
+ @moduledoc """
+ Analyses the current Mix project and sends dependency tree to mix shell.
+
+ ## Command line options
+
+ * `--exclude` - exclude dependencies, which you do not want to see in a tree
+
+ ## Example of use
+
+ mix deps.tree --exclude logger --exclude elixir
@alco
alco Feb 4, 2016 Member

This should be app.tree.

@liveforeverx
liveforeverx Feb 4, 2016 Contributor

Yes, sorry overseen by porting...

@josevalim
Member

@alco yup, i have fixed it locally :)

@TBK145
Contributor
TBK145 commented Feb 4, 2016

This is a really cool feature! Will it also be available for umbrella apps?

@ericmj
Member
ericmj commented Feb 4, 2016

Shouldn't this be deps.tree instead? In which circumstances would apps.tree be more useful than deps.tree?

@josevalim
Member

We have both in master. app.tree is great to see what we will effectively
depend on in production. I posted a gist online:
https://gist.github.com/josevalim/67cc4fdbd66f96c647fd

App.tree doesn't work for umbrellas but deps.tree does. I will fix that.

José Valimwww.plataformatec.com.br
http://www.plataformatec.com.br/Founder and Director of R&D

@fishcakez
Member

Do we always need to show elixir in the apps.tree? It creates a lot of noise in the output. Of course a dependency may not require elixir so perhaps we could enable it with a flag? We hide erts, kernel and stdlib - though it is not quite the same brcause I'm not sure it possible to not require those 3 apps, whereas elixir is not always required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment