Skip to content

Commit

Permalink
Remove deprecations and up requirements
Browse files Browse the repository at this point in the history
New minimum:

- Elixir 1.7
- Ecto 3.0
- Phoenix 1.4
  • Loading branch information
danschultzer committed Mar 12, 2019
1 parent 58353ff commit 44257eb
Show file tree
Hide file tree
Showing 14 changed files with 24 additions and 241 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ env:
- MIX_ENV=test
matrix:
include:
- elixir: 1.6
- elixir: 1.7
otp_release: 20.0
- elixir: 1.8
otp_release: 21.0
Expand Down
60 changes: 8 additions & 52 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,60 +1,16 @@
# Changelog

## v1.0.4 (TBA)

* Added `PowInvitation` to the `mix pow.extension.phoenix.gen.templates` and `mix pow.extension.phoenix.mailer.gen.templates` tasks
* Fixed issue in umbrella projects where extensions wasn't found in environment configuration
* Shell instructions will only be printed if the configuration is missing
* Deprecated `Mix.Pow.context_app/0`

## v1.0.3 (2019-03-09)
## v1.1.0 (TBA)

### Changes

* Added `PowInvitation` extension
* Added support in `Pow.Ecto.Schema` for Ecto associations fields
* Added support for adding custom methods with `Pow.Extension.Ecto.Schema` through `__using__/1` macro in extension ecto schema module
* Help information raised with invalid schema arguments for `pow.install`, `pow.ecto.install`, `pow.ecto.gen.migration`, and `pow.ecto.gen.schema` mix tasks
* `PowEmailConfirmation` now redirects unconfirmed users to `after_registration_path/1` or `after_sign_in_path/1` rather than `pow_session_path(conn, :new)`

### Bug fixes

* Correct shell instructions for `mix pow.install` task with custom schema
* Fixed bug in `Pow.Extension.Phoenix.Router.Base` and `Pow.Extension.Phoenix.Messages` where the full extension name wasn't used to namespace methods
- Requires Elixir 1.7 or higher
- Requires Ecto 3.0 or higher
- Requires Phoenix 1.4 or higher

### Deprecations

* Deprecated `Pow.Extension.Config.underscore_extension/1`
* Deprecated `PowResetPassword.Ecto.Context.password_changeset/2`
* Deprecated `Pow.Ecto.Schema.filter_new_fields/2`
* Deprecated `:messages_backend_fallback` setting for extension controllers
* Removed deprecated macro `router_helpers/1` in `Pow.Phoenix.Controller`

## v1.0.2 (2019-02-28)

* Added flash error message about e-mail confirmation for when user changes e-mail with PowEmailConfirmation enabled
* Added `new_password_changeset/3` and `confirm_password_changeset/3` to `Pow.Ecto.Schema.Changeset`
* Redis cache store backend guide
* Correct shell instructions for `mix pow.phoenix.gen.templates` task
* Only load environment config in `Pow.Config.get/3` when no key is set in the provided config
* Fixed issue in `Pow.Store.Backend.MnesiaCache.keys/1` and `Pow.Store.Backend.EtsCache.keys/1` so they now return keys without namespace
* `Pow.Store.Backend.MnesiaCache.put/3` now raises an error if TTL is not provided

### Breaking changes

* `PowResetPassword.Plug.reset_password_token/1` has been removed

## v1.0.1 (2019-01-27)

* `pow.extension.ecto.gen.migrations` mix task will output warning when a migration file won't be generated for any particular extension
* Leading and trailing whitespace is removed from the user id field value (in addition to forced lower case)
* An exception is raised when `pow_routes/0` or `pow_extension_routes/0` are used inside router scopes with aliases
* Mail view templates assigns now has `[user: user, conn: conn]` along with the template specific assigns
* Mail view subject methods now gets the same assigns passed as mail view template assigns instead of only `[conn: conn]`
* Added `pow_registration_routes/0`, `pow_session_routes/0` and `pow_scope/1` macros to the router module
* Added guide on how to disable registration

## v1.0.0 (2018-11-18)

* Phoenix 1.4 support
* Ecto 3.0 support
- Removed deprecated method `PowResetPassword.Ecto.Context.password_changeset/2`
- Removed deprecated method `Pow.Extension.Config.underscore_extension/1`
- Config fallback set with `:messages_backend_fallback` configuration option removed in `Pow.Extension.Phoenix.Controller.Base`
- Removed deprecated Bootstrap support in `Pow.Phoenix.HTML.FormTemplate`
4 changes: 0 additions & 4 deletions lib/extensions/reset_password/ecto/context.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,4 @@ defmodule PowResetPassword.Ecto.Context do
|> Schema.reset_password_changeset(params)
|> Context.do_update(config)
end

