Skip to content

Commit

Permalink
fix: properly parse flag options
Browse files Browse the repository at this point in the history
  • Loading branch information
zachdaniel committed Oct 14, 2024
1 parent 41065a2 commit e09fe3e
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 53 deletions.
100 changes: 50 additions & 50 deletions documentation/tutorials/ui-overrides.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ Renders sign in mark-up for an authenticated resource.

* `:root_class` - CSS class for the root `div` element.

* `:strategy_class` - CSS class for a `div` surrounding each strategy component.

* `:show_banner` - Whether or not to show the banner.

* `:authentication_error_container_class` - CSS class for the container for the text of the authentication error.

* `:authentication_error_text_class` - CSS class for the authentication error text.

* `:show_banner` - Whether or not to show the banner.

* `:strategy_class` - CSS class for a `div` surrounding each strategy component.


## Password Sign-in
### `AshAuthentication.Phoenix.Components.Password`
Expand All @@ -87,21 +87,21 @@ Generates sign in, registration and reset forms for a resource.

* `:root_class` - CSS class for the root `div` element.

* `:slot_class` - CSS class for the `div` surrounding the slot.

* `:interstitial_class` - CSS class for the `div` element between the form and the button.
* `:hide_class` - CSS class to apply to hide an element.

* `:toggler_class` - CSS class for the toggler `a` element.
* `:show_first` - The form to show on first load. Either `:sign_in` or `:register`. Only relevant if paths aren't set for them in the router.

* `:sign_in_toggle_text` - Toggle text to display when the sign in form is not showing (or `nil` to disable).
* `:interstitial_class` - CSS class for the `div` element between the form and the button.

* `:register_toggle_text` - Toggle text to display when the register form is not showing (or `nil` to disable).

* `:reset_toggle_text` - Toggle text to display when the reset form is not showing (or `nil` to disable).

* `:show_first` - The form to show on first load. Either `:sign_in` or `:register`. Only relevant if paths aren't set for them in the router.
* `:sign_in_toggle_text` - Toggle text to display when the sign in form is not showing (or `nil` to disable).

* `:hide_class` - CSS class to apply to hide an element.
* `:slot_class` - CSS class for the `div` surrounding the slot.

* `:toggler_class` - CSS class for the toggler `a` element.


### `AshAuthentication.Phoenix.Components.Password.RegisterForm`
Expand All @@ -110,13 +110,13 @@ Generates a default registration form.

* `:root_class` - CSS class for the root `div` element.

* `:label_class` - CSS class for the `h2` element.

* `:form_class` - CSS class for the `form` element.
* `:slot_class` - CSS class for the `div` surrounding the slot.

* `:disable_button_text` - Text for the submit button when the request is happening.

* `:slot_class` - CSS class for the `div` surrounding the slot.
* `:form_class` - CSS class for the `form` element.

* `:label_class` - CSS class for the `h2` element.


### `AshAuthentication.Phoenix.Components.Password.SignInForm`
Expand All @@ -125,13 +125,13 @@ Generates a default sign in form.

* `:root_class` - CSS class for the root `div` element.

* `:label_class` - CSS class for the `h2` element.

* `:form_class` - CSS class for the `form` element.
* `:slot_class` - CSS class for the `div` surrounding the slot.

* `:disable_button_text` - Text for the submit button when the request is happening.

* `:slot_class` - CSS class for the `div` surrounding the slot.
* `:form_class` - CSS class for the `form` element.

* `:label_class` - CSS class for the `h2` element.


## Password Reset
Expand All @@ -150,22 +150,22 @@ Renders a password-reset form.

* `:root_class` - CSS class for the root `div` element.

* `:strategy_class` - CSS class for a `div` surrounding each strategy component.

* `:show_banner` - Whether or not to show the banner.

* `:strategy_class` - CSS class for a `div` surrounding each strategy component.


### `AshAuthentication.Phoenix.Components.Reset.Form`

Generates a default password reset form.

* `:root_class` - CSS class for the root `div` element.

* `:label_class` - CSS class for the `h2` element.
* `:disable_button_text` - Text for the submit button when the request is happening.

* `:form_class` - CSS class for the `form` element.

* `:disable_button_text` - Text for the submit button when the request is happening.
* `:label_class` - CSS class for the `h2` element.

* `:spacer_class` - CSS classes for space between the password input and submit elements.

Expand All @@ -176,13 +176,13 @@ Generates a default password reset form.

