Skip to content

Commit

Permalink
⬆️ Upgrade dependencies
Browse files Browse the repository at this point in the history
Upgrades all dependencies except for dialyxir, which [introduces a bug](jeremyjh/dialyxir#544) that affects us.

- Fix one test for breaking PhoenixTest change.
- Use new `Money.negate!` instead of our `MoneyUtils` variant.
- Re-format with new Styler version.
- Update usage of Gettext to match latest version
- Remove mix test.interactive config since that can now be done from the command line according to  developer preference.
  • Loading branch information
randycoulman committed Sep 28, 2024
1 parent 52a4722 commit ac1db97
Show file tree
Hide file tree
Showing 21 changed files with 64 additions and 81 deletions.
3 changes: 0 additions & 3 deletions config/dev.exs
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ config :logger, :console,
level: :info,
metadata: :all

config :mix_test_interactive,
clear: true

# Set a higher stacktrace during development. Avoid configuring such
# in production as building large stacktraces may be expensive.
config :phoenix, :plug_init_mode, :runtime
Expand Down
3 changes: 0 additions & 3 deletions lib/freedom_account/money_utils.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ defmodule FreedomAccount.MoneyUtils do
@moduledoc false
use Boundary

@spec negate(Money.t()) :: Money.t()
def negate(%Money{} = money), do: Money.mult!(money, -1)

@spec sum([Money.t()]) :: Money.t()
def sum(monies) do
Enum.reduce(monies, Money.zero(:usd), &Money.add!/2)
Expand Down
7 changes: 3 additions & 4 deletions lib/freedom_account/transactions/line_item.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ defmodule FreedomAccount.Transactions.LineItem do
alias Ecto.Queryable
alias Ecto.Schema
alias FreedomAccount.Funds.Fund
alias FreedomAccount.MoneyUtils
alias FreedomAccount.Transactions.Transaction

@type attrs :: %{
Expand Down Expand Up @@ -43,8 +42,8 @@ defmodule FreedomAccount.Transactions.LineItem do
difference = Money.add!(fund.current_balance, amount)

if Money.negative?(difference) do
updated_changeset = put_change(changeset, :amount, MoneyUtils.negate(fund.current_balance))
{updated_changeset, MoneyUtils.negate(difference)}
updated_changeset = put_change(changeset, :amount, Money.negate!(fund.current_balance))
{updated_changeset, Money.negate!(difference)}
else
{changeset, Money.zero(:usd)}
end
Expand All @@ -59,7 +58,7 @@ defmodule FreedomAccount.Transactions.LineItem do
def withdrawal_changeset(line_item, attrs) do
line_item
|> base_changeset(attrs)
|> update_change(:amount, &MoneyUtils.negate/1)
|> update_change(:amount, &Money.negate!/1)
|> ignore_if_amount_missing()
end

Expand Down
3 changes: 1 addition & 2 deletions lib/freedom_account/transactions/loan_transaction.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ defmodule FreedomAccount.Transactions.LoanTransaction do
alias Ecto.Schema
alias FreedomAccount.Accounts.Account
alias FreedomAccount.Loans.Loan
alias FreedomAccount.MoneyUtils
alias Money.Ecto.Composite.Type, as: MoneyEctoType

@type attrs :: %{
Expand Down Expand Up @@ -86,7 +85,7 @@ defmodule FreedomAccount.Transactions.LoanTransaction do
def loan_changeset(transaction, attrs) do
transaction
|> changeset(attrs)
|> update_change(:amount, &MoneyUtils.negate/1)
|> update_change(:amount, &Money.negate!/1)
end

@spec newest_first(Queryable.t()) :: Queryable.t()
Expand Down
6 changes: 4 additions & 2 deletions lib/freedom_account_web.ex
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ defmodule FreedomAccountWeb do
formats: [:html, :json],
layouts: [html: FreedomAccountWeb.Layouts]

import FreedomAccountWeb.Gettext
use Gettext, backend: FreedomAccountWeb.Gettext

import Plug.Conn

unquote(verified_routes())
Expand Down Expand Up @@ -94,8 +95,9 @@ defmodule FreedomAccountWeb do
quote do
# HTML escaping functionality
# Core UI components and translation
use Gettext, backend: FreedomAccountWeb.Gettext

import FreedomAccountWeb.CoreComponents
import FreedomAccountWeb.Gettext
import Phoenix.HTML

# Shortcut for generating JS commands
Expand Down
3 changes: 1 addition & 2 deletions lib/freedom_account_web/components/core_components.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ defmodule FreedomAccountWeb.CoreComponents do
Icons are provided by [heroicons](https://heroicons.com). See `icon/1` for usage.
"""
use Phoenix.Component

import FreedomAccountWeb.Gettext
use Gettext, backend: FreedomAccountWeb.Gettext

alias Phoenix.HTML.Form
alias Phoenix.HTML.FormField
Expand Down
3 changes: 1 addition & 2 deletions lib/freedom_account_web/components/fund_transaction/index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ defmodule FreedomAccountWeb.FundTransaction.Index do
import FreedomAccountWeb.CoreComponents

alias FreedomAccount.Funds.Fund
alias FreedomAccount.MoneyUtils
alias FreedomAccount.Paging
alias FreedomAccount.Transactions
alias Phoenix.LiveComponent
Expand Down Expand Up @@ -48,7 +47,7 @@ defmodule FreedomAccountWeb.FundTransaction.Index do
<:col :let={transaction} label="Memo"><%= transaction.memo %></:col>
<:col :let={transaction} align={:right} label="Out">
<span :if={Money.negative?(transaction.amount)} data-role="withdrawal">
<%= MoneyUtils.negate(transaction.amount) %>
<%= Money.negate!(transaction.amount) %>
</span>
</:col>
<:col :let={transaction} align={:right} label="In">
Expand Down
3 changes: 1 addition & 2 deletions lib/freedom_account_web/components/loan_transaction/index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ defmodule FreedomAccountWeb.LoanTransaction.Index do
import FreedomAccountWeb.CoreComponents

alias FreedomAccount.Loans.Loan
alias FreedomAccount.MoneyUtils
alias FreedomAccount.Paging
alias FreedomAccount.Transactions
alias Phoenix.LiveComponent
Expand Down Expand Up @@ -48,7 +47,7 @@ defmodule FreedomAccountWeb.LoanTransaction.Index do
<:col :let={transaction} label="Memo"><%= transaction.memo %></:col>
<:col :let={transaction} align={:right} label="Out">
<span :if={Money.negative?(transaction.amount)} data-role="loan">
<%= MoneyUtils.negate(transaction.amount) %>
<%= Money.negate!(transaction.amount) %>
</span>
</:col>
<:col :let={transaction} align={:right} label="In">
Expand Down
2 changes: 1 addition & 1 deletion lib/freedom_account_web/gettext.ex
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ defmodule FreedomAccountWeb.Gettext do
See the [Gettext Docs](https://hexdocs.pm/gettext) for detailed usage.
"""
use Gettext, otp_app: :freedom_account
use Gettext.Backend, otp_app: :freedom_account
end
3 changes: 1 addition & 2 deletions lib/freedom_account_web/live/transaction_live/index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ defmodule FreedomAccountWeb.TransactionLive.Index do
import FreedomAccountWeb.TransactionForm, only: [transaction_form: 1]

alias FreedomAccount.Error.NotFoundError
alias FreedomAccount.MoneyUtils
alias FreedomAccount.Paging
alias FreedomAccount.Transactions
alias FreedomAccount.Transactions.AccountTransaction
Expand Down Expand Up @@ -96,7 +95,7 @@ defmodule FreedomAccountWeb.TransactionLive.Index do
<:col :let={transaction} label="Fund/Loan"><%= transaction %></:col>
<:col :let={transaction} align={:right} label="Out">
<span :if={Money.negative?(transaction.amount)} data-role="out">
<%= MoneyUtils.negate(transaction.amount) %>
<%= Money.negate!(transaction.amount) %>
</span>
</:col>
<:col :let={transaction} align={:right} label="In">
Expand Down
6 changes: 2 additions & 4 deletions lib/mix/tasks/import.ex
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ defmodule Mix.Tasks.Import do
|> Path.join("categoryTransactions.csv")
|> File.stream!()
|> CSV.parse_stream()
|> Stream.each(fn [fund_name, date, memo, amount] ->
|> Enum.each(fn [fund_name, date, memo, amount] ->
date = Date.from_iso8601!(date)
%Money{} = amount = Money.parse(amount)
{:ok, fund} = find_fund(funds, fund_name)
Expand Down Expand Up @@ -165,7 +165,6 @@ defmodule Mix.Tasks.Import do
})
end
end)
|> Stream.run()
end

defp update_default_fund(%Account{} = account, _funds, nil, _opts) do
Expand Down Expand Up @@ -240,7 +239,7 @@ defmodule Mix.Tasks.Import do
|> Path.join("loanTransactions.csv")
|> File.stream!()
|> CSV.parse_stream()
|> Stream.each(fn [loan_name, date, memo, amount] ->
|> Enum.each(fn [loan_name, date, memo, amount] ->
date = Date.from_iso8601!(date)
%Money{} = amount = Money.parse(amount)
{:ok, loan} = find_loan(loans, loan_name)
Expand All @@ -262,7 +261,6 @@ defmodule Mix.Tasks.Import do
})
end
end)
|> Stream.run()
end

defp find_fund(funds, name) do
Expand Down
12 changes: 6 additions & 6 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -74,38 +74,38 @@ defmodule FreedomAccount.MixProject do
[
{:assertions, "~> 0.20.0", only: [:test]},
{:bandit, "~> 1.5"},
{:boundary, "~> 0.10.3"},
{:boundary, "~> 0.10.4"},
{:credo, "~> 1.7", only: [:dev, :test], runtime: false},
{:dialyxir, "~> 1.4", only: [:dev, :test], runtime: false},
{:dns_cluster, "~> 0.1.1"},
{:ecto_sql, "~> 3.12"},
{:esbuild, "~> 0.8.1", runtime: Mix.env() == :dev},
{:ex_machina, "~> 2.8", only: :test},
{:ex_money, "~> 5.17", runtime: false},
{:ex_money, "~> 5.18", runtime: false},
{:ex_money_sql, "~> 1.1"},
{:faker, "~> 0.18.0", only: :test},
{:floki, ">= 0.35.3", only: :test},
{:gettext, "~> 0.25.0"},
{:gettext, "~> 0.26.1"},
# {:heroicons,
# github: "tailwindlabs/heroicons", tag: "v2.1.5", sparse: "optimized", app: false, compile: false, depth: 1},
{:heroicons,
github: "tailwindlabs/heroicons", branch: "master", sparse: "optimized", app: false, compile: false, depth: 1},
{:jason, "~> 1.2"},
{:mix_test_interactive, "~> 3.0", only: :dev, runtime: false},
{:mix_test_interactive, "~> 4.0", only: :dev, runtime: false},
{:nimble_csv, "~> 1.2"},
{:paginator, "~> 1.2"},
{:phoenix_ecto, "~> 4.5"},
{:phoenix_html, "~> 4.1"},
{:phoenix_live_dashboard, "~> 0.8.4"},
{:phoenix_live_reload, "~> 1.5", only: :dev},
{:phoenix_live_view, "~> 1.0.0-rc.1", override: true},
{:phoenix_test, "~> 0.3.1", only: :test, runtime: false},
{:phoenix_test, "~> 0.4.0", only: :test, runtime: false},
{:phoenix, "~> 1.7"},
# This is here to resolve a conflict with paginator's dependencies
{:plug_crypto, "~> 2.1", override: true},
{:postgrex, ">= 0.0.0"},
{:process_tree, "~> 0.1.3"},
{:styler, "~> 1.0", only: [:dev, :test], runtime: false},
{:styler, "~> 1.1", only: [:dev, :test], runtime: false},
{:tailwind, "~> 0.2.3", runtime: Mix.env() == :dev},
{:telemetry_metrics, "~> 1.0"},
{:telemetry_poller, "~> 1.1"},
Expand Down
Loading

0 comments on commit ac1db97

Please sign in to comment.