Permalink
Browse files

Rewrite for Capistrano v3

  • Loading branch information...
1 parent 5da070f commit 0268eb93bb89f74ad0013d2ecdd57f828165358f @swalkinshaw swalkinshaw committed Oct 1, 2013
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,47 +1,46 @@
-# capistrano-composer
+# Capistrano::Composer
-capistrano-composer is a [Capistrano](https://github.com/capistrano/capistrano) extension that will let you use [Composer](http://getcomposer.org/) to manage your dependencies during your deploy process.
+Composer for support for Capistrano 3.x
## Installation
-1. Install the Gem
+Add this line to your application's Gemfile:
-```bash
-gem install capistrano-composer
+```ruby
+gem 'capistrano-composer'
+gem 'capistrano', github: 'capistrano/capistrano', branch: 'v3'
```
-Or if you're using Bundler, add it to your `Gemfile`:
+And then execute:
-```ruby
-gem 'capistrano-composer', github: 'swalkinshaw/composer'
-```
+ $ bundle
-2. Add to `Capfile` or `config/deploy.rb`:
+Or install it yourself as:
-```ruby
-require 'capistrano/composer'
-```
+ $ gem install capistrano-composer
## Usage
-Add the task to your `deploy.rb`:
+Require in `Capfile` to use the default task:
```ruby
-after 'deploy:finalize_update', 'composer:install'
+require 'capistrano/composer'
```
-### Tasks
-
-* `composer:install`: Installs the project dependencies from the composer.lock file if present, or falls back on the composer.json.
-* `composer:update`: Updates your dependencies to the latest version according to composer.json, and updates the composer.lock file.
-* `composer:dump_autoload`: Dumps an optimized autoloader.
-
-### Dependencies
+The task will run before `deploy:updated` as part of Capistrano's default deploy,
+or can be run in isolation with `cap production composer:install`
-This extension also adds `composer_path` as a Capistrano dependency. Meaning when you run `cap deploy:check`, it will make sure the `composer` command exists.
+Configurable options, shown here with defaults:
-## Configuration
+```ruby
+set :composer_flags, '--production --silent'
+set :composer_roles, :all
+```
-* `composer_path`: Path to the Composer bin (defaults to `/usr/local/bin/composer`)
-* `composer_options`: Options passed to composer command (defaults to `--no-scripts --no-dev --verbose --prefer-dist --optimize-autoloader --no-progress`)
+## Contributing
+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/composer/version'
+Gem::Specification.new do |spec|
+ spec.name = 'capistrano-composer'
+ spec.version = '0.0.1'
+ spec.authors = ['Scott Walkinshaw']
+ spec.email = ['scott.walkinshaw@gmail.com']
+ spec.description = %q{Composer support for Capistrano 3.x}
+ spec.summary = %q{Composer support for Capistrano 3.x}
+ spec.homepage = 'https://github.com/capistrano/composer'
+ spec.license = 'MIT'
-Gem::Specification.new do |s|
- s.name = 'capistrano-composer'
- s.version = Capistrano::Composer::VERSION
- s.authors = ['Scott Walkinshaw']
- s.email = ['scott.walkinshaw@gmail.com']
- s.homepage = 'https://github.com/swalkinshaw/capistrano-composer'
- s.summary = %q{Capistrano extension that adds Composer tasks}
- 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.
@@ -1,23 +1 @@
-Capistrano::Configuration.instance(true).load do
- set :composer_path, '/usr/local/bin/composer'
- set :composer_options, '--no-scripts --no-dev --verbose --prefer-dist --optimize-autoloader --no-progress'
-
- depend :remote, :command, composer_path
-
- namespace :composer do
- desc 'Installs the project dependencies from the composer.lock file if present, or falls back on the composer.json.'
- task :install, :roles => :app, :except => { :no_release => true } do
- try_sudo "cd #{latest_release} && #{composer_path} install #{composer_options}"
- end
-
- desc 'Updates your dependencies to the latest version according to composer.json, and updates the composer.lock file.'
- task :update, :roles => :app, :except => { :no_release => true } do
- try_sudo "cd #{latest_release} && #{composer_path} update #{composer_options}"
- end
-
- desc 'Dumps an optimized autoloader.'
- task :dump_autoload, :roles => :app, :except => { :no_release => true } do
- try_sudo "cd #{latest_release} && #{composer_path} dump-autoload --optimize"
- end
- end
-end
+load File.expand_path('../tasks/composer.cap', __FILE__)
@@ -1,5 +0,0 @@
-module Capistrano
- module Composer
- VERSION = '0.0.1'
- end
-end
@@ -0,0 +1,27 @@
+namespace :composer do
+ desc <<-DESC
+ Install the project dependencies via Composer. By default, require-dev \
+ dependencies will not be installed.
+
+ You can override any of the defaults by setting the variables shown below.
+
+ set :composer_flags, '--no-dev --no-scripts --quiet --optimize-autoloader'
+ set :composer_roles, :all
+ DESC
+ task :install do
+ on roles fetch(:composer_roles) do
+ within release_path do
+ execute :composer, fetch(:composer_flags)
+ end
+ end
+ end
+
+ before 'deploy:updated', 'composer:install'
+end
+
+namespace :load do
+ task :defaults do
+ set :composer_flags, '--no-dev --no-scripts --quiet --optimize-autoloader'
+ set :composer_roles, :all
+ end
+end

0 comments on commit 0268eb9

Please sign in to comment.