Created
February 15, 2025 14:16
-
-
Save dch/52bda729b347e17b99931de311845e55 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Indie.MixProject do | |
use Mix.Project | |
def project do | |
[version, description] = version() | |
[ | |
app: :indie, | |
version: version, | |
id: description, | |
description: "Indie " <> description, | |
elixir: "~> 1.15", | |
elixirc_paths: elixirc_paths(Mix.env()), | |
compilers: Mix.compilers(), | |
start_permanent: Mix.env() == :prod, | |
# http://erlang.org/doc/man/dialyzer.html | |
dialyzer: [ | |
flags: ["-Wunmatched_returns", :error_handling], | |
list_unused_filters: true, | |
ignore_warnings: ".dialyzer_ignore.exs", | |
plt_local_path: System.user_home!() <> "/.mix/plts/indie" | |
], | |
aliases: aliases(), | |
deps: deps(), | |
test_coverage: [tool: ExCoveralls], | |
preferred_cli_env: [ | |
quality: :test, | |
wallaby: :test, | |
coveralls: :test, | |
"coveralls.detail": :test, | |
"coveralls.post": :test, | |
"coveralls.html": :test | |
], | |
default_release: :indie, | |
releases: releases() | |
] | |
end | |
# Configuration for the OTP application. | |
# | |
# Type `mix help compile.app` for more information. | |
def application do | |
[ | |
mod: {Indie.Application, []}, | |
extra_applications: [:logger, :runtime_tools] | |
] | |
end | |
# Specifies which paths to compile per environment. | |
defp elixirc_paths(:test), do: ["lib", "test/support"] | |
defp elixirc_paths(_), do: ["lib"] | |
# Specifies your project dependencies. | |
# | |
# Type `mix help deps` for examples and options. | |
# Type `mix deps.update --all` to update deps (won't updated this file) | |
# Type `mix hex.outdated` to see deps that can be updated | |
defp deps do | |
[ | |
# APIs | |
{:ascio, git: "https://git.sr.ht/~dch/ascio", tag: "0.2.0"}, | |
# Phoenix base | |
{:phoenix, "~> 1.7.0"}, | |
{:phoenix_ecto, "~> 4.4"}, | |
{:ecto_sql, "~> 3.9"}, | |
{:postgrex, ">= 0.0.0"}, | |
{:phoenix_html, "~> 3.0"}, | |
{:phoenix_live_reload, "~> 1.2", only: :dev}, | |
{:phoenix_live_view, "~> 0.18"}, | |
{:floki, ">= 0.30.0"}, | |
{:phoenix_live_dashboard, "~> 0.7"}, | |
{:esbuild, "~> 0.2", runtime: Mix.env() == :dev}, | |
{:swoosh, "~> 1.8"}, | |
{:telemetry_metrics, "~> 0.6"}, | |
{:telemetry_poller, "~> 1.0"}, | |
{:gettext, "~> 0.20"}, | |
{:jason, "~> 1.4"}, | |
{:bandit, "~> 1.1"}, | |
{:cachex, "~> 3.6"}, | |
# hackney breaks all the things in swoosh | |
{:hackney, "~> 1.19", override: true}, | |
# certifi 2.12.0 | |
# ssl_verify_fun 1.1.7 | |
# {:certifi, "~> 2.4"}, | |
# {:ssl_verify_fun, "~> 1.1"}, | |
# Emails | |
{:phoenix_swoosh, "~> 1.0"}, | |
{:gen_smtp, "~> 1.2", override: true}, | |
{:premailex, "~> 0.3.0"}, | |
# Ecto querying / pagination | |
{:query_builder, "~> 1.0"}, | |
{:flop, "~> 0.17"}, | |
{:elixir_uuid, "~> 1.6", hex: :uuid_utils}, | |
# Authentication | |
{:bcrypt_elixir, "~> 3.0"}, | |
{:ueberauth, "~> 0.10", override: true}, | |
{:ueberauth_google, "~> 0.10"}, | |
{:ueberauth_github, "~> 0.7"}, | |
# TOTP (2FA) | |
{:nimble_totp, "~> 1.0"}, | |
{:eqrcode, "~> 0.1.10"}, | |
# Logging | |
{:logger_syslog_backend, "~> 1.0"}, | |
# Hashing | |
{:hashids, "~> 2.0"}, | |
# Assets | |
{:tailwind, "~> 0.2.0", runtime: Mix.env() == :dev}, | |
# Components | |
{:petal_components, "~> 0.18"}, | |
# Utils | |
{:email_checker, "~> 0.2.4"}, | |
{:blankable, "~> 1.0.0"}, | |
{:currency_formatter, "~> 0.4"}, | |
{:timex, "~> 3.7"}, | |
{:inflex, "~> 2.1.0"}, | |
{:slugify, "~> 1.3"}, | |
{:ex_cldr, "~> 2.34"}, | |
{:ex_cldr_plugs, "~> 1.2"}, | |
{:ex_cldr_currencies, "~> 2.6"}, | |
{:ex_cldr_numbers, "~> 2.29"}, | |
{:ex_cldr_territories, "~> 2.6"}, | |
{:flagpack, "~> 0.1"}, | |
# HTTP client | |
{:tesla, "~> 1.5"}, | |
# Testing | |
{:wallaby, "~> 0.30", runtime: false, only: :test}, | |
{:faker, git: "https://github.com/elixirs/faker"}, | |
# Jobs / Cron | |
{:oban, "~> 2.13"}, | |
# Markdown | |
{:earmark, "~> 1.4"}, | |
{:html_sanitize_ex, "~> 1.4"}, | |
# Security | |
{:content_security_policy, "~> 1.0"}, | |
# Code quality | |
{:dialyxir, "~> 1.3", only: :dev, runtime: false}, | |
{:sobelow, "~> 0.8", only: [:dev, :test], runtime: false}, | |
{:credo, "~> 1.6", only: [:dev, :test], runtime: false}, | |
{:excoveralls, "~> 0.10", only: [:dev, :test], runtime: false}, | |
{:mix_test_watch, "~> 1.0", only: [:dev, :test], runtime: false}, | |
# Code Coverage generator | |
{:lcov_ex, "~> 0.3", only: [:dev, :test], runtime: false}, | |
# Stubbing tool to avoid retesting Ascio whenever used | |
{:mimic, "~> 1.7", only: :test}, | |
# To check EU Views | |
{:httpoison, "~> 2.2.1", override: true}, | |
{:ex_vatcheck, "~> 0.3.1"}, | |
# Mockup API calls | |
{:exvcr, "~> 0.14", only: :test}, | |
# Currency conversion, NOTE: Still figuring whether this is the final one | |
{:ex_money, "~> 5.0"} | |
] | |
end | |
# Aliases are shortcuts or tasks specific to the current project. | |
# For example, to install project dependencies and perform other setup tasks, run: | |
# | |
# $ mix setup | |
# | |
# See the documentation for `Mix` for more info on aliases. | |
defp aliases do | |
[ | |
dist: [ | |
"deps.get --only prod", | |
"tailwind.install --if-missing #{tailwind_url()}", | |
"esbuild.install --if-missing" | |
], | |
setup: ["deps.get", "ecto.setup", "tailwind.install --if-missing", "esbuild.install"], | |
"ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"], | |
"ecto.reset": ["ecto.drop", "ecto.setup"], | |
test: ["ecto.create --quiet", "ecto.migrate --quiet", "test"], | |
"assets.deploy": [ | |
"esbuild default --minify", | |
"tailwind default --minify", | |
"phx.digest" | |
], | |
# Run to check the quality of your code | |
quality: [ | |
"format --check-formatted", | |
"sobelow --config", | |
"coveralls", | |
"credo" | |
], | |
update_translations: ["gettext.extract --merge"], | |
# Unlocks unused dependencies (no longer mentioned in the mix.exs file) | |
clean_mix_lock: ["deps.unlock --unused"], | |
# Only run wallaby (e2e) tests | |
wallaby: ["test --only feature"] | |
] | |
end | |
defp tailwind_url do | |
case :os.type() do | |
{:unix, :freebsd} -> | |
"https://people.freebsd.org/~dch/pub/tailwind/v3.3.2/tailwindcss-freebsd-x64" | |
_ -> | |
"" | |
end | |
end | |
defp releases do | |
[version, _] = version() | |
[ | |
indie: [ | |
version: version, | |
include_executables_for: [:unix], | |
include_erts: true, | |
strip_beams: false, | |
applications: [runtime_tools: :permanent] | |
] | |
] | |
end | |
defp version do | |
case File.dir?(".git") do | |
false -> from_hex() | |
true -> from_git() | |
end | |
end | |
defp from_hex do | |
# when in github CI, there is no tag, and no .version | |
case File.read!(".version") do | |
{:ok, resp} -> resp | |
_ -> "0.0.0: 0.0.0-alpha" | |
end | |
|> String.split(":") | |
end | |
defp from_git do | |
# pulls version information from "nearest" git tag or sha hash-ish | |
{hashish, 0} = | |
System.cmd("git", ~w[describe --dirty --abbrev=7 --tags --always --first-parent]) | |
description = String.trim(hashish) | |
version = | |
hashish | |
|> String.split("-") | |
|> List.first() | |
|> String.replace_prefix("v", "") | |
|> String.trim() | |
version = | |
case Version.parse(version) do | |
:error -> "0.0.0-#{version}" | |
_ -> version | |
end | |
# stash the tag so that it's rolled into the next commit and therefore | |
# available in hex packages when git tag info may not be present | |
File.write!(".version", "#{version}: #{description}") | |
[version, description] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment