Skip to content

Commit

Permalink
moving phx_host to mix_release
Browse files Browse the repository at this point in the history
  • Loading branch information
andyduong1920 committed Mar 3, 2022
1 parent 65473dd commit 77be419
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 24 deletions.
15 changes: 0 additions & 15 deletions lib/nimble_template/addons/github.ex
Original file line number Diff line number Diff line change
Expand Up @@ -89,21 +89,6 @@ defmodule NimbleTemplate.Addons.Github do
"url: [scheme: \"https\", host: host,"
)

Generator.replace_content(
"config/runtime.exs",
"""
host = System.get_env("PHX_HOST") || "example.com"
""",
"""
host =
System.get_env("PHX_HOST") ||
raise \"\"\"
Environment variable PHX_HOST is missing.
Set the Heroku endpoint to this variable.
\"\"\"
"""
)

Generator.append_content(
"config/prod.exs",
"""
Expand Down
15 changes: 15 additions & 0 deletions lib/nimble_template/addons/variants/phoenix/mix_release.ex
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,21 @@ defmodule NimbleTemplate.Addons.Phoenix.MixRelease do
"""
)

Generator.replace_content(
"config/runtime.exs",
"""
host = System.get_env("PHX_HOST") || "example.com"
""",
"""
host =
System.get_env("PHX_HOST") ||
raise \"\"\"
Environment variable PHX_HOST is missing.
Set the Heroku endpoint to this variable.
\"\"\"
"""
)

project
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@
### Endpoint configuration

- `HEALTH_PATH`: Health path (eg: "/_health")
- `PHX_HOST`: The application endpoint.
- `SECRET_KEY_BASE`: Secret key base
9 changes: 0 additions & 9 deletions test/nimble_template/addons/github_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -304,15 +304,6 @@ defmodule NimbleTemplate.Addons.GithubTest do
config :nimble_template, NimbleTemplate.Repo,
ssl: true,
"""

assert file =~ """
host =
System.get_env("PHX_HOST") ||
raise \"\"\"
Environment variable PHX_HOST is missing.
Set the Heroku endpoint to this variable.
\"\"\"
"""
end)
end)
end
Expand Down
9 changes: 9 additions & 0 deletions test/nimble_template/addons/variants/mix_release_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ defmodule NimbleTemplate.Addons.Phoenix.MixReleaseTest do
server: true,
"""

assert file =~ """
host =
System.get_env("PHX_HOST") ||
raise \"\"\"
Environment variable PHX_HOST is missing.
Set the Heroku endpoint to this variable.
\"\"\"
"""

refute file =~ """
# ## Using releases
Expand Down

0 comments on commit 77be419

Please sign in to comment.