summaryrefslogtreecommitdiff
path: root/test/rebar_new_SUITE_data/plugin_tpl/_checkouts/tpl
diff options
context:
space:
mode:
authorFred Hebert <mononcqc@ferd.ca>2015-12-18 22:44:20 -0500
committerFred Hebert <mononcqc@ferd.ca>2015-12-19 20:16:49 -0500
commit44a30ca52f3c74d19007fd0433f6192fa4ccca79 (patch)
tree12e5be5a54ff9d3bcb692bad3800505f2abe7bae /test/rebar_new_SUITE_data/plugin_tpl/_checkouts/tpl
parentddc64cd66b2d6e4e2315ee281b9eabb8bc2e8868 (diff)
Plugin templates enabled
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.
Diffstat (limited to 'test/rebar_new_SUITE_data/plugin_tpl/_checkouts/tpl')
-rw-r--r--test/rebar_new_SUITE_data/plugin_tpl/_checkouts/tpl/.gitignore19
-rw-r--r--test/rebar_new_SUITE_data/plugin_tpl/_checkouts/tpl/priv/module.erl.dtl2
-rw-r--r--test/rebar_new_SUITE_data/plugin_tpl/_checkouts/tpl/priv/tpl.template7
-rw-r--r--test/rebar_new_SUITE_data/plugin_tpl/_checkouts/tpl/rebar.config2
-rw-r--r--test/rebar_new_SUITE_data/plugin_tpl/_checkouts/tpl/src/tpl.app.src15
-rw-r--r--test/rebar_new_SUITE_data/plugin_tpl/_checkouts/tpl/src/tpl.erl8
-rw-r--r--test/rebar_new_SUITE_data/plugin_tpl/_checkouts/tpl/src/tpl_prv.erl32
7 files changed, 85 insertions, 0 deletions
diff --git a/test/rebar_new_SUITE_data/plugin_tpl/_checkouts/tpl/.gitignore b/test/rebar_new_SUITE_data/plugin_tpl/_checkouts/tpl/.gitignore
new file mode 100644
index 0000000..a939dce
--- /dev/null
+++ b/test/rebar_new_SUITE_data/plugin_tpl/_checkouts/tpl/.gitignore
@@ -0,0 +1,19 @@
+.rebar3
+_*
+.eunit
+*.o
+*.beam
+*.plt
+*.swp
+*.swo
+.erlang.cookie
+ebin
+log
+erl_crash.dump
+.rebar
+_rel
+_deps
+_plugins
+_tdeps
+logs
+_build \ No newline at end of file
diff --git a/test/rebar_new_SUITE_data/plugin_tpl/_checkouts/tpl/priv/module.erl.dtl b/test/rebar_new_SUITE_data/plugin_tpl/_checkouts/tpl/priv/module.erl.dtl
new file mode 100644
index 0000000..9129961
--- /dev/null
+++ b/test/rebar_new_SUITE_data/plugin_tpl/_checkouts/tpl/priv/module.erl.dtl
@@ -0,0 +1,2 @@
+-module({{name}}).
+
diff --git a/test/rebar_new_SUITE_data/plugin_tpl/_checkouts/tpl/priv/tpl.template b/test/rebar_new_SUITE_data/plugin_tpl/_checkouts/tpl/priv/tpl.template
new file mode 100644
index 0000000..7fa4caf
--- /dev/null
+++ b/test/rebar_new_SUITE_data/plugin_tpl/_checkouts/tpl/priv/tpl.template
@@ -0,0 +1,7 @@
+{description, "A basic template"}.
+{variables, [
+ {name, "mod", "Name of the module"}
+]}.
+
+{dir, "test"}.
+{template, "module.erl.dtl", "src/{{name}}.erl"}.
diff --git a/test/rebar_new_SUITE_data/plugin_tpl/_checkouts/tpl/rebar.config b/test/rebar_new_SUITE_data/plugin_tpl/_checkouts/tpl/rebar.config
new file mode 100644
index 0000000..f618f3e
--- /dev/null
+++ b/test/rebar_new_SUITE_data/plugin_tpl/_checkouts/tpl/rebar.config
@@ -0,0 +1,2 @@
+{erl_opts, [debug_info]}.
+{deps, []}. \ No newline at end of file
diff --git a/test/rebar_new_SUITE_data/plugin_tpl/_checkouts/tpl/src/tpl.app.src b/test/rebar_new_SUITE_data/plugin_tpl/_checkouts/tpl/src/tpl.app.src
new file mode 100644
index 0000000..6c6d811
--- /dev/null
+++ b/test/rebar_new_SUITE_data/plugin_tpl/_checkouts/tpl/src/tpl.app.src
@@ -0,0 +1,15 @@
+{application, 'tpl',
+ [{description, "A rebar plugin"},
+ {vsn, "0.1.0"},
+ {registered, []},
+ {applications,
+ [kernel,
+ stdlib
+ ]},
+ {env,[]},
+ {modules, []},
+
+ {contributors, []},
+ {licenses, []},
+ {links, []}
+ ]}.
diff --git a/test/rebar_new_SUITE_data/plugin_tpl/_checkouts/tpl/src/tpl.erl b/test/rebar_new_SUITE_data/plugin_tpl/_checkouts/tpl/src/tpl.erl
new file mode 100644
index 0000000..529bcb8
--- /dev/null
+++ b/test/rebar_new_SUITE_data/plugin_tpl/_checkouts/tpl/src/tpl.erl
@@ -0,0 +1,8 @@
+-module('tpl').
+
+-export([init/1]).
+
+-spec init(rebar_state:t()) -> {ok, rebar_state:t()}.
+init(State) ->
+ {ok, State1} = 'tpl_prv':init(State),
+ {ok, State1}.
diff --git a/test/rebar_new_SUITE_data/plugin_tpl/_checkouts/tpl/src/tpl_prv.erl b/test/rebar_new_SUITE_data/plugin_tpl/_checkouts/tpl/src/tpl_prv.erl
new file mode 100644
index 0000000..c68ffa3
--- /dev/null
+++ b/test/rebar_new_SUITE_data/plugin_tpl/_checkouts/tpl/src/tpl_prv.erl
@@ -0,0 +1,32 @@
+-module('tpl_prv').
+
+-export([init/1, do/1, format_error/1]).
+
+-define(PROVIDER, 'tpl').
+-define(DEPS, [app_discovery]).
+
+%% ===================================================================
+%% Public API
+%% ===================================================================
+-spec init(rebar_state:t()) -> {ok, rebar_state:t()}.
+init(State) ->
+ Provider = providers:create([
+ {name, ?PROVIDER}, % The 'user friendly' name of the task
+ {module, ?MODULE}, % The module implementation of the task
+ {bare, true}, % The task can be run by the user, always true
+ {deps, ?DEPS}, % The list of dependencies
+ {example, "rebar3 tpl"}, % How to use the plugin
+ {opts, []}, % list of options understood by the plugin
+ {short_desc, "A rebar plugin"},
+ {desc, "A rebar plugin"}
+ ]),
+ {ok, rebar_state:add_provider(State, Provider)}.
+
+
+-spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}.
+do(State) ->
+ {ok, State}.
+
+-spec format_error(any()) -> iolist().
+format_error(Reason) ->
+ io_lib:format("~p", [Reason]).