-
Notifications
You must be signed in to change notification settings - Fork 3
/
mix.exs
129 lines (113 loc) · 3.39 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
defmodule LiveQchatex.MixProject do
use Mix.Project
@github_url "https://github.com/fiqus/lqchatex"
@demo_url "https://lqchatex.fiqus.coop"
@version "0.4.0"
def project do
[
app: :live_qchatex,
version: @version,
git_version: read_git_version(),
name: "LiveQchatex",
description:
"Very simple and quick chat engine that allows you to create and join chat rooms on-the-fly.",
source_url: @github_url,
homepage_url: @github_url,
demo_url: @demo_url,
elixir: "~> 1.9",
elixirc_paths: elixirc_paths(Mix.env()),
compilers: [:phoenix, :gettext] ++ Mix.compilers(),
start_permanent: Mix.env() == :prod,
deps: deps(),
releases: releases(),
aliases: aliases(),
test_coverage: [tool: ExCoveralls],
preferred_cli_env: [
coverage: :test,
coveralls: :test,
"coveralls.detail": :test,
"coveralls.post": :test,
"coveralls.html": :test
]
]
end
# Configuration for the OTP application.
#
# Type `mix help compile.app` for more information.
def application do
[
mod: {LiveQchatex.Application, []},
extra_applications: [:logger, :runtime_tools]
]
end
# Specifies which paths to compile per environment.
defp elixirc_paths(:test), do: ["lib", "test/support"]
defp elixirc_paths(_), do: ["lib"]
# Specifies your project dependencies.
#
# Type `mix help deps` for examples and options.
defp deps do
[
{:phoenix, "~> 1.4"},
{:phoenix_pubsub, "~> 1.1"},
{:phoenix_html, "~> 2.11"},
{:phoenix_live_reload, "~> 1.2", only: :dev},
{:phoenix_live_view, "~> 0.4"},
{:gettext, "~> 0.11"},
{:jason, "~> 1.0"},
{:plug_cowboy, "~> 2.0"},
{:guardian, "~> 1.0"},
{:excoveralls, "~> 0.10", only: :test},
{:memento, "~> 0.3"},
{:libcluster, "~> 3.0"}
]
end
# App releases configuration.
defp releases do
[
lqchatex: [
include_executables_for: [:unix, :windows],
applications: [runtime_tools: :permanent, live_qchatex: :permanent]
]
]
end
# Aliases are shortcuts or tasks specific to the current project.
defp aliases do
[
coverage: ["coveralls.html"],
"deps.get": ["deps.get", &update_git_version/1],
"mnesia.reset": fn _ -> reset_mnesia(Mix.env()) end
]
end
defp reset_mnesia(:prod), do: Mix.raise("Can't reset mnesia on production!")
defp reset_mnesia(_) do
Mix.shell().info("Removing '.mnesia' directory..")
Mix.shell().cmd("rm -rf .mnesia")
end
defp read_git_version() do
[vsn, hash, date] =
case File.read("VERSION") do
{:ok, data} -> data |> String.split("\n")
_ -> [@version, nil, nil]
end
%{vsn: vsn, hash: hash, date: date}
end
defp update_git_version(_) do
contents = [
@version,
get_commit_sha(),
get_commit_date()
]
Mix.shell().info("\e[33mUpdating app version with: #{inspect(contents)}\e[39m")
File.write("VERSION", Enum.join(contents, "\n"), [:write])
end
defp get_commit_sha(), do: System.cmd("git", ["rev-parse", "HEAD"]) |> elem(0) |> String.trim()
defp get_commit_date() do
[sec, tz] =
System.cmd("git", ~w|log -1 --date=raw --format=%cd|)
|> elem(0)
|> String.split(~r/\s+/, trim: true)
|> Enum.map(&String.to_integer/1)
DateTime.from_unix!(sec + tz * 36)
end
end