Skip to content

Commit 0120520

Browse files
authored
Refactor: add live_debugger_web to project structure (#325)
* create live_view_web module * add debugging errors on live_debugger while in dev mode * check LiveDebuggerWeb prefix
1 parent 05376c5 commit 0120520

33 files changed

Lines changed: 98 additions & 92 deletions

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ In `router.ex` of your Phoenix app, make sure your locally running Phoenix app c
9191
config :live_debugger,
9292
ip: {127, 0, 0, 1}, # IP on which LiveDebugger will be hosted
9393
port: 4007, # Port on which LiveDebugger will be hosted
94-
secret_key_base: "YOUR_SECRET_KEY_BASE", # Secret key used for LiveDebugger.Endpoint
95-
signing_salt: "your_signing_salt", # Signing salt used for LiveDebugger.Endpoint
96-
adapter: Bandit.PhoenixAdapter, # Adapter used in LiveDebugger.Endpoint
94+
secret_key_base: "YOUR_SECRET_KEY_BASE", # Secret key used for LiveDebuggerWeb.Endpoint
95+
signing_salt: "your_signing_salt", # Signing salt used for LiveDebuggerWeb.Endpoint
96+
adapter: Bandit.PhoenixAdapter, # Adapter used in LiveDebuggerWeb.Endpoint
9797
tracing_setup_delay: 0 # Time in ms after tracing will be initialized. Useful in case multi-nodes envs
9898
```
9999

config/config.exs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ if config_env() == :dev do
4747
]
4848
]
4949

50+
config :live_debugger, LiveDebuggerWeb.Endpoint, debug_errors: true
51+
5052
config :live_debugger, experimental_features: :all
5153
end
5254

lib/live_debugger.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ defmodule LiveDebugger do
2121

2222
children = [
2323
{Phoenix.PubSub, name: LiveDebugger.PubSub},
24-
{LiveDebugger.Endpoint,
24+
{LiveDebuggerWeb.Endpoint,
2525
[
2626
check_origin: false,
2727
pubsub_server: LiveDebugger.PubSub
@@ -61,7 +61,7 @@ defmodule LiveDebugger do
6161
live_reload: Keyword.get(config, :live_reload, [])
6262
]
6363

64-
Application.put_env(@app_name, LiveDebugger.Endpoint, endpoint_config)
64+
Application.put_env(@app_name, LiveDebuggerWeb.Endpoint, endpoint_config)
6565
end
6666

6767
defp put_live_debugger_tags(config) do
@@ -83,7 +83,7 @@ defmodule LiveDebugger do
8383
highlighting?: highlighting?
8484
}
8585

86-
tags = LiveDebugger.Components.Config.live_debugger_tags(assigns)
86+
tags = LiveDebuggerWeb.Components.Config.live_debugger_tags(assigns)
8787
Application.put_env(@app_name, :live_debugger_tags, tags)
8888
end
8989
end

lib/live_debugger/router.ex

Lines changed: 0 additions & 23 deletions
This file was deleted.

lib/live_debugger/services/module_discovery_service.ex

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@ defmodule LiveDebugger.Services.ModuleDiscoveryService do
5757
defp debugger?(module) do
5858
stringified_module = Atom.to_string(module)
5959

60-
String.starts_with?(stringified_module, "LiveDebugger.") or
61-
String.starts_with?(stringified_module, "Elixir.LiveDebugger.")
60+
String.starts_with?(stringified_module, [
61+
"Elixir.LiveDebugger.",
62+
"Elixir.LiveDebuggerWeb.",
63+
"LiveDebugger.",
64+
"LiveDebuggerWeb."
65+
])
6266
end
6367
end

lib/live_debugger/structs/lv_process.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ defmodule LiveDebugger.Structs.LvProcess do
3737
debugger? =
3838
socket.view
3939
|> Atom.to_string()
40-
|> String.starts_with?("Elixir.LiveDebugger.")
40+
|> String.starts_with?(["Elixir.LiveDebugger.", "Elixir.LiveDebuggerWeb."])
4141

4242
embedded? = socket.host_uri == :not_mounted_at_router
4343

lib/live_debugger_web.ex

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ defmodule LiveDebuggerWeb do
44
def live_view do
55
quote do
66
use Phoenix.LiveView,
7-
layout: {LiveDebugger.Layout, :app}
7+
layout: {LiveDebuggerWeb.Layout, :app}
88

9-
on_mount({LiveDebugger.Flash, :add_hook})
9+
on_mount({LiveDebuggerWeb.Hooks.Flash, :add_hook})
1010

1111
import Phoenix.HTML
1212
import LiveDebuggerWeb.Helpers
13-
import LiveDebugger.Components
14-
import LiveDebugger.Flash, only: [push_flash: 2, push_flash: 3]
13+
import LiveDebuggerWeb.Components
14+
import LiveDebuggerWeb.Hooks.Flash, only: [push_flash: 2, push_flash: 3]
1515
end
1616
end
1717

@@ -21,8 +21,8 @@ defmodule LiveDebuggerWeb do
2121

2222
import Phoenix.HTML
2323
import LiveDebuggerWeb.Helpers
24-
import LiveDebugger.Components
25-
import LiveDebugger.Flash, only: [push_flash: 2, push_flash: 3]
24+
import LiveDebuggerWeb.Components
25+
import LiveDebuggerWeb.Hooks.Flash, only: [push_flash: 2, push_flash: 3]
2626
end
2727
end
2828

@@ -32,7 +32,7 @@ defmodule LiveDebuggerWeb do
3232

3333
import Phoenix.HTML
3434
import LiveDebuggerWeb.Helpers
35-
import LiveDebugger.Components
35+
import LiveDebuggerWeb.Components
3636
end
3737
end
3838

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
defmodule LiveDebugger.Components do
1+
defmodule LiveDebuggerWeb.Components do
22
@moduledoc """
33
This module provides reusable components for LiveDebugger.
44
"""
55

66
use Phoenix.Component
77

88
alias Phoenix.LiveView.JS
9-
alias LiveDebugger.LiveHelpers.Routes
9+
alias LiveDebuggerWeb.Helpers.RoutesHelper
1010

1111
@report_issue_url "https://github.com/software-mansion/live-debugger/issues/new/choose"
1212

@@ -553,7 +553,7 @@ defmodule LiveDebugger.Components do
553553
def navbar(assigns) do
554554
~H"""
555555
<navbar class="w-full h-12 shrink-0 py-auto px-4 flex items-center gap-2 bg-navbar-bg text-navbar-logo border-b border-navbar-border">
556-
<.link :if={@return_link?} patch={Routes.live_views_dashboard()}>
556+
<.link :if={@return_link?} patch={RoutesHelper.live_views_dashboard()}>
557557
<.nav_icon icon="icon-arrow-left" />
558558
</.link>
559559

lib/live_debugger/components/config.ex renamed to lib/live_debugger_web/components/config.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
defmodule LiveDebugger.Components.Config do
1+
defmodule LiveDebuggerWeb.Components.Config do
22
@moduledoc """
33
Renders the LiveDebugger config meta tag and the browser features script.
44
It is meant to be injected to the debugged application layout.

lib/live_debugger/components/elixir_display.ex renamed to lib/live_debugger_web/components/elixir_display.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
defmodule LiveDebugger.Components.ElixirDisplay do
1+
defmodule LiveDebuggerWeb.Components.ElixirDisplay do
22
@moduledoc """
33
This module provides a component to display a tree of terms.
44
Check LiveDebugger.Utils.TermParser.

0 commit comments

Comments
 (0)