-
Notifications
You must be signed in to change notification settings - Fork 518
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
Plugin templates #987
Plugin templates #987
Conversation
What do you mean callable only from the top? For plugins using |
Only from the top as in if you
then My scare with |
But you are only looking in plugins, right? That is what I meant about it probably being fine for plugins, they are rebar3 specific already. |
Alright. I can leave it as-is then. I'll try to see how to test this in the upcoming days. |
13dd141
to
5e9a446
Compare
Test added. It doesn't check priorities but eeeh. It otherwise executes a plugin template off a _checkouts directory fine. |
5e9a446
to
9e60021
Compare
IMO: it's fine for templates to only really be usable at the top level (rebar3 new only working right at the top level). The top level project is the one you're working on, (though if you have an apps/component{1,2,3} structure, it working there would be good too). I guess it should work anywhere in the top-level-project repo that is for erlang or related stuff. I think the priority order should be rebar built-in < plugins < my own templates in ~/.config/rebar3. If I've gone to the effort of writing templates in my home dir, I probably want those executed in preference to others (the ability to override/choose which would be great but not required). Plugins probably have a better idea of what people want, and built-ins are the most generic/least specific, so should be the lowest priority (imo, ymmv, etc). |
This lets a plugin define templates to be loaded: $ rebar3 new ... proper (plugin): A basic PropEr suite for an OTP application ... $ rebar3 new help proper proper: plugin template (...) Description: A basic PropEr suite for an OTP application Variables: name="suite" (...) ... → rebar3 new proper fakesuite ===> Writing test/prop_fakesuite.erl In this case, proper is a fake template file I've put by hand in _build/default/plugins/rebar3_proper/priv/<somename>/, meaning it will only work as far as it's called from the project's root. The priority order of plugins is now .config > plugin > built-in, such that someone could ensure plugins do not crush their own private templates, but also that custom or plugin templates do overtake built-in ones. It used to be Built-in > .config only. Templates are searched for recursively in the priv/ directory of plugins.
9e60021
to
44a30ca
Compare
Fixed & Amended. |
This is a proof of concept, untested in practice, that goes and dig in the plugin paths for all plugins of a project's priv/ dir, for .template files the way we do it in ~/.config/rebar3. This lets a plugin define templates to be loaded:
In this case,
proper
is a fake template file I've put by hand in_build/default/plugins/rebar3_proper/priv/<somename>/
, meaning it will only work as far as it's called from the project's root.Things I'd like to figure out:
priv/
for this and rather mandate atemplate/
ortemplates/
directory for pluginsNote: this PR builds on #986, I can rebase it out if wanted.
CC @archaelus