* `:root_class` - CSS class for the root `div` element.

* `:label_class` - CSS class for the `h2` element.

* `:form_class` - CSS class for the `form` element.
* `:slot_class` - CSS class for the `div` surrounding the slot.

* `:disable_button_text` - Text for the submit button when the request is happening.

* `:slot_class` - CSS class for the `div` surrounding the slot.
* `:form_class` - CSS class for the `form` element.

* `:label_class` - CSS class for the `h2` element.

* `:reset_flash_text` - Text for the flash message when a request is received. Set to `nil` to disable.

Expand All @@ -195,25 +195,25 @@ authentication.

* `:label_class` - CSS class for `label` elements.

* `:field_class` - CSS class for `div` elements surrounding the fields.

* `:input_class` - CSS class for text/password `input` elements.

* `:identity_input_label` - Label for identity field.
* `:error_li` - CSS class for the `li` elements on error lists.

* `:password_input_label` - Label for password field.
* `:error_ul` - CSS class for the `ul` element on error lists.

* `:password_confirmation_input_label` - Label for password confirmation field.
* `:field_class` - CSS class for `div` elements surrounding the fields.

* `:identity_input_label` - Label for identity field.

* `:input_class_with_error` - CSS class for text/password `input` elements when there is a validation error.

* `:submit_class` - CSS class for the form submit `input` element.
* `:input_debounce` - Number of milliseconds to debounce input by (or `nil` to disable).

* `:error_ul` - CSS class for the `ul` element on error lists.
* `:password_confirmation_input_label` - Label for password confirmation field.

* `:error_li` - CSS class for the `li` elements on error lists.
* `:password_input_label` - Label for password field.

* `:input_debounce` - Number of milliseconds to debounce input by (or `nil` to disable).
* `:submit_class` - CSS class for the form submit `input` element.


## Magic Link
Expand All @@ -223,13 +223,13 @@ Generates a sign-in for for a resource using the "Magic link" strategy.

* `:root_class` - CSS class for the root `div` element.

* `:label_class` - CSS class for the `h2` element.
* `:disable_button_text` - Text for the submit button when the request is happening.

* `:form_class` - CSS class for the `form` element.

* `:request_flash_text` - Text for the flash message when a request is received. Set to `nil` to disable.
* `:label_class` - CSS class for the `h2` element.

* `:disable_button_text` - Text for the submit button when the request is happening.
* `:request_flash_text` - Text for the flash message when a request is received. Set to `nil` to disable.


## OAuth2
Expand All @@ -239,21 +239,21 @@ Generates a sign-in button for Apple.

* `:root_class` - CSS classes for the root `div` element.

* `:link_class` - CSS classes for the `a` element.

* `:icon_class` - CSS classes for the icon SVG.

* `:link_class` - CSS classes for the `a` element.


### `AshAuthentication.Phoenix.Components.OAuth2`

Generates a sign-in button for OAuth2.

* `:root_class` - CSS classes for the root `div` element.

* `:link_class` - CSS classes for the `a` element.

* `:icon_class` - CSS classes for the icon SVG.

* `:link_class` - CSS classes for the `a` element.


## Miscellaneous
### `AshAuthentication.Phoenix.Components.HorizontalRule`
Expand All @@ -264,14 +264,14 @@ A horizontal rule with text.

* `:root_class` - CSS class for the root `div` element.

* `:hr_outer_class` - CSS class for the outer `div` element of the horizontal rule.

* `:hr_inner_class` - CSS class for the inner `div` element of the horizontal rule.

* `:text_outer_class` - CSS class for the outer `div` element of the text area.
* `:hr_outer_class` - CSS class for the outer `div` element of the horizontal rule.

* `:text_inner_class` - CSS class for the inner `div` element of the text area.

* `:text_outer_class` - CSS class for the outer `div` element of the text area.


### `AshAuthentication.Phoenix.Components.Banner`

Expand All @@ -281,18 +281,18 @@ Renders a very simple banner at the top of the sign-in component.

* `:root_class` - CSS class for the root `div` element.

* `:dark_image_class` - Css class for the `img` tag in dark mode.

* `:dark_image_url` - A URL for the `img` `src` attribute in dark mode. Set to `nil` to disable.

* `:href_class` - CSS class for the `a` tag.

* `:href_url` - A URL for the banner image to link to. Set to `nil` to disable.

* `:image_class` - CSS class for the `img` tag.

* `:dark_image_class` - Css class for the `img` tag in dark mode.

