Local copy of Pleroma, an ActivityPub server software. Contains modifications running live on fedi.underscore.world
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

281 lines
9.4KB

  1. defmodule Pleroma.Mixfile do
  2. use Mix.Project
  3. def project do
  4. [
  5. app: :pleroma,
  6. version: version("1.1.50"),
  7. elixir: "~> 1.8",
  8. elixirc_paths: elixirc_paths(Mix.env()),
  9. compilers: [:phoenix, :gettext] ++ Mix.compilers(),
  10. elixirc_options: [warnings_as_errors: warnings_as_errors(Mix.env())],
  11. xref: [exclude: [:eldap]],
  12. start_permanent: Mix.env() == :prod,
  13. aliases: aliases(),
  14. deps: deps(),
  15. test_coverage: [tool: ExCoveralls],
  16. preferred_cli_env: ["coveralls.html": :test],
  17. # Docs
  18. name: "Pleroma",
  19. homepage_url: "https://pleroma.social/",
  20. source_url: "https://git.underscore.world/d/pleroma",
  21. docs: [
  22. source_url_pattern:
  23. "https://git.pleroma.social/pleroma/pleroma/blob/develop/%{path}#L%{line}",
  24. logo: "priv/static/static/logo.png",
  25. extras: ["README.md", "CHANGELOG.md"] ++ Path.wildcard("docs/**/*.md"),
  26. groups_for_extras: [
  27. "Installation manuals": Path.wildcard("docs/installation/*.md"),
  28. Configuration: Path.wildcard("docs/config/*.md"),
  29. Administration: Path.wildcard("docs/admin/*.md"),
  30. "Pleroma's APIs and Mastodon API extensions": Path.wildcard("docs/api/*.md")
  31. ],
  32. main: "readme",
  33. output: "priv/static/doc"
  34. ],
  35. releases: [
  36. pleroma: [
  37. include_executables_for: [:unix],
  38. applications: [ex_syslogger: :load, syslog: :load],
  39. steps: [:assemble, &copy_files/1, &copy_nginx_config/1]
  40. ]
  41. ]
  42. ]
  43. end
  44. def copy_files(%{path: target_path} = release) do
  45. File.cp_r!("./rel/files", target_path)
  46. release
  47. end
  48. def copy_nginx_config(%{path: target_path} = release) do
  49. File.cp!(
  50. "./installation/pleroma.nginx",
  51. Path.join([target_path, "installation", "pleroma.nginx"])
  52. )
  53. release
  54. end
  55. # Configuration for the OTP application.
  56. #
  57. # Type `mix help compile.app` for more information.
  58. def application do
  59. [
  60. mod: {Pleroma.Application, []},
  61. extra_applications: [:logger, :runtime_tools, :comeonin, :quack, :fast_sanitize],
  62. included_applications: [:ex_syslogger]
  63. ]
  64. end
  65. # Specifies which paths to compile per environment.
  66. defp elixirc_paths(:benchmark), do: ["lib", "benchmarks"]
  67. defp elixirc_paths(:test), do: ["lib", "test/support"]
  68. defp elixirc_paths(_), do: ["lib"]
  69. defp warnings_as_errors(:prod), do: false
  70. # Uncomment this if you need testing configurable_from_database logic
  71. # defp warnings_as_errors(:dev), do: false
  72. defp warnings_as_errors(_), do: true
  73. # Specifies OAuth dependencies.
  74. defp oauth_deps do
  75. oauth_strategy_packages =
  76. System.get_env("OAUTH_CONSUMER_STRATEGIES")
  77. |> to_string()
  78. |> String.split()
  79. |> Enum.map(fn strategy_entry ->
  80. with [_strategy, dependency] <- String.split(strategy_entry, ":") do
  81. dependency
  82. else
  83. [strategy] -> "ueberauth_#{strategy}"
  84. end
  85. end)
  86. for s <- oauth_strategy_packages, do: {String.to_atom(s), ">= 0.0.0"}
  87. end
  88. # Specifies your project dependencies.
  89. #
  90. # Type `mix help deps` for examples and options.
  91. defp deps do
  92. [
  93. {:phoenix, "~> 1.4.8"},
  94. {:tzdata, "~> 0.5.21"},
  95. {:plug_cowboy, "~> 2.0"},
  96. {:phoenix_pubsub, "~> 1.1"},
  97. {:phoenix_ecto, "~> 4.0"},
  98. {:ecto_enum, "~> 1.4"},
  99. {:ecto_sql, "~> 3.3.2"},
  100. {:postgrex, ">= 0.13.5"},
  101. {:oban, "~> 0.12.1"},
  102. {:gettext, "~> 0.15"},
  103. {:comeonin, "~> 4.1.1"},
  104. {:pbkdf2_elixir, "~> 0.12.3"},
  105. {:trailing_format_plug, "~> 0.0.7"},
  106. {:fast_sanitize, "~> 0.1"},
  107. {:html_entities, "~> 0.5", override: true},
  108. {:phoenix_html, "~> 2.10"},
  109. {:calendar, "~> 0.17.4"},
  110. {:cachex, "~> 3.0.2"},
  111. {:poison, "~> 3.0", override: true},
  112. {:tesla, "~> 1.3", override: true},
  113. {:jason, "~> 1.0"},
  114. {:mogrify, "~> 0.6.1"},
  115. {:ex_aws, "~> 2.1"},
  116. {:ex_aws_s3, "~> 2.0"},
  117. {:sweet_xml, "~> 0.6.6"},
  118. {:earmark, "~> 1.3"},
  119. {:bbcode, "~> 0.1.1"},
  120. {:ex_machina, "~> 2.3", only: :test},
  121. {:credo, "~> 1.1.0", only: [:dev, :test], runtime: false},
  122. {:mock, "~> 0.3.3", only: :test},
  123. {:crypt,
  124. git: "https://github.com/msantos/crypt", ref: "1f2b58927ab57e72910191a7ebaeff984382a1d3"},
  125. {:cors_plug, "~> 1.5"},
  126. {:ex_doc, "~> 0.21", only: :dev, runtime: false},
  127. {:web_push_encryption, "~> 0.2.1"},
  128. {:swoosh, "~> 0.23.2"},
  129. {:phoenix_swoosh, "~> 0.2"},
  130. {:gen_smtp, "~> 0.13"},
  131. {:websocket_client, git: "https://github.com/jeremyong/websocket_client.git", only: :test},
  132. {:floki, "~> 0.23.0"},
  133. {:ex_syslogger, github: "slashmili/ex_syslogger", tag: "1.4.0"},
  134. {:timex, "~> 3.5"},
  135. {:ueberauth, "~> 0.4"},
  136. {:auto_linker,
  137. git: "https://git.pleroma.social/pleroma/auto_linker.git",
  138. ref: "95e8188490e97505c56636c1379ffdf036c1fdde"},
  139. {:http_signatures,
  140. git: "https://git.pleroma.social/pleroma/http_signatures.git",
  141. ref: "293d77bb6f4a67ac8bde1428735c3b42f22cbb30"},
  142. {:telemetry, "~> 0.3"},
  143. {:poolboy, "~> 1.5"},
  144. {:prometheus_ex, "~> 3.0"},
  145. {:prometheus_plugs, "~> 1.1"},
  146. {:prometheus_phoenix, "~> 1.3"},
  147. {:prometheus_ecto, "~> 1.4"},
  148. {:recon, github: "ferd/recon", tag: "2.4.0"},
  149. {:quack, "~> 0.1.1"},
  150. {:joken, "~> 2.0"},
  151. {:benchee, "~> 1.0"},
  152. {:esshd, "~> 0.1.0", runtime: Application.get_env(:esshd, :enabled, false)},
  153. {:ex_const, "~> 0.2"},
  154. {:plug_static_index_html, "~> 1.0.0"},
  155. {:excoveralls, "~> 0.12.1", only: :test},
  156. {:flake_id, "~> 0.1.0"},
  157. {:remote_ip,
  158. git: "https://git.pleroma.social/pleroma/remote_ip.git",
  159. ref: "825dc00aaba5a1b7c4202a532b696b595dd3bcb3"},
  160. {:captcha,
  161. git: "https://git.pleroma.social/pleroma/elixir-libraries/elixir-captcha.git",
  162. ref: "e0f16822d578866e186a0974d65ad58cddc1e2ab"},
  163. {:mox, "~> 0.5", only: :test},
  164. {:restarter, path: "./restarter"}
  165. ] ++ oauth_deps()
  166. end
  167. # Aliases are shortcuts or tasks specific to the current project.
  168. # For example, to create, migrate and run the seeds file at once:
  169. #
  170. # $ mix ecto.setup
  171. #
  172. # See the documentation for `Mix` for more info on aliases.
  173. defp aliases do
  174. [
  175. "ecto.migrate": ["pleroma.ecto.migrate"],
  176. "ecto.rollback": ["pleroma.ecto.rollback"],
  177. "ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"],
  178. "ecto.reset": ["ecto.drop", "ecto.setup"],
  179. test: ["ecto.create --quiet", "ecto.migrate", "test"],
  180. docs: ["pleroma.docs", "docs"]
  181. ]
  182. end
  183. # Builds a version string made of:
  184. # * the application version
  185. # * a pre-release if ahead of the tag: the describe string (-count-commithash)
  186. # * branch name
  187. # * build metadata:
  188. # * a build name if `PLEROMA_BUILD_NAME` or `:pleroma, :build_name` is defined
  189. # * the mix environment if different than prod
  190. defp version(version) do
  191. identifier_filter = ~r/[^0-9a-z\-]+/i
  192. # Pre-release version, denoted from patch version with a hyphen
  193. git_pre_release =
  194. with {tag, 0} <-
  195. System.cmd("git", ["describe", "--tags", "--abbrev=0"], stderr_to_stdout: true),
  196. {describe, 0} <- System.cmd("git", ["describe", "--tags", "--abbrev=8"]) do
  197. describe
  198. |> String.trim()
  199. |> String.replace(String.trim(tag), "")
  200. |> String.trim_leading("-")
  201. |> String.trim()
  202. else
  203. _ ->
  204. {commit_hash, 0} = System.cmd("git", ["rev-parse", "--short", "HEAD"])
  205. "0-g" <> String.trim(commit_hash)
  206. end
  207. # Branch name as pre-release version component, denoted with a dot
  208. branch_name =
  209. with {branch_name, 0} <- System.cmd("git", ["rev-parse", "--abbrev-ref", "HEAD"]),
  210. branch_name <- String.trim(branch_name),
  211. branch_name <- System.get_env("PLEROMA_BUILD_BRANCH") || branch_name,
  212. true <-
  213. !Enum.any?(["master", "HEAD", "release/", "stable"], fn name ->
  214. String.starts_with?(name, branch_name)
  215. end) do
  216. branch_name =
  217. branch_name
  218. |> String.trim()
  219. |> String.replace(identifier_filter, "-")
  220. branch_name
  221. end
  222. build_name =
  223. cond do
  224. name = Application.get_env(:pleroma, :build_name) -> name
  225. name = System.get_env("PLEROMA_BUILD_NAME") -> name
  226. true -> nil
  227. end
  228. env_name = if Mix.env() != :prod, do: to_string(Mix.env())
  229. env_override = System.get_env("PLEROMA_BUILD_ENV")
  230. env_name =
  231. case env_override do
  232. nil -> env_name
  233. env_override when env_override in ["", "prod"] -> nil
  234. env_override -> env_override
  235. end
  236. # Pre-release version, denoted by appending a hyphen
  237. # and a series of dot separated identifiers
  238. pre_release =
  239. [git_pre_release, branch_name]
  240. |> Enum.filter(fn string -> string && string != "" end)
  241. |> Enum.join(".")
  242. |> (fn
  243. "" -> nil
  244. string -> "-" <> String.replace(string, identifier_filter, "-")
  245. end).()
  246. # Build metadata, denoted with a plus sign
  247. build_metadata =
  248. [build_name, env_name]
  249. |> Enum.filter(fn string -> string && string != "" end)
  250. |> Enum.join(".")
  251. |> (fn
  252. "" -> nil
  253. string -> "+" <> String.replace(string, identifier_filter, "-")
  254. end).()
  255. [version, pre_release, build_metadata]
  256. |> Enum.filter(fn string -> string && string != "" end)
  257. |> Enum.join()
  258. end
  259. end