Permalink
Browse files

Capistrano v3 rewrite

  • Loading branch information...
1 parent ddc8780 commit be3a34de2f52a599d586c073eeaa6f95df9157b6 @swalkinshaw swalkinshaw committed Oct 1, 2013
Showing with 110 additions and 77 deletions.
  1. +0 −4 .gitignore
  2. +1 −1 Gemfile
  3. +20 −0 LICENSE
  4. +22 −0 LICENSE.txt
  5. +22 −42 README.md
  6. +16 −12 capistrano-npm.gemspec
  7. 0 lib/capistrano-npm.rb
  8. +1 −13 lib/capistrano/npm.rb
  9. +0 −5 lib/capistrano/npm/version.rb
  10. +28 −0 lib/capistrano/tasks/npm.cap
View
@@ -1,4 +0,0 @@
-*.gem
-.bundle
-Gemfile.lock
-pkg/*
View
@@ -1,4 +1,4 @@
source 'https://rubygems.org'
-# Specify your gem's dependencies in capistrano-composer.gemspec
+# Specify your gem's dependencies in capistrano-bundler.gemspec
gemspec
View
@@ -0,0 +1,20 @@
+The MIT License (MIT)
+
+Copyright (c) 2013 Capistrano, your one stop deployment shop.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
@@ -0,0 +1,22 @@
+Copyright (c) 2013 swalkinshaw
+
+MIT License
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
@@ -1,60 +1,40 @@
-# capistrano-npm
+# Capistrano::npm
-capistrano-npm is a [Capistrano](https://github.com/capistrano/capistrano) extension that will let you run [npm](https://npmjs.org/) during your deploy process.
+npm for support for Capistrano 3.x
## Installation
-1. Install the Gem
+Add this line to your application's Gemfile:
-```bash
-gem install capistrano-npm
-```
+ gem 'capistrano-npm'
+ gem 'capistrano', github: 'capistrano/capistrano', branch: 'v3'
-Or if you're using Bundler, add it to your `Gemfile`:
+And then execute:
-```ruby
-gem 'capistrano-npm'
-```
+ $ bundle
-2. Add to `Capfile` or `config/deploy.rb`:
+Or install it yourself as:
-```ruby
-require 'capistrano/npm'
-```
+ $ gem install capistrano-npm
## Usage
-Add the task to your `deploy.rb`:
+Require in `Capfile` to use the default task:
-```ruby
-after 'deploy:finalize_update', 'npm:install'
-```
+ require 'capistrano/npm'
-And `npm install` will be run in your in your `latest_release` path on `deploy:finalize_update`.
+The task will run before `deploy:updated` as part of Capistrano's default deploy,
+or can be run in isolation with `cap production npm:install`
-### Limitations
+Configurable options, shown here with defaults:
-There's currently no way to specify a path other than the default `latest_releast` where npm installs. This will be fixed in a future version.
+ set :npm_flags, '--production --silent'
+ set :npm_roles, :all
-### Optimize
+## Contributing
-Ideally when using npm, you should add `node_modules` to your `.gitignore` file to keep them out of your repository.
-
-Since `npm install` does not guarantee that you will get the same package versions when deploying, you should use `npm shrinkwrap` (https://npmjs.org/doc/shrinkwrap.html) first.
-
-Running `npm shrinkwrap` will created a `npm-shrinkwrap.json` file that locks down the dependency versions. Check this file into your repository.
-
-Now when deploying, `npm install` will detect the `npm-shrinkwrap.json` file and use that to install the packages.
-
-### Tasks
-
-* `npm:install`: Runs `npm install`.
-
-### Dependencies
-
-This extension also adds the `npm` command as a Capistrano dependency. Meaning when you run `cap deploy:check`, it will make sure the `npm` command exists.
-
-### Configuration
-
-* `npm_path`: Path to npm bin on the remote server. Defaults to just `npm` as its assumed to be in your `$PATH`.
-* `npm_options`: Options for `npm` command. Defaults to `--production --silent` to avoid installing dev dependencies.
+1. Fork it
+2. Create your feature branch (`git checkout -b my-new-feature`)
+3. Commit your changes (`git commit -am 'Add some feature'`)
+4. Push to the branch (`git push origin my-new-feature`)
+5. Create new Pull Request
@@ -2,19 +2,23 @@
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
-require 'capistrano/npm/version'
+Gem::Specification.new do |spec|
+ spec.name = 'capistrano-npm'
+ spec.version = '0.0.1'
+ spec.authors = ['Scott Walkinshaw']
+ spec.email = ['scott.walkinshaw@gmail.com']
+ spec.description = %q{npm support for Capistrano 3.x}
+ spec.summary = %q{npm support for Capistrano 3.x}
+ spec.homepage = 'https://github.com/capistrano/npm'
+ spec.license = 'MIT'
-Gem::Specification.new do |s|
- s.name = 'capistrano-npm'
- s.version = Capistrano::Npm::VERSION
- s.authors = ['Scott Walkinshaw']
- s.email = ['scott.walkinshaw@gmail.com']
- s.homepage = 'https://github.com/swalkinshaw/capistrano-npm'
- s.summary = %q{Capistrano extension for npm (Node Packaged Modules)}
- s.license = 'MIT'
+ spec.files = `git ls-files`.split($/)
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
+ spec.require_paths = ['lib']
- s.files = `git ls-files`.split($/)
- s.require_paths = %w(lib)
+ spec.add_dependency 'capistrano', '>= 3.0.0.pre'
- s.add_dependency 'capistrano', '>= 2.5.5'
+ spec.add_development_dependency 'bundler', '~> 1.3'
+ spec.add_development_dependency 'rake'
end
No changes.
View
@@ -1,13 +1 @@
-Capistrano::Configuration.instance(true).load do
- set :npm_path, 'npm'
- set :npm_options, '--production --silent'
-
- depend :remote, :command, npm_path
-
- namespace :npm do
- desc 'Runs npm install.'
- task :install, :roles => :app, :except => { :no_release => true } do
- try_sudo "cd #{latest_release} && #{npm_path} #{npm_options} install"
- end
- end
-end
+load File.expand_path('../tasks/npm.cap', __FILE__)
@@ -1,5 +0,0 @@
-module Capistrano
- module Npm
- VERSION = '0.0.2'
- end
-end
@@ -0,0 +1,28 @@
+namespace :npm do
+ desc <<-DESC
+ Install the project dependencies via npm. By default, devDependencies \
+ will not be installed. The install command is executed \
+ with the --production and --silent flags.
+
+ You can override any of these defaults by setting the variables shown below.
+
+ set :npm_flags, '--production --silent'
+ set :npm_roles, :all
+ DESC
+ task :install do
+ on roles fetch(:npm_roles) do
+ within release_path do
+ execute :npm, fetch(:npm_flags)
+ end
+ end
+ end
+
+ before 'deploy:updated', 'npm:install'
+end
+
+namespace :load do
+ task :defaults do
+ set :npm_flags, '--production --silent'
+ set :npm_roles, :all
+ end
+end

0 comments on commit be3a34d

Please sign in to comment.