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, #default_text_charset, #default_text_charset?, #deploy, deprecated, #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
14
15
|
# File 'lib/dpl/provider/npm.rb', line 14
def check_app
end
|
#check_auth ⇒ Object
23
24
25
26
|
# File 'lib/dpl/provider/npm.rb', line 23
def check_auth
setup_auth
log "Authenticated with email #{option(:email)}"
end
|
#needs_key? ⇒ Boolean
10
11
12
|
# File 'lib/dpl/provider/npm.rb', line 10
def needs_key?
false
end
|
#npm_version ⇒ Object
59
60
61
|
# File 'lib/dpl/provider/npm.rb', line 59
def npm_version
`npm --version`
end
|
#npmrc_file_content ⇒ Object
50
51
52
53
54
55
56
57
|
# File 'lib/dpl/provider/npm.rb', line 50
def npmrc_file_content
log "NPM version: #{npm_version}"
if npm_version =~ /^1/
"_auth = ${NPM_API_KEY}\nemail = #{option(:email)}"
else
"//#{package_registry}/:_authToken=${NPM_API_KEY}"
end
end
|
#package_registry ⇒ Object
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/dpl/provider/npm.rb', line 39
def package_registry
if File.exists?('package.json')
data = JSON.parse(File.read('package.json'))
if data['publishConfig'] && data['publishConfig']['registry']
return URI(data['publishConfig']['registry']).host
end
end
DEFAULT_NPM_REGISTRY
end
|
#push_app ⇒ Object
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/dpl/provider/npm.rb', line 28
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/"
log "#{NPMRC_FILE} size: #{File.size(File.expand_path(NPMRC_FILE))}"
command = "env NPM_API_KEY=#{option(:api_key)} npm publish"
command << " --tag #{option(:tag)}" if options[:tag]
context.shell "#{command}"
FileUtils.rm(File.expand_path(NPMRC_FILE))
end
|
#setup_auth ⇒ Object
17
18
19
20
21
|
# File 'lib/dpl/provider/npm.rb', line 17
def setup_auth
file = File.open(File.expand_path(NPMRC_FILE), 'w')
file.puts(npmrc_file_content)
file.flush
end
|