1
0
mirror of https://github.com/mastodon/mastodon synced 2025-01-22 09:43:25 +09:00

Extract most of mastodon:setup task to large private method

This commit is contained in:
Matt Jankowski 2025-01-16 11:20:15 -05:00
parent 3af6739f21
commit c71345009c

View File

@ -5,12 +5,29 @@ require 'tty-prompt'
namespace :mastodon do
desc 'Configure the instance for production use'
task :setup do
prompt = TTY::Prompt.new
env = {}
clear_environment!
begin
configure_environment
rescue TTY::Reader::InputInterrupt
TTY::Prompt.new.ok 'Aborting. Bye!'
end
end
namespace :webpush do
desc 'Generate VAPID key'
task :generate_vapid_key do
vapid_key = Webpush.generate_key
puts "VAPID_PRIVATE_KEY=#{vapid_key.private_key}"
puts "VAPID_PUBLIC_KEY=#{vapid_key.public_key}"
end
end
private
def configure_environment # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
prompt = TTY::Prompt.new
env = {}
errors = []
prompt.say('Your instance is identified by its domain name. Changing it afterward will break things.')
@ -558,21 +575,7 @@ namespace :mastodon do
else
prompt.warn 'Nothing saved. Bye!'
end
rescue TTY::Reader::InputInterrupt
prompt.ok 'Aborting. Bye!'
end
end
namespace :webpush do
desc 'Generate VAPID key'
task :generate_vapid_key do
vapid_key = Webpush.generate_key
puts "VAPID_PRIVATE_KEY=#{vapid_key.private_key}"
puts "VAPID_PUBLIC_KEY=#{vapid_key.public_key}"
end
end
private
def clear_environment!
# When the application code gets loaded, it runs `lib/mastodon/redis_configuration.rb`.