logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://anongit.hacktivis.me/git/pleroma.git/

mix.exs (12144B)


  1. defmodule Pleroma.Mixfile do
  2. use Mix.Project
  3. def project do
  4. [
  5. app: :pleroma,
  6. version: version("2.10.0"),
  7. elixir: "~> 1.15",
  8. elixirc_paths: elixirc_paths(Mix.env()),
  9. compilers: Mix.compilers(),
  10. elixirc_options: [warnings_as_errors: warnings_as_errors(), prune_code_paths: false],
  11. xref: [exclude: [:eldap]],
  12. dialyzer: [plt_add_apps: [:mix, :eldap]],
  13. start_permanent: Mix.env() == :prod,
  14. aliases: aliases(),
  15. deps: deps(),
  16. test_coverage: [tool: :covertool, summary: true],
  17. # Docs
  18. name: "Pleroma",
  19. homepage_url: "https://pleroma.social/",
  20. source_url: "https://hacktivis.me/git/pleroma",
  21. docs: [
  22. source_url_pattern: "https://hacktivis.me/git/pleroma/files/%{path}#L%{line}",
  23. logo: "priv/static/images/logo.png",
  24. extras: ["README.md", "CHANGELOG.md"] ++ Path.wildcard("docs/**/*.md"),
  25. groups_for_extras: [
  26. "Installation manuals": Path.wildcard("docs/installation/*.md"),
  27. Configuration: Path.wildcard("docs/config/*.md"),
  28. Administration: Path.wildcard("docs/admin/*.md"),
  29. "Pleroma's APIs and Mastodon API extensions": Path.wildcard("docs/api/*.md")
  30. ],
  31. main: "readme",
  32. output: "priv/static/doc"
  33. ],
  34. releases: [
  35. pleroma: [
  36. include_executables_for: [:unix],
  37. applications: [ex_syslogger: :load, syslog: :load, eldap: :transient],
  38. steps: [:assemble, &copy_files/1, &copy_nginx_config/1],
  39. config_providers: [{Pleroma.Config.ReleaseRuntimeProvider, []}]
  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:
  62. [
  63. :logger,
  64. :runtime_tools,
  65. :comeonin,
  66. :fast_sanitize,
  67. :os_mon,
  68. :ssl,
  69. :eldap
  70. ] ++ logger_application(),
  71. included_applications: [:ex_syslogger]
  72. ]
  73. end
  74. # Specifies which paths to compile per environment.
  75. defp elixirc_paths(:benchmark), do: ["lib", "benchmarks", "priv/scrubbers"]
  76. defp elixirc_paths(:test), do: ["lib", "test/support"]
  77. defp elixirc_paths(_), do: ["lib"]
  78. defp warnings_as_errors, do: System.get_env("CI") == "true"
  79. # Specifies OAuth dependencies.
  80. defp oauth_deps do
  81. oauth_strategy_packages =
  82. System.get_env("OAUTH_CONSUMER_STRATEGIES")
  83. |> to_string()
  84. |> String.split()
  85. |> Enum.map(fn strategy_entry ->
  86. with [_strategy, dependency] <- String.split(strategy_entry, ":") do
  87. dependency
  88. else
  89. [strategy] -> "ueberauth_#{strategy}"
  90. end
  91. end)
  92. for s <- oauth_strategy_packages, do: {String.to_atom(s), ">= 0.0.0"}
  93. end
  94. defp logger_application do
  95. if Version.match?(System.version(), "<1.15.0-rc.0") do
  96. []
  97. else
  98. [:logger_backends]
  99. end
  100. end
  101. defp logger_deps do
  102. if Version.match?(System.version(), "<1.15.0-rc.0") do
  103. []
  104. else
  105. [{:logger_backends, "~> 1.0"}]
  106. end
  107. end
  108. # Specifies your project dependencies.
  109. #
  110. # Type `mix help deps` for examples and options.
  111. defp deps do
  112. [
  113. {:phoenix, "~> 1.8.0"},
  114. {:phoenix_ecto, "~> 4.4"},
  115. {:ecto_sql, "~> 3.10"},
  116. {:ecto_enum, "~> 1.4"},
  117. {:postgrex, ">= 0.20.0"},
  118. {:phoenix_html, "~> 3.3"},
  119. {:phoenix_live_view, "~> 1.1.0"},
  120. {:phoenix_live_dashboard, "~> 0.8.0"},
  121. {:telemetry_metrics, "~> 0.6"},
  122. {:telemetry_poller, "~> 1.0"},
  123. {:tzdata, "~> 1.0.3"},
  124. {:plug_cowboy, "~> 2.7"},
  125. {:oban, "~> 2.19.0"},
  126. {:oban_plugins_lazarus,
  127. git: "https://git.pleroma.social/pleroma/elixir-libraries/oban_plugins_lazarus.git",
  128. ref: "e49fc355baaf0e435208bf5f534d31e26e897711"},
  129. {:oban_web, "~> 2.11"},
  130. {:gettext, "~> 0.20"},
  131. {:bcrypt_elixir, "~> 2.2"},
  132. {:trailing_format_plug, "~> 0.0.7"},
  133. {:fast_sanitize, "~> 0.2.0"},
  134. {:html_entities, "~> 0.5", override: true},
  135. {:calendar, "~> 1.0"},
  136. {:cachex, "~> 3.2"},
  137. {:tesla, "~> 1.11"},
  138. {:castore, "~> 1.0"},
  139. {:cowlib, "~> 2.15"},
  140. {:gun, "~> 2.2"},
  141. {:finch, "~> 0.15"},
  142. {:jason, "~> 1.2"},
  143. {:mogrify, "~> 0.9.0", override: "true"},
  144. {:ex_aws, "~> 2.1.6"},
  145. {:ex_aws_s3, "~> 2.0"},
  146. {:sweet_xml, "~> 0.7.2"},
  147. {:earmark, "1.4.46"},
  148. {:bbcode_pleroma, "~> 0.2.0"},
  149. {:cors_plug, "~> 2.0"},
  150. {:web_push_encryption, "~> 0.3.1"},
  151. {:swoosh, "~> 1.16.9"},
  152. {:phoenix_swoosh, "~> 1.1"},
  153. {:gen_smtp, "~> 0.13"},
  154. {:mua, "~> 0.2.0"},
  155. {:mail, "~> 0.3.0"},
  156. {:ex_syslogger, "~> 1.4"},
  157. {:floki, "~> 0.35"},
  158. {:timex, "~> 3.6"},
  159. {:ueberauth, "~> 0.4"},
  160. {:linkify, git: "https://hacktivis.me/git/auto_linker.git", branch: "lanodan/master"},
  161. {:http_signatures, "~> 0.1.2"},
  162. {:telemetry, "~> 1.0.0", override: true},
  163. {:poolboy, "~> 1.5"},
  164. {:prom_ex, "~> 1.9"},
  165. {:recon, "~> 2.5"},
  166. {:joken, "~> 2.0"},
  167. {:pot, "~> 1.0"},
  168. {:ex_const, "~> 0.2"},
  169. {:plug_static_index_html, "~> 1.0.0"},
  170. {:flake_id, "~> 0.1.0"},
  171. {:concurrent_limiter, "~> 0.1.1"},
  172. {:remote_ip,
  173. git: "https://git.pleroma.social/pleroma/remote_ip.git",
  174. ref: "b647d0deecaa3acb140854fe4bda5b7e1dc6d1c8"},
  175. {:captcha,
  176. git: "https://git.pleroma.social/pleroma/elixir-libraries/elixir-captcha.git",
  177. ref: "e7b7cc34cc16b383461b966484c297e4ec9aeef6"},
  178. {:restarter, path: "./restarter"},
  179. {:majic, "~> 1.0"},
  180. {:open_api_spex, "~> 3.16"},
  181. {:ecto_psql_extras, "~> 0.8"},
  182. {:vix, "~> 0.36"},
  183. {:elixir_make, "~> 0.7.7", override: true},
  184. {:blurhash, "~> 0.1.0", hex: :rinpatch_blurhash},
  185. {:exile, "~> 0.10.0"},
  186. {:bandit, "~> 1.5.2"},
  187. {:websock_adapter, "~> 0.5.6"},
  188. {:oban_live_dashboard, "~> 0.1.1"},
  189. {:multipart, "~> 0.4.0", optional: true},
  190. {:argon2_elixir, "~> 4.0"},
  191. ## dev & test
  192. {:phoenix_live_reload, "~> 1.3.3", only: :dev},
  193. {:poison, "~> 3.0", only: :test},
  194. {:ex_doc, "~> 0.22", only: :dev, runtime: false},
  195. {:ex_machina, "~> 2.4", only: :test},
  196. {:credo, "~> 1.7", only: [:dev, :test], runtime: false},
  197. {:mock, "~> 0.3.5", only: :test},
  198. {:covertool, "~> 2.0", only: :test},
  199. {:hackney, "~> 1.18.0", override: true},
  200. {:mox, "~> 1.0", only: :test},
  201. {:websockex, "~> 0.4.3", only: :test},
  202. {:benchee, "~> 1.0", only: :benchmark},
  203. {:dialyxir, "~> 1.4", only: [:dev, :test], runtime: false}
  204. ] ++ oauth_deps() ++ logger_deps()
  205. end
  206. # Aliases are shortcuts or tasks specific to the current project.
  207. # For example, to create, migrate and run the seeds file at once:
  208. #
  209. # $ mix ecto.setup
  210. #
  211. # See the documentation for `Mix` for more info on aliases.
  212. defp aliases do
  213. [
  214. "ecto.migrate": ["pleroma.ecto.migrate"],
  215. "ecto.rollback": ["pleroma.ecto.rollback"],
  216. "ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"],
  217. "ecto.reset": ["ecto.drop", "ecto.setup"],
  218. test: ["ecto.create --quiet", "pleroma.ecto.migrate --quiet", "test --warnings-as-errors"],
  219. docs: ["pleroma.docs", "docs"],
  220. analyze: ["credo --strict --only=warnings,todo,fixme,consistency,readability"],
  221. copyright: &add_copyright/1,
  222. "copyright.bump": &bump_copyright/1
  223. ]
  224. end
  225. # Builds a version string made of:
  226. # * the application version
  227. # * a pre-release if ahead of the tag: the describe string (-count-commithash)
  228. # * branch name
  229. # * build metadata:
  230. # * a build name if `PLEROMA_BUILD_NAME` or `:pleroma, :build_name` is defined
  231. # * the mix environment if different than prod
  232. defp version(version) do
  233. identifier_filter = ~r/[^0-9a-z\-]+/i
  234. git_available? = match?({_output, 0}, System.cmd("sh", ["-c", "command -v git"]))
  235. dotgit_present? = File.exists?(".git")
  236. git_pre_release =
  237. if git_available? and dotgit_present? do
  238. {tag, tag_err} =
  239. System.cmd("git", ["describe", "--tags", "--abbrev=0"], stderr_to_stdout: true)
  240. {describe, describe_err} = System.cmd("git", ["describe", "--tags", "--abbrev=8"])
  241. {commit_hash, commit_hash_err} = System.cmd("git", ["rev-parse", "--short", "HEAD"])
  242. # Pre-release version, denoted from patch version with a hyphen
  243. cond do
  244. tag_err == 0 and describe_err == 0 ->
  245. describe
  246. |> String.trim()
  247. |> String.replace(String.trim(tag), "")
  248. |> String.trim_leading("-")
  249. |> String.trim()
  250. commit_hash_err == 0 ->
  251. "0-g" <> String.trim(commit_hash)
  252. true ->
  253. nil
  254. end
  255. end
  256. # Branch name as pre-release version component, denoted with a dot
  257. branch_name =
  258. with true <- git_available?,
  259. true <- dotgit_present?,
  260. {branch_name, 0} <- System.cmd("git", ["rev-parse", "--abbrev-ref", "HEAD"]),
  261. branch_name <- String.trim(branch_name),
  262. branch_name <- System.get_env("PLEROMA_BUILD_BRANCH") || branch_name,
  263. true <-
  264. !Enum.any?(["master", "HEAD", "release/", "stable"], fn name ->
  265. String.starts_with?(name, branch_name)
  266. end) do
  267. branch_name =
  268. branch_name
  269. |> String.trim()
  270. |> String.replace(identifier_filter, "-")
  271. branch_name
  272. else
  273. _ -> ""
  274. end
  275. build_name =
  276. cond do
  277. name = Application.get_env(:pleroma, :build_name) -> name
  278. name = System.get_env("PLEROMA_BUILD_NAME") -> name
  279. true -> nil
  280. end
  281. env_name = if Mix.env() != :prod, do: to_string(Mix.env())
  282. env_override = System.get_env("PLEROMA_BUILD_ENV")
  283. env_name =
  284. case env_override do
  285. nil -> env_name
  286. env_override when env_override in ["", "prod"] -> nil
  287. env_override -> env_override
  288. end
  289. # Pre-release version, denoted by appending a hyphen
  290. # and a series of dot separated identifiers
  291. pre_release =
  292. [git_pre_release, branch_name]
  293. |> Enum.filter(fn string -> string && string != "" end)
  294. |> Enum.join(".")
  295. |> (fn
  296. "" -> nil
  297. string -> "-" <> String.replace(string, identifier_filter, "-")
  298. end).()
  299. # Build metadata, denoted with a plus sign
  300. build_metadata =
  301. [build_name, env_name]
  302. |> Enum.filter(fn string -> string && string != "" end)
  303. |> Enum.join(".")
  304. |> (fn
  305. "" -> nil
  306. string -> "+" <> String.replace(string, identifier_filter, "-")
  307. end).()
  308. [version, pre_release, build_metadata]
  309. |> Enum.filter(fn string -> string && string != "" end)
  310. |> Enum.join()
  311. end
  312. defp add_copyright(_) do
  313. year = NaiveDateTime.utc_now().year
  314. template = ~s[\
  315. # Pleroma: A lightweight social networking server
  316. # Copyright © 2017-#{year} Pleroma Authors <https://pleroma.social/>
  317. # SPDX-License-Identifier: AGPL-3.0-only
  318. ] |> String.replace("\n", "\\n")
  319. find = "find lib test priv -type f \\( -name '*.ex' -or -name '*.exs' \\) -exec "
  320. grep = "grep -L '# Copyright © [0-9\-]* Pleroma' {} \\;"
  321. xargs = "xargs -n1 sed -i'' '1s;^;#{template};'"
  322. :os.cmd(String.to_charlist("#{find}#{grep} | #{xargs}"))
  323. end
  324. defp bump_copyright(_) do
  325. year = NaiveDateTime.utc_now().year
  326. find = "find lib test priv -type f \\( -name '*.ex' -or -name '*.exs' \\)"
  327. xargs =
  328. "xargs sed -i'' 's;# Copyright © [0-9\-]* Pleroma.*$;# Copyright © 2017-#{year} Pleroma Authors <https://pleroma.social/>;'"
  329. :os.cmd(String.to_charlist("#{find} | #{xargs}"))
  330. end
  331. end