Sha256: 7a45a237511f77427badfdd2438ac60bcd8e1459ffaa028a6f8836416d978ff3
Contents?: true
Size: 1.5 KB
Versions: 10
Compression:
Stored size: 1.5 KB
Contents
require 'shopify_cli' require 'json' module Rails 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('rails.generate.webhook.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('rails.generate.webhook.selected', selected_type)) do |spinner| Rails::Commands::Generate.run_generate(generate_command(selected_type), selected_type, @ctx) spinner.update_title("{{green:#{selected_type}}} config/initializers/shopify_app.rb") end spin_group.wait end def self.help ShopifyCli::Context.message('rails.generate.webhook.help', ShopifyCli::TOOL_NAME) end def generate_command(selected_type) parts = selected_type.downcase.split("_") env = ShopifyCli::Project.current.env.host selected_type = parts[0..-2].join("_") + "/" + parts[-1] "rails g shopify_app:add_webhook -t #{selected_type} -a #{env}/webhooks/#{selected_type.downcase}" end end end end end
Version data entries
10 entries across 10 versions & 1 rubygems