Skip to content

Commit

Permalink
Support lliveview 1.0 (#761)
Browse files Browse the repository at this point in the history
* Support LV 1.0

* Add :ignore_when option to patchers and update phx_new to 1.7.19

* Remove unused code spotted by Elixir 1.18

* Update CI config
  • Loading branch information
msaraiva authored Feb 14, 2025
1 parent 14d6d6f commit 14d1738
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 37 deletions.
15 changes: 10 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@ jobs:
matrix:
include:
- elixir: '1.13.4'
otp: '24.0'
otp: '25.0'
blend: phoenix_live_view_0_19
- elixir: '1.13.4'
otp: '25.0'
run_plugin_tests: true
warnings_as_errors: true
- elixir: '1.14.0'
blend: phoenix_live_view_0_20
- elixir: '1.14.1'
otp: '25.0'
run_plugin_tests: true
run_integration_tests: true
Expand All @@ -45,7 +44,13 @@ jobs:
run_plugin_tests: true
run_integration_tests: true
warnings_as_errors: true
- elixir: '1.17.0'
- elixir: '1.18.0'
otp: '27.0.1'
check_formatted: true
run_plugin_tests: true
run_integration_tests: true
warnings_as_errors: true
- elixir: '1.18.0'
otp: '27.0.1'
update_deps: true
run_plugin_tests: true
Expand Down
4 changes: 2 additions & 2 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
erlang 27.0.1
elixir 1.17.2-otp-27
erlang 27.2.2
elixir 1.18.2-otp-27
3 changes: 2 additions & 1 deletion blend.exs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
%{
phoenix_live_view_0_19: [{:phoenix_live_view, "~> 0.19.0"}]
phoenix_live_view_0_19: [{:phoenix_live_view, "~> 0.19.0"}],
phoenix_live_view_0_20: [{:phoenix_live_view, "~> 0.20.10"}]
}
24 changes: 24 additions & 0 deletions blend/phoenix_live_view_0_20.mix.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
%{
"blend": {:hex, :blend, "0.3.0", "ba12054cd0d9e4235285e72017f04c3678058c7d293212e699d17f59e52340de", [:mix], [], "hexpm", "0a4b17a1acfe5d6dad7df8173b7ba89c92f3f3e02416dd3321b85262117ebfd8"},
"castore": {:hex, :castore, "1.0.11", "4bbd584741601eb658007339ea730b082cc61f3554cf2e8f39bf693a11b49073", [:mix], [], "hexpm", "e03990b4db988df56262852f20de0f659871c35154691427a5047f4967a16a62"},
"earmark_parser": {:hex, :earmark_parser, "1.4.43", "34b2f401fe473080e39ff2b90feb8ddfeef7639f8ee0bbf71bb41911831d77c5", [:mix], [], "hexpm", "970a3cd19503f5e8e527a190662be2cee5d98eed1ff72ed9b3d1a3d466692de8"},
"ex_doc": {:hex, :ex_doc, "0.37.1", "65ca30d242082b95aa852b3b73c9d9914279fff56db5dc7b3859be5504417980", [:mix], [{:earmark_parser, "~> 1.4.42", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "6774f75477733ea88ce861476db031f9399c110640752ca2b400dbbb50491224"},
"floki": {:hex, :floki, "0.37.0", "b83e0280bbc6372f2a403b2848013650b16640cd2470aea6701f0632223d719e", [:mix], [], "hexpm", "516a0c15a69f78c47dc8e0b9b3724b29608aa6619379f91b1ffa47109b5d0dd3"},
"jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"},
"makeup": {:hex, :makeup, "1.2.1", "e90ac1c65589ef354378def3ba19d401e739ee7ee06fb47f94c687016e3713d1", [:mix], [{:nimble_parsec, "~> 1.4", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "d36484867b0bae0fea568d10131197a4c2e47056a6fbe84922bf6ba71c8d17ce"},
"makeup_elixir": {:hex, :makeup_elixir, "1.0.1", "e928a4f984e795e41e3abd27bfc09f51db16ab8ba1aebdba2b3a575437efafc2", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "7284900d412a3e5cfd97fdaed4f5ed389b8f2b4cb49efc0eb3bd10e2febf9507"},
"makeup_erlang": {:hex, :makeup_erlang, "1.0.2", "03e1804074b3aa64d5fad7aa64601ed0fb395337b982d9bcf04029d68d51b6a7", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "af33ff7ef368d5893e4a267933e7744e46ce3cf1f61e2dccf53a111ed3aa3727"},
"mime": {:hex, :mime, "2.0.6", "8f18486773d9b15f95f4f4f1e39b710045fa1de891fada4516559967276e4dc2", [:mix], [], "hexpm", "c9945363a6b26d747389aac3643f8e0e09d30499a138ad64fe8fd1d13d9b153e"},
"nimble_parsec": {:hex, :nimble_parsec, "1.4.2", "8efba0122db06df95bfaa78f791344a89352ba04baedd3849593bfce4d0dc1c6", [:mix], [], "hexpm", "4b21398942dda052b403bbe1da991ccd03a053668d147d53fb8c4e0efe09c973"},
"phoenix": {:hex, :phoenix, "1.7.19", "36617efe5afbd821099a8b994ff4618a340a5bfb25531a1802c4d4c634017a57", [: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.7", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:plug_crypto, "~> 1.2 or ~> 2.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:websock_adapter, "~> 0.5.3", [hex: :websock_adapter, repo: "hexpm", optional: false]}], "hexpm", "ba4dc14458278773f905f8ae6c2ec743d52c3a35b6b353733f64f02dfe096cd6"},
"phoenix_html": {:hex, :phoenix_html, "4.2.0", "83a4d351b66f472ebcce242e4ae48af1b781866f00ef0eb34c15030d4e2069ac", [:mix], [], "hexpm", "9713b3f238d07043583a94296cc4bbdceacd3b3a6c74667f4df13971e7866ec8"},
"phoenix_live_view": {:hex, :phoenix_live_view, "0.20.17", "f396bbdaf4ba227b82251eb75ac0afa6b3da5e509bc0d030206374237dfc9450", [:mix], [{:floki, "~> 0.36", [hex: :floki, repo: "hexpm", optional: true]}, {: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 or ~> 4.0", [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]}, {:plug, "~> 1.15", [hex: :plug, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.2 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "a61d741ffb78c85fdbca0de084da6a48f8ceb5261a79165b5a0b59e5f65ce98b"},
"phoenix_pubsub": {:hex, :phoenix_pubsub, "2.1.3", "3168d78ba41835aecad272d5e8cd51aa87a7ac9eb836eabc42f6e57538e3731d", [:mix], [], "hexpm", "bba06bc1dcfd8cb086759f0edc94a8ba2bc8896d5331a1e2c2902bf8e36ee502"},
"phoenix_template": {:hex, :phoenix_template, "1.0.4", "e2092c132f3b5e5b2d49c96695342eb36d0ed514c5b252a77048d5969330d639", [:mix], [{:phoenix_html, "~> 2.14.2 or ~> 3.0 or ~> 4.0", [hex: :phoenix_html, repo: "hexpm", optional: true]}], "hexpm", "2c0c81f0e5c6753faf5cca2f229c9709919aba34fab866d3bc05060c9c444206"},
"plug": {:hex, :plug, "1.16.1", "40c74619c12f82736d2214557dedec2e9762029b2438d6d175c5074c933edc9d", [:mix], [{:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2 or ~> 2.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.3 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "a13ff6b9006b03d7e33874945b2755253841b238c34071ed85b0e86057f8cddc"},
"plug_crypto": {:hex, :plug_crypto, "2.1.0", "f44309c2b06d249c27c8d3f65cfe08158ade08418cf540fd4f72d4d6863abb7b", [:mix], [], "hexpm", "131216a4b030b8f8ce0f26038bc4421ae60e4bb95c5cf5395e1421437824c4fa"},
"sourceror": {:hex, :sourceror, "1.7.1", "599d78f4cc2be7d55c9c4fd0a8d772fd0478e3a50e726697c20d13d02aa056d4", [:mix], [], "hexpm", "cd6f268fe29fa00afbc535e215158680a0662b357dc784646d7dff28ac65a0fc"},
"telemetry": {:hex, :telemetry, "1.3.0", "fedebbae410d715cf8e7062c96a1ef32ec22e764197f70cda73d82778d61e7a2", [:rebar3], [], "hexpm", "7015fc8919dbe63764f4b4b87a95b7c0996bd539e0d499be6ec9d7f3875b79e6"},
"websock": {:hex, :websock, "0.5.3", "2f69a6ebe810328555b6fe5c831a851f485e303a7c8ce6c5f675abeb20ebdadc", [:mix], [], "hexpm", "6105453d7fac22c712ad66fab1d45abdf049868f253cf719b625151460b8b453"},
"websock_adapter": {:hex, :websock_adapter, "0.5.8", "3b97dc94e407e2d1fc666b2fb9acf6be81a1798a2602294aac000260a7c4a47d", [:mix], [{:bandit, ">= 0.6.0", [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.5", [hex: :websock, repo: "hexpm", optional: false]}], "hexpm", "315b9a1865552212b5f35140ad194e67ce31af45bcee443d4ecb96b5fd3f3782"},
}
38 changes: 20 additions & 18 deletions lib/mix/tasks/surface/surface.init/patcher.ex
Original file line number Diff line number Diff line change
Expand Up @@ -136,33 +136,35 @@ defmodule Mix.Tasks.Surface.Init.Patcher do
end

defp to_results(patches, status, file) do
Enum.map(patches, fn patch_spec ->
for patch_spec <- patches, status not in Map.get(patch_spec, :ignore_when, []) do
{status, file, patch_spec}
end)
end
end

defp log(action, file, fun) do
prefix = "* #{action} "
Mix.shell().info([:green, prefix, :reset, file])

result = fun.()

skipped_postfix =
case result |> List.wrap() |> Enum.split_with(&match?({:patched, _, _}, &1)) do
{[], _not_patched} ->
[:yellow, " (skipped)", :reset]
if result != [] do
prefix = "* #{action} "
Mix.shell().info([:green, prefix, :reset, file])

{_patched, []} ->
[]
skipped_postfix =
case result |> List.wrap() |> Enum.split_with(&match?({:patched, _, _}, &1)) do
{[], _not_patched} ->
[:yellow, " (skipped)", :reset]

{patched, not_patched} ->
n_not_patched = length(not_patched)
total = n_not_patched + length(patched)
[:yellow, " (skipped #{n_not_patched} of #{total} changes)", :reset]
end
{_patched, []} ->
[]

if skipped_postfix != [] do
Mix.shell().info([IO.ANSI.cursor_up(), :clear_line, :yellow, prefix, :reset, file] ++ skipped_postfix)
{patched, not_patched} ->
n_not_patched = length(not_patched)
total = n_not_patched + length(patched)
[:yellow, " (skipped #{n_not_patched} of #{total} changes)", :reset]
end

if skipped_postfix != [] do
Mix.shell().info([IO.ANSI.cursor_up(), :clear_line, :yellow, prefix, :reset, file] ++ skipped_postfix)
end
end

result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ defmodule Mix.Tasks.Surface.Init.ProjectPatchers.Docker do
def swap_assets_deploy_with_compile() do
%{
name: "Run mix compile before mix assets.deploy",
ignore_when: [:file_not_found],
instructions: """
Update `Dockerfile` so that `mix compile` is before `mix assets.deploy`.
Update `Dockerfile` so that `mix compile` is called before `mix assets.deploy`.
# Example
Expand Down
2 changes: 0 additions & 2 deletions lib/surface/compiler/parser.ex
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,7 @@ defmodule Surface.Compiler.Parser do
end

defp node_type({:tag_open, _, _, _}), do: "tag"
defp node_type({:tag_close, _, _}), do: "tag"
defp node_type({:block_open, _, _, _}), do: "block"
defp node_type({:block_close, _, _}), do: "block"

defp format_node({:tag_open, name, _attrs, _meta}), do: "<#{name}>"
defp format_node({:tag_close, name, _meta}), do: "</#{name}>"
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ defmodule Surface.MixProject do
# Run "mix help deps" to learn about dependencies.
defp deps do
[
{:phoenix_live_view, "~> 0.19.0 or ~> 0.20.10"},
{:phoenix_live_view, "~> 0.19.0 or ~> 0.20.10 or ~> 1.0"},
{:sourceror, "~> 1.0"},
{:blend, "~> 0.3.0", only: :dev},
{:jason, "~> 1.0", only: :test},
Expand Down
Loading

0 comments on commit 14d1738

Please sign in to comment.