* `:image_url` - A URL for the `img` `src` attribute. Set to `nil` to disable.

* `:dark_image_url` - A URL for the `img` `src` attribute in dark mode. Set to `nil` to disable.

* `:text_class` - CSS class for the text `div`.


Expand Down
15 changes: 14 additions & 1 deletion lib/mix/tasks/ash_authentication_phoenix.install.ex
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ defmodule Mix.Tasks.AshAuthenticationPhoenix.Install do
|> Keyword.put_new_lazy(:token, fn ->
Module.concat(options[:accounts], Token)
end)
|> module_option(:user)
|> module_option(:accounts)
|> module_option(:token)

install? =
!Igniter.Project.Deps.get_dependency_declaration(igniter, :ash_authentication)
Expand Down Expand Up @@ -311,7 +314,7 @@ defmodule Mix.Tasks.AshAuthenticationPhoenix.Install do
if install? do
Igniter.add_issue(
igniter,
"Could not find #{type} module. Something went wrong with installing ash_authentication."
"Could not find #{type} module: #{inspect(options[type])}. Something went wrong with installing ash_authentication."
)
else
run_installer? =
Expand All @@ -337,4 +340,14 @@ defmodule Mix.Tasks.AshAuthenticationPhoenix.Install do
end
end
end

defp module_option(opts, name) do
case Keyword.fetch(opts, name) do
{:ok, value} when is_binary(value) ->
Keyword.put(opts, name, Igniter.Code.Module.parse(value))

