webistrano_cli 0.0.3 → 0.0.5
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/Gemfile +1 -1
- data/Gemfile.lock +48 -27
- data/README.rdoc +20 -8
- data/bin/webistrano_cli +21 -10
- data/lib/webistrano_cli/config.rb +43 -28
- data/lib/webistrano_cli/her_middlewares.rb +58 -0
- data/lib/webistrano_cli/models.rb +67 -0
- data/lib/webistrano_cli/task.rb +51 -25
- data/lib/webistrano_cli/version.rb +1 -1
- data/lib/webistrano_cli.rb +25 -10
- data/webistrano_cli.gemspec +7 -6
- metadata +136 -62
- data/lib/webistrano_cli/deployment.rb +0 -38
- data/lib/webistrano_cli/project.rb +0 -19
- data/lib/webistrano_cli/stage.rb +0 -16
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,42 +1,63 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
webistrano_cli (0.0.
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
webistrano_cli (0.0.4)
|
5
|
+
faraday_middleware (~> 0.9.0)
|
6
|
+
her (~> 0.6.2)
|
7
|
+
highline (~> 1.6.18)
|
8
|
+
mechanize (~> 2.6.0)
|
9
|
+
multi_xml (~> 0.5.3)
|
10
|
+
slop (~> 3.4.4)
|
9
11
|
|
10
12
|
GEM
|
11
13
|
remote: http://rubygems.org/
|
12
14
|
specs:
|
13
|
-
activemodel (3.
|
14
|
-
activesupport (= 3.
|
15
|
-
builder (~>
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
15
|
+
activemodel (3.2.13)
|
16
|
+
activesupport (= 3.2.13)
|
17
|
+
builder (~> 3.0.0)
|
18
|
+
activesupport (3.2.13)
|
19
|
+
i18n (= 0.6.1)
|
20
|
+
multi_json (~> 1.0)
|
21
|
+
builder (3.0.4)
|
22
|
+
domain_name (0.5.11)
|
23
|
+
unf (>= 0.0.5, < 1.0.0)
|
24
|
+
faraday (0.8.7)
|
25
|
+
multipart-post (~> 1.1)
|
26
|
+
faraday_middleware (0.9.0)
|
27
|
+
faraday (>= 0.7.4, < 0.9)
|
28
|
+
her (0.6.2)
|
29
|
+
activemodel (>= 3.0.0)
|
30
|
+
activesupport (>= 3.0.0)
|
31
|
+
faraday (~> 0.8)
|
32
|
+
multi_json (~> 1.7)
|
33
|
+
highline (1.6.18)
|
34
|
+
i18n (0.6.1)
|
35
|
+
mechanize (2.6.0)
|
36
|
+
domain_name (~> 0.5, >= 0.5.1)
|
37
|
+
mime-types (~> 1.17, >= 1.17.2)
|
38
|
+
net-http-digest_auth (~> 1.1, >= 1.1.1)
|
39
|
+
net-http-persistent (~> 2.5, >= 2.5.2)
|
27
40
|
nokogiri (~> 1.4)
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
41
|
+
ntlm-http (~> 0.1, >= 0.1.1)
|
42
|
+
webrobots (>= 0.0.9, < 0.2)
|
43
|
+
mime-types (1.23)
|
44
|
+
multi_json (1.7.2)
|
45
|
+
multi_xml (0.5.3)
|
46
|
+
multipart-post (1.2.0)
|
47
|
+
net-http-digest_auth (1.3)
|
48
|
+
net-http-persistent (2.8)
|
49
|
+
nokogiri (1.5.9)
|
50
|
+
ntlm-http (0.1.1)
|
32
51
|
rake (0.9.2)
|
33
|
-
slop (
|
34
|
-
|
35
|
-
|
52
|
+
slop (3.4.4)
|
53
|
+
unf (0.1.1)
|
54
|
+
unf_ext
|
55
|
+
unf_ext (0.0.6)
|
56
|
+
webrobots (0.1.1)
|
36
57
|
|
37
58
|
PLATFORMS
|
38
59
|
ruby
|
39
60
|
|
40
61
|
DEPENDENCIES
|
41
|
-
rake
|
62
|
+
rake (~> 0.9.2)
|
42
63
|
webistrano_cli!
|
data/README.rdoc
CHANGED
@@ -3,24 +3,36 @@
|
|
3
3
|
webistrano_cli - bash command allow to deploy projects from webistrano
|
4
4
|
|
5
5
|
=== Instalation
|
6
|
-
install gem:
|
7
6
|
|
8
7
|
gem install webistrano_cli
|
9
8
|
|
10
|
-
setup your
|
9
|
+
setup your env variables:
|
11
10
|
|
12
|
-
$ export
|
11
|
+
$ export WCLI_URL=webistrano_url
|
13
12
|
$ export WCLI_USER=user
|
14
13
|
$ export WCLI_PASSWORD=pass
|
15
14
|
|
16
|
-
|
15
|
+
or put config in ~/.webistrano_cli.yml
|
16
|
+
---
|
17
|
+
webistrano_cli:
|
18
|
+
url: webistrano_url
|
19
|
+
user: user
|
20
|
+
password: pass
|
21
|
+
defaults:
|
22
|
+
stage: staging
|
23
|
+
task: deploy:migrations
|
24
|
+
|
25
|
+
tip: when you don't provide settings above webistrano_cli will ask for it and save in ~/.webistrano_cli.yml
|
17
26
|
|
18
27
|
=== Usage
|
19
28
|
|
20
29
|
deploy example
|
21
30
|
|
22
|
-
$ webistrano_cli
|
23
|
-
|
24
|
-
defaults:
|
31
|
+
$ webistrano_cli
|
32
|
+
|
33
|
+
defaults:
|
34
|
+
project = current directory name
|
35
|
+
stage = staging
|
36
|
+
task = deploy:migrations
|
25
37
|
|
26
|
-
tip: webistrano_cli will ask for any prompt value
|
38
|
+
tip: webistrano_cli will ask for any prompt value
|
data/bin/webistrano_cli
CHANGED
@@ -1,27 +1,38 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
require 'rubygems'
|
3
|
-
|
4
|
-
# Set up gems listed in the Gemfile.
|
5
|
-
ENV['BUNDLE_GEMFILE'] = File.expand_path('../../Gemfile', __FILE__)
|
6
|
-
require 'bundler'
|
7
|
-
Bundler.setup
|
8
2
|
require 'slop'
|
9
3
|
require 'webistrano_cli'
|
10
4
|
|
5
|
+
config = WebistranoCli::Config.new
|
6
|
+
config.setup_and_load!
|
7
|
+
|
8
|
+
WebistranoCli.configure(
|
9
|
+
config.get_value('url'),
|
10
|
+
config.get_value('user'),
|
11
|
+
config.get_value('password')
|
12
|
+
)
|
13
|
+
|
11
14
|
# parse assumes ARGV, otherwise you can pass it your own Array
|
12
15
|
opts = Slop.new :help => true do
|
13
16
|
banner 'Usage: webistrano_cli -p project_name'
|
14
17
|
description 'command allow to deploy projects from webistrano'
|
15
|
-
on :p, :project
|
16
|
-
on :s, :stage
|
17
|
-
on :t, :task
|
18
|
+
on :p, :project=, 'Project name', :as => String
|
19
|
+
on :s, :stage=, 'Stage', :as => String
|
20
|
+
on :t, :task=, 'Task', :as => String
|
18
21
|
on :v, :version, 'Print the version' do
|
19
22
|
puts "Version #{WebistranoCli::VERSION}"
|
20
23
|
end
|
21
24
|
end
|
25
|
+
|
22
26
|
begin
|
23
27
|
opts.parse
|
24
|
-
|
28
|
+
hash = opts.to_hash
|
29
|
+
unless opts.p?
|
30
|
+
hash[:project] = File.split(Dir.pwd).last
|
31
|
+
puts "No project param, used current dir name."
|
32
|
+
end
|
33
|
+
hash = hash.inject({}) {|m, (k, v)| m[k] = v if v.present?; m}
|
34
|
+
hash.reverse_merge!(config.defaults)
|
35
|
+
WebistranoCli.deploy(hash)
|
25
36
|
rescue Slop::Error => ex
|
26
37
|
puts ex.message
|
27
38
|
end
|
@@ -4,50 +4,65 @@ module WebistranoCli
|
|
4
4
|
class Config
|
5
5
|
|
6
6
|
def initialize
|
7
|
-
@file_path
|
8
|
-
|
9
|
-
@config = YAML.load_file(@file_path) rescue nil
|
10
|
-
else
|
11
|
-
@config = nil
|
12
|
-
end
|
7
|
+
@file_path = File.expand_path('~/.webistrano_cli.yml')
|
8
|
+
@config = YAML.load_file(@file_path) rescue nil
|
13
9
|
end
|
14
10
|
|
15
|
-
def
|
16
|
-
config =
|
11
|
+
def load!(path)
|
12
|
+
@config = YAML.load_file(path)
|
13
|
+
end
|
17
14
|
|
18
|
-
|
19
|
-
|
15
|
+
def setup_and_load!
|
16
|
+
return @config if @config.presence
|
17
|
+
config = {}
|
18
|
+
# read config from ENV or ask for it
|
19
|
+
['url', 'user', 'password'].each do |field|
|
20
|
+
config[field] = ENV["WCLI_#{field.upcase}"]
|
20
21
|
next if config[field]
|
21
|
-
config[field] = ask("webistrano #{field}: ") do |q|
|
22
|
+
config[field] = ask("webistrano #{field}: ", String) do |q|
|
22
23
|
q.whitespace = :strip_and_collapse
|
23
24
|
q.validate = lambda { |p| p.length > 0 }
|
24
25
|
q.responses[:not_valid] = "can't be blank!"
|
25
26
|
end
|
26
27
|
end
|
28
|
+
@config = {'webistrano_cli' => config}
|
29
|
+
save_yaml
|
30
|
+
end
|
31
|
+
|
32
|
+
def defaults
|
33
|
+
{
|
34
|
+
:stage => get_value('defaults/stage') || 'staging',
|
35
|
+
:task => get_value('defaults/task') || 'deploy:migrations'
|
36
|
+
}
|
37
|
+
end
|
27
38
|
|
28
|
-
|
29
|
-
|
39
|
+
def get_value(path)
|
40
|
+
nested = path.to_s.split('/')
|
41
|
+
current = @config['webistrano_cli']
|
42
|
+
nested.each do |key|
|
43
|
+
current = current[key]
|
44
|
+
end
|
45
|
+
current
|
46
|
+
rescue
|
47
|
+
nil
|
48
|
+
end
|
49
|
+
|
50
|
+
def save_yaml
|
51
|
+
return @config if File.exists?(@file_path)
|
52
|
+
File.open(@file_path, 'w') do |file|
|
53
|
+
YAML.dump({
|
30
54
|
'webistrano_cli' => {
|
31
|
-
'
|
32
|
-
'user' => config[
|
33
|
-
'password' => config[
|
55
|
+
'url' => @config['url'].to_s,
|
56
|
+
'user' => @config['user'].to_s,
|
57
|
+
'password' => @config['password'].to_s,
|
34
58
|
'defaults' => {
|
35
59
|
'stage' => 'staging',
|
36
60
|
'task' => 'deploy:migrations'
|
37
61
|
}
|
38
62
|
}
|
39
|
-
}
|
40
|
-
|
41
|
-
|
42
|
-
config
|
43
|
-
end
|
44
|
-
|
45
|
-
def stage opt
|
46
|
-
opt || (@config['webistrano_cli']['defaults']['stage'] rescue nil) || 'staging'
|
47
|
-
end
|
48
|
-
|
49
|
-
def task opt
|
50
|
-
opt || (@config['webistrano_cli']['defaults']['task'] rescue nil) || 'deploy:migrations'
|
63
|
+
}, file)
|
64
|
+
end
|
65
|
+
@config
|
51
66
|
end
|
52
67
|
|
53
68
|
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require 'her'
|
3
|
+
require 'faraday_middleware'
|
4
|
+
require 'multi_xml'
|
5
|
+
|
6
|
+
# hack multi_xml parser
|
7
|
+
MultiXml.send(:remove_const, 'DISALLOWED_XML_TYPES')
|
8
|
+
MultiXml.const_set('DISALLOWED_XML_TYPES', [])
|
9
|
+
|
10
|
+
class HerXmlParser < Faraday::Response::ParseXml
|
11
|
+
def process_response(env)
|
12
|
+
case env[:status]
|
13
|
+
when 200
|
14
|
+
hash = parse(env[:body])
|
15
|
+
hash = HashWithIndifferentAccess.new(hash)
|
16
|
+
root = hash.keys.first
|
17
|
+
env[:body] = {
|
18
|
+
:data => hash[root],
|
19
|
+
:errors => {},
|
20
|
+
:metadata => {}
|
21
|
+
}
|
22
|
+
when 201
|
23
|
+
location = env[:response_headers]['location']
|
24
|
+
id = location.to_s.split('/').last.to_i
|
25
|
+
env[:body] = {
|
26
|
+
:data => {:id => id},
|
27
|
+
:errors => {},
|
28
|
+
:metadata => {}
|
29
|
+
}
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
class HerXMLPost < Faraday::Middleware
|
35
|
+
dependency 'active_support/all'
|
36
|
+
|
37
|
+
def initialize(app, options={})
|
38
|
+
@app = app
|
39
|
+
@options = options
|
40
|
+
end
|
41
|
+
|
42
|
+
def call(env)
|
43
|
+
if [:post, :put].include?(env[:method])
|
44
|
+
hash = env[:body]
|
45
|
+
root = hash.keys.first
|
46
|
+
env[:body] = (hash[root]).to_xml(:root => root)
|
47
|
+
end
|
48
|
+
@app.call(env)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
module Her
|
53
|
+
class Collection
|
54
|
+
def eq(value, field = :name)
|
55
|
+
self.find{|p| p.send(field) =~ Regexp.new(value)}
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require 'mechanize'
|
3
|
+
|
4
|
+
module WebistranoCli
|
5
|
+
|
6
|
+
class Deployment
|
7
|
+
include Her::Model
|
8
|
+
uses_api WebistranoCli::API
|
9
|
+
collection_path "projects/:project_id/stages/:stage_id/deployments"
|
10
|
+
include_root_in_json :deployment
|
11
|
+
end
|
12
|
+
|
13
|
+
class Project
|
14
|
+
include Her::Model
|
15
|
+
uses_api WebistranoCli::API
|
16
|
+
has_many :stages
|
17
|
+
end
|
18
|
+
|
19
|
+
class Stage
|
20
|
+
include Her::Model
|
21
|
+
uses_api WebistranoCli::API
|
22
|
+
belongs_to :project
|
23
|
+
|
24
|
+
def tasks
|
25
|
+
Task.all(:_project_id => self.project_id, :_stage_id => self.id)
|
26
|
+
end
|
27
|
+
|
28
|
+
def deploy_form_for(task_name)
|
29
|
+
agent = Mechanize.new
|
30
|
+
agent.user_agent_alias = 'Mac Safari'
|
31
|
+
|
32
|
+
login_page = agent.get("#{WebistranoCli.url}/sessions/new")
|
33
|
+
login_page.form_with(:action => '/sessions') { |f|
|
34
|
+
f.login = WebistranoCli.user
|
35
|
+
f.password = WebistranoCli.pass
|
36
|
+
}.submit
|
37
|
+
|
38
|
+
task_page = agent.get("#{WebistranoCli.url}/projects/#{project_id}/stages/#{id}/deployments/new?task=#{name}")
|
39
|
+
task_page.form_with(:action => /deployments/, :method => /post/i)
|
40
|
+
end
|
41
|
+
|
42
|
+
def prompt_task_config(task_name)
|
43
|
+
prompt_config = {}
|
44
|
+
|
45
|
+
deploy_form_for(task_name).fields_with(:name => /prompt_config/).each do |field|
|
46
|
+
field.name.match(/(\w+)\]$/)
|
47
|
+
prompt_config[$1.to_sym] = ask("=> Set #{$1}: ") do |q|
|
48
|
+
q.whitespace = :strip_and_collapse
|
49
|
+
q.validate = lambda { |p| p.length > 0 }
|
50
|
+
q.responses[:not_valid] = "#{field.name} => can't be blank!"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
prompt_config
|
54
|
+
end
|
55
|
+
|
56
|
+
def get_required_config(task_name)
|
57
|
+
required_keys = []
|
58
|
+
deploy_form_for(task_name).fields_with(:name => /prompt_config/).each do |field|
|
59
|
+
field.name.match(/(\w+)\]$/)
|
60
|
+
required_keys << $1.to_sym
|
61
|
+
end
|
62
|
+
required_keys.compact
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
data/lib/webistrano_cli/task.rb
CHANGED
@@ -1,35 +1,37 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
require 'active_resource'
|
3
|
-
require 'webistrano_cli/project'
|
4
|
-
require 'webistrano_cli/stage'
|
5
|
-
require 'webistrano_cli/deployment'
|
6
|
-
|
7
2
|
module WebistranoCli
|
8
3
|
class Task
|
9
4
|
attr_accessor :log
|
10
5
|
|
11
|
-
def initialize
|
12
|
-
puts
|
13
|
-
@project
|
14
|
-
puts
|
15
|
-
@stage
|
16
|
-
@
|
17
|
-
@log
|
6
|
+
def initialize project_name, stage_name, task_name
|
7
|
+
puts "=> Select project: #{project_name}"
|
8
|
+
@project = Project.all.eq(project_name)
|
9
|
+
puts "=> Select stage: #{stage_name}"
|
10
|
+
@stage = @project.stages.eq(stage_name)
|
11
|
+
@task_name = task_name
|
12
|
+
@log = ""
|
13
|
+
end
|
14
|
+
|
15
|
+
def trigger_deployment(params)
|
16
|
+
@deployment = Deployment.new(params)
|
17
|
+
@deployment.save
|
18
|
+
end
|
19
|
+
|
20
|
+
def reload_deployment
|
21
|
+
@deployment = Deployment.find(@deployment.id, {:project_id => @project.id, :stage_id => @stage.id})
|
18
22
|
end
|
19
23
|
|
20
24
|
def loop_latest_deployment
|
21
|
-
prefix_options = @deployment.prefix_options
|
22
25
|
begin
|
23
26
|
sleep 5
|
24
|
-
|
25
|
-
|
26
|
-
print_diff(@deployment)
|
27
|
+
reload_deployment
|
28
|
+
print_diff
|
27
29
|
end while @deployment.completed_at.nil?
|
28
30
|
end
|
29
31
|
|
30
|
-
def print_diff
|
31
|
-
if deployment.log
|
32
|
-
diff = deployment.log
|
32
|
+
def print_diff
|
33
|
+
if @deployment.try(:log)
|
34
|
+
diff = @deployment.log
|
33
35
|
diff.slice!(log)
|
34
36
|
print diff
|
35
37
|
log << diff
|
@@ -39,16 +41,40 @@ module WebistranoCli
|
|
39
41
|
def run
|
40
42
|
puts "=> Get prompt config..."
|
41
43
|
params = {
|
42
|
-
:task
|
43
|
-
:project_id
|
44
|
-
:stage_id
|
45
|
-
:prompt_config =>
|
44
|
+
:task => @task_name,
|
45
|
+
:project_id => @project.id,
|
46
|
+
:stage_id => @stage.id,
|
47
|
+
:prompt_config => @stage.prompt_task_config(@task_name)
|
46
48
|
}
|
47
|
-
|
48
|
-
|
49
|
+
|
50
|
+
puts "=> Task: #{@task_name}"
|
51
|
+
trigger_deployment(params)
|
49
52
|
loop_latest_deployment
|
50
53
|
puts "=> Status: #{@deployment.status}"
|
51
54
|
end
|
52
55
|
|
56
|
+
def quiet_run(prompt_config = {})
|
57
|
+
puts "=> Checking prompt config..."
|
58
|
+
required_keys = @stage.get_required_config(@task_name)
|
59
|
+
prompt_config.symbolize_keys!
|
60
|
+
|
61
|
+
if (required_keys - prompt_config).blank?
|
62
|
+
|
63
|
+
params = {
|
64
|
+
:task => @task_name,
|
65
|
+
:project_id => @project.id,
|
66
|
+
:stage_id => @stage.id,
|
67
|
+
:prompt_config => prompt_config
|
68
|
+
}
|
69
|
+
|
70
|
+
puts "=> Task: #{@task_name}"
|
71
|
+
trigger_deployment(params)
|
72
|
+
puts "=> Deploy started"
|
73
|
+
else
|
74
|
+
puts "=> Requied promt config to deploy: #{required_keys.join(', ')}"
|
75
|
+
puts "=> Deploy failed "
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
53
79
|
end
|
54
80
|
end
|
data/lib/webistrano_cli.rb
CHANGED
@@ -2,19 +2,34 @@
|
|
2
2
|
require 'highline/import'
|
3
3
|
require 'webistrano_cli/version'
|
4
4
|
require 'webistrano_cli/config'
|
5
|
-
require 'webistrano_cli/
|
5
|
+
require 'webistrano_cli/her_middlewares'
|
6
6
|
|
7
7
|
module WebistranoCli
|
8
|
+
API = Her::API.new
|
9
|
+
|
8
10
|
class << self
|
11
|
+
attr_accessor :url, :user, :pass
|
12
|
+
|
13
|
+
def configure(url, user, pass, &block)
|
14
|
+
@url = url; @user = user; @pass = pass
|
15
|
+
WebistranoCli::API.setup :url => url do |c|
|
16
|
+
c.headers['Accept'] = 'application/xml'
|
17
|
+
c.headers['Content-Type'] = 'application/xml'
|
18
|
+
c.basic_auth user, pass
|
19
|
+
c.response :logger if ENV['WCLI_DEBUG']
|
20
|
+
c.use HerXmlParser
|
21
|
+
c.use HerXMLPost
|
22
|
+
c.adapter Faraday.default_adapter
|
23
|
+
|
24
|
+
yield c if block_given?
|
25
|
+
end
|
26
|
+
require 'webistrano_cli/models'
|
27
|
+
require 'webistrano_cli/task'
|
28
|
+
end
|
29
|
+
|
9
30
|
def deploy opts = {}
|
10
|
-
|
11
|
-
config_hash = Config.new.get
|
12
|
-
[Project, Stage, Deployment].each { |model| model.configure(config_hash) }
|
13
|
-
Task.new(
|
14
|
-
opts[:project],
|
15
|
-
config.stage(opts[:stage]),
|
16
|
-
config.task(opts[:task])
|
17
|
-
).run
|
31
|
+
Task.new(opts[:project], opts[:stage], opts[:task]).run
|
18
32
|
end
|
19
33
|
end
|
20
|
-
|
34
|
+
|
35
|
+
end
|
data/webistrano_cli.gemspec
CHANGED
@@ -18,10 +18,11 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.executables = `if [ -d .git ]; then git ls-files -- bin/*; fi`.split("\n").map{ |f| File.basename(f) }
|
19
19
|
s.require_paths = ["lib"]
|
20
20
|
|
21
|
-
s.add_development_dependency 'rake'
|
22
|
-
s.add_dependency '
|
23
|
-
s.add_dependency '
|
24
|
-
s.add_dependency '
|
25
|
-
s.add_dependency '
|
26
|
-
|
21
|
+
s.add_development_dependency 'rake', '~> 0.9.2'
|
22
|
+
s.add_dependency 'her', '~> 0.6.2'
|
23
|
+
s.add_dependency 'faraday_middleware','~> 0.9.0'
|
24
|
+
s.add_dependency 'multi_xml', '~> 0.5.3'
|
25
|
+
s.add_dependency 'mechanize', '~> 2.6.0'
|
26
|
+
s.add_dependency 'slop', '~> 3.4.4'
|
27
|
+
s.add_dependency 'highline', '~> 1.6.18'
|
27
28
|
end
|
metadata
CHANGED
@@ -1,79 +1,144 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: webistrano_cli
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 5
|
10
|
+
version: 0.0.5
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- chytreg
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
17
|
+
|
18
|
+
date: 2013-04-23 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
15
21
|
name: rake
|
16
|
-
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
17
24
|
none: false
|
18
|
-
requirements:
|
19
|
-
- -
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 63
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
- 9
|
32
|
+
- 2
|
33
|
+
version: 0.9.2
|
22
34
|
type: :development
|
35
|
+
version_requirements: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: her
|
23
38
|
prerelease: false
|
24
|
-
|
25
|
-
- !ruby/object:Gem::Dependency
|
26
|
-
name: slop
|
27
|
-
requirement: &2153786320 !ruby/object:Gem::Requirement
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
28
40
|
none: false
|
29
|
-
requirements:
|
30
|
-
- -
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
|
41
|
+
requirements:
|
42
|
+
- - ~>
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 3
|
45
|
+
segments:
|
46
|
+
- 0
|
47
|
+
- 6
|
48
|
+
- 2
|
49
|
+
version: 0.6.2
|
33
50
|
type: :runtime
|
51
|
+
version_requirements: *id002
|
52
|
+
- !ruby/object:Gem::Dependency
|
53
|
+
name: faraday_middleware
|
34
54
|
prerelease: false
|
35
|
-
|
36
|
-
- !ruby/object:Gem::Dependency
|
37
|
-
name: highline
|
38
|
-
requirement: &2153785900 !ruby/object:Gem::Requirement
|
55
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
39
56
|
none: false
|
40
|
-
requirements:
|
41
|
-
- -
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
|
57
|
+
requirements:
|
58
|
+
- - ~>
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
hash: 59
|
61
|
+
segments:
|
62
|
+
- 0
|
63
|
+
- 9
|
64
|
+
- 0
|
65
|
+
version: 0.9.0
|
44
66
|
type: :runtime
|
67
|
+
version_requirements: *id003
|
68
|
+
- !ruby/object:Gem::Dependency
|
69
|
+
name: multi_xml
|
45
70
|
prerelease: false
|
46
|
-
|
47
|
-
|
71
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ~>
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
hash: 13
|
77
|
+
segments:
|
78
|
+
- 0
|
79
|
+
- 5
|
80
|
+
- 3
|
81
|
+
version: 0.5.3
|
82
|
+
type: :runtime
|
83
|
+
version_requirements: *id004
|
84
|
+
- !ruby/object:Gem::Dependency
|
48
85
|
name: mechanize
|
49
|
-
|
86
|
+
prerelease: false
|
87
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
50
88
|
none: false
|
51
|
-
requirements:
|
52
|
-
- -
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
|
89
|
+
requirements:
|
90
|
+
- - ~>
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
hash: 23
|
93
|
+
segments:
|
94
|
+
- 2
|
95
|
+
- 6
|
96
|
+
- 0
|
97
|
+
version: 2.6.0
|
55
98
|
type: :runtime
|
99
|
+
version_requirements: *id005
|
100
|
+
- !ruby/object:Gem::Dependency
|
101
|
+
name: slop
|
56
102
|
prerelease: false
|
57
|
-
|
58
|
-
- !ruby/object:Gem::Dependency
|
59
|
-
name: activeresource
|
60
|
-
requirement: &2153784980 !ruby/object:Gem::Requirement
|
103
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
61
104
|
none: false
|
62
|
-
requirements:
|
63
|
-
- -
|
64
|
-
- !ruby/object:Gem::Version
|
65
|
-
|
105
|
+
requirements:
|
106
|
+
- - ~>
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
hash: 31
|
109
|
+
segments:
|
110
|
+
- 3
|
111
|
+
- 4
|
112
|
+
- 4
|
113
|
+
version: 3.4.4
|
66
114
|
type: :runtime
|
115
|
+
version_requirements: *id006
|
116
|
+
- !ruby/object:Gem::Dependency
|
117
|
+
name: highline
|
67
118
|
prerelease: false
|
68
|
-
|
119
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
120
|
+
none: false
|
121
|
+
requirements:
|
122
|
+
- - ~>
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
hash: 43
|
125
|
+
segments:
|
126
|
+
- 1
|
127
|
+
- 6
|
128
|
+
- 18
|
129
|
+
version: 1.6.18
|
130
|
+
type: :runtime
|
131
|
+
version_requirements: *id007
|
69
132
|
description: Allow to deploy projects from webistrano via console
|
70
|
-
email:
|
133
|
+
email:
|
71
134
|
- dariusz.gertych@gmail.com
|
72
|
-
executables:
|
135
|
+
executables:
|
73
136
|
- webistrano_cli
|
74
137
|
extensions: []
|
138
|
+
|
75
139
|
extra_rdoc_files: []
|
76
|
-
|
140
|
+
|
141
|
+
files:
|
77
142
|
- .gitignore
|
78
143
|
- Gemfile
|
79
144
|
- Gemfile.lock
|
@@ -83,34 +148,43 @@ files:
|
|
83
148
|
- bin/webistrano_cli
|
84
149
|
- lib/webistrano_cli.rb
|
85
150
|
- lib/webistrano_cli/config.rb
|
86
|
-
- lib/webistrano_cli/
|
87
|
-
- lib/webistrano_cli/
|
88
|
-
- lib/webistrano_cli/stage.rb
|
151
|
+
- lib/webistrano_cli/her_middlewares.rb
|
152
|
+
- lib/webistrano_cli/models.rb
|
89
153
|
- lib/webistrano_cli/task.rb
|
90
154
|
- lib/webistrano_cli/version.rb
|
91
155
|
- webistrano_cli.gemspec
|
92
156
|
homepage: https://github.com/chytreg/webistrano_cli
|
93
157
|
licenses: []
|
158
|
+
|
94
159
|
post_install_message:
|
95
160
|
rdoc_options: []
|
96
|
-
|
161
|
+
|
162
|
+
require_paths:
|
97
163
|
- lib
|
98
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
164
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
99
165
|
none: false
|
100
|
-
requirements:
|
101
|
-
- -
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
|
104
|
-
|
166
|
+
requirements:
|
167
|
+
- - ">="
|
168
|
+
- !ruby/object:Gem::Version
|
169
|
+
hash: 3
|
170
|
+
segments:
|
171
|
+
- 0
|
172
|
+
version: "0"
|
173
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
174
|
none: false
|
106
|
-
requirements:
|
107
|
-
- -
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
|
175
|
+
requirements:
|
176
|
+
- - ">="
|
177
|
+
- !ruby/object:Gem::Version
|
178
|
+
hash: 3
|
179
|
+
segments:
|
180
|
+
- 0
|
181
|
+
version: "0"
|
110
182
|
requirements: []
|
183
|
+
|
111
184
|
rubyforge_project: webistrano_cli
|
112
|
-
rubygems_version: 1.8.
|
185
|
+
rubygems_version: 1.8.15
|
113
186
|
signing_key:
|
114
187
|
specification_version: 3
|
115
188
|
summary: Allow to deploy projects from webistrano via console
|
116
189
|
test_files: []
|
190
|
+
|
@@ -1,38 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
require 'mechanize'
|
3
|
-
module WebistranoCli
|
4
|
-
class Deployment < ActiveResource::Base
|
5
|
-
|
6
|
-
def self.configure(config)
|
7
|
-
self.site = config[:site] + "/projects/:project_id/stages/:stage_id"
|
8
|
-
self.user = config[:user]
|
9
|
-
self.password = config[:password]
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.get_prompt_config(project_id, stage_id, task)
|
13
|
-
prompt_config = {}
|
14
|
-
agent = Mechanize.new
|
15
|
-
agent.user_agent_alias = 'Mac Safari'
|
16
|
-
|
17
|
-
login_page = agent.get("#{Project.site}/sessions/new")
|
18
|
-
login_page.form_with(:action => '/sessions') { |f|
|
19
|
-
f.login = self.user
|
20
|
-
f.password = self.password
|
21
|
-
}.submit
|
22
|
-
|
23
|
-
task_page = agent.get("#{Project.site}/projects/#{project_id}/stages/#{stage_id}/deployments/new?task=#{task}")
|
24
|
-
|
25
|
-
deploy_form = task_page.form_with(:action => /deployments/, :method => /post/i)
|
26
|
-
|
27
|
-
deploy_form.fields_with(:name => /prompt_config/).each do |field|
|
28
|
-
field.name.match(/(\w+)\]$/)
|
29
|
-
prompt_config[$1.to_sym] = ask("=> Set #{$1}: ") do |q|
|
30
|
-
q.whitespace = :strip_and_collapse
|
31
|
-
q.validate = lambda { |p| p.length > 0 }
|
32
|
-
q.responses[:not_valid] = "#{field.name} => can't be blank!"
|
33
|
-
end
|
34
|
-
end
|
35
|
-
prompt_config.presence
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
module WebistranoCli
|
3
|
-
class Project < ActiveResource::Base
|
4
|
-
|
5
|
-
def self.configure(config)
|
6
|
-
self.site = config[:site]
|
7
|
-
self.user = config[:user]
|
8
|
-
self.password = config[:password]
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.find_by_name(name)
|
12
|
-
project = find(:all).find {|project| project.name == name}
|
13
|
-
end
|
14
|
-
|
15
|
-
def find_stage(name)
|
16
|
-
Stage.find(:all, :params => {:project_id => id}).find {|stage| stage.name == name}
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
data/lib/webistrano_cli/stage.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
module WebistranoCli
|
3
|
-
class Stage < ActiveResource::Base
|
4
|
-
|
5
|
-
def self.configure(config)
|
6
|
-
self.site = config[:site] + "/projects/:project_id"
|
7
|
-
self.user = config[:user]
|
8
|
-
self.password = config[:password]
|
9
|
-
end
|
10
|
-
|
11
|
-
def find_task(name)
|
12
|
-
Task.find(:all, :params => @prefix_options.merge({:stage_id => id}) ).find {|task| task.name == name}
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|