Sha256: 9933ec2632d81df4e5867e28afc0534f9c399ce50714baa3ea72794c8a13e7df

Contents?: true

Size: 1.55 KB

Versions: 2

Compression:

Stored size: 1.55 KB

Contents

module ShopifyCLI
  module Services
    module App
      module Serve
        class RailsService < BaseService
          attr_accessor :host, :port, :context

          def initialize(host:, port:, context:)
            @host = host
            @port = port
            @context = context
            super()
          end

          def call
            project = ShopifyCLI::Project.current
            url = host || ShopifyCLI::Tunnel.start(context)
            raise ShopifyCLI::Abort,
              context.message("core.app.serve.error.host_must_be_https") if url.match(/^https/i).nil?
            project.env.update(context, :host, url)
            ShopifyCLI::Tasks::UpdateDashboardURLS.call(
              context,
              url: url,
              callback_url: "/auth/shopify/callback",
            )

            if project.env.shop
              project_url = "#{project.env.host}/login?shop=#{project.env.shop}"
              context.puts("\n" + context.message("core.app.serve.open_info", project_url) + "\n")
            end

            CLI::UI::Frame.open(context.message("core.app.serve.running_server")) do
              env = ShopifyCLI::Project.current.env.to_h
              env.delete("HOST")
              env["PORT"] = port.to_s
              env["GEM_PATH"] = Rails::Gem.gem_path(context)
              if context.windows?
                context.system("ruby bin\\rails server", env: env)
              else
                context.system("bin/rails server", env: env)
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
shopify-cli-2.7.1 lib/shopify_cli/services/app/serve/rails_service.rb
shopify-cli-2.7.0 lib/shopify_cli/services/app/serve/rails_service.rb