Sha256: 10b17f3c03fadd7945c5d00157497e2143aea86cf793400f013e14c68d1a88cf
Contents?: true
Size: 1.69 KB
Versions: 1
Compression:
Stored size: 1.69 KB
Contents
# frozen_string_literal: true module Extension module Commands class Serve < ExtensionCommand YARN_SERVE_COMMAND = %w(server) NPM_SERVE_COMMAND = %w(run-script server) def call(_args, _command_name) if argo_admin? ShopifyCli::Tasks::EnsureEnv.call(@ctx, required: [:api_key, :secret, :shop]) ShopifyCli::Tasks::EnsureDevStore.call(@ctx) validate_env end CLI::UI::Frame.open(@ctx.message("serve.frame_title")) do yarn_serve_command = YARN_SERVE_COMMAND npm_serve_command = NPM_SERVE_COMMAND if argo_admin? serve_args = %W(--shop=#{project.env.shop} --apiKey=#{project.env.api_key}) yarn_serve_command += serve_args npm_serve_command += %w(--) + serve_args end 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 def self.help <<~HELP Serve your extension in a local simulator for development. Usage: {{command:#{ShopifyCli::TOOL_NAME} serve}} HELP end private def argo_admin? ShopifyCli::Shopifolk.check && ShopifyCli::Feature.enabled?(:argo_admin_beta) && extension_type.specification.features&.argo&.surface == "admin" end def validate_env ExtensionProject.reload @ctx.abort(@ctx.message("serve.serve_missing_information")) if project.env.shop.nil? || project.env.api_key.nil? || project.env.shop.strip.empty? || project.env.api_key.strip.empty? end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
shopify-cli-1.8.0 | lib/project_types/extension/commands/serve.rb |