-
Notifications
You must be signed in to change notification settings - Fork 511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Profiles #31
Profiles #31
Changes from 12 commits
14cb680
bdd5d90
9afd6e8
731f05c
fc2089a
c705f9e
d6e1632
3abb122
5fdf2f8
56fdeda
c4ee53c
5673fe0
3386765
e154b99
fa71d55
8e5c916
31db811
3af351c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
{template, "app.erl.dtl", "{{name}}/{{apps_dir}}/{{name}}/src/{{name}}_app.erl"}. | ||
{template, "sup.erl.dtl", "{{name}}/{{apps_dir}}/{{name}}/src/{{name}}_sup.erl"}. | ||
{template, "otp_app.app.src.dtl", "{{name}}/{{apps_dir}}/{{name}}/src/{{name}}.app.src"}. | ||
{template, "rebar.config.dtl", "{{name}}/rebar.config"}. | ||
{template, "relx_rebar.config.dtl", "{{name}}/rebar.config"}. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's this change for, and should it be adopted at a wider scale? Is this going to be breaking some compatibility, or does it require you to have a specific relx version installed? If there's this config file, is there a reason to still have relx.config? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I didn't, I meant to remove relx.config. This works only for relx within rebar3. If you want to run your own version of relx you have to create the relx.config. But without this you can't use profiles to build a dev vs prod release. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What happens to an existing project that swaps in rebar3 in lieu of rebar and used relx? It keeps working or relx-within-rebar3 starts breaking with this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keeps working. This has worked for a long time just hasn't been the template. rebar3 checks if |
||
{template, "relx.config.dtl", "{{name}}/relx.config"}. | ||
{template, "sys.config.dtl", "{{name}}/config/sys.config"}. | ||
{template, "vm.args.dtl", "{{name}}/config/vm.args"}. | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{erl_opts, [debug_info]}. | ||
{deps, []}. | ||
|
||
{relx, [{release, {'{{name}}', "0.1.0"}, | ||
[{{name}}, | ||
sasl]}, | ||
|
||
{sys_config, "./config/sys.config"}, | ||
{vm_args, "./config/vm.args"}, | ||
|
||
{dev_mode, true}, | ||
{include_erts, false}, | ||
|
||
{extended_start_script, true}] | ||
}. | ||
|
||
{profiles, [{prod, [{relx, [{dev_mode, true}, | ||
{include_erts, false},]}] | ||
}] | ||
}. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,22 +17,13 @@ | |
debug_info, | ||
warnings_as_errors]}. | ||
|
||
%% Types dict:dict() and digraph:digraph() have been introduced in Erlang 17. | ||
%% At the same time, their counterparts dict() and digraph() are to be | ||
%% deprecated in Erlang 18. namespaced_types option is used to select proper | ||
%% type name depending on the OTP version used. | ||
{erl_opts, | ||
[ | ||
{platform_define, "^[0-9]+", namespaced_types} | ||
]}. | ||
|
||
{deps, [ | ||
{erlware_commons, ".*", | ||
{git, "https://github.com/erlware/erlware_commons.git", | ||
{branch, "master"}}}, | ||
{providers, "", | ||
{git, "https://github.com/tsloughter/providers.git", | ||
{branch, "format_error1"}}}, | ||
{branch, "master"}}}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we depend on a tag or something? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea, I'll change it to a tag soon. |
||
{erlydtl, ".*", | ||
{git, "https://github.com/erlydtl/erlydtl.git", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So where does that leave us for backwards compat? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same. That |
||
{tag, "0.9.4"}}}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,15 +74,15 @@ main(Args) -> | |
run(BaseState, Command) -> | ||
_ = application:load(rebar), | ||
BaseState1 = rebar_state:set(BaseState, task, Command), | ||
run_aux(BaseState1, [Command]). | ||
run_aux(BaseState1, [], [Command]). | ||
|
||
%% ==================================================================== | ||
%% Internal functions | ||
%% ==================================================================== | ||
|
||
run(RawArgs) -> | ||
_ = application:load(rebar), | ||
BaseConfig = init_config(), | ||
{GlobalPluginProviders, BaseConfig} = init_config(), | ||
|
||
case erlang:system_info(version) of | ||
"6.1" -> | ||
|
@@ -93,9 +93,9 @@ run(RawArgs) -> | |
end, | ||
|
||
{BaseConfig1, _Args1} = set_options(BaseConfig, {[], []}), | ||
run_aux(BaseConfig1, RawArgs). | ||
run_aux(BaseConfig1, GlobalPluginProviders, RawArgs). | ||
|
||
run_aux(State, RawArgs) -> | ||
run_aux(State, GlobalPluginProviders, RawArgs) -> | ||
%% Make sure crypto is running | ||
case crypto:start() of | ||
ok -> ok; | ||
|
@@ -106,23 +106,28 @@ run_aux(State, RawArgs) -> | |
application:start(ssl), | ||
inets:start(), | ||
|
||
%% Process each command, resetting any state between each one | ||
State2 = case rebar_state:get(State, base_dir, undefined) of | ||
undefined -> | ||
rebar_state:set(State, base_dir, filename:absname(rebar_state:dir(State))); | ||
Dir -> | ||
rebar_state:set(State, base_dir, filename:absname(Dir)) | ||
State2 = case os:getenv("REBAR_DEFAULT_PROFILE") of | ||
false -> | ||
State; | ||
Profile -> | ||
State1 = rebar_state:current_profile(State, list_to_atom(Profile)), | ||
rebar_state:default(State1, rebar_state:opts(State1)) | ||
end, | ||
|
||
{ok, Providers} = application:get_env(rebar, providers), | ||
%% Process each command, resetting any state between each one | ||
BaseDir = rebar_utils:base_dir(State2), | ||
State3 = rebar_state:set(State2, base_dir, | ||
filename:join(filename:absname(rebar_state:dir(State2)), BaseDir)), | ||
|
||
{ok, PluginProviders, State3} = rebar_plugins:install(State2), | ||
rebar_core:update_code_path(State3), | ||
{ok, Providers} = application:get_env(rebar, providers), | ||
{ok, PluginProviders, State4} = rebar_plugins:install(State3), | ||
rebar_core:update_code_path(State4), | ||
|
||
State4 = rebar_state:create_logic_providers(Providers++PluginProviders, State3), | ||
AllProviders = Providers++PluginProviders++GlobalPluginProviders, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm guessing this new difference between 'Providers', 'PluginProviders', and 'GlobalPluginProviders' means:
Am I right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Almost right. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm eager to see how that one will work out. My fear is always that some people will start pushing apps that rely on plugins they didn't package in and stuff breaks near-randomly, or replace proper building by ad-hoc "you have to have plugin I guess it's gonna be a question of discipline so that people who require plugins to build apps do ship them with them, and the plugins about workflow and analytics or whatever can be more global. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea, I agreed and had planned to always have them local until I made the auto compile plugin. |
||
State5 = rebar_state:create_logic_providers(AllProviders, State4), | ||
{Task, Args} = parse_args(RawArgs), | ||
|
||
rebar_core:process_command(rebar_state:command_args(State4, Args), list_to_atom(Task)). | ||
rebar_core:process_command(rebar_state:command_args(State5, Args), list_to_atom(Task)). | ||
|
||
init_config() -> | ||
%% Initialize logging system | ||
|
@@ -150,9 +155,11 @@ init_config() -> | |
true -> | ||
?DEBUG("Load global config file ~p", | ||
[GlobalConfigFile]), | ||
GlobalConfig = rebar_state:new(rebar_config:consult_file(GlobalConfigFile)), | ||
rebar_state:new(GlobalConfig, Config1); | ||
GlobalConfig = rebar_state:new(global, rebar_config:consult_file(GlobalConfigFile)), | ||
{ok, PluginProviders, GlobalConfig1} = rebar_plugins:install(GlobalConfig), | ||
rebar_state:new(GlobalConfig1, Config1); | ||
false -> | ||
PluginProviders = [], | ||
rebar_state:new(Config1) | ||
end, | ||
|
||
|
@@ -168,7 +175,7 @@ init_config() -> | |
|
||
%% TODO: Do we need this still? I think it may still be used. | ||
%% Initialize vsn cache | ||
rebar_state:set(State1, vsn_cache, dict:new()). | ||
{PluginProviders, rebar_state:set(State1, vsn_cache, dict:new())}. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any reason we don't return There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. None of those are in scope... This is returning the globally found plugin providers. |
||
|
||
%% | ||
%% Parse command line arguments using getopt and also filtering out any | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -258,10 +258,5 @@ format_error(AbsSource, Extra, {Mod, Desc}) -> | |
ErrorDesc = Mod:format_error(Desc), | ||
?FMT("~s: ~s~s~n", [AbsSource, Extra, ErrorDesc]). | ||
|
||
maybe_absname(Config, Filename) -> | ||
case rebar_utils:processing_base_dir(Config) of | ||
true -> | ||
Filename; | ||
false -> | ||
filename:absname(Filename) | ||
end. | ||
maybe_absname(_Config, Filename) -> | ||
Filename. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did this suddenly need to go away as a need? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It wasn't sudden, dialyzer caught it. Since we no longer |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,52 +19,45 @@ | |
-spec lock_source(file:filename_all(), rebar_resource:resource()) -> | ||
rebar_resource:resource() | {error, string()}. | ||
lock_source(AppDir, Source) -> | ||
case get_resource_type(Source) of | ||
{error, _}=Error -> | ||
Error; | ||
Module -> | ||
Module:lock(AppDir, Source) | ||
end. | ||
Module = get_resource_type(Source), | ||
Module:lock(AppDir, Source). | ||
|
||
-spec download_source(file:filename_all(), rebar_resource:resource()) -> true | {error, any()}. | ||
download_source(AppDir, Source) -> | ||
case get_resource_type(Source) of | ||
{error, _}=Error -> | ||
Error; | ||
Module -> | ||
TmpDir = ec_file:insecure_mkdtemp(), | ||
AppDir1 = ec_cnv:to_list(AppDir), | ||
ec_file:mkdir_p(AppDir1), | ||
case Module:download(TmpDir, Source) of | ||
{ok, _} -> | ||
code:del_path(filename:absname(filename:join(AppDir1, "ebin"))), | ||
ec_file:remove(filename:absname(AppDir1), [recursive]), | ||
ok = ec_file:copy(TmpDir, filename:absname(AppDir1), [recursive]), | ||
true; | ||
{tarball, File} -> | ||
ok = erl_tar:extract(File, [{cwd, TmpDir} | ||
,compressed]), | ||
BaseName = filename:basename(AppDir1), | ||
[FromDir] = filelib:wildcard(filename:join(TmpDir, BaseName++"-*")), | ||
code:del_path(filename:absname(filename:join(AppDir1, "ebin"))), | ||
ec_file:remove(filename:absname(AppDir1), [recursive]), | ||
ok = ec_file:copy(FromDir, filename:absname(AppDir1), [recursive]), | ||
true | ||
end | ||
try | ||
Module = get_resource_type(Source), | ||
TmpDir = ec_file:insecure_mkdtemp(), | ||
AppDir1 = ec_cnv:to_list(AppDir), | ||
ec_file:mkdir_p(AppDir1), | ||
case Module:download(TmpDir, Source) of | ||
{ok, _} -> | ||
code:del_path(filename:absname(filename:join(AppDir1, "ebin"))), | ||
ec_file:remove(filename:absname(AppDir1), [recursive]), | ||
ok = ec_file:copy(TmpDir, filename:absname(AppDir1), [recursive]), | ||
true; | ||
{tarball, File} -> | ||
ok = erl_tar:extract(File, [{cwd, TmpDir} | ||
,compressed]), | ||
BaseName = filename:basename(AppDir1), | ||
[FromDir] = filelib:wildcard(filename:join(TmpDir, BaseName++"-*")), | ||
code:del_path(filename:absname(filename:join(AppDir1, "ebin"))), | ||
ec_file:remove(filename:absname(AppDir1), [recursive]), | ||
ok = ec_file:copy(FromDir, filename:absname(AppDir1), [recursive]), | ||
true | ||
end | ||
catch | ||
_:E -> | ||
{error, E} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What are we catching here? I'm always wary of these catch alls, and may also prefer we at the very least catch There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea.. It is a pain. So much could go wrong when dealing with the network, the users disk, moving files around. I can change it to |
||
end. | ||
|
||
-spec needs_update(file:filename_all(), rebar_resource:resource()) -> boolean() | {error, string()}. | ||
needs_update(AppDir, Source) -> | ||
case get_resource_type(Source) of | ||
{error, _}=Error -> | ||
Error; | ||
Module -> | ||
try | ||
Module:needs_update(AppDir, Source) | ||
catch | ||
_:_ -> | ||
true | ||
end | ||
Module = get_resource_type(Source), | ||
try | ||
Module:needs_update(AppDir, Source) | ||
catch | ||
_:_ -> | ||
true | ||
end. | ||
|
||
get_resource_type({Type, Location}) -> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -126,12 +126,7 @@ collect_default_refcount() -> | |
build_vsn_string(Vsn, RawRef, RawCount) -> | ||
%% Cleanup the tag and the Ref information. Basically leading 'v's and | ||
%% whitespace needs to go away. | ||
RefTag = case RawRef of | ||
undefined -> | ||
""; | ||
RawRef -> | ||
[".ref", re:replace(RawRef, "\\s", "", [global])] | ||
end, | ||
RefTag = [".ref", re:replace(RawRef, "\\s", "", [global])], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure I got how you got to make sure the reference can never be undefined anymore? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another catch by dialyzer. |
||
Count = erlang:iolist_to_binary(re:replace(RawCount, "\\s", "", [global])), | ||
|
||
%% Create the valid [semver](http://semver.org) version from the tag | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm seeing why it's being done that way, but do the binary packages ship with the source code? Otherwise the demo app doing a search over source might look funny. Also this should require a patch on https://bitbucket.org/ferd/rebar3-todo-plugin to match the tutorial.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They do ship with source code. And yea, I'd have sent a PR if it was on github :P
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah we should just take a note when merging it so that I can go and update it.