Repository: phoenixframework/phoenix
Pull request #2430 (2017-08-03 05:48:07)

typo: Paramaters -> Parameters


Patch:
diff --git a/assets/js/phoenix.js b/assets/js/phoenix.js
index 309ab850c..7d1ff16fe 100644
--- a/assets/js/phoenix.js
+++ b/assets/js/phoenix.js
@@ -728,7 +728,7 @@ export class Socket {
    * Initiates a new channel for the given topic
    *
    * @param {string} topic
-   * @param {Object} chanParams - Paramaters for the channel
+   * @param {Object} chanParams - Parameters for the channel
    * @returns {Channel}
    */
   channel(topic, chanParams = {}){
diff --git a/installer/lib/phx_new/generator.ex b/installer/lib/phx_new/generator.ex
index aae8289e5..8b096c479 100644
--- a/installer/lib/phx_new/generator.ex
+++ b/installer/lib/phx_new/generator.ex
@@ -126,14 +126,14 @@ defmodule Phx.New.Generator do
       adapter_app: adapter_app,
       adapter_module: adapter_module,
       adapter_config: adapter_config,
-      generators: generators(adapter_config),
+      generators: nil_if_empty(project.generators ++ adapter_generators(adapter_config)),
       namespaced?: namespaced?(project)]
 
     %Project{project | binding: binding}
   end
 
   defp namespaced?(project) do
-    project.in_umbrella? || Macro.camelize(project.app) != inspect(project.app_mod)
+    Macro.camelize(project.app) != inspect(project.app_mod)
   end
 
   def gen_ecto_config(%Project{app_path: app_path, binding: binding}) do
@@ -198,16 +198,15 @@ defmodule Phx.New.Generator do
     end)
   end
 
-  defp generators(adapter_config) do
+  defp adapter_generators(adapter_config) do
     adapter_config
     |> Keyword.take([:binary_id, :migration, :sample_binary_id])
     |> Enum.filter(fn {_, value} -> not is_nil(value) end)
-    |> case do
-      [] -> nil
-      conf -> conf
-    end
   end
 
+  defp nil_if_empty([]), do: nil
+  defp nil_if_empty(other), do: other
+
   defp phoenix_path(%Project{} = project, true) do
     absolute = Path.expand(project.project_path)
     relative = Path.relative_to(absolute, @phoenix)
diff --git a/installer/lib/phx_new/project.ex b/installer/lib/phx_new/project.ex
index cc9238bfd..f0ae8d37a 100644
--- a/installer/lib/phx_new/project.ex
+++ b/installer/lib/phx_new/project.ex
@@ -15,8 +15,8 @@ defmodule Phx.New.Project do
             web_path: nil,
             opts: :unset,
             in_umbrella?: false,
-            web_applications: [],
-            binding: []
+            binding: [],
+            generators: []
 
   def new(project_path, opts) do
     project_path = Path.expand(project_path)
diff --git a/installer/lib/phx_new/umbrella.ex b/installer/lib/phx_new/umbrella.ex
index 9b6f8a230..5f88f321c 100644
--- a/installer/lib/phx_new/umbrella.ex
+++ b/installer/lib/phx_new/umbrella.ex
@@ -28,14 +28,15 @@ defmodule Phx.New.Umbrella do
              app_path: app_path,
              project_path: project_path}
   end
-  def put_web(%Project{opts: opts} = project) do
-    web_app = :"#{project.app}_web"
+  def put_web(%Project{app: app, opts: opts} = project) do
+    web_app = :"#{app}_web"
     web_namespace = Module.concat([opts[:web_module] || "#{project.app_mod}Web"])
 
     %Project{project |
              web_app: web_app,
              lib_web_name: web_app,
              web_namespace: web_namespace,
+             generators: [context_app: :"#{app}"],
              web_path: Path.join(project.project_path, "apps/#{web_app}/")}
   end
 
diff --git a/installer/lib/phx_new/web.ex b/installer/lib/phx_new/web.ex
index 3d7a1f909..9ae97b66e 100644
--- a/installer/lib/phx_new/web.ex
+++ b/installer/lib/phx_new/web.ex
@@ -78,6 +78,7 @@ defmodule Phx.New.Web do
              project_path: project_path,
              web_path: project_path,
              web_app: app,
+             generators: [context_app: false],
              web_namespace: project.app_mod}
   end
 
diff --git a/installer/templates/phx_umbrella/apps/app_name_web/config/config.exs b/installer/templates/phx_umbrella/apps/app_name_web/config/config.exs
index 60e68c438..72ba31420 100644
--- a/installer/templates/phx_umbrella/apps/app_name_web/config/config.exs
+++ b/installer/templates/phx_umbrella/apps/app_name_web/config/config.exs
@@ -19,14 +19,6 @@ config :<%= web_app_name %>, <%= endpoint_module %>,
   pubsub: [name: <%= web_namespace %>.PubSub,
            adapter: Phoenix.PubSub.PG2]
 
-# Configures Elixir's Logger
-config :logger, :console,
-  format: "$time $metadata[$level] $message\n",
-  metadata: [:request_id]
-
-config :<%= web_app_name %>, :generators,
-  context_app: <%= if app_name == web_app_name, do: false, else: ":#{app_name}" %>
-
 # Import environment specific config. This must remain at the bottom
 # of this file so it overrides the configuration defined above.
 import_config "#{Mix.env}.exs"


Test patch:
diff --git a/installer/test/phx_new_umbrella_test.exs b/installer/test/phx_new_umbrella_test.exs
index 58a7055da..aa2079bb7 100644
--- a/installer/test/phx_new_umbrella_test.exs
+++ b/installer/test/phx_new_umbrella_test.exs
@@ -61,9 +61,7 @@ defmodule Mix.Tasks.Phx.New.UmbrellaTest do
       assert_file web_path(@app, "config/config.exs"), fn file ->
         assert file =~ "ecto_repos: [PhxUmb.Repo]"
         assert file =~ ":phx_umb_web, PhxUmbWeb.Endpoint"
-        assert file =~ "namespace"
-        assert file =~ "config :phx_umb_web, :generators,"
-        assert file =~ "context_app: :phx_umb\n"
+        assert file =~ "generators: [context_app: :phx_umb]\n"
       end
 
       assert_file web_path(@app, "config/prod.exs"), fn file ->
@@ -255,7 +253,7 @@ defmodule Mix.Tasks.Phx.New.UmbrellaTest do
   test "new with binary_id" do
     in_tmp "new with binary_id", fn ->
       Mix.Tasks.Phx.New.run([@app, "--umbrella", "--binary-id"])
-      assert_file web_path(@app, "config/config.exs"), ~r/generators: \[binary_id: true\]/
+      assert_file web_path(@app, "config/config.exs"), ~r/generators: \[context_app: :phx_umb, binary_id: true\]/
     end
   end
 
diff --git a/installer/test/phx_new_web_test.exs b/installer/test/phx_new_web_test.exs
index d987c4613..a8166241c 100644
--- a/installer/test/phx_new_web_test.exs
+++ b/installer/test/phx_new_web_test.exs
@@ -34,8 +34,7 @@ defmodule Mix.Tasks.Phx.New.WebTest do
       Mix.Tasks.Phx.New.Web.run([@app_name])
 
       assert_file "#{@app_name}/config/config.exs", fn file ->
-        assert file =~ "config :#{@app_name}, :generators,"
-        assert file =~ "context_app: false"
+        assert file =~ "generators: [context_app: false]"
       end
 
       # Install dependencies?