Skip to content

Commit 1293479

Browse files
committed
Remove deprecations and up requirements
New minimum: - Elixir 1.7 - Ecto 3.0 - Phoenix 1.4
1 parent 58353ff commit 1293479

File tree

14 files changed

+31
-189
lines changed

14 files changed

+31
-189
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ env:
33
- MIX_ENV=test
44
matrix:
55
include:
6-
- elixir: 1.6
6+
- elixir: 1.7
77
otp_release: 20.0
88
- elixir: 1.8
99
otp_release: 21.0

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
# Changelog
22

3+
## v1.1.0 (TBA)
4+
5+
### Changes
6+
7+
- Requires Elixir 1.7 or higher
8+
- Requires Ecto 3.0 or higher
9+
- Requires Phoenix 1.4 or higher
10+
11+
### Deprecations
12+
13+
- Removed deprecated method `PowResetPassword.Ecto.Context.password_changeset/2`
14+
- Removed deprecated method `Pow.Extension.Config.underscore_extension/1`
15+
- Config fallback set with `:messages_backend_fallback` configuration option removed in `Pow.Extension.Phoenix.Controller.Base`
16+
- Removed deprecated Bootstrap support in `Pow.Phoenix.HTML.FormTemplate`
17+
318
## v1.0.4 (TBA)
419

520
* Added `PowInvitation` to the `mix pow.extension.phoenix.gen.templates` and `mix pow.extension.phoenix.mailer.gen.templates` tasks

lib/extensions/reset_password/ecto/context.ex

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,4 @@ defmodule PowResetPassword.Ecto.Context do
1515
|> Schema.reset_password_changeset(params)
1616
|> Context.do_update(config)
1717
end
18-
19-
# TODO: Remove by 1.1.0
20-
@deprecated "Use `PowResetPassword.Ecto.Schema.reset_password_changeset/2` instead"
21-
def password_changeset(user, params), do: Schema.reset_password_changeset(user, params)
2218
end

lib/mix/pow.ex

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ defmodule Mix.Pow do
2121
"""
2222
@spec ensure_dep!(binary(), atom(), OptionParser.argv()) :: :ok | no_return
2323
def ensure_dep!(task, dep, _args) do
24-
fetch_deps()
24+
[]
25+
|> Dep.load_on_environment()
2526
|> dep_in_deps?(dep)
2627
|> case do
2728
true ->
@@ -32,16 +33,6 @@ defmodule Mix.Pow do
3233
end
3334
end
3435

35-
# TODO: Remove by 1.1.0 and only support Elixir 1.7
36-
defp fetch_deps do
37-
System.version()
38-
|> Version.match?("~> 1.6.0")
39-
|> case do
40-
true -> apply(Dep, :loaded, [[]])
41-
false -> apply(Dep, :load_on_environment, [[]])
42-
end
43-
end
44-
4536
defp dep_in_deps?(deps, dep) do
4637
Enum.any?(deps, fn
4738
%Mix.Dep{app: ^dep} -> true
@@ -131,24 +122,6 @@ defmodule Mix.Pow do
131122
""")
132123
end
133124

134-
# TODO: Remove by 1.1.0
135-
@doc false
136-
@deprecated "Please use `Pow.Phoenix.parse_structure/1` instead"
137-
@spec context_app :: atom() | no_return
138-
def context_app do
139-
this_app = otp_app()
140-
141-
this_app
142-
|> Application.get_env(:generators, [])
143-
|> Keyword.get(:context_app)
144-
|> case do
145-
nil -> this_app
146-
false -> Mix.raise("No context_app configured for current application")
147-
{app, _path} -> app
148-
app -> app
149-
end
150-
end
151-
152125
@doc false
153126
@spec otp_app :: atom() | no_return
154127
def otp_app do

lib/mix/pow/ecto/migration.ex

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ defmodule Mix.Pow.Ecto.Migration do
22
@moduledoc """
33
Utilities module for ecto migrations in mix tasks.
44
"""
5-
alias Mix.Generator
5+
alias Mix.{EctoSQL, Generator}
66

