Skip to content

Commit

Permalink
Merge pull request #65 from fleetyards/depfu/update/elixir/phoenix-1.7.2
Browse files Browse the repository at this point in the history
Upgrade phoenix: 1.6.16 → 1.7.2 (minor)
  • Loading branch information
kloenk authored Apr 2, 2023
2 parents 9847a5b + e41d0c3 commit 109de16
Show file tree
Hide file tree
Showing 66 changed files with 1,502 additions and 621 deletions.
1 change: 1 addition & 0 deletions .formatter.exs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[
inputs: ["mix.exs", "config/*.exs"],
plugins: [Phoenix.LiveView.HTMLFormatter],
subdirectories: ["apps/*"]
]
2 changes: 1 addition & 1 deletion .github/workflows/credo.job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
elixir-version: '1.14.2'
elixir-version: '1.14.3'
otp-version: '25.1'
- name: Restore dependencies cache
uses: actions/cache@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
elixir-version: '1.13.0'
elixir-version: '1.14.3'
otp-version: '25.1'
- name: Restore dependencies cache
uses: actions/cache@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/elixir_build.job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
strategy:
matrix:
otp: ['24.0', '24.3', '25.1']
elixir: ['1.14.2', '1.14.0', '1.13.0']
elixir: ['1.14.2', '1.14.0']
runs-on: ubuntu-latest

services:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/elixir_release.job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
elixir-version: 1.13.0
elixir-version: 1.14.3
otp-version: 25.1
- name: Restore dependencies cache
uses: actions/cache@v3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ defmodule ExFleetYardsApi.ControllerHelpers do
end

defp resource_name(module) do
view = Phoenix.Controller.__view__(module)
view = Phoenix.Controller.__view__(module, [])

view.__resource__
end
Expand Down
5 changes: 3 additions & 2 deletions apps/ex_fleet_yards_api/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ defmodule ExFleetYardsApi.MixProject do
config_path: "../../config/config.exs",
deps_path: "../../deps",
lockfile: "../../mix.lock",
elixir: "~> 1.13",
elixir: "~> 1.14",
elixirc_paths: elixirc_paths(Mix.env()),
compilers: [] ++ Mix.compilers(),
xref: xref(),
Expand All @@ -34,7 +34,8 @@ defmodule ExFleetYardsApi.MixProject do
# Run "mix help deps" to learn about dependencies.
defp deps do
[
{:phoenix, "~> 1.6.11"},
{:phoenix, "~> 1.7.2"},
{:phoenix_view, "~> 2.0"},
{:phoenix_ecto, "~> 4.4"},
{:telemetry_metrics, "~> 0.6"},
{:telemetry_poller, "~> 1.0"},
Expand Down
3 changes: 2 additions & 1 deletion apps/ex_fleet_yards_auth/.formatter.exs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[
import_deps: [:phoenix, :open_api_spex],
inputs: ["*.{ex,exs}", "{config,lib,test}/**/*.{ex,exs}"]
plugins: [Phoenix.LiveView.HTMLFormatter],
inputs: ["*.{ex,exs}", "{config,lib,test}/**/*.{heex,ex,exs}"]
]
73 changes: 46 additions & 27 deletions apps/ex_fleet_yards_auth/lib/ex_fleet_yards_auth.ex
Original file line number Diff line number Diff line change
Expand Up @@ -19,78 +19,97 @@ defmodule ExFleetYardsAuth do

def controller do
quote do
@moduledoc "Controller used for Api"
use Phoenix.Controller, namespace: ExFleetYardsAuth
@moduledoc "Controller used for Auth"
use Phoenix.Controller,
formats: [:html, :json],
layouts: [html: ExFleetYardsAuth.Layouts]

import Plug.Conn

alias ExFleetYards.Repo

alias ExFleetYardsAuth.Router.Helpers, as: Routes
end
end

def view do
quote do
use Phoenix.View,
root: "lib/ex_fleet_yards_auth/templates",
namespace: ExFleetYardsAuth

# Import convenience functions from controllers
import Phoenix.Controller,
only: [view_module: 1, view_template: 1]

# Include shared imports and aliases for views
unquote(view_helpers())
@moduledoc "View module used for api"
unquote(verified_routes())
end
end

def live_view do
quote do
use Phoenix.LiveView,
layout: {ExFleetYardsWeb.LayoutView, "live.html"}
layout: {ExFleetYardsAuth.Layout, :app}

unquote(view_helpers())
unquote(html_helpers())
end
end

def live_component do
quote do
use Phoenix.LiveComponent

unquote(view_helpers())
unquote(html_helpers())
end
end

def component do
def html do
quote do
use Phoenix.Component

unquote(view_helpers())
# Import convenience functions from controllers
import Phoenix.Controller,
only: [get_csrf_token: 0, view_module: 1, view_template: 1]

# Include shared imports and aliases for views
unquote(html_helpers())
@moduledoc "View module used for api"
end
end

def router do
quote do
use Phoenix.Router
use Phoenix.Router, helpers: true

# Import common connection and controller functions to use in pipelines
import Plug.Conn
import Phoenix.Controller
import Phoenix.LiveView.Router
end
end

defp html_helpers() do
quote do
# HTML escaping functionality
import Phoenix.HTML
# Core UI components and translation
import ExFleetYardsAuth.CoreComponents

# Shortcut for generating JS commands
alias Phoenix.LiveView.JS

# Routes generation with the ~p sigil
unquote(verified_routes())
end
end

defp view_helpers() do
quote do
# Import basic rendering functionality (render, render_layout, etc)
import Phoenix.View
import Phoenix.HTML.Tag

# import ExFleetYardsApi.ErrorHelpers

alias ExFleetYardsAuth.Router.Helpers, as: Routes
# import ExFleetYardsAuth.ViewHelpers

unquote(verified_routes())
end
end

def static_paths, do: ~w(assets fonts images favicon.ico favicon.png robots.txt)

def verified_routes do
quote do
use Phoenix.VerifiedRoutes,
endpoint: ExFleetYardsAuth.Endpoint,
router: ExFleetYardsAuth.Router,
statics: ExFleetYardsAuth.static_paths()
end
end

Expand Down
5 changes: 4 additions & 1 deletion apps/ex_fleet_yards_auth/lib/ex_fleet_yards_auth/auth.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
defmodule ExFleetYardsAuth.Auth do
@moduledoc """
Auth helpers
"""
import Plug.Conn
import Phoenix.Controller

Expand Down Expand Up @@ -38,7 +41,7 @@ defmodule ExFleetYardsAuth.Auth do

def log_out_user(conn) do
user_token = get_session(conn, :user_token)
user_token = Account.delete_token(user_token, "auth")
_user_token = Account.delete_token(user_token, "auth")

if live_socket_id = get_session(conn, :live_socket_id) do
ExFleetYardsAuth.Endpoint.broadcast(live_socket_id, "disconnect", %{})
Expand Down
Loading

0 comments on commit 109de16

Please sign in to comment.