Packages
phx_new
1.7.0
1.8.9
1.8.8
1.8.7
1.8.6
1.8.5
1.8.4
1.8.3
1.8.2
1.8.1
1.8.0
1.8.0-rc.4
1.8.0-rc.3
1.8.0-rc.2
1.8.0-rc.1
1.8.0-rc.0
1.7.24
1.7.23
1.7.22
1.7.21
1.7.20
1.7.19
1.7.18
1.7.17
1.7.16
1.7.15
1.7.14
1.7.13
1.7.12
1.7.11
1.7.10
1.7.9
1.7.8
1.7.7
1.7.6
1.7.5
1.7.4
1.7.3
1.7.2
1.7.1
1.7.0
1.7.0-rc.3
1.7.0-rc.2
1.7.0-rc.1
1.7.0-rc.0
1.6.17
1.6.16
1.6.15
1.6.14
1.6.13
1.6.12
1.6.11
1.6.10
1.6.9
1.6.8
1.6.7
1.6.6
1.6.5
1.6.4
1.6.3
1.6.2
1.6.1
1.6.0
1.6.0-rc.1
1.6.0-rc.0
1.5.15
1.5.14
1.5.13
1.5.12
1.5.11
1.5.10
1.5.9
1.5.8
1.5.7
1.5.6
1.5.5
1.5.4
1.5.3
1.5.2
1.5.1
1.5.0
1.5.0-rc.0
1.4.18
1.4.17
1.4.16
1.4.15
1.4.14
1.4.13
1.4.12
1.4.11
1.4.10
1.4.9
1.4.8
1.4.7
1.4.6
1.4.5
1.4.4
1.4.3
1.4.2
1.4.1
1.4.0
1.4.0-rc.3
1.4.0-rc.2
1.4.0-rc.1
1.4.0-rc.0
1.4.0-dev.0
1.3.5
Phoenix framework project generator. Provides a `mix phx.new` task to bootstrap a new Elixir application with Phoenix dependencies.
Current section
Files
Jump to
Current section
Files
lib/phx_new/web.ex
defmodule Phx.New.Web do
@moduledoc false
use Phx.New.Generator
alias Phx.New.{Project}
@pre "phx_umbrella/apps/app_name_web"
template(:new, [
{:prod_config, :project, "#{@pre}/config/runtime.exs": "config/runtime.exs"},
{:config, :project,
"#{@pre}/config/config.exs": "config/config.exs",
"#{@pre}/config/dev.exs": "config/dev.exs",
"#{@pre}/config/prod.exs": "config/prod.exs",
"#{@pre}/config/test.exs": "config/test.exs"},
{:keep, :web,
"phx_web/controllers": "lib/:web_app/controllers",
"phx_test/channels": "test/:web_app/channels",
"phx_test/controllers": "test/:web_app/controllers"},
{:eex, :web,
"#{@pre}/lib/app_name.ex": "lib/:web_app.ex",
"#{@pre}/lib/app_name/application.ex": "lib/:web_app/application.ex",
"phx_web/endpoint.ex": "lib/:web_app/endpoint.ex",
"phx_web/router.ex": "lib/:web_app/router.ex",
"phx_web/telemetry.ex": "lib/:web_app/telemetry.ex",
"phx_web/controllers/error_json.ex": "lib/:web_app/controllers/error_json.ex",
"#{@pre}/mix.exs": "mix.exs",
"#{@pre}/README.md": "README.md",
"#{@pre}/gitignore": ".gitignore",
"#{@pre}/test/test_helper.exs": "test/test_helper.exs",
"phx_test/support/conn_case.ex": "test/support/conn_case.ex",
"phx_test/controllers/error_html_test.exs": "test/:web_app/controllers/error_html_test.exs",
"phx_test/controllers/error_json_test.exs": "test/:web_app/controllers/error_json_test.exs",
"#{@pre}/formatter.exs": ".formatter.exs"}
])
template(:gettext, [
{:eex, :web,
"phx_gettext/gettext.ex": "lib/:web_app/gettext.ex",
"phx_gettext/en/LC_MESSAGES/errors.po": "priv/gettext/en/LC_MESSAGES/errors.po",
"phx_gettext/errors.pot": "priv/gettext/errors.pot"}
])
template(:html, [
{:eex, :web,
"phx_web/components/core_components.ex": "lib/:web_app/components/core_components.ex",
"phx_web/components/layouts.ex": "lib/:web_app/components/layouts.ex",
"phx_web/controllers/page_controller.ex": "lib/:web_app/controllers/page_controller.ex",
"phx_web/controllers/error_html.ex": "lib/:web_app/controllers/error_html.ex",
"phx_web/controllers/page_html.ex": "lib/:web_app/controllers/page_html.ex",
"phx_web/controllers/page_html/home.html.heex":
"lib/:web_app/controllers/page_html/home.html.heex",
"phx_test/controllers/page_controller_test.exs":
"test/:web_app/controllers/page_controller_test.exs",
"phx_assets/topbar.js": "assets/vendor/topbar.js",
"phx_web/components/layouts/root.html.heex": "lib/:web_app/components/layouts/root.html.heex",
"phx_web/components/layouts/app.html.heex": "lib/:web_app/components/layouts/app.html.heex"}
])
def prepare_project(%Project{app: app} = project) when not is_nil(app) do
web_path = Path.expand(project.base_path)
project_path = Path.dirname(Path.dirname(web_path))
%Project{
project
| in_umbrella?: true,
project_path: project_path,
web_path: web_path,
web_app: app,
generators: [context_app: false],
web_namespace: project.app_mod
}
end
def generate(%Project{} = project) do
inject_umbrella_config_defaults(project)
copy_from(project, __MODULE__, :new)
if Project.html?(project), do: gen_html(project)
if Project.gettext?(project), do: gen_gettext(project)
Phx.New.Single.gen_assets(project)
project
end
defp gen_html(%Project{} = project) do
copy_from(project, __MODULE__, :html)
end
defp gen_gettext(%Project{} = project) do
copy_from(project, __MODULE__, :gettext)
end
end