77
@doc """
88
Creates a migration file for the repo.
@@ -12,7 +12,7 @@ defmodule Mix.Pow.Ecto.Migration do
1212
base_name = "#{Macro.underscore(name)}.exs"
1313
path =
1414
repo
15-
|> source_repo_priv()
15+
|> EctoSQL.source_repo_priv()
1616
|> Path.join("migrations")
1717
|> maybe_create_directory()
1818
timestamp = timestamp(path)
@@ -63,14 +63,4 @@ defmodule Mix.Pow.Ecto.Migration do
6363

6464
defp pad(i) when i < 10, do: <<?0, ?0 + i>>
6565
defp pad(i), do: to_string(i)
66-
67-
# TODO: Remove by 1.1.0 and only use Ecto 3.0
68-
defp source_repo_priv(repo) do
69-
mod =
70-
if Pow.dependency_vsn_match?(:ecto, "< 3.0.0"),
71-
do: Mix.Ecto,
72-
else: Mix.EctoSQL
73-
74-
mod.source_repo_priv(repo)
75-
end
7666
end

lib/pow.ex

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,3 @@
11
defmodule Pow do
22
@moduledoc false
3-
4-
@doc """
5-
Checks for version requirement in dependencies.
6-
"""
7-
@spec dependency_vsn_match?(atom(), binary()) :: boolean()
8-
def dependency_vsn_match?(dep, req) do
9-
case :application.get_key(dep, :vsn) do
10-
{:ok, actual} ->
11-
actual
12-
|> List.to_string()
13-
|> Version.match?(req)
14-
15-
_any ->
16-
false
17-
end
18-
end
193
end

lib/pow/ecto/schema.ex

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,6 @@ defmodule Pow.Ecto.Schema do
215215
Enum.filter(fields, &not Enum.member?(existing_fields, {elem(&1, 0), elem(&1, 1)}))
216216
end
217217

218-
# TODO: Remove by 1.1.0
219-
@deprecated "No longer public method"
220-
def filter_new_fields(fields, existing_fields), do: __filter_new_fields__(fields, existing_fields)
221-
222218
@doc false
223219
defmacro __register_fields__ do
224220
quote do

lib/pow/extension/config.ex

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,4 @@ defmodule Pow.Extension.Config do
2525
|> Enum.map(&Module.concat([&1] ++ module_list))
2626
|> Enum.filter(&Code.ensure_compiled?/1)
2727
end
28-
29-
# TODO: Remove by 1.1.0
30-
@doc """
31-
Returns a binary of the extension atom.
32-
33-
This is usually used to create extension namespaces for methods to be used
34-
in shared modules.
35-
"""
36-
@deprecated "Create the namespace directly in your module"
37-
@spec underscore_extension(atom()) :: binary()
38-
def underscore_extension(extension) do
39-
extension
40-
|> Module.split()
41-
|> List.first()
42-
|> Macro.underscore()
43-
end
4428
end

lib/pow/extension/phoenix/controllers/controller/base.ex

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,21 @@ defmodule Pow.Extension.Phoenix.Controller.Base do
1010
# ...
1111
end
1212
"""
13-
alias Pow.{Config, Phoenix.Controller, Phoenix.Routes}
13+
alias Pow.{Phoenix.Controller, Phoenix.Routes}
1414

1515
@doc false
1616
defmacro __using__(config) do
1717
quote do
1818
use Controller, unquote(config)
1919

20-
unquote(__MODULE__).__define_helper_methods__(unquote(config))
20+
unquote(__MODULE__).__define_helper_methods__()
2121
end
2222
end
2323

2424
@doc false
25-
defmacro __define_helper_methods__(config) do
25+
defmacro __define_helper_methods__() do
2626
quote do
27-
@messages_fallback unquote(__MODULE__).__messages_fallback__(unquote(config), __MODULE__, __ENV__)
27+
@messages_fallback unquote(__MODULE__).__messages_fallback__(__MODULE__)
2828

2929
@doc false
3030
def messages(conn), do: unquote(__MODULE__).__messages_module__(conn, @messages_fallback)
@@ -54,17 +54,4 @@ defmodule Pow.Extension.Phoenix.Controller.Base do
5454
|> Enum.reverse()
5555
|> Module.concat()
5656
end
57-
58-
# TODO: Remove config fallback by 1.1.0
59-
def __messages_fallback__(config, module, env) do
60-
case Config.get(config, :messages_backend_fallback) do
61-
nil ->
62-
__messages_fallback__(module)
63-
64-
module ->
65-
IO.warn("Passing `:messages_backend_fallback` is deprecated", Macro.Env.stacktrace(env))
66-
67-
module
68-
end
69-
end
7057
end

