mirror of
https://github.com/bonfire-networks/bonfire-app.git
synced 2024-05-17 00:22:40 +00:00
Umbrella
This commit is contained in:
parent
b7978856a1
commit
6fe9949d47
|
@ -1 +0,0 @@
|
|||
// tells Bonfire extensions that they're running in a multi-repo umbrella
|
|
@ -8,20 +8,34 @@ if not Code.ensure_loaded?(Mess) do
|
|||
@newline ~r/(?:\r\n|[\r\n])/
|
||||
@parser ~r/^(?<indent>\s*)((?<package>[a-z_][a-z0-9_]+)\s*=\s*"(?<value>[^"]+)")?(?<post>.*)/
|
||||
@git_branch ~r/(?<repo>[^#]+)(#(?<branch>.+))?/
|
||||
@ext_forks_path System.get_env("FORKS_PATH", "extensions/")
|
||||
|
||||
defp sources(true), do: [path: "deps.path", git: "deps.git", hex: "deps.hex"]
|
||||
defp sources(_), do: [git: "deps.git", hex: "deps.hex"]
|
||||
|
||||
defp opts(opts \\ []),
|
||||
do:
|
||||
defp opts(opts \\ []) do
|
||||
opts =
|
||||
opts
|
||||
|> Keyword.put_new_lazy(:use_local_forks?, fn ->
|
||||
System.get_env("WITH_FORKS", "1") == "1"
|
||||
end)
|
||||
|> Keyword.put_new_lazy(:umbrella_path, fn ->
|
||||
if Mix.env() == :dev, do: "extensions/", else: nil
|
||||
|
||||
# NOTE: we check MIX_ENV instead of `Mix.env` because it incorrectly returns :prod when doing deps.get
|
||||
opts =
|
||||
opts
|
||||
|> Keyword.put_new_lazy(:use_umbrella?, fn ->
|
||||
System.get_env("MIX_ENV", "dev") == "dev" and opts[:use_local_forks?] and
|
||||
System.get_env("AS_UMBRELLA") == "1"
|
||||
end)
|
||||
|
||||
opts
|
||||
|> Keyword.put_new_lazy(:umbrella_path, fn ->
|
||||
if opts[:use_umbrella?], do: @ext_forks_path, else: nil
|
||||
end)
|
||||
|
||||
# |> IO.inspect(label: "opts for #{File.cwd!}")
|
||||
end
|
||||
|
||||
def deps(sources \\ nil, extra_deps, opts \\ []) do
|
||||
opts = opts(opts)
|
||||
|
||||
|
@ -53,10 +67,9 @@ if not Code.ensure_loaded?(Mess) do
|
|||
|
||||
# |> IO.inspect(label: "umbrella_only")
|
||||
|
||||
opts[:umbrella_path] != nil ->
|
||||
umbrella_deps =
|
||||
read_umbrella("../../config/deps.path", opts)
|
||||
|> IO.inspect(label: "umbrella_deps for #{File.cwd!}")
|
||||
opts[:use_umbrella?] ->
|
||||
umbrella_deps = read_umbrella("../../config/deps.path", opts)
|
||||
# |> IO.inspect(label: "umbrella_deps for #{File.cwd!}")
|
||||
|
||||
deps
|
||||
|> Enum.map(fn dep ->
|
||||
|
@ -70,7 +83,11 @@ if not Code.ensure_loaded?(Mess) do
|
|||
if dep_opts[:from_umbrella] do
|
||||
{name, in_umbrella: true, override: true}
|
||||
else
|
||||
{name, dep_opts |> Keyword.put(:path, "../../#{dep_opts[:path]}")}
|
||||
{
|
||||
name,
|
||||
dep_opts
|
||||
# |> Keyword.put(:path, "../../#{dep_opts[:path]}")
|
||||
}
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
@ -86,8 +103,7 @@ if not Code.ensure_loaded?(Mess) do
|
|||
read(path, :path)
|
||||
|> Enum.flat_map(&dep_spec(&1, opts))
|
||||
else
|
||||
IO.inspect(File.cwd!())
|
||||
IO.puts("did not load #{path}")
|
||||
# IO.puts("did not load #{path}")
|
||||
[]
|
||||
end
|
||||
end
|
||||
|
@ -114,7 +130,13 @@ if not Code.ensure_loaded?(Mess) do
|
|||
umbrella_path = opts[:umbrella_path]
|
||||
|
||||
if umbrella_path && String.starts_with?(v, umbrella_path) do
|
||||
pkg(p, from_umbrella: true, override: true, path: v)
|
||||
if opts[:umbrella_root?] do
|
||||
pkg(p, from_umbrella: true, override: true, path: "../../#{v}")
|
||||
# |> IO.inspect(label: "from_umbrella: #{p}")
|
||||
else
|
||||
pkg(p, in_umbrella: true, override: true)
|
||||
# |> IO.inspect(label: "in_umbrella: #{p}")
|
||||
end
|
||||
else
|
||||
pkg(p, path: v, override: true)
|
||||
end
|
||||
|
|
38
mix.exs
38
mix.exs
|
@ -8,7 +8,11 @@ defmodule Bonfire.Umbrella.MixProject do
|
|||
# we only behave as an umbrella im dev/test env
|
||||
@use_local_forks System.get_env("WITH_FORKS", "1") == "1"
|
||||
@ext_forks_path Mixer.forks_path()
|
||||
@umbrella_path if Mix.env() == :dev and @use_local_forks and File.exists?("#{@ext_forks_path}/bonfire"), do: @ext_forks_path, else: nil
|
||||
@use_umbrella? Mix.env() == :dev and @use_local_forks and System.get_env("AS_UMBRELLA") == "1" and
|
||||
File.exists?("#{@ext_forks_path}/bonfire")
|
||||
@umbrella_path if @use_umbrella?, do: @ext_forks_path, else: nil
|
||||
|
||||
if @use_umbrella?, do: IO.puts("NOTE: Running as umbrella...")
|
||||
|
||||
@extra_deps [
|
||||
## password hashing - builtin vs nif
|
||||
|
@ -55,14 +59,14 @@ defmodule Bonfire.Umbrella.MixProject do
|
|||
{:benchee_html, "~> 1.0", only: :dev},
|
||||
|
||||
# list dependencies & licenses
|
||||
{
|
||||
:licensir,
|
||||
only: :dev,
|
||||
runtime: false,
|
||||
git: "https://github.com/bonfire-networks/licensir",
|
||||
branch: "main"
|
||||
# path: "./forks/licensir"
|
||||
},
|
||||
# {
|
||||
# :licensir,
|
||||
# only: :dev,
|
||||
# runtime: false,
|
||||
# git: "https://github.com/bonfire-networks/licensir",
|
||||
# branch: "main"
|
||||
# # path: "./forks/licensir"
|
||||
# },
|
||||
|
||||
# security auditing
|
||||
# {:mix_audit, "~> 0.1", only: [:dev], runtime: false}
|
||||
|
@ -151,12 +155,16 @@ defmodule Bonfire.Umbrella.MixProject do
|
|||
localise: ["bonfire"],
|
||||
localise_self: []
|
||||
],
|
||||
deps: Mess.deps(Mixer.mess_sources(@default_flavour), @extra_deps, [
|
||||
use_local_forks?: @use_local_forks,
|
||||
umbrella_root?: @use_local_forks,
|
||||
umbrella_path: @umbrella_path
|
||||
] |> IO.inspect())
|
||||
] |> IO.inspect(limit: :infinity)
|
||||
deps:
|
||||
Mess.deps(Mixer.mess_sources(@default_flavour), @extra_deps,
|
||||
use_local_forks?: @use_local_forks,
|
||||
use_umbrella?: @use_umbrella?,
|
||||
umbrella_root?: @use_local_forks,
|
||||
umbrella_path: @umbrella_path
|
||||
)
|
||||
]
|
||||
|
||||
# |> IO.inspect(limit: :infinity)
|
||||
|
||||
def config, do: @config
|
||||
def deps, do: config()[:deps]
|
||||
|
|
2
mix.lock
2
mix.lock
|
@ -46,7 +46,7 @@
|
|||
"bonfire_ui_coordination": {:git, "https://github.com/bonfire-networks/bonfire_ui_coordination", "a016a32e3817499da9db4a353d546402fa4bd131", [branch: "main"]},
|
||||
"bonfire_ui_kanban": {:git, "https://github.com/bonfire-networks/bonfire_ui_kanban", "864d4fc1f012df6bc2ab5e942a7202f8c27f1076", [branch: "main"]},
|
||||
"bonfire_ui_me": {:git, "https://github.com/bonfire-networks/bonfire_ui_me", "fb0e2ff789db52bf1d05faba9793a572b6bdbbe2", [branch: "main"]},
|
||||
"bonfire_ui_social": {:git, "https://github.com/bonfire-networks/bonfire_ui_social", "7b1fac136020b901209c93c27fc1566fa72d9d95", [branch: "main"]},
|
||||
"bonfire_ui_social": {:git, "https://github.com/bonfire-networks/bonfire_ui_social", "7187d6de23451658991af219166536eac2992bd2", [branch: "main"]},
|
||||
"bonfire_ui_valueflows": {:git, "https://github.com/bonfire-networks/bonfire_ui_valueflows", "f2e47c1d2602c0e6cce28aebbcdeb4700ac9237a", [branch: "main"]},
|
||||
"bonfire_upcycle": {:git, "https://gitlab.com/bonfire-networks/bonfire_upcycle", "8f1cc7b1578d42318f12a13de017c5d0b760950d", [branch: "main"]},
|
||||
"bonfire_valueflows": {:git, "https://github.com/bonfire-networks/bonfire_valueflows", "f12b67187341f289ef7be67ecd3c3eb7a6a1969a", [branch: "main"]},
|
||||
|
|
Loading…
Reference in a new issue