Class: Extension::Commands::Serve

Inherits:
ExtensionCommand show all
Defined in:
lib/project_types/extension/commands/serve.rb

Constant Summary collapse

YARN_SERVE_COMMAND =
%w(server)
NPM_SERVE_COMMAND =
%w(run-script server)

Instance Attribute Summary

Attributes inherited from ShopifyCli::Command

#ctx, #options

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ExtensionCommand

#extension_type, #project

Methods inherited from ShopifyCli::Command

call, call_help, #initialize, options, prerequisite_task, run_prerequisites, subcommand, subcommand_registry

Methods included from ShopifyCli::Feature::Set

#hidden?, #hidden_feature

Constructor Details

This class inherits a constructor from ShopifyCli::Command

Class Method Details

.helpObject



16
17
18
19
20
21
# File 'lib/project_types/extension/commands/serve.rb', line 16

def self.help
  <<~HELP
    Serve your extension in a local simulator for development.
      Usage: {{command:#{ShopifyCli::TOOL_NAME} serve}}
  HELP
end

Instance Method Details

#call(_args, _command_name) ⇒ Object



9
10
11
12
13
14
# File 'lib/project_types/extension/commands/serve.rb', line 9

def call(_args, _command_name)
  CLI::UI::Frame.open(@ctx.message('serve.frame_title')) do
    success = ShopifyCli::JsSystem.call(@ctx, yarn: YARN_SERVE_COMMAND, npm: NPM_SERVE_COMMAND)
    @ctx.abort(@ctx.message('serve.serve_failure_message')) unless success
  end
end