Class: DPL::Provider::Nodejitsu

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

Constant Summary collapse

CONFIG_FILE =
'.dpl/jitsu.json'

Instance Attribute Summary

Attributes inherited from DPL::Provider

#context, #options

Instance Method Summary collapse

Methods inherited from DPL::Provider

apt_get, #cleanup, #commit_msg, context, #create_key, #deploy, #detect_encoding?, #encoding_for, #error, experimental, #initialize, #log, new, npm_g, #option, pip, requires, #run, #setup_git_credentials, #setup_git_ssh, #sha, shell, #uncleanup, #user_agent, #warn

Constructor Details

This class inherits a constructor from DPL::Provider

Instance Method Details

#check_appObject



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_authObject



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

#configObject



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_appObject



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

def push_app
  context.shell "jitsu deploy --jitsuconf #{File.expand_path(CONFIG_FILE)} --release=yes"
end