diff --git a/lib/generators/cw_to_activestorage/USAGE b/gems/houdini_upgrade/lib/generators/cw_to_activestorage/USAGE similarity index 100% rename from lib/generators/cw_to_activestorage/USAGE rename to gems/houdini_upgrade/lib/generators/cw_to_activestorage/USAGE diff --git a/lib/generators/cw_to_activestorage/cw_to_activestorage_generator.rb b/gems/houdini_upgrade/lib/generators/cw_to_activestorage/cw_to_activestorage_generator.rb similarity index 79% rename from lib/generators/cw_to_activestorage/cw_to_activestorage_generator.rb rename to gems/houdini_upgrade/lib/generators/cw_to_activestorage/cw_to_activestorage_generator.rb index 7b8e4e68..19e13e4a 100644 --- a/lib/generators/cw_to_activestorage/cw_to_activestorage_generator.rb +++ b/gems/houdini_upgrade/lib/generators/cw_to_activestorage/cw_to_activestorage_generator.rb @@ -1,11 +1,9 @@ # License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later class CwToActivestorageGenerator < Rails::Generators::Base source_root File.expand_path('templates', __dir__) + class_option :aws_bucket, type: :string, required: true + class_option :aws_assethost, type: :string, required: false - def install_activestorage_tables - rake 'active_storage:install' - end - def copy_uploaders if (!File.exists?('app/uploaders')) directory 'uploaders', 'app/uploaders' @@ -40,4 +38,11 @@ class CwToActivestorageGenerator < Rails::Generators::Base gem "carrierwave", "~> 1" gem "carrierwave-aws" end + + def add_carrierwave_template + @aws_bucket = options[:aws_bucket] + @aws_assethost = options[:aws_assethost] || "https://#{@aws_bucket}.s3.amazonaws.com" + + template 'initializers/carrierwave.rb', 'config/initializers/carrierwave.rb' + end end diff --git a/lib/generators/cw_to_activestorage/templates/initializers/carrierwave.rb b/gems/houdini_upgrade/lib/generators/cw_to_activestorage/templates/initializers/carrierwave.rb.tt similarity index 77% rename from lib/generators/cw_to_activestorage/templates/initializers/carrierwave.rb rename to gems/houdini_upgrade/lib/generators/cw_to_activestorage/templates/initializers/carrierwave.rb.tt index 9014df8a..e24f313a 100644 --- a/lib/generators/cw_to_activestorage/templates/initializers/carrierwave.rb +++ b/gems/houdini_upgrade/lib/generators/cw_to_activestorage/templates/initializers/carrierwave.rb.tt @@ -4,9 +4,9 @@ CarrierWave.configure do |config| config.storage = :aws - config.aws_bucket = ENV['CARRIERWAVE_AWS_BUCKET'] + config.aws_bucket = <%= @aws_bucket %> config.aws_acl = :public_read - config.asset_host = ENV['CARRIERWAVE_IMAGE_HOST'] || "https://#{config.aws_bucket}.s3.amazonaws.com" + config.asset_host = <%= @aws_assethost %> # config.aws_authenticated_url_expiration = 60 * 60 * 24 * 365 # config.aws_credentials = { # access_key_id: ENV['CARRIERWAVE_AWS_ACCESS_KEY_ID'], diff --git a/lib/generators/cw_to_activestorage/templates/migrate/rename_uploader_columns.rb b/gems/houdini_upgrade/lib/generators/cw_to_activestorage/templates/migrate/rename_uploader_columns.rb similarity index 100% rename from lib/generators/cw_to_activestorage/templates/migrate/rename_uploader_columns.rb rename to gems/houdini_upgrade/lib/generators/cw_to_activestorage/templates/migrate/rename_uploader_columns.rb diff --git a/lib/generators/cw_to_activestorage/templates/models/campaign.rb b/gems/houdini_upgrade/lib/generators/cw_to_activestorage/templates/models/campaign.rb similarity index 100% rename from lib/generators/cw_to_activestorage/templates/models/campaign.rb rename to gems/houdini_upgrade/lib/generators/cw_to_activestorage/templates/models/campaign.rb diff --git a/lib/generators/cw_to_activestorage/templates/models/event.rb b/gems/houdini_upgrade/lib/generators/cw_to_activestorage/templates/models/event.rb similarity index 100% rename from lib/generators/cw_to_activestorage/templates/models/event.rb rename to gems/houdini_upgrade/lib/generators/cw_to_activestorage/templates/models/event.rb diff --git a/lib/generators/cw_to_activestorage/templates/models/image_attachment.rb b/gems/houdini_upgrade/lib/generators/cw_to_activestorage/templates/models/image_attachment.rb similarity index 100% rename from lib/generators/cw_to_activestorage/templates/models/image_attachment.rb rename to gems/houdini_upgrade/lib/generators/cw_to_activestorage/templates/models/image_attachment.rb diff --git a/lib/generators/cw_to_activestorage/templates/models/nonprofit.rb b/gems/houdini_upgrade/lib/generators/cw_to_activestorage/templates/models/nonprofit.rb similarity index 100% rename from lib/generators/cw_to_activestorage/templates/models/nonprofit.rb rename to gems/houdini_upgrade/lib/generators/cw_to_activestorage/templates/models/nonprofit.rb diff --git a/lib/generators/cw_to_activestorage/templates/models/profile.rb b/gems/houdini_upgrade/lib/generators/cw_to_activestorage/templates/models/profile.rb similarity index 100% rename from lib/generators/cw_to_activestorage/templates/models/profile.rb rename to gems/houdini_upgrade/lib/generators/cw_to_activestorage/templates/models/profile.rb diff --git a/lib/generators/cw_to_activestorage/templates/uploaders/article_background_uploader.rb b/gems/houdini_upgrade/lib/generators/cw_to_activestorage/templates/uploaders/article_background_uploader.rb similarity index 100% rename from lib/generators/cw_to_activestorage/templates/uploaders/article_background_uploader.rb rename to gems/houdini_upgrade/lib/generators/cw_to_activestorage/templates/uploaders/article_background_uploader.rb diff --git a/lib/generators/cw_to_activestorage/templates/uploaders/article_uploader.rb b/gems/houdini_upgrade/lib/generators/cw_to_activestorage/templates/uploaders/article_uploader.rb similarity index 100% rename from lib/generators/cw_to_activestorage/templates/uploaders/article_uploader.rb rename to gems/houdini_upgrade/lib/generators/cw_to_activestorage/templates/uploaders/article_uploader.rb diff --git a/lib/generators/cw_to_activestorage/templates/uploaders/campaign_background_image_uploader.rb b/gems/houdini_upgrade/lib/generators/cw_to_activestorage/templates/uploaders/campaign_background_image_uploader.rb similarity index 100% rename from lib/generators/cw_to_activestorage/templates/uploaders/campaign_background_image_uploader.rb rename to gems/houdini_upgrade/lib/generators/cw_to_activestorage/templates/uploaders/campaign_background_image_uploader.rb diff --git a/lib/generators/cw_to_activestorage/templates/uploaders/campaign_banner_image_uploader.rb b/gems/houdini_upgrade/lib/generators/cw_to_activestorage/templates/uploaders/campaign_banner_image_uploader.rb similarity index 100% rename from lib/generators/cw_to_activestorage/templates/uploaders/campaign_banner_image_uploader.rb rename to gems/houdini_upgrade/lib/generators/cw_to_activestorage/templates/uploaders/campaign_banner_image_uploader.rb diff --git a/lib/generators/cw_to_activestorage/templates/uploaders/campaign_main_image_uploader.rb b/gems/houdini_upgrade/lib/generators/cw_to_activestorage/templates/uploaders/campaign_main_image_uploader.rb similarity index 100% rename from lib/generators/cw_to_activestorage/templates/uploaders/campaign_main_image_uploader.rb rename to gems/houdini_upgrade/lib/generators/cw_to_activestorage/templates/uploaders/campaign_main_image_uploader.rb diff --git a/lib/generators/cw_to_activestorage/templates/uploaders/event_background_image_uploader.rb b/gems/houdini_upgrade/lib/generators/cw_to_activestorage/templates/uploaders/event_background_image_uploader.rb similarity index 100% rename from lib/generators/cw_to_activestorage/templates/uploaders/event_background_image_uploader.rb rename to gems/houdini_upgrade/lib/generators/cw_to_activestorage/templates/uploaders/event_background_image_uploader.rb diff --git a/lib/generators/cw_to_activestorage/templates/uploaders/event_main_image_uploader.rb b/gems/houdini_upgrade/lib/generators/cw_to_activestorage/templates/uploaders/event_main_image_uploader.rb similarity index 100% rename from lib/generators/cw_to_activestorage/templates/uploaders/event_main_image_uploader.rb rename to gems/houdini_upgrade/lib/generators/cw_to_activestorage/templates/uploaders/event_main_image_uploader.rb diff --git a/lib/generators/cw_to_activestorage/templates/uploaders/image_attachment_uploader.rb b/gems/houdini_upgrade/lib/generators/cw_to_activestorage/templates/uploaders/image_attachment_uploader.rb similarity index 100% rename from lib/generators/cw_to_activestorage/templates/uploaders/image_attachment_uploader.rb rename to gems/houdini_upgrade/lib/generators/cw_to_activestorage/templates/uploaders/image_attachment_uploader.rb diff --git a/lib/generators/cw_to_activestorage/templates/uploaders/nonprofit_background_uploader.rb b/gems/houdini_upgrade/lib/generators/cw_to_activestorage/templates/uploaders/nonprofit_background_uploader.rb similarity index 100% rename from lib/generators/cw_to_activestorage/templates/uploaders/nonprofit_background_uploader.rb rename to gems/houdini_upgrade/lib/generators/cw_to_activestorage/templates/uploaders/nonprofit_background_uploader.rb diff --git a/lib/generators/cw_to_activestorage/templates/uploaders/nonprofit_logo_uploader.rb b/gems/houdini_upgrade/lib/generators/cw_to_activestorage/templates/uploaders/nonprofit_logo_uploader.rb similarity index 100% rename from lib/generators/cw_to_activestorage/templates/uploaders/nonprofit_logo_uploader.rb rename to gems/houdini_upgrade/lib/generators/cw_to_activestorage/templates/uploaders/nonprofit_logo_uploader.rb diff --git a/lib/generators/cw_to_activestorage/templates/uploaders/nonprofit_uploader.rb b/gems/houdini_upgrade/lib/generators/cw_to_activestorage/templates/uploaders/nonprofit_uploader.rb similarity index 100% rename from lib/generators/cw_to_activestorage/templates/uploaders/nonprofit_uploader.rb rename to gems/houdini_upgrade/lib/generators/cw_to_activestorage/templates/uploaders/nonprofit_uploader.rb diff --git a/lib/generators/cw_to_activestorage/templates/uploaders/profile_uploader.rb b/gems/houdini_upgrade/lib/generators/cw_to_activestorage/templates/uploaders/profile_uploader.rb similarity index 100% rename from lib/generators/cw_to_activestorage/templates/uploaders/profile_uploader.rb rename to gems/houdini_upgrade/lib/generators/cw_to_activestorage/templates/uploaders/profile_uploader.rb diff --git a/gems/houdini_upgrade/lib/tasks/houdini_upgrade_tasks.rake b/gems/houdini_upgrade/lib/tasks/houdini_upgrade_tasks.rake index a62d8df8..83c229b2 100644 --- a/gems/houdini_upgrade/lib/tasks/houdini_upgrade_tasks.rake +++ b/gems/houdini_upgrade/lib/tasks/houdini_upgrade_tasks.rake @@ -7,10 +7,15 @@ task :run => :environment do Rake::Task["houdini_upgrade:install:migrations"].invoke Rake::Task["active_storage:install"].invoke + Rake::Task["houdini_upgrade:cw_to_activestorage"].invoke Rake::Task["houdini_upgrade:run_db_migration"].invoke end - task :run_db_migration do + task :migration do sh 'rails db:migrate' end + + task :cw_to_activestorage do + sh 'rails generate cw_to_activestorage' + end end