Class: ShopifyCLI::Services::App::Serve::RailsService

Inherits:
ServeService show all
Defined in:
lib/shopify_cli/services/app/serve/rails_service.rb

Instance Attribute Summary

Attributes inherited from ServeService

#context, #host, #no_update, #port

Instance Method Summary collapse

Methods inherited from ServeService

#initialize

Methods inherited from BaseService

call

Constructor Details

This class inherits a constructor from ShopifyCLI::Services::App::Serve::ServeService

Instance Method Details

#callObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/shopify_cli/services/app/serve/rails_service.rb', line 6

def call
  generate_url

  CLI::UI::Frame.open(context.message("core.app.serve.running_server")) do
    original_env = JSON.parse(ENV["ORIGINAL_ENV"] || "{}")
    env = original_env.merge(ShopifyCLI::Project.current.env.to_h)
    env.delete("HOST") if context.ruby_gem_version("shopify_app") < ::Semantic::Version.new("19.0.0")
    env["PORT"] = port.to_s
    env["GEM_PATH"] =
      [env["GEM_PATH"], Rails::Gem.gem_path(context)].compact
        .join(CLI::UI::OS.current.path_separator)
    if context.windows?
      context.system("ruby bin\\rails server", env: env)
    else
      context.system("bin/rails server", env: env)
    end
  end
end