Class: RubyNative::CLI::Deploy

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_native/cli/deploy.rb

Constant Summary collapse

CONFIG_PATH =
"config/ruby_native.yml"
HOST =
ENV.fetch("RUBY_NATIVE_HOST", "https://rubynative.com")
POLL_INTERVAL =
5
POLL_TIMEOUT =
600
PLATFORMS =
%w[ios android].freeze
MAX_POLL_FAILURES =

Consecutive failures tolerated mid-poll; one blip must not kill a deploy whose build is succeeding server-side.

3
TokenExpiredError =
Class.new(StandardError)
ConnectionError =
Class.new(StandardError)
NETWORK_ERRORS =
[
  SocketError,
  Errno::ECONNREFUSED,
  Errno::ECONNRESET,
  Net::OpenTimeout,
  Net::ReadTimeout,
  OpenSSL::SSL::SSLError
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Deploy

Returns a new instance of Deploy.



32
33
34
35
# File 'lib/ruby_native/cli/deploy.rb', line 32

def initialize(argv)
  @if_needed = argv.include?("--if-needed")
  @platform = parse_platform(argv)
end

Instance Method Details

#runObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/ruby_native/cli/deploy.rb', line 37

def run
  load_config!
  ensure_authenticated!
  app_id = resolve_app_id!

  if @if_needed && skip_build?(app_id)
    puts "Ruby Native v#{RubyNative::VERSION} already built. Skipping deploy."
    return
  end

  build = trigger_build(app_id)
  return if @if_needed

  poll_build_status(app_id, build)
rescue TokenExpiredError
  abort_token_expired!
rescue ConnectionError => error
  puts error.message
  puts "Check your internet connection and run `ruby_native deploy` again."
  exit 1
end