# TODO: Remove by 1.1.0
@deprecated "Use `PowResetPassword.Ecto.Schema.reset_password_changeset/2` instead"
def password_changeset(user, params), do: Schema.reset_password_changeset(user, params)
end
31 changes: 2 additions & 29 deletions lib/mix/pow.ex
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ defmodule Mix.Pow do
"""
@spec ensure_dep!(binary(), atom(), OptionParser.argv()) :: :ok | no_return
def ensure_dep!(task, dep, _args) do
fetch_deps()
[]
|> Dep.load_on_environment()
|> dep_in_deps?(dep)
|> case do
true ->
Expand All @@ -32,16 +33,6 @@ defmodule Mix.Pow do
end
end

# TODO: Remove by 1.1.0 and only support Elixir 1.7
defp fetch_deps do
System.version()
|> Version.match?("~> 1.6.0")
|> case do
true -> apply(Dep, :loaded, [[]])
false -> apply(Dep, :load_on_environment, [[]])
end
end

defp dep_in_deps?(deps, dep) do
Enum.any?(deps, fn
%Mix.Dep{app: ^dep} -> true
Expand Down Expand Up @@ -131,24 +122,6 @@ defmodule Mix.Pow do
""")
end

# TODO: Remove by 1.1.0
@doc false
@deprecated "Please use `Pow.Phoenix.parse_structure/1` instead"
@spec context_app :: atom() | no_return
def context_app do
this_app = otp_app()

this_app
|> Application.get_env(:generators, [])
|> Keyword.get(:context_app)
|> case do
nil -> this_app
false -> Mix.raise("No context_app configured for current application")
{app, _path} -> app
app -> app
end
end

@doc false
@spec otp_app :: atom() | no_return
def otp_app do
Expand Down
14 changes: 2 additions & 12 deletions lib/mix/pow/ecto/migration.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ defmodule Mix.Pow.Ecto.Migration do
@moduledoc """
Utilities module for ecto migrations in mix tasks.
"""
alias Mix.Generator
alias Mix.{EctoSQL, Generator}

@doc """
Creates a migration file for the repo.
Expand All @@ -12,7 +12,7 @@ defmodule Mix.Pow.Ecto.Migration do
base_name = "#{Macro.underscore(name)}.exs"
path =
repo
|> source_repo_priv()
|> EctoSQL.source_repo_priv()
|> Path.join("migrations")
|> maybe_create_directory()
timestamp = timestamp(path)
Expand Down Expand Up @@ -63,14 +63,4 @@ defmodule Mix.Pow.Ecto.Migration do

defp pad(i) when i < 10, do: <<?0, ?0 + i>>
defp pad(i), do: to_string(i)

# TODO: Remove by 1.1.0 and only use Ecto 3.0
defp source_repo_priv(repo) do
mod =
if Pow.dependency_vsn_match?(:ecto, "< 3.0.0"),
do: Mix.Ecto,
else: Mix.EctoSQL

mod.source_repo_priv(repo)
end
end
16 changes: 0 additions & 16 deletions lib/pow.ex
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
defmodule Pow do
@moduledoc false

@doc """
Checks for version requirement in dependencies.
"""
@spec dependency_vsn_match?(atom(), binary()) :: boolean()
def dependency_vsn_match?(dep, req) do
case :application.get_key(dep, :vsn) do
{:ok, actual} ->
actual
|> List.to_string()
|> Version.match?(req)

_any ->
false
end
end
end
4 changes: 0 additions & 4 deletions lib/pow/ecto/schema.ex
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,6 @@ defmodule Pow.Ecto.Schema do
Enum.filter(fields, &not Enum.member?(existing_fields, {elem(&1, 0), elem(&1, 1)}))
end

# TODO: Remove by 1.1.0
@deprecated "No longer public method"
def filter_new_fields(fields, existing_fields), do: __filter_new_fields__(fields, existing_fields)

@doc false
defmacro __register_fields__ do
quote do
Expand Down
16 changes: 0 additions & 16 deletions lib/pow/extension/config.ex
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,4 @@ defmodule Pow.Extension.Config do
|> Enum.map(&Module.concat([&1] ++ module_list))
|> Enum.filter(&Code.ensure_compiled?/1)
end

# TODO: Remove by 1.1.0
@doc """
Returns a binary of the extension atom.
This is usually used to create extension namespaces for methods to be used
in shared modules.
"""
@deprecated "Create the namespace directly in your module"
@spec underscore_extension(atom()) :: binary()
def underscore_extension(extension) do
extension
|> Module.split()
|> List.first()
|> Macro.underscore()
end
end
21 changes: 4 additions & 17 deletions lib/pow/extension/phoenix/controllers/controller/base.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ defmodule Pow.Extension.Phoenix.Controller.Base do
# ...
end
"""
alias Pow.{Config, Phoenix.Controller, Phoenix.Routes}
alias Pow.{Phoenix.Controller, Phoenix.Routes}

