Sha256: a0f6f03f5045f3be09f45cab3511e342f83325a8f7d70dd9bb059da737d2785a
Contents?: true
Size: 1.63 KB
Versions: 1
Compression:
Stored size: 1.63 KB
Contents
# frozen_string_literal: true require "shopify_cli" module Extension module Tasks class RunExtensionCommand < ShopifyCLI::Task include SmartProperties SUPPORTED_EXTENSION_TYPES = [ "checkout_ui_extension", ] SUPPORTED_COMMANDS = [ "create", "build", "serve", ] property :root_dir, accepts: String property :template, accepts: Models::ServerConfig::Development::VALID_TEMPLATES property! :type, accepts: SUPPORTED_EXTENSION_TYPES property! :command, accepts: SUPPORTED_COMMANDS property :context, accepts: ShopifyCLI::Context property :port, accepts: Integer, default: 39351 def call ShopifyCLI::Result .call(&method(:build_extension)) .then(&method(:build_server_config)) .then(&method(:run_command)) .unwrap do |error| raise error unless error.nil? end end private def build_extension Models::ServerConfig::Extension.build( template: template, type: type, root_dir: root_dir, ) end def build_server_config(extension) Models::ServerConfig::Root.new(port: port, extensions: [extension]) end def run_command(server_config) case command when "create" Models::DevelopmentServer.new.create(server_config) when "build" Models::DevelopmentServer.new.build(server_config) when "serve" Models::DevelopmentServer.new.serve(context, server_config) else raise NotImplementedError end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
shopify-cli-2.5.0 | lib/project_types/extension/tasks/run_extension_command.rb |