aboutsummaryrefslogtreecommitdiff
path: root/lib/mix
diff options
context:
space:
mode:
Diffstat (limited to 'lib/mix')
-rw-r--r--lib/mix/pleroma.ex4
-rw-r--r--lib/mix/tasks/pleroma/config.ex6
-rw-r--r--lib/mix/tasks/pleroma/ecto/ecto.ex11
-rw-r--r--lib/mix/tasks/pleroma/ecto/migrate.ex2
-rw-r--r--lib/mix/tasks/pleroma/ecto/rollback.ex2
-rw-r--r--lib/mix/tasks/pleroma/instance.ex16
-rw-r--r--lib/mix/tasks/pleroma/user.ex4
7 files changed, 38 insertions, 7 deletions
diff --git a/lib/mix/pleroma.ex b/lib/mix/pleroma.ex
index 548c8a0a4..1b758ea33 100644
--- a/lib/mix/pleroma.ex
+++ b/lib/mix/pleroma.ex
@@ -9,6 +9,10 @@ defmodule Mix.Pleroma do
{:ok, _} = Application.ensure_all_started(:pleroma)
end
+ def load_pleroma do
+ Application.load(:pleroma)
+ end
+
def get_option(options, opt, prompt, defval \\ nil, defname \\ nil) do
Keyword.get(options, opt) || shell_prompt(prompt, defval, defname)
end
diff --git a/lib/mix/tasks/pleroma/config.ex b/lib/mix/tasks/pleroma/config.ex
index cc5425362..4ed2c9789 100644
--- a/lib/mix/tasks/pleroma/config.ex
+++ b/lib/mix/tasks/pleroma/config.ex
@@ -24,7 +24,7 @@ defmodule Mix.Tasks.Pleroma.Config do
|> Enum.reject(fn {k, _v} -> k in [Pleroma.Repo, :env] end)
|> Enum.each(fn {k, v} ->
key = to_string(k) |> String.replace("Elixir.", "")
- {:ok, _} = Config.update_or_create(%{key: key, value: v})
+ {:ok, _} = Config.update_or_create(%{group: "pleroma", key: key, value: v})
Mix.shell().info("#{key} is migrated.")
end)
@@ -51,7 +51,9 @@ defmodule Mix.Tasks.Pleroma.Config do
IO.write(
file,
- "config :pleroma, #{config.key}#{mark} #{inspect(Config.from_binary(config.value))}\r\n"
+ "config :#{config.group}, #{config.key}#{mark} #{
+ inspect(Config.from_binary(config.value))
+ }\r\n"
)
{:ok, _} = Repo.delete(config)
diff --git a/lib/mix/tasks/pleroma/ecto/ecto.ex b/lib/mix/tasks/pleroma/ecto/ecto.ex
index af09cb289..324f57fdd 100644
--- a/lib/mix/tasks/pleroma/ecto/ecto.ex
+++ b/lib/mix/tasks/pleroma/ecto/ecto.ex
@@ -9,6 +9,15 @@ defmodule Mix.Tasks.Pleroma.Ecto do
def ensure_migrations_path(repo, opts) do
path = opts[:migrations_path] || Path.join(source_repo_priv(repo), "migrations")
+ path =
+ case Path.type(path) do
+ :relative ->
+ Path.join(Application.app_dir(:pleroma), path)
+
+ :absolute ->
+ path
+ end
+
if not File.dir?(path) do
raise_missing_migrations(Path.relative_to_cwd(path), repo)
end
@@ -22,7 +31,7 @@ defmodule Mix.Tasks.Pleroma.Ecto do
def source_repo_priv(repo) do
config = repo.config()
priv = config[:priv] || "priv/#{repo |> Module.split() |> List.last() |> Macro.underscore()}"
- Path.join(File.cwd!(), priv)
+ Path.join(Application.app_dir(:pleroma), priv)
end
defp raise_missing_migrations(path, repo) do
diff --git a/lib/mix/tasks/pleroma/ecto/migrate.ex b/lib/mix/tasks/pleroma/ecto/migrate.ex
index 22eafe76f..855c977f6 100644
--- a/lib/mix/tasks/pleroma/ecto/migrate.ex
+++ b/lib/mix/tasks/pleroma/ecto/migrate.ex
@@ -4,6 +4,7 @@
defmodule Mix.Tasks.Pleroma.Ecto.Migrate do
use Mix.Task
+ import Mix.Pleroma
require Logger
@shortdoc "Wrapper on `ecto.migrate` task."
@@ -37,6 +38,7 @@ defmodule Mix.Tasks.Pleroma.Ecto.Migrate do
@impl true
def run(args \\ []) do
+ load_pleroma()
{opts, _} = OptionParser.parse!(args, strict: @switches, aliases: @aliases)
opts =
diff --git a/lib/mix/tasks/pleroma/ecto/rollback.ex b/lib/mix/tasks/pleroma/ecto/rollback.ex
index 0033ceba4..2ffb0901c 100644
--- a/lib/mix/tasks/pleroma/ecto/rollback.ex
+++ b/lib/mix/tasks/pleroma/ecto/rollback.ex
@@ -4,6 +4,7 @@
defmodule Mix.Tasks.Pleroma.Ecto.Rollback do
use Mix.Task
+ import Mix.Pleroma
require Logger
@shortdoc "Wrapper on `ecto.rollback` task"
@@ -36,6 +37,7 @@ defmodule Mix.Tasks.Pleroma.Ecto.Rollback do
@impl true
def run(args \\ []) do
+ load_pleroma()
{opts, _} = OptionParser.parse!(args, strict: @switches, aliases: @aliases)
opts =
diff --git a/lib/mix/tasks/pleroma/instance.ex b/lib/mix/tasks/pleroma/instance.ex
index c6738dbcc..997eabbeb 100644
--- a/lib/mix/tasks/pleroma/instance.ex
+++ b/lib/mix/tasks/pleroma/instance.ex
@@ -29,6 +29,7 @@ defmodule Mix.Tasks.Pleroma.Instance do
- `--dbname DBNAME` - the name of the database to use
- `--dbuser DBUSER` - the user (aka role) to use for the database connection
- `--dbpass DBPASS` - the password to use for the database connection
+ - `--rum Y/N` - Whether to enable RUM indexes
- `--indexable Y/N` - Allow/disallow indexing site by search engines
- `--db-configurable Y/N` - Allow/disallow configuring instance from admin part
- `--uploads-dir` - the directory uploads go in when using a local uploader
@@ -51,6 +52,7 @@ defmodule Mix.Tasks.Pleroma.Instance do
dbname: :string,
dbuser: :string,
dbpass: :string,
+ rum: :string,
indexable: :string,
db_configurable: :string,
uploads_dir: :string,
@@ -136,6 +138,14 @@ defmodule Mix.Tasks.Pleroma.Instance do
"autogenerated"
)
+ rum_enabled =
+ get_option(
+ options,
+ :rum,
+ "Would you like to use RUM indices?",
+ "n"
+ ) === "y"
+
uploads_dir =
get_option(
options,
@@ -175,7 +185,8 @@ defmodule Mix.Tasks.Pleroma.Instance do
web_push_private_key: Base.url_encode64(web_push_private_key, padding: false),
db_configurable?: db_configurable?,
static_dir: static_dir,
- uploads_dir: uploads_dir
+ uploads_dir: uploads_dir,
+ rum_enabled: rum_enabled
)
result_psql =
@@ -183,7 +194,8 @@ defmodule Mix.Tasks.Pleroma.Instance do
template_dir <> "/sample_psql.eex",
dbname: dbname,
dbuser: dbuser,
- dbpass: dbpass
+ dbpass: dbpass,
+ rum_enabled: rum_enabled
)
shell_info(
diff --git a/lib/mix/tasks/pleroma/user.ex b/lib/mix/tasks/pleroma/user.ex
index ab158f57e..8a78b4fe6 100644
--- a/lib/mix/tasks/pleroma/user.ex
+++ b/lib/mix/tasks/pleroma/user.ex
@@ -204,9 +204,9 @@ defmodule Mix.Tasks.Pleroma.User do
IO.puts(
"URL: #{
- Pleroma.Web.Router.Helpers.util_url(
+ Pleroma.Web.Router.Helpers.reset_password_url(
Pleroma.Web.Endpoint,
- :show_password_reset,
+ :reset,
token.token
)
}"