Skip to content

Commit

Permalink
Merge pull request #323 from dwyl/phoenix-1.7_fix-#322
Browse files Browse the repository at this point in the history
[PR] Upgrading to Phoenix 1.7
  • Loading branch information
nelsonic authored Feb 28, 2023
2 parents a30aa78 + a83b8cf commit fd74095
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 39 deletions.
6 changes: 3 additions & 3 deletions .formatter.exs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[
import_deps: [:ecto, :phoenix],
subdirectories: ["priv/*/migrations"],
plugins: [Phoenix.LiveView.HTMLFormatter],
inputs: [
"*.{heex,ex,exs}",
"priv/*/seeds.exs",
"{config,lib,test}/**/*.{heex,ex,exs}"
"{config,lib,test}/**/*.{heex,ex,exs}",
"priv/*/seeds.exs"
],
subdirectories: ["priv/*/migrations"],
line_length: 80
]
15 changes: 9 additions & 6 deletions BUILDIT.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,14 +225,17 @@ You should see output similar to the following:

## 1.3 Setup `Tailwind`

As we're using **`Tailwind CSS`**
for the **UI** in this project
we need to enable it.

We are not duplicating the instructions here,
With the release of
[**`Phoenix 1.7`**](https://phoenixframework.org/blog/phoenix-1.7-final-released),
**`Tailwind CSS`** is automatically built-in.
So if you are starting the project with the new
`phx.new` generator,
you don't need to follow any steps.

Otherwise,
please refer to:
[Tailwind in Phoenix](https://github.com/dwyl/learn-tailwind#part-2-tailwind-in-phoenix).
Should only take **`~1 minute`**.
Setting up should only take **`~1 minute`**.

By the end of this step you should have **`Tailwind`** working.
When you visit
Expand Down
24 changes: 0 additions & 24 deletions lib/api/MVP.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,30 +103,6 @@
"endpoint": "<<host>>/api/items",
"params": []
},
{
"body": {
"body": "{\n \"text\": \"some text\",\n \"tags\": [\n {\n \"text\": \"yet another tag\",\n \"color\": \"#FFFFFF\"\n }\n ]\n}",
"contentType": "application/json"
},
"method": "POST",
"testScript": "// Check status code is 400\npw.test(\"Status code is 400\", ()=> {\n pw.expect(pw.response.status).toBe(400);\n});",
"endpoint": "<<host>>/api/items",
"preRequestScript": "",
"auth": {
"authType": "none",
"authActive": true
},
"v": "1",
"headers": [
{
"key": "accept",
"value": "application/json",
"active": true
}
],
"params": [],
"name": "Create item with tags (400 - Tag is malformed)"
},
{
"name": "Create item with tags (400 - Tag is malformed)",
"auth": {
Expand Down
15 changes: 15 additions & 0 deletions lib/app_web.ex
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@ defmodule AppWeb do
and import those modules here.
"""

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

def controller do
quote do
use Phoenix.Controller, namespace: AppWeb

import Plug.Conn
alias AppWeb.Router.Helpers, as: Routes

unquote(verified_routes())
end
end

Expand Down Expand Up @@ -97,6 +101,17 @@ defmodule AppWeb do
import AppWeb.ErrorHelpers
alias AppWeb.Router.Helpers, as: Routes
use PetalComponents

unquote(verified_routes())
end
end

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

Expand Down
2 changes: 1 addition & 1 deletion lib/app_web/endpoint.ex
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ defmodule AppWeb.Endpoint do
at: "/",
from: :app,
gzip: false,
only: ~w(assets fonts images favicon.ico robots.txt)
only: AppWeb.static_paths()

# Code reloading can be explicitly enabled under the
# :code_reloader configuration of your endpoint.
Expand Down
3 changes: 2 additions & 1 deletion lib/app_web/live/app_live.html.heex
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<main class="font-sans container mx-auto">
<.form
:let={_f}
for={:item}
for={%{}}
as={:item}
phx-submit="create"
class="w-full lg:w-1/2 m-auto"
>
Expand Down
4 changes: 2 additions & 2 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ defmodule App.MixProject do
version: "1.0.0",
elixir: "~> 1.14",
elixirc_paths: elixirc_paths(Mix.env()),
compilers: Mix.compilers(),
start_permanent: Mix.env() == :prod,
aliases: aliases(),
deps: deps(),
Expand Down Expand Up @@ -42,13 +41,14 @@ defmodule App.MixProject do
defp deps do
[
# Phoenix deps:
{:phoenix, "~> 1.6.10"},
{:phoenix, "~> 1.7.0"},
{:phoenix_ecto, "~> 4.4"},
{:ecto_sql, "~> 3.6"},
{:postgrex, ">= 0.0.0"},
{:phoenix_html, "~> 3.0"},
{:phoenix_live_reload, "~> 1.2", only: :dev},
{:phoenix_live_view, "~> 0.18.3"},
{:phoenix_view, "~> 2.0"},
{:floki, ">= 0.30.0", only: :test},
{:esbuild, "~> 0.4", runtime: Mix.env() == :dev},
{:telemetry_metrics, "~> 0.6"},
Expand Down
6 changes: 4 additions & 2 deletions mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@
"paper_trail": {:hex, :paper_trail, "1.0.0", "afe08da1b6c07bdd300bfc087a23e22c8706f8649182d3bd549e32427fea7850", [:mix], [{:ecto, ">= 3.9.2", [hex: :ecto, repo: "hexpm", optional: false]}, {:ecto_sql, ">= 3.9.1", [hex: :ecto_sql, repo: "hexpm", optional: false]}], "hexpm", "bbfe0c85f898a478efb508ce340a90acdac6c3b6715470dbc60f99d4ab23af56"},
"parse_trans": {:hex, :parse_trans, "3.3.1", "16328ab840cc09919bd10dab29e431da3af9e9e7e7e6f0089dd5a2d2820011d8", [:rebar3], [], "hexpm", "07cd9577885f56362d414e8c4c4e6bdf10d43a8767abb92d24cbe8b24c54888b"},
"petal_components": {:hex, :petal_components, "1.0.0", "12161b7351501bbd517c1a5ef5486fb1e7d80840f8984d539edad3930eb969f3", [:mix], [{:heroicons, "~> 0.5.0", [hex: :heroicons, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.6", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_ecto, "~> 4.4", [hex: :phoenix_ecto, repo: "hexpm", optional: false]}, {:phoenix_live_view, "~> 0.18.3", [hex: :phoenix_live_view, repo: "hexpm", optional: false]}], "hexpm", "241fe35adf154f747d019ced5cc6c9486f04164a6cff18a398bf80b6f2d5886c"},
"phoenix": {:hex, :phoenix, "1.6.15", "0a1d96bbc10747fd83525370d691953cdb6f3ccbac61aa01b4acb012474b047d", [:mix], [{:castore, ">= 0.0.0", [hex: :castore, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 2.0", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:phoenix_view, "~> 1.0 or ~> 2.0", [hex: :phoenix_view, repo: "hexpm", optional: false]}, {:plug, "~> 1.10", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.2", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:plug_crypto, "~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "d70ab9fbf6b394755ea88b644d34d79d8b146e490973151f248cacd122d20672"},
"phoenix": {:hex, :phoenix, "1.7.0", "cbed113bdc203e2ced75859011fe7e71eeebb6259cefa54de810d9c7048b5e22", [:mix], [{:castore, ">= 0.0.0", [hex: :castore, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 2.1", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:phoenix_template, "~> 1.0", [hex: :phoenix_template, repo: "hexpm", optional: false]}, {:phoenix_view, "~> 2.0", [hex: :phoenix_view, repo: "hexpm", optional: true]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.6", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:plug_crypto, "~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:websock_adapter, "~> 0.4", [hex: :websock_adapter, repo: "hexpm", optional: false]}], "hexpm", "8526139d4bd79ec97c5c3c8e69f6cd663597f782756cec874ba7da5429c93e34"},
"phoenix_ecto": {:hex, :phoenix_ecto, "4.4.0", "0672ed4e4808b3fbed494dded89958e22fb882de47a97634c0b13e7b0b5f7720", [:mix], [{:ecto, "~> 3.3", [hex: :ecto, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.14.2 or ~> 3.0", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:plug, "~> 1.9", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "09864e558ed31ee00bd48fcc1d4fc58ae9678c9e81649075431e69dbabb43cc1"},
"phoenix_html": {:hex, :phoenix_html, "3.3.0", "bf451c71ebdaac8d2f40d3b703435e819ccfbb9ff243140ca3bd10c155f134cc", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "272c5c1533499f0132309936c619186480bafcc2246588f99a69ce85095556ef"},
"phoenix_html": {:hex, :phoenix_html, "3.3.1", "4788757e804a30baac6b3fc9695bf5562465dd3f1da8eb8460ad5b404d9a2178", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "bed1906edd4906a15fd7b412b85b05e521e1f67c9a85418c55999277e553d0d3"},
"phoenix_live_reload": {:hex, :phoenix_live_reload, "1.4.1", "2aff698f5e47369decde4357ba91fc9c37c6487a512b41732818f2204a8ef1d3", [:mix], [{:file_system, "~> 0.2.1 or ~> 0.3", [hex: :file_system, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.4", [hex: :phoenix, repo: "hexpm", optional: false]}], "hexpm", "9bffb834e7ddf08467fe54ae58b5785507aaba6255568ae22b4d46e2bb3615ab"},
"phoenix_live_view": {:hex, :phoenix_live_view, "0.18.15", "58137e648fca9da56d6e931c9c3001f895ff090291052035f395bc958b82f1a5", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix, "~> 1.6.15 or ~> 1.7.0", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 3.3", [hex: :phoenix_html, repo: "hexpm", optional: false]}, {:phoenix_template, "~> 1.0", [hex: :phoenix_template, repo: "hexpm", optional: false]}, {:phoenix_view, "~> 2.0", [hex: :phoenix_view, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.2 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "888dd8ea986bebbda741acc65aef788c384d13db91fea416461b2e96aa06a193"},
"phoenix_pubsub": {:hex, :phoenix_pubsub, "2.1.1", "ba04e489ef03763bf28a17eb2eaddc2c20c6d217e2150a61e3298b0f4c2012b5", [:mix], [], "hexpm", "81367c6d1eea5878ad726be80808eb5a787a23dee699f96e72b1109c57cdd8d9"},
Expand All @@ -70,4 +70,6 @@
"tzdata": {:hex, :tzdata, "1.1.1", "20c8043476dfda8504952d00adac41c6eda23912278add38edc140ae0c5bcc46", [:mix], [{:hackney, "~> 1.17", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm", "a69cec8352eafcd2e198dea28a34113b60fdc6cb57eb5ad65c10292a6ba89787"},
"unicode_util_compat": {:hex, :unicode_util_compat, "0.7.0", "bc84380c9ab48177092f43ac89e4dfa2c6d62b40b8bd132b1059ecc7232f9a78", [:rebar3], [], "hexpm", "25eee6d67df61960cf6a794239566599b09e17e668d3700247bc498638152521"},
"useful": {:hex, :useful, "1.10.0", "a9377b3d8765d28dbb99332f37ab73f5a85706bef918072383957c9294d7bfbc", [:mix], [], "hexpm", "39c5535370943604ee185f46a5d2d9e6956568e48e0120fcda988653b5acbfc3"},
"websock": {:hex, :websock, "0.4.3", "184ac396bdcd3dfceb5b74c17d221af659dd559a95b1b92041ecb51c9b728093", [:mix], [], "hexpm", "5e4dd85f305f43fd3d3e25d70bec4a45228dfed60f0f3b072d8eddff335539cf"},
"websock_adapter": {:hex, :websock_adapter, "0.4.5", "30038a3715067f51a9580562c05a3a8d501126030336ffc6edb53bf57d6d2d26", [:mix], [{:bandit, "~> 0.6", [hex: :bandit, repo: "hexpm", optional: true]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.6", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:websock, "~> 0.4", [hex: :websock, repo: "hexpm", optional: false]}], "hexpm", "1d9812dc7e703c205049426fd4fe0852a247a825f91b099e53dc96f68bafe4c8"},
}
2 changes: 2 additions & 0 deletions test/support/conn_case.ex
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ defmodule AppWeb.ConnCase do

using do
quote do
use AppWeb, :verified_routes

# Import conveniences for testing with connections
import Plug.Conn
import Phoenix.ConnTest
Expand Down

0 comments on commit fd74095

Please sign in to comment.