-
Notifications
You must be signed in to change notification settings - Fork 2
/
mix.exs
158 lines (145 loc) · 3.98 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
defmodule BeamMeta.MixProject do
use Mix.Project
@app :beam_meta
@name "BeamMeta"
@description "A library to programmatically retrieve information related to BEAM languages"
@repo_url "https://github.com/eksperimental/beam_meta"
def project do
[
app: @app,
version: "0.2.1",
elixir: "~> 1.10",
start_permanent: Mix.env() == :prod,
description: @description,
aliases: aliases(),
package: package(),
deps: deps(),
# Docs
name: @name,
source_url: @repo_url,
# homepage_url: @repo_url,
docs: docs()
]
end
# Run "mix help compile.app" to learn about applications.
def application do
[
extra_applications: [:logger]
]
end
defp aliases do
[
validate: [
"format --check-formatted",
"deps.unlock --check-unused",
"compile",
"compile --warnings-as-errors",
"dialyzer",
"docs",
"credo --ignore Credo.Check.Design.TagTODO"
],
prepare: [
"format",
"deps.clean --unused --unlock",
"deps.unlock --unsued"
],
setup: [
"deps.get",
"deps.update --all"
],
all: [
"setup",
"prepare",
"validate",
test_isolated()
]
]
end
defp test_isolated() do
fn _args ->
env = %{"MIX_ENV" => "test"}
with {:"test setup", {_, 0}} <- {:"test setup", System.cmd("mix", ~w[setup], env: env)},
{:test, {_, 0}} <- {:test, System.cmd("mix", ~w[test], env: env)} do
true
else
{type, {output, _}} ->
IO.puts(output)
raise("#{type} failed.")
end
end
end
defp package do
[
maintainers: ["Eksperimental"],
licenses: ["CC0-1.0", "MIT-0", "0BSD"],
links: %{"GitHub" => @repo_url},
source_url: @repo_url
]
end
# Run "mix help deps" to learn about dependencies.
defp deps do
[
# {:beam_langs_meta_data,
# git: "https://github.com/eksperimental/beam_langs_meta_data.git", branch: "main"},
{:beam_langs_meta_data, "~> 0.2.1"},
# {:beam_langs_meta_data, path: "../beam_langs_meta_data"},
{:dialyxir, "~> 1.0", only: [:dev], runtime: false},
{:credo, "~> 1.6", only: [:dev], runtime: false},
{:gradient, github: "esl/gradient", only: [:dev], runtime: false},
{:ex_doc, "~> 0.28", only: :dev, runtime: false}
]
end
defp docs do
[
# The main page in the docs
main: @name,
extras: [
"README.md": [filename: "readme", title: "Readme"],
# "NOTICE": [filename: "notice", title: "Notice"],
"LICENSES/LICENSE.CC0-1.0.txt": [
filename: "license_CC0-1.0",
title: "Creative Commons Zero Universal version 1.0 License"
],
"LICENSES/LICENSE.MIT-0.txt": [
filename: "license_MIT-0",
title: "MIT No Attribution License"
],
"LICENSES/LICENSE.0BSD.txt": [
filename: "license_0BSD",
title: "BSD Zero Clause License"
]
],
groups_for_modules: [
Compatibility: [
BeamMeta.Compatibility.OtpElixir
],
Release: [
BeamMeta.Release,
BeamMeta.Release.Elixir,
BeamMeta.Release.Otp
]
],
groups_for_extras: [
Licenses: ~r{LICENSES/}
],
source_ref: revision()
]
end
# Originally taken from: https://github.com/elixir-lang/elixir/blob/2b0abcebbe9acee4a103c9d02c6bae707f0e9e73/lib/elixir/lib/system.ex#L1019
# Tries to run "git rev-parse --short=7 HEAD". In the case of success returns
# the short revision hash. If that fails, returns an empty string.
defp revision do
null =
case :os.type() do
{:win32, _} -> 'NUL'
_ -> '/dev/null'
end
'git rev-parse --short=7 HEAD 2> '
|> Kernel.++(null)
|> :os.cmd()
|> strip
end
defp strip(iodata) do
:re.replace(iodata, "^[\s\r\n\t]+|[\s\r\n\t]+$", "", [:global, return: :binary])
end
end