aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/mix/tasks/pleroma/frontend.ex22
-rw-r--r--mix.exs6
-rw-r--r--test/tasks/frontend_test.exs43
3 files changed, 51 insertions, 20 deletions
diff --git a/lib/mix/tasks/pleroma/frontend.ex b/lib/mix/tasks/pleroma/frontend.ex
index a17e875d0..2f4bdf1b4 100644
--- a/lib/mix/tasks/pleroma/frontend.ex
+++ b/lib/mix/tasks/pleroma/frontend.ex
@@ -147,10 +147,26 @@ defmodule Mix.Tasks.Pleroma.Frontend do
%{status: 200, body: json} = Tesla.get!(http_client(), url)
- %{"name" => ref, "commit" => %{"short_id" => last_commit_ref}} =
- Enum.find(json, & &1["default"])
+ %{"commit" => %{"short_id" => last_commit_ref}} = Enum.find(json, & &1["default"])
- %{"ref" => ref, "url" => build_url(frontend, last_commit_ref)}
+ %{"ref" => last_commit_ref, "url" => build_url(frontend, last_commit_ref)}
+ end
+
+ # fallback to develop version if compatible stable ref is not defined in
+ # mix.exs for the given frontend
+ defp get_frontend_metadata(frontend, @ref_stable) do
+ ref =
+ Map.get(
+ Pleroma.Application.frontends(),
+ frontend,
+ get_frontend_metadata(frontend, @ref_develop)
+ )
+
+ %{"ref" => ref, "url" => build_url(frontend, ref)}
+ end
+
+ defp get_frontend_metadata(frontend, ref) do
+ %{"ref" => ref, "url" => build_url(frontend, ref)}
end
defp project_url(frontend),
diff --git a/mix.exs b/mix.exs
index 7d5725da2..2de1a32e9 100644
--- a/mix.exs
+++ b/mix.exs
@@ -40,7 +40,11 @@ defmodule Pleroma.Mixfile do
applications: [ex_syslogger: :load, syslog: :load, eldap: :transient],
steps: [:assemble, &put_otp_version/1, &copy_files/1, &copy_nginx_config/1]
]
- ]
+ ],
+ frontends: %{
+ "pleroma" => "5d49edc8",
+ "mastodon" => "b1e42686"
+ }
]
end
diff --git a/test/tasks/frontend_test.exs b/test/tasks/frontend_test.exs
index 55193df67..c544bf220 100644
--- a/test/tasks/frontend_test.exs
+++ b/test/tasks/frontend_test.exs
@@ -71,21 +71,32 @@ defmodule Mix.Tasks.Pleroma.FrontendTest do
end
end
- test "Installation from web, pre-built packages" do
- frontends = ~w(pleroma kenoma mastodon admin)
- refs = ~w(develop stable 1.2.3)
-
- Enum.each(frontends, fn frontend ->
- Enum.each(refs, fn ref ->
- Mix.Tasks.Pleroma.Frontend.run([
- "install",
- frontend,
- "--ref",
- ref
- ])
-
- assert File.exists?(Path.join([@dir, "frontends/#{frontend}/#{ref}/index.html"]))
- end)
- end)
+ describe "Installation from web, pre-built packages" do
+ test "develop" do
+ Mix.Tasks.Pleroma.Frontend.run([
+ "install",
+ "pleroma",
+ "--develop"
+ ])
+
+ assert File.exists?(Path.join([@dir, "frontends/pleroma/d5457c32/index.html"]))
+ end
+
+ test "stable" do
+ Mix.Tasks.Pleroma.Frontend.run(["install", "pleroma"])
+
+ assert File.exists?(Path.join([@dir, "frontends/pleroma/5d49edc8/index.html"]))
+ end
+
+ test "ref" do
+ Mix.Tasks.Pleroma.Frontend.run([
+ "install",
+ "pleroma",
+ "--ref",
+ "1.2.3"
+ ])
+
+ assert File.exists?(Path.join([@dir, "frontends/pleroma/1.2.3/index.html"]))
+ end
end
end