lib/pow/extension/phoenix/controllers/controller_callbacks/base.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ defmodule Pow.Extension.Phoenix.ControllerCallbacks.Base do
1919
@callback before_respond(atom(), atom(), any(), Config.t()) :: any()
2020

2121
@doc false
22-
defmacro __using__(config) do
22+
defmacro __using__(_config) do
2323
quote do
2424
@behaviour unquote(__MODULE__)
2525

26-
import Base, only: [__define_helper_methods__: 1]
26+
import Base, only: [__define_helper_methods__: 0]
2727

28-
__define_helper_methods__(unquote(config))
28+
__define_helper_methods__()
2929

3030
@before_compile unquote(__MODULE__)
3131
end

lib/pow/phoenix/html/bootstrap.ex

Lines changed: 0 additions & 54 deletions
This file was deleted.

lib/pow/phoenix/html/form_template.ex

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
defmodule Pow.Phoenix.HTML.FormTemplate do
22
@moduledoc """
33
Module that can build user form templates for Phoenix.
4-
5-
For Phoenix 1.3, or bootstrap templates, `Pow.Phoenix.HTML.Bootstrap` can be
6-
used.
74
"""
8-
alias Pow.Phoenix.HTML.Bootstrap
95

106
@template EEx.compile_string(
117
"""
@@ -32,24 +28,12 @@ defmodule Pow.Phoenix.HTML.FormTemplate do
3228
## Options
3329
3430
* `:button_label` - the submit button label, defaults to "Submit".
35-
* `:bootstrap` - to render form as bootstrap, defaults to false with
36-
phoenix 1.4 and true with phoenix 1.3.
3731
"""
3832
@spec render(list(), Keyword.t()) :: Macro.t()
3933
def render(inputs, opts \\ []) do
4034
button_label = Keyword.get(opts, :button_label, "Submit")
4135

42-
case bootstrap?(opts) do
43-
true -> Bootstrap.render_form(inputs, button_label)
44-
_any -> render_form(inputs, button_label)
45-
end
46-
end
47-
48-
# TODO: Remove bootstrap support by 1.1.0 and only support Phoenix 1.4.0
49-
defp bootstrap?(opts) do
50-
bootstrap = Pow.dependency_vsn_match?(:phoenix, "~> 1.3.0")
51-
52-
Keyword.get(opts, :bootstrap, bootstrap)
36+
render_form(inputs, button_label)
5337
end
5438

5539
defp render_form(inputs, button_label) do

mix.exs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ defmodule Pow.MixProject do
77
[
88
app: :pow,
99
version: @version,
10-
elixir: "~> 1.6",
10+
elixir: "~> 1.7",
1111
elixirc_paths: elixirc_paths(Mix.env()),
1212
start_permanent: Mix.env() == :prod,
1313
compilers: [:phoenix] ++ Mix.compilers(),
@@ -35,8 +35,8 @@ defmodule Pow.MixProject do
3535

3636
defp deps do
3737
[
38-
{:ecto, "~> 2.2 or ~> 3.0"},
39-
{:phoenix, "~> 1.3.0 or ~> 1.4.0"},
38+
{:ecto, "~> 3.0"},
39+
{:phoenix, "~> 1.4.0"},
4040
{:phoenix_html, ">= 2.0.0 and <= 3.0.0"},
4141
{:plug, ">= 1.5.0 and < 1.8.0", optional: true},
4242

test/pow/phoenix/html/form_template_test.exs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,4 @@ defmodule Pow.Phoenix.HTML.FormTemplateTest do
1616
assert html =~ "<%= password_input f, :password %>"
1717
assert html =~ "<%= error_tag f, :password %>"
1818
end
19-
20-
test "render/2 with bootstrap" do
21-
html = FormTemplate.render([
22-
{:text, {:changeset, :pow_user_id_field}},
23-
{:password, :password},
24-
{:password, :confirm_password}
25-
], bootstrap: true)
26-
27-
assert html =~ "<div class=\"form-group\">"
28-
assert html =~ "<%= label f, :password, class: \"control-label\" %>"
29-
assert html =~ "<%= password_input f, :password, class: \"form-control\" %>"
30-
assert html =~ "<%= error_tag f, :password %>"
31-
end
3219
end

0 commit comments

Comments
 (0)