Repository: phoenixframework/phoenix
Pull request #2171 (2017-03-08 14:08:58)

not-web app secret config generated with phx.new --umbrella is not ignored
`mix phx.new --umbrella` creates two application in an umbrella project, say `my_app` and `my_app_web`. I found that `prod.secret.exs` in `apps/my_app/config` is not listed in `gitignore`. So the file possibly accidentally be under version controlled. I guess this is not intended.

In this pull request, I add a line simply ignoring `config/*.secret.exs`. Would you let me know If there is any other good solution or some reasons that it is not ignored.

Thanks.

Joe-noh: noticed that `apps/my_app/.gitignore` is not generated. Is there another problem?

Patch:
diff --git a/installer/lib/phx_new/ecto.ex b/installer/lib/phx_new/ecto.ex
index 41e37f06a..9a810619a 100644
--- a/installer/lib/phx_new/ecto.ex
+++ b/installer/lib/phx_new/ecto.ex
@@ -6,15 +6,16 @@ defmodule Phx.New.Ecto do
   @pre "phx_umbrella/apps/app_name"
 
   template :new, [
-    {:eex, "#{@pre}/config/config.exs",           :app, "config/config.exs"},
-    {:eex, "#{@pre}/config/dev.exs",              :app, "config/dev.exs"},
-    {:eex, "#{@pre}/config/prod.exs",             :app, "config/prod.exs"},
-    {:eex, "#{@pre}/config/prod.secret.exs",      :app, "config/prod.secret.exs"},
-    {:eex, "#{@pre}/config/test.exs",             :app, "config/test.exs"},
-    {:eex, "#{@pre}/lib/app_name/application.ex", :app, "lib/:app/application.ex"},
-    {:eex, "#{@pre}/test/test_helper.exs",        :app, "test/test_helper.exs"},
-    {:eex, "#{@pre}/README.md",                   :app, "README.md"},
-    {:eex, "#{@pre}/mix.exs",                     :app, "mix.exs"},
+    {:eex,  "#{@pre}/config/config.exs",           :app, "config/config.exs"},
+    {:eex,  "#{@pre}/config/dev.exs",              :app, "config/dev.exs"},
+    {:eex,  "#{@pre}/config/prod.exs",             :app, "config/prod.exs"},
+    {:eex,  "#{@pre}/config/prod.secret.exs",      :app, "config/prod.secret.exs"},
+    {:eex,  "#{@pre}/config/test.exs",             :app, "config/test.exs"},
+    {:eex,  "#{@pre}/lib/app_name/application.ex", :app, "lib/:app/application.ex"},
+    {:eex,  "#{@pre}/test/test_helper.exs",        :app, "test/test_helper.exs"},
+    {:eex,  "#{@pre}/README.md",                   :app, "README.md"},
+    {:eex,  "#{@pre}/mix.exs",                     :app, "mix.exs"},
+    {:text, "phx_assets/bare/gitignore",           :app, ".gitignore"},
   ]
 
   template :ecto, [
diff --git a/installer/templates/phx_umbrella/apps/app_name/gitignore b/installer/templates/phx_umbrella/apps/app_name/gitignore
deleted file mode 100644
index 755b60554..000000000
--- a/installer/templates/phx_umbrella/apps/app_name/gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-/_build
-/cover
-/deps
-erl_crash.dump
-*.ez
diff --git a/lib/mix/tasks/phx.gen.context.ex b/lib/mix/tasks/phx.gen.context.ex
index 494d4984f..f18757c24 100644
--- a/lib/mix/tasks/phx.gen.context.ex
+++ b/lib/mix/tasks/phx.gen.context.ex
@@ -100,10 +100,9 @@ defmodule Mix.Tasks.Phx.Gen.Context do
     context
   end
 
-  defp inject_schema_access(%Context{dir: dir, file: file} = context, paths, binding) do
+  defp inject_schema_access(%Context{file: file} = context, paths, binding) do
     unless context.pre_existing? do
-      File.mkdir_p!(dir)
-      File.write!(file, Mix.Phoenix.eval_from(paths, "priv/templates/phx.gen.context/context.ex", binding))
+      Mix.Generator.create_file(file, Mix.Phoenix.eval_from(paths, "priv/templates/phx.gen.context/context.ex", binding))
     end
 
     schema_content = Mix.Phoenix.eval_from(paths, "priv/templates/phx.gen.context/schema_access.ex", binding)
diff --git a/lib/phoenix/endpoint/supervisor.ex b/lib/phoenix/endpoint/supervisor.ex
index ed154614b..3d7981a7d 100644
--- a/lib/phoenix/endpoint/supervisor.ex
+++ b/lib/phoenix/endpoint/supervisor.ex
@@ -21,6 +21,10 @@ defmodule Phoenix.Endpoint.Supervisor do
   end
 
   @doc false
+  # TODO: Ideally every process would be named based on a `name` option
+  # instead of using the module. However, __phoenix_pubsub__ is highly
+  # dependent on the module name, so we should consider enabling this
+  # once we move to Firenest.
   def init({otp_app, mod}) do
     id = :crypto.strong_rand_bytes(16) |> Base.encode64
     conf = [endpoint_id: id] ++ config(otp_app, mod)
@@ -57,7 +61,6 @@ defmodule Phoenix.Endpoint.Supervisor do
     [worker(Phoenix.Config, args)]
   end
 
-  # TODO: Consider moving this out of the endpoint once we introduce firenest
   defp pubsub_children(mod, conf) do
     pub_conf = conf[:pubsub]
 


Test patch:
diff --git a/installer/test/phx_new_umbrella_test.exs b/installer/test/phx_new_umbrella_test.exs
index 0d81ee737..022269ee2 100644
--- a/installer/test/phx_new_umbrella_test.exs
+++ b/installer/test/phx_new_umbrella_test.exs
@@ -36,6 +36,7 @@ defmodule Mix.Tasks.Phx.New.UmbrellaTest do
       assert_file root_path(@app, "README.md")
       assert_file root_path(@app, ".gitignore")
       assert_file app_path(@app, "README.md")
+      assert_file app_path(@app, ".gitignore")
       assert_file web_path(@app, "README.md")
       assert_file root_path(@app, "mix.exs"), fn file ->
         assert file =~ "apps_path: \"apps\""