Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

119 рядки
4.3 KiB

10 роки тому
10 роки тому
10 роки тому
10 роки тому
10 роки тому
10 роки тому
10 роки тому
10 роки тому
10 роки тому
support for hex v2, multiple repository fetching, private organizations (#1884) * update to hex_core for hex-v2 repo support (#1865) * update to hex_core for hex-v2 repo support This patch adds only single repo hex-v2 support through hex_core. Packages no longer filtered out by buildtool metadata and the package index is updated per-package instead of fetched as one large ets dump. * tell travis to also build hex_core branch * support list of repos for hex packages (#1866) * support list of repos for hex packages repos are defined under the hex key in rebar configs. They can be defined at the top level of a project or globally, but not in profiles and the repos configured in dependencies are also ignored. Searching for packages involves first checking for a match in the local repo index cache, in the order repos are defined. If not found each repo is checked through the hex api for any known versions of the package and the first repo with a version that fits the constraint is used. * add {repos, replace, []} for overriding the global & default repos * add hex auth handling for repos (#1874) auth token are kept in a hex.config file that is modified by the rebar3 hex plugin. Repo names that have a : separating a parent and child are considered organizations. The parent repo's auth will be included with the child. So an organization named hexpm:rebar3_test will include any hexpm auth tokens found in the rebar3_test organization's configuration. * move packages to top level of of hexpm cache dir (#1876) * move packages to top level of of hexpm cache dir * append organization name to parent's repo_url when parsing repos * only eval config scripts and apply overrides once per app (#1879) * only eval config scripts and apply overrides once per app * move new resource behaviour to rebar_resource_v2 and keep v1 * cleanup use of rebar_resource module and unused functions * cleanup error messages and unused code * when discovering apps support mix packages as unbuilt apps (#1882) * use hex_core tarball unpacking support in pkg resource (#1883) * use hex_core tarball unpacking support in pkg resource * ignore etag if package doesn't exist and delete if checksum fails * add back tests for bad package checksums * improve bad registry checksum error message
6 роки тому
10 роки тому
support for hex v2, multiple repository fetching, private organizations (#1884) * update to hex_core for hex-v2 repo support (#1865) * update to hex_core for hex-v2 repo support This patch adds only single repo hex-v2 support through hex_core. Packages no longer filtered out by buildtool metadata and the package index is updated per-package instead of fetched as one large ets dump. * tell travis to also build hex_core branch * support list of repos for hex packages (#1866) * support list of repos for hex packages repos are defined under the hex key in rebar configs. They can be defined at the top level of a project or globally, but not in profiles and the repos configured in dependencies are also ignored. Searching for packages involves first checking for a match in the local repo index cache, in the order repos are defined. If not found each repo is checked through the hex api for any known versions of the package and the first repo with a version that fits the constraint is used. * add {repos, replace, []} for overriding the global & default repos * add hex auth handling for repos (#1874) auth token are kept in a hex.config file that is modified by the rebar3 hex plugin. Repo names that have a : separating a parent and child are considered organizations. The parent repo's auth will be included with the child. So an organization named hexpm:rebar3_test will include any hexpm auth tokens found in the rebar3_test organization's configuration. * move packages to top level of of hexpm cache dir (#1876) * move packages to top level of of hexpm cache dir * append organization name to parent's repo_url when parsing repos * only eval config scripts and apply overrides once per app (#1879) * only eval config scripts and apply overrides once per app * move new resource behaviour to rebar_resource_v2 and keep v1 * cleanup use of rebar_resource module and unused functions * cleanup error messages and unused code * when discovering apps support mix packages as unbuilt apps (#1882) * use hex_core tarball unpacking support in pkg resource (#1883) * use hex_core tarball unpacking support in pkg resource * ignore etag if package doesn't exist and delete if checksum fails * add back tests for bad package checksums * improve bad registry checksum error message
6 роки тому
10 роки тому
10 роки тому
support for hex v2, multiple repository fetching, private organizations (#1884) * update to hex_core for hex-v2 repo support (#1865) * update to hex_core for hex-v2 repo support This patch adds only single repo hex-v2 support through hex_core. Packages no longer filtered out by buildtool metadata and the package index is updated per-package instead of fetched as one large ets dump. * tell travis to also build hex_core branch * support list of repos for hex packages (#1866) * support list of repos for hex packages repos are defined under the hex key in rebar configs. They can be defined at the top level of a project or globally, but not in profiles and the repos configured in dependencies are also ignored. Searching for packages involves first checking for a match in the local repo index cache, in the order repos are defined. If not found each repo is checked through the hex api for any known versions of the package and the first repo with a version that fits the constraint is used. * add {repos, replace, []} for overriding the global & default repos * add hex auth handling for repos (#1874) auth token are kept in a hex.config file that is modified by the rebar3 hex plugin. Repo names that have a : separating a parent and child are considered organizations. The parent repo's auth will be included with the child. So an organization named hexpm:rebar3_test will include any hexpm auth tokens found in the rebar3_test organization's configuration. * move packages to top level of of hexpm cache dir (#1876) * move packages to top level of of hexpm cache dir * append organization name to parent's repo_url when parsing repos * only eval config scripts and apply overrides once per app (#1879) * only eval config scripts and apply overrides once per app * move new resource behaviour to rebar_resource_v2 and keep v1 * cleanup use of rebar_resource module and unused functions * cleanup error messages and unused code * when discovering apps support mix packages as unbuilt apps (#1882) * use hex_core tarball unpacking support in pkg resource (#1883) * use hex_core tarball unpacking support in pkg resource * ignore etag if package doesn't exist and delete if checksum fails * add back tests for bad package checksums * improve bad registry checksum error message
6 роки тому
10 роки тому
  1. -module(rebar_prv_deps).
  2. -behaviour(provider).
  3. -export([init/1,
  4. do/1,
  5. format_error/1]).
  6. -include("rebar.hrl").
  7. -define(PROVIDER, deps).
  8. -define(DEPS, [app_discovery]).
  9. -spec init(rebar_state:t()) -> {ok, rebar_state:t()}.
  10. init(State) ->
  11. State1 = rebar_state:add_provider(
  12. State,
  13. providers:create([
  14. {name, ?PROVIDER},
  15. {module, ?MODULE},
  16. {bare, true},
  17. {deps, ?DEPS},
  18. {example, "rebar3 deps"},
  19. {short_desc, "List dependencies"},
  20. {desc, "List dependencies. Those not matching lock files "
  21. "are followed by an asterisk (*)."},
  22. {opts, []}])),
  23. {ok, State1}.
  24. -spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}.
  25. do(State) ->
  26. Profiles = rebar_state:current_profiles(State),
  27. List = [{Profile, rebar_state:get(State, {deps, Profile}, [])}
  28. || Profile <- Profiles],
  29. [display(State, Profile, Deps) || {Profile, Deps} <- List],
  30. {ok, State}.
  31. -spec format_error(any()) -> iolist().
  32. format_error(Reason) ->
  33. io_lib:format("~p", [Reason]).
  34. display(State, default, Deps) ->
  35. NewDeps = merge(Deps, rebar_state:get(State, deps, [])),
  36. display_deps(State, NewDeps),
  37. ?CONSOLE("", []);
  38. display(State, Profile, Deps) ->
  39. ?CONSOLE("-- ~p --", [Profile]),
  40. display_deps(State, Deps),
  41. ?CONSOLE("", []).
  42. merge(Deps, SourceDeps) ->
  43. merge1(dedup([normalize(Dep) || Dep <- Deps]),
  44. [normalize(Dep) || Dep <- SourceDeps]).
  45. normalize(Name) when is_binary(Name) ->
  46. Name;
  47. normalize(Name) when is_atom(Name) ->
  48. atom_to_binary(Name, unicode);
  49. normalize(Dep) when is_tuple(Dep) ->
  50. Name = element(1, Dep),
  51. setelement(1, Dep, normalize(Name)).
  52. merge1(Deps, SourceDeps) ->
  53. Names = [name(Dep) || Dep <- Deps],
  54. ToAdd = [Dep || Dep <- SourceDeps,
  55. not lists:member(name(Dep), Names)],
  56. Deps ++ ToAdd.
  57. %% Keep the latter one as locks come after regular deps in the list.
  58. %% This is totally not safe as an assumption, but it's what we got.
  59. %% We do this by comparing the current element and looking if a
  60. %% similar named one happens later. If so, drop the current one.
  61. dedup(Deps) -> dedup(Deps, [name(Dep) || Dep <- Deps]).
  62. dedup([], []) -> [];
  63. dedup([Dep|Deps], [Name|DepNames]) ->
  64. case lists:member(Name, DepNames) of
  65. true -> dedup(Deps, DepNames);
  66. false -> [Dep | dedup(Deps, DepNames)]
  67. end.
  68. name(T) when is_tuple(T) -> element(1, T);
  69. name(B) when is_binary(B) -> B.
  70. display_deps(State, Deps) ->
  71. lists:foreach(fun(Dep) -> display_dep(State, Dep) end, Deps).
  72. %% packages
  73. display_dep(_State, {Name, Vsn}) when is_list(Vsn) ->
  74. ?CONSOLE("~ts* (package ~ts)", [rebar_utils:to_binary(Name), rebar_utils:to_binary(Vsn)]);
  75. display_dep(_State, Name) when is_binary(Name) ->
  76. ?CONSOLE("~ts* (package)", [Name]);
  77. display_dep(_State, {Name, Source}) when is_tuple(Source) ->
  78. ?CONSOLE("~ts* (~ts source)", [rebar_utils:to_binary(Name), type(Source)]);
  79. display_dep(_State, {Name, _Vsn, Source}) when is_tuple(Source) ->
  80. ?CONSOLE("~ts* (~ts source)", [rebar_utils:to_binary(Name), type(Source)]);
  81. display_dep(_State, {Name, _Vsn, Source, _Opts}) when is_tuple(Source) ->
  82. ?CONSOLE("~ts* (~ts source)", [rebar_utils:to_binary(Name), type(Source)]);
  83. %% Locked
  84. display_dep(State, {Name, _Source={pkg, _, Vsn}, Level}) when is_integer(Level) ->
  85. DepsDir = rebar_dir:deps_dir(State),
  86. AppDir = filename:join([DepsDir, rebar_utils:to_binary(Name)]),
  87. {ok, AppInfo} = rebar_app_info:discover(AppDir),
  88. NeedsUpdate = case rebar_fetch:needs_update(AppInfo, State) of
  89. true -> "*";
  90. false -> ""
  91. end,
  92. ?CONSOLE("~ts~ts (locked package ~ts)", [Name, NeedsUpdate, Vsn]);
  93. display_dep(State, {Name, Source, Level}) when is_tuple(Source), is_integer(Level) ->
  94. DepsDir = rebar_dir:deps_dir(State),
  95. AppDir = filename:join([DepsDir, rebar_utils:to_binary(Name)]),
  96. {ok, AppInfo} = rebar_app_info:discover(AppDir),
  97. NeedsUpdate = case rebar_fetch:needs_update(AppInfo, State) of
  98. true -> "*";
  99. false -> ""
  100. end,
  101. ?CONSOLE("~ts~ts (locked ~ts source)", [Name, NeedsUpdate, type(Source)]).
  102. type(Source) when is_tuple(Source) -> element(1, Source).