Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mayel committed Nov 18, 2024
1 parent f3c0914 commit 05b9135
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 69 deletions.
9 changes: 3 additions & 6 deletions config/bonfire_common.exs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ import Config
default_locale = "en"

config :bonfire_common,
localisation_path: "priv/localisation"

config :bonfire_common,
otp_app: :bonfire_common,
localisation_path: "priv/localisation",
ecto_repos: [Bonfire.Common.Repo]

config :bonfire_common, Bonfire.Common.Repo,
Expand All @@ -25,11 +22,11 @@ config :bonfire_common, Bonfire.Common.Localise.Cldr,
otp_app: :bonfire_common,
default_locale: default_locale,
# locales that will be made available on top of those for which gettext localisation files are available
locales: ["fr", "en", "es"],
locales: ["fr", "en"],
providers: [
Cldr.Language,
Cldr.DateTime,
Cldr.Number,
Cldr.Number, # TEMP: because Jason error at compilation
Cldr.Unit,
Cldr.List,
Cldr.Calendar,
Expand Down
19 changes: 4 additions & 15 deletions config/config.exs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import Config

config :bonfire_common,
otp_app: :bonfire_common,
env: config_env()

config :needle, :search_path, [:bonfire_common]

# Choose password hashing backend
Expand All @@ -9,18 +13,3 @@ config :bonfire_data_identity, Bonfire.Data.Identity.Credential, hasher_module:

import_config "bonfire_common.exs"

config_file = if Mix.env() == :test, do: "config/test.exs", else: "config/config.exs"

cond do
File.exists?("../bonfire/#{config_file}") ->
IO.puts("Load #{config_file} from local clone of `bonfire` dep")
import_config "../../bonfire/#{config_file}"

File.exists?("deps/bonfire/#{config_file}") ->
IO.puts("Load #{config_file} from `bonfire` dep")
import_config "../deps/bonfire/#{config_file}"

true ->
IO.puts("No #{config_file} found")
nil
end
12 changes: 6 additions & 6 deletions lib/config_settings/config.ex
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ defmodule Bonfire.Common.Config do
iex> get!(:test_key)
"test_value"
iex> get!(:missing_key)
** (Bonfire.Common.Config.Error) Missing configuration value: [:bonfire, :missing_key]
iex> get!(:missing_key, :bonfire_common)
** (Bonfire.Common.Config.Error) Missing configuration value: [:bonfire_common, :missing_key]
"""

Expand Down Expand Up @@ -379,11 +379,11 @@ defmodule Bonfire.Common.Config do
> keys_tree(:bonfire_me)
[:bonfire_me]
iex> keys_tree(:random_atom)
[:bonfire, :random_atom]
> keys_tree(:random_atom)
[:bonfire_common, :random_atom]
iex>keys_tree([:random_atom, :sub_key])
[:bonfire, :random_atom, :sub_key]
>keys_tree([:random_atom, :sub_key])
[:bonfire_common, :random_atom, :sub_key]
"""
def keys_tree(keys) when is_list(keys) do
maybe_module_or_otp_app = List.first(keys)
Expand Down
9 changes: 3 additions & 6 deletions lib/config_settings/settings.ex
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,16 @@ defmodule Bonfire.Common.Settings do
iex> get(:non_existing_key, "default")
"default"
iex> get(:otp_app)
> get(:otp_app)
:bonfire
iex> get([:bonfire_common, :otp_app])
> get([:bonfire_common, :otp_app])
:bonfire
iex> get([:bonfire_common, :otp_app])
:bonfire
iex> get([Bonfire.Common.Localise.Cldr, :gettext])
Bonfire.Common.Localise.Gettext
iex> get([:bonfire_common, Bonfire.Common.Localise.Cldr, :gettext])
> get([:bonfire_common, Bonfire.Common.Localise.Cldr, :gettext])
Bonfire.Common.Localise.Gettext
## Options
Expand Down
4 changes: 2 additions & 2 deletions lib/modularity/extend.ex
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ defmodule Bonfire.Common.Extend do
## Examples
iex> %{bonfire_common: true} = loaded_applications_names()
iex> %{bonfire_common: _} = loaded_applications_names()
"""
def loaded_applications_names(opts \\ [cache: false]) do
Expand Down Expand Up @@ -658,7 +658,7 @@ defmodule Bonfire.Common.Extend do
## Examples
iex> generate_reverse_router!()
> generate_reverse_router!()
:ok
"""
def generate_reverse_router!() do
Expand Down
6 changes: 1 addition & 5 deletions lib/modularity/extension_diff.ex
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ defmodule Bonfire.Common.Extensions.Diff do
## Examples
iex> Bonfire.Common.Extensions.Diff.git_generate_diff("main", "./", "./data/test_output.patch")
> Bonfire.Common.Extensions.Diff.git_generate_diff("main", "./", "./data/test_output.patch")
"""
def git_generate_diff(ref_or_branch, repo_path, path_output, extra_opt \\ "--cached") do
git!(
Expand Down Expand Up @@ -195,10 +195,6 @@ defmodule Bonfire.Common.Extensions.Diff do
- `repo_path`: The path to the repository.
- `into`: Optional destination for command output (defaults to standard output)
- `original_cwd`: The original working directory.
## Examples
> Bonfire.Common.Extensions.Diff.git!(["status"], "./")
"""
def git!(args, repo_path \\ ".", into \\ default_into(), original_cwd \\ root())
when is_list(args) and is_binary(repo_path) and is_binary(original_cwd) do
Expand Down
3 changes: 3 additions & 0 deletions lib/runtime_config.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ defmodule Bonfire.Common.RuntimeConfig do
def config do
import Config

config :bonfire_common,
root_path: File.cwd!()

config :bonfire, :http,
proxy_url: System.get_env("HTTP_PROXY_URL", nil),
adapter_options: [
Expand Down
Loading

0 comments on commit 05b9135

Please sign in to comment.