forked from anoma/anoma
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mix.exs
208 lines (193 loc) · 5.8 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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
defmodule Anoma.MixProject do
use Mix.Project
def version do
{ver, _} = Code.eval_file("version.exs", ".")
ver
end
def project do
[
apps_path: "apps",
version: version(),
elixir: "~> 1.17",
start_permanent: Mix.env() == :prod,
deps: deps(),
dialyzer: [
plt_local_path: "plts/anoma.plt",
plt_core_path: "plts/core.plt",
flags: ["-Wno_improper_lists"],
plt_add_apps: [:mix, :ex_unit]
],
# Docs
name: "Anoma",
docs: docs(),
# Nockma eval
escript: escript(),
releases: releases(),
package: package(),
# these options are required for running `mix compile` in the umbrella.
# make changes here and in apps/anoma_protobuf/mix.exs
protoc_options: [
elixir_out: "apps/anoma_protobuf/lib/anoma/protobuf",
proto_files: ["apps/anoma_protobuf/priv/protobuf"],
extra_opts:
"one_file_per_module=true,gen_descriptors=true,plugins=grpc"
]
]
end
def releases do
[
anoma_client: [
include_executables_for: [:unix],
applications: [
{:anoma_client, :permanent}
]
],
anoma: [
include_executables_for: [:unix, :windows],
applications: [
anoma_node: :permanent,
event_broker: :permanent
]
]
]
end
# Run "mix help deps" to learn about dependencies.
defp deps do
[]
end
defp docs do
[
main: "readme",
extras: extras(),
source_ref: "v#{version()}",
javascript_config_path: "./.doc-versions.js",
extra_section: "GUIDES",
groups_for_extras: group_for_extras(),
groups_for_modules: group_for_modules(),
before_closing_body_tag: &docs_before_closing_body_tag/1
]
end
def package do
[
maintainers: ["Mariari", " Raymond E. Pasco"],
name: :anoma,
licenses: ["MIT"]
]
end
def group_for_modules() do
[
"Resource Machine": [
~r/^Anoma.RM.?/,
~r/^Anoma.Resource.?/,
~r/^Anoma.CairoResource.Resource.?/
],
"Anoma Actors": [Anoma.Node],
Mempool: ~r/^Anoma.Node.Mempool.?/,
Executor: ~r/^Anoma.Node.Executor.?/,
Identity: [~r/^Anoma.Identity.?/, ~r/^Anoma.Node.Identity.?/],
Intents: ~r/^Anoma.Node.Intent.?/,
Storage: [~r/^Anoma.Node.Storage.?/, Anoma.Node.Storage, Anoma.Order],
Transport: ~r/^Anoma.Node.Transport.?/,
Examples: ~r/^Examples.?/,
"Cryptographic Primitives": [~r/^Anoma.Crypto.?/],
Solver: [~r/^Anoma.Node.Solver.?/],
"General Engines": [~r/^Anoma.Node.?/],
"CLI Engine": [~r/^Anoma.Cli.?/],
Nock: [~r/^Nock.?/, ~r/^Noun.?/],
CommitmentTree: [~r/^CommitmentTree.?/],
EventBroker: ~r/^EventBroker.?/,
Utilities: [Anoma.Utility, Anoma.Mnesia, Anoma.Communicator],
"Test Helpers": ~r/^TestHelper.?/
]
end
def group_for_extras() do
[
"Guide Index": "documentation/index_docs.livemd",
"Contributors Guide": ~r/documentation\/contributing\/.?/,
"Contributors Guide": "documentation/CONTRIBUTING.livemd",
"Visualizing Anoma": ~r/documentation\/visualization\/.?/,
"Visualizing Anoma": "documentation/visualization.livemd",
"Nock Environment": ~r/documentation\/hoon\/.?/,
"Nock Environment": "documentation/hoon.livemd"
]
end
def extras() do
["README.md" | all_docs("./documentation")]
end
# Run "mix help compile.app" to learn about applications.
def application do
[
extra_applications: [
:observer,
:wx
]
]
end
def escript do
[
main_module: Anoma.Cli,
name: "anoma",
app: nil
]
end
defp docs_before_closing_body_tag(:html) do
# https://hexdocs.pm/ex_doc/readme.html#extensions
"""
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/mermaid.min.js"></script>
<script>
document.addEventListener("DOMContentLoaded", function () {
mermaid.initialize({
startOnLoad: false,
theme: document.body.className.includes("dark") ? "dark" : "default"
});
let id = 0;
for (const codeEl of document.querySelectorAll("pre code.mermaid")) {
const preEl = codeEl.parentElement;
const graphDefinition = codeEl.textContent;
const graphEl = document.createElement("div");
const graphId = "mermaid-graph-" + id++;
mermaid.render(graphId, graphDefinition).then(({svg, bindFunctions}) => {
graphEl.innerHTML = svg;
bindFunctions?.(graphEl);
preEl.insertAdjacentElement("afterend", graphEl);
preEl.remove();
});
}
});
</script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
<script>
document.addEventListener("DOMContentLoaded", function () {
for (const codeEl of document.querySelectorAll("pre code.vega-lite")) {
try {
const preEl = codeEl.parentElement;
const spec = JSON.parse(codeEl.textContent);
const plotEl = document.createElement("div");
preEl.insertAdjacentElement("afterend", plotEl);
vegaEmbed(plotEl, spec);
preEl.remove();
} catch (error) {
console.log("Failed to render Vega-Lite plot: " + error)
}
}
});
</script>
"""
end
defp docs_before_closing_body_tag(_), do: ""
defp all_docs(dir) do
[dir | dir_from_path(dir)]
|> Stream.map(fn x -> Path.wildcard(Path.join(x, "*livemd")) end)
|> Stream.concat()
|> Enum.sort()
end
defp dir_from_path(dir) do
File.ls!(dir)
|> Stream.map(&Path.join(dir, &1))
|> Stream.filter(&File.dir?(&1))
|> Enum.map(fn x -> [x | dir_from_path(x)] end)
|> Enum.concat()
end
end