Add ActionMailbox install generator

Forward ActionMailbox install to install generator and hide the ActionMailbox install generator from generator list

Updated the Action Mailbox install task description
This commit is contained in:
Abhay Nikam 2019-12-17 00:52:24 +05:30
parent 0b3c710d35
commit fc12d224ae
4 changed files with 33 additions and 28 deletions

View File

@ -0,0 +1,28 @@
# frozen_string_literal: true
require "rails/generators/mailbox/mailbox_generator"
module ActionMailbox
module Generators
class InstallGenerator < ::Rails::Generators::Base
source_root Rails::Generators::MailboxGenerator.source_root
def create_action_mailbox_files
say "Copying application_mailbox.rb to app/mailboxes", :green
template "application_mailbox.rb", "app/mailboxes/application_mailbox.rb"
end
def add_action_mailbox_production_environment_config
environment <<~end_of_config, env: "production"
# Prepare the ingress controller used to receive mail
# config.action_mailbox.ingress = :relay
end_of_config
end
def create_migrations
rails_command "railties:install:migrations FROM=active_storage,action_mailbox"
end
end
end
end

View File

@ -1,10 +0,0 @@
# frozen_string_literal: true
say "Copying application_mailbox.rb to app/mailboxes"
copy_file "#{__dir__}/mailbox/templates/application_mailbox.rb", "app/mailboxes/application_mailbox.rb"
environment <<~end_of_config, env: "production"
# Prepare the ingress controller used to receive mail
# config.action_mailbox.ingress = :relay
end_of_config

View File

@ -1,20 +1,6 @@
# frozen_string_literal: true
namespace :action_mailbox do
# Prevent migration installation task from showing up twice.
Rake::Task["install:migrations"].clear_comments
desc "Copy over the migration"
task install: %w[ environment run_installer copy_migrations ]
task :run_installer do
installer_template = File.expand_path("../rails/generators/installer.rb", __dir__)
system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{installer_template}"
end
task :copy_migrations do
Rake::Task["active_storage:install:migrations"].invoke
Rake::Task["railties:install:migrations"].reenable # Otherwise you can't run 2 migration copy tasks in one invocation
Rake::Task["action_mailbox:install:migrations"].invoke
end
desc "Installs Action Mailbox and its dependencies"
task "action_mailbox:install" do
Rails::Command.invoke :generate, ["action_mailbox:install"]
end

View File

@ -161,7 +161,8 @@ module Rails
"#{css}:assets",
"css:assets",
"css:scaffold",
"action_text:install"
"action_text:install",
"action_mailbox:install"
]
end
end