logo

pleroma

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

mix.exs (11756B)


  1. defmodule Pleroma.Mixfile do
  2. use Mix.Project
  3. def project do
  4. [
  5. app: :pleroma,
  6. version: version("2.6.52"),
  7. elixir: "~> 1.11",
  8. elixirc_paths: elixirc_paths(Mix.env()),
  9. compilers: Mix.compilers(),
  10. elixirc_options: [warnings_as_errors: warnings_as_errors()],
  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, &put_otp_version/1, &copy_files/1, &copy_nginx_config/1],
  39. config_providers: [{Pleroma.Config.ReleaseRuntimeProvider, []}]
  40. ]
  41. ]
  42. ]
  43. end
  44. def put_otp_version(%{path: target_path} = release) do
  45. File.write!(
  46. Path.join([target_path, "OTP_VERSION"]),
  47. Pleroma.OTPVersion.version()
  48. )
  49. release
  50. end
  51. def copy_files(%{path: target_path} = release) do
  52. File.cp_r!("./rel/files", target_path)
  53. release
  54. end
  55. def copy_nginx_config(%{path: target_path} = release) do
  56. File.cp!(
  57. "./installation/pleroma.nginx",
  58. Path.join([target_path, "installation", "pleroma.nginx"])
  59. )
  60. release
  61. end
  62. # Configuration for the OTP application.
  63. #
  64. # Type `mix help compile.app` for more information.
  65. def application do
  66. [
  67. mod: {Pleroma.Application, []},
  68. extra_applications: [
  69. :logger,
  70. :runtime_tools,
  71. :comeonin,
  72. :fast_sanitize,
  73. :os_mon,
  74. :ssl
  75. ],
  76. included_applications: [:ex_syslogger]
  77. ]
  78. end
  79. # Specifies which paths to compile per environment.
  80. defp elixirc_paths(:benchmark), do: ["lib", "benchmarks", "priv/scrubbers"]
  81. defp elixirc_paths(:test), do: ["lib", "test/support"]
  82. defp elixirc_paths(_), do: ["lib"]
  83. defp warnings_as_errors, do: System.get_env("CI") == "true"
  84. # Specifies OAuth dependencies.
  85. defp oauth_deps do
  86. oauth_strategy_packages =
  87. System.get_env("OAUTH_CONSUMER_STRATEGIES")
  88. |> to_string()
  89. |> String.split()
  90. |> Enum.map(fn strategy_entry ->
  91. with [_strategy, dependency] <- String.split(strategy_entry, ":") do
  92. dependency
  93. else
  94. [strategy] -> "ueberauth_#{strategy}"
  95. end
  96. end)
  97. for s <- oauth_strategy_packages, do: {String.to_atom(s), ">= 0.0.0"}
  98. end
  99. # Specifies your project dependencies.
  100. #
  101. # Type `mix help deps` for examples and options.
  102. defp deps do
  103. [
  104. {:phoenix, "~> 1.7.3"},
  105. {:phoenix_ecto, "~> 4.4"},
  106. {:ecto_sql, "~> 3.10"},
  107. {:ecto_enum, "~> 1.4"},
  108. {:postgrex, ">= 0.0.0"},
  109. {:phoenix_html, "~> 3.3"},
  110. {:phoenix_live_reload, "~> 1.3.3", only: :dev},
  111. {:phoenix_live_view, "~> 0.19.0"},
  112. {:phoenix_live_dashboard, "~> 0.8.0"},
  113. {:telemetry_metrics, "~> 0.6"},
  114. {:telemetry_poller, "~> 1.0"},
  115. {:tzdata, "~> 1.0.3"},
  116. {:plug_cowboy, "~> 2.5"},
  117. # oban 2.14 requires Elixir 1.12+
  118. {:oban, "~> 2.13.4"},
  119. {:gettext, "~> 0.20"},
  120. {:bcrypt_elixir, "~> 2.2"},
  121. {:trailing_format_plug, "~> 0.0.7"},
  122. {:fast_sanitize, "~> 0.2.0"},
  123. {:html_entities, "~> 0.5", override: true},
  124. {:calendar, "~> 1.0"},
  125. {:cachex, "~> 3.2"},
  126. {:poison, "~> 3.0", override: true},
  127. {:tesla, "~> 1.8.0"},
  128. {:castore, "~> 0.1"},
  129. {:cowlib, "~> 2.9", override: true},
  130. {:gun, "~> 2.0.0-rc.1", override: true},
  131. {:finch, "~> 0.15"},
  132. {:jason, "~> 1.2"},
  133. {:mogrify, "~> 0.8.0"},
  134. {:ex_aws, "~> 2.1.6"},
  135. {:ex_aws_s3, "~> 2.0"},
  136. {:sweet_xml, "~> 0.7.2"},
  137. # earmark 1.4.23 requires Elixir 1.12+
  138. {:earmark, "1.4.22"},
  139. {:bbcode_pleroma, "~> 0.2.0"},
  140. {:cors_plug, "~> 2.0"},
  141. {:web_push_encryption, "~> 0.3.1"},
  142. # swoosh 1.11.2+ requires Elixir 1.12+
  143. {:swoosh, "~> 1.10.0"},
  144. {:phoenix_swoosh, "~> 1.1"},
  145. {:gen_smtp, "~> 0.13"},
  146. {:ex_syslogger, "~> 1.4"},
  147. {:floki, "~> 0.35"},
  148. {:timex, "~> 3.6"},
  149. {:ueberauth, "~> 0.4"},
  150. {:linkify, git: "https://hacktivis.me/git/auto_linker.git", branch: "lanodan/master"},
  151. {:http_signatures, "~> 0.1.2"},
  152. {:telemetry, "~> 1.0.0", override: true},
  153. {:poolboy, "~> 1.5"},
  154. {:prom_ex, "~> 1.9"},
  155. {:recon, "~> 2.5"},
  156. {:joken, "~> 2.0"},
  157. {:pot, "~> 1.0"},
  158. {:ex_const, "~> 0.2"},
  159. {:plug_static_index_html, "~> 1.0.0"},
  160. {:flake_id, "~> 0.1.0"},
  161. {:concurrent_limiter, "~> 0.1.1"},
  162. {:remote_ip,
  163. git: "https://git.pleroma.social/pleroma/remote_ip.git",
  164. ref: "b647d0deecaa3acb140854fe4bda5b7e1dc6d1c8"},
  165. {:captcha,
  166. git: "https://git.pleroma.social/pleroma/elixir-libraries/elixir-captcha.git",
  167. ref: "90f6ce7672f70f56708792a98d98bd05176c9176"},
  168. {:restarter, path: "./restarter"},
  169. {:majic, "~> 1.0"},
  170. {:open_api_spex, "~> 3.16"},
  171. {:ecto_psql_extras, "~> 0.6"},
  172. {:vix, "~> 0.26.0"},
  173. {:elixir_make, "~> 0.7.7", override: true},
  174. {:blurhash, "~> 0.1.0", hex: :rinpatch_blurhash},
  175. {:exile,
  176. git: "https://git.pleroma.social/pleroma/elixir-libraries/exile.git",
  177. ref: "0d6337cf68e7fbc8a093cae000955aa93b067f91"},
  178. {:bandit, "~> 1.2"},
  179. ## dev & test
  180. {:ex_doc, "~> 0.22", only: :dev, runtime: false},
  181. {:ex_machina, "~> 2.4", only: :test},
  182. {:credo, "~> 1.6", only: [:dev, :test], runtime: false},
  183. {:mock, "~> 0.3.5", only: :test},
  184. {:covertool, "~> 2.0", only: :test},
  185. {:hackney, "~> 1.18.0", override: true},
  186. {:mox, "~> 1.0", only: :test},
  187. {:websockex, "~> 0.4.3", only: :test},
  188. {:benchee, "~> 1.0", only: :benchmark},
  189. {:dialyxir, "~> 1.4", only: [:dev, :test], runtime: false}
  190. ] ++ oauth_deps()
  191. end
  192. # Aliases are shortcuts or tasks specific to the current project.
  193. # For example, to create, migrate and run the seeds file at once:
  194. #
  195. # $ mix ecto.setup
  196. #
  197. # See the documentation for `Mix` for more info on aliases.
  198. defp aliases do
  199. [
  200. "ecto.migrate": ["pleroma.ecto.migrate"],
  201. "ecto.rollback": ["pleroma.ecto.rollback"],
  202. "ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"],
  203. "ecto.reset": ["ecto.drop", "ecto.setup"],
  204. test: ["ecto.create --quiet", "ecto.migrate", "test"],
  205. docs: ["pleroma.docs", "docs"],
  206. analyze: ["credo --strict --only=warnings,todo,fixme,consistency,readability"],
  207. copyright: &add_copyright/1,
  208. "copyright.bump": &bump_copyright/1
  209. ]
  210. end
  211. # Builds a version string made of:
  212. # * the application version
  213. # * a pre-release if ahead of the tag: the describe string (-count-commithash)
  214. # * branch name
  215. # * build metadata:
  216. # * a build name if `PLEROMA_BUILD_NAME` or `:pleroma, :build_name` is defined
  217. # * the mix environment if different than prod
  218. defp version(version) do
  219. identifier_filter = ~r/[^0-9a-z\-]+/i
  220. git_available? = match?({_output, 0}, System.cmd("sh", ["-c", "command -v git"]))
  221. dotgit_present? = File.exists?(".git")
  222. git_pre_release =
  223. if git_available? and dotgit_present? do
  224. {tag, tag_err} =
  225. System.cmd("git", ["describe", "--tags", "--abbrev=0"], stderr_to_stdout: true)
  226. {describe, describe_err} = System.cmd("git", ["describe", "--tags", "--abbrev=8"])
  227. {commit_hash, commit_hash_err} = System.cmd("git", ["rev-parse", "--short", "HEAD"])
  228. # Pre-release version, denoted from patch version with a hyphen
  229. cond do
  230. tag_err == 0 and describe_err == 0 ->
  231. describe
  232. |> String.trim()
  233. |> String.replace(String.trim(tag), "")
  234. |> String.trim_leading("-")
  235. |> String.trim()
  236. commit_hash_err == 0 ->
  237. "0-g" <> String.trim(commit_hash)
  238. true ->
  239. nil
  240. end
  241. end
  242. # Branch name as pre-release version component, denoted with a dot
  243. branch_name =
  244. with true <- git_available?,
  245. true <- dotgit_present?,
  246. {branch_name, 0} <- System.cmd("git", ["rev-parse", "--abbrev-ref", "HEAD"]),
  247. branch_name <- String.trim(branch_name),
  248. branch_name <- System.get_env("PLEROMA_BUILD_BRANCH") || branch_name,
  249. true <-
  250. !Enum.any?(["master", "HEAD", "release/", "stable"], fn name ->
  251. String.starts_with?(name, branch_name)
  252. end) do
  253. branch_name =
  254. branch_name
  255. |> String.trim()
  256. |> String.replace(identifier_filter, "-")
  257. branch_name
  258. else
  259. _ -> ""
  260. end
  261. build_name =
  262. cond do
  263. name = Application.get_env(:pleroma, :build_name) -> name
  264. name = System.get_env("PLEROMA_BUILD_NAME") -> name
  265. true -> nil
  266. end
  267. env_name = if Mix.env() != :prod, do: to_string(Mix.env())
  268. env_override = System.get_env("PLEROMA_BUILD_ENV")
  269. env_name =
  270. case env_override do
  271. nil -> env_name
  272. env_override when env_override in ["", "prod"] -> nil
  273. env_override -> env_override
  274. end
  275. # Pre-release version, denoted by appending a hyphen
  276. # and a series of dot separated identifiers
  277. pre_release =
  278. [git_pre_release, branch_name]
  279. |> Enum.filter(fn string -> string && string != "" end)
  280. |> Enum.join(".")
  281. |> (fn
  282. "" -> nil
  283. string -> "-" <> String.replace(string, identifier_filter, "-")
  284. end).()
  285. # Build metadata, denoted with a plus sign
  286. build_metadata =
  287. [build_name, env_name]
  288. |> Enum.filter(fn string -> string && string != "" end)
  289. |> Enum.join(".")
  290. |> (fn
  291. "" -> nil
  292. string -> "+" <> String.replace(string, identifier_filter, "-")
  293. end).()
  294. [version, pre_release, build_metadata]
  295. |> Enum.filter(fn string -> string && string != "" end)
  296. |> Enum.join()
  297. end
  298. defp add_copyright(_) do
  299. year = NaiveDateTime.utc_now().year
  300. template = ~s[\
  301. # Pleroma: A lightweight social networking server
  302. # Copyright © 2017-#{year} Pleroma Authors <https://pleroma.social/>
  303. # SPDX-License-Identifier: AGPL-3.0-only
  304. ] |> String.replace("\n", "\\n")
  305. find = "find lib test priv -type f \\( -name '*.ex' -or -name '*.exs' \\) -exec "
  306. grep = "grep -L '# Copyright © [0-9\-]* Pleroma' {} \\;"
  307. xargs = "xargs -n1 sed -i'' '1s;^;#{template};'"
  308. :os.cmd(String.to_charlist("#{find}#{grep} | #{xargs}"))
  309. end
  310. defp bump_copyright(_) do
  311. year = NaiveDateTime.utc_now().year
  312. find = "find lib test priv -type f \\( -name '*.ex' -or -name '*.exs' \\)"
  313. xargs =
  314. "xargs sed -i'' 's;# Copyright © [0-9\-]* Pleroma.*$;# Copyright © 2017-#{year} Pleroma Authors <https://pleroma.social/>;'"
  315. :os.cmd(String.to_charlist("#{find} | #{xargs}"))
  316. end
  317. end