summaryrefslogtreecommitdiff
path: root/priv/templates
diff options
context:
space:
mode:
Diffstat (limited to 'priv/templates')
-rw-r--r--priv/templates/LICENSE.dtl2
-rw-r--r--priv/templates/README.md.dtl2
-rw-r--r--priv/templates/app.template11
-rw-r--r--priv/templates/gitignore.dtl6
-rw-r--r--priv/templates/lib.template11
-rw-r--r--priv/templates/mod.erl.dtl4
-rw-r--r--priv/templates/otp_app.app.src.dtl3
-rw-r--r--priv/templates/otp_app.template7
-rw-r--r--priv/templates/otp_lib.app.src.dtl7
-rw-r--r--priv/templates/otp_lib.template7
-rw-r--r--priv/templates/otp_rel.template11
-rw-r--r--priv/templates/plugin.erl.dtl41
-rw-r--r--priv/templates/plugin.template18
-rw-r--r--priv/templates/plugin_README.md.dtl15
-rw-r--r--priv/templates/release.template15
15 files changed, 98 insertions, 62 deletions
diff --git a/priv/templates/LICENSE.dtl b/priv/templates/LICENSE.dtl
index 5ce77ce..41588ab 100644
--- a/priv/templates/LICENSE.dtl
+++ b/priv/templates/LICENSE.dtl
@@ -1,4 +1,4 @@
-Copyright (c) {{copyright_year}}, {{copyright_holder}} <{{author_email}}>.
+Copyright (c) {{copyright_year}}, {{author_name}} <{{author_email}}>.
All rights reserved.
Redistribution and use in source and binary forms, with or without
diff --git a/priv/templates/README.md.dtl b/priv/templates/README.md.dtl
index b2435a8..900fedb 100644
--- a/priv/templates/README.md.dtl
+++ b/priv/templates/README.md.dtl
@@ -1,7 +1,7 @@
{{appid}}
=====
-An Erlang {{appid}} library.
+{{desc}}
Build
-----
diff --git a/priv/templates/app.template b/priv/templates/app.template
new file mode 100644
index 0000000..39ec14a
--- /dev/null
+++ b/priv/templates/app.template
@@ -0,0 +1,11 @@
+{description, "OTP Application"}.
+{variables, [
+ {appid, "mylib", "Name of the OTP application"},
+ {desc, "An OTP application", "Short description of the app"}
+]}.
+{template, "app.erl.dtl", "src/{{appid}}_app.erl"}.
+{template, "otp_app.app.src.dtl", "src/{{appid}}.app.src"}.
+{template, "rebar.config.dtl", "rebar.config"}.
+{template, "gitignore.dtl", ".gitignore"}.
+{template, "LICENSE.dtl", "LICENSE"}.
+{template, "README.md.dtl", "README.md"}.
diff --git a/priv/templates/gitignore.dtl b/priv/templates/gitignore.dtl
index 23123d4..9e09bf1 100644
--- a/priv/templates/gitignore.dtl
+++ b/priv/templates/gitignore.dtl
@@ -1,13 +1,17 @@
_*
.eunit
-deps
*.o
*.beam
*.plt
+*.swp
+*.swo
.erlang.cookie
ebin
log
erl_crash.dump
.rebar
_rel
+_deps
+_plugins
+_tdeps
logs
diff --git a/priv/templates/lib.template b/priv/templates/lib.template
new file mode 100644
index 0000000..3f35945
--- /dev/null
+++ b/priv/templates/lib.template
@@ -0,0 +1,11 @@
+{description, "OTP Library application (no processes)"}.
+{variables, [
+ {appid, "mylib", "Name of the OTP library application"},
+ {desc, "An OTP library", "Short description of the app"}
+]}.
+{template, "mod.erl.dtl", "src/{{appid}}.erl"}.
+{template, "otp_lib.app.src.dtl", "src/{{appid}}.app.src"}.
+{template, "rebar.config.dtl", "rebar.config"}.
+{template, "gitignore.dtl", ".gitignore"}.
+{template, "LICENSE.dtl", "LICENSE"}.
+{template, "README.md.dtl", "README.md"}.
diff --git a/priv/templates/mod.erl.dtl b/priv/templates/mod.erl.dtl
index 1be8186..2453366 100644
--- a/priv/templates/mod.erl.dtl
+++ b/priv/templates/mod.erl.dtl
@@ -1,10 +1,10 @@
-module({{appid}}).
-%% Application callbacks
+%% API exports
-export([]).
%%====================================================================
-%% API
+%% API functions
%%====================================================================
diff --git a/priv/templates/otp_app.app.src.dtl b/priv/templates/otp_app.app.src.dtl
index 0af909f..cd5ac89 100644
--- a/priv/templates/otp_app.app.src.dtl
+++ b/priv/templates/otp_app.app.src.dtl
@@ -1,6 +1,5 @@
{application, {{appid}},
- [
- {description, "{{appid}}"}
+ [{description, "{{desc}}"}
,{vsn, "0.1.0"}
,{registered, []}
,{mod, {'{{appid}}_app', []}}
diff --git a/priv/templates/otp_app.template b/priv/templates/otp_app.template
deleted file mode 100644
index db31b31..0000000
--- a/priv/templates/otp_app.template
+++ /dev/null
@@ -1,7 +0,0 @@
-{variables, []}.
-{template, "app.erl", "src/{{appid}}_app.erl"}.
-{template, "otp_app.app.src", "src/{{appid}}.app.src"}.
-{template, "rebar.config", "rebar.config"}.
-{template, "gitignore", ".gitignore"}.
-{template, "LICENSE", "LICENSE"}.
-{template, "README.md", "README.md"}.
diff --git a/priv/templates/otp_lib.app.src.dtl b/priv/templates/otp_lib.app.src.dtl
index 5192af7..53ebbb0 100644
--- a/priv/templates/otp_lib.app.src.dtl
+++ b/priv/templates/otp_lib.app.src.dtl
@@ -1,12 +1,9 @@
{application, {{appid}},
- [
- {description, "{{appid}}"}
+ [{description, "{{desc}}"}
,{vsn, "0.1.0"}
,{registered, []}
,{applications,
- [kernel
- ,stdlib
- ]}
+ [kernel,stdlib]}
,{env,[]}
,{modules, []}
]}.
diff --git a/priv/templates/otp_lib.template b/priv/templates/otp_lib.template
deleted file mode 100644
index 19d7593..0000000
--- a/priv/templates/otp_lib.template
+++ /dev/null
@@ -1,7 +0,0 @@
-{variables, []}.
-{template, "mod.erl", "src/{{appid}}.erl"}.
-{template, "otp_lib.app.src", "src/{{appid}}.app.src"}.
-{template, "rebar.config", "rebar.config"}.
-{template, "gitignore", ".gitignore"}.
-{template, "LICENSE", "LICENSE"}.
-{template, "README.md", "README.md"}.
diff --git a/priv/templates/otp_rel.template b/priv/templates/otp_rel.template
deleted file mode 100644
index b75c1da..0000000
--- a/priv/templates/otp_rel.template
+++ /dev/null
@@ -1,11 +0,0 @@
-{variables, []}.
-{template, "app.erl", "apps/{{appid}}/src/{{appid}}_app.erl"}.
-{template, "sup.erl", "apps/{{appid}}/src/{{appid}}_sup.erl"}.
-{template, "otp_app.app.src", "apps/{{appid}}/src/{{appid}}.app.src"}.
-{template, "rebar.config", "rebar.config"}.
-{template, "relx.config", "relx.config"}.
-{template, "sys.config", "config/sys.config"}.
-{template, "vm.args", "config/vm.args"}.
-{template, "gitignore", ".gitignore"}.
-{template, "LICENSE", "LICENSE"}.
-{template, "README.md", "README.md"}.
diff --git a/priv/templates/plugin.erl.dtl b/priv/templates/plugin.erl.dtl
index 80a03bb..e51763b 100644
--- a/priv/templates/plugin.erl.dtl
+++ b/priv/templates/plugin.erl.dtl
@@ -1,29 +1,36 @@
-module({{appid}}).
+-behaviour(provider).
--behaviour(rebar_provider).
+-export([init/1, do/1, format_error/2]).
--export([init/1,
- do/1]).
+-include_lib("rebar3/include/rebar.hrl").
--define(PROVIDER, {{appid}}).
--define(DEPS, []).
+-define(PROVIDER, todo).
+-define(DEPS, [app_discovery]).
%% ===================================================================
%% Public API
%% ===================================================================
-
-spec init(rebar_state:t()) -> {ok, rebar_state:t()}.
init(State) ->
- State1 = rebar_state:add_provider(State, rebar_provider:create([{name, ?PROVIDER},
- {provider_impl, ?MODULE},
- {bare, false},
- {deps, ?DEPS},
- {example, "rebar {{appid}}"},
- {short_desc, "{{appid}} plugin."},
- {desc, ""},
- {opts, []}])),
- {ok, State1}.
-
--spec do(rebar_state:t()) -> {ok, rebar_state:t()}.
+ 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, "rebar {{appid}}"}, % How to use the plugin
+ {opts, []} % list of options understood by the plugin
+ {short_desc, {{desc}}},
+ {desc, ""}
+ ]),
+ {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(), rebar_state:t()) -> {iolist(), rebar_state:t()}.
+format_error(Reason, State) ->
+ {io_lib:format("~p", [Reason]), State}.
+
diff --git a/priv/templates/plugin.template b/priv/templates/plugin.template
index bc44863..7235b60 100644
--- a/priv/templates/plugin.template
+++ b/priv/templates/plugin.template
@@ -1,7 +1,11 @@
-{variables, []}.
-{template, "plugin.erl", "src/{{appid}}.erl"}.
-{template, "otp_lib.app.src", "src/{{appid}}.app.src"}.
-{template, "rebar.config", "rebar.config"}.
-{template, "gitignore", ".gitignore"}.
-{template, "LICENSE", "LICENSE"}.
-{template, "plugin_README.md", "README.md"}.
+{description, "Rebar3 plugin"}.
+{variables, [
+ {appid, "myplugin", "Name of the plugin"},
+ {desc, "A rebar plugin", "Short description of the plugin's purpose"}
+]}.
+{template, "plugin.erl.dtl", "src/{{appid}}.erl"}.
+{template, "otp_lib.app.src.dtl", "src/{{appid}}.app.src"}.
+{template, "rebar.config.dtl", "rebar.config"}.
+{template, "gitignore.dtl", ".gitignore"}.
+{template, "LICENSE.dtl", "LICENSE"}.
+{template, "plugin_README.md.dtl", "README.md"}.
diff --git a/priv/templates/plugin_README.md.dtl b/priv/templates/plugin_README.md.dtl
index 19990f5..c784324 100644
--- a/priv/templates/plugin_README.md.dtl
+++ b/priv/templates/plugin_README.md.dtl
@@ -1,7 +1,7 @@
{{appid}}
=====
-Rebar3 plugin
+{{desc}}
Build
-----
@@ -11,4 +11,17 @@ Build
Use
---
+Add the plugin to your rebar config:
+
+ {plugins, [
+ { {{appid}}, ".*", {git, "git@host:user/{{appid}}.git", {tag, "0.1.0"}}}
+ ]}.
+
+Then just call your plugin directly in an existing application:
+
+
$ rebar3 {{appid}}
+ ===> Fetching {{appid}}
+ Cloning into '.tmp_dir539136867963'...
+ ===> Compiling {{appid}}
+ <Plugin Output>
diff --git a/priv/templates/release.template b/priv/templates/release.template
new file mode 100644
index 0000000..5e3ba1a
--- /dev/null
+++ b/priv/templates/release.template
@@ -0,0 +1,15 @@
+{description, "OTP Release structure for executable programs"}.
+{variables, [
+ {appid, "myapp", "Name of the OTP release. An app with this name will also be created."},
+ {desc, "An OTP application", "Short description of the release's main app's purpose"}
+]}.
+{template, "app.erl.dtl", "{{apps_dir}}/{{appid}}/src/{{appid}}_app.erl"}.
+{template, "sup.erl.dtl", "{{apps_dir}}/{{appid}}/src/{{appid}}_sup.erl"}.
+{template, "otp_app.app.src.dtl", "{{apps_dir}}/{{appid}}/src/{{appid}}.app.src"}.
+{template, "rebar.config.dtl", "rebar.config"}.
+{template, "relx.config.dtl", "relx.config"}.
+{template, "sys.config.dtl", "config/sys.config"}.
+{template, "vm.args.dtl", "config/vm.args"}.
+{template, "gitignore.dtl", ".gitignore"}.
+{template, "LICENSE.dtl", "LICENSE"}.
+{template, "README.md.dtl", "README.md"}.