2018-05-29 10:55:04 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
namespace :action_text do
|
|
|
|
# Prevent migration installation task from showing up twice.
|
|
|
|
Rake::Task["install:migrations"].clear_comments
|
|
|
|
|
|
|
|
desc "Copy over the migration, stylesheet, and JavaScript files"
|
2018-10-02 18:47:01 -04:00
|
|
|
task install: %w( environment copy_migrations copy_stylesheet copy_fixtures yarn_add )
|
2018-05-29 10:55:04 -04:00
|
|
|
|
2018-10-01 20:47:07 -04:00
|
|
|
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_text:install:migrations"].invoke
|
2018-05-29 10:55:04 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
STYLESHEET_TEMPLATE_PATH = File.expand_path("../templates/actiontext.css", __dir__)
|
|
|
|
STYLESHEET_APP_PATH = Rails.root.join("app/assets/stylesheets/actiontext.css")
|
|
|
|
|
|
|
|
task :copy_stylesheet do
|
2018-10-02 18:45:48 -04:00
|
|
|
unless File.exist?(STYLESHEET_APP_PATH)
|
2018-05-29 10:55:04 -04:00
|
|
|
FileUtils.cp STYLESHEET_TEMPLATE_PATH, STYLESHEET_APP_PATH
|
|
|
|
end
|
|
|
|
end
|
2018-09-12 19:22:40 -04:00
|
|
|
|
|
|
|
FIXTURE_TEMPLATE_PATH = File.expand_path("../templates/fixtures.yml", __dir__)
|
|
|
|
FIXTURE_APP_DIR_PATH = Rails.root.join("test/fixtures/action_text")
|
2018-09-12 19:24:20 -04:00
|
|
|
FIXTURE_APP_PATH = FIXTURE_APP_DIR_PATH.join("rich_texts.yml")
|
2018-09-12 19:22:40 -04:00
|
|
|
|
|
|
|
task :copy_fixtures do
|
2018-10-02 18:45:48 -04:00
|
|
|
unless File.exist?(FIXTURE_APP_PATH)
|
2018-09-12 19:22:40 -04:00
|
|
|
FileUtils.mkdir FIXTURE_APP_DIR_PATH
|
|
|
|
FileUtils.cp FIXTURE_TEMPLATE_PATH, FIXTURE_APP_PATH
|
|
|
|
end
|
|
|
|
end
|
2018-10-02 18:47:01 -04:00
|
|
|
|
|
|
|
task :yarn_add do
|
|
|
|
# FIXME: Replace with release version on release
|
|
|
|
system "yarn add https://github.com/basecamp/actiontext"
|
|
|
|
end
|
2018-05-29 10:55:04 -04:00
|
|
|
end
|