2020-09-09 15:18:39 +00:00
Code . eval_file ( " mess.exs " )
2020-11-07 14:05:06 +00:00
defmodule Bonfire.MixProject do
2020-08-05 07:39:59 +00:00
use Mix.Project
def project do
[
2020-11-07 14:05:06 +00:00
app : :bonfire ,
2021-05-15 19:11:36 +00:00
version : " 0.1.0-alpha.99 " ,
2020-11-28 13:46:08 +00:00
elixir : " ~> 1.11 " ,
2021-05-15 18:14:06 +00:00
elixirc_paths : elixirc_paths ( Mix . env ( ) ) ,
2021-05-05 13:29:10 +00:00
test_paths : test_paths ( ) ,
2020-11-10 08:29:02 +00:00
compilers : [ :phoenix , :gettext ] ++ Mix . compilers ( ) ,
2020-08-05 07:39:59 +00:00
start_permanent : Mix . env ( ) == :prod ,
aliases : aliases ( ) ,
2021-05-04 17:29:30 +00:00
deps : deps ( ) ,
config_path : config_path ( " config.exs " ) ,
releases : [
2021-05-04 18:09:59 +00:00
bonfire : [ runtime_config_path : config_path ( " runtime.exs " ) ] ,
2021-05-04 17:29:30 +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 , [ ] } ,
extra_applications : [ :logger , :runtime_tools , :ssl , :bamboo , :bamboo_smtp ]
]
2021-05-04 10:25:25 +00:00
end
2020-12-26 17:01:34 +00:00
defp deps ( ) do
2021-05-04 10:25:25 +00:00
Mess . deps ( mess_sources ( ) , [
2020-12-26 17:01:34 +00:00
## password hashing - builtin vs nif
2021-05-13 20:05:27 +00:00
{ :pbkdf2_elixir , " ~> 1.4 " , only : [ :dev , :test ] } ,
2020-12-26 17:01:34 +00:00
{ :argon2_elixir , " ~> 2.3.0 " , only : [ :prod ] } ,
## dev conveniences
2021-04-08 18:19:52 +00:00
# {:dbg, "~> 1.0", only: [:dev, :test]},
2020-12-26 17:01:34 +00:00
{ :phoenix_live_reload , " ~> 1.2 " , only : :dev } ,
2021-03-02 14:38:17 +00:00
{ :exsync , " ~> 0.2 " , only : :dev } ,
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 } ,
{ :mock , " ~> 0.3.0 " , only : :test } ,
2020-12-27 12:44:16 +00:00
{ :zest , " ~> 0.1 " } ,
2021-05-11 12:48:32 +00:00
{ :grumble , " ~> 0.1.3 " , only : [ :test ] , override : true } ,
2021-05-11 13:31:15 +00:00
{ :bonfire_api_graphql , git : " https://github.com/bonfire-networks/bonfire_api_graphql " , branch : " main " , only : [ :test ] } ,
2021-04-27 10:26:40 +00:00
2021-02-18 13:45:59 +00:00
# list dependencies & licenses
2021-02-21 18:52:16 +00:00
{ :licensir , only : :dev , runtime : false ,
git : " https://github.com/mayel/licensir " , branch : " pr " ,
# path: "./forks/licensir"
} ,
2021-04-30 10:58:35 +00:00
2021-04-20 13:07:54 +00:00
# Testing a component library for liveview
# {:surface_catalogue, "~> 0.0.7", only: :dev},
2021-02-18 13:45:59 +00:00
# security auditing
# {:mix_audit, "~> 0.1", only: [:dev], runtime: false}
{ :sobelow , " ~> 0.8 " , only : :dev }
2021-05-11 13:31:15 +00:00
]
)
2021-05-11 13:55:40 +00:00
# |> IO.inspect()
2020-12-26 17:01:34 +00:00
end
2021-05-05 13:29:10 +00:00
defp deps ( test ) when is_atom ( test ) , do : deps ( & dep? ( test , &1 ) )
defp deps ( test ) when is_function ( test , 1 ) , do : Enum . filter ( deps ( ) , test )
2020-11-28 12:49:44 +00:00
2020-08-05 07:39:59 +00:00
defp aliases do
[
2020-09-17 10:44:25 +00:00
" hex.setup " : [ " local.hex --force " ] ,
" rebar.setup " : [ " local.rebar --force " ] ,
2021-02-11 13:22:48 +00:00
" js.deps.get " : [
2021-05-15 17:49:43 +00:00
" cmd npm install --prefix " <> dep_path ( " bonfire_geolocate " ) <> " /assets " ,
2021-05-12 11:30:54 +00:00
" cmd npm install --prefix ./assets ./assets " ,
2021-02-11 13:22:48 +00:00
] ,
2021-05-15 18:23:52 +00:00
" js.release " : [
" cmd npm run deploy --prefix ./assets " ,
] ,
2020-12-16 18:47:02 +00:00
" js.deps.update " : [ " cmd npm update --prefix assets " ] ,
2021-02-11 13:22:48 +00:00
" ecto.seeds " : [
# "phil_columns.seed",
2021-05-05 13:55:08 +00:00
" run #{ flavour_path ( ) } /repo/seeds.exs "
2021-02-11 13:22:48 +00:00
] ,
2021-05-11 13:31:15 +00:00
" bonfire.deps.update " : [ " deps.update " <> deps_to_update ( ) ] ,
" bonfire.deps.clean " : [ " deps.clean " <> deps_to_clean ( ) <> " --build " ] ,
2020-11-28 12:49:44 +00:00
" bonfire.deps " : [ " bonfire.deps.update " , " bonfire.deps.clean " ] ,
setup : [ " hex.setup " , " rebar.setup " , " deps.get " , " bonfire.deps.clean " , " ecto.setup " , " js.deps.get " ] ,
2021-04-03 13:27:44 +00:00
updates : [ " deps.get " , " bonfire.deps " , " js.deps.get " ] ,
upgrade : [ " updates " , " ecto.migrate " ] ,
2020-08-05 07:39:59 +00:00
" ecto.setup " : [ " ecto.create " , " ecto.migrate " , " ecto.seeds " ] ,
" ecto.reset " : [ " ecto.drop " , " ecto.setup " ] ,
2021-01-22 17:46:25 +00:00
test : [ " ecto.create --quiet " , " ecto.migrate --quiet " , " ecto.seeds " , " test " ]
2020-08-05 07:39:59 +00:00
]
end
2020-09-09 15:18:39 +00:00
2021-05-11 13:31:15 +00:00
def flavour_path ( ) , do : System . get_env ( " BONFIRE_FLAVOUR " , " flavours/ " <> System . get_env ( " FLAVOUR " , " classic " ) )
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
2021-05-05 13:29:10 +00:00
defp mess_sources ( ) do
mess_sources ( System . get_env ( " WITH_FORKS " , " 1 " ) )
|> Enum . map ( fn { k , v } -> { k , config_path ( v ) } end )
end
2021-03-23 08:35:29 +00:00
2021-05-05 13:29:10 +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-11 13:31:15 +00:00
def deps_to_clean ( ) do
deps ( )
|> Enum . map ( & dep_name / 1 )
|> Enum . filter ( & data_dep? / 1 )
|> Enum . join ( " " )
end
def deps_to_update ( ) do
deps ( )
|> Enum . filter ( & should_update_dep? / 1 )
|> Enum . map ( & elem ( &1 , 0 ) )
|> Enum . join ( " " )
2021-05-13 17:42:52 +00:00
|> IO . inspect ( label : " Running Bonfire 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
defp should_update_dep? ( dep ) , do : unpinned_git_dep? ( dep )
defp unpinned_git_dep? ( dep ) do
spec = elem ( dep , 1 )
is_list ( spec ) && spec [ :git ] && ! spec [ :commit ]
end
2021-05-15 14:28:18 +00:00
defp dep_path ( dep ) when is_binary ( dep ) do
2021-05-15 18:54:46 +00:00
path_if_exists ( Mix.Project . deps_path ( ) <> " / " <> dep |> Path . relative_to ( File . cwd! ) )
2021-05-15 17:37:37 +00:00
|| path_if_exists ( System . get_env ( " LIBS_PATH " , " ./forks/ " ) <> dep )
|| " . "
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
path = if is_list ( spec ) && spec [ :path ] ,
2021-05-08 18:17:50 +00:00
do : spec [ :path ] ,
2021-05-11 12:16:15 +00:00
else : Mix.Project . deps_path ( ) <> " / " <> dep_name ( dep ) |> Path . relative_to ( File . cwd! )
2021-05-15 14:28:18 +00:00
path_if_exists ( path )
2020-12-26 17:01:34 +00:00
end
2021-05-15 14:28:18 +00:00
defp path_if_exists ( path ) , do : if File . exists? ( path ) , do : path
2021-05-05 13:29:10 +00:00
defp dep_paths ( dep , extra ) when is_list ( extra ) , do : Enum . flat_map ( extra , & dep_paths ( dep , &1 ) )
defp dep_paths ( dep , extra ) when is_binary ( extra ) do
2021-05-15 17:33:58 +00:00
dep_path = dep_path ( dep )
if dep_path , do : [ Path . join ( dep_path , extra ) ] , else : [ ]
2020-12-26 17:01:34 +00:00
end
2021-05-05 13:29:10 +00:00
defp test_paths ( ) , do : [ " test " | Enum . flat_map ( deps ( :test ) , & dep_paths ( &1 , " test " ) ) ]
defp test_lib_paths ( ) , do : [ " lib " , " test/support " | Enum . flat_map ( deps ( :test ) , & dep_paths ( &1 , " test/support " ) ) ]
@test_deps [ :pointers ]
2021-05-05 20:27:05 +00:00
2021-05-08 18:17:50 +00:00
defp dep? ( :test , dep ) , do : elem ( dep , 0 ) in @test_deps || String . starts_with? ( dep_name ( dep ) , " bonfire_ " )
2021-05-05 13:29:10 +00:00
defp dep_name ( dep ) , do : Atom . to_string ( elem ( dep , 0 ) )
2021-05-11 13:31:15 +00:00
def data_dep? ( dep ) , do : String . starts_with? ( dep , " bonfire_data_ " )
2021-05-05 13:29:10 +00:00
# Specifies which paths to compile per environment.
defp elixirc_paths ( :test ) , do : test_lib_paths ( )
defp elixirc_paths ( _ ) , do : [ " lib " ]
2020-08-05 07:39:59 +00:00
end