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,
|
ref: :string,
|
||||||
build_url: :string,
|
build_url: :string,
|
||||||
build_dir: :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()
|
|> opts_to_frontend()
|
||||||
|> Frontend.install() do
|
|> Frontend.install() do
|
||||||
shell_info("Frontend #{fe.name} installed")
|
shell_info("Frontend #{fe.name} installed")
|
||||||
|
|
||||||
|
if get_frontend_type(options) do
|
||||||
|
run(["enable", name] ++ args)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
error ->
|
error ->
|
||||||
shell_error("Failed to install frontend")
|
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}...")
|
shell_info("Enabling frontend #{name}...")
|
||||||
|
|
||||||
@ -92,8 +98,11 @@ defmodule Mix.Tasks.Pleroma.Frontend do
|
|||||||
%{admin: true} ->
|
%{admin: true} ->
|
||||||
:admin
|
:admin
|
||||||
|
|
||||||
_ ->
|
%{primary: true} ->
|
||||||
:primary
|
:primary
|
||||||
|
|
||||||
|
_ ->
|
||||||
|
nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -39,6 +39,28 @@ defmodule Mix.Tasks.Pleroma.FrontendTest do
|
|||||||
assert File.exists?(Path.join([@dir, "frontends", "pleroma", "fantasy", "test.txt"]))
|
assert File.exists?(Path.join([@dir, "frontends", "pleroma", "fantasy", "test.txt"]))
|
||||||
end
|
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
|
test "it also works given a file" do
|
||||||
clear_config([:frontends, :available], %{
|
clear_config([:frontends, :available], %{
|
||||||
"pleroma" => %{
|
"pleroma" => %{
|
||||||
@ -104,7 +126,10 @@ defmodule Mix.Tasks.Pleroma.FrontendTest do
|
|||||||
|
|
||||||
test "raise if configurable_from_database is disabled" do
|
test "raise if configurable_from_database is disabled" do
|
||||||
clear_config(:configurable_from_database, false)
|
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
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user