Sha256: 9f432e1ba12575ed6251709984f1312c079edea9135cd75f3a8ac4ddc7a5e19f

Contents?: true

Size: 1.11 KB

Versions: 9

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true
require 'thor'
require 'dato/dump/runner'
require 'dato/dump/ssg_detector'
require 'dato/migrate_slugs/runner'

module Dato
  class Cli < Thor
    package_name 'DatoCMS'

    desc 'dump', 'dumps DatoCMS contents into local files'
    option :config, default: 'dato.config.rb'
    option :token, default: ENV['DATO_API_TOKEN'], required: true
    def dump
      config_file = File.expand_path(options[:config])

      client = Dato::Site::Client.new(
        options[:token],
        extra_headers: {
          'X-Reason' => 'dump',
          'X-SSG' => Dump::SsgDetector.new(Dir.pwd).detect
        }
      )

      Dump::Runner.new(config_file, client).run
    end

    desc 'migrate-slugs', 'migrates a Site so that it uses slug fields'
    option :token, default: ENV['DATO_API_TOKEN'], required: true
    option :skip_id_prefix, type: :boolean
    def migrate_slugs
      client = Dato::Site::Client.new(
        options[:token],
        extra_headers: {
          'X-Reason' => 'migrate-slugs'
        }
      )

      MigrateSlugs::Runner.new(client, options[:skip_id_prefix]).run
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
dato-0.3.6 lib/dato/cli.rb
dato-0.3.5 lib/dato/cli.rb
dato-0.3.3 lib/dato/cli.rb
dato-0.3.2 lib/dato/cli.rb
dato-0.3.1 lib/dato/cli.rb
dato-0.3.0 lib/dato/cli.rb
dato-0.2.7 lib/dato/cli.rb
dato-0.2.6 lib/dato/cli.rb
dato-0.2.4 lib/dato/cli.rb