Sha256: a027151a801e515507f39694998a7135fb8b0a28417842f326e4bcb47811cd8a

Contents?: true

Size: 1.23 KB

Versions: 15

Compression:

Stored size: 1.23 KB

Contents

require 'uri'

module Node
  module Forms
    class Create < ShopifyCli::Form
      attr_accessor :name
      flag_arguments :title, :organization_id, :shop_domain, :type

      def ask
        self.title ||= CLI::UI::Prompt.ask(ctx.message('node.forms.create.app_name'))
        self.type = ask_type
        self.name = self.title.downcase.split(" ").join("_")
        res = ShopifyCli::Tasks::SelectOrgAndShop.call(ctx, organization_id: organization_id, shop_domain: shop_domain)
        self.organization_id = res[:organization_id]
        self.shop_domain = res[:shop_domain]
      end

      private

      def ask_type
        if type.nil?
          return CLI::UI::Prompt.ask(ctx.message('node.forms.create.app_type.select')) do |handler|
            handler.option(ctx.message('node.forms.create.app_type.select_public')) { 'public' }
            handler.option(ctx.message('node.forms.create.app_type.select_custom')) { 'custom' }
          end
        end

        unless ShopifyCli::Tasks::CreateApiClient::VALID_APP_TYPES.include?(type)
          ctx.abort(ctx.message('node.forms.create.error.invalid_app_type', type))
        end
        ctx.puts(ctx.message('node.forms.create.app_type.selected', type))
        type
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
shopify-cli-1.6.0 lib/project_types/node/forms/create.rb
shopify-cli-1.5.0 lib/project_types/node/forms/create.rb
shopify-cli-1.4.1 lib/project_types/node/forms/create.rb
shopify-cli-1.4.0 lib/project_types/node/forms/create.rb
shopify-cli-1.3.1 lib/project_types/node/forms/create.rb
shopify-cli-1.3.0 lib/project_types/node/forms/create.rb
shopify-cli-1.2.0 lib/project_types/node/forms/create.rb
shopify-cli-1.1.2 lib/project_types/node/forms/create.rb
shopify-cli-1.1.1 lib/project_types/node/forms/create.rb
shopify-cli-1.1.0 lib/project_types/node/forms/create.rb
shopify-cli-1.0.5 lib/project_types/node/forms/create.rb
shopify-cli-1.0.4 lib/project_types/node/forms/create.rb
shopify-cli-1.0.3 lib/project_types/node/forms/create.rb
shopify-cli-1.0.2 lib/project_types/node/forms/create.rb
shopify-cli-1.0.1 lib/project_types/node/forms/create.rb