Class: DPL::Provider::NPM
Constant Summary
collapse
- NPMRC_FILE =
'~/.npmrc'
- DEFAULT_NPM_REGISTRY =
'registry.npmjs.org'
Instance Attribute Summary
#context, #options
Instance Method Summary
collapse
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_app ⇒ Object
13
14
|
# File 'lib/dpl/provider/npm.rb', line 13
def check_app
end
|
#check_auth ⇒ Object
22
23
24
25
|
# File 'lib/dpl/provider/npm.rb', line 22
def check_auth
setup_auth
log "Authenticated with email #{option(:email)}"
end
|
#needs_key? ⇒ Boolean
9
10
11
|
# File 'lib/dpl/provider/npm.rb', line 9
def needs_key?
false
end
|
#package_registry ⇒ Object
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/dpl/provider/npm.rb', line 34
def package_registry
if File.exists?('package.json')
data = JSON.parse(File.read('package.json'))
if data['publishConfig'] && data['publishConfig']['registry']
return data['publishConfig']['registry']
end
end
DEFAULT_NPM_REGISTRY
end
|
#push_app ⇒ Object
27
28
29
30
31
32
|
# File 'lib/dpl/provider/npm.rb', line 27
def push_app
log "NPM API key format changed recently. If your deployment fails, check your API key in ~/.npmrc."
log "http://docs.travis-ci.com/user/deployment/npm/"
context.shell "env NPM_API_KEY=#{option(:api_key)} npm publish"
FileUtils.rm(File.expand_path(NPMRC_FILE))
end
|
#setup_auth ⇒ Object
16
17
18
19
20
|
# File 'lib/dpl/provider/npm.rb', line 16
def setup_auth
file = File.open(File.expand_path(NPMRC_FILE), 'w')
file.puts("//#{package_registry}/:_authToken=${NPM_API_KEY}")
file.flush
end
|