Skip to content

Commit a6ef4ba

Browse files
committed
remove socket route from existing endpoints
1 parent 0f15ef0 commit a6ef4ba

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

lib/mix/tasks/beacon.gen.proxy_endpoint.ex

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,12 @@ defmodule Mix.Tasks.Beacon.Gen.ProxyEndpoint do
186186
end
187187
end
188188
)
189+
|> Igniter.Project.Module.find_and_update_module!(endpoint, fn zipper ->
190+
{:ok, zipper} = Igniter.Code.Function.move_to_function_call(zipper, :socket, 3)
191+
# TODO replace the node with a commented-out version of itself
192+
# blocked by https://github.com/ash-project/igniter/pull/200
193+
{:ok, Sourceror.Zipper.remove(zipper)}
194+
end)
189195
end)
190196
end
191197

test/mix/tasks/gen_proxy_endpoint.exs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,18 @@ defmodule Mix.Tasks.Beacon.GenProxyEndpointTest do
3333
""")
3434
end
3535

36+
test "update existing endpoint module", %{project: project} do
37+
project
38+
|> Igniter.compose_task("beacon.gen.proxy_endpoint", @opts)
39+
|> assert_has_patch("lib/test_web/endpoint.ex", """
40+
14 - | socket("/live", Phoenix.LiveView.Socket,
41+
15 - | websocket: [connect_info: [session: @session_options]],
42+
16 - | longpoll: [connect_info: [session: @session_options]]
43+
17 - | )
44+
18 - |
45+
""")
46+
end
47+
3648
test "add endpoint to application.ex", %{project: project} do
3749
project
3850
|> Igniter.compose_task("beacon.gen.proxy_endpoint", @opts)

0 commit comments

Comments
 (0)