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 17, 2019
1 parent c46cf4c commit 6039e75
Show file tree
Hide file tree
Showing 17 changed files with 28 additions and 303 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
74 changes: 12 additions & 62 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,70 +1,20 @@
# Changelog

## v1.0.5 (TBA)

* Added `extension_messages/1` to extension controllers and callbacks
* Improved feedback for when no templates are generated for an extension with `mix pow.extension.phoenix.gen.templates` and `mix pow.extension.phoenix.mailer.gen.templates` tasks
* Deprecated `Pow.Extension.Ecto.Context.Base`

## v1.0.4 (2019-03-13)

* 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
* Fixed so `:namespace` environment config can be used as web app module name
* Shell instructions will only be printed if the configuration is missing
* Now requires that `:ecto` or `:phoenix` are included in the dependency list for the app to run respective mix tasks
* Deprecated `Mix.Pow.context_app/0`
* Deprecated `Mix.Pow.ensure_dep!/3`
* Deprecated `Mix.Pow.context_base/1`

## 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`
- Removed deprecated method `Mix.Pow.context_app/0`
- Removed deprecated method `Mix.Pow.ensure_dep!/3`
- Removed deprecated method `Mix.Pow.context_base/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`
- Removed deprecated module `Pow.Extension.Ecto.Context.Base`
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 @@ -12,8 +12,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
50 changes: 1 addition & 49 deletions lib/mix/pow.ex
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,6 @@ defmodule Mix.Pow do
:ok
end

# TODO: Remove by 1.1.0
@doc false
@deprecated "Use `ensure_ecto!` or `ensure_phoenix!` instead"
@spec ensure_dep!(binary(), atom(), OptionParser.argv()) :: :ok | no_return
def ensure_dep!(task, dep, _args) do
fetch_deps()
|> top_level_dep_in_deps?(dep)
|> case do
true ->
:ok

false ->
Mix.raise("mix #{task} can only be run inside an application directory that has #{inspect dep} as dependency")
end
end

@doc """
Raises an exception if application doesn't have Ecto as dependency.
"""
Expand All @@ -53,15 +37,7 @@ 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 fetch_deps, do: Dep.load_on_environment([])

@doc """
Raises an exception if application doesn't have Phoenix as dependency.
Expand Down Expand Up @@ -147,36 +123,12 @@ 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
Keyword.fetch!(Mix.Project.config(), :app)
end

# TODO: Remove by 1.1.0
@doc false
@deprecated "Use `app_base/1` instead"
@spec context_base(atom()) :: atom()
def context_base(app), do: app_base(app)

@doc """
Fetches the context base module for the app.
"""
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
15 changes: 0 additions & 15 deletions lib/pow/extension/ecto/context/base.ex

This file was deleted.

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}
alias Pow.Phoenix.Controller

@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 extension_messages(conn), do: unquote(__MODULE__).__messages_module__(conn, @messages_fallback)
Expand All @@ -51,17 +51,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,14 +19,14 @@ 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__)

require Base
require Controller

Base.__define_helper_methods__(unquote(config))
Base.__define_helper_methods__()
Controller.__define_helper_methods__()

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

This file was deleted.

Loading

0 comments on commit 6039e75

Please sign in to comment.