-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmix.exs
117 lines (103 loc) · 2.67 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
defmodule Nvir.MixProject do
use Mix.Project
@source_url "https://github.com/lud/nvir"
@version "0.10.2"
def project do
[
app: :nvir,
name: "Nvir",
version: @version,
elixir: "~> 1.13",
start_permanent: Mix.env() == :prod,
deps: deps(),
package: package(),
modkit: modkit(),
dialyzer: dialyzer(),
versioning: versioning(),
docs: [
main: "readme",
source_ref: "v#{@version}",
source_url: @source_url,
extras: extras()
]
]
end
def extras do
[
"README.md"
]
end
defp package do
[
description:
"A fully-featured dotenv parser with environment variables helpers. Fork of Dotenvy with fallback to system environment variables.",
licenses: ["MIT"],
links: %{"Github" => @source_url, "Changelog" => "#{@source_url}/blob/main/CHANGELOG.md"},
maintainers: ["Ludovic Demblans <[email protected]>"]
]
end
def application do
[]
end
defp deps do
[
# Test
{:briefly, "~> 0.5.1", only: :test},
# Doc
{:ex_doc, ">= 0.0.0", only: :dev, runtime: false},
# Checks
{:ex_check, "~> 0.16.0", only: [:dev, :test], runtime: false},
{:credo, "~> 1.7", only: [:dev, :test], runtime: false},
{:dialyxir, "~> 1.4", only: [:dev, :test], runtime: false},
{:mix_audit, "~> 2.1", only: [:dev, :test], runtime: false},
{:doctor, "~> 0.22.0", only: :dev, runtime: false}
]
end
defp modkit do
[
mount: [
{Nvir, "lib/nvir"}
]
]
end
defp dialyzer do
[
flags: [:unmatched_returns, :error_handling, :unknown, :extra_return],
list_unused_filters: true,
plt_add_deps: :app_tree,
plt_add_apps: [:ex_unit, :mix],
plt_local_path: "_build/plts"
]
end
def cli do
[
preferred_envs: [dialyzer: :test]
]
end
defp versioning do
[
annotate: true,
before_commit: [
&update_readme/1,
{:add, "README.md"},
&gen_changelog/1,
{:add, "CHANGELOG.md"}
]
]
end
def update_readme(vsn) do
version = Version.parse!(vsn)
readme_vsn = "#{version.major}.#{version.minor}" |> dbg()
readme = File.read!("README.md")
re = ~r/:nvir, "~> \d+\.\d+"/
readme = String.replace(readme, re, ":nvir, \"~> #{readme_vsn}\"")
File.write!("README.md", readme)
:ok
end
defp gen_changelog(vsn) do
case System.cmd("git", ["cliff", "--tag", vsn, "-o", "CHANGELOG.md"], stderr_to_stdout: true) do
{_, 0} -> IO.puts("Updated CHANGELOG.md with #{vsn}")
{out, _} -> {:error, "Could not update CHANGELOG.md:\n\n #{out}"}
end
end
end