Class: Node::Commands::Generate::Webhook
- Inherits:
-
ShopifyCli::SubCommand
- Object
- CLI::Kit::BaseCommand
- ShopifyCli::Command
- ShopifyCli::SubCommand
- Node::Commands::Generate::Webhook
- Defined in:
- lib/project_types/node/commands/generate/webhook.rb
Instance Attribute Summary
Attributes inherited from ShopifyCli::Command
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from ShopifyCli::SubCommand
Methods inherited from ShopifyCli::Command
call, call_help, #initialize, options, prerequisite_task, run_prerequisites, subcommand, subcommand_registry
Methods included from ShopifyCli::Feature::Set
Constructor Details
This class inherits a constructor from ShopifyCli::Command
Class Method Details
.help ⇒ Object
31 32 33 |
# File 'lib/project_types/node/commands/generate/webhook.rb', line 31 def self.help ShopifyCli::Context.('node.generate.webhook.help', ShopifyCli::TOOL_NAME) end |
Instance Method Details
#call(args, _name) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/project_types/node/commands/generate/webhook.rb', line 7 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.('node.generate.webhook.type_select')) do |handler| webhooks.each do |type| handler.option(type) { type } end end end generate_path = File.join(ShopifyCli::Project.current.directory, "node_modules/.bin/generate-node-app") generate_path = "\"#{generate_path}\"" spin_group = CLI::UI::SpinGroup.new spin_group.add(@ctx.('node.generate.webhook.generating', selected_type)) do |spinner| Node::Commands::Generate.run_generate("#{generate_path} webhook #{selected_type}", selected_type, @ctx) spinner.update_title(@ctx.('node.generate.webhook.generated', selected_type)) end spin_group.wait end |