This commit is contained in:
Maksim Pechnikov 2020-08-08 06:49:19 +03:00
parent cf53e300f8
commit 2030ffd490
3 changed files with 22 additions and 3 deletions

View File

@ -41,3 +41,4 @@ If any of the options are left unspecified, you will be prompted interactively.
- `--anonymize-uploads <Y|N>` - randomize uploaded filenames - `--anonymize-uploads <Y|N>` - randomize uploaded filenames
- `--dedupe-uploads <Y|N>` - store files based on their hash to reduce data storage requirements if duplicates are uploaded with different filenames - `--dedupe-uploads <Y|N>` - store files based on their hash to reduce data storage requirements if duplicates are uploaded with different filenames
- `--skip-release-env` - skip generation the release environment file - `--skip-release-env` - skip generation the release environment file
- `--release-env-file` - release environment file path

View File

@ -37,7 +37,8 @@ defmodule Mix.Tasks.Pleroma.Instance do
strip_uploads: :string, strip_uploads: :string,
anonymize_uploads: :string, anonymize_uploads: :string,
dedupe_uploads: :string, dedupe_uploads: :string,
skip_release_env: :boolean skip_release_env: :boolean,
release_env_file: :string
], ],
aliases: [ aliases: [
o: :output, o: :output,
@ -249,7 +250,15 @@ defmodule Mix.Tasks.Pleroma.Instance do
""") """)
else else
shell_info("Generation the environment file:") shell_info("Generation the environment file:")
Mix.Tasks.Pleroma.ReleaseEnv.run(["gen"])
release_env_args =
with path when not is_nil(path) <- Keyword.get(options, :release_env_file) do
["gen", "--path", path]
else
_ -> ["gen"]
end
Mix.Tasks.Pleroma.ReleaseEnv.run(release_env_args)
end end
shell_info( shell_info(

View File

@ -5,6 +5,8 @@
defmodule Mix.Tasks.Pleroma.InstanceTest do defmodule Mix.Tasks.Pleroma.InstanceTest do
use ExUnit.Case use ExUnit.Case
@release_env_file "./test/pleroma.test.env"
setup do setup do
File.mkdir_p!(tmp_path()) File.mkdir_p!(tmp_path())
@ -16,6 +18,8 @@ defmodule Mix.Tasks.Pleroma.InstanceTest do
File.rm_rf(Path.join(static_dir, "robots.txt")) File.rm_rf(Path.join(static_dir, "robots.txt"))
end end
if File.exists?(@release_env_file), do: File.rm_rf(@release_env_file)
Pleroma.Config.put([:instance, :static_dir], static_dir) Pleroma.Config.put([:instance, :static_dir], static_dir)
end) end)
@ -69,7 +73,9 @@ defmodule Mix.Tasks.Pleroma.InstanceTest do
"--dedupe-uploads", "--dedupe-uploads",
"n", "n",
"--anonymize-uploads", "--anonymize-uploads",
"n" "n",
"--release-env-file",
@release_env_file
]) ])
end end
@ -91,6 +97,9 @@ defmodule Mix.Tasks.Pleroma.InstanceTest do
assert generated_config =~ "filters: [Pleroma.Upload.Filter.ExifTool]" assert generated_config =~ "filters: [Pleroma.Upload.Filter.ExifTool]"
assert File.read!(tmp_path() <> "setup.psql") == generated_setup_psql() assert File.read!(tmp_path() <> "setup.psql") == generated_setup_psql()
assert File.exists?(Path.expand("./test/instance/static/robots.txt")) assert File.exists?(Path.expand("./test/instance/static/robots.txt"))
assert File.exists?(@release_env_file)
assert File.read!(@release_env_file) =~ ~r/^RELEASE_COOKIE=.*/
end end
defp generated_setup_psql do defp generated_setup_psql do