Skip to content

Commit 474c506

Browse files
committed
adjust order according to the improved installation docs
1 parent 035232b commit 474c506

File tree

1 file changed

+43
-43
lines changed

1 file changed

+43
-43
lines changed

lib/mix/tasks/backpex.install.ex

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ if Code.ensure_loaded?(Igniter) do
8585
|> configure_pubsub_server()
8686
|> install_backpex_hooks()
8787
|> install_daisyui()
88-
|> add_backpex_formatter()
8988
|> add_files_to_tailwind_content()
89+
|> add_backpex_formatter()
9090
|> add_backpex_routes()
9191
|> generate_layout()
9292
|> check_for_bg_white()
@@ -157,12 +157,6 @@ if Code.ensure_loaded?(Igniter) do
157157
)
158158
end
159159

160-
# Add Backpex to formatter
161-
162-
defp add_backpex_formatter(igniter) do
163-
Formatter.import_dep(igniter, :backpex)
164-
end
165-
166160
# Add backpex files to tailwind content
167161

168162
defp add_files_to_tailwind_content(igniter) do
@@ -173,6 +167,12 @@ if Code.ensure_loaded?(Igniter) do
173167
|> Helpers.add_line_to_file(app_css_path, "@source \"../../deps/backpex/assets/js/**/*.*js\"")
174168
end
175169

170+
# Add Backpex to formatter
171+
172+
defp add_backpex_formatter(igniter) do
173+
Formatter.import_dep(igniter, :backpex)
174+
end
175+
176176
# Add Backpex routes
177177

178178
defp add_backpex_routes(igniter) do
@@ -215,7 +215,7 @@ if Code.ensure_loaded?(Igniter) do
215215
end
216216
end
217217

218-
# Creates default adminlayout
218+
# Creates default admin layout
219219

220220
defp generate_layout(igniter) do
221221
if igniter.args.options[:no_layout] do
@@ -231,41 +231,6 @@ if Code.ensure_loaded?(Igniter) do
231231
end
232232
end
233233

234-
# Checks for tailwind forms plugin
235-
236-
defp check_for_tailwind_forms_plugin(igniter) do
237-
app_css_path = igniter.args.options[:app_css_path]
238-
line = "@plugin \"@tailwindcss/forms\""
239-
240-
if Igniter.exists?(igniter, app_css_path) do
241-
Igniter.update_file(igniter, app_css_path, &maybe_remove_tailwind_forms_plugin(&1, line))
242-
else
243-
Warning.warn_with_code_sample(
244-
igniter,
245-
"""
246-
app.css not found at #{app_css_path}.
247-
You may remove the following line from your app.css file because it can cause issues with daisyUI:
248-
""",
249-
line
250-
)
251-
end
252-
end
253-
254-
defp maybe_remove_tailwind_forms_plugin(source, line) do
255-
app_css_content = Rewrite.Source.get(source, :content)
256-
257-
with true <- String.contains?(app_css_content, line),
258-
true <- remove_tailwind_forms_plugin?(line) do
259-
Rewrite.Source.update(source, :content, &String.replace(&1, line, ""))
260-
else
261-
_false -> source
262-
end
263-
end
264-
265-
defp remove_tailwind_forms_plugin?(line) do
266-
Mix.shell().yes?("The following line could cause issues with daisyUI: #{line}. Do you want to remove it?")
267-
end
268-
269234
# Checks for default background color
270235

271236
defp check_for_bg_white(igniter) do
@@ -300,6 +265,41 @@ if Code.ensure_loaded?(Igniter) do
300265
"A background color at the body could cause issues with the backpex app_shell. Do you want to remove it? See: https://hexdocs.pm/backpex/installation.html#remove-default-background-color"
301266
)
302267
end
268+
269+
# Checks for tailwind forms plugin
270+
271+
defp check_for_tailwind_forms_plugin(igniter) do
272+
app_css_path = igniter.args.options[:app_css_path]
273+
line = "@plugin \"@tailwindcss/forms\""
274+
275+
if Igniter.exists?(igniter, app_css_path) do
276+
Igniter.update_file(igniter, app_css_path, &maybe_remove_tailwind_forms_plugin(&1, line))
277+
else
278+
Warning.warn_with_code_sample(
279+
igniter,
280+
"""
281+
app.css not found at #{app_css_path}.
282+
You may remove the following line from your app.css file because it can cause issues with daisyUI:
283+
""",
284+
line
285+
)
286+
end
287+
end
288+
289+
defp maybe_remove_tailwind_forms_plugin(source, line) do
290+
app_css_content = Rewrite.Source.get(source, :content)
291+
292+
with true <- String.contains?(app_css_content, line),
293+
true <- remove_tailwind_forms_plugin?(line) do
294+
Rewrite.Source.update(source, :content, &String.replace(&1, line, ""))
295+
else
296+
_false -> source
297+
end
298+
end
299+
300+
defp remove_tailwind_forms_plugin?(line) do
301+
Mix.shell().yes?("The following line could cause issues with daisyUI: #{line}. Do you want to remove it?")
302+
end
303303
end
304304
else
305305
defmodule Mix.Tasks.Backpex.Install do

0 commit comments

Comments
 (0)