Skip to content

Commit

Permalink
fix: handle igniter/rewrite upgrades
Browse files Browse the repository at this point in the history
  • Loading branch information
zachdaniel committed Nov 2, 2024
1 parent 476251b commit c8fabde
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion lib/mix/tasks/ash_authentication.add_strategy.ex
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ defmodule Mix.Tasks.AshAuthentication.AddStrategy do
argv
|> options!()
|> Keyword.update(:identity_field, :email, &String.to_atom/1)
|> Keyword.update(:user, default_user, &Igniter.Code.Module.parse/1)
|> Keyword.update(:user, default_user, &Igniter.Project.Module.parse/1)

if invalid_strategy = Enum.find(strategies, &(&1 not in @strategy_names)) do
Mix.shell().error("""
Expand Down
2 changes: 1 addition & 1 deletion lib/mix/tasks/ash_authentication.install.ex
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ defmodule Mix.Tasks.AshAuthentication.Install do
defp parse_module_option(opts, option) do
Keyword.update(opts, option, nil, fn value ->
if is_binary(value) do
Igniter.Code.Module.parse(value)
Igniter.Project.Module.parse(value)
else
value
end
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ defmodule AshAuthentication.MixProject do
defp deps do
[
{:ash, ash_version("~> 3.0 and >= 3.4.29")},
{:igniter, "~> 0.3 and >= 0.3.62"},
{:igniter, "~> 0.4"},
{:assent, "~> 0.2 and >= 0.2.8"},
{:bcrypt_elixir, "~> 3.0"},
{:castore, "~> 1.0"},
Expand Down
9 changes: 5 additions & 4 deletions mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
"finch": {:hex, :finch, "0.19.0", "c644641491ea854fc5c1bbaef36bfc764e3f08e7185e1f084e35e0672241b76d", [:mix], [{:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:mint, "~> 1.6.2 or ~> 1.7", [hex: :mint, repo: "hexpm", optional: false]}, {:nimble_options, "~> 0.4 or ~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:nimble_pool, "~> 1.1", [hex: :nimble_pool, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "fc5324ce209125d1e2fa0fcd2634601c52a787aff1cd33ee833664a5af4ea2b6"},
"git_cli": {:hex, :git_cli, "0.3.0", "a5422f9b95c99483385b976f5d43f7e8233283a47cda13533d7c16131cb14df5", [:mix], [], "hexpm", "78cb952f4c86a41f4d3511f1d3ecb28edb268e3a7df278de2faa1bd4672eaf9b"},
"git_ops": {:hex, :git_ops, "2.6.3", "38c6e381b8281b86e2911fa39bea4eab2d171c86d7428786566891efb73b68c3", [:mix], [{:git_cli, "~> 0.2", [hex: :git_cli, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "a81cb6c6a2a026a4d48cb9a2e1dfca203f9283a3a70aa0c7bc171970c44f23f8"},
"glob_ex": {:hex, :glob_ex, "0.1.9", "b97a25392f5339e49f587e5b24c468c6a4f38299febd5ec85c5f8bb2e42b5c1e", [:mix], [], "hexpm", "be72e584ad1d8776a4d134d4b6da1bac8b80b515cdadf0120e0920b9978d7f01"},
"glob_ex": {:hex, :glob_ex, "0.1.10", "d819a368637495a5c1962ef34f48fe4e9a09032410b96ade5758f2cd1cc5fcde", [:mix], [], "hexpm", "c75357e57d71c85ef8ef7269b6e787dce3f0ff71e585f79a90e4d5477c532b90"},
"ham": {:hex, :ham, "0.3.0", "7cd031b4a55fba219c11553e7b13ba73bd86eab4034518445eff1e038cb9a44d", [:mix], [], "hexpm", "7d6c6b73d7a6a83233876cc1b06a4d9b5de05562b228effda4532f9a49852bf6"},
"hpax": {:hex, :hpax, "1.0.0", "28dcf54509fe2152a3d040e4e3df5b265dcb6cb532029ecbacf4ce52caea3fd2", [:mix], [], "hexpm", "7f1314731d711e2ca5fdc7fd361296593fc2542570b3105595bb0bc6d0fad601"},
"igniter": {:hex, :igniter, "0.3.63", "ac27c466e6f779cf5f39d200a7d433cd91c8d465277e001661dc9b4680ca9eb3", [:mix], [{:glob_ex, "~> 0.1.7", [hex: :glob_ex, repo: "hexpm", optional: false]}, {:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: false]}, {:rewrite, "~> 0.9", [hex: :rewrite, repo: "hexpm", optional: false]}, {:sourceror, "~> 1.4", [hex: :sourceror, repo: "hexpm", optional: false]}, {:spitfire, ">= 0.1.3 and < 1.0.0-0", [hex: :spitfire, repo: "hexpm", optional: false]}], "hexpm", "5e24f71479cfd3575f79a767db51de0b38a633f05107b05d94ef1a54fde9093f"},
"igniter": {:hex, :igniter, "0.4.3", "cf4c4404e761bee456441a427a42a7dd815df7445362d69a4a21bcf7c74305d0", [:mix], [{:glob_ex, "~> 0.1.7", [hex: :glob_ex, repo: "hexpm", optional: false]}, {:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: false]}, {:rewrite, "~> 1.0", [hex: :rewrite, repo: "hexpm", optional: false]}, {:sourceror, "~> 1.4", [hex: :sourceror, repo: "hexpm", optional: false]}, {:spitfire, ">= 0.1.3 and < 1.0.0-0", [hex: :spitfire, repo: "hexpm", optional: false]}], "hexpm", "bcee7e30caa7ef8d4a4d0d6e9968d62cf162d1991af8afe67bfefb2e625c6cf9"},
"inflex": {:hex, :inflex, "2.1.0", "a365cf0821a9dacb65067abd95008ca1b0bb7dcdd85ae59965deef2aa062924c", [:mix], [], "hexpm", "14c17d05db4ee9b6d319b0bff1bdf22aa389a25398d1952c7a0b5f3d93162dd8"},
"iterex": {:hex, :iterex, "0.1.2", "58f9b9b9a22a55cbfc7b5234a9c9c63eaac26d276b3db80936c0e1c60355a5a6", [:mix], [], "hexpm", "2e103b8bcc81757a9af121f6dc0df312c9a17220f302b1193ef720460d03029d"},
"jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"},
Expand All @@ -61,14 +61,15 @@
"postgrex": {:hex, :postgrex, "0.19.1", "73b498508b69aded53907fe48a1fee811be34cc720e69ef4ccd568c8715495ea", [:mix], [{:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.5 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:table, "~> 0.1.0", [hex: :table, repo: "hexpm", optional: true]}], "hexpm", "8bac7885a18f381e091ec6caf41bda7bb8c77912bb0e9285212829afe5d8a8f8"},
"ranch": {:hex, :ranch, "1.8.0", "8c7a100a139fd57f17327b6413e4167ac559fbc04ca7448e9be9057311597a1d", [:make, :rebar3], [], "hexpm", "49fbcfd3682fab1f5d109351b61257676da1a2fdbe295904176d5e521a2ddfe5"},
"reactor": {:hex, :reactor, "0.10.0", "1206113c21ba69b889e072b2c189c05a7aced523b9c3cb8dbe2dab7062cb699a", [:mix], [{:igniter, "~> 0.2", [hex: :igniter, repo: "hexpm", optional: false]}, {:iterex, "~> 0.1", [hex: :iterex, repo: "hexpm", optional: false]}, {:libgraph, "~> 0.16", [hex: :libgraph, repo: "hexpm", optional: false]}, {:spark, "~> 2.0", [hex: :spark, repo: "hexpm", optional: false]}, {:splode, "~> 0.2", [hex: :splode, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.2", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "4003c33e4c8b10b38897badea395e404d74d59a31beb30469a220f2b1ffe6457"},
"rewrite": {:hex, :rewrite, "0.10.5", "6afadeae0b9d843b27ac6225e88e165884875e0aed333ef4ad3bf36f9c101bed", [:mix], [{:glob_ex, "~> 0.1", [hex: :glob_ex, repo: "hexpm", optional: false]}, {:sourceror, "~> 1.0", [hex: :sourceror, repo: "hexpm", optional: false]}], "hexpm", "51cc347a4269ad3a1e7a2c4122dbac9198302b082f5615964358b4635ebf3d4f"},
"rewrite": {:hex, :rewrite, "1.0.0", "fddda21eb62c2b9dbd6cf35b39984d02761a63c25de2947ceab7ffe2729fa2e5", [:mix], [{:glob_ex, "~> 0.1", [hex: :glob_ex, repo: "hexpm", optional: false]}, {:sourceror, "~> 1.0", [hex: :sourceror, repo: "hexpm", optional: false]}, {:text_diff, "~> 0.1", [hex: :text_diff, repo: "hexpm", optional: false]}], "hexpm", "701975d9d0c21b1f40a82881e489aca6b53893f095f318978c6d2899299a514b"},
"sobelow": {:hex, :sobelow, "0.13.0", "218afe9075904793f5c64b8837cc356e493d88fddde126a463839351870b8d1e", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "cd6e9026b85fc35d7529da14f95e85a078d9dd1907a9097b3ba6ac7ebbe34a0d"},
"sourceror": {:hex, :sourceror, "1.6.0", "9907884e1449a4bd7dbaabe95088ed4d9a09c3c791fb0103964e6316bc9448a7", [:mix], [], "hexpm", "e90aef8c82dacf32c89c8ef83d1416fc343cd3e5556773eeffd2c1e3f991f699"},
"sourceror": {:hex, :sourceror, "1.7.1", "599d78f4cc2be7d55c9c4fd0a8d772fd0478e3a50e726697c20d13d02aa056d4", [:mix], [], "hexpm", "cd6f268fe29fa00afbc535e215158680a0662b357dc784646d7dff28ac65a0fc"},
"spark": {:hex, :spark, "2.2.34", "1f0a3bd86d37f86a1d26db4a34d6b0e5fb091940aee25cd40041dab1397c8ada", [:mix], [{:igniter, ">= 0.3.36 and < 1.0.0-0", [hex: :igniter, repo: "hexpm", optional: false]}, {:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: false]}, {:sourceror, "~> 1.2", [hex: :sourceror, repo: "hexpm", optional: false]}], "hexpm", "93f94b8f511a72f8764465ea32ff2e5376695f70e747884de2ce64bb6ac22a59"},
"spitfire": {:hex, :spitfire, "0.1.3", "7ea0f544005dfbe48e615ed90250c9a271bfe126914012023fd5e4b6b82b7ec7", [:mix], [], "hexpm", "d53b5107bcff526a05c5bb54c95e77b36834550affd5830c9f58760e8c543657"},
"splode": {:hex, :splode, "0.2.4", "71046334c39605095ca4bed5d008372e56454060997da14f9868534c17b84b53", [:mix], [], "hexpm", "ca3b95f0d8d4b482b5357954fec857abd0fa3ea509d623334c1328e7382044c2"},
"stream_data": {:hex, :stream_data, "1.1.2", "05499eaec0443349ff877aaabc6e194e82bda6799b9ce6aaa1aadac15a9fdb4d", [:mix], [], "hexpm", "129558d2c77cbc1eb2f4747acbbea79e181a5da51108457000020a906813a1a9"},
"telemetry": {:hex, :telemetry, "1.3.0", "fedebbae410d715cf8e7062c96a1ef32ec22e764197f70cda73d82778d61e7a2", [:rebar3], [], "hexpm", "7015fc8919dbe63764f4b4b87a95b7c0996bd539e0d499be6ec9d7f3875b79e6"},
"text_diff": {:hex, :text_diff, "0.1.0", "1caf3175e11a53a9a139bc9339bd607c47b9e376b073d4571c031913317fecaa", [:mix], [], "hexpm", "d1ffaaecab338e49357b6daa82e435f877e0649041ace7755583a0ea3362dbd7"},
"xema": {:hex, :xema, "0.17.4", "e958baaf1f8238414c0646a6946a2fa8812673d14771aefc12af182b97d20665", [:mix], [{:conv_case, "~> 0.2.2", [hex: :conv_case, repo: "hexpm", optional: false]}, {:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "faf638de7c424326f089475db8077c86506af971537eb2097e06124c5e0e4240"},
"yamerl": {:hex, :yamerl, "0.10.0", "4ff81fee2f1f6a46f1700c0d880b24d193ddb74bd14ef42cb0bcf46e81ef2f8e", [:rebar3], [], "hexpm", "346adb2963f1051dc837a2364e4acf6eb7d80097c0f53cbdc3046ec8ec4b4e6e"},
"yaml_elixir": {:hex, :yaml_elixir, "2.11.0", "9e9ccd134e861c66b84825a3542a1c22ba33f338d82c07282f4f1f52d847bd50", [:mix], [{:yamerl, "~> 0.10", [hex: :yamerl, repo: "hexpm", optional: false]}], "hexpm", "53cc28357ee7eb952344995787f4bb8cc3cecbf189652236e9b163e8ce1bc242"},
Expand Down
6 changes: 4 additions & 2 deletions test/mix/tasks/ash_authentication.add_strategy_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ defmodule Mix.Tasks.AshAuthentication.AddStrategyTest do
igniter =
test_project()
|> Igniter.Project.Deps.add_dep({:simple_sat, ">= 0.0.0"})
|> Igniter.Project.Formatter.add_formatter_plugin(Spark.Formatter)
|> Igniter.compose_task("ash_authentication.install", ["--yes"])
# These can be removed when https://github.com/hrzndhrn/rewrite/issues/39 is addressed (in igniter too)
|> Igniter.Project.Formatter.remove_imported_dep(:ash_authentication)
|> Igniter.Project.Formatter.remove_formatter_plugin(Spark.Formatter)
|> apply_igniter!()

[igniter: igniter]
Expand Down Expand Up @@ -205,7 +207,7 @@ defmodule Mix.Tasks.AshAuthentication.AddStrategyTest do
igniter
|> Igniter.compose_task("ash_authentication.add_strategy", ["password"])
|> assert_has_patch("mix.exs", """
25 + | bcrypt_elixir: "~> 3.0",
+ | {:bcrypt_elixir, "~> 3.0"},
""")
end

Expand Down
10 changes: 4 additions & 6 deletions test/mix/tasks/ash_authentication.install_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ defmodule Mix.Tasks.AshAuthentication.InstallTest do
igniter =
test_project()
|> Igniter.Project.Deps.add_dep({:simple_sat, ">= 0.0.0"})
|> Igniter.Project.Formatter.add_formatter_plugin(Spark.Formatter)
|> Igniter.compose_task("ash_authentication.install", ["--yes"])
# This can be removed when https://github.com/hrzndhrn/rewrite/issues/39 is addressed (in igniter too)
|> Igniter.Project.Formatter.remove_imported_dep(:ash_authentication)
|> Igniter.Project.Formatter.remove_formatter_plugin(Spark.Formatter)

[igniter: igniter]
end

test "installation creates a secrets module", %{igniter: igniter} do
igniter
|> Igniter.compose_task("ash_authentication.install", ["--yes"])
|> assert_creates("lib/test/secrets.ex", """
defmodule Test.Secrets do
use AshAuthentication.Secret
Expand All @@ -29,15 +31,13 @@ defmodule Mix.Tasks.AshAuthentication.InstallTest do

test "installation adds the supervisor to the app", %{igniter: igniter} do
igniter
|> Igniter.compose_task("ash_authentication.install", ["--yes"])
|> assert_has_patch("lib/test/application.ex", """
8 | children = [{AshAuthentication.Supervisor, [otp_app: :test]}]
""")
end

test "installation adds config files", %{igniter: igniter} do
igniter
|> Igniter.compose_task("ash_authentication.install", ["--yes"])
|> assert_creates("config/runtime.exs", """
import Config
Expand All @@ -64,7 +64,6 @@ defmodule Mix.Tasks.AshAuthentication.InstallTest do

test "installation adds a user resource", %{igniter: igniter} do
igniter
|> Igniter.compose_task("ash_authentication.install", ["--yes"])
|> assert_creates("lib/test/accounts/user.ex", """
defmodule Test.Accounts.User do
use Ash.Resource,
Expand Down Expand Up @@ -115,7 +114,6 @@ defmodule Mix.Tasks.AshAuthentication.InstallTest do

test "instalation adds a user token resource", %{igniter: igniter} do
igniter
|> Igniter.compose_task("ash_authentication.install", ["--yes"])
|> assert_creates("lib/test/accounts/token.ex", """
defmodule Test.Accounts.Token do
use Ash.Resource,
Expand Down

0 comments on commit c8fabde

Please sign in to comment.