-
Notifications
You must be signed in to change notification settings - Fork 1
/
mix.exs
99 lines (89 loc) · 2.7 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
defmodule Weather.MixProject do
use Mix.Project
def project do
[
app: :weather,
version: "0.3.8",
elixir: "~> 1.17",
start_permanent: Mix.env() == :prod,
deps: deps(),
aliases: aliases(),
package: package(),
name: "Weather",
source_url: "https://github.com/spencerolson/weather",
docs: [
main: "Weather",
logo: "priv/static/images/logo.png",
extras: ["README.md", "LIVEBOOK.livemd"]
],
escript: escript(),
elixirc_paths: elixirc_paths(Mix.env()),
dialyzer: [
# Put the project-level PLT in the priv/ directory (instead of the default _build/ location)
plt_file: {:no_warn, "priv/plts/project.plt"}
]
]
end
# Run "mix help compile.app" to learn about applications.
def application do
[
extra_applications: [:logger]
]
end
# Run "mix help deps" to learn about dependencies.
defp deps do
[
{:credo, "~> 1.7", only: [:dev, :test], runtime: false},
{:ex_doc, "~> 0.34", only: :dev, runtime: false},
{:mimic, "~> 1.7", only: :test},
{:plug, "~> 1.0"},
{:req, "~> 0.5.0"},
{:tz, "~> 0.27"},
{:dialyxir, "~> 1.4", only: [:dev, :test], runtime: false}
]
end
defp aliases do
[push: &push/1]
end
defp package do
[
name: "weather",
description:
"An Elixir library and command-line interface for fetching weather data from the OpenWeatherMap API.",
licenses: ["MIT"],
links: %{
"Changelog" => "https://github.com/spencerolson/weather/blob/main/CHANGELOG.md",
"GitHub" => "https://github.com/spencerolson/weather",
"OpenWeatherMap 'One Call API 3.0'" => "https://openweathermap.org/api/one-call-3"
}
]
end
defp push(_args) do
with :ok <-
run(
"git diff --quiet && git diff --cached --quiet",
"1. Check for uncommitted changes"
),
:ok <- run("mix format --check-formatted &> /dev/null", "2. Check formatting"),
:ok <- run("mix credo &> /dev/null", "3. Run credo"),
:ok <- run("mix dialyzer --quiet &> /dev/null", "4. Run dialyzer"),
:ok <- run("mix test --include slow &> /dev/null", "5. Run tests") do
Mix.shell().cmd("git push")
else
:error -> [:red, "Failed!"] |> IO.ANSI.format() |> IO.puts()
end
end
defp run(command, step) do
[:yellow, step, :reset, "\n$ #{command}\n"]
|> IO.ANSI.format()
|> IO.puts()
case Mix.shell().cmd(command) do
0 -> :ok
_ -> :error
end
end
defp escript do
[main_module: Weather.CLI, name: :weather, strip_beams: true, embed_elixir: true]
end
defp elixirc_paths(_), do: ["lib"]
end