logo

pleroma

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

mix.exs (12227B)


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