diff --git a/.formatter.exs b/.formatter.exs index 4d45ebf..33e1eff 100644 --- a/.formatter.exs +++ b/.formatter.exs @@ -13,6 +13,6 @@ ], locals_without_parens: [oban_dashboard: 1], subdirectories: ["priv/*/migrations"], - plugins: [Phoenix.LiveView.HTMLFormatter], + plugins: [Phoenix.LiveView.HTMLFormatter, Quokka], inputs: ["*.{heex,ex,exs}", "{config,lib,test}/**/*.{heex,ex,exs}", "priv/*/*.exs"] ] diff --git a/.iex.exs b/.iex.exs index fef1334..f2afb96 100644 --- a/.iex.exs +++ b/.iex.exs @@ -1,7 +1,7 @@ +alias Garage.Accounts +alias Garage.Accounts.User alias Garage.Builds alias Garage.Builds.Build alias Garage.Mopeds alias Garage.Mopeds.Make alias Garage.Mopeds.Model -alias Garage.Accounts -alias Garage.Accounts.User diff --git a/config/config.exs b/config/config.exs index 4eac594..9d23902 100644 --- a/config/config.exs +++ b/config/config.exs @@ -7,15 +7,28 @@ # General application configuration import Config -config :garage, Oban, - engine: Oban.Engines.Basic, - notifier: Oban.Notifiers.Postgres, - queues: [default: 10], - repo: Garage.Repo +# Configure esbuild (the version is required) +config :esbuild, + version: "0.17.11", + default: [ + args: + ~w(js/app.js --bundle --target=es2017 --outdir=../priv/static/assets --external:/fonts/* --external:/images/* --external:/js/service-worker.js --external:js/heroicons.tailwind.plugin.js), + cd: Path.expand("../assets", __DIR__), + env: %{"NODE_PATH" => Path.expand("../deps", __DIR__)} + ] -config :garage, - ecto_repos: [Garage.Repo], - generators: [timestamp_type: :utc_datetime] +config :ex_aws, + http_client: ExAws.Finch, + json_codec: Jason + +# Configures the mailer +# +# By default it uses the "Local" adapter which stores the emails +# locally. You can see the emails in your browser, at "/dev/mailbox". +# +# For production it's recommended to configure a different adapter +# at the `config/runtime.exs`. +config :garage, Garage.Mailer, adapter: Swoosh.Adapters.Local # Configures the endpoint config :garage, GarageWeb.Endpoint, @@ -28,24 +41,28 @@ config :garage, GarageWeb.Endpoint, pubsub_server: Garage.PubSub, live_view: [signing_salt: "bViCUv7u"] -# Configures the mailer -# -# By default it uses the "Local" adapter which stores the emails -# locally. You can see the emails in your browser, at "/dev/mailbox". -# -# For production it's recommended to configure a different adapter -# at the `config/runtime.exs`. -config :garage, Garage.Mailer, adapter: Swoosh.Adapters.Local +config :garage, Oban, + engine: Oban.Engines.Basic, + notifier: Oban.Notifiers.Postgres, + queues: [default: 10, resize: 20, push: 20], + repo: Garage.Repo -# Configure esbuild (the version is required) -config :esbuild, - version: "0.17.11", - default: [ - args: - ~w(js/app.js --bundle --target=es2017 --outdir=../priv/static/assets --external:/fonts/* --external:/images/* --external:/js/service-worker.js --external:js/heroicons.tailwind.plugin.js), - cd: Path.expand("../assets", __DIR__), - env: %{"NODE_PATH" => Path.expand("../deps", __DIR__)} - ] +config :garage, + ash_domains: [Garage.Builds, Garage.Mopeds, Garage.Accounts], + env: config_env(), + max_upload_size: 15_000_000 + +config :garage, + ecto_repos: [Garage.Repo], + generators: [timestamp_type: :utc_datetime] + +# Configures Elixir's Logger +config :logger, :console, + format: "$time $metadata[$level] $message\n", + metadata: [:request_id] + +# Use Jason for JSON parsing in Phoenix +config :phoenix, :json_library, JSON # Configure tailwind (the version is required) config :tailwind, @@ -58,27 +75,6 @@ config :tailwind, cd: Path.expand("../assets", __DIR__) ] -# Configures Elixir's Logger -config :logger, :console, - format: "$time $metadata[$level] $message\n", - metadata: [:request_id] - -# Use Jason for JSON parsing in Phoenix -config :phoenix, :json_library, JSON - -config :ex_aws, - http_client: ExAws.Finch, - json_codec: Jason - -config :garage, - ash_domains: [Garage.Builds, Garage.Mopeds, Garage.Accounts], - env: config_env(), - max_upload_size: 15_000_000 - -config :garage, Oban, - repo: Garage.Repo, - queues: [resize: 20, push: 20] - # config :crawly, # closespider_timeout: 10, # concurrent_requests_per_domain: 8, diff --git a/config/dev.exs b/config/dev.exs index c5672d8..fc691ce 100644 --- a/config/dev.exs +++ b/config/dev.exs @@ -2,6 +2,12 @@ import Config # Configure your database config :garage, Garage.Repo, + # For development, we disable any cache and enable + # debugging and code reloading. + # + # The watchers configuration can be used to run external + # watchers to your application. For example, we can use it + # to bundle .js and .css sources. username: "postgres", password: "postgres", hostname: "localhost", @@ -10,12 +16,6 @@ config :garage, Garage.Repo, show_sensitive_data_on_connection_error: true, pool_size: 10 -# For development, we disable any cache and enable -# debugging and code reloading. -# -# The watchers configuration can be used to run external -# watchers to your application. For example, we can use it -# to bundle .js and .css sources. config :garage, GarageWeb.Endpoint, # Binding to loopback ipv4 address prevents access from other machines. # Change to `ip: {0, 0, 0, 0}` to allow access from other machines. @@ -29,29 +29,6 @@ config :garage, GarageWeb.Endpoint, tailwind: {Tailwind, :install_and_run, [:default, ~w(--watch)]} ] -# ## SSL Support -# -# In order to use HTTPS in development, a self-signed -# certificate can be generated by running the following -# Mix task: -# -# mix phx.gen.cert -# -# Run `mix help phx.gen.cert` for more information. -# -# The `http:` config above can be replaced with: -# -# https: [ -# port: 4001, -# cipher_suite: :strong, -# keyfile: "priv/cert/selfsigned_key.pem", -# certfile: "priv/cert/selfsigned.pem" -# ], -# -# If desired, both `http:` and `https:` keys can be -# configured to run both http and https servers on -# different ports. - # Watch static and templates for browser reloading. config :garage, GarageWeb.Endpoint, live_reload: [ @@ -59,33 +36,56 @@ config :garage, GarageWeb.Endpoint, ~r"priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$", ~r"priv/gettext/.*(po)$", ~r"lib/garage_web/(controllers|live|components)/.*(ex|heex)$", + # ## SSL Support + # + # In order to use HTTPS in development, a self-signed + # certificate can be generated by running the following + # Mix task: ~r"lib/garage_web/pyro_overrides.ex" ] ] # Enable dev routes for dashboard and mailbox +# +# mix phx.gen.cert +# +# Run `mix help phx.gen.cert` for more information. +# +# The `http:` config above can be replaced with: +# +# https: [ +# port: 4001, config :garage, dev_routes: true +config :garage, + upload_bucket: :dev, + public_image_root: "https://pub-09d9519a20aa4503bc4336772b724d1a.r2.dev", + discord_channel: 1_388_349_484_383_207_516, + site_url: "http://localhost:4000" + # Do not include metadata nor timestamps in development logs +# cipher_suite: :strong, +# keyfile: "priv/cert/selfsigned_key.pem", +# certfile: "priv/cert/selfsigned.pem" +# ], config :logger, :console, format: "[$level] $message\n" +# Initialize plugs at runtime for faster development compilation +# +# If desired, both `http:` and `https:` keys can be +# configured to run both http and https servers on +config :phoenix, :plug_init_mode, :runtime + # Set a higher stacktrace during development. Avoid configuring such +# different ports. + # in production as building large stacktraces may be expensive. config :phoenix, :stacktrace_depth, 20 -# Initialize plugs at runtime for faster development compilation -config :phoenix, :plug_init_mode, :runtime - # Include HEEx debug annotations as HTML comments in rendered markup config :phoenix_live_view, :debug_heex_annotations, true # Disable swoosh api client as it is only required for production adapters. config :swoosh, :api_client, false -config :garage, - upload_bucket: :dev, - public_image_root: "https://pub-09d9519a20aa4503bc4336772b724d1a.r2.dev", - discord_channel: 1_388_349_484_383_207_516, - site_url: "http://localhost:4000" - import_config("dev.secret.exs") diff --git a/config/prod.exs b/config/prod.exs index c0610c6..61e34ed 100644 --- a/config/prod.exs +++ b/config/prod.exs @@ -1,20 +1,18 @@ import Config -# Note we also include the path to a cache manifest -# containing the digested version of static files. This -# manifest is generated by the `mix assets.deploy` task, -# which you should run after static files are built and -# before starting your production server. -config :garage, GarageWeb.Endpoint, cache_static_manifest: "priv/static/cache_manifest.json" - -# Configures Swoosh API Client -config :swoosh, api_client: Swoosh.ApiClient.Finch, finch_name: Garage.Finch +config :ex_aws, :s3, + scheme: "https://", + # Note we also include the path to a cache manifest + # containing the digested version of static files. This + # manifest is generated by the `mix assets.deploy` task, + # which you should run after static files are built and + # before starting your production server. + host: "4e7e19d415ae25f4681ff5aa75b38d98.r2.cloudflarestorage.com" -# Disable Swoosh Local Memory Storage -config :swoosh, local: false +config :ex_aws, + region: "auto" -# Do not print debug messages in production -config :logger, level: :info +config :garage, GarageWeb.Endpoint, cache_static_manifest: "priv/static/cache_manifest.json" # Runtime production configuration, including reading # of environment variables, is done on config/runtime.exs. @@ -24,12 +22,8 @@ config :garage, discord_channel: 1_237_258_590_675_402_794, site_url: "https://moped.club" -config :ex_aws, - region: "auto" - -config :ex_aws, :s3, - scheme: "https://", - host: "4e7e19d415ae25f4681ff5aa75b38d98.r2.cloudflarestorage.com" +# Do not print debug messages in production +config :logger, level: :info config :sentry, dsn: @@ -37,3 +31,9 @@ config :sentry, environment_name: Mix.env(), enable_source_code_context: true, root_source_code_paths: [File.cwd!()] + +# Configures Swoosh API Client +config :swoosh, api_client: Swoosh.ApiClient.Finch, finch_name: Garage.Finch + +# Disable Swoosh Local Memory Storage +config :swoosh, local: false diff --git a/config/runtime.exs b/config/runtime.exs index 1df79b7..44e411a 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -30,12 +30,6 @@ if config_env() == :prod do maybe_ipv6 = if System.get_env("ECTO_IPV6") in ~w(true 1), do: [:inet6], else: [] - config :garage, Garage.Repo, - # ssl: true, - url: database_url, - pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10"), - socket_options: maybe_ipv6 - # The secret key base is used to sign/encrypt cookies and other secrets. # A default value is used in config/dev.exs and config/test.exs but you # want to use a different value for prod and you most likely don't want @@ -72,12 +66,27 @@ if config_env() == :prod do You can generate one by calling: mix generate.vapid.keys """ + # ## Configuring the mailer + # + # In production you need to configure the mailer to use a different adapter. + # Also, you may need to configure the Swoosh API client of your choice if you + # are not using SMTP. Here is an example of the configuration: + # + config :garage, Garage.Mailer, + adapter: Swoosh.Adapters.Mailgun, + api_key: System.get_env("MAILGUN_API_KEY"), + domain: System.get_env("MAILGUN_DOMAIN") + config :garage, Garage.Push, vapid_private_key: vapid_private_key, vapid_public_key: vapid_public_key, vapid_subject: vapid_subject - config :garage, :dns_cluster_query, System.get_env("DNS_CLUSTER_QUERY") + config :garage, Garage.Repo, + # ssl: true, + url: database_url, + pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10"), + socket_options: maybe_ipv6 config :garage, GarageWeb.Endpoint, url: [host: host, port: 443, scheme: "https"], @@ -91,16 +100,7 @@ if config_env() == :prod do ], secret_key_base: secret_key_base - config :nostrum, token: System.get_env("NOSTRUM_TOKEN") + config :garage, :dns_cluster_query, System.get_env("DNS_CLUSTER_QUERY") - # ## Configuring the mailer - # - # In production you need to configure the mailer to use a different adapter. - # Also, you may need to configure the Swoosh API client of your choice if you - # are not using SMTP. Here is an example of the configuration: - # - config :garage, Garage.Mailer, - adapter: Swoosh.Adapters.Mailgun, - api_key: System.get_env("MAILGUN_API_KEY"), - domain: System.get_env("MAILGUN_DOMAIN") + config :nostrum, token: System.get_env("NOSTRUM_TOKEN") end diff --git a/config/test.exs b/config/test.exs index 7391d77..ed33e54 100644 --- a/config/test.exs +++ b/config/test.exs @@ -1,34 +1,35 @@ -import Config -config :garage, Oban, testing: :manual - # Configure your database # # The MIX_TEST_PARTITION environment variable can be used +import Config + +# In test we don't send emails. # to provide built-in test partitioning in CI environment. # Run `mix help test` for more information. +config :garage, Garage.Mailer, adapter: Swoosh.Adapters.Test + config :garage, Garage.Repo, username: "postgres", password: "postgres", hostname: "localhost", database: "garage_test#{System.get_env("MIX_TEST_PARTITION")}", pool: Ecto.Adapters.SQL.Sandbox, + # We don't run a server during test. If one is required, + # you can enable the server option below. pool_size: 10 -# We don't run a server during test. If one is required, -# you can enable the server option below. config :garage, GarageWeb.Endpoint, http: [ip: {127, 0, 0, 1}, port: 4002], secret_key_base: "W2x/f7dT4cYWLuOrmI+RV9vhjLcqKwfYaErjaDumfYkW2UCyGsBzK0KBp/CMpWyD", server: false -# In test we don't send emails. -config :garage, Garage.Mailer, adapter: Swoosh.Adapters.Test - -# Disable swoosh api client as it is only required for production adapters. -config :swoosh, :api_client, false +config :garage, Oban, testing: :manual # Print only warnings and errors during test config :logger, level: :warning # Initialize plugs at runtime for faster test compilation config :phoenix, :plug_init_mode, :runtime + +# Disable swoosh api client as it is only required for production adapters. +config :swoosh, :api_client, false diff --git a/lib/garage/accounts/push_token.ex b/lib/garage/accounts/push_token.ex index 954ce2d..9339e60 100644 --- a/lib/garage/accounts/push_token.ex +++ b/lib/garage/accounts/push_token.ex @@ -1,7 +1,7 @@ defmodule Garage.Accounts.PushToken do - @derive {Jason.Encoder, only: [:endpoint, :keys]} use Ash.Resource, otp_app: :garage, domain: Garage.Accounts, data_layer: AshPostgres.DataLayer + @derive {Jason.Encoder, only: [:endpoint, :keys]} actions do defaults [ :read, diff --git a/lib/garage/builds/build.ex b/lib/garage/builds/build.ex index a9db683..6ae207a 100644 --- a/lib/garage/builds/build.ex +++ b/lib/garage/builds/build.ex @@ -1,13 +1,11 @@ defmodule Garage.Builds.Build do - @derive {Phoenix.Param, key: :slug} - use Ash.Resource, data_layer: AshPostgres.DataLayer, domain: Garage.Builds, authorizers: [Ash.Policy.Authorizer], simple_notifiers: [Garage.Notifiers.Discord] - require Ecto.Query + alias Garage.Accounts.User alias Garage.Builds.{ CarbTuning, @@ -30,7 +28,9 @@ defmodule Garage.Builds.Build do Pulley } - alias Garage.Accounts.User + require Ecto.Query + + @derive {Phoenix.Param, key: :slug} attributes do uuid_primary_key :id diff --git a/lib/garage/changes/reset_nonce.ex b/lib/garage/changes/reset_nonce.ex index f23ef83..bd7be52 100644 --- a/lib/garage/changes/reset_nonce.ex +++ b/lib/garage/changes/reset_nonce.ex @@ -3,6 +3,7 @@ defmodule Garage.Changes.ResetNonce do Change module to set the slug on a resource """ use Ash.Resource.Change + alias Ash.Changeset @impl true diff --git a/lib/garage/changes/set_color.ex b/lib/garage/changes/set_color.ex index 3b40950..234aca6 100644 --- a/lib/garage/changes/set_color.ex +++ b/lib/garage/changes/set_color.ex @@ -5,6 +5,7 @@ defmodule Garage.Changes.SetColor do The nonce is so users can change it (but only randomly) """ use Ash.Resource.Change + alias Ash.Changeset @impl true diff --git a/lib/garage/changes/set_nonce.ex b/lib/garage/changes/set_nonce.ex index 843c4eb..e1af0fc 100644 --- a/lib/garage/changes/set_nonce.ex +++ b/lib/garage/changes/set_nonce.ex @@ -3,6 +3,7 @@ defmodule Garage.Changes.SetNonce do Set a color nonce if one didn't exist before """ use Ash.Resource.Change + alias Ash.Changeset @impl true diff --git a/lib/garage/changes/set_slug.ex b/lib/garage/changes/set_slug.ex index 055f80c..f36c475 100644 --- a/lib/garage/changes/set_slug.ex +++ b/lib/garage/changes/set_slug.ex @@ -3,6 +3,7 @@ defmodule Garage.Changes.SetSlug do Change module to set the slug on a resource """ use Ash.Resource.Change + alias Ash.Changeset @impl true diff --git a/lib/garage/mopeds/crank.ex b/lib/garage/mopeds/crank.ex index 79f7e65..eff7e63 100644 --- a/lib/garage/mopeds/crank.ex +++ b/lib/garage/mopeds/crank.ex @@ -4,6 +4,7 @@ defmodule Garage.Mopeds.Crank do domain: Garage.Mopeds import Ash.Sort, only: [expr_sort: 2] + alias Garage.Mopeds.Engine actions do diff --git a/lib/garage/mopeds/engine.ex b/lib/garage/mopeds/engine.ex index d5c68a5..923fee4 100644 --- a/lib/garage/mopeds/engine.ex +++ b/lib/garage/mopeds/engine.ex @@ -3,8 +3,8 @@ defmodule Garage.Mopeds.Engine do data_layer: AshPostgres.DataLayer, domain: Garage.Mopeds - import Ash.Sort, only: [expr_sort: 2] import Ash.Expr + import Ash.Sort, only: [expr_sort: 2] actions do default_accept :* diff --git a/lib/garage/mopeds/manufacturer.ex b/lib/garage/mopeds/manufacturer.ex index 930a74d..8d20726 100644 --- a/lib/garage/mopeds/manufacturer.ex +++ b/lib/garage/mopeds/manufacturer.ex @@ -1,9 +1,9 @@ defmodule Garage.Mopeds.Manufacturer do - @derive {Phoenix.Param, key: :slug} use Ash.Resource, data_layer: AshPostgres.DataLayer, domain: Garage.Mopeds + @derive {Phoenix.Param, key: :slug} actions do default_accept :* defaults [:read, :update, :destroy] diff --git a/lib/garage/notifiers/discord.ex b/lib/garage/notifiers/discord.ex index 38080ee..24d517d 100644 --- a/lib/garage/notifiers/discord.ex +++ b/lib/garage/notifiers/discord.ex @@ -56,5 +56,4 @@ defmodule Garage.Notifiers.Discord do defp enabled? do Application.get_env(:garage, :env) in [:dev, :prod] end - end diff --git a/lib/garage/release.ex b/lib/garage/release.ex index b6b322d..3d67885 100644 --- a/lib/garage/release.ex +++ b/lib/garage/release.ex @@ -31,7 +31,7 @@ defmodule Garage.Release do Application.load(@app) end - def move_image_urls_to_images() do + def move_image_urls_to_images do all_builds = Ash.read!(Garage.Builds.Build) for build <- all_builds do diff --git a/lib/garage/seeds.ex b/lib/garage/seeds.ex index 2fca342..a2d473a 100644 --- a/lib/garage/seeds.ex +++ b/lib/garage/seeds.ex @@ -63,7 +63,7 @@ defmodule Garage.Seeds do end # Run me next - def generate_part_seeds() do + def generate_part_seeds do mapping = %{ "1" => :engines, "2" => :carburetors, diff --git a/lib/garage/workers/push.ex b/lib/garage/workers/push.ex index db96527..385ed7e 100644 --- a/lib/garage/workers/push.ex +++ b/lib/garage/workers/push.ex @@ -1,5 +1,6 @@ defmodule Garage.Workers.Push do use Oban.Worker, queue: :push + require Logger @impl Oban.Worker diff --git a/lib/garage/workers/resize.ex b/lib/garage/workers/resize.ex index 1ccc9af..6fd04a2 100644 --- a/lib/garage/workers/resize.ex +++ b/lib/garage/workers/resize.ex @@ -1,5 +1,6 @@ defmodule Garage.Workers.Resize do use Oban.Worker, queue: :resize + require Logger @impl Oban.Worker @@ -26,8 +27,8 @@ defmodule Garage.Workers.Resize do ExAws.S3.put_object(bucket(), optimized_path, optimized) |> ExAws.request!() Garage.Builds.Image.update!(image_record, %{ - thumbnail_url: URI.to_string(%URI{parsed_uri | path: thumb_path}), - optimized_url: URI.to_string(%URI{parsed_uri | path: optimized_path}) + thumbnail_url: URI.to_string(%{parsed_uri | path: thumb_path}), + optimized_url: URI.to_string(%{parsed_uri | path: optimized_path}) }) :ok diff --git a/lib/garage_web.ex b/lib/garage_web.ex index 8f00e03..2a99fcd 100644 --- a/lib/garage_web.ex +++ b/lib/garage_web.ex @@ -25,10 +25,11 @@ defmodule GarageWeb do quote do use Phoenix.Router, helpers: true - # Import common connection and controller functions to use in pipelines - import Plug.Conn import Phoenix.Controller import Phoenix.LiveView.Router + + # Import common connection and controller functions to use in pipelines + import Plug.Conn end end @@ -44,9 +45,10 @@ defmodule GarageWeb do formats: [:html, :json], layouts: [html: GarageWeb.Layouts] - import Plug.Conn use Gettext, backend: GarageWeb.Gettext + import Plug.Conn + unquote(verified_routes()) end end @@ -95,16 +97,13 @@ defmodule GarageWeb do defp html_helpers do quote do + use Gettext, backend: GarageWeb.Gettext + import GarageWeb.CoreComponents + import GarageWeb.Options + import GarageWeb.TimeHelpers # HTML escaping functionality import Phoenix.HTML # Core UI components and translation - import GarageWeb.CoreComponents - - use Gettext, backend: GarageWeb.Gettext - - import GarageWeb.TimeHelpers - - import GarageWeb.Options # Shortcut for generating JS commands alias Phoenix.LiveView.JS diff --git a/lib/garage_web/components/core_components.ex b/lib/garage_web/components/core_components.ex index 031883a..68cbe0c 100644 --- a/lib/garage_web/components/core_components.ex +++ b/lib/garage_web/components/core_components.ex @@ -16,9 +16,9 @@ defmodule GarageWeb.CoreComponents do """ use Phoenix.Component use GarageWeb, :verified_routes + use Gettext, backend: GarageWeb.Gettext alias Phoenix.LiveView.JS - use Gettext, backend: GarageWeb.Gettext @doc """ Renders a modal. diff --git a/lib/garage_web/live/auth_live/index.ex b/lib/garage_web/live/auth_live/index.ex index d7a2616..e3ad90a 100644 --- a/lib/garage_web/live/auth_live/index.ex +++ b/lib/garage_web/live/auth_live/index.ex @@ -1,9 +1,9 @@ defmodule GarageWeb.AuthLive.Index do use GarageWeb, :live_view + alias AshPhoenix.Form alias Garage.Accounts alias Garage.Accounts.User - alias AshPhoenix.Form @impl true def render(assigns) do diff --git a/lib/garage_web/live/auth_live/reset.ex b/lib/garage_web/live/auth_live/reset.ex index 90395b0..8ad86c2 100644 --- a/lib/garage_web/live/auth_live/reset.ex +++ b/lib/garage_web/live/auth_live/reset.ex @@ -1,8 +1,9 @@ defmodule GarageWeb.AuthLive.Reset do use GarageWeb, :live_view + + alias AshPhoenix.Form alias Garage.Accounts alias Garage.Accounts.User - alias AshPhoenix.Form @impl true def render(assigns) do diff --git a/lib/garage_web/live/builds_live/edit.ex b/lib/garage_web/live/builds_live/edit.ex index 094c060..8f92b84 100644 --- a/lib/garage_web/live/builds_live/edit.ex +++ b/lib/garage_web/live/builds_live/edit.ex @@ -1,9 +1,8 @@ defmodule GarageWeb.BuildsLive.Edit do - require Logger - alias Garage.Mopeds.Variator - alias Garage.Mopeds.Pulley use GarageWeb, :live_view + import GarageWeb.BuildsLive.Helpers + alias AshPhoenix.Form alias ExAws.S3 alias Garage.Builds.Build @@ -17,8 +16,9 @@ defmodule GarageWeb.BuildsLive.Edit do alias Garage.Mopeds.Ignition alias Garage.Mopeds.Manufacturer alias Garage.Mopeds.Model + alias Garage.Mopeds.Pulley + alias Garage.Mopeds.Variator - import GarageWeb.BuildsLive.Helpers require Logger @impl true @@ -44,8 +44,6 @@ defmodule GarageWeb.BuildsLive.Edit do models = if manufacturer_id = form_manufacturer_id(form) do Model.by_manufacturer_id!(manufacturer_id) - else - nil end {:ok, @@ -477,7 +475,7 @@ defmodule GarageWeb.BuildsLive.Edit do end end - defp max_size() do + defp max_size do Application.get_env(:garage, :max_upload_size) end end diff --git a/lib/garage_web/live/builds_live/helpers.ex b/lib/garage_web/live/builds_live/helpers.ex index 3ef8529..005dfd6 100644 --- a/lib/garage_web/live/builds_live/helpers.ex +++ b/lib/garage_web/live/builds_live/helpers.ex @@ -17,7 +17,7 @@ defmodule GarageWeb.BuildsLive.Helpers do end end - def year_options() do + def year_options do 2023..1900//-1 |> Enum.to_list() end end diff --git a/lib/garage_web/live/builds_live/index.ex b/lib/garage_web/live/builds_live/index.ex index f1ad9e5..f625e31 100644 --- a/lib/garage_web/live/builds_live/index.ex +++ b/lib/garage_web/live/builds_live/index.ex @@ -1,9 +1,10 @@ defmodule GarageWeb.BuildsLive.Index do use GarageWeb, :live_view - alias Garage.Builds.Build import GarageWeb.Components.Builds.Build + alias Garage.Builds.Build + @impl true def render(assigns) do ~H""" diff --git a/lib/garage_web/live/builds_live/new.ex b/lib/garage_web/live/builds_live/new.ex index dbbca38..d873532 100644 --- a/lib/garage_web/live/builds_live/new.ex +++ b/lib/garage_web/live/builds_live/new.ex @@ -1,12 +1,13 @@ defmodule GarageWeb.BuildsLive.New do use GarageWeb, :live_view + import GarageWeb.BuildsLive.Helpers + alias AshPhoenix.Form alias Garage.Builds alias Garage.Builds.Build alias Garage.Mopeds.Manufacturer alias Garage.Mopeds.Model - import GarageWeb.BuildsLive.Helpers @impl true def render(assigns) do @@ -69,8 +70,6 @@ defmodule GarageWeb.BuildsLive.New do model_options = if manufacturer_id = form_manufacturer_id(form) do model_options_by_id(manufacturer_id) - else - nil end {:ok, @@ -123,11 +122,7 @@ defmodule GarageWeb.BuildsLive.New do end @impl true - def handle_event( - "save", - %{"form" => params}, - socket - ) do + def handle_event("save", %{"form" => params}, socket) do case Form.submit(socket.assigns.form, params: params) do {:ok, build} -> {:noreply, @@ -140,7 +135,7 @@ defmodule GarageWeb.BuildsLive.New do end end - def manufacturer_options() do + def manufacturer_options do for manufacturer <- Manufacturer.by_category!(:mopeds), into: [], do: {manufacturer.name, manufacturer.id} diff --git a/lib/garage_web/live/builds_live/show.ex b/lib/garage_web/live/builds_live/show.ex index 1e23460..8331d12 100644 --- a/lib/garage_web/live/builds_live/show.ex +++ b/lib/garage_web/live/builds_live/show.ex @@ -1,13 +1,13 @@ defmodule GarageWeb.BuildsLive.Show do use GarageWeb, :live_view - alias Garage.Builds.Build - alias Garage.Builds.Comment - alias AshPhoenix.Form - import GarageWeb.Components.Builds.Comment - import GarageWeb.Components.Builds.LikeHeart import GarageWeb.Components.Builds.FollowButton + import GarageWeb.Components.Builds.LikeHeart + + alias AshPhoenix.Form + alias Garage.Builds.Build + alias Garage.Builds.Comment @impl true def mount(_params, _session, socket) do diff --git a/lib/garage_web/live/carburetor_live/form_component.ex b/lib/garage_web/live/carburetor_live/form_component.ex index 1d6f0ad..6bc43ac 100644 --- a/lib/garage_web/live/carburetor_live/form_component.ex +++ b/lib/garage_web/live/carburetor_live/form_component.ex @@ -169,11 +169,11 @@ defmodule GarageWeb.CarburetorLive.FormComponent do assign(socket, form: to_form(form)) end - def manufacturer_options() do + def manufacturer_options do Manufacturer.by_category!(:carburetors) |> to_options() end - def tunable_parts() do + def tunable_parts do Ash.Resource.Info.attribute(Carburetor, :tunable_parts).constraints[:items][:one_of] |> to_options() end diff --git a/lib/garage_web/live/carburetor_live/show.ex b/lib/garage_web/live/carburetor_live/show.ex index bd2d5e6..1965042 100644 --- a/lib/garage_web/live/carburetor_live/show.ex +++ b/lib/garage_web/live/carburetor_live/show.ex @@ -1,7 +1,8 @@ defmodule GarageWeb.CarburetorLive.Show do - import GarageWeb.Components.Builds.Build use GarageWeb, :live_view + import GarageWeb.Components.Builds.Build + @impl true def render(assigns) do ~H""" diff --git a/lib/garage_web/live/clutch_live/form_component.ex b/lib/garage_web/live/clutch_live/form_component.ex index cc7710c..a934cc3 100644 --- a/lib/garage_web/live/clutch_live/form_component.ex +++ b/lib/garage_web/live/clutch_live/form_component.ex @@ -1,5 +1,6 @@ defmodule GarageWeb.ClutchLive.FormComponent do use GarageWeb, :live_component + alias Garage.Mopeds.Manufacturer @impl true @@ -124,7 +125,7 @@ defmodule GarageWeb.ClutchLive.FormComponent do assign(socket, form: to_form(form)) end - def manufacturer_options() do + def manufacturer_options do for manufacturer <- Manufacturer.by_category!(:clutches), into: [], do: {manufacturer.name, manufacturer.id} diff --git a/lib/garage_web/live/clutch_live/show.ex b/lib/garage_web/live/clutch_live/show.ex index 68ac5e2..8090b13 100644 --- a/lib/garage_web/live/clutch_live/show.ex +++ b/lib/garage_web/live/clutch_live/show.ex @@ -1,7 +1,8 @@ defmodule GarageWeb.ClutchLive.Show do - import GarageWeb.Components.Builds.Build use GarageWeb, :live_view + import GarageWeb.Components.Builds.Build + @impl true def render(assigns) do ~H""" diff --git a/lib/garage_web/live/crank_live/form_component.ex b/lib/garage_web/live/crank_live/form_component.ex index c8ed163..c09edd8 100644 --- a/lib/garage_web/live/crank_live/form_component.ex +++ b/lib/garage_web/live/crank_live/form_component.ex @@ -1,5 +1,6 @@ defmodule GarageWeb.CrankLive.FormComponent do use GarageWeb, :live_component + alias Garage.Mopeds.Engine alias Garage.Mopeds.Manufacturer @@ -144,13 +145,13 @@ defmodule GarageWeb.CrankLive.FormComponent do assign(socket, form: to_form(form)) end - def manufacturer_options() do + def manufacturer_options do for manufacturer <- Manufacturer.by_category!(:cranks), into: [], do: {manufacturer.name, manufacturer.id} end - def engine_options() do + def engine_options do for engine <- Engine.read_all!(load: [:manufacturer]), into: [], do: {"#{engine.manufacturer.name} #{engine.name}", engine.id} diff --git a/lib/garage_web/live/cylinder_live/form_component.ex b/lib/garage_web/live/cylinder_live/form_component.ex index f5ad4ce..668ea56 100644 --- a/lib/garage_web/live/cylinder_live/form_component.ex +++ b/lib/garage_web/live/cylinder_live/form_component.ex @@ -128,7 +128,7 @@ defmodule GarageWeb.CylinderLive.FormComponent do assign(socket, form: to_form(form)) end - def manufacturer_options() do + def manufacturer_options do for manufacturer <- Manufacturer.by_category!(:cylinders), into: [], do: {manufacturer.name, manufacturer.id} diff --git a/lib/garage_web/live/cylinder_live/show.ex b/lib/garage_web/live/cylinder_live/show.ex index 159e351..18d264f 100644 --- a/lib/garage_web/live/cylinder_live/show.ex +++ b/lib/garage_web/live/cylinder_live/show.ex @@ -1,7 +1,8 @@ defmodule GarageWeb.CylinderLive.Show do - import GarageWeb.Components.Builds.Build use GarageWeb, :live_view + import GarageWeb.Components.Builds.Build + @impl true def render(assigns) do ~H""" diff --git a/lib/garage_web/live/engine_live/form_component.ex b/lib/garage_web/live/engine_live/form_component.ex index d55feee..fcf20e9 100644 --- a/lib/garage_web/live/engine_live/form_component.ex +++ b/lib/garage_web/live/engine_live/form_component.ex @@ -1,5 +1,6 @@ defmodule GarageWeb.EngineLive.FormComponent do use GarageWeb, :live_component + alias Garage.Mopeds.Manufacturer @impl true diff --git a/lib/garage_web/live/engine_live/show.ex b/lib/garage_web/live/engine_live/show.ex index 29d4f97..e3c1f0b 100644 --- a/lib/garage_web/live/engine_live/show.ex +++ b/lib/garage_web/live/engine_live/show.ex @@ -1,7 +1,8 @@ defmodule GarageWeb.EngineLive.Show do - import GarageWeb.Components.Builds.Build use GarageWeb, :live_view + import GarageWeb.Components.Builds.Build + @impl true def render(assigns) do ~H""" diff --git a/lib/garage_web/live/exhaust_live/form_component.ex b/lib/garage_web/live/exhaust_live/form_component.ex index c4bc853..9604d22 100644 --- a/lib/garage_web/live/exhaust_live/form_component.ex +++ b/lib/garage_web/live/exhaust_live/form_component.ex @@ -1,5 +1,6 @@ defmodule GarageWeb.ExhaustLive.FormComponent do use GarageWeb, :live_component + alias Garage.Mopeds.Manufacturer @impl true @@ -123,7 +124,7 @@ defmodule GarageWeb.ExhaustLive.FormComponent do assign(socket, form: to_form(form)) end - def manufacturer_options() do + def manufacturer_options do for manufacturer <- Manufacturer.by_category!(:exhausts), into: [], do: {manufacturer.name, manufacturer.id} diff --git a/lib/garage_web/live/exhaust_live/show.ex b/lib/garage_web/live/exhaust_live/show.ex index aa74fa6..23c8b11 100644 --- a/lib/garage_web/live/exhaust_live/show.ex +++ b/lib/garage_web/live/exhaust_live/show.ex @@ -1,7 +1,8 @@ defmodule GarageWeb.ExhaustLive.Show do - import GarageWeb.Components.Builds.Build use GarageWeb, :live_view + import GarageWeb.Components.Builds.Build + @impl true def render(assigns) do ~H""" diff --git a/lib/garage_web/live/home_live/index.ex b/lib/garage_web/live/home_live/index.ex index 1791d41..e915bdd 100644 --- a/lib/garage_web/live/home_live/index.ex +++ b/lib/garage_web/live/home_live/index.ex @@ -1,5 +1,6 @@ defmodule GarageWeb.HomeLive.Index do use GarageWeb, :live_view + import GarageWeb.Components.Builds.Card def render(assigns) do diff --git a/lib/garage_web/live/ignition_live/form_component.ex b/lib/garage_web/live/ignition_live/form_component.ex index 0a98b4d..2f670b6 100644 --- a/lib/garage_web/live/ignition_live/form_component.ex +++ b/lib/garage_web/live/ignition_live/form_component.ex @@ -1,5 +1,6 @@ defmodule GarageWeb.IgnitionLive.FormComponent do use GarageWeb, :live_component + alias Garage.Mopeds.Manufacturer @impl true @@ -123,7 +124,7 @@ defmodule GarageWeb.IgnitionLive.FormComponent do assign(socket, form: to_form(form)) end - def manufacturer_options() do + def manufacturer_options do for manufacturer <- Manufacturer.by_category!(:ignitions), into: [], do: {manufacturer.name, manufacturer.id} diff --git a/lib/garage_web/live/ignition_live/show.ex b/lib/garage_web/live/ignition_live/show.ex index 817681d..716f7c9 100644 --- a/lib/garage_web/live/ignition_live/show.ex +++ b/lib/garage_web/live/ignition_live/show.ex @@ -1,7 +1,8 @@ defmodule GarageWeb.IgnitionLive.Show do - import GarageWeb.Components.Builds.Build use GarageWeb, :live_view + import GarageWeb.Components.Builds.Build + @impl true def render(assigns) do ~H""" diff --git a/lib/garage_web/live/manufacturer_live/form_component.ex b/lib/garage_web/live/manufacturer_live/form_component.ex index 51a71fe..86e721f 100644 --- a/lib/garage_web/live/manufacturer_live/form_component.ex +++ b/lib/garage_web/live/manufacturer_live/form_component.ex @@ -1,5 +1,6 @@ defmodule GarageWeb.ManufacturerLive.FormComponent do use GarageWeb, :live_component + alias Garage.Mopeds.Manufacturer @impl true diff --git a/lib/garage_web/live/manufacturer_live/show.ex b/lib/garage_web/live/manufacturer_live/show.ex index ddd4506..c991b4b 100644 --- a/lib/garage_web/live/manufacturer_live/show.ex +++ b/lib/garage_web/live/manufacturer_live/show.ex @@ -1,6 +1,8 @@ defmodule GarageWeb.ManufacturerLive.Show do - import GarageWeb.Components.Builds.Build use GarageWeb, :live_view + + import GarageWeb.Components.Builds.Build + require Ash.Query @impl true diff --git a/lib/garage_web/live/model_live/form_component.ex b/lib/garage_web/live/model_live/form_component.ex index 41b00e2..ab5199d 100644 --- a/lib/garage_web/live/model_live/form_component.ex +++ b/lib/garage_web/live/model_live/form_component.ex @@ -1,5 +1,6 @@ defmodule GarageWeb.ModelLive.FormComponent do use GarageWeb, :live_component + alias Garage.Mopeds.Carburetor alias Garage.Mopeds.Clutch alias Garage.Mopeds.Crank diff --git a/lib/garage_web/live/model_live/show.ex b/lib/garage_web/live/model_live/show.ex index 30b6b46..750d934 100644 --- a/lib/garage_web/live/model_live/show.ex +++ b/lib/garage_web/live/model_live/show.ex @@ -1,6 +1,8 @@ defmodule GarageWeb.ModelLive.Show do - import GarageWeb.Components.Builds.Build use GarageWeb, :live_view + + import GarageWeb.Components.Builds.Build + require Ash.Query @impl true diff --git a/lib/garage_web/live/pulley_live/form_component.ex b/lib/garage_web/live/pulley_live/form_component.ex index ac2e6ac..88a821a 100644 --- a/lib/garage_web/live/pulley_live/form_component.ex +++ b/lib/garage_web/live/pulley_live/form_component.ex @@ -1,5 +1,6 @@ defmodule GarageWeb.PulleyLive.FormComponent do use GarageWeb, :live_component + alias Garage.Mopeds.Manufacturer @impl true @@ -146,7 +147,7 @@ defmodule GarageWeb.PulleyLive.FormComponent do assign(socket, form: to_form(form)) end - def manufacturer_options() do + def manufacturer_options do for manufacturer <- Manufacturer.by_category!(:pulleys), into: [], do: {manufacturer.name, manufacturer.id} diff --git a/lib/garage_web/live/pulley_live/show.ex b/lib/garage_web/live/pulley_live/show.ex index 0094783..a824031 100644 --- a/lib/garage_web/live/pulley_live/show.ex +++ b/lib/garage_web/live/pulley_live/show.ex @@ -1,7 +1,8 @@ defmodule GarageWeb.PulleyLive.Show do - import GarageWeb.Components.Builds.Build use GarageWeb, :live_view + import GarageWeb.Components.Builds.Build + @impl true def render(assigns) do ~H""" diff --git a/lib/garage_web/live/users_live/settings.ex b/lib/garage_web/live/users_live/settings.ex index be751b9..9343962 100644 --- a/lib/garage_web/live/users_live/settings.ex +++ b/lib/garage_web/live/users_live/settings.ex @@ -1,10 +1,11 @@ defmodule GarageWeb.UsersLive.Settings do - alias Garage.Accounts.User - alias Garage.Accounts + use GarageWeb, :live_view + alias AshPhoenix.Form - require Logger + alias Garage.Accounts + alias Garage.Accounts.User - use GarageWeb, :live_view + require Logger @impl true def render(assigns) do @@ -296,7 +297,7 @@ defmodule GarageWeb.UsersLive.Settings do defp public_root, do: Application.get_env(:garage, :public_image_root) - defp max_size() do + defp max_size do Application.get_env(:garage, :max_upload_size) end end diff --git a/lib/garage_web/live/users_live/show.ex b/lib/garage_web/live/users_live/show.ex index 227f594..e293557 100644 --- a/lib/garage_web/live/users_live/show.ex +++ b/lib/garage_web/live/users_live/show.ex @@ -1,8 +1,10 @@ defmodule GarageWeb.UsersLive.Show do - alias Garage.Accounts.User use GarageWeb, :live_view + import GarageWeb.Components.Builds.Build + alias Garage.Accounts.User + def mount(%{"username" => username}, _session, socket) do case User.get_by_username(username, load: [builds: [:like_count, :follow_count]]) do {:ok, user} -> diff --git a/lib/garage_web/live/variator_live/form_component.ex b/lib/garage_web/live/variator_live/form_component.ex index b9c420c..754cc2b 100644 --- a/lib/garage_web/live/variator_live/form_component.ex +++ b/lib/garage_web/live/variator_live/form_component.ex @@ -1,5 +1,6 @@ defmodule GarageWeb.VariatorLive.FormComponent do use GarageWeb, :live_component + alias Garage.Mopeds.Manufacturer alias Garage.Mopeds.Variator @@ -158,13 +159,13 @@ defmodule GarageWeb.VariatorLive.FormComponent do assign(socket, form: to_form(form)) end - def manufacturer_options() do + def manufacturer_options do for manufacturer <- Manufacturer.by_category!(:variators), into: [], do: {manufacturer.name, manufacturer.id} end - def types() do + def types do for t <- Ash.Resource.Info.attribute(Garage.Mopeds.Variator, :type).constraints[:one_of], do: {humanize(t), t} diff --git a/lib/garage_web/live_user_auth.ex b/lib/garage_web/live_user_auth.ex index a8e6ce8..74ea31e 100644 --- a/lib/garage_web/live_user_auth.ex +++ b/lib/garage_web/live_user_auth.ex @@ -3,9 +3,10 @@ defmodule GarageWeb.LiveUserAuth do Helpers for authenticating users in liveviews """ - import Phoenix.Component use GarageWeb, :verified_routes + import Phoenix.Component + def on_mount(:live_user_optional, _params, _session, socket) do if socket.assigns[:current_user] do {:cont, socket} diff --git a/lib/garage_web/router.ex b/lib/garage_web/router.ex index f49f180..a3d5cc1 100644 --- a/lib/garage_web/router.ex +++ b/lib/garage_web/router.ex @@ -1,13 +1,13 @@ defmodule GarageWeb.Router do use GarageWeb, :router use AshAuthentication.Phoenix.Router - import AshAuthentication.Plug.Helpers - - require Logger import AshAdmin.Router + import AshAuthentication.Plug.Helpers import Oban.Web.Router + require Logger + pipeline :browser do plug :accepts, ["html"] plug :fetch_session diff --git a/lib/garage_web/telemetry.ex b/lib/garage_web/telemetry.ex index daef099..401b886 100644 --- a/lib/garage_web/telemetry.ex +++ b/lib/garage_web/telemetry.ex @@ -1,5 +1,6 @@ defmodule GarageWeb.Telemetry do use Supervisor + import Telemetry.Metrics def start_link(arg) do diff --git a/lib/mix/tasks/generate_vapid_keys.ex b/lib/mix/tasks/generate_vapid_keys.ex index 4a5f67f..ae6ac42 100644 --- a/lib/mix/tasks/generate_vapid_keys.ex +++ b/lib/mix/tasks/generate_vapid_keys.ex @@ -1,8 +1,8 @@ defmodule Mix.Tasks.Generate.Vapid.Keys do + @shortdoc "Generate vapid keys" @moduledoc "The mix task: `mix help generate.vapid.keys`" use Mix.Task - @shortdoc "Generate vapid keys" def run(_args) do {public_key, private_key} = :crypto.generate_key(:ecdh, :prime256v1) diff --git a/mix.exs b/mix.exs index e1235a2..e89afab 100644 --- a/mix.exs +++ b/mix.exs @@ -78,7 +78,8 @@ defmodule Garage.MixProject do {:sentry, "~> 10.0"}, {:image, "~> 0.55"}, {:oban, "~> 2.0"}, - {:oban_web, "~> 2.0"} + {:oban_web, "~> 2.0"}, + {:quokka, "~> 2.9", only: [:dev, :test], runtime: false} # {:crawly, "~> 0.16.0"}, ] end diff --git a/mix.lock b/mix.lock index dc51e1d..084dcfe 100644 --- a/mix.lock +++ b/mix.lock @@ -9,6 +9,7 @@ "assent": {:hex, :assent, "0.2.13", "11226365d2d8661d23e9a2cf94d3255e81054ff9d88ac877f28bfdf38fa4ef31", [:mix], [{:certifi, ">= 0.0.0", [hex: :certifi, repo: "hexpm", optional: true]}, {:finch, "~> 0.15", [hex: :finch, 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", "bf9f351b01dd6bceea1d1f157f05438f6765ce606e6eb8d29296003d29bf6eab"}, "bandit": {:hex, :bandit, "1.7.0", "d1564f30553c97d3e25f9623144bb8df11f3787a26733f00b21699a128105c0c", [:mix], [{:hpax, "~> 1.0", [hex: :hpax, repo: "hexpm", optional: false]}, {:plug, "~> 1.18", [hex: :plug, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:thousand_island, "~> 1.0", [hex: :thousand_island, repo: "hexpm", optional: false]}, {:websock, "~> 0.5", [hex: :websock, repo: "hexpm", optional: false]}], "hexpm", "3e2f7a98c7a11f48d9d8c037f7177cd39778e74d55c7af06fe6227c742a8168a"}, "bcrypt_elixir": {:hex, :bcrypt_elixir, "3.3.2", "d50091e3c9492d73e17fc1e1619a9b09d6a5ef99160eb4d736926fd475a16ca3", [:make, :mix], [{:comeonin, "~> 5.3", [hex: :comeonin, repo: "hexpm", optional: false]}, {:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "471be5151874ae7931911057d1467d908955f93554f7a6cd1b7d804cac8cef53"}, + "bunt": {:hex, :bunt, "1.0.0", "081c2c665f086849e6d57900292b3a161727ab40431219529f13c4ddcf3e7a44", [:mix], [], "hexpm", "dc5f86aa08a5f6fa6b8096f0735c4e76d54ae5c9fa2c143e5a1fc7c1cd9bb6b5"}, "castle": {:hex, :castle, "0.3.0", "47b1a550b2348a6d7e60e43ded1df19dca601ed21ef6f267c3dbb1b3a301fbf5", [:mix], [{:forecastle, "~> 0.1.0", [hex: :forecastle, repo: "hexpm", optional: false]}], "hexpm", "dbdc1c171520c4591101938a3d342dec70d36b7f5b102a5c138098581e35fcef"}, "castore": {:hex, :castore, "1.0.14", "4582dd7d630b48cf5e1ca8d3d42494db51e406b7ba704e81fbd401866366896a", [:mix], [], "hexpm", "7bc1b65249d31701393edaaac18ec8398d8974d52c647b7904d01b964137b9f4"}, "cc_precompiler": {:hex, :cc_precompiler, "0.1.10", "47c9c08d8869cf09b41da36538f62bc1abd3e19e41701c2cea2675b53c704258", [:mix], [{:elixir_make, "~> 0.7", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "f6e046254e53cd6b41c6bacd70ae728011aa82b2742a80d6e2214855c6e06b22"}, @@ -21,6 +22,7 @@ "cowboy_telemetry": {:hex, :cowboy_telemetry, "0.4.0", "f239f68b588efa7707abce16a84d0d2acf3a0f50571f8bb7f56a15865aae820c", [:rebar3], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "7d98bac1ee4565d31b62d59f8823dfd8356a169e7fcbb83831b8a5397404c9de"}, "cowlib": {:hex, :cowlib, "2.15.0", "3c97a318a933962d1c12b96ab7c1d728267d2c523c25a5b57b0f93392b6e9e25", [:make, :rebar3], [], "hexpm", "4f00c879a64b4fe7c8fcb42a4281925e9ffdb928820b03c3ad325a617e857532"}, "crawly": {:hex, :crawly, "0.16.0", "01e33d7c6d9775f7808b18e5e8c627038288d4aa675c9e89cb8c8438354e8994", [:mix], [{:elixir_uuid, "~> 1.2", [hex: :elixir_uuid, repo: "hexpm", optional: false]}, {:ex_json_schema, "~> 0.9.2", [hex: :ex_json_schema, repo: "hexpm", optional: false]}, {:gollum, "~> 0.4.0", [hex: :new_gollum, repo: "hexpm", optional: false]}, {:httpoison, "~> 1.7", [hex: :httpoison, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.0", [hex: :plug_cowboy, repo: "hexpm", optional: false]}, {:poison, "~> 3.1", [hex: :poison, repo: "hexpm", optional: false]}, {:yaml_elixir, "~> 2.9", [hex: :yaml_elixir, repo: "hexpm", optional: false]}], "hexpm", "88ae4a2ad413d9a16671bc262a78c8f2fbd1adbb9298571571fcef819e6a384d"}, + "credo": {:hex, :credo, "1.7.12", "9e3c20463de4b5f3f23721527fcaf16722ec815e70ff6c60b86412c695d426c1", [:mix], [{:bunt, "~> 0.2.1 or ~> 1.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "8493d45c656c5427d9c729235b99d498bd133421f3e0a683e5c1b561471291e5"}, "curve25519": {:hex, :curve25519, "1.0.5", "f801179424e4012049fcfcfcda74ac04f65d0ffceeb80e7ef1d3352deb09f5bb", [:mix], [], "hexpm", "0fba3ad55bf1154d4d5fc3ae5fb91b912b77b13f0def6ccb3a5d58168ff4192d"}, "db_connection": {:hex, :db_connection, "2.8.0", "64fd82cfa6d8e25ec6660cea73e92a4cbc6a18b31343910427b702838c4b33b2", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "008399dae5eee1bf5caa6e86d204dcb44242c82b1ed5e22c881f2c34da201b15"}, "decimal": {:hex, :decimal, "2.3.0", "3ad6255aa77b4a3c4f818171b12d237500e63525c2fd056699967a3e7ea20f62", [:mix], [], "hexpm", "a4d66355cb29cb47c3cf30e71329e58361cfcb37c34235ef3bf1d7bf3773aeac"}, @@ -98,6 +100,7 @@ "poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [:mix], [], "hexpm", "fec8660eb7733ee4117b85f55799fd3833eb769a6df71ccf8903e8dc5447cfce"}, "poly1305": {:hex, :poly1305, "1.0.4", "7cdc8961a0a6e00a764835918cdb8ade868044026df8ef5d718708ea6cc06611", [:mix], [{:chacha20, "~> 1.0", [hex: :chacha20, repo: "hexpm", optional: false]}, {:equivalex, "~> 1.0", [hex: :equivalex, repo: "hexpm", optional: false]}], "hexpm", "e14e684661a5195e149b3139db4a1693579d4659d65bba115a307529c47dbc3b"}, "postgrex": {:hex, :postgrex, "0.20.0", "363ed03ab4757f6bc47942eff7720640795eb557e1935951c1626f0d303a3aed", [: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", "d36ef8b36f323d29505314f704e21a1a038e2dc387c6409ee0cd24144e187c0f"}, + "quokka": {:hex, :quokka, "2.9.1", "c0c864f4452b3da901c605b18181226692cda312b049b6dbf8dcd56233bdae44", [:mix], [{:credo, "~> 1.7", [hex: :credo, repo: "hexpm", optional: false]}], "hexpm", "85befd4adc75c832d18dcdd9c7de4fdb9f3eff6d8ec1ea32c03fc9c3b7ec6ed7"}, "ranch": {:hex, :ranch, "1.8.0", "8c7a100a139fd57f17327b6413e4167ac559fbc04ca7448e9be9057311597a1d", [:make, :rebar3], [], "hexpm", "49fbcfd3682fab1f5d109351b61257676da1a2fdbe295904176d5e521a2ddfe5"}, "reactor": {:hex, :reactor, "0.15.5", "341d9ee664d6141df6639f227692ee6adc8a493d04232dee79e8a4a88e6cef8a", [:mix], [{:igniter, "~> 0.4", [hex: :igniter, repo: "hexpm", optional: true]}, {:iterex, "~> 0.1", [hex: :iterex, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, 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]}, {:yaml_elixir, "~> 2.11", [hex: :yaml_elixir, repo: "hexpm", optional: false]}, {:ymlr, "~> 5.0", [hex: :ymlr, repo: "hexpm", optional: false]}], "hexpm", "f9f440ecbdb0c41a832902a692608bd24be621fa7a602819d0dd12971d69f9aa"}, "recase": {:hex, :recase, "0.8.1", "ab98cd35857a86fa5ca99036f575241d71d77d9c2ab0c39aacf1c9b61f6f7d1d", [:mix], [], "hexpm", "9fd8d63e7e43bd9ea385b12364e305778b2bbd92537e95c4b2e26fc507d5e4c2"}, diff --git a/priv/repo/local_seeds.exs b/priv/repo/local_seeds.exs index 077e31e..e30b04e 100644 --- a/priv/repo/local_seeds.exs +++ b/priv/repo/local_seeds.exs @@ -1,10 +1,10 @@ -:erlang.system_flag(:backtrace_depth, 100) alias AshAuthentication.Info alias AshAuthentication.Strategy +alias Garage.Mopeds.Engine alias Garage.Mopeds.Manufacturer alias Garage.Mopeds.Model -alias Garage.Mopeds.Engine +:erlang.system_flag(:backtrace_depth, 100) strategy = Info.strategy!(Garage.Accounts.User, :password) {:ok, _admin} = diff --git a/test/support/conn_case.ex b/test/support/conn_case.ex index a1a15a3..be9df4f 100644 --- a/test/support/conn_case.ex +++ b/test/support/conn_case.ex @@ -19,15 +19,14 @@ defmodule GarageWeb.ConnCase do using do quote do + use GarageWeb, :verified_routes + import GarageWeb.ConnCase + import Phoenix.ConnTest + import Plug.Conn # The default endpoint for testing @endpoint GarageWeb.Endpoint - use GarageWeb, :verified_routes - # Import conveniences for testing with connections - import Plug.Conn - import Phoenix.ConnTest - import GarageWeb.ConnCase end end diff --git a/test/support/data_case.ex b/test/support/data_case.ex index 367d22a..2d4e240 100644 --- a/test/support/data_case.ex +++ b/test/support/data_case.ex @@ -18,12 +18,12 @@ defmodule Garage.DataCase do using do quote do - alias Garage.Repo - import Ecto import Ecto.Changeset import Ecto.Query import Garage.DataCase + + alias Garage.Repo end end