Class: DPL::Provider::Nodejitsu

Inherits:
Provider
  • Object
show all
Defined in:
lib/dpl/provider/nodejitsu.rb

Constant Summary collapse

CONFIG_FILE =
'.dpl/jitsu.json'

Instance Method Summary collapse

Instance Method Details

#check_app ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/dpl/provider/nodejitsu.rb', line 20

def check_app
  error "missing package.json" unless File.exist? 'package.json'

  package = JSON.parse File.read('package.json')
  message = "missing %s in package.json, see https://www.nodejitsu.com/documentation/appendix/package-json/"
  error message % "subdomain"    unless package['subdomain']
  error message % "node version" unless package['engines'] and package['engines']['node']
  error message % "start script" unless package['scripts'] and package['scripts']['start']
end

#check_auth ⇒ Object



16
17
18
# File 'lib/dpl/provider/nodejitsu.rb', line 16

def check_auth
  File.open(CONFIG_FILE, 'w') { |f| f << config.to_json }
end

#config ⇒ Object



8
9
10
11
12
13
14
# File 'lib/dpl/provider/nodejitsu.rb', line 8

def config
  {
    "username"     => option(:username, :user_name, :user),
    "apiToken"     => option(:api_key),
    "apiTokenName" => "travis"
  }
end

#needs_key? ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/dpl/provider/nodejitsu.rb', line 30

def needs_key?
  false
end

#push_app ⇒ Object



34
35
36
# File 'lib/dpl/provider/nodejitsu.rb', line 34

def push_app
  context.shell "jitsu deploy -j #{CONFIG_FILE} --release=yes"
end