2024-09-09 23:14:39 +08:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require_relative "../lib/migrations"
|
|
|
|
|
2024-11-20 06:51:53 +08:00
|
|
|
require "colored2"
|
|
|
|
require "thor"
|
|
|
|
|
2024-09-09 23:14:39 +08:00
|
|
|
module Migrations
|
|
|
|
configure_zeitwerk
|
|
|
|
enable_i18n
|
|
|
|
|
2024-11-20 06:51:53 +08:00
|
|
|
module CLI
|
|
|
|
class Application < Thor
|
|
|
|
desc "convert [FROM]", "Convert a file"
|
|
|
|
option :settings, type: :string, desc: "Path of settings file", banner: "path"
|
|
|
|
option :reset, type: :boolean, desc: "Reset database before converting data"
|
|
|
|
def convert(converter_type)
|
|
|
|
::Migrations::CLI::ConvertCommand.new(converter_type, options).execute
|
|
|
|
end
|
|
|
|
|
|
|
|
desc "import", "Import a file"
|
|
|
|
def import
|
|
|
|
::Migrations::CLI::ImportCommand.new(options).execute
|
|
|
|
end
|
2024-09-09 23:14:39 +08:00
|
|
|
|
2024-11-20 06:51:53 +08:00
|
|
|
desc "upload", "Upload media uploads"
|
|
|
|
option :settings,
|
|
|
|
type: :string,
|
|
|
|
desc: "Uploads settings file path",
|
|
|
|
default: "./migrations/config/upload.yml",
|
|
|
|
aliases: "-s",
|
|
|
|
banner: "path"
|
|
|
|
option :fix_missing, type: :boolean, desc: "Fix missing uploads"
|
|
|
|
option :optimize, type: :boolean, desc: "Optimize uploads"
|
|
|
|
def upload
|
|
|
|
::Migrations::CLI::UploadCommand.new(options).execute
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.exit_on_failure?
|
|
|
|
true
|
|
|
|
end
|
2024-09-09 23:14:39 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2024-11-20 06:51:53 +08:00
|
|
|
|
|
|
|
# rubocop:disable Discourse/NoChdir
|
|
|
|
Dir.chdir(File.expand_path("../..", __dir__)) { ::Migrations::CLI::Application.start }
|
|
|
|
# rubocop:enable Discourse/NoChdir
|