Sha256: c26ccd87a71e4af1402dd06005e24df7f9324bb7352a038b9ad27df94ee930cf

Contents?: true

Size: 1.36 KB

Versions: 50

Compression:

Stored size: 1.36 KB

Contents

# frozen_string_literal: true

module Extension
  module Forms
    class Create < ShopifyCLI::Form
      flag_arguments :name, :type, :api_key, :template

      attr_reader :app

      class ExtensionProjectDetails
        include SmartProperties

        property :app, accepts: Models::App
        property :name, accepts: String
        property :type, accepts: Models::SpecificationHandlers::Default
        property :template, accepts: String

        def complete?
          !!(app && name && type)
        end
      end

      def ask
        ShopifyCLI::Result.wrap(ExtensionProjectDetails.new)
          .then(&Questions::AskApp.new(ctx: ctx, api_key: api_key))
          .then(&Questions::AskType.new(ctx: ctx, type: type))
          .then(&Questions::AskTemplate.new(ctx: ctx, template: template))
          .then(&Questions::AskName.new(ctx: ctx, name: name))
          .unwrap { |e| raise e }
          .tap do |project_details|
            ctx.abort(ctx.message("create.incomplete_configuration")) unless project_details.complete?

            self.app = project_details.app
            self.type = project_details.type
            self.template = project_details.template
            self.name = project_details.name
          end
      end

      def directory_name
        name.strip.gsub(/( )/, "_").downcase
      end

      private

      attr_writer :app
    end
  end
end

Version data entries

50 entries across 50 versions & 1 rubygems

Version Path
shopify-cli-2.36.0 lib/project_types/extension/forms/create.rb
shopify-cli-2.35.0 lib/project_types/extension/forms/create.rb
shopify-cli-2.34.0 lib/project_types/extension/forms/create.rb
shopify-cli-2.33.1 lib/project_types/extension/forms/create.rb
shopify-cli-2.33.0 lib/project_types/extension/forms/create.rb
shopify-cli-2.32.1 lib/project_types/extension/forms/create.rb
shopify-cli-2.32.0 lib/project_types/extension/forms/create.rb
shopify-cli-2.31.0 lib/project_types/extension/forms/create.rb
shopify-cli-2.30.0 lib/project_types/extension/forms/create.rb
shopify-cli-2.29.0 lib/project_types/extension/forms/create.rb
shopify-cli-2.28.0 lib/project_types/extension/forms/create.rb
shopify-cli-2.27.0 lib/project_types/extension/forms/create.rb
shopify-cli-2.26.0 lib/project_types/extension/forms/create.rb
shopify-cli-2.25.0 lib/project_types/extension/forms/create.rb
shopify-cli-2.24.0 lib/project_types/extension/forms/create.rb
shopify-cli-2.23.0 lib/project_types/extension/forms/create.rb
shopify-cli-2.22.0 lib/project_types/extension/forms/create.rb
shopify-cli-2.21.0 lib/project_types/extension/forms/create.rb
shopify-cli-2.20.1 lib/project_types/extension/forms/create.rb
shopify-cli-2.20.0 lib/project_types/extension/forms/create.rb