_ ->
opts
end
end
end
4 changes: 2 additions & 2 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
%{
"ash": {:hex, :ash, "3.4.26", "3d6aeb13aad5e703e9dcb59e4f4f69e94549599f56fcf8c546dc80f071930f61", [:mix], [{:decimal, "~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:ecto, "~> 3.7", [hex: :ecto, repo: "hexpm", optional: false]}, {:ets, "~> 0.8", [hex: :ets, repo: "hexpm", optional: false]}, {:igniter, ">= 0.3.36 and < 1.0.0-0", [hex: :igniter, repo: "hexpm", optional: false]}, {:jason, ">= 1.0.0", [hex: :jason, repo: "hexpm", optional: false]}, {:owl, "~> 0.11", [hex: :owl, repo: "hexpm", optional: false]}, {:picosat_elixir, "~> 0.2", [hex: :picosat_elixir, repo: "hexpm", optional: true]}, {:plug, ">= 0.0.0", [hex: :plug, repo: "hexpm", optional: true]}, {:reactor, "~> 0.9", [hex: :reactor, repo: "hexpm", optional: false]}, {:simple_sat, ">= 0.1.1 and < 1.0.0-0", [hex: :simple_sat, repo: "hexpm", optional: true]}, {:spark, ">= 2.2.29 and < 3.0.0-0", [hex: :spark, repo: "hexpm", optional: false]}, {:splode, "~> 0.2", [hex: :splode, repo: "hexpm", optional: false]}, {:stream_data, "~> 1.0", [hex: :stream_data, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.1", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "a59584bb8b59f87cbe858fd1ce1c0c3bb42fe99d9052c4423a15eb1acbaa4b6a"},
"ash": {:hex, :ash, "3.4.32", "7445f6876491acecf1621ad97434540a360f82fbfeb7c8c4f7971c92c9ae5f91", [:mix], [{:decimal, "~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:ecto, "~> 3.7", [hex: :ecto, repo: "hexpm", optional: false]}, {:ets, "~> 0.8", [hex: :ets, repo: "hexpm", optional: false]}, {:igniter, ">= 0.3.61 and < 1.0.0-0", [hex: :igniter, repo: "hexpm", optional: false]}, {:jason, ">= 1.0.0", [hex: :jason, repo: "hexpm", optional: false]}, {:owl, "~> 0.11", [hex: :owl, repo: "hexpm", optional: false]}, {:picosat_elixir, "~> 0.2", [hex: :picosat_elixir, repo: "hexpm", optional: true]}, {:plug, ">= 0.0.0", [hex: :plug, repo: "hexpm", optional: true]}, {:reactor, "~> 0.9", [hex: :reactor, repo: "hexpm", optional: false]}, {:simple_sat, ">= 0.1.1 and < 1.0.0-0", [hex: :simple_sat, repo: "hexpm", optional: true]}, {:spark, ">= 2.2.29 and < 3.0.0-0", [hex: :spark, repo: "hexpm", optional: false]}, {:splode, "~> 0.2", [hex: :splode, repo: "hexpm", optional: false]}, {:stream_data, "~> 1.0", [hex: :stream_data, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.1", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "a20224455a842f792d3aeb1fe313dedf619e4ad3d60a583f863b7417f8dc1991"},
"ash_authentication": {:hex, :ash_authentication, "4.2.0", "e2edea587c97d9ceeaf51fc7b9417b5c7dc32863cb36b44e3534062e9b3a2ce5", [:mix], [{:ash, ">= 3.4.14 and < 4.0.0-0", [hex: :ash, repo: "hexpm", optional: false]}, {:ash_postgres, "~> 2.0", [hex: :ash_postgres, repo: "hexpm", optional: true]}, {:assent, ">= 0.2.8 and < 1.0.0-0", [hex: :assent, repo: "hexpm", optional: false]}, {:bcrypt_elixir, "~> 3.0", [hex: :bcrypt_elixir, repo: "hexpm", optional: false]}, {:castore, "~> 1.0", [hex: :castore, repo: "hexpm", optional: false]}, {:finch, "~> 0.19", [hex: :finch, repo: "hexpm", optional: false]}, {:igniter, ">= 0.3.43 and < 1.0.0-0", [hex: :igniter, repo: "hexpm", optional: false]}, {:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: false]}, {:joken, "~> 2.5", [hex: :joken, repo: "hexpm", optional: false]}, {:plug, "~> 1.13", [hex: :plug, repo: "hexpm", optional: false]}, {:spark, "~> 2.0", [hex: :spark, repo: "hexpm", optional: false]}, {:splode, "~> 0.2", [hex: :splode, repo: "hexpm", optional: false]}], "hexpm", "5aafd9be1f60c647c8faf5da78028b98b0dfd1829e09306e2c07ce34a62b616c"},
"ash_phoenix": {:hex, :ash_phoenix, "2.1.4", "b4bcb718c7819671b6c59729b3c1550fc73c37d0115a55be8e0651404b2e2818", [:mix], [{:ash, "~> 3.0", [hex: :ash, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.5.6 or ~> 1.6", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 4.0", [hex: :phoenix_html, repo: "hexpm", optional: false]}, {:phoenix_live_view, "~> 0.20.3 or ~> 1.0", [hex: :phoenix_live_view, repo: "hexpm", optional: false]}], "hexpm", "d44004070e07ec342e754144a3474c45b7d38f0d47de5cbbbfb6219b65eebdf1"},
"assent": {:hex, :assent, "0.2.10", "27e544c3428996c8ad744d473b3ceae86e4eb7db6bc7432676420e67e9148dd7", [:mix], [{:certifi, ">= 0.0.0", [hex: :certifi, repo: "hexpm", optional: true]}, {:finch, "~> 0.15", [hex: :finch, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:jose, "~> 1.8", [hex: :jose, repo: "hexpm", optional: true]}, {:mint, "~> 1.0", [hex: :mint, repo: "hexpm", optional: true]}, {:req, "~> 0.4", [hex: :req, repo: "hexpm", optional: true]}, {:ssl_verify_fun, ">= 0.0.0", [hex: :ssl_verify_fun, repo: "hexpm", optional: true]}], "hexpm", "8483bf9621e994795a70a4ad8fda725abfb6a9675d63a9bfd4217c76d4a2d82a"},
Expand Down Expand Up @@ -64,7 +64,7 @@
"slugify": {:hex, :slugify, "1.3.1", "0d3b8b7e5c1eeaa960e44dce94382bee34a39b3ea239293e457a9c5b47cc6fd3", [:mix], [], "hexpm", "cb090bbeb056b312da3125e681d98933a360a70d327820e4b7f91645c4d8be76"},
"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"},
"spark": {:hex, :spark, "2.2.32", "cb84983c56e57670dd87a7a008a860d6e69626c814b0b5e25194b495ce56c7ba", [: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", "ee5a0a4ddb16ad8f5a792a7b1883498d3090c60101af77a866f76d54962478e8"},
"spark": {:hex, :spark, "2.2.33", "221e4e3f94296e4aedfc63ba4371328f0cfcbf884c6348eaa8ed636003d0c5c2", [: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", "663bc54574c55d6bfaf40eaa2732a197b42715020cca73a5b1737a4b398997d3"},
"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"},
Expand Down

0 comments on commit e09fe3e

Please sign in to comment.