mirror of
https://github.com/capistrano/capistrano
synced 2023-03-27 23:21:18 -04:00
load multistage configuration, pass to ssh kit
This commit is contained in:
parent
13e7b72b8e
commit
b05649c33f
4 changed files with 33 additions and 17 deletions
|
@ -1,4 +1,4 @@
|
|||
# Capistrano
|
||||
# Capistrano [](https://travis-ci.org/capistrano/capistrano)
|
||||
|
||||
wip - aim here is to get 'something' up and running
|
||||
|
||||
|
@ -17,14 +17,14 @@ TODO:
|
|||
|
||||
- [x] before/after task hooks
|
||||
- [x] handle multi stage
|
||||
- [ ] pass any necessary configuration from deploy.rb to SSHKit
|
||||
- [x] pass any necessary configuration from deploy.rb to SSHKit
|
||||
- [ ] is Capfile still legit? (although capfile/capfile.rb are already alternatives by default)
|
||||
|
||||
## Installation
|
||||
|
||||
Add this line to your application's Gemfile:
|
||||
|
||||
gem 'capistrano' github: 'capistrano/capistrano', branch: :wip
|
||||
gem 'capistrano' github: 'capistrano/capistrano', branch: :v3
|
||||
|
||||
And then execute:
|
||||
|
||||
|
|
|
@ -5,12 +5,16 @@ module Capistrano
|
|||
I18n.t(key, scope: :capistrano)
|
||||
end
|
||||
|
||||
def stages
|
||||
Dir["config/deploy/*.rb"].map { |f| File.basename(f, ".rb") }
|
||||
end
|
||||
|
||||
def stage_set?
|
||||
!!Capistrano::Env.configuration.stage
|
||||
!!env.stage
|
||||
end
|
||||
|
||||
def before(task, prerequisite, *args, &block)
|
||||
rerequisite = Rake::Task.define_task(prerequisite, *args, &block) if block_given?
|
||||
prerequisite = Rake::Task.define_task(prerequisite, *args, &block) if block_given?
|
||||
Rake::Task[task].enhance [prerequisite]
|
||||
end
|
||||
|
||||
|
@ -21,16 +25,22 @@ module Capistrano
|
|||
end
|
||||
end
|
||||
|
||||
def configure_ssh_kit
|
||||
SSHKit.configure do |sshkit|
|
||||
sshkit.format = env.format
|
||||
end
|
||||
end
|
||||
|
||||
def invoke(task)
|
||||
Rake::Task[task].invoke
|
||||
end
|
||||
|
||||
def fetch(key)
|
||||
configuration.fetch(key)
|
||||
env.fetch(key)
|
||||
end
|
||||
|
||||
def set(key, value)
|
||||
configuration.set(key, value)
|
||||
env.set(key, value)
|
||||
end
|
||||
|
||||
def role(name)
|
||||
|
@ -45,14 +55,12 @@ module Capistrano
|
|||
Env.configuration
|
||||
end
|
||||
|
||||
# I prefer env.my_var
|
||||
# over fetch(:my_var)
|
||||
def env
|
||||
configuration
|
||||
end
|
||||
|
||||
def roles
|
||||
Env.configuration.roles
|
||||
env.roles
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,7 +8,7 @@ module Capistrano
|
|||
|
||||
class << self
|
||||
def configure(&block)
|
||||
@env = new &block
|
||||
@env ||= new &block
|
||||
end
|
||||
|
||||
def configuration
|
||||
|
@ -22,15 +22,15 @@ module Capistrano
|
|||
end
|
||||
|
||||
def set(key, value)
|
||||
@env[key] = value
|
||||
env[key] = value
|
||||
end
|
||||
|
||||
def fetch(value)
|
||||
@env[value]
|
||||
env[value]
|
||||
end
|
||||
|
||||
def respond_to?(method)
|
||||
@env.has_key?(method)
|
||||
env.has_key?(method)
|
||||
end
|
||||
|
||||
def role(title, servers)
|
||||
|
@ -41,5 +41,8 @@ module Capistrano
|
|||
def roles
|
||||
@roles ||= {}
|
||||
end
|
||||
|
||||
private
|
||||
attr_reader :env
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,8 +1,13 @@
|
|||
include Capistrano::DSL
|
||||
|
||||
# SSHKit.configure do |sshkit|
|
||||
# sshkit.format = env.format
|
||||
# end
|
||||
|
||||
stages.each do |stage|
|
||||
Rake::Task.define_task(stage) do
|
||||
load "config/deploy/#{stage}.rb"
|
||||
set(:stage, stage.to_sym)
|
||||
configure_ssh_kit
|
||||
end
|
||||
end
|
||||
|
||||
namespace :deploy do
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue