Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[gh315] Support Phoenix 1.7.x #318

Draft
wants to merge 51 commits into
base: develop
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
0abae0b
[gh315] Upgrade the template dependencies and Phoenix to 1.7.0
andyduong1920 Feb 27, 2023
f4c0e85
[gh315] Remove Phoenix view
andyduong1920 Feb 27, 2023
f2da7a0
[gh315] Upgrade to Phoenix 1.7.1
andyduong1920 Mar 10, 2023
29121fa
[gh315] Upgrade the docs
andyduong1920 Mar 10, 2023
ec3d4b8
[gh315] Do not need --no-live when the --no-html is given
andyduong1920 Mar 10, 2023
8285a95
[gh315] Update - 1
andyduong1920 Mar 10, 2023
e0f71d3
[gh315] Update - 2
andyduong1920 Mar 10, 2023
898d053
[gh315] Format
andyduong1920 Mar 10, 2023
e5c6bac
[gh315] Format
andyduong1920 Mar 10, 2023
8fafd23
[gh315] Fix the gettext
andyduong1920 Mar 10, 2023
d711e97
[gh315] Fix linting
andyduong1920 Mar 10, 2023
993f8bf
[gh315] Fix the wallaby with httppoison
andyduong1920 Mar 10, 2023
21f9553
[gh315] Fix format
andyduong1920 Mar 10, 2023
e01a3a9
[gh315] Fix wallaby
andyduong1920 Mar 10, 2023
ba9d749
[gh315] Fix wallaby
andyduong1920 Mar 10, 2023
a7067d6
[gh315] Disable SVG
andyduong1920 Mar 10, 2023
cfee357
[gh315] Fix the CoreComponents
andyduong1920 Mar 10, 2023
d58e92a
[gh315] Fix the CoreComponents
andyduong1920 Mar 10, 2023
9963795
[gh315] Fix the CoreComponents
andyduong1920 Mar 10, 2023
33e0727
[gh315] Disable the EmptyBodyParamsPlugTest
andyduong1920 Mar 10, 2023
cbf2e4f
[gh315] Remove the httppoison as Wallaby released the new version
andyduong1920 Mar 14, 2023
20a369e
Remove the CoreComponent
andyduong1920 Mar 15, 2023
d91d395
[gh315] Fix the credo on the web entry point
andyduong1920 Mar 15, 2023
d8fd6aa
[gh315] Fix the credo and the feature test
andyduong1920 Mar 15, 2023
766e541
[gh315] Fix the credo and the feature test
andyduong1920 Mar 15, 2023
9890876
[gh315] Skip test on the core_components
andyduong1920 Mar 15, 2023
ad453cc
[gh315] Fix credo helper
andyduong1920 Mar 15, 2023
87b59ce
[gh315] Fix credo helper
andyduong1920 Mar 15, 2023
0b73dc2
Initial
liamstevens111 Mar 15, 2023
f8225ad
Remove duplicate code introduced
liamstevens111 Mar 16, 2023
47bdea3
Change IconHelper tests to pipe |> syntax
liamstevens111 Mar 16, 2023
25fd192
Merge pull request #320 from nimblehq/feature/incorporate-verified-ro…
andyduong1920 Mar 16, 2023
614792e
Initial conversion from ErrorView to ErrorJSON view
liamstevens111 Mar 17, 2023
a9d9325
Change to match pre-existing custom error output and tests
liamstevens111 Mar 17, 2023
9baa1c5
Add Plug.Conn.Status alias
liamstevens111 Mar 17, 2023
4a0c259
Add test for non-exisitant error code
liamstevens111 Mar 17, 2023
3e26ff0
Include changeset error output and tests
liamstevens111 Mar 19, 2023
b496595
Disable singlemodulefile CompassCredoCheck for test file
liamstevens111 Mar 19, 2023
d9a3c6c
Add test for ensuring file exists for ErrorJSON in template
liamstevens111 Mar 19, 2023
116856a
Fix webmodule name for Gettext
liamstevens111 Mar 19, 2023
2bd1e00
Add ErrorJSON to multiple module disable rule
liamstevens111 Mar 19, 2023
33b9e63
Use translate_error/1 from CoreComponents instead of redefining
liamstevens111 Mar 20, 2023
c725541
Change to use ErrorJSON in Fallback Controller and check_empty_body_p…
liamstevens111 Mar 20, 2023
4e7621b
Fix CoreComponent webmodule prefix for translate
liamstevens111 Mar 20, 2023
2887ee6
Fix CoreComponent import again
liamstevens111 Mar 20, 2023
31aea20
Add back translate_errors as CoreComponents cant be found
liamstevens111 Mar 20, 2023
8d6bb13
Update ViewCase although it doesn't seem to be used
liamstevens111 Mar 21, 2023
d408554
Update ViewCase although it doesn't seem to be used
liamstevens111 Mar 21, 2023
334c0da
Remove TODO and RouteHelper from feature_case and view_case
liamstevens111 Apr 4, 2023
dece778
Remove RouteHelper from tests
liamstevens111 Apr 4, 2023
0fc9f5a
Merge pull request #323 from nimblehq/feature/revisit-error-view
andyduong1920 Apr 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[gh315] Fix the credo on the web entry point
  • Loading branch information
