Show the difference of the generators after a Phoenix update: phx.new , phx.gen.auth

Thought I’d post it. It might be useful to others.
I used it to apply the changes to an existing project.

#!/usr/bin/env bash

if [[ $# == 0 ]]; then
  printf "First parameter should be the phoenix version (eg. 1.7.0-rc.0)\n"
  exit 1
else
  phx_version="${1}"
fi

# Create branch 'phoenix_1.7.0-rc.0' of branch 'init'
git checkout -b "phoenix_${phx_version}" init

yes | mix archive.install hex phx_new "${phx_version}"
mix deps.get

mix phx.new . --app hello --module Hello --live --install
git add .
git commit -m "phx.new"

mix phx.gen.auth Accounts User users --live
git add .
git commit -m "phx.gen.auth"

# git diff phoenix_1.7.0-rc.0..phoenix_1.7.0-rc.1
echo "git diff phoenix_1.7.0-rc.0..phoenix_${phx_version}"

./scriptname.sh 1.7.0-rc.0
./scriptname.sh 1.7.0-rc.1
git diff phoenix_1.7.0-rc.0..phoenix_1.7.0-rc.1

I’m interested too, are the changes significant? Could you post them here directly on the forum?

Also, good old hexdiff: phoenix 1.7.0-rc.0..1.7.0-rc.1 | hexdiff

2 Likes

Like this?

diff --git a/README.md b/README.md
index cd33487..2438104 100644
--- a/README.md
+++ b/README.md
@@ -2,8 +2,7 @@
 
 To start your Phoenix server:
 
-  * Install dependencies with `mix deps.get`
-  * Create and migrate your database with `mix ecto.setup`
+  * Run `mix setup` to install and setup dependencies
   * Start Phoenix endpoint with `mix phx.server` or inside IEx with `iex -S mix phx.server`
 
 Now you can visit [`localhost:4000`](http://localhost:4000) from your browser.
diff --git a/assets/tailwind.config.js b/assets/tailwind.config.js
index b611701..e3bf241 100644
--- a/assets/tailwind.config.js
+++ b/assets/tailwind.config.js
@@ -23,4 +23,4 @@ module.exports = {
     plugin(({addVariant}) => addVariant("phx-submit-loading", [".phx-submit-loading&", ".phx-submit-loading &"])),
     plugin(({addVariant}) => addVariant("phx-change-loading", [".phx-change-loading&", ".phx-change-loading &"]))
   ]
-}
\ No newline at end of file
+}
diff --git a/config/config.exs b/config/config.exs
index abe8ce5..6d3d48b 100644
--- a/config/config.exs
+++ b/config/config.exs
@@ -18,7 +18,7 @@ config :hello, HelloWeb.Endpoint,
     layout: false
   ],
   pubsub_server: Hello.PubSub,
-  live_view: [signing_salt: "+0AwugQU"]
+  live_view: [signing_salt: "O6WNa71q"]
 
 # Configures the mailer
 #
@@ -41,7 +41,7 @@ config :esbuild,
 
 # Configure tailwind (the version is required)
 config :tailwind,
