Enable a frontend automatically with --primary
arg
This commit is contained in:
parent
9a768429a3
commit
8527faecf5
@ -28,7 +28,9 @@ defmodule Mix.Tasks.Pleroma.Frontend do
|
||||
ref: :string,
|
||||
build_url: :string,
|
||||
build_dir: :string,
|
||||
file: :string
|
||||
file: :string,
|
||||
admin: :boolean,
|
||||
primary: :boolean
|
||||
]
|
||||
)
|
||||
|
||||
@ -40,6 +42,10 @@ defmodule Mix.Tasks.Pleroma.Frontend do
|
||||
|> opts_to_frontend()
|
||||
|> Frontend.install() do
|
||||
shell_info("Frontend #{fe.name} installed")
|
||||
|
||||
if get_frontend_type(options) do
|
||||
run(["enable", name] ++ args)
|
||||
end
|
||||
else
|
||||
error ->
|
||||
shell_error("Failed to install frontend")
|
||||
@ -63,7 +69,7 @@ defmodule Mix.Tasks.Pleroma.Frontend do
|
||||
]
|
||||
)
|
||||
|
||||
frontend_type = get_frontend_type(options)
|
||||
frontend_type = get_frontend_type(options) || :primary
|
||||
|
||||
shell_info("Enabling frontend #{name}...")
|
||||
|
||||
@ -92,8 +98,11 @@ defmodule Mix.Tasks.Pleroma.Frontend do
|
||||
%{admin: true} ->
|
||||
:admin
|
||||
|
||||
_ ->
|
||||
%{primary: true} ->
|
||||
:primary
|
||||
|
||||
_ ->
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -39,6 +39,28 @@ defmodule Mix.Tasks.Pleroma.FrontendTest do
|
||||
assert File.exists?(Path.join([@dir, "frontends", "pleroma", "fantasy", "test.txt"]))
|
||||
end
|
||||
|
||||
test "it enables a frontend with the --primary flag" do
|
||||
frontend = %Pleroma.Frontend{
|
||||
ref: "fantasy",
|
||||
name: "pleroma",
|
||||
build_url: "http://gensokyo.2hu/builds/${ref}"
|
||||
}
|
||||
|
||||
map = Pleroma.Frontend.to_map(frontend)
|
||||
clear_config(:configurable_from_database, true)
|
||||
clear_config([:frontends, :available], %{"pleroma" => map})
|
||||
|
||||
Tesla.Mock.mock(fn %{url: "http://gensokyo.2hu/builds/fantasy"} ->
|
||||
%Tesla.Env{status: 200, body: File.read!("test/fixtures/tesla_mock/frontend_dist.zip")}
|
||||
end)
|
||||
|
||||
capture_io(fn ->
|
||||
Frontend.run(["install", "pleroma", "--primary"])
|
||||
end)
|
||||
|
||||
assert Pleroma.Config.get([:frontends, :primary]) == map
|
||||
end
|
||||
|
||||
test "it also works given a file" do
|
||||
clear_config([:frontends, :available], %{
|
||||
"pleroma" => %{
|
||||
@ -104,7 +126,10 @@ defmodule Mix.Tasks.Pleroma.FrontendTest do
|
||||
|
||||
test "raise if configurable_from_database is disabled" do
|
||||
clear_config(:configurable_from_database, false)
|
||||
assert_raise(RuntimeError, fn -> Frontend.run(["enable", "soapbox-fe"]) end)
|
||||
|
||||
assert_raise(RuntimeError, fn ->
|
||||
capture_io(fn -> Frontend.run(["enable", "soapbox-fe"]) end)
|
||||
end)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user