Closed yohaneskuma closed 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?
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]' ?
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.
@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
Ohh you are right. I forgot to change it. I will improve it. Thanks
@tsloughter I have now used init:get_argument(home)
to get home dir of the user.
Sorry, I should have been more clear, you can't do that either. You need to do:
{ok, RegistryDir} = rebar_packages:registry_dir(State)
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?
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.
@tsloughter Thanks, I have used now rebar_packages:registry_dir(State)
as you suggested
Great, looking good. One last nitpick :):
-define(REGISTRY_FILE, "registry").
...
case ets:file2tab(filename:join(RegistryDir, ?REGISTRY_FILE)) of
@tsloughter it now uses filename:join. thanks
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:
This will be helpful, since the current implementation of 'rebar3 deps' only list out the deps at level 0.