lib/dpl/providers/npm.rb in dpl-2.0.0.alpha.11 vs lib/dpl/providers/npm.rb in dpl-2.0.0.alpha.12
- old
+ new
@@ -1,9 +1,9 @@
module Dpl
module Providers
class Npm < Provider
- status :beta
+ status :stable
full_name 'npm'
description sq(<<-str)
tbd
@@ -17,40 +17,53 @@
opt '--api_token TOKEN', 'npm api token', alias: :api_key, required: true, secret: true, note: 'can be retrieved from your local ~/.npmrc file', see: 'https://docs.npmjs.com/creating-and-viewing-authentication-tokens'
opt '--access ACCESS', 'Access level', enum: %w(public private)
opt '--registry URL', 'npm registry url'
opt '--src SRC', 'directory or tarball to publish', default: '.'
opt '--tag TAGS', 'distribution tags to add'
+ opt '--run_script SCRIPT', 'run the given script from package.json', type: :array, note: 'skips running npm publish'
opt '--dry_run', 'performs test run without uploading to registry'
opt '--auth_method METHOD', 'Authentication method', enum: %w(auth)
REGISTRY = 'https://registry.npmjs.org'
NPMRC = '~/.npmrc'
msgs version: 'npm version: %{npm_version}',
login: 'Authenticated with API token %{api_token}'
cmds registry: 'npm config set registry "%{registry}"',
- deploy: 'npm publish %{src} %{publish_opts}'
+ publish: 'npm publish %{src} %{publish_opts}',
+ run: 'npm run %{script}'
errs registry: 'Failed to set registry config',
- deploy: 'Failed pushing to npm'
+ publish: 'Failed to publish',
+ run: 'Failed to run script %{script}'
def login
info :version
info :login
write_npmrc
shell :registry
end
def deploy
- shell :deploy
+ if run_script?
+ run_scripts
+ else
+ shell :publish
+ end
end
def finish
remove_npmrc
end
private
+
+ def run_scripts
+ run_script.each do |script|
+ shell :run, script: script
+ end
+ end
def publish_opts
opts_for(%i(access tag dry_run), dashed: true)
end