diff --git a/lib/nimble_template/addons/variants/phoenix/api/config.ex b/lib/nimble_template/addons/variants/phoenix/api/config.ex index d5435c64..2b0b7923 100644 --- a/lib/nimble_template/addons/variants/phoenix/api/config.ex +++ b/lib/nimble_template/addons/variants/phoenix/api/config.ex @@ -15,7 +15,7 @@ defmodule NimbleTemplate.Addons.Phoenix.Api.Config do # For production, don't forget to configure the url host # to something meaningful, Phoenix uses this information # when generating URLs. - # + # Note we also include the path to a cache manifest # containing the digested version of static files. This # manifest is generated by the `mix phx.digest` task, diff --git a/lib/nimble_template/addons/variants/phoenix/api/error_view.ex b/lib/nimble_template/addons/variants/phoenix/api/error_view.ex index c86ce1de..aeee23f9 100644 --- a/lib/nimble_template/addons/variants/phoenix/api/error_view.ex +++ b/lib/nimble_template/addons/variants/phoenix/api/error_view.ex @@ -5,42 +5,46 @@ defmodule NimbleTemplate.Addons.Phoenix.Api.ErrorView do @impl true def do_apply!(%Project{} = project, _opts) do - project - |> delete_files!() - |> copy_files!() - end - - defp delete_files!(%Project{web_path: web_path} = project) do - File.rm!("#{web_path}/views/error_helpers.ex") - - project - end - - defp copy_files!( - %Project{ - base_module: base_module, - web_module: web_module, - web_path: web_path, - web_test_path: web_test_path - } = project - ) do - binding = [ - web_module: web_module, - base_module: base_module - ] - - files = [ - {:eex, "lib/otp_app_web/views/error_helpers.ex.eex", "#{web_path}/views/error_helpers.ex"}, - {:eex, "lib/otp_app_web/views/api/error_view.ex.eex", "#{web_path}/views/api/error_view.ex"}, - {:eex, "test/otp_app_web/views/error_helpers_test.exs", - "#{web_test_path}/views/error_helpers_test.exs"}, - {:eex, "test/otp_app_web/views/api/error_view_test.exs", - "#{web_test_path}/views/api/error_view_test.exs"}, - {:eex, "test/support/view_case.ex.eex", "test/support/view_case.ex"} - ] - - Generator.copy_file!(files, binding) - + # TODO: Revisit on the next PR project end + # def do_apply!(%Project{} = project, _opts) do + # project + # |> delete_files!() + # |> copy_files!() + # end + + # defp delete_files!(%Project{web_path: web_path} = project) do + # File.rm!("#{web_path}/views/error_helpers.ex") + + # project + # end + + # defp copy_files!( + # %Project{ + # base_module: base_module, + # web_module: web_module, + # web_path: web_path, + # web_test_path: web_test_path + # } = project + # ) do + # binding = [ + # web_module: web_module, + # base_module: base_module + # ] + + # files = [ + # {:eex, "lib/otp_app_web/views/error_helpers.ex.eex", "#{web_path}/views/error_helpers.ex"}, + # {:eex, "lib/otp_app_web/views/api/error_view.ex.eex", "#{web_path}/views/api/error_view.ex"}, + # {:eex, "test/otp_app_web/views/error_helpers_test.exs", + # "#{web_test_path}/views/error_helpers_test.exs"}, + # {:eex, "test/otp_app_web/views/api/error_view_test.exs", + # "#{web_test_path}/views/api/error_view_test.exs"}, + # {:eex, "test/support/view_case.ex.eex", "test/support/view_case.ex"} + # ] + + # Generator.copy_file!(files, binding) + + # project + # end end diff --git a/lib/nimble_template/addons/variants/phoenix/api/fallback_controller.ex b/lib/nimble_template/addons/variants/phoenix/api/fallback_controller.ex index 7bb87277..aef2b556 100644 --- a/lib/nimble_template/addons/variants/phoenix/api/fallback_controller.ex +++ b/lib/nimble_template/addons/variants/phoenix/api/fallback_controller.ex @@ -31,24 +31,26 @@ defmodule NimbleTemplate.Addons.Phoenix.Api.FallbackController do """ def controller do quote do - use Phoenix.Controller, namespace: #{web_module} + use Phoenix.Controller, + formats: [:html, :json], + layouts: [html: #{web_module}.Layouts] import Plug.Conn import #{web_module}.Gettext alias #{web_module}.ParamsValidator - alias #{web_module}.Router.Helpers, as: Routes """, """ def controller do quote do - use Phoenix.Controller, namespace: #{web_module} + use Phoenix.Controller, + formats: [:html, :json], + layouts: [html: #{web_module}.Layouts] import Plug.Conn import #{web_module}.Gettext alias #{web_module}.ParamsValidator - alias #{web_module}.Router.Helpers, as: Routes action_fallback #{web_module}.Api.FallbackController """ diff --git a/lib/nimble_template/addons/variants/phoenix/api/params_validation.ex b/lib/nimble_template/addons/variants/phoenix/api/params_validation.ex index d4c419e5..aa9dcdc8 100644 --- a/lib/nimble_template/addons/variants/phoenix/api/params_validation.ex +++ b/lib/nimble_template/addons/variants/phoenix/api/params_validation.ex @@ -19,22 +19,24 @@ defmodule NimbleTemplate.Addons.Phoenix.Api.ParamsValidation do """ def controller do quote do - use Phoenix.Controller, namespace: #{web_module} + use Phoenix.Controller, + formats: [:html, :json], + layouts: [html: #{web_module}.Layouts] import Plug.Conn import #{web_module}.Gettext - alias #{web_module}.Router.Helpers, as: Routes """, """ def controller do quote do - use Phoenix.Controller, namespace: #{web_module} + use Phoenix.Controller, + formats: [:html, :json], + layouts: [html: #{web_module}.Layouts] import Plug.Conn import #{web_module}.Gettext alias #{web_module}.ParamsValidator - alias #{web_module}.Router.Helpers, as: Routes """ ) diff --git a/lib/nimble_template/addons/variants/phoenix/oban.ex b/lib/nimble_template/addons/variants/phoenix/oban.ex index 32b85b1d..72951af4 100644 --- a/lib/nimble_template/addons/variants/phoenix/oban.ex +++ b/lib/nimble_template/addons/variants/phoenix/oban.ex @@ -102,7 +102,7 @@ defmodule NimbleTemplate.Addons.Phoenix.Oban do Generator.inject_content!( "config/test.exs", """ - config :logger, level: :warn + config :logger, level: :warning """, """ diff --git a/lib/nimble_template/addons/variants/phoenix/web/bootstrap.ex b/lib/nimble_template/addons/variants/phoenix/web/bootstrap.ex index b9c3c532..871c6778 100644 --- a/lib/nimble_template/addons/variants/phoenix/web/bootstrap.ex +++ b/lib/nimble_template/addons/variants/phoenix/web/bootstrap.ex @@ -4,149 +4,153 @@ defmodule NimbleTemplate.Addons.Phoenix.Web.Bootstrap do use NimbleTemplate.Addons.Addon @impl true - def do_apply!(%Project{} = project, opts) do - project - |> edit_files!(opts) - |> copy_files!() - end - - defp edit_files!(%Project{} = project, opts) do - project - |> edit_assets_package!() - |> edit_app_js!(opts) - |> edit_app_scss!(opts) - |> edit_vendor_index!(opts) - |> edit_css_variables!(opts) - end - - defp copy_files!(%Project{} = project) do - copy_bootstrap_vendor!(project) - - project - end - - defp edit_assets_package!(%Project{} = project) do - Generator.replace_content!( - "assets/package.json", - """ - "dependencies": { - """, - """ - "dependencies": { - "@popperjs/core": "2.11.5", - "bootstrap": "5.1.3", - """ - ) - - project - end - - defp edit_app_js!(project, %{with_nimble_js_addon: true}) do - Generator.replace_content!( - "assets/js/app.js", - """ - import "phoenix_html" - """, - """ - // Bootstrap - import "bootstrap/dist/js/bootstrap"; - - import "phoenix_html" - """ - ) - - project - end - - defp edit_app_js!(project, %{with_nimble_js_addon: false}) do - Generator.replace_content!( - "assets/js/app.js", - """ - import "phoenix_html" - """, - """ - // Bootstrap - import "bootstrap/dist/js/bootstrap"; - - import "phoenix_html" - """ - ) - - project - end - - defp edit_app_scss!(project, %{with_nimble_css_addon: true}), do: project - - defp edit_app_scss!(project, %{with_nimble_css_addon: false}) do - Generator.replace_content!( - "assets/css/app.scss", - """ - @import "./phoenix.css"; - """, - """ - @import "./phoenix.css"; - - @import './vendor/'; - """ - ) - - project - end - - defp edit_css_variables!(project, %{with_nimble_css_addon: false}) do - Generator.create_file!( - "assets/css/_variables.scss", - """ - //////////////////////////////// - // Shared variables // - //////////////////////////////// - - - //////////////////////////////// - // Custom Bootstrap variables // - //////////////////////////////// - """ - ) - - project - end - - defp edit_css_variables!(project, %{with_nimble_css_addon: true}) do - Generator.append_content!( - "assets/css/_variables.scss", - """ - //////////////////////////////// - // Shared variables // - //////////////////////////////// - - - //////////////////////////////// - // Custom Bootstrap variables // - //////////////////////////////// - """ - ) - - project - end - - defp edit_vendor_index!(project, %{with_nimble_css_addon: true}) do - Generator.append_content!("assets/css/vendor/_index.scss", "@import './bootstrap';") - - project - end - - defp edit_vendor_index!(project, %{with_nimble_css_addon: false}) do - Generator.make_directory!("assets/css/vendor/", false) - Generator.create_file!("assets/css/vendor/_index.scss", "@import './bootstrap';") - - project - end - - defp copy_bootstrap_vendor!(%Project{} = project) do - Generator.copy_file!([ - {:text, "assets/bootstrap_css/vendor/_bootstrap.scss", "assets/css/vendor/_bootstrap.scss"} - ]) - + def do_apply!(%Project{} = project, _opts) do project end + # TODO: Enable Bootstrap on the next PR + # def do_apply!(%Project{} = project, opts) do + # project + # |> edit_files!(opts) + # |> copy_files!() + # end + + # defp edit_files!(%Project{} = project, opts) do + # project + # |> edit_assets_package!() + # |> edit_app_js!(opts) + # |> edit_app_scss!(opts) + # |> edit_vendor_index!(opts) + # |> edit_css_variables!(opts) + # end + + # defp copy_files!(%Project{} = project) do + # copy_bootstrap_vendor!(project) + + # project + # end + + # defp edit_assets_package!(%Project{} = project) do + # Generator.replace_content!( + # "assets/package.json", + # """ + # "dependencies": { + # """, + # """ + # "dependencies": { + # "@popperjs/core": "2.11.5", + # "bootstrap": "5.1.3", + # """ + # ) + + # project + # end + + # defp edit_app_js!(project, %{with_nimble_js_addon: true}) do + # Generator.replace_content!( + # "assets/js/app.js", + # """ + # import "phoenix_html" + # """, + # """ + # // Bootstrap + # import "bootstrap/dist/js/bootstrap"; + + # import "phoenix_html" + # """ + # ) + + # project + # end + + # defp edit_app_js!(project, %{with_nimble_js_addon: false}) do + # Generator.replace_content!( + # "assets/js/app.js", + # """ + # import "phoenix_html" + # """, + # """ + # // Bootstrap + # import "bootstrap/dist/js/bootstrap"; + + # import "phoenix_html" + # """ + # ) + + # project + # end + + # defp edit_app_scss!(project, %{with_nimble_css_addon: true}), do: project + + # defp edit_app_scss!(project, %{with_nimble_css_addon: false}) do + # Generator.replace_content!( + # "assets/css/app.scss", + # """ + # @import "./phoenix.css"; + # """, + # """ + # @import "./phoenix.css"; + + # @import './vendor/'; + # """ + # ) + + # project + # end + + # defp edit_css_variables!(project, %{with_nimble_css_addon: false}) do + # Generator.create_file!( + # "assets/css/_variables.scss", + # """ + # //////////////////////////////// + # // Shared variables // + # //////////////////////////////// + + + # //////////////////////////////// + # // Custom Bootstrap variables // + # //////////////////////////////// + # """ + # ) + + # project + # end + + # defp edit_css_variables!(project, %{with_nimble_css_addon: true}) do + # Generator.append_content!( + # "assets/css/_variables.scss", + # """ + # //////////////////////////////// + # // Shared variables // + # //////////////////////////////// + + + # //////////////////////////////// + # // Custom Bootstrap variables // + # //////////////////////////////// + # """ + # ) + + # project + # end + + # defp edit_vendor_index!(project, %{with_nimble_css_addon: true}) do + # Generator.append_content!("assets/css/vendor/_index.scss", "@import './bootstrap';") + + # project + # end + + # defp edit_vendor_index!(project, %{with_nimble_css_addon: false}) do + # Generator.make_directory!("assets/css/vendor/", false) + # Generator.create_file!("assets/css/vendor/_index.scss", "@import './bootstrap';") + + # project + # end + + # defp copy_bootstrap_vendor!(%Project{} = project) do + # Generator.copy_file!([ + # {:text, "assets/bootstrap_css/vendor/_bootstrap.scss", "assets/css/vendor/_bootstrap.scss"} + # ]) + + # project + # end end diff --git a/lib/nimble_template/addons/variants/phoenix/web/dart_sass.ex b/lib/nimble_template/addons/variants/phoenix/web/dart_sass.ex index 73dc3f72..9f2934c6 100644 --- a/lib/nimble_template/addons/variants/phoenix/web/dart_sass.ex +++ b/lib/nimble_template/addons/variants/phoenix/web/dart_sass.ex @@ -11,7 +11,6 @@ defmodule NimbleTemplate.Addons.Phoenix.Web.DartSass do |> inject_mix_dependency!() |> edit_config!() |> edit_mix!() - |> edit_app_js!() |> rename_app_css!() end @@ -75,6 +74,7 @@ defmodule NimbleTemplate.Addons.Phoenix.Web.DartSass do "mix.exs", """ "assets.deploy": [ + "tailwind default --minify", "esbuild app --minify", "cmd npm run postcss --prefix assets", "phx.digest" @@ -82,6 +82,7 @@ defmodule NimbleTemplate.Addons.Phoenix.Web.DartSass do """, """ "assets.deploy": [ + "tailwind default --minify", "esbuild app --minify", "sass app --no-source-map --style=compressed", "cmd npm run postcss --prefix assets", @@ -93,20 +94,6 @@ defmodule NimbleTemplate.Addons.Phoenix.Web.DartSass do project end - defp edit_app_js!(project) do - Generator.delete_content!( - "assets/js/app.js", - """ - // We import the CSS which is extracted to its own file by esbuild. - // Remove this line if you add a your own CSS build pipeline (e.g postcss). - import "../css/app.css" - - """ - ) - - project - end - defp rename_app_css!(project) do Generator.rename_file!( "assets/css/app.css", diff --git a/lib/nimble_template/addons/variants/phoenix/web/esbuild.ex b/lib/nimble_template/addons/variants/phoenix/web/esbuild.ex index 5837f93e..a6ed1f83 100644 --- a/lib/nimble_template/addons/variants/phoenix/web/esbuild.ex +++ b/lib/nimble_template/addons/variants/phoenix/web/esbuild.ex @@ -19,7 +19,7 @@ defmodule NimbleTemplate.Addons.Phoenix.Web.EsBuild do end defp edit_mix!(project) do - Generator.replace_content!("mix.exs", "esbuild default", "esbuild app") + Generator.replace_content_all("mix.exs", "esbuild default", "esbuild app") project end diff --git a/lib/nimble_template/addons/variants/phoenix/web/post_css.ex b/lib/nimble_template/addons/variants/phoenix/web/post_css.ex index 78e984ae..aeb55ba1 100644 --- a/lib/nimble_template/addons/variants/phoenix/web/post_css.ex +++ b/lib/nimble_template/addons/variants/phoenix/web/post_css.ex @@ -52,10 +52,11 @@ defmodule NimbleTemplate.Addons.Phoenix.Web.PostCSS do Generator.replace_content!( "mix.exs", """ - "assets.deploy": ["esbuild app --minify", "phx.digest"] + "assets.deploy": ["tailwind default --minify", "esbuild app --minify", "phx.digest"] """, """ "assets.deploy": [ + "tailwind default --minify", "esbuild app --minify", "cmd npm run postcss --prefix assets", "phx.digest" diff --git a/test/nimble_template/addons/variants/phoenix/api/config_test.exs b/test/nimble_template/addons/variants/phoenix/api/config_test.exs index 9229a39a..0536a177 100644 --- a/test/nimble_template/addons/variants/phoenix/api/config_test.exs +++ b/test/nimble_template/addons/variants/phoenix/api/config_test.exs @@ -16,7 +16,7 @@ defmodule NimbleTemplate.Addons.Phoenix.Api.ConfigTest do # For production, don't forget to configure the url host # to something meaningful, Phoenix uses this information # when generating URLs. - # + # Note we also include the path to a cache manifest # containing the digested version of static files. This # manifest is generated by the `mix phx.digest` task, diff --git a/test/nimble_template/addons/variants/phoenix/api/error_view_test.exs b/test/nimble_template/addons/variants/phoenix/api/error_view_test.exs index 080d5746..9c9b2296 100644 --- a/test/nimble_template/addons/variants/phoenix/api/error_view_test.exs +++ b/test/nimble_template/addons/variants/phoenix/api/error_view_test.exs @@ -1,20 +1,20 @@ -defmodule NimbleTemplate.Addons.Phoenix.Api.ErrorViewTest do - use NimbleTemplate.AddonCase, async: false +# defmodule NimbleTemplate.Addons.Phoenix.Api.ErrorViewTest do +# use NimbleTemplate.AddonCase, async: false - describe "#apply!/2" do - test "copies the error view files", %{ - project: project, - test_project_path: project_path - } do - in_test_project!(project_path, fn -> - ApiAddons.ErrorView.apply!(project) +# describe "#apply!/2" do +# test "copies the error view files", %{ +# project: project, +# test_project_path: project_path +# } do +# in_test_project!(project_path, fn -> +# ApiAddons.ErrorView.apply!(project) - assert_file("lib/nimble_template_web/views/error_helpers.ex") - assert_file("lib/nimble_template_web/views/api/error_view.ex") - assert_file("test/nimble_template_web/views/error_helpers_test.exs") - assert_file("test/nimble_template_web/views/api/error_view_test.exs") - assert_file("test/support/view_case.ex") - end) - end - end -end +# assert_file("lib/nimble_template_web/views/error_helpers.ex") +# assert_file("lib/nimble_template_web/views/api/error_view.ex") +# assert_file("test/nimble_template_web/views/error_helpers_test.exs") +# assert_file("test/nimble_template_web/views/api/error_view_test.exs") +# assert_file("test/support/view_case.ex") +# end) +# end +# end +# end diff --git a/test/nimble_template/addons/variants/phoenix/web/bootstrap_test.exs b/test/nimble_template/addons/variants/phoenix/web/bootstrap_test.exs index 8cae3214..cc6494f7 100644 --- a/test/nimble_template/addons/variants/phoenix/web/bootstrap_test.exs +++ b/test/nimble_template/addons/variants/phoenix/web/bootstrap_test.exs @@ -1,249 +1,249 @@ -defmodule NimbleTemplate.Addons.Phoenix.Web.BootstrapTest do - use NimbleTemplate.AddonCase, async: false - - describe "#apply!/2 given no Nimble CSS and Nimble JS structure" do - @describetag required_addons: [ - :TestEnv, - :"Phoenix.Web.NodePackage", - :"Phoenix.Web.EsBuild", - :"Phoenix.Web.PostCSS", - :"Phoenix.Web.DartSass" - ] - @describetag mock_latest_package_versions: [{:dart_sass, "0.26.2"}] - - test "copies Bootstrap vendor file", %{project: project, test_project_path: test_project_path} do - in_test_project!(test_project_path, fn -> - WebAddons.Bootstrap.apply!(project, %{ - with_nimble_css_addon: false, - with_nimble_js_addon: false - }) - - assert_file("assets/css/vendor/_bootstrap.scss") - end) - end - - test "adds Bootstrap into package.json", %{ - project: project, - test_project_path: test_project_path - } do - in_test_project!(test_project_path, fn -> - WebAddons.Bootstrap.apply!(project, %{ - with_nimble_css_addon: false, - with_nimble_js_addon: false - }) - - assert_file("assets/package.json", fn file -> - assert file =~ """ - "dependencies": { - "@popperjs/core": "2.11.5", - "bootstrap": "5.1.3", - """ - end) - end) - end - - test "imports Bootstrap into app.js given", %{ - project: project, - test_project_path: test_project_path - } do - in_test_project!(test_project_path, fn -> - WebAddons.Bootstrap.apply!(project, %{ - with_nimble_js_addon: false, - with_nimble_css_addon: false - }) - - assert_file("assets/js/app.js", fn file -> - assert file =~ """ - import "bootstrap/dist/js/bootstrap"; - """ - end) - end) - end - - test "imports Vendor into app.scss", %{ - project: project, - test_project_path: test_project_path - } do - in_test_project!(test_project_path, fn -> - WebAddons.Bootstrap.apply!(project, %{ - with_nimble_css_addon: false, - with_nimble_js_addon: false - }) - - assert_file("assets/css/app.scss", fn file -> - assert file =~ """ - @import "./phoenix.css"; - - @import './vendor/'; - """ - end) - end) - end - - test "imports bootstrap vendor index file", %{ - project: project, - test_project_path: test_project_path - } do - in_test_project!(test_project_path, fn -> - WebAddons.Bootstrap.apply!(project, %{ - with_nimble_css_addon: false, - with_nimble_js_addon: false - }) - - assert_file("assets/css/vendor/_index.scss", fn file -> - assert file =~ "@import './bootstrap';" - end) - end) - end - - test "creates the assets/css/_variables.scss", %{ - project: project, - test_project_path: test_project_path - } do - in_test_project!(test_project_path, fn -> - WebAddons.Bootstrap.apply!(project, %{ - with_nimble_css_addon: false, - with_nimble_js_addon: false - }) - - assert_file("assets/css/_variables.scss", fn file -> - assert file =~ """ - //////////////////////////////// - // Shared variables // - //////////////////////////////// - - - //////////////////////////////// - // Custom Bootstrap variables // - //////////////////////////////// - """ - end) - end) - end - end - - describe "#apply!/2 given Nimble CSS and Nimble JS structure" do - @describetag required_addons: [ - :TestEnv, - :"Phoenix.Web.NodePackage", - :"Phoenix.Web.StyleLint", - :"Phoenix.Web.EsLint", - :"Phoenix.Web.EsBuild", - :"Phoenix.Web.PostCSS", - :"Phoenix.Web.DartSass", - :"Phoenix.Web.NimbleCSS", - :"Phoenix.Web.NimbleJS" - ] - @describetag mock_latest_package_versions: [{:dart_sass, "0.26.2"}] - - test "copies Bootstrap vendor file", %{project: project, test_project_path: test_project_path} do - in_test_project!(test_project_path, fn -> - WebAddons.Bootstrap.apply!(project, %{ - with_nimble_css_addon: true, - with_nimble_js_addon: true - }) - - assert_file("assets/css/vendor/_bootstrap.scss") - end) - end - - test "adds Bootstrap into package.json", %{ - project: project, - test_project_path: test_project_path - } do - in_test_project!(test_project_path, fn -> - WebAddons.Bootstrap.apply!(project, %{ - with_nimble_css_addon: true, - with_nimble_js_addon: true - }) - - assert_file("assets/package.json", fn file -> - assert file =~ """ - "dependencies": { - "@popperjs/core": "2.11.5", - "bootstrap": "5.1.3", - """ - end) - end) - end - - test "imports Bootstrap into app.js", %{ - project: project, - test_project_path: test_project_path - } do - in_test_project!(test_project_path, fn -> - WebAddons.Bootstrap.apply!(project, %{ - with_nimble_css_addon: true, - with_nimble_js_addon: true - }) - - assert_file("assets/js/app.js", fn file -> - assert file =~ """ - import "bootstrap/dist/js/bootstrap"; - """ - end) - end) - end - - test "does not import Vendor into app.scss", %{ - project: project, - test_project_path: test_project_path - } do - in_test_project!(test_project_path, fn -> - WebAddons.Bootstrap.apply!(project, %{ - with_nimble_css_addon: true, - with_nimble_js_addon: true - }) - - assert_file("assets/css/app.scss", fn file -> - assert file =~ """ - @import './functions'; - - @import './vendor'; - """ - end) - end) - end - - test "imports bootstrap vendor index file", %{ - project: project, - test_project_path: test_project_path - } do - in_test_project!(test_project_path, fn -> - WebAddons.Bootstrap.apply!(project, %{ - with_nimble_css_addon: true, - with_nimble_js_addon: true - }) - - assert_file("assets/css/vendor/_index.scss", fn file -> - assert file =~ "@import './bootstrap';" - end) - end) - end - - test "updates the assets/css/_variables.scss", %{ - project: project, - test_project_path: test_project_path - } do - in_test_project!(test_project_path, fn -> - WebAddons.Bootstrap.apply!(project, %{ - with_nimble_css_addon: true, - with_nimble_js_addon: true - }) - - assert_file("assets/css/_variables.scss", fn file -> - assert file =~ """ - //////////////////////////////// - // Shared variables // - //////////////////////////////// - - - //////////////////////////////// - // Custom Bootstrap variables // - //////////////////////////////// - """ - end) - end) - end - end -end +# defmodule NimbleTemplate.Addons.Phoenix.Web.BootstrapTest do +# use NimbleTemplate.AddonCase, async: false + +# describe "#apply!/2 given no Nimble CSS and Nimble JS structure" do +# @describetag required_addons: [ +# :TestEnv, +# :"Phoenix.Web.NodePackage", +# :"Phoenix.Web.EsBuild", +# :"Phoenix.Web.PostCSS", +# :"Phoenix.Web.DartSass" +# ] +# @describetag mock_latest_package_versions: [{:dart_sass, "0.26.2"}] + +# test "copies Bootstrap vendor file", %{project: project, test_project_path: test_project_path} do +# in_test_project!(test_project_path, fn -> +# WebAddons.Bootstrap.apply!(project, %{ +# with_nimble_css_addon: false, +# with_nimble_js_addon: false +# }) + +# assert_file("assets/css/vendor/_bootstrap.scss") +# end) +# end + +# test "adds Bootstrap into package.json", %{ +# project: project, +# test_project_path: test_project_path +# } do +# in_test_project!(test_project_path, fn -> +# WebAddons.Bootstrap.apply!(project, %{ +# with_nimble_css_addon: false, +# with_nimble_js_addon: false +# }) + +# assert_file("assets/package.json", fn file -> +# assert file =~ """ +# "dependencies": { +# "@popperjs/core": "2.11.5", +# "bootstrap": "5.1.3", +# """ +# end) +# end) +# end + +# test "imports Bootstrap into app.js given", %{ +# project: project, +# test_project_path: test_project_path +# } do +# in_test_project!(test_project_path, fn -> +# WebAddons.Bootstrap.apply!(project, %{ +# with_nimble_js_addon: false, +# with_nimble_css_addon: false +# }) + +# assert_file("assets/js/app.js", fn file -> +# assert file =~ """ +# import "bootstrap/dist/js/bootstrap"; +# """ +# end) +# end) +# end + +# test "imports Vendor into app.scss", %{ +# project: project, +# test_project_path: test_project_path +# } do +# in_test_project!(test_project_path, fn -> +# WebAddons.Bootstrap.apply!(project, %{ +# with_nimble_css_addon: false, +# with_nimble_js_addon: false +# }) + +# assert_file("assets/css/app.scss", fn file -> +# assert file =~ """ +# @import "./phoenix.css"; + +# @import './vendor/'; +# """ +# end) +# end) +# end + +# test "imports bootstrap vendor index file", %{ +# project: project, +# test_project_path: test_project_path +# } do +# in_test_project!(test_project_path, fn -> +# WebAddons.Bootstrap.apply!(project, %{ +# with_nimble_css_addon: false, +# with_nimble_js_addon: false +# }) + +# assert_file("assets/css/vendor/_index.scss", fn file -> +# assert file =~ "@import './bootstrap';" +# end) +# end) +# end + +# test "creates the assets/css/_variables.scss", %{ +# project: project, +# test_project_path: test_project_path +# } do +# in_test_project!(test_project_path, fn -> +# WebAddons.Bootstrap.apply!(project, %{ +# with_nimble_css_addon: false, +# with_nimble_js_addon: false +# }) + +# assert_file("assets/css/_variables.scss", fn file -> +# assert file =~ """ +# //////////////////////////////// +# // Shared variables // +# //////////////////////////////// + + +# //////////////////////////////// +# // Custom Bootstrap variables // +# //////////////////////////////// +# """ +# end) +# end) +# end +# end + +# describe "#apply!/2 given Nimble CSS and Nimble JS structure" do +# @describetag required_addons: [ +# :TestEnv, +# :"Phoenix.Web.NodePackage", +# :"Phoenix.Web.StyleLint", +# :"Phoenix.Web.EsLint", +# :"Phoenix.Web.EsBuild", +# :"Phoenix.Web.PostCSS", +# :"Phoenix.Web.DartSass", +# :"Phoenix.Web.NimbleCSS", +# :"Phoenix.Web.NimbleJS" +# ] +# @describetag mock_latest_package_versions: [{:dart_sass, "0.26.2"}] + +# test "copies Bootstrap vendor file", %{project: project, test_project_path: test_project_path} do +# in_test_project!(test_project_path, fn -> +# WebAddons.Bootstrap.apply!(project, %{ +# with_nimble_css_addon: true, +# with_nimble_js_addon: true +# }) + +# assert_file("assets/css/vendor/_bootstrap.scss") +# end) +# end + +# test "adds Bootstrap into package.json", %{ +# project: project, +# test_project_path: test_project_path +# } do +# in_test_project!(test_project_path, fn -> +# WebAddons.Bootstrap.apply!(project, %{ +# with_nimble_css_addon: true, +# with_nimble_js_addon: true +# }) + +# assert_file("assets/package.json", fn file -> +# assert file =~ """ +# "dependencies": { +# "@popperjs/core": "2.11.5", +# "bootstrap": "5.1.3", +# """ +# end) +# end) +# end + +# test "imports Bootstrap into app.js", %{ +# project: project, +# test_project_path: test_project_path +# } do +# in_test_project!(test_project_path, fn -> +# WebAddons.Bootstrap.apply!(project, %{ +# with_nimble_css_addon: true, +# with_nimble_js_addon: true +# }) + +# assert_file("assets/js/app.js", fn file -> +# assert file =~ """ +# import "bootstrap/dist/js/bootstrap"; +# """ +# end) +# end) +# end + +# test "does not import Vendor into app.scss", %{ +# project: project, +# test_project_path: test_project_path +# } do +# in_test_project!(test_project_path, fn -> +# WebAddons.Bootstrap.apply!(project, %{ +# with_nimble_css_addon: true, +# with_nimble_js_addon: true +# }) + +# assert_file("assets/css/app.scss", fn file -> +# assert file =~ """ +# @import './functions'; + +# @import './vendor'; +# """ +# end) +# end) +# end + +# test "imports bootstrap vendor index file", %{ +# project: project, +# test_project_path: test_project_path +# } do +# in_test_project!(test_project_path, fn -> +# WebAddons.Bootstrap.apply!(project, %{ +# with_nimble_css_addon: true, +# with_nimble_js_addon: true +# }) + +# assert_file("assets/css/vendor/_index.scss", fn file -> +# assert file =~ "@import './bootstrap';" +# end) +# end) +# end + +# test "updates the assets/css/_variables.scss", %{ +# project: project, +# test_project_path: test_project_path +# } do +# in_test_project!(test_project_path, fn -> +# WebAddons.Bootstrap.apply!(project, %{ +# with_nimble_css_addon: true, +# with_nimble_js_addon: true +# }) + +# assert_file("assets/css/_variables.scss", fn file -> +# assert file =~ """ +# //////////////////////////////// +# // Shared variables // +# //////////////////////////////// + + +# //////////////////////////////// +# // Custom Bootstrap variables // +# //////////////////////////////// +# """ +# end) +# end) +# end +# end +# end diff --git a/test/nimble_template/addons/variants/phoenix/web/dart_sass_test.exs b/test/nimble_template/addons/variants/phoenix/web/dart_sass_test.exs index 0ad8d94b..2b2828bb 100644 --- a/test/nimble_template/addons/variants/phoenix/web/dart_sass_test.exs +++ b/test/nimble_template/addons/variants/phoenix/web/dart_sass_test.exs @@ -37,6 +37,7 @@ defmodule NimbleTemplate.Addons.Phoenix.Web.DartSassTest do assert_file("mix.exs", fn file -> assert file =~ """ "assets.deploy": [ + "tailwind default --minify", "esbuild app --minify", "sass app --no-source-map --style=compressed", "cmd npm run postcss --prefix assets", diff --git a/test/nimble_template/addons/variants/phoenix/web/esbuild_test.exs b/test/nimble_template/addons/variants/phoenix/web/esbuild_test.exs index 9d4dbc9f..aa9d004c 100644 --- a/test/nimble_template/addons/variants/phoenix/web/esbuild_test.exs +++ b/test/nimble_template/addons/variants/phoenix/web/esbuild_test.exs @@ -10,7 +10,7 @@ defmodule NimbleTemplate.Addons.Phoenix.Web.EsBuildTest do WebAddons.EsBuild.apply!(project) assert_file("mix.exs", fn file -> - assert file =~ "\"assets.deploy\": [\"esbuild app --minify\"," + assert file =~ "\"esbuild app --minify\"," end) end) end @@ -25,7 +25,7 @@ defmodule NimbleTemplate.Addons.Phoenix.Web.EsBuildTest do assert_file("config/config.exs", fn file -> assert file =~ """ config :esbuild, - version: "0.14.29", + version: "0.14.41", app: [ args: """ diff --git a/test/nimble_template/addons/variants/phoenix/web/post_css_test.exs b/test/nimble_template/addons/variants/phoenix/web/post_css_test.exs index 2d30edb3..c8b14e83 100644 --- a/test/nimble_template/addons/variants/phoenix/web/post_css_test.exs +++ b/test/nimble_template/addons/variants/phoenix/web/post_css_test.exs @@ -16,6 +16,7 @@ defmodule NimbleTemplate.Addons.Phoenix.Web.PostCSSTest do assert_file("mix.exs", fn file -> assert file =~ """ "assets.deploy": [ + "tailwind default --minify", "esbuild app --minify", "cmd npm run postcss --prefix assets", "phx.digest"