25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

108 lines
3.6 KiB

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 년 전
  1. %%% @doc Packages rebar.hrl features and macros into a more generic API
  2. %%% that can be used by plugin builders.
  3. -module(rebar_api).
  4. -include("rebar.hrl").
  5. -include_lib("providers/include/providers.hrl").
  6. -export([abort/0, abort/2,
  7. console/2,
  8. debug/2, info/2, warn/2, error/2,
  9. expand_env_variable/3,
  10. get_arch/0,
  11. wordsize/0,
  12. set_paths/2,
  13. unset_paths/2,
  14. add_deps_to_path/1,
  15. restore_code_path/1,
  16. processing_base_dir/1,
  17. ssl_opts/1]).
  18. -export_type([rebar_dict/0, rebar_digraph/0]).
  19. %%%%%%%%%%%%%%%%%%%%%%%
  20. %%% Error reporting %%%
  21. %%%%%%%%%%%%%%%%%%%%%%%
  22. %% @doc Interrupts program flow
  23. -spec abort() -> no_return().
  24. abort() -> ?FAIL.
  25. %% @doc like {@link error/2}, except it also raises an
  26. %% exception to interrupt program flow.
  27. -spec abort(string(), list()) -> no_return().
  28. abort(Str, Args) -> ?ABORT(Str, Args).
  29. %% @doc Prints to the console, including a newline
  30. -spec console(string(), list()) -> ok.
  31. console(Str, Args) -> ?CONSOLE(Str, Args).
  32. %% @doc logs with severity `debug'
  33. -spec debug(string(), list()) -> ok.
  34. debug(Str, Args) -> ?DEBUG(Str, Args).
  35. %% @doc logs with severity `info'
  36. -spec info(string(), list()) -> ok.
  37. info(Str, Args) -> ?INFO(Str, Args).
  38. %% @doc logs with severity `warn'
  39. -spec warn(string(), list()) -> ok.
  40. warn(Str, Args) -> ?WARN(Str, Args).
  41. %% @doc logs with severity `error'
  42. -spec error(string(), list()) -> ok.
  43. error(Str, Args) -> ?ERROR(Str, Args).
  44. %% @doc Given env. variable `FOO' we want to expand all references to
  45. %% it in `InStr'. References can have two forms: `$FOO' and `${FOO}'
  46. %% The end of form `$FOO' is delimited with whitespace or EOL
  47. -spec expand_env_variable(string(), string(), term()) -> string().
  48. expand_env_variable(InStr, VarName, RawVarValue) ->
  49. rebar_utils:expand_env_variable(InStr, VarName, RawVarValue).
  50. %% @doc returns the sytem architecture, in strings like
  51. %% `"19.0.4-x86_64-unknown-linux-gnu-64"'.
  52. -spec get_arch() -> string().
  53. get_arch() ->
  54. rebar_utils:get_arch().
  55. %% @doc returns the size of a word on the system, as a string
  56. -spec wordsize() -> string().
  57. wordsize() ->
  58. rebar_utils:wordsize().
  59. %% @doc Set code paths. Takes arguments of the form
  60. %% `[plugins, deps]' or `[deps, plugins]' and ensures the
  61. %% project's app and dependencies are set in the right order
  62. %% for the next bit of execution
  63. -spec set_paths(rebar_paths:targets(), rebar_state:t()) -> ok.
  64. set_paths(List, State) ->
  65. rebar_paths:set_paths(List, State).
  66. %% @doc Unsets code paths. Takes arguments of the form
  67. %% `[plugins, deps]' or `[deps, plugins]' and ensures the
  68. %% paths are no longer active.
  69. -spec unset_paths(rebar_paths:targets(), rebar_state:t()) -> ok.
  70. unset_paths(List, State) ->
  71. rebar_paths:unset_paths(List, State).
  72. %% @doc Add deps to the code path
  73. -spec add_deps_to_path(rebar_state:t()) -> ok.
  74. add_deps_to_path(State) ->
  75. code:add_pathsa(rebar_state:code_paths(State, all_deps)).
  76. %% @doc Revert to only having the beams necessary for running rebar3 and
  77. %% plugins in the path
  78. -spec restore_code_path(rebar_state:t()) -> true | {error, term()}.
  79. restore_code_path(State) ->
  80. rebar_utils:cleanup_code_path(rebar_state:code_paths(State, default)).
  81. %% @doc checks if the current working directory is the base directory
  82. %% for the project.
  83. -spec processing_base_dir(rebar_state:t()) -> boolean().
  84. processing_base_dir(State) ->
  85. rebar_dir:processing_base_dir(State).
  86. %% @doc returns the SSL options adequate for the project based on
  87. %% its configuration, including for validation of certs.
  88. -spec ssl_opts(string()) -> [term()].
  89. ssl_opts(Url) ->
  90. rebar_utils:ssl_opts(Url).