Sha256: 63f806be40bed530800f01ac66d1ca1151ad41958993d90d484acb7373cdd724

Contents?: true

Size: 1.22 KB

Versions: 10

Compression:

Stored size: 1.22 KB

Contents

require 'shopify_cli'
require 'json'
module Node
  module Commands
    class Generate
      class Webhook < ShopifyCli::SubCommand
        def call(args, _name)
          selected_type = args.first
          schema = ShopifyCli::AdminAPI::Schema.get(@ctx)
          webhooks = schema.get_names_from_type('WebhookSubscriptionTopic')
          unless selected_type && webhooks.include?(selected_type)
            selected_type = CLI::UI::Prompt.ask(@ctx.message('node.generate.webhook.type_select')) do |handler|
              webhooks.each do |type|
                handler.option(type) { type }
              end
            end
          end
          spin_group = CLI::UI::SpinGroup.new
          spin_group.add(@ctx.message('node.generate.webhook.generating', selected_type)) do |spinner|
            Node::Commands::Generate.run_generate("./node_modules/.bin/generate-node-app webhook #{selected_type}",
              selected_type, @ctx)
            spinner.update_title(@ctx.message('node.generate.webhook.generated', selected_type))
          end
          spin_group.wait
        end

        def self.help
          ShopifyCli::Context.message('node.generate.webhook.help', ShopifyCli::TOOL_NAME)
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
shopify-cli-1.0.5 lib/project_types/node/commands/generate/webhook.rb
shopify-cli-1.0.4 lib/project_types/node/commands/generate/webhook.rb
shopify-cli-1.0.3 lib/project_types/node/commands/generate/webhook.rb
shopify-cli-1.0.2 lib/project_types/node/commands/generate/webhook.rb
shopify-cli-1.0.1 lib/project_types/node/commands/generate/webhook.rb
shopify-cli-1.0.0 lib/project_types/node/commands/generate/webhook.rb
shopify-cli-0.9.3 lib/project_types/node/commands/generate/webhook.rb
shopify-cli-0.9.2 lib/project_types/node/commands/generate/webhook.rb
shopify-cli-0.9.1 lib/project_types/node/commands/generate/webhook.rb
shopify-cli-0.9.0 lib/project_types/node/commands/generate/webhook.rb