Current section

Files

Jump to
phx_custom lib phx_custom web.ex
Raw

lib/phx_custom/web.ex

defmodule PhxCustom.Web do
alias PhxCustom.Project
alias PhxCustom.Generator
alias PhxCustom.Reporter
@app PhxCustom.MixProject.project()[:app]
def patch(root) do
assigns = Project.inspect(root)
web_root = Keyword.get(assigns, :web_root)
project_name = Keyword.get(assigns, :project_name)
Generator.delete(
[
"assets",
"priv/static",
"lib/#{project_name}_web/controllers/*",
"lib/#{project_name}_web/templates/*",
"lib/#{project_name}_web/views/page_view.ex"
]
|> Enum.map(&Path.join(web_root, &1))
)
template_base = Path.expand("templates/web", :code.priv_dir(@app))
Generator.copy_dir(
Path.expand("assets", template_base),
Path.expand("assets", web_root)
)
Generator.copy_dir(
Path.expand("lib/_web", template_base),
Path.expand("lib/#{project_name}_web", web_root),
assigns
)
post_file = Path.expand("post-info.txt.eex", template_base)
Reporter.report(post_file, assigns)
end
end