bonfire-app/mix.exs

564 lines
16 KiB
Elixir
Raw Normal View History

2020-09-09 15:18:39 +00:00
Code.eval_file("mess.exs")
2022-09-12 04:34:14 +00:00
2020-11-07 14:05:06 +00:00
defmodule Bonfire.MixProject do
2020-08-05 07:39:59 +00:00
use Mix.Project
2022-09-12 04:34:14 +00:00
# TODO: put these in ENV or an external writeable config file similar to deps.*
@config [
# note that the flavour will automatically be added where the dash appears
2022-10-11 06:41:16 +00:00
version: "0.3.5-beta.13",
2022-09-12 04:34:14 +00:00
elixir: "~> 1.13",
default_flavour: "classic",
logo: "assets/static/images/bonfire-icon.png",
docs: [
"README.md",
"docs/HACKING.md",
"docs/DEPLOY.md",
"docs/ARCHITECTURE.md",
"docs/BONFIRE-FLAVOURED-ELIXIR.md",
"docs/DATABASE.md",
"docs/BOUNDARIES.md",
"docs/GRAPHQL.md",
"docs/MRF.md",
"docs/CHANGELOG.md",
"docs/CHANGELOG-autogenerated.md"
],
deps_prefixes: [
2021-12-16 22:56:46 +00:00
docs: [
2022-09-12 04:34:14 +00:00
"bonfire",
"pointers",
"paginator",
"ecto_shorts",
"ecto_sparkles",
"absinthe_client",
"activity_pub",
"arrows",
"ecto_materialized_path",
"flexto",
"grumble",
"linkify",
"verbs",
"voodoo",
"waffle",
"zest"
2021-12-16 22:56:46 +00:00
],
2022-09-12 04:34:14 +00:00
test: [
"bonfire",
"pointers",
"paginator",
"ecto_shorts",
"ecto_sparkles",
"activity_pub",
2022-09-12 05:12:35 +00:00
"arrows",
2022-09-12 04:34:14 +00:00
"linkify",
"fetch_favicon"
],
data: [
"bonfire_data_",
"bonfire_data_edges",
"pointers",
"bonfire_boundaries",
"bonfire_tag",
"bonfire_classify",
"bonfire_geolocate",
"bonfire_quantify",
"bonfire_valueflows"
],
api: [
"bonfire_me",
"bonfire_social",
"bonfire_tag",
"bonfire_classify",
"bonfire_geolocate",
"bonfire_valueflows"
],
required: [
"bonfire_boundaries",
"bonfire_social",
"bonfire_me",
"bonfire_ecto",
"bonfire_epics",
"bonfire_common"
],
2022-09-12 04:34:14 +00:00
localise: ["bonfire"],
localise_self: []
2021-05-16 08:34:50 +00:00
]
2022-09-12 04:34:14 +00:00
]
2021-05-16 08:34:50 +00:00
2020-08-05 07:39:59 +00:00
def project do
[
2020-11-07 14:05:06 +00:00
app: :bonfire,
2021-05-16 08:34:50 +00:00
version: version(),
elixir: @config[:elixir],
2022-04-07 05:23:18 +00:00
elixirc_options: [debug_info: true, docs: true],
2022-09-08 02:50:23 +00:00
elixirc_paths: elixirc_paths(Mix.env()),
2021-05-05 13:29:10 +00:00
test_paths: test_paths(),
2022-09-08 02:50:23 +00:00
test_deps: deps(:test),
required_deps: @config[:deps_prefixes][:required],
2021-10-31 22:07:04 +00:00
compilers: compilers(Mix.env()),
2020-08-05 07:39:59 +00:00
start_permanent: Mix.env() == :prod,
aliases: aliases(),
deps: deps(),
2022-09-08 02:50:23 +00:00
multirepo_deps: deps(:bonfire),
in_multirepo_fn: &in_multirepo?/1,
multirepo_recompile_fn: &deps_recompile/0,
config_path: config_path("config.exs"),
releases: [
2022-04-07 06:20:32 +00:00
bonfire: [
runtime_config_path: config_path("runtime.exs"),
2022-09-12 04:34:14 +00:00
# to enable debugging
strip_beams: false
]
2021-11-19 00:48:15 +00:00
],
2022-03-06 00:32:13 +00:00
source_url: "https://github.com/bonfire-networks/bonfire-app",
homepage_url: "https://bonfirenetworks.org",
2021-11-19 00:48:15 +00:00
docs: [
# The first page to display from the docs
main: "readme",
2021-12-16 22:56:46 +00:00
logo: @config[:logo],
2021-11-19 00:48:15 +00:00
output: "docs/exdoc",
2022-03-06 01:55:05 +00:00
source_url_pattern: &source_url_pattern/2,
2021-12-16 22:56:46 +00:00
# extra pages to include
extras: readme_paths(),
2022-03-06 00:32:13 +00:00
# extra apps to include in module docs
2022-09-08 02:50:23 +00:00
source_beam: beam_paths(:docs),
2022-03-06 00:32:13 +00:00
deps: doc_deps(),
2022-09-12 04:34:14 +00:00
# Note: first match wins
groups_for_extras: [
Guides: Path.wildcard("docs/*"),
2022-03-06 00:32:13 +00:00
"Flavours of Bonfire": Path.wildcard("flavours/*/*"),
"Data schemas": Path.wildcard("{deps,forks}/bonfire_data_*/*"),
"UI extensions": Path.wildcard("{deps,forks}/bonfire_ui_*/*"),
2022-09-12 04:34:14 +00:00
"Bonfire utilities":
[
"bonfire_api_graphql",
"bonfire_boundaries",
"bonfire_common",
"bonfire_ecto",
"bonfire_epics",
"bonfire_fail",
"bonfire_files",
"bonfire_mailer"
]
|> Enum.flat_map(&Path.wildcard("{deps,forks}/#{&1}/*")),
2022-03-06 00:32:13 +00:00
"Feature extensions": Path.wildcard("{deps,forks}/bonfire_*/*"),
2022-03-29 22:02:21 +00:00
"Other utilities": Path.wildcard("{deps,forks}/*/*"),
2022-09-12 04:34:14 +00:00
Dependencies: Path.wildcard("docs/DEPENDENCIES/*")
2022-03-06 00:32:13 +00:00
],
groups_for_modules: [
"Data schemas": ~r/^Bonfire.Data.?/,
"UI extensions": ~r/^Bonfire.UI.?/,
2022-09-12 04:34:14 +00:00
"Bonfire utilities": [
~r/^Bonfire.API?/,
~r/^Bonfire.GraphQL?/,
~r/^Bonfire.Web?/,
~r/^Bonfire.Boundaries?/,
~r/^Bonfire.Common?/,
~r/^Bonfire.Ecto?/,
~r/^Bonfire.Epics?/,
~r/^Bonfire.Fail?/,
~r/^Bonfire.Files?/,
~r/^Bonfire.Mailer?/
],
2022-03-06 00:32:13 +00:00
"Feature extensions": [~r/^Bonfire.?/, ~r/^ValueFlows.?/],
2022-09-12 04:34:14 +00:00
Utilities: ~r/.?/
2022-03-06 00:32:13 +00:00
],
2022-03-06 01:55:05 +00:00
nest_modules_by_prefix: [
Bonfire.Data,
# Bonfire.UI,
Bonfire,
ValueFlows
]
2022-09-12 04:34:14 +00:00
]
2020-08-05 07:39:59 +00:00
]
end
2021-05-05 13:29:10 +00:00
def application do
[
mod: {Bonfire.Application, []},
2022-09-12 04:34:14 +00:00
extra_applications: [
:logger,
:runtime_tools,
:os_mon,
:ssl,
:bamboo,
:bamboo_smtp
]
2021-05-05 13:29:10 +00:00
]
end
2020-12-26 17:01:34 +00:00
2021-05-16 08:34:50 +00:00
defp aliases do
[
"hex.setup": ["local.hex --force"],
"rebar.setup": ["local.rebar --force"],
2022-04-07 06:38:25 +00:00
"assets.build": [
2022-09-12 04:34:14 +00:00
"cmd cd ./assets && yarn build"
2021-05-16 08:34:50 +00:00
],
2021-10-10 01:02:52 +00:00
"bonfire.seeds": [
# "phil_columns.seed",
],
2022-01-09 10:19:16 +00:00
"bonfire.deps.update": ["deps.update " <> deps_to_update()],
2022-09-12 04:34:14 +00:00
"bonfire.deps.clean": [
"deps.clean " <> deps_to_clean(:localise) <> " --build"
],
"bonfire.deps.clean.data": [
"deps.clean " <> deps_to_clean(:data) <> " --build"
],
"bonfire.deps.clean.api": [
"deps.clean " <> deps_to_clean(:api) <> " --build"
],
"bonfire.deps.recompile": [
"deps.compile " <> deps_to_update() <> " --force"
],
2022-04-06 06:16:15 +00:00
"bonfire.deps": ["bonfire.deps.update", "bonfire.deps.clean.data"],
2022-03-06 00:32:13 +00:00
"ecto.seeds": [
"run #{flavour_path()}/repo/seeds.exs"
2022-09-12 04:34:14 +00:00
],
2022-03-06 00:32:13 +00:00
"js.deps.get": ["cmd make js.deps.get"],
"js.deps.update": ["cmd cd assets && yarn update"],
2022-09-12 04:34:14 +00:00
setup: [
"hex.setup",
"rebar.setup",
"deps.get",
"bonfire.deps.clean.data",
"ecto.setup"
],
2021-06-25 11:17:01 +00:00
updates: ["deps.get", "bonfire.deps"],
2021-05-16 08:34:50 +00:00
upgrade: ["updates", "ecto.migrate"],
2021-11-25 02:21:03 +00:00
"ecto.setup": ["ecto.create", "ecto.migrate"],
"ecto.migrate": ["ecto.migrate", "bonfire.seeds"],
2022-01-09 10:19:16 +00:00
"ecto.reset": ["ecto.drop --force", "ecto.setup"],
2022-09-12 04:34:14 +00:00
test: ["ecto.create --quiet", "ecto.migrate --quiet", "test"]
2021-05-16 08:34:50 +00:00
]
end
2022-05-29 21:17:27 +00:00
def deps() do
Mess.deps(mess_sources(), [
2020-12-26 17:01:34 +00:00
## password hashing - builtin vs nif
2022-06-22 06:59:10 +00:00
{:pbkdf2_elixir, "~> 2.0", only: [:dev, :test]},
{:argon2_elixir, "~> 3.0", only: [:prod]},
2022-04-15 19:56:35 +00:00
# error reporting
2022-06-08 08:47:02 +00:00
{:sentry, "~> 8.0", only: [:dev, :prod]},
2022-04-15 19:56:35 +00:00
2020-12-26 17:01:34 +00:00
## dev conveniences
2021-04-08 18:19:52 +00:00
# {:dbg, "~> 1.0", only: [:dev, :test]},
2021-09-25 03:33:45 +00:00
{:phoenix_live_reload, "~> 1.3", only: :dev},
# {:exsync, git: "https://github.com/falood/exsync", only: :dev},
2022-09-19 08:45:28 +00:00
# {:mix_unused, "~> 0.4", only: :dev},
2022-03-25 02:43:49 +00:00
{:ex_doc, "~> 0.28.3", only: [:dev, :test], runtime: false},
2022-02-19 08:03:58 +00:00
{:ecto_erd, "~> 0.4", only: :dev},
2022-08-19 20:23:18 +00:00
# {:ecto_dev_logger, "~> 0.4", only: :dev},
2022-09-12 04:34:14 +00:00
# flame graphs in live_dashboard
2022-09-24 00:33:57 +00:00
# {:flame_on, "~> 0.5", only: :dev},
2022-05-28 22:30:35 +00:00
{:pseudo_gettext, git: "https://github.com/tmbb/pseudo_gettext", only: :dev},
2022-06-22 06:59:10 +00:00
{:periscope, "~> 0.4", only: :dev},
2022-07-19 04:22:38 +00:00
# {:changelog, "~> 0.1", only: [:dev, :test], runtime: false}, # retrieve changelogs of latest dependency versions
2022-09-12 04:34:14 +00:00
# changelog generation
{:versioce, "~> 1.1.2", only: :dev},
# needed for changelog generation
{:git_cli, "~> 0.3.0", only: :dev},
2022-09-08 05:23:23 +00:00
# {:archeometer, git: "https://gitlab.com/mayel/archeometer", only: [:dev, :test]}, # "~> 0.1.0" # disabled because exqlite not working in CI
2022-09-12 04:34:14 +00:00
{:recode, "~> 0.4", only: :dev},
2022-09-15 06:40:33 +00:00
# API client needed for changelog generation
2022-09-23 06:00:21 +00:00
{:neuron, "~> 5.0", only: :dev, override: true},
2022-10-09 08:02:03 +00:00
# note: cannot use only: dev
2022-10-10 09:29:20 +00:00
# {:phoenix_profiler, "~> 0.2.0"},
2021-04-27 10:26:40 +00:00
2020-12-26 17:01:34 +00:00
# tests
{:floki, ">= 0.0.0", only: [:dev, :test]},
{:ex_machina, "~> 2.4", only: :test},
2021-09-25 03:33:45 +00:00
{:mock, "~> 0.3", only: :test},
2022-06-22 06:59:10 +00:00
{:mox, "~> 1.0", only: :test},
2022-09-08 02:50:23 +00:00
{:zest, "~> 0.1.0"},
2021-05-11 12:48:32 +00:00
{:grumble, "~> 0.1.3", only: [:test], override: true},
2022-09-29 07:35:25 +00:00
{:mix_test_watch, "~> 1.1", only: :test, runtime: false, override: true},
2022-06-22 06:59:10 +00:00
{:mix_test_interactive, "~> 1.2", only: :test, runtime: false},
2021-06-10 14:46:57 +00:00
{:ex_unit_notifier, "~> 1.0", only: :test},
2022-08-19 20:23:18 +00:00
{:wallaby, "~> 0.30", runtime: false, only: :test},
2022-07-04 05:06:44 +00:00
# {:bypass, "~> 2.1", only: :test}, # used in furlex
2021-04-27 10:26:40 +00:00
2022-03-10 07:04:27 +00:00
# Benchmarking utilities
{:benchee, "~> 1.1", only: :dev},
{:benchee_html, "~> 1.0", only: :dev},
2021-02-18 13:45:59 +00:00
# list dependencies & licenses
2022-09-12 04:34:14 +00:00
{
:licensir,
only: :dev,
runtime: false,
git: "https://github.com/bonfire-networks/licensir",
branch: "main"
2022-02-25 08:13:50 +00:00
# path: "./forks/licensir"
2021-02-21 18:52:16 +00:00
},
2021-04-30 10:58:35 +00:00
2021-02-18 13:45:59 +00:00
# security auditing
# {:mix_audit, "~> 0.1", only: [:dev], runtime: false}
{:sobelow, "~> 0.8", only: :dev}
2022-09-12 04:34:14 +00:00
])
2020-12-26 17:01:34 +00:00
end
2022-09-19 08:45:28 +00:00
# defp compilers(:dev) do
# [:unused] ++ compilers(nil)
# end
2022-09-12 04:34:14 +00:00
2021-10-31 22:07:04 +00:00
defp compilers(_) do
2022-09-06 20:59:28 +00:00
[:phoenix] ++ Mix.compilers()
2021-10-31 22:07:04 +00:00
end
2021-10-12 01:27:24 +00:00
def catalogues(_env) do
2021-07-28 10:11:11 +00:00
[
"deps/surface/priv/catalogue",
2022-09-12 04:34:14 +00:00
dep_path("bonfire_ui_social") <> "/priv/catalogue"
2021-07-28 10:11:11 +00:00
]
end
2022-05-01 23:19:01 +00:00
def deps(deps \\ deps(), deps_subtype)
2022-09-12 04:34:14 +00:00
2022-09-08 02:50:23 +00:00
def deps(deps, :bonfire) do
deps_prefixes = multirepo_prefixes()
Enum.filter(deps, &in_multirepo?(&1, deps_prefixes))
end
2022-09-12 04:34:14 +00:00
def deps(deps, deps_subtype) when is_atom(deps_subtype),
do:
Enum.filter(
deps,
&include_dep?(deps_subtype, &1, @config[:deps_prefixes][deps_subtype])
)
def multirepo_prefixes(),
do:
Enum.flat_map(@config[:deps_prefixes], fn {_, list} -> list end)
|> Enum.uniq()
def in_multirepo?(dep, deps_prefixes \\ multirepo_prefixes()),
do: include_dep?(:bonfire, dep, deps_prefixes)
2022-09-08 02:50:23 +00:00
2022-09-12 04:34:14 +00:00
def deps_recompile(deps \\ deps_for(:bonfire)),
do: Mix.Task.run("bonfire.dep.compile", ["--force"] ++ List.wrap(deps))
2020-11-28 12:49:44 +00:00
2022-09-12 04:34:14 +00:00
def flavour_path(),
do: System.get_env("FLAVOUR_PATH", "flavours/" <> flavour())
2020-09-09 15:18:39 +00:00
2022-09-12 04:34:14 +00:00
def flavour(), do: System.get_env("FLAVOUR", @config[:default_flavour])
2020-12-26 17:01:34 +00:00
2021-05-11 13:31:15 +00:00
def config_path(flavour_path \\ flavour_path(), filename),
2021-05-05 13:29:10 +00:00
do: Path.expand(Path.join([flavour_path, "config", filename]))
2021-03-23 08:35:29 +00:00
2022-03-06 00:32:13 +00:00
def forks_path(), do: System.get_env("FORKS_PATH", "forks/")
2021-05-16 08:34:50 +00:00
2021-05-05 13:29:10 +00:00
defp mess_sources() do
2022-09-12 04:34:14 +00:00
mess_sources(System.get_env("WITH_FORKS", "1"))
|> Enum.map(fn {k, v} -> {k, config_path(v)} end)
2021-05-05 13:29:10 +00:00
end
2021-03-23 08:35:29 +00:00
2022-09-12 04:34:14 +00:00
defp mess_sources("0"), do: [git: "deps.git", hex: "deps.hex"]
defp mess_sources(_),
do: [path: "deps.path", git: "deps.git", hex: "deps.hex"]
2021-05-05 13:29:10 +00:00
2022-04-06 06:12:13 +00:00
def deps_to_clean(type) do
deps(type)
2021-05-16 08:34:50 +00:00
|> deps_names()
2021-05-11 13:31:15 +00:00
end
def deps_to_update() do
2021-05-16 08:34:50 +00:00
deps(:update)
|> deps_names()
2022-09-12 04:34:14 +00:00
|> IO.inspect(
label:
"Running Bonfire #{version()} with configuration from #{flavour_path()} in #{Mix.env()} environment. You can run `mix bonfire.deps.update` to update these extensions and dependencies"
)
2021-05-11 13:31:15 +00:00
end
2021-11-19 00:48:15 +00:00
# Specifies which paths to include in docs
2022-09-08 02:50:23 +00:00
def beam_paths(type \\ :all) do
2021-11-19 00:48:15 +00:00
build = Mix.Project.build_path()
2022-09-12 04:34:14 +00:00
2022-09-08 02:50:23 +00:00
([:bonfire] ++ deps(type))
|> Enum.map(&beam_path(&1, build))
2021-11-19 00:48:15 +00:00
end
2021-12-16 22:56:46 +00:00
2022-09-12 04:34:14 +00:00
defp beam_path(app, build),
do: Path.join([build, "lib", dep_name(app), "ebin"])
2022-03-06 00:32:13 +00:00
2022-09-12 04:34:14 +00:00
def readme_paths(),
do:
@config[:docs] ++
Enum.map(Path.wildcard("flavours/*/README.md"), &flavour_readme/1) ++
Enum.map(Path.wildcard("docs/DEPENDENCIES/*.md"), &flavour_deps_doc/1) ++
Enum.flat_map(deps(:docs), &readme_path/1)
defp readme_path(dep) when not is_nil(dep),
do: dep_paths(dep, "README.md") |> List.first() |> readme_path(dep)
2021-12-17 00:52:46 +00:00
2022-09-12 04:34:14 +00:00
defp readme_path(path, dep) when not is_nil(path),
do: [{path |> String.to_atom(), [filename: "extension-" <> dep_name(dep)]}]
2021-12-16 22:56:46 +00:00
2022-09-12 04:34:14 +00:00
defp readme_path(_, _), do: []
def flavour_readme(path),
do: {path |> String.to_atom(), [filename: path |> String.split("/") |> Enum.at(1)]}
def flavour_deps_doc(path),
do:
{path |> String.to_atom(),
[
title:
path
|> String.split("/")
|> Enum.at(2)
|> String.slice(0..-4)
|> String.capitalize(),
filename:
path
|> String.split("/")
|> Enum.at(2)
|> String.slice(0..-4)
|> then(&"deps-#{&1}")
]}
# [plug: "https://myserver/plug/"]
defp doc_deps(), do: deps(:docs) |> Enum.map(&doc_dep/1)
2021-12-16 22:56:46 +00:00
defp doc_dep(dep), do: {elem(dep, 0), "./"}
2021-11-19 00:48:15 +00:00
2022-09-12 04:34:14 +00:00
def source_url_pattern("deps/" <> _ = path, line),
do: bonfire_ext_pattern(path, line)
2022-03-06 00:32:13 +00:00
2022-09-12 04:34:14 +00:00
def source_url_pattern("forks/" <> _ = path, line),
do: bonfire_ext_pattern(path, line)
2022-03-06 00:32:13 +00:00
2022-09-12 04:34:14 +00:00
def source_url_pattern(path, line), do: bonfire_app_pattern(path, line)
2022-03-06 00:32:13 +00:00
2022-09-12 04:34:14 +00:00
defp bonfire_ext_pattern(path, line),
do:
bonfire_ext_pattern(
path |> String.split("/") |> Enum.at(1),
path |> String.split("/") |> Enum.slice(2..1000) |> Enum.join("/"),
line
)
defp bonfire_ext_pattern(dep, path, line),
do:
bonfire_app_pattern(
"https://github.com/bonfire-networks/#{dep}/blob/main/%{path}#L%{line}",
path,
line
)
defp bonfire_app_pattern(path, line),
do:
bonfire_app_pattern(
"https://github.com/bonfire-networks/bonfire-app/blob/main/%{path}#L%{line}",
path,
line
)
defp bonfire_app_pattern(pattern, path, line),
do:
pattern
|> String.replace("%{path}", "#{path}")
|> String.replace("%{line}", "#{line}")
2022-03-06 00:32:13 +00:00
2021-05-16 08:34:50 +00:00
# Specifies which paths to include when running tests
2022-09-12 04:34:14 +00:00
defp test_paths(),
do: ["test" | Enum.flat_map(deps(:test), &dep_paths(&1, "test"))]
2021-05-16 08:34:50 +00:00
# Specifies which paths to compile per environment
2022-09-12 04:34:14 +00:00
defp elixirc_paths(:test),
do: [
"lib",
"test/support"
| Enum.flat_map(deps(:test), &dep_paths(&1, "test/support"))
]
# |> IO.inspect()
2022-09-12 04:34:14 +00:00
2021-10-12 01:27:24 +00:00
defp elixirc_paths(env), do: ["lib"] ++ catalogues(env)
2021-05-16 08:34:50 +00:00
2022-09-12 04:34:14 +00:00
defp include_dep?(type, dep, deps_prefixes)
2021-11-19 00:48:15 +00:00
2022-09-12 04:34:14 +00:00
defp include_dep?(:update, dep, _deps_prefixes) when is_tuple(dep),
do: unpinned_git_dep?(dep)
# defp include_dep?(:docs = type, dep, deps_prefixes), do: String.starts_with?(dep_name(dep), deps_prefixes || @config[:deps_prefixes][type]) || git_dep?(dep)
defp include_dep?(type, dep, deps_prefixes),
do:
String.starts_with?(
dep_name(dep),
deps_prefixes || @config[:deps_prefixes][type]
)
# defp git_dep?(dep) do
# spec = elem(dep, 1)
# is_list(spec) && spec[:git]
# end
2021-11-19 01:39:50 +00:00
2021-05-11 13:31:15 +00:00
defp unpinned_git_dep?(dep) do
spec = elem(dep, 1)
is_list(spec) && spec[:git] && !spec[:commit]
end
2021-05-16 08:34:50 +00:00
defp dep_name(dep) when is_tuple(dep), do: elem(dep, 0) |> dep_name()
defp dep_name(dep) when is_atom(dep), do: Atom.to_string(dep)
defp dep_name(dep) when is_binary(dep), do: dep
def deps_names(deps) do
2022-05-29 21:17:27 +00:00
deps
|> Enum.map(&dep_name/1)
|> Enum.join(" ")
end
def deps_for(type) do
deps(type)
|> Enum.map(&dep_name/1)
2021-05-16 08:34:50 +00:00
end
2021-05-15 14:28:18 +00:00
defp dep_path(dep) when is_binary(dep) do
2022-09-12 04:34:14 +00:00
path_if_exists(forks_path() <> dep) ||
path_if_exists(
(Mix.Project.deps_path() <> "/" <> dep)
|> Path.expand(File.cwd!())
) ||
"."
2021-05-15 14:28:18 +00:00
end
2021-05-05 13:29:10 +00:00
defp dep_path(dep) do
spec = elem(dep, 1)
2021-05-15 14:28:18 +00:00
2022-09-12 04:34:14 +00:00
path =
if is_list(spec) && spec[:path],
do: spec[:path],
else:
(Mix.Project.deps_path() <> "/" <> dep_name(dep))
2022-09-12 05:25:21 +00:00
|> Path.relative_to_cwd()
2021-05-15 14:28:18 +00:00
path_if_exists(path)
2020-12-26 17:01:34 +00:00
end
2022-09-12 04:34:14 +00:00
defp path_if_exists(path), do: if(File.exists?(path), do: path)
defp dep_paths(dep, extra) when is_list(extra),
do: Enum.flat_map(extra, &dep_paths(dep, &1))
2021-05-15 14:28:18 +00:00
2021-05-05 13:29:10 +00:00
defp dep_paths(dep, extra) when is_binary(extra) do
2021-05-15 17:33:58 +00:00
dep_path = dep_path(dep)
2022-09-12 04:34:14 +00:00
2021-05-19 06:42:43 +00:00
if dep_path do
path = Path.join(dep_path, extra) |> path_if_exists()
if path, do: [path], else: []
else
[]
end
2020-12-26 17:01:34 +00:00
end
2021-05-19 08:37:10 +00:00
def version do
@config[:version]
2022-09-12 04:34:14 +00:00
|> String.split("-", parts: 2)
|> List.insert_at(1, flavour())
|> Enum.join("-")
2021-05-19 08:37:10 +00:00
end
2020-08-05 07:39:59 +00:00
end