aktion_cap 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +16 -0
- data/README.md +7 -4
- data/lib/aktion_cap/tasks.rb +38 -35
- data/lib/aktion_cap/version.rb +1 -1
- data/spec/capify_spec.rb +5 -1
- data/spec/fixtures/custom_capify_responses +1 -0
- data/spec/fixtures/default_capify_responses +1 -0
- metadata +4 -3
data/CHANGELOG.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# v0.1.1
|
2
|
+
|
3
|
+
* Remove harded stages in config/deploy.rb
|
4
|
+
* Improvements to interactive configuration
|
5
|
+
* Make ssh user configurable, defaults to deployer
|
6
|
+
|
7
|
+
# v0.1.0
|
8
|
+
|
9
|
+
Released *rake capify* task. Provides an interactive version of capify.
|
10
|
+
|
11
|
+
# v0.0.1
|
12
|
+
|
13
|
+
Initial release.
|
14
|
+
|
15
|
+
* Provides capistrano, multistage capistrano and rvm capistrano gems
|
16
|
+
|
data/README.md
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
# AktionCap
|
2
2
|
|
3
|
-
|
3
|
+
A metagem for use with capistrano. It includes capistrano with multistage extension, rvm integration and rake tasks to make capistrano management simpler.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
7
|
Add this line to your application's Gemfile:
|
8
8
|
|
9
|
-
gem 'aktion_cap'
|
9
|
+
gem 'aktion_cap', '~> 0.1.0'
|
10
10
|
|
11
11
|
And then execute:
|
12
12
|
|
13
|
-
$ bundle
|
13
|
+
$ bundle install
|
14
14
|
|
15
15
|
Or install it yourself as:
|
16
16
|
|
@@ -18,7 +18,10 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
-
|
21
|
+
### capify
|
22
|
+
|
23
|
+
The `rake capify` command acts as a replacement for `capify`. When run it will prompt a series of questions about the deployment and output files
|
24
|
+
fully configured for deployment. The prompts will attempt to supply defaults based on the application.
|
22
25
|
|
23
26
|
## Contributing
|
24
27
|
|
data/lib/aktion_cap/tasks.rb
CHANGED
@@ -19,11 +19,13 @@ module AktionCap
|
|
19
19
|
q.default = `git config --local remote.origin.url`.strip
|
20
20
|
end
|
21
21
|
end
|
22
|
+
options[:ssh_user] = ask("Enter the ssh username to deploy with: ") {|q| q.default = 'deployer'}
|
22
23
|
options[:stages] = ask("Enter the deployment stages(separate with commas): ") {|q| q.default = 'production'}.split(',').map(&:to_sym)
|
23
24
|
options[:stages].each do |stage|
|
25
|
+
say("\nConfigure #{stage.to_s}:")
|
24
26
|
options[stage] = {}
|
25
|
-
options[stage][:server_hostname] = ask("Enter the server hostname or IP: ") {|q| q.default = 'localhost'}
|
26
|
-
options[stage][:server_port] = ask("Enter the ssh port to connect to: ", Integer) do |q|
|
27
|
+
options[stage][:server_hostname] = ask(" Enter the server hostname or IP: ") {|q| q.default = 'localhost'}
|
28
|
+
options[stage][:server_port] = ask(" Enter the ssh port to connect to: ", Integer) do |q|
|
27
29
|
if options[stage][:server_hostname] == 'localhost'
|
28
30
|
q.default = '2222'
|
29
31
|
else
|
@@ -34,36 +36,31 @@ module AktionCap
|
|
34
36
|
options
|
35
37
|
end
|
36
38
|
|
37
|
-
def
|
38
|
-
|
39
|
-
|
40
|
-
options = prompts_for_capify
|
41
|
-
|
42
|
-
capfile = File.join(Dir.pwd, 'Capfile')
|
43
|
-
File.open(capfile, 'w') do |f|
|
44
|
-
f << <<FILE
|
39
|
+
def write_capfile
|
40
|
+
File.open('Capfile', 'w') do |file|
|
41
|
+
file << <<-FILE
|
45
42
|
load 'deploy'
|
46
43
|
load 'config/deploy'
|
47
|
-
FILE
|
48
|
-
|
49
|
-
|
44
|
+
FILE
|
45
|
+
end
|
46
|
+
end
|
50
47
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
set :stages %w(
|
48
|
+
def write_config_deploy(opts)
|
49
|
+
File.open('config/deploy.rb', 'w') do |file|
|
50
|
+
file << <<-FILE
|
51
|
+
set :stages, %w(#{opts[:stages].map(&:to_s).join(' ')})
|
55
52
|
|
56
53
|
require 'capistrano/ext/multistage'
|
57
54
|
require 'bundler/capistrano'
|
58
55
|
require 'rvm/capistrano'
|
59
56
|
require './config/boot'
|
60
57
|
|
61
|
-
ssh_options[:username] = '
|
58
|
+
ssh_options[:username] = '#{opts[:ssh_user]}'
|
62
59
|
ssh_options[:forward_agent] = true
|
63
60
|
|
64
|
-
set :application, '#{
|
65
|
-
set :repository, '#{
|
66
|
-
set :scm, :#{
|
61
|
+
set :application, '#{opts[:application]}'
|
62
|
+
set :repository, '#{opts[:repository]}'
|
63
|
+
set :scm, :#{opts[:scm]}
|
67
64
|
set :deploy_via, :remote_cache
|
68
65
|
set :deploy_to, "/var/www/\#{application}/\#{stage}"
|
69
66
|
set :rvm_type, :user
|
@@ -75,24 +72,30 @@ set :tasks_for_rake, %w(db:migrate)
|
|
75
72
|
after 'deploy:update_code', 'deploy:create_shared_symlinks'
|
76
73
|
before 'deploy:create_symlink', 'deploy:run_rake_tasks'
|
77
74
|
after 'deploy', 'deploy:cleanup'
|
78
|
-
FILE
|
79
|
-
|
80
|
-
|
81
|
-
deploy_dir = File.join(Dir.pwd, 'config', 'deploy')
|
82
|
-
Dir.mkdir(deploy_dir) unless Dir.exists?(deploy_dir)
|
75
|
+
FILE
|
76
|
+
end
|
77
|
+
end
|
83
78
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
set :
|
89
|
-
set :server_hostname, '#{options[stage][:server_hostname]}'
|
79
|
+
def write_stage_config_deploy(stage, opts)
|
80
|
+
File.open("config/deploy/#{stage.to_s}.rb", 'w') do |file|
|
81
|
+
file << <<-FILE
|
82
|
+
set :port, #{opts[stage][:server_port]}
|
83
|
+
set :server_hostname, '#{opts[stage][:server_hostname]}'
|
90
84
|
role :app, server_hostname
|
91
85
|
role :web, server_hostname
|
92
86
|
role :db, server_hostname, primary: true
|
93
|
-
FILE
|
94
|
-
|
95
|
-
|
87
|
+
FILE
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def install
|
92
|
+
desc 'capify'
|
93
|
+
task 'capify' do
|
94
|
+
opts = prompts_for_capify
|
95
|
+
Dir.mkdir('config/deploy') unless Dir.exists?('config/deploy')
|
96
|
+
write_capfile
|
97
|
+
write_config_deploy opts
|
98
|
+
opts[:stages].each{|stage| write_stage_config_deploy(stage, opts)}
|
96
99
|
end
|
97
100
|
end
|
98
101
|
end
|
data/lib/aktion_cap/version.rb
CHANGED
data/spec/capify_spec.rb
CHANGED
@@ -29,7 +29,7 @@ RSpec::Matchers.define :contain_content do |expected_line|
|
|
29
29
|
failure_message_for_should do |file|
|
30
30
|
file = File.open(file) if file.is_a? String
|
31
31
|
lines = file.lines.to_a
|
32
|
-
best_match = [string_similarity(expected_line, lines.first)]
|
32
|
+
best_match = [string_similarity(expected_line, lines.first), lines.first]
|
33
33
|
lines[1..-1].each do |l|
|
34
34
|
score = string_similarity(expected_line, l)
|
35
35
|
best_match = [score,l] if score > best_match[0]
|
@@ -64,9 +64,11 @@ describe 'capify' do
|
|
64
64
|
|
65
65
|
describe "dummy/config/deploy.rb" do
|
66
66
|
it { should be_a_file_that_exists }
|
67
|
+
it { should contain_content "set :stages, %w(production)" }
|
67
68
|
it { should contain_content "set :application, 'dummy'" }
|
68
69
|
it { should contain_content "set :repository, 'git@github.com:AktionLab/aktion_cap'" }
|
69
70
|
it { should contain_content "set :scm, :git" }
|
71
|
+
it { should contain_content "ssh_options[:username] = 'deployer'" }
|
70
72
|
end
|
71
73
|
|
72
74
|
describe 'dummy/config/deploy/production.rb' do
|
@@ -83,8 +85,10 @@ describe 'capify' do
|
|
83
85
|
|
84
86
|
describe 'dummy/config/deploy.rb' do
|
85
87
|
it { should be_a_file_that_exists }
|
88
|
+
it { should contain_content "set :stages, %w(staging production)" }
|
86
89
|
it { should contain_content "set :application, 'custom_application'" }
|
87
90
|
it { should contain_content "set :repository, 'git@github.com:someone/custom_application'" }
|
91
|
+
it { should contain_content "ssh_options[:username] = 'www-data'" }
|
88
92
|
end
|
89
93
|
|
90
94
|
describe 'dummy/config/deploy/production.rb' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aktion_cap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -69,6 +69,7 @@ files:
|
|
69
69
|
- .gitignore
|
70
70
|
- .rspec
|
71
71
|
- .rvmrc
|
72
|
+
- CHANGELOG.md
|
72
73
|
- Gemfile
|
73
74
|
- LICENSE
|
74
75
|
- README.md
|
@@ -98,7 +99,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
98
99
|
version: '0'
|
99
100
|
segments:
|
100
101
|
- 0
|
101
|
-
hash:
|
102
|
+
hash: 1872119278476282222
|
102
103
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
104
|
none: false
|
104
105
|
requirements:
|
@@ -107,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
108
|
version: '0'
|
108
109
|
segments:
|
109
110
|
- 0
|
110
|
-
hash:
|
111
|
+
hash: 1872119278476282222
|
111
112
|
requirements: []
|
112
113
|
rubyforge_project:
|
113
114
|
rubygems_version: 1.8.24
|