Sha256: 9942120d4759d83be16c39fe402d7cb3925a0ac441d2f29c96662dee8fa93bb9

Contents?: true

Size: 1.36 KB

Versions: 1

Compression:

Stored size: 1.36 KB

Contents

module Extension
  module Features
    class ArgoServeOptions
      include SmartProperties

      property! :argo_runtime, accepts: Features::ArgoRuntime
      property! :context, accepts: ShopifyCli::Context
      property  :port, accepts: Integer, default: 39351
      property  :public_url, accepts: String, default: ""
      property! :required_fields, accepts: Array, default: -> { [] }
      property! :renderer_package, accepts: Models::NpmPackage

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

      def yarn_serve_command
        YARN_SERVE_COMMAND + options
      end

      def npm_serve_command
        NPM_SERVE_COMMAND  + ["--"] + options
      end

      private

      def options
        project = ExtensionProject.current

        @serve_options ||= [].tap do |options|
          options << "--port=#{port}" if argo_runtime.accepts_port?
          options << "--shop=#{project.env.shop}" if required_fields.include?(:shop)
          options << "--apiKey=#{project.env.api_key}" if required_fields.include?(:api_key)
          options << "--argoVersion=#{renderer_package.version}" if argo_runtime.accepts_argo_version?
          options << "--uuid=#{project.registration_uuid}" if argo_runtime.accepts_uuid?
          options << "--publicUrl=#{public_url}" if argo_runtime.accepts_tunnel_url?
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shopify-cli-1.11.0 lib/project_types/extension/features/argo_serve_options.rb