Skip to content

Commit

Permalink
Revert auto-formatted code.
Browse files Browse the repository at this point in the history
  • Loading branch information
ShPakvel committed Dec 12, 2024
1 parent 7fd09e2 commit b8730cc
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 117 deletions.
15 changes: 3 additions & 12 deletions integration_test/test/code_generation/app_with_defaults_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,7 @@ defmodule Phoenix.Integration.CodeGeneration.AppWithDefaultsTest do
with_installer_tmp("app_with_defaults", fn tmp_dir ->
{app_root_path, _} = generate_phoenix_app(tmp_dir, "phx_blog")

mix_run!(
~w(phx.gen.html Blog Post posts title:unique body:string status:enum:unpublished:published:deleted order:integer:unique),
app_root_path
)
mix_run!(~w(phx.gen.html Blog Post posts title:unique body:string status:enum:unpublished:published:deleted order:integer:unique), app_root_path)

modify_file(Path.join(app_root_path, "lib/phx_blog_web/router.ex"), fn file ->
inject_before_final_end(file, """
Expand Down Expand Up @@ -120,10 +117,7 @@ defmodule Phoenix.Integration.CodeGeneration.AppWithDefaultsTest do
with_installer_tmp("app_with_defaults", fn tmp_dir ->
{app_root_path, _} = generate_phoenix_app(tmp_dir, "phx_blog")

mix_run!(
~w(phx.gen.json Blog Post posts title:unique body:string status:enum:unpublished:published:deleted),
app_root_path
)
mix_run!(~w(phx.gen.json Blog Post posts title:unique body:string status:enum:unpublished:published:deleted), app_root_path)

modify_file(Path.join(app_root_path, "lib/phx_blog_web/router.ex"), fn file ->
inject_before_final_end(file, """
Expand Down Expand Up @@ -184,10 +178,7 @@ defmodule Phoenix.Integration.CodeGeneration.AppWithDefaultsTest do
with_installer_tmp("app_with_defaults", fn tmp_dir ->
{app_root_path, _} = generate_phoenix_app(tmp_dir, "phx_blog", ["--live"])

mix_run!(
~w(phx.gen.live Blog Post posts title body:string public:boolean status:enum:unpublished:published:deleted),
app_root_path
)
mix_run!(~w(phx.gen.live Blog Post posts title body:string public:boolean status:enum:unpublished:published:deleted), app_root_path)

modify_file(Path.join(app_root_path, "lib/phx_blog_web/router.ex"), fn file ->
inject_before_final_end(file, """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ defmodule Phoenix.Integration.CodeGeneration.AppWithMSSQLAdapterTest do
{app_root_path, _} =
generate_phoenix_app(tmp_dir, "default_mssql_app", ["--database", "mssql"])

mix_run!(
~w(phx.gen.html Blog Post posts title body:string status:enum:unpublished:published:deleted),
app_root_path
)
mix_run!(~w(phx.gen.html Blog Post posts title body:string status:enum:unpublished:published:deleted), app_root_path)

modify_file(Path.join(app_root_path, "lib/default_mssql_app_web/router.ex"), fn file ->
inject_before_final_end(file, """
Expand All @@ -37,10 +34,7 @@ defmodule Phoenix.Integration.CodeGeneration.AppWithMSSQLAdapterTest do
{app_root_path, _} =
generate_phoenix_app(tmp_dir, "default_mssql_app", ["--database", "mssql"])

mix_run!(
~w(phx.gen.json Blog Post posts title body:string status:enum:unpublished:published:deleted),
app_root_path
)
mix_run!(~w(phx.gen.json Blog Post posts title body:string status:enum:unpublished:published:deleted), app_root_path)

modify_file(Path.join(app_root_path, "lib/default_mssql_app_web/router.ex"), fn file ->
inject_before_final_end(file, """
Expand All @@ -66,10 +60,7 @@ defmodule Phoenix.Integration.CodeGeneration.AppWithMSSQLAdapterTest do
{app_root_path, _} =
generate_phoenix_app(tmp_dir, "default_mssql_app", ["--database", "mssql", "--live"])

mix_run!(
~w(phx.gen.live Blog Post posts title body:string status:enum:unpublished:published:deleted),
app_root_path
)
mix_run!(~w(phx.gen.live Blog Post posts title body:string status:enum:unpublished:published:deleted), app_root_path)

modify_file(Path.join(app_root_path, "lib/default_mssql_app_web/router.ex"), fn file ->
inject_before_final_end(file, """
Expand All @@ -94,8 +85,7 @@ defmodule Phoenix.Integration.CodeGeneration.AppWithMSSQLAdapterTest do
describe "phx.gen.auth + pbkdf2 + existing context" do
test "has no compilation or formatter warnings (--live)" do
with_installer_tmp("new with defaults", fn tmp_dir ->
{app_root_path, _} =
generate_phoenix_app(tmp_dir, "phx_blog", ["--database", "mssql", "--live"])
{app_root_path, _} = generate_phoenix_app(tmp_dir, "phx_blog", ["--database", "mssql", "--live"])

mix_run!(
~w(phx.gen.html Accounts Group groups
Expand All @@ -117,10 +107,7 @@ defmodule Phoenix.Integration.CodeGeneration.AppWithMSSQLAdapterTest do
""")
end)

mix_run!(
~w(phx.gen.auth Accounts User users --hashing-lib pbkdf2 --merge-with-existing-context --live),
app_root_path
)
mix_run!(~w(phx.gen.auth Accounts User users --hashing-lib pbkdf2 --merge-with-existing-context --live), app_root_path)

assert_no_compilation_warnings(app_root_path)
assert_passes_formatter_check(app_root_path)
Expand All @@ -129,8 +116,7 @@ defmodule Phoenix.Integration.CodeGeneration.AppWithMSSQLAdapterTest do

test "has no compilation or formatter warnings (--no-live)" do
with_installer_tmp("new with defaults", fn tmp_dir ->
{app_root_path, _} =
generate_phoenix_app(tmp_dir, "phx_blog", ["--database", "mssql", "--live"])
{app_root_path, _} = generate_phoenix_app(tmp_dir, "phx_blog", ["--database", "mssql", "--live"])

mix_run!(~w(phx.gen.html Accounts Group groups name), app_root_path)

Expand All @@ -145,10 +131,7 @@ defmodule Phoenix.Integration.CodeGeneration.AppWithMSSQLAdapterTest do
""")
end)

mix_run!(
~w(phx.gen.auth Accounts User users --hashing-lib pbkdf2 --merge-with-existing-context --no-live),
app_root_path
)
mix_run!(~w(phx.gen.auth Accounts User users --hashing-lib pbkdf2 --merge-with-existing-context --no-live), app_root_path)

assert_no_compilation_warnings(app_root_path)
assert_passes_formatter_check(app_root_path)
Expand All @@ -158,8 +141,7 @@ defmodule Phoenix.Integration.CodeGeneration.AppWithMSSQLAdapterTest do
@tag database: :mssql
test "has a passing test suite" do
with_installer_tmp("app_with_defaults (--live)", fn tmp_dir ->
{app_root_path, _} =
generate_phoenix_app(tmp_dir, "phx_blog", ["--database", "mssql", "--live"])
{app_root_path, _} = generate_phoenix_app(tmp_dir, "phx_blog", ["--database", "mssql", "--live"])

mix_run!(~w(phx.gen.html Accounts Group groups name), app_root_path)

Expand All @@ -174,10 +156,7 @@ defmodule Phoenix.Integration.CodeGeneration.AppWithMSSQLAdapterTest do
""")
end)

mix_run!(
~w(phx.gen.auth Accounts User users --hashing-lib pbkdf2 --merge-with-existing-context --live),
app_root_path
)
mix_run!(~w(phx.gen.auth Accounts User users --hashing-lib pbkdf2 --merge-with-existing-context --live), app_root_path)

drop_test_database(app_root_path)
assert_tests_pass(app_root_path)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ defmodule Phoenix.Integration.CodeGeneration.AppWithMySqlAdapterTest do
describe "phx.gen.auth + argon2" do
test "has no compilation or formatter warnings (--live)" do
with_installer_tmp("new with defaults", fn tmp_dir ->
{app_root_path, _} =
generate_phoenix_app(tmp_dir, "phx_blog", ["--database", "mysql", "--binary-id"])
{app_root_path, _} = generate_phoenix_app(tmp_dir, "phx_blog", ["--database", "mysql", "--binary-id"])

mix_run!(~w(phx.gen.auth Accounts User users --hashing-lib argon2 --live), app_root_path)

Expand All @@ -136,13 +135,9 @@ defmodule Phoenix.Integration.CodeGeneration.AppWithMySqlAdapterTest do

test "has no compilation or formatter warnings (--no-live)" do
with_installer_tmp("new with defaults", fn tmp_dir ->
{app_root_path, _} =
generate_phoenix_app(tmp_dir, "phx_blog", ["--database", "mysql", "--binary-id"])
{app_root_path, _} = generate_phoenix_app(tmp_dir, "phx_blog", ["--database", "mysql", "--binary-id"])

mix_run!(
~w(phx.gen.auth Accounts User users --hashing-lib argon2 --no-live),
app_root_path
)
mix_run!(~w(phx.gen.auth Accounts User users --hashing-lib argon2 --no-live), app_root_path)

assert_no_compilation_warnings(app_root_path)
assert_passes_formatter_check(app_root_path)
Expand All @@ -152,8 +147,7 @@ defmodule Phoenix.Integration.CodeGeneration.AppWithMySqlAdapterTest do
@tag database: :mysql
test "has a passing test suite (--live)" do
with_installer_tmp("app_with_defaults", fn tmp_dir ->
{app_root_path, _} =
generate_phoenix_app(tmp_dir, "default_app", ["--database", "mysql", "--binary-id"])
{app_root_path, _} = generate_phoenix_app(tmp_dir, "default_app", ["--database", "mysql", "--binary-id"])

mix_run!(~w(phx.gen.auth Accounts User users --hashing-lib argon2 --live), app_root_path)

Expand All @@ -165,13 +159,9 @@ defmodule Phoenix.Integration.CodeGeneration.AppWithMySqlAdapterTest do
@tag database: :mysql
test "has a passing test suite (--no-live)" do
with_installer_tmp("app_with_defaults", fn tmp_dir ->
{app_root_path, _} =
generate_phoenix_app(tmp_dir, "default_app", ["--database", "mysql", "--binary-id"])
{app_root_path, _} = generate_phoenix_app(tmp_dir, "default_app", ["--database", "mysql", "--binary-id"])

mix_run!(
~w(phx.gen.auth Accounts User users --hashing-lib argon2 --no-live),
app_root_path
)
mix_run!(~w(phx.gen.auth Accounts User users --hashing-lib argon2 --no-live), app_root_path)

drop_test_database(app_root_path)
assert_tests_pass(app_root_path)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,7 @@ defmodule Phoenix.Integration.CodeGeneration.AppWithSQLite3AdapterTest do
@tag database: :sqlite3
test "has a passing test suite (--live)" do
with_installer_tmp("app_with_defaults", fn tmp_dir ->
{app_root_path, _} =
generate_phoenix_app(tmp_dir, "default_app", ["--database", "sqlite3"])
{app_root_path, _} = generate_phoenix_app(tmp_dir, "default_app", ["--database", "sqlite3"])

mix_run!(~w(phx.gen.auth Accounts User users --live), app_root_path)

Expand All @@ -156,8 +155,7 @@ defmodule Phoenix.Integration.CodeGeneration.AppWithSQLite3AdapterTest do

test "has a passing test suite (--no-live)" do
with_installer_tmp("app_with_defaults", fn tmp_dir ->
{app_root_path, _} =
generate_phoenix_app(tmp_dir, "default_app", ["--database", "sqlite3"])
{app_root_path, _} = generate_phoenix_app(tmp_dir, "default_app", ["--database", "sqlite3"])

mix_run!(~w(phx.gen.auth Accounts User users --no-live), app_root_path)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,7 @@ defmodule Phoenix.Integration.CodeGeneration.UmbrellaAppWithDefaultsTest do
{app_root_path, _} = generate_phoenix_app(tmp_dir, "rainy_day", ["--umbrella"])
web_root_path = Path.join(app_root_path, "apps/rainy_day_web")

mix_run!(
~w(phx.gen.html Blog Post posts title body:string status:enum:unpublished:published:deleted),
web_root_path
)
mix_run!(~w(phx.gen.html Blog Post posts title body:string status:enum:unpublished:published:deleted), web_root_path)

modify_file(Path.join(web_root_path, "lib/rainy_day_web/router.ex"), fn file ->
inject_before_final_end(file, """
Expand Down Expand Up @@ -125,10 +122,7 @@ defmodule Phoenix.Integration.CodeGeneration.UmbrellaAppWithDefaultsTest do
{app_root_path, _} = generate_phoenix_app(tmp_dir, "rainy_day", ["--umbrella"])
web_root_path = Path.join(app_root_path, "apps/rainy_day_web")

mix_run!(
~w(phx.gen.json Blog Post posts title body:string status:enum:unpublished:published:deleted),
web_root_path
)
mix_run!(~w(phx.gen.json Blog Post posts title body:string status:enum:unpublished:published:deleted), web_root_path)

modify_file(Path.join(web_root_path, "lib/rainy_day_web/router.ex"), fn file ->
inject_before_final_end(file, """
Expand Down Expand Up @@ -190,10 +184,7 @@ defmodule Phoenix.Integration.CodeGeneration.UmbrellaAppWithDefaultsTest do
{app_root_path, _} = generate_phoenix_app(tmp_dir, "rainy_day", ["--umbrella", "--live"])
web_root_path = Path.join(app_root_path, "apps/rainy_day_web")

mix_run!(
~w(phx.gen.live Blog Post posts title body:string status:enum:unpublished:published:deleted),
web_root_path
)
mix_run!(~w(phx.gen.live Blog Post posts title body:string status:enum:unpublished:published:deleted), web_root_path)

modify_file(Path.join(web_root_path, "lib/rainy_day_web/router.ex"), fn file ->
inject_before_final_end(file, """
Expand Down
19 changes: 8 additions & 11 deletions lib/mix/tasks/phx.gen.embedded.ex
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ defmodule Mix.Tasks.Phx.Gen.Embedded do
The following types are supported:
#{for attr <- Mix.Phoenix.Schema.valid_types(), do: " * `#{inspect(attr)}`\n"}
#{for attr <- Mix.Phoenix.Schema.valid_types(), do: " * `#{inspect attr}`\n"}
* `:datetime` - An alias for `:naive_datetime`
## Format
Expand All @@ -43,9 +43,7 @@ defmodule Mix.Tasks.Phx.Gen.Embedded do
@doc false
def run(args) do
if Mix.Project.umbrella?() do
Mix.raise(
"mix phx.gen.embedded must be invoked from within your *_web application root directory"
)
Mix.raise "mix phx.gen.embedded must be invoked from within your *_web application root directory"
end

schema = build(args)
Expand Down Expand Up @@ -79,29 +77,28 @@ defmodule Mix.Tasks.Phx.Gen.Embedded do
if Schema.valid?(schema) do
args
else
raise_with_help(
"Expected the schema argument, #{inspect(schema)}, to be a valid module name"
)
raise_with_help "Expected the schema argument, #{inspect schema}, to be a valid module name"
end
end

def validate_args!(_) do
raise_with_help("Invalid arguments")
raise_with_help "Invalid arguments"
end

@doc false
@spec raise_with_help(String.t()) :: no_return()
@spec raise_with_help(String.t) :: no_return()
def raise_with_help(msg) do
Mix.raise("""
Mix.raise """
#{msg}
mix phx.gen.embedded expects a module name followed by
any number of attributes:
mix phx.gen.embedded Blog.Post title:string
""")
"""
end


defp prompt_for_conflicts(schema) do
schema
|> files_to_be_generated()
Expand Down
Loading

0 comments on commit b8730cc

Please sign in to comment.