andyduong1920 committed Mar 15, 2023
commit d91d3952a8ce1a62d6f4b637853954843e8ae9bd
44 changes: 44 additions & 0 deletions lib/nimble_template/addons/credo.ex
Original file line number Diff line number Diff line change
@@ -33,6 +33,7 @@ defmodule NimbleTemplate.Addons.Credo do
project
|> inject_mix_dependency!()
|> edit_mix!()
|> edit_web_entry!()
end

defp inject_mix_dependency!(project) do
@@ -59,4 +60,47 @@ defmodule NimbleTemplate.Addons.Credo do

project
end

defp edit_web_entry!(
%Project{web_path: web_path, web_module: web_module, web_project?: true} = project
) do
Generator.delete_content!(
"#{web_path}.ex",
"""
def verified_routes do
quote do
use Phoenix.VerifiedRoutes,
endpoint: #{web_module}.Endpoint,
router: #{web_module}.Router,
statics: #{web_module}.static_paths()
end
end
"""
)

Generator.replace_content!(
"#{web_path}.ex",
"""
defp html_helpers do
""",
"""
def verified_routes do
quote do
use Phoenix.VerifiedRoutes,
endpoint: #{web_module}.Endpoint,
router: #{web_module}.Router,
statics: #{web_module}.static_paths()
end
end

defp html_helpers do
"""
)

project
end

defp edit_web_entry!(project) do
project
end
end
20 changes: 20 additions & 0 deletions lib/nimble_template/helpers/credo.ex
Original file line number Diff line number Diff line change
@@ -2,6 +2,8 @@ defmodule NimbleTemplate.CredoHelper do
alias NimbleTemplate.Generator
alias NimbleTemplate.Projects.Project

# TODO: Move this to the Credo Addon

@do_single_expression_rule_name "CompassCredoPlugin.Check.DoSingleExpression"
@single_module_file_rule_name "CompassCredoPlugin.Check.SingleModuleFile"

@@ -19,6 +21,8 @@ defmodule NimbleTemplate.CredoHelper do
project
|> get_files_containing_single_expression()
|> disable_rules(@do_single_expression_rule_name)

disable_on_core_components(project)
end

@spec suppress_credo_warnings_for_phoenix_api_project(Project.t()) :: :ok
@@ -32,6 +36,8 @@ defmodule NimbleTemplate.CredoHelper do
project
|> get_files_containing_single_expression()
|> disable_rules(@do_single_expression_rule_name)

disable_on_core_components(project)
end

defp get_files_containing_single_expression(%Project{
@@ -70,4 +76,18 @@ defmodule NimbleTemplate.CredoHelper do
""")
end
end

# TODO: Could remove the core_components file as we might not need it
defp disable_on_core_components(%Project{web_path: web_path}) do
core_components_path = "#{web_path}/components/core_components.ex"

if File.exists?(core_components_path) do
Generator.prepend_content(
core_components_path,
"""
# credo:disable-for-this-file
"""
)
end
end
end