@doc false
defmacro __using__(config) do
quote do
use Controller, unquote(config)

unquote(__MODULE__).__define_helper_methods__(unquote(config))
unquote(__MODULE__).__define_helper_methods__()
end
end

@doc false
defmacro __define_helper_methods__(config) do
defmacro __define_helper_methods__() do
quote do
@messages_fallback unquote(__MODULE__).__messages_fallback__(unquote(config), __MODULE__, __ENV__)
@messages_fallback unquote(__MODULE__).__messages_fallback__(__MODULE__)

@doc false
def messages(conn), do: unquote(__MODULE__).__messages_module__(conn, @messages_fallback)
Expand Down Expand Up @@ -54,17 +54,4 @@ defmodule Pow.Extension.Phoenix.Controller.Base do
|> Enum.reverse()
|> Module.concat()
end

# TODO: Remove config fallback by 1.1.0
def __messages_fallback__(config, module, env) do
case Config.get(config, :messages_backend_fallback) do
nil ->
__messages_fallback__(module)

module ->
IO.warn("Passing `:messages_backend_fallback` is deprecated", Macro.Env.stacktrace(env))

module
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ defmodule Pow.Extension.Phoenix.ControllerCallbacks.Base do
@callback before_respond(atom(), atom(), any(), Config.t()) :: any()

@doc false
defmacro __using__(config) do
defmacro __using__(_config) do
quote do
@behaviour unquote(__MODULE__)

import Base, only: [__define_helper_methods__: 1]
import Base, only: [__define_helper_methods__: 0]

__define_helper_methods__(unquote(config))
__define_helper_methods__()

@before_compile unquote(__MODULE__)
end
Expand Down
54 changes: 0 additions & 54 deletions lib/pow/phoenix/html/bootstrap.ex

This file was deleted.

18 changes: 1 addition & 17 deletions lib/pow/phoenix/html/form_template.ex
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
defmodule Pow.Phoenix.HTML.FormTemplate do
@moduledoc """
Module that can build user form templates for Phoenix.
For Phoenix 1.3, or bootstrap templates, `Pow.Phoenix.HTML.Bootstrap` can be
used.
"""
alias Pow.Phoenix.HTML.Bootstrap

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

case bootstrap?(opts) do
true -> Bootstrap.render_form(inputs, button_label)
_any -> render_form(inputs, button_label)
end
end

# TODO: Remove bootstrap support by 1.1.0 and only support Phoenix 1.4.0
defp bootstrap?(opts) do
bootstrap = Pow.dependency_vsn_match?(:phoenix, "~> 1.3.0")

Keyword.get(opts, :bootstrap, bootstrap)
render_form(inputs, button_label)
end

defp render_form(inputs, button_label) do
Expand Down
6 changes: 3 additions & 3 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ defmodule Pow.MixProject do
[
app: :pow,
version: @version,
elixir: "~> 1.6",
elixir: "~> 1.7",
elixirc_paths: elixirc_paths(Mix.env()),
start_permanent: Mix.env() == :prod,
compilers: [:phoenix] ++ Mix.compilers(),
Expand Down Expand Up @@ -35,8 +35,8 @@ defmodule Pow.MixProject do

defp deps do
[
{:ecto, "~> 2.2 or ~> 3.0"},
{:phoenix, "~> 1.3.0 or ~> 1.4.0"},
{:ecto, "~> 3.0"},
{:phoenix, "~> 1.4.0"},
{:phoenix_html, ">= 2.0.0 and <= 3.0.0"},
{:plug, ">= 1.5.0 and < 1.8.0", optional: true},

Expand Down
Loading

0 comments on commit 44257eb

Please sign in to comment.