-
Notifications
You must be signed in to change notification settings - Fork 0
/
mix.exs
175 lines (146 loc) · 4.95 KB
/
mix.exs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
defmodule Stampede.MixProject do
use Mix.Project
def project do
[
app: :stampede,
version: "0.1.2-dev",
elixir: "~> 1.16",
start_permanent: Mix.env() == :prod,
deps: deps(),
dialyzer: dialyzer(),
preferred_cli_env: [release: :prod, compile: :prod, test: :test],
# Appears to not work at all
erlc_options: [
strong_validation: true,
recv_opt_info: true,
bin_opt_info: true
],
# Docs
name: "Stampede",
source_url: "https://github.com/ProducerMatt/stampede",
docs: [
main: "Stampede",
extras: ["README.md"]
]
]
end
defp service_requirements_map() do
%{
Services.Discord => fn config_acc ->
config_acc
|> Keyword.update!(:extra_applications, fn app_list ->
[:certifi, :gun, :inets, :jason, :kcl, :mime | app_list]
end)
end
}
end
def application do
configure_app(Application.fetch_env!(:stampede, :services_to_install))
end
@doc "Dynamically configure app dependencies for given services"
def configure_app(:all) do
service_requirements_map()
|> Map.keys()
|> configure_app()
end
def configure_app(list) when is_list(list), do: configure_app(list, nil)
defp configure_app(mod_list, nil) when is_list(mod_list) do
configure_app(mod_list,
extra_applications: [:logger, :runtime_tools],
mod: {Stampede.Application, []},
included_applications: [],
env: [
installed_services: [Services.Dummy]
]
)
end
defp configure_app([first_service_name | rest], config_acc) when is_list(config_acc) do
update_fun = Map.fetch!(service_requirements_map(), first_service_name)
new_acc =
update_fun.(config_acc)
|> Keyword.update!(:env, fn env_ls ->
# always add service name to :installed_services
Keyword.update!(env_ls, :installed_services, fn installed ->
if first_service_name in installed,
do:
raise(
"There's no reason for #{first_service_name |> inspect()} to already be there??"
)
[first_service_name | installed]
end)
end)
configure_app(rest, new_acc)
end
defp configure_app([], config_acc) when is_list(config_acc), do: config_acc
defp deps do
[
# Checking
{:ex_check, "~> 0.16.0", only: [:dev], runtime: false},
{:credo, ">= 0.0.0", only: [:dev], runtime: false},
{:dialyxir, ">= 0.0.0", only: [:dev, :test], runtime: false},
{:doctor, ">= 0.0.0", only: [:dev], runtime: false},
{:ex_doc, ">= 0.0.0", only: [:dev], runtime: false},
{:gettext, ">= 0.0.0", only: [:dev], runtime: false},
{:sobelow, ">= 0.0.0", only: [:dev], runtime: false},
{:mix_audit, ">= 0.0.0", only: [:dev], runtime: false},
# must be started before use, see test/test_helper.exs
{:assert_value, "~> 0.10.4", only: [:test, :dev]},
# RUNTIME TYPE CHECKING
# https://hexdocs.pm/type_check/readme.html
{:type_check, "~> 0.13.5"},
# for type checking streams
{:stream_data, "~> 0.5.0"},
# Benchmarking
{:benchee, "~> 1.1", runtime: false, only: :bench},
# profiling
# {:eflambe, ">= 0.0.0", only: :dev},
{:eflambe, ">= 0.0.0"},
{:sweet_xml, ">= 0.0.0"},
# Fast arrays
{:arrays_aja, "~> 0.2.0"},
# SERVICES
{:nostrum, "~> 0.9.1", runtime: false},
# {:nostrum, github: "Kraigie/nostrum", runtime: false},
# EXTERNAL PLUGIN SUPPORT
{:doumi_port, "~> 0.6.0"},
# override erlport for newer version
{:erlport, "~> 0.11.0", override: true},
# For catching Erlang errors and sending to services
{:logger_backends, "~> 1.0"},
# For site configs
{:fast_yaml, "~> 1.0"},
# NimbleOptions generates docs with its definitions. Use for site configs.
# https://hexdocs.pm/nimble_options/NimbleOptions.html
{:nimble_options, "~> 1.0"},
# JSON logging to disk. Parse easily with `jq -s <query> ./logs/<env>/<logfile>`
{:uinta, "~> 0.13.0"},
# Cron jobs
{:quantum, "~> 3.5"},
# CLI monitoring
{:observer_cli, "~> 1.7", only: :dev},
# Persistant storage, particularly interaction logging
{:memento, "~> 0.3.2"},
# Erlang match specifications in Elixir style
{:ex2ms, "~> 1.7"},
# storage for Services.Dummy
{:ets, "~> 0.9.0"}
## NOTE: this would be great if it supported TOML
# {:confispex, "~> 1.1"}, # https://hexdocs.pm/confispex/api-reference.html
]
end
defp dialyzer() do
[
flags: [
:missing_return,
:extra_return,
:unmatched_returns,
:error_handling,
:no_improper_lists
],
plt_core_path: "priv/plts",
plt_file: {:no_warn, "priv/plts/dialyzer.plt"},
# NOTE: Nostrum for some reason doesn't give type info without explicitly demanding it
plt_add_apps: [:nostrum]
]
end
end