erlef / rebar3_hex

Rebar3 Hex library
Apache License 2.0
101 stars 49 forks source link

Add functionality for "rebar3 hex info" #28

Closed yohaneskuma closed 8 years ago

yohaneskuma commented 8 years ago

The current implementation of rebar3_hex has no functionality for command 'rebar3 hex info' if the package is not specified. In this commit, we have added functionality for this command, which will list out:

  1. All deps at level 0
  2. for those deps at level 0 which are package deps (are found in Hex registry), it will continue listing out their deps at level > 0

This will be helpful, since the current implementation of 'rebar3 deps' only list out the deps at level 0.

tsloughter commented 8 years ago

@yohaneskuma hey, sorry I'm late on this I somehow missed the PR. It looks like this fetches packages here https://github.com/hexpm/rebar3_hex/pull/28/files#diff-07e7d677eea863060d701c58e8645254R79 and i don't understand why. Isn't all the necessary information available in the local registry?

yohaneskuma commented 8 years ago

Yes we could use the local registry. I used it in that way (via fetching) in order to have the same pattern as of the other services of 'rebar3 hex info' command. As you can see here https://github.com/hexpm/rebar3_hex/pull/28/files#diff-07e7d677eea863060d701c58e8645254L53 and https://github.com/hexpm/rebar3_hex/pull/28/files#diff-07e7d677eea863060d701c58e8645254L82 , rebar3_hex_info fetches directly from hex instead of the local registry. Shall we use the local registry for 'rebar3 hex info' , while communicating the hex registry for 'rebar3 hex info PACKAGE [VERSION]' ?

tsloughter commented 8 years ago

Oh, yes, we should definitely use the local registry here. Maybe I copied how mix's hex plugin does it without thinking. It would be much better to not fetch.

yohaneskuma commented 8 years ago

@tsloughter I have squashed a new version as of your comment. It will now first use local registry, and if it is missing it will contact hex server. With this pull request, we can have the following functionality:

Given a sample rebar.config {erl_opts, [debug_info]}. {deps, [cowboy] or [{cowboy, "1.0.4"}]}. {plugins, [rebar3_hex]}. we can get the following output from performing 'rebar3 hex info': cowboy 1.0.4 cowlib ~> 1.0.0 ranch ~> 1.0

yohaneskuma commented 8 years ago

Ohh you are right. I forgot to change it. I will improve it. Thanks

yohaneskuma commented 8 years ago

@tsloughter I have now used init:get_argument(home) to get home dir of the user.

tsloughter commented 8 years ago

Sorry, I should have been more clear, you can't do that either. You need to do:

{ok, RegistryDir} = rebar_packages:registry_dir(State)
yohaneskuma commented 8 years ago

I am kinda confused here. Do you think it is good idea to use rebar_packages from rebar3 in rebar3_hex project? aren't rebar3 and rebar3_hex completely separated?

tsloughter commented 8 years ago

Oh, no, they aren't. rebar3_hex is a plugin to rebar3, I could move the call to be rebar_api:registry_dir(State) but needs to be used either way.

yohaneskuma commented 8 years ago

@tsloughter Thanks, I have used now rebar_packages:registry_dir(State) as you suggested

tsloughter commented 8 years ago

Great, looking good. One last nitpick :):

-define(REGISTRY_FILE, "registry").
...
case ets:file2tab(filename:join(RegistryDir, ?REGISTRY_FILE)) of
yohaneskuma commented 8 years ago

@tsloughter it now uses filename:join. thanks