From 8285a954907a41c0fd2f784ba5ff00446f3af492 Mon Sep 17 00:00:00 2001 From: Andy Duong Date: Fri, 10 Mar 2023 14:11:52 +0700 Subject: [PATCH] [gh315] Update - 1 --- .../addons/variants/phoenix/web/es_lint.ex | 26 ----------------- .../variants/phoenix/web/heex_formatter.ex | 29 ------------------- .../addons/variants/phoenix/web/svg_sprite.ex | 10 +++---- lib/nimble_template/helpers/credo.ex | 3 +- .../variants/phoenix/web/template.ex | 1 - .../variants/phoenix/web/es_lint_test.exs | 22 -------------- .../phoenix/web/hex_formatter_test.exs | 24 --------------- test/nimble_template/helpers/credo_test.exs | 6 ---- 8 files changed, 6 insertions(+), 115 deletions(-) delete mode 100644 lib/nimble_template/addons/variants/phoenix/web/heex_formatter.ex delete mode 100644 test/nimble_template/addons/variants/phoenix/web/hex_formatter_test.exs diff --git a/lib/nimble_template/addons/variants/phoenix/web/es_lint.ex b/lib/nimble_template/addons/variants/phoenix/web/es_lint.ex index 3c5abaf3..da9d3a62 100644 --- a/lib/nimble_template/addons/variants/phoenix/web/es_lint.ex +++ b/lib/nimble_template/addons/variants/phoenix/web/es_lint.ex @@ -10,18 +10,6 @@ defmodule NimbleTemplate.Addons.Phoenix.Web.EsLint do |> copy_files!() end - def edit_app_js!(%Project{live_project?: true} = project) do - update_topbar_js_variables!() - - project - end - - def edit_app_js!(%Project{web_project?: true} = project) do - update_topbar_js_variables!() - - project - end - def edit_app_js!(project), do: project defp edit_files!(%Project{} = project) do @@ -91,18 +79,4 @@ defmodule NimbleTemplate.Addons.Phoenix.Web.EsLint do project end - - defp update_topbar_js_variables! do - Generator.replace_content!( - "assets/js/app.js", - "window.addEventListener(\"phx:page-loading-start\", info => topbar.show())", - "window.addEventListener(\"phx:page-loading-start\", _info => topbar.show())" - ) - - Generator.replace_content!( - "assets/js/app.js", - "window.addEventListener(\"phx:page-loading-stop\", info => topbar.hide())", - "window.addEventListener(\"phx:page-loading-stop\", _info => topbar.hide())" - ) - end end diff --git a/lib/nimble_template/addons/variants/phoenix/web/heex_formatter.ex b/lib/nimble_template/addons/variants/phoenix/web/heex_formatter.ex deleted file mode 100644 index d060f216..00000000 --- a/lib/nimble_template/addons/variants/phoenix/web/heex_formatter.ex +++ /dev/null @@ -1,29 +0,0 @@ -defmodule NimbleTemplate.Addons.Phoenix.Web.HeexFormatter do - @moduledoc false - - use NimbleTemplate.Addons.Addon - - @impl true - def do_apply!(%Project{} = project, _opts) do - Generator.replace_content!(".formatter.exs", "\"*.{ex,exs}\"", "\"*.{heex,ex,exs}\"") - - Generator.replace_content!( - ".formatter.exs", - "\"{config,lib,test}/**/*.{ex,exs}\"", - "\"{config,lib,test}/**/*.{heex,ex,exs}\"" - ) - - Generator.replace_content!( - ".formatter.exs", - """ - import_deps: [:ecto, :phoenix], - """, - """ - import_deps: [:ecto, :phoenix], - plugins: [Phoenix.LiveView.HTMLFormatter], - """ - ) - - project - end -end diff --git a/lib/nimble_template/addons/variants/phoenix/web/svg_sprite.ex b/lib/nimble_template/addons/variants/phoenix/web/svg_sprite.ex index aaf3f01b..2fe3175b 100644 --- a/lib/nimble_template/addons/variants/phoenix/web/svg_sprite.ex +++ b/lib/nimble_template/addons/variants/phoenix/web/svg_sprite.ex @@ -53,14 +53,14 @@ defmodule NimbleTemplate.Addons.Phoenix.Web.SvgSprite do Generator.replace_content!( "#{web_path}.ex", """ - # Include shared imports and aliases for views - unquote(view_helpers()) + # HTML escaping functionality + import Phoenix.HTML """, """ - import #{web_module}.IconHelper + # HTML escaping functionality + import Phoenix.HTML - # Include shared imports and aliases for views - unquote(view_helpers()) + import #{web_module}.IconHelper """ ) diff --git a/lib/nimble_template/helpers/credo.ex b/lib/nimble_template/helpers/credo.ex index ae9a6b5d..681ca76d 100644 --- a/lib/nimble_template/helpers/credo.ex +++ b/lib/nimble_template/helpers/credo.ex @@ -41,8 +41,7 @@ defmodule NimbleTemplate.CredoHelper do [ "#{base_path}/release_tasks.ex", "#{web_path}/controllers/page_controller.ex", - "#{web_path}/telemetry.ex", - "#{web_path}/views/error_view.ex" + "#{web_path}/telemetry.ex" ] end diff --git a/lib/nimble_template/templates/variants/phoenix/web/template.ex b/lib/nimble_template/templates/variants/phoenix/web/template.ex index d080a007..e29dcfc0 100644 --- a/lib/nimble_template/templates/variants/phoenix/web/template.ex +++ b/lib/nimble_template/templates/variants/phoenix/web/template.ex @@ -22,7 +22,6 @@ defmodule NimbleTemplate.Templates.Phoenix.Web.Template do |> Web.StyleLint.apply!() |> Web.EsBuild.apply!() |> Web.PostCSS.apply!() - |> Web.HeexFormatter.apply!() end defp apply_optional_web_addons(%Project{optional_addons: optional_addons} = project) do diff --git a/test/nimble_template/addons/variants/phoenix/web/es_lint_test.exs b/test/nimble_template/addons/variants/phoenix/web/es_lint_test.exs index 35d8cccd..58978603 100644 --- a/test/nimble_template/addons/variants/phoenix/web/es_lint_test.exs +++ b/test/nimble_template/addons/variants/phoenix/web/es_lint_test.exs @@ -82,26 +82,4 @@ defmodule NimbleTemplate.Addons.Phoenix.Web.EsLintTest do end) end end - - describe "#apply!/2 to a Live project" do - @describetag live_project?: true - @describetag required_addons: [:TestEnv, :"Phoenix.Web.NodePackage"] - - test "updates the assets/js/app.js", %{ - project: project, - test_project_path: test_project_path - } do - in_test_project!(test_project_path, fn -> - WebAddons.EsLint.apply!(project) - - assert_file("assets/js/app.js", fn file -> - assert file =~ - "window.addEventListener(\"phx:page-loading-start\", _info => topbar.show())" - - assert file =~ - "window.addEventListener(\"phx:page-loading-stop\", _info => topbar.hide())" - end) - end) - end - end end diff --git a/test/nimble_template/addons/variants/phoenix/web/hex_formatter_test.exs b/test/nimble_template/addons/variants/phoenix/web/hex_formatter_test.exs deleted file mode 100644 index 3159fa4a..00000000 --- a/test/nimble_template/addons/variants/phoenix/web/hex_formatter_test.exs +++ /dev/null @@ -1,24 +0,0 @@ -defmodule NimbleTemplate.Addons.Phoenix.Web.HeexFormatterTest do - use NimbleTemplate.AddonCase, async: false - - describe "#apply!/2" do - test "adds the HTMLFormatter into the .formatter.exs", %{ - project: project, - test_project_path: test_project_path - } do - in_test_project!(test_project_path, fn -> - WebAddons.HeexFormatter.apply!(project) - - assert_file(".formatter.exs", fn file -> - assert file =~ """ - plugins: [Phoenix.LiveView.HTMLFormatter], - """ - - assert file =~ """ - inputs: ["*.{heex,ex,exs}", "priv/*/seeds.exs", "{config,lib,test}/**/*.{heex,ex,exs}"], - """ - end) - end) - end - end -end diff --git a/test/nimble_template/helpers/credo_test.exs b/test/nimble_template/helpers/credo_test.exs index 7eb37645..161ae83e 100644 --- a/test/nimble_template/helpers/credo_test.exs +++ b/test/nimble_template/helpers/credo_test.exs @@ -42,12 +42,6 @@ defmodule NimbleTemplate.CredoHelperTest do # credo:disable-for-this-file CompassCredoPlugin.Check.DoSingleExpression """ end) - - assert_file("#{test_project_path}/lib/nimble_template_web/views/error_view.ex", fn file -> - assert file =~ """ - # credo:disable-for-this-file CompassCredoPlugin.Check.DoSingleExpression - """ - end) end) end end