-  version: "3.1.8",
+  version: "3.2.4",
   default: [
     args: ~w(
       --config=tailwind.config.js
diff --git a/config/dev.exs b/config/dev.exs
index a31a467..962061d 100644
--- a/config/dev.exs
+++ b/config/dev.exs
@@ -23,7 +23,7 @@ config :hello, HelloWeb.Endpoint,
   check_origin: false,
   code_reloader: true,
   debug_errors: true,
-  secret_key_base: "uQcJbPQYS7tkDlFQTn4wD5sPyVM7H1IIzllBAaSwZUkhvbwuRd9ur82OXulLaoW2",
+  secret_key_base: "kddeDWBfs0rZV5D4YhA/LjrJlzh8gLhClFViB0I95DX1tHfUWV6pgJD3weP7iXEN",
   watchers: [
     esbuild: {Esbuild, :install_and_run, [:default, ~w(--sourcemap=inline --watch)]},
     tailwind: {Tailwind, :install_and_run, [:default, ~w(--watch)]}
@@ -58,8 +58,7 @@ config :hello, HelloWeb.Endpoint,
     patterns: [
       ~r"priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$",
       ~r"priv/gettext/.*(po)$",
-      ~r"lib/hello_web/(live|views)/.*(ex)$",
-      ~r"lib/hello_web/templates/.*(eex)$"
+      ~r"lib/hello_web/(controllers|live|components)/.*(ex|heex)$"
     ]
   ]
 
diff --git a/config/prod.exs b/config/prod.exs
index dddbbcc..4563f1f 100644
--- a/config/prod.exs
+++ b/config/prod.exs
@@ -12,7 +12,7 @@ import Config
 config :hello, HelloWeb.Endpoint, cache_static_manifest: "priv/static/cache_manifest.json"
 
 # Configures Swoosh API Client
-config :swoosh, :api_client, Hello.Finch
+config :swoosh, api_client: Swoosh.ApiClient.Finch, finch_name: Hello.Finch
 
 # Do not print debug messages in production
 config :logger, level: :info
diff --git a/config/test.exs b/config/test.exs
index 696e941..18b01e9 100644
--- a/config/test.exs
+++ b/config/test.exs
@@ -20,7 +20,7 @@ config :hello, Hello.Repo,
 # you can enable the server option below.
 config :hello, HelloWeb.Endpoint,
   http: [ip: {127, 0, 0, 1}, port: 4002],
-  secret_key_base: "WjE36fkYim7ys91aDtDx9I8/99Kk4Uxems8wvDyJKyeOrJJUX1rDzyK4LRtPPXMO",
+  secret_key_base: "UM4bF8fooSIW9TiTgPesMNCowdbA0mCw1OpBOMK+eGHM+tFOcR/JF6zrCq5WLs9o",
   server: false
 
 # In test we don't send emails.
diff --git a/lib/hello_web.ex b/lib/hello_web.ex
index 72d19e7..0de50d8 100644
--- a/lib/hello_web.ex
+++ b/lib/hello_web.ex
@@ -39,7 +39,6 @@ defmodule HelloWeb do
   def controller do
     quote do
       use Phoenix.Controller,
-        namespace: HelloWeb,
         formats: [:html, :json],
         layouts: [html: HelloWeb.Layouts]
 
diff --git a/lib/hello_web/components/core_components.ex b/lib/hello_web/components/core_components.ex
index 47548e7..7ffe282 100644
--- a/lib/hello_web/components/core_components.ex
+++ b/lib/hello_web/components/core_components.ex
@@ -47,7 +47,12 @@ defmodule HelloWeb.CoreComponents do
 
   def modal(assigns) do
     ~H"""
-    <div id={@id} phx-mounted={@show && show_modal(@id)} class="relative z-50 hidden">
+    <div
+      id={@id}
+      phx-mounted={@show && show_modal(@id)}
+      phx-remove={hide_modal(@id)}
+      class="relative z-50 hidden"
+    >
       <div id={"#{@id}-bg"} class="fixed inset-0 bg-zinc-50/90 transition-opacity" aria-hidden="true" />
       <div
         class="fixed inset-0 overflow-y-auto"
@@ -82,7 +87,11 @@ defmodule HelloWeb.CoreComponents do
                   <h1 id={"#{@id}-title"} class="text-lg font-semibold leading-8 text-zinc-800">
                     <%= render_slot(@title) %>
                   </h1>
-                  <p :if={@subtitle != []} class="mt-2 text-sm leading-6 text-zinc-600">
+                  <p
+                    :if={@subtitle != []}
+                    id={"#{@id}-description"}
+                    class="mt-2 text-sm leading-6 text-zinc-600"
+                  >
                     <%= render_slot(@subtitle) %>
                   </p>
                 </header>
@@ -138,7 +147,7 @@ defmodule HelloWeb.CoreComponents do
       :if={msg = render_slot(@inner_block) || Phoenix.Flash.get(@flash, @kind)}
       id={@id}
       phx-mounted={@autoshow && show("##{@id}")}
-      phx-click={JS.push("lv:clear-flash", value: %{key: @kind}) |> hide("#flash")}
+      phx-click={JS.push("lv:clear-flash", value: %{key: @kind}) |> hide("##{@id}")}
       role="alert"
       class={[
         "fixed hidden top-2 right-2 w-80 sm:w-96 z-50 rounded-lg p-3 shadow-md shadow-zinc-900/5 ring-1",
@@ -259,8 +268,8 @@ defmodule HelloWeb.CoreComponents do
   attr :prompt, :string, default: nil, doc: "the prompt for select inputs"
   attr :options, :list, doc: "the options to pass to Phoenix.HTML.Form.options_for_select/2"
   attr :multiple, :boolean, default: false, doc: "the multiple flag for select inputs"
-  attr :rest, :global, include: ~w(autocomplete disabled form max maxlength min minlength
-                                   pattern placeholder readonly required size step)
+  attr :rest, :global, include: ~w(autocomplete cols disabled form max maxlength min minlength
+                                   pattern placeholder readonly required rows size step)
   slot :inner_block
 
   def input(%{field: {f, field}} = assigns) do
@@ -307,7 +316,7 @@ defmodule HelloWeb.CoreComponents do
         multiple={@multiple}
         {@rest}
       >
-        <option :if={@prompt}><%= @prompt %></option>
+        <option :if={@prompt} value=""><%= @prompt %></option>
         <%= Phoenix.HTML.Form.options_for_select(@options, @value) %>
       </select>
       <.error :for={msg <- @errors}><%= msg %></.error>
@@ -330,7 +339,6 @@ defmodule HelloWeb.CoreComponents do
         ]}
         {@rest}
       >
-
     <%= @value %></textarea>
       <.error :for={msg <- @errors}><%= msg %></.error>
     </div>
@@ -568,6 +576,7 @@ defmodule HelloWeb.CoreComponents do
       transition: {"transition-all transform ease-out duration-300", "opacity-0", "opacity-100"}
     )
     |> show("##{id}-container")
+    |> JS.add_class("overflow-hidden", to: "body")
     |> JS.focus_first(to: "##{id}-content")
   end
 
@@ -579,6 +588,7 @@ defmodule HelloWeb.CoreComponents do
     )
     |> hide("##{id}-container")
     |> JS.hide(to: "##{id}", transition: {"block", "block", "hidden"})
+    |> JS.remove_class("overflow-hidden", to: "body")
     |> JS.pop_focus()
   end
 
diff --git a/lib/hello_web/components/layouts/root.html.heex b/lib/hello_web/components/layouts/root.html.heex
index d0eb6a5..a326c3d 100644
--- a/lib/hello_web/components/layouts/root.html.heex
+++ b/lib/hello_web/components/layouts/root.html.heex
@@ -1,5 +1,5 @@
 <!DOCTYPE html>
-<html lang="en">
+<html lang="en" style="scrollbar-gutter: stable;">
   <head>
     <meta charset="utf-8" />
     <meta name="viewport" content="width=device-width, initial-scale=1" />
diff --git a/lib/hello_web/controllers/error_html.ex b/lib/hello_web/controllers/error_html.ex
index aaa5e01..e81802f 100644
--- a/lib/hello_web/controllers/error_html.ex
+++ b/lib/hello_web/controllers/error_html.ex
@@ -5,10 +5,10 @@ defmodule HelloWeb.ErrorHTML do
   # uncomment the embed_templates/1 call below
   # and add pages to the error directory:
   #
-  #   * lib/hello_web/controllers/error/404.html.heex
-  #   * lib/hello_web/controllers/error/500.html.heex
+  #   * lib/hello_web/controllers/error_html/404.html.heex
+  #   * lib/hello_web/controllers/error_html/500.html.heex
   #
-  # embed_templates "error/*"
+  # embed_templates "error_html/*"
 
   # The default is to render a plain text page based on
   # the template name. For example, "404.html" becomes
diff --git a/lib/hello_web/controllers/page_html/home.html.heex b/lib/hello_web/controllers/page_html/home.html.heex
index ca89da6..619f097 100644
--- a/lib/hello_web/controllers/page_html/home.html.heex
+++ b/lib/hello_web/controllers/page_html/home.html.heex
@@ -216,7 +216,7 @@
           </div>
           <div>
             <a
-              href="https://fly.io/docs/getting-started/elixir/"
+              href="https://fly.io/docs/elixir/getting-started/"
               class="group -mx-2 -my-0.5 inline-flex items-center gap-3 rounded-lg px-2 py-0.5 hover:bg-zinc-50 hover:text-zinc-900"
             >
               <svg
diff --git a/lib/hello_web/endpoint.ex b/lib/hello_web/endpoint.ex
index e63e743..c9a1f17 100644
--- a/lib/hello_web/endpoint.ex
+++ b/lib/hello_web/endpoint.ex
@@ -7,7 +7,7 @@ defmodule HelloWeb.Endpoint do
   @session_options [
     store: :cookie,
     key: "_hello_key",
-    signing_salt: "IX8UZ/y0",
+    signing_salt: "S1Jtzvyr",
     same_site: "Lax"
   ]
 
diff --git a/mix.exs b/mix.exs
index a913e73..7ddc5e1 100644
--- a/mix.exs
+++ b/mix.exs
@@ -33,7 +33,7 @@ defmodule Hello.MixProject do
   defp deps do
     [
       {:bcrypt_elixir, "~> 3.0"},
-      {:phoenix, "~> 1.7.0-rc.0", override: true},
+      {:phoenix, "~> 1.7.0-rc.1", override: true},
       {:phoenix_ecto, "~> 4.4"},
       {:ecto_sql, "~> 3.6"},
       {:postgrex, ">= 0.0.0"},
@@ -63,10 +63,11 @@ defmodule Hello.MixProject do
   # See the documentation for `Mix` for more info on aliases.
   defp aliases do
     [
-      setup: ["deps.get", "ecto.setup"],
+      setup: ["deps.get", "ecto.setup", "assets.setup"],
       "ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"],
       "ecto.reset": ["ecto.drop", "ecto.setup"],
       test: ["ecto.create --quiet", "ecto.migrate --quiet", "test"],
+      "assets.setup": ["tailwind.install --if-missing", "esbuild.install --if-missing"],
       "assets.deploy": ["tailwind default --minify", "esbuild default --minify", "phx.digest"]
     ]
   end
diff --git a/priv/repo/migrations/20230107194405_create_users_auth_tables.exs b/priv/repo/migrations/20230107194452_create_users_auth_tables.exs
similarity index 100%
rename from priv/repo/migrations/20230107194405_create_users_auth_tables.exs
rename to priv/repo/migrations/20230107194452_create_users_auth_tables.exs
diff --git a/priv/static/images/phoenix.png b/priv/static/images/phoenix.png
deleted file mode 100644
index 9c81075..0000000
Binary files a/priv/static/images/phoenix.png and /dev/null differ
diff --git a/test/hello_web/controllers/error_html_test.exs b/test/hello_web/controllers/error_html_test.exs
index 8c1de64..23fa55a 100644
--- a/test/hello_web/controllers/error_html_test.exs
+++ b/test/hello_web/controllers/error_html_test.exs
@@ -1,7 +1,7 @@
 defmodule HelloWeb.ErrorHTMLTest do
   use HelloWeb.ConnCase, async: true
 
-  # Bring render_to_string/3 for testing custom views
+  # Bring render_to_string/4 for testing custom views
   import Phoenix.Template
 
   test "renders 404.html" do


1 Like