webbynode 0.2.4.1 → 0.2.5.beta1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of webbynode might be problematic. Click here for more details.
- data/Manifest +10 -7
- data/Rakefile +1 -1
- data/{cucumber.yml → cucumber.yml.old} +0 -0
- data/{features → inactive_features}/bootstrap.feature +2 -3
- data/{features → inactive_features}/step_definitions/command_steps.rb +0 -0
- data/{features → inactive_features}/support/env.rb +0 -0
- data/{features → inactive_features}/support/hooks.rb +0 -0
- data/{features → inactive_features}/support/io_features.rb +0 -0
- data/{features → inactive_features}/support/mocha.rb +0 -0
- data/lib/webbynode/command.rb +5 -0
- data/lib/webbynode/commands/apps.rb +12 -0
- data/lib/webbynode/commands/init.rb +79 -30
- data/lib/webbynode/commands/push.rb +9 -1
- data/lib/webbynode/commands/tasks.rb +1 -1
- data/lib/webbynode/io.rb +37 -1
- data/lib/webbynode/notify.rb +2 -2
- data/lib/webbynode/option.rb +1 -1
- data/lib/webbynode/remote_executor.rb +2 -2
- data/lib/webbynode/ssh.rb +2 -1
- data/lib/webbynode/updater.rb +19 -0
- data/lib/webbynode.rb +3 -1
- data/spec/webbynode/commands/apps_spec.rb +17 -0
- data/spec/webbynode/commands/init_spec.rb +91 -7
- data/spec/webbynode/commands/push_spec.rb +28 -0
- data/spec/webbynode/commands/tasks_spec.rb +3 -3
- data/spec/webbynode/remote_executor_spec.rb +1 -1
- data/webbynode.gemspec +4 -4
- metadata +18 -13
data/Manifest
CHANGED
@@ -8,14 +8,14 @@ assets/webbynode.png
|
|
8
8
|
bin/webbynode
|
9
9
|
bin/wn
|
10
10
|
changelog.rdoc
|
11
|
-
cucumber.yml
|
11
|
+
cucumber.yml.old
|
12
12
|
devver.rake
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
13
|
+
inactive_features/bootstrap.feature
|
14
|
+
inactive_features/step_definitions/command_steps.rb
|
15
|
+
inactive_features/support/env.rb
|
16
|
+
inactive_features/support/hooks.rb
|
17
|
+
inactive_features/support/io_features.rb
|
18
|
+
inactive_features/support/mocha.rb
|
19
19
|
lib/templates/api_token
|
20
20
|
lib/templates/backup
|
21
21
|
lib/templates/gitignore
|
@@ -27,6 +27,7 @@ lib/webbynode/command.rb
|
|
27
27
|
lib/webbynode/commands/add_backup.rb
|
28
28
|
lib/webbynode/commands/add_key.rb
|
29
29
|
lib/webbynode/commands/alias.rb
|
30
|
+
lib/webbynode/commands/apps.rb
|
30
31
|
lib/webbynode/commands/change_dns.rb
|
31
32
|
lib/webbynode/commands/config.rb
|
32
33
|
lib/webbynode/commands/delete.rb
|
@@ -52,6 +53,7 @@ lib/webbynode/remote_executor.rb
|
|
52
53
|
lib/webbynode/server.rb
|
53
54
|
lib/webbynode/ssh.rb
|
54
55
|
lib/webbynode/ssh_keys.rb
|
56
|
+
lib/webbynode/updater.rb
|
55
57
|
spec/fixtures/aliases
|
56
58
|
spec/fixtures/api/credentials
|
57
59
|
spec/fixtures/api/dns
|
@@ -79,6 +81,7 @@ spec/webbynode/command_spec.rb
|
|
79
81
|
spec/webbynode/commands/add_backup_spec.rb
|
80
82
|
spec/webbynode/commands/add_key_spec.rb
|
81
83
|
spec/webbynode/commands/alias_spec.rb
|
84
|
+
spec/webbynode/commands/apps_spec.rb
|
82
85
|
spec/webbynode/commands/change_dns_spec.rb
|
83
86
|
spec/webbynode/commands/config_spec.rb
|
84
87
|
spec/webbynode/commands/delete_spec.rb
|
data/Rakefile
CHANGED
File without changes
|
@@ -7,11 +7,10 @@ Feature: Bootstrap an app for deployment
|
|
7
7
|
Given I am running webbynode gem for the first time
|
8
8
|
When I run "wn init"
|
9
9
|
Then I should see "Missing 'webby' parameter"
|
10
|
-
And I should see "Usage: webbynode init webby \[
|
10
|
+
And I should see "Usage: webbynode init \[webby\] \[options\]"
|
11
11
|
|
12
12
|
Scenario: Getting help for the init command
|
13
13
|
When I run "wn help init"
|
14
|
-
Then I should see "Usage: webbynode init webby \[
|
14
|
+
Then I should see "Usage: webbynode init \[webby\] \[options\]"
|
15
15
|
And I should see "Parameters:"
|
16
16
|
And I should see " webby Name or IP of the Webby to deploy to"
|
17
|
-
And I should see " dns The DNS used for this application, optional"
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/lib/webbynode/command.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
module Webbynode::Commands
|
2
2
|
class Init < Webbynode::Command
|
3
3
|
summary "Prepares the application on current folder for deployment"
|
4
|
-
parameter :webby, String, "Name or IP of the Webby to deploy to"
|
5
|
-
|
4
|
+
parameter :webby, String, "Name or IP of the Webby to deploy to", :required => false
|
5
|
+
option :dns, String, "The DNS used for this application"
|
6
6
|
option :adddns, "Creates the DNS entries for the domain"
|
7
7
|
option :engine, "Sets the application engine for the app", :validate => { :in => ['php', 'rack', 'rails', 'rails3'] }
|
8
8
|
|
@@ -11,19 +11,20 @@ module Webbynode::Commands
|
|
11
11
|
io.log help
|
12
12
|
return
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
|
+
check_prerequisites
|
15
16
|
check_gemfile
|
16
17
|
|
17
18
|
webby = param(:webby)
|
18
19
|
app_name = io.app_name
|
19
20
|
git_present = git.present?
|
20
21
|
|
21
|
-
if
|
22
|
-
dns_entry = "#{
|
22
|
+
if option(:dns)
|
23
|
+
dns_entry = "#{option(:dns)}"
|
23
24
|
else
|
24
25
|
dns_entry = app_name
|
25
26
|
end
|
26
|
-
|
27
|
+
|
27
28
|
if git_present and !git.clean?
|
28
29
|
raise CommandError,
|
29
30
|
"Cannot initialize: git has pending changes. Execute a git commit or add changes to .gitignore and try again."
|
@@ -31,24 +32,10 @@ module Webbynode::Commands
|
|
31
32
|
|
32
33
|
io.log "Initializing application #{app_name} #{dns_entry ? "with dns #{dns_entry}" : ""}", :start
|
33
34
|
|
34
|
-
|
35
|
-
webby_ip = webby
|
36
|
-
else
|
37
|
-
begin
|
38
|
-
io.log "Retrieving IP for Webby #{webby}...", :action
|
39
|
-
webby_ip = api.ip_for(webby)
|
40
|
-
unless webby_ip
|
41
|
-
if (webbies = api.webbies.keys) and webbies.any?
|
42
|
-
raise CommandError,
|
43
|
-
"Couldn't find Webby '#{webby}' on your account. Your Webbies are: #{webbies.map { |w| "'#{w}'"}.to_phrase}."
|
44
|
-
else
|
45
|
-
raise CommandError, "You don't have any active Webbies on your account."
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
35
|
+
webby_ip = get_ip(webby)
|
50
36
|
|
51
|
-
io.log "
|
37
|
+
io.log ""
|
38
|
+
io.log "Initializing directory structure..."
|
52
39
|
git.remove("config/database.yml") if git.tracks?("config/database.yml")
|
53
40
|
git.remove("db/schema.rb") if git.tracks?("db/schema.rb")
|
54
41
|
|
@@ -63,7 +50,8 @@ module Webbynode::Commands
|
|
63
50
|
end
|
64
51
|
|
65
52
|
unless io.directory?(".webbynode")
|
66
|
-
io.
|
53
|
+
io.mkdir(".webbynode/tasks")
|
54
|
+
|
67
55
|
io.create_file(".webbynode/tasks/after_push", "")
|
68
56
|
io.create_file(".webbynode/tasks/before_push", "")
|
69
57
|
io.create_file(".webbynode/aliases", "")
|
@@ -73,36 +61,86 @@ module Webbynode::Commands
|
|
73
61
|
detect_engine
|
74
62
|
|
75
63
|
unless git_present
|
76
|
-
io.log "Initializing git and applying initial commit..."
|
64
|
+
io.log "Initializing git and applying initial commit..."
|
77
65
|
git.init
|
78
66
|
git.add "."
|
79
67
|
git.commit "Initial commit"
|
80
68
|
end
|
81
69
|
|
82
70
|
if git.remote_exists?('webbynode')
|
83
|
-
|
71
|
+
io.log ""
|
72
|
+
io.log "Webbynode git integration already initialized."
|
73
|
+
if ask('Do you want to overwrite the current settings (y/n)?').downcase == 'y'
|
84
74
|
git.delete_remote('webbynode')
|
85
75
|
end
|
76
|
+
io.log ""
|
86
77
|
end
|
87
78
|
|
88
79
|
if !git.remote_exists?('webbynode') and git_present
|
89
|
-
io.log "Commiting Webbynode changes..."
|
80
|
+
io.log "Commiting Webbynode changes..."
|
90
81
|
git.add "."
|
91
82
|
git.commit2 "[Webbynode] Rapid App Deployment Initialization"
|
92
83
|
end
|
93
84
|
|
94
|
-
io.log "Adding webbynode as git remote..."
|
85
|
+
io.log "Adding webbynode as git remote..."
|
95
86
|
git.add_remote "webbynode", webby_ip, app_name
|
96
87
|
|
97
|
-
handle_dns
|
88
|
+
handle_dns option(:dns) if option(:adddns)
|
98
89
|
|
99
90
|
io.log "Application #{app_name} ready for Rapid Deployment", :finish
|
100
91
|
rescue Webbynode::GitRemoteAlreadyExistsError
|
101
|
-
io.log "Application already initialized."
|
92
|
+
io.log "Application already initialized."
|
102
93
|
end
|
103
94
|
|
104
95
|
private
|
105
96
|
|
97
|
+
def get_ip(webby)
|
98
|
+
return webby if webby =~ /\b(?:\d{1,3}\.){3}\d{1,3}\b/
|
99
|
+
|
100
|
+
api_webbies = api.webbies
|
101
|
+
|
102
|
+
unless webby
|
103
|
+
# TODO: raise CommandError id size = 0
|
104
|
+
if api_webbies.keys.size == 1
|
105
|
+
webby = api_webbies[api_webbies.keys.first]
|
106
|
+
else
|
107
|
+
io.log "", :simple
|
108
|
+
io.log "Current Webbies in your account:", :simple
|
109
|
+
io.log "", :simple
|
110
|
+
|
111
|
+
choices = []
|
112
|
+
api_webbies.keys.sort.each_with_index do |webby_key, i|
|
113
|
+
webby = api_webbies[webby_key]
|
114
|
+
choices << webby
|
115
|
+
io.log " #{i+1}. #{webby[:name]} (#{webby[:ip]})", :simple
|
116
|
+
end
|
117
|
+
|
118
|
+
io.log "", :simple
|
119
|
+
choice = ask("Which Webby do you want to deploy to:", Integer) { |q| q.in = 1..(api_webbies.size+1) }
|
120
|
+
webby = choices[choice-1]
|
121
|
+
end
|
122
|
+
|
123
|
+
io.log "", :simple
|
124
|
+
io.log "Set deployment Webby to #{webby[:name]}.", :simple
|
125
|
+
|
126
|
+
return webby[:ip]
|
127
|
+
end
|
128
|
+
|
129
|
+
io.log "Retrieving IP for Webby #{webby}...", :action
|
130
|
+
webby_ip = api.ip_for(webby)
|
131
|
+
|
132
|
+
unless webby_ip
|
133
|
+
if (webbies = api_webbies.keys) and webbies.any?
|
134
|
+
raise CommandError,
|
135
|
+
"Couldn't find Webby '#{webby}' on your account. Your Webbies are: #{webbies.map { |w| "'#{w}'"}.to_phrase}."
|
136
|
+
else
|
137
|
+
raise CommandError, "You don't have any active Webbies on your account."
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
webby_ip
|
142
|
+
end
|
143
|
+
|
106
144
|
def detect_engine
|
107
145
|
unless engine = option(:engine)
|
108
146
|
if rails3?
|
@@ -118,6 +156,17 @@ module Webbynode::Commands
|
|
118
156
|
io.file_exists?("script/rails")
|
119
157
|
end
|
120
158
|
|
159
|
+
def check_prerequisites
|
160
|
+
unless io.exec_in_path?('git')
|
161
|
+
raise CommandError, <<-EOS
|
162
|
+
Error: git not found on current path.
|
163
|
+
|
164
|
+
In order to use Webbynode Gem for deployment, you must have git installed.
|
165
|
+
For more information about installing git: http://book.git-scm.com/2_installing_git.html
|
166
|
+
EOS
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
121
170
|
def check_gemfile
|
122
171
|
return unless gemfile.present?
|
123
172
|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
module Webbynode::Commands
|
2
2
|
class Push < Webbynode::Command
|
3
|
+
include Webbynode::Updater
|
3
4
|
|
4
5
|
requires_initialization!
|
5
6
|
|
@@ -33,8 +34,15 @@ module Webbynode::Commands
|
|
33
34
|
perform_before_tasks if before_tasks.has_tasks?
|
34
35
|
|
35
36
|
# Logs a initialization message to the user
|
36
|
-
# Pushes the application to Webbynode
|
37
37
|
io.log "Pushing #{app_name}", :start
|
38
|
+
|
39
|
+
# Checks for server-side updates
|
40
|
+
if check_for_updates
|
41
|
+
io.log "Note: Rapp Engine updated"
|
42
|
+
io.log ""
|
43
|
+
end
|
44
|
+
|
45
|
+
# Pushes the application to Webbynode
|
38
46
|
io.exec("git push webbynode master", false)
|
39
47
|
|
40
48
|
# Reads out the "after push" tasks file to see if there are any tasks that must be performed
|
@@ -58,7 +58,7 @@ module Webbynode::Commands
|
|
58
58
|
# Ensures the presence of the .webbynode/tasks folder
|
59
59
|
# Will create the necessary task files when they are not available
|
60
60
|
def ensure_tasks_folder
|
61
|
-
io.
|
61
|
+
io.mkdir('.webbynode/tasks') unless io.directory?(".webbynode/tasks")
|
62
62
|
%w[before_push after_push].each do |file|
|
63
63
|
io.exec("touch .webbynode/tasks/#{file}") unless io.file_exists?(".webbynode/tasks/#{file}")
|
64
64
|
end
|
data/lib/webbynode/io.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'yaml'
|
2
2
|
require 'fileutils'
|
3
|
+
require 'rbconfig'
|
3
4
|
|
4
5
|
module Webbynode
|
5
6
|
class DirectoryNotFound < StandardError; end
|
@@ -9,10 +10,41 @@ module Webbynode
|
|
9
10
|
|
10
11
|
TemplatesPath = File.join(File.dirname(__FILE__), '..', 'templates')
|
11
12
|
|
13
|
+
def is_windows?
|
14
|
+
Config::CONFIG["host_os"] =~ /mswin|mingw/
|
15
|
+
end
|
16
|
+
|
17
|
+
def exists_in_path?(file)
|
18
|
+
search_in_path { |f| File.exists?("#{f}/#{file}") }
|
19
|
+
end
|
20
|
+
|
21
|
+
def exec_in_path?(file)
|
22
|
+
search_in_path do |f|
|
23
|
+
if is_windows?
|
24
|
+
File.executable?("#{f}/#{file}") ||
|
25
|
+
File.executable?("#{f}/#{file}.exe") ||
|
26
|
+
File.executable?("#{f}/#{file}.bat") ||
|
27
|
+
File.executable?("#{f}/#{file}.cmd")
|
28
|
+
else
|
29
|
+
File.executable?("#{f}/#{file}")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def search_in_path(&blk)
|
35
|
+
return false unless block_given?
|
36
|
+
entries = ENV['PATH'].split(is_windows? ? ";" : ":")
|
37
|
+
entries.any? &blk
|
38
|
+
end
|
39
|
+
|
12
40
|
def app_name
|
13
41
|
Dir.pwd.split("/").last.gsub(/[\.| ]/, "_")
|
14
42
|
end
|
15
43
|
|
44
|
+
def mkdir(path)
|
45
|
+
FileUtils.mkdir_p(path)
|
46
|
+
end
|
47
|
+
|
16
48
|
def exec(s, redirect_stderr=true)
|
17
49
|
`#{s}#{redirect_stderr ? " 2>&1" : ""}`
|
18
50
|
end
|
@@ -39,13 +71,17 @@ module Webbynode
|
|
39
71
|
end
|
40
72
|
|
41
73
|
def log(text, notify=false)
|
42
|
-
notify = :
|
74
|
+
notify = :simple unless notify
|
43
75
|
|
44
76
|
case notify
|
45
77
|
when :notify
|
46
78
|
notify = true
|
47
79
|
puts "#{text}"
|
48
80
|
|
81
|
+
when :simple
|
82
|
+
notify = false
|
83
|
+
puts "#{text}"
|
84
|
+
|
49
85
|
when :start
|
50
86
|
notify = true
|
51
87
|
puts "[Webbynode] #{text}"
|
data/lib/webbynode/notify.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
module Webbynode
|
2
|
+
|
2
3
|
class Notify
|
3
4
|
|
4
5
|
TITLE = "Webbynode"
|
@@ -11,8 +12,7 @@ module Webbynode
|
|
11
12
|
end
|
12
13
|
|
13
14
|
def self.installed?
|
14
|
-
|
15
|
-
true
|
15
|
+
@installed ||= Io.new.exec_in_path?("growlnotify")
|
16
16
|
end
|
17
17
|
|
18
18
|
end
|
data/lib/webbynode/option.rb
CHANGED
data/lib/webbynode/ssh.rb
CHANGED
@@ -29,7 +29,7 @@ module Webbynode
|
|
29
29
|
|
30
30
|
end
|
31
31
|
|
32
|
-
def execute(script, echo=false)
|
32
|
+
def execute(script, echo=false, ret_exit_code=false)
|
33
33
|
connect
|
34
34
|
output = ""
|
35
35
|
error_output = ""
|
@@ -59,6 +59,7 @@ module Webbynode
|
|
59
59
|
|
60
60
|
channel.wait
|
61
61
|
|
62
|
+
return exit_code if ret_exit_code
|
62
63
|
output
|
63
64
|
end
|
64
65
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Webbynode
|
2
|
+
module Updater
|
3
|
+
def check_for_updates
|
4
|
+
updated = remote_executor.exec(<<-EOS, false, true)
|
5
|
+
if [ ! -f /var/webbynode/update_rapp ]; then
|
6
|
+
cd /var/webbynode
|
7
|
+
wget http://repo.webbynode.com/rapidapps/update_rapp
|
8
|
+
chmod +x update_rapp
|
9
|
+
ln -s -f /var/webbynode/update_rapp /usr/bin/update_rapp
|
10
|
+
fi
|
11
|
+
|
12
|
+
/var/webbynode/update_rapp
|
13
|
+
if [ $? -eq 1 ]; then exit 1; fi
|
14
|
+
EOS
|
15
|
+
|
16
|
+
updated == 1
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/webbynode.rb
CHANGED
@@ -19,7 +19,9 @@ require File.join(File.dirname(__FILE__), 'webbynode', 'parameter')
|
|
19
19
|
require File.join(File.dirname(__FILE__), 'webbynode', 'api_client')
|
20
20
|
require File.join(File.dirname(__FILE__), 'webbynode', 'remote_executor')
|
21
21
|
require File.join(File.dirname(__FILE__), 'webbynode', 'notify')
|
22
|
+
require File.join(File.dirname(__FILE__), 'webbynode', 'updater')
|
22
23
|
require File.join(File.dirname(__FILE__), 'webbynode', 'properties')
|
24
|
+
require File.join(File.dirname(__FILE__), 'webbynode', 'commands', 'apps')
|
23
25
|
require File.join(File.dirname(__FILE__), 'webbynode', 'commands', 'init')
|
24
26
|
require File.join(File.dirname(__FILE__), 'webbynode', 'commands', 'push')
|
25
27
|
require File.join(File.dirname(__FILE__), 'webbynode', 'commands', 'config')
|
@@ -40,7 +42,7 @@ require File.join(File.dirname(__FILE__), 'webbynode', 'commands', 'version')
|
|
40
42
|
require File.join(File.dirname(__FILE__), 'webbynode', 'application')
|
41
43
|
|
42
44
|
module Webbynode
|
43
|
-
VERSION = '0.2.
|
45
|
+
VERSION = '0.2.5.beta1'
|
44
46
|
end
|
45
47
|
|
46
48
|
class Array
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# Load Spec Helper
|
2
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), '../..', 'spec_helper')
|
3
|
+
|
4
|
+
describe Webbynode::Commands::Apps do
|
5
|
+
let(:re) { double("RemoteExecutor").as_null_object }
|
6
|
+
|
7
|
+
subject do
|
8
|
+
Webbynode::Commands::Apps.new.tap do |cmd|
|
9
|
+
cmd.stub!(:remote_executor).and_return(re)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
it "executes list_apps remotely" do
|
14
|
+
re.should_receive(:exec).with("list_apps", true)
|
15
|
+
subject.execute
|
16
|
+
end
|
17
|
+
end
|
@@ -7,6 +7,7 @@ describe Webbynode::Commands::Init do
|
|
7
7
|
let(:gemfile) { double("gemfile").as_null_object.tap { |g| g.stub!(:present?).and_return(false) } }
|
8
8
|
|
9
9
|
def create_init(ip="4.3.2.1", host=nil, extra=[])
|
10
|
+
host = "--dns=#{host}" if host
|
10
11
|
@command = Webbynode::Commands::Init.new(ip, host, *extra)
|
11
12
|
@command.stub!(:gemfile).and_return(gemfile)
|
12
13
|
@command.should_receive(:git).any_number_of_times.and_return(git_handler)
|
@@ -19,6 +20,88 @@ describe Webbynode::Commands::Init do
|
|
19
20
|
git_handler.stub!(:remote_exists?).and_return(false)
|
20
21
|
end
|
21
22
|
|
23
|
+
context 'Checking prerequisites' do
|
24
|
+
subject do
|
25
|
+
Webbynode::Commands::Init.new.tap do |cmd|
|
26
|
+
cmd.stub!(:git).and_return(git_handler)
|
27
|
+
cmd.stub!(:io).and_return(io_handler)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
it "raises an error if git is not found" do
|
32
|
+
io_handler.should_receive(:exec_in_path?).with('git').and_return(false)
|
33
|
+
lambda { subject.execute }.should raise_error(Webbynode::Command::CommandError)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context "Deployment webby" do
|
38
|
+
let(:api) { double("api").as_null_object }
|
39
|
+
subject do
|
40
|
+
Webbynode::Commands::Init.new.tap do |cmd|
|
41
|
+
cmd.stub!(:git).and_return(git_handler)
|
42
|
+
cmd.stub!(:io).and_return(io_handler)
|
43
|
+
cmd.stub!(:api).and_return(api)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
it "is detected automatically if user only have one Webby" do
|
48
|
+
webbies = {
|
49
|
+
'sandbox' => {
|
50
|
+
:ip => "201.81.121.201",
|
51
|
+
:status => "on",
|
52
|
+
:name => "sandbox",
|
53
|
+
:notes => "",
|
54
|
+
:plan => "Webbybeta",
|
55
|
+
:node => "miami-b15"
|
56
|
+
}
|
57
|
+
}
|
58
|
+
api.should_receive(:webbies).and_return(webbies)
|
59
|
+
git_handler.should_receive(:add_remote).with("webbynode", "201.81.121.201", anything())
|
60
|
+
|
61
|
+
subject.run
|
62
|
+
end
|
63
|
+
|
64
|
+
it "complains if missing and user has > 1 webby" do
|
65
|
+
webbies = {
|
66
|
+
'webby3' => {
|
67
|
+
:ip => "67.53.31.3",
|
68
|
+
:status => "on",
|
69
|
+
:name => "webby3",
|
70
|
+
:notes => "",
|
71
|
+
:plan => "Webbybeta",
|
72
|
+
:node => "miami-b11"
|
73
|
+
},
|
74
|
+
'sandbox' => {
|
75
|
+
:ip => "201.81.121.201",
|
76
|
+
:status => "on",
|
77
|
+
:name => "sandbox",
|
78
|
+
:notes => "",
|
79
|
+
:plan => "Webbybeta",
|
80
|
+
:node => "miami-b15"
|
81
|
+
},
|
82
|
+
'webby2' => {
|
83
|
+
:ip => "67.53.31.2",
|
84
|
+
:status => "on",
|
85
|
+
:name => "webby2",
|
86
|
+
:notes => "",
|
87
|
+
:plan => "Webbybeta",
|
88
|
+
:node => "miami-b11"
|
89
|
+
}
|
90
|
+
}
|
91
|
+
api.should_receive(:webbies).and_return(webbies)
|
92
|
+
io_handler.should_receive(:log).with("Current Webbies in your account:", anything())
|
93
|
+
io_handler.should_receive(:log).with(" 1. sandbox (201.81.121.201)", anything())
|
94
|
+
io_handler.should_receive(:log).with(" 2. webby2 (67.53.31.2)", anything())
|
95
|
+
io_handler.should_receive(:log).with(" 3. webby3 (67.53.31.3)", anything())
|
96
|
+
subject.should_receive(:ask).with("Which Webby do you want to deploy to:", Integer).and_return(2)
|
97
|
+
|
98
|
+
io_handler.should_receive(:log).with("Set deployment Webby to webby2.", anything())
|
99
|
+
git_handler.should_receive(:add_remote).with("webbynode", "67.53.31.2", anything())
|
100
|
+
|
101
|
+
subject.run
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
22
105
|
context "Gemfile checking" do
|
23
106
|
context "when present" do
|
24
107
|
it "complains if there is a sqlite3-ruby dependency outside of development and test groups" do
|
@@ -46,7 +129,7 @@ describe Webbynode::Commands::Init do
|
|
46
129
|
command = Webbynode::Commands::Init.new("10.0.1.1")
|
47
130
|
command.stub!(:gemfile).and_return(gemfile)
|
48
131
|
command.should_receive(:git).any_number_of_times.and_return(git_handler)
|
49
|
-
command.should_receive(:ask).with("
|
132
|
+
command.should_receive(:ask).with("Do you want to overwrite the current settings (y/n)?").once.ordered.and_return("n")
|
50
133
|
|
51
134
|
git_handler.should_receive(:present?).and_return(true)
|
52
135
|
git_handler.should_receive(:remote_exists?).with("webbynode").and_return(true)
|
@@ -59,7 +142,7 @@ describe Webbynode::Commands::Init do
|
|
59
142
|
command = Webbynode::Commands::Init.new("10.0.1.1")
|
60
143
|
command.stub!(:gemfile).and_return(gemfile)
|
61
144
|
command.should_receive(:git).any_number_of_times.and_return(git_handler)
|
62
|
-
command.should_receive(:ask).with("
|
145
|
+
command.should_receive(:ask).with("Do you want to overwrite the current settings (y/n)?").once.ordered.and_return("y")
|
63
146
|
|
64
147
|
git_handler.should_receive(:present?).and_return(true)
|
65
148
|
git_handler.should_receive(:remote_exists?).with("webbynode").and_return(true)
|
@@ -86,7 +169,7 @@ describe Webbynode::Commands::Init do
|
|
86
169
|
let(:io) { io = double("Io").as_null_object }
|
87
170
|
|
88
171
|
def create_init(ip="4.3.2.1", host=nil, extra=[])
|
89
|
-
@command = Webbynode::Commands::Init.new(ip, host, *extra)
|
172
|
+
@command = Webbynode::Commands::Init.new(ip, "--dns=#{host}", *extra)
|
90
173
|
@command.stub!(:gemfile).and_return(gemfile)
|
91
174
|
@command.should_receive(:git).any_number_of_times.and_return(git_handler)
|
92
175
|
end
|
@@ -247,6 +330,7 @@ describe Webbynode::Commands::Init do
|
|
247
330
|
|
248
331
|
it "should try to get Webby's IP if no IP given" do
|
249
332
|
api = double("ApiClient")
|
333
|
+
api.stub!(:webbies).and_return(['a', 'b'])
|
250
334
|
api.should_receive(:ip_for).with("my_webby_name").and_return("1.2.3.4")
|
251
335
|
|
252
336
|
io_handler.should_receive(:app_name).any_number_of_times.and_return("my_app")
|
@@ -254,7 +338,7 @@ describe Webbynode::Commands::Init do
|
|
254
338
|
git_handler.should_receive(:add_remote).with("webbynode", "1.2.3.4", "my_app")
|
255
339
|
|
256
340
|
create_init("my_webby_name")
|
257
|
-
@command.
|
341
|
+
@command.stub!(:api).and_return(api)
|
258
342
|
@command.run
|
259
343
|
end
|
260
344
|
|
@@ -335,7 +419,7 @@ describe Webbynode::Commands::Init do
|
|
335
419
|
context "when .webbynode is not present" do
|
336
420
|
it "should create the .webbynode system folder and stub files" do
|
337
421
|
io_handler.should_receive(:directory?).with(".webbynode").and_return(false)
|
338
|
-
io_handler.should_receive(:
|
422
|
+
io_handler.should_receive(:mkdir).with(".webbynode/tasks")
|
339
423
|
io_handler.should_receive(:create_file).with(".webbynode/tasks/after_push", "")
|
340
424
|
io_handler.should_receive(:create_file).with(".webbynode/tasks/before_push", "")
|
341
425
|
io_handler.should_receive(:create_file).with(".webbynode/aliases", "")
|
@@ -411,7 +495,7 @@ describe Webbynode::Commands::Init do
|
|
411
495
|
end
|
412
496
|
|
413
497
|
it "shows that a commit is being added" do
|
414
|
-
io_handler.should_receive(:log).with("Commiting Webbynode changes..."
|
498
|
+
io_handler.should_receive(:log).with("Commiting Webbynode changes...")
|
415
499
|
git_handler.should_receive(:present?).and_return(true)
|
416
500
|
|
417
501
|
@command.run
|
@@ -442,7 +526,7 @@ describe Webbynode::Commands::Init do
|
|
442
526
|
git_handler.should_receive(:present?).and_return(true)
|
443
527
|
git_handler.should_receive(:add_remote).and_raise(Webbynode::GitRemoteAlreadyExistsError)
|
444
528
|
|
445
|
-
io_handler.should_receive(:log).with("Application already initialized."
|
529
|
+
io_handler.should_receive(:log).with("Application already initialized.")
|
446
530
|
@command.run
|
447
531
|
end
|
448
532
|
end
|
@@ -18,6 +18,34 @@ describe Webbynode::Commands::Push do
|
|
18
18
|
push.after_tasks.stub!(:read_tasks)
|
19
19
|
end
|
20
20
|
|
21
|
+
subject do
|
22
|
+
Webbynode::Commands::Push.new.tap do |cmd|
|
23
|
+
cmd.stub!(:io).and_return(io)
|
24
|
+
cmd.stub!(:remote_executor).and_return(re)
|
25
|
+
cmd.stub!(:pushand).and_return(pushand)
|
26
|
+
cmd.stub!(:git).and_return(git)
|
27
|
+
cmd.after_tasks.stub!(:read_tasks)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context "before pushing" do
|
32
|
+
it "checks for update_rapp script remotely" do
|
33
|
+
re.should_receive(:exec).with(<<-EOS, false, true)
|
34
|
+
if [ ! -f /var/webbynode/update_rapp ]; then
|
35
|
+
cd /var/webbynode
|
36
|
+
wget http://repo.webbynode.com/rapidapps/update_rapp
|
37
|
+
chmod +x update_rapp
|
38
|
+
ln -s -f /var/webbynode/update_rapp /usr/bin/update_rapp
|
39
|
+
fi
|
40
|
+
|
41
|
+
/var/webbynode/update_rapp
|
42
|
+
if [ $? -eq 1 ]; then exit 1; fi
|
43
|
+
EOS
|
44
|
+
|
45
|
+
subject.execute
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
21
49
|
context "when the user runs the command" do
|
22
50
|
it "should display a message that the application is being pushed to the webby" do
|
23
51
|
pushand.should_receive(:parse_remote_app_name).and_return("test.webbynode.com")
|
@@ -51,7 +51,7 @@ describe Webbynode::Commands::Tasks do
|
|
51
51
|
end
|
52
52
|
|
53
53
|
it "should create the webbynode tasks folder" do
|
54
|
-
io.should_receive(:
|
54
|
+
io.should_receive(:mkdir).with('.webbynode/tasks')
|
55
55
|
task.execute
|
56
56
|
end
|
57
57
|
|
@@ -76,12 +76,12 @@ describe Webbynode::Commands::Tasks do
|
|
76
76
|
end
|
77
77
|
|
78
78
|
it "should create the webbynode folder" do
|
79
|
-
io.should_not_receive(:
|
79
|
+
io.should_not_receive(:mkdir).with('.webbynode')
|
80
80
|
task.execute
|
81
81
|
end
|
82
82
|
|
83
83
|
it "should create the webbynode folder" do
|
84
|
-
io.should_not_receive(:
|
84
|
+
io.should_not_receive(:mkdir).with('.webbynode/tasks')
|
85
85
|
task.execute
|
86
86
|
end
|
87
87
|
|
@@ -11,7 +11,7 @@ describe Webbynode::RemoteExecutor do
|
|
11
11
|
|
12
12
|
describe "#exec" do
|
13
13
|
it "should execute the raw command on the server" do
|
14
|
-
@ssh.should_receive(:execute).with("the same string I pass", false)
|
14
|
+
@ssh.should_receive(:execute).with("the same string I pass", false, false)
|
15
15
|
@re.exec "the same string I pass"
|
16
16
|
end
|
17
17
|
end
|
data/webbynode.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{webbynode}
|
5
|
-
s.version = "0.2.
|
5
|
+
s.version = "0.2.5.beta1"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Felipe Coury"]
|
9
|
-
s.date = %q{2010-06-
|
9
|
+
s.date = %q{2010-06-30}
|
10
10
|
s.description = %q{Webbynode Deployment Gem}
|
11
11
|
s.email = %q{felipe@webbynode.com}
|
12
12
|
s.executables = ["webbynode", "wn"]
|
13
|
-
s.extra_rdoc_files = ["README.rdoc", "bin/webbynode", "bin/wn", "lib/templates/api_token", "lib/templates/backup", "lib/templates/gitignore", "lib/templates/help", "lib/webbynode.rb", "lib/webbynode/api_client.rb", "lib/webbynode/application.rb", "lib/webbynode/command.rb", "lib/webbynode/commands/add_backup.rb", "lib/webbynode/commands/add_key.rb", "lib/webbynode/commands/alias.rb", "lib/webbynode/commands/change_dns.rb", "lib/webbynode/commands/config.rb", "lib/webbynode/commands/delete.rb", "lib/webbynode/commands/help.rb", "lib/webbynode/commands/init.rb", "lib/webbynode/commands/push.rb", "lib/webbynode/commands/remote.rb", "lib/webbynode/commands/restart.rb", "lib/webbynode/commands/start.rb", "lib/webbynode/commands/stop.rb", "lib/webbynode/commands/tasks.rb", "lib/webbynode/commands/version.rb", "lib/webbynode/commands/webbies.rb", "lib/webbynode/gemfile.rb", "lib/webbynode/git.rb", "lib/webbynode/io.rb", "lib/webbynode/notify.rb", "lib/webbynode/option.rb", "lib/webbynode/parameter.rb", "lib/webbynode/properties.rb", "lib/webbynode/push_and.rb", "lib/webbynode/remote_executor.rb", "lib/webbynode/server.rb", "lib/webbynode/ssh.rb", "lib/webbynode/ssh_keys.rb"]
|
14
|
-
s.files = ["History.txt", "Manifest", "Manifest.txt", "PostInstall.txt", "README.rdoc", "Rakefile", "assets/webbynode.png", "bin/webbynode", "bin/wn", "changelog.rdoc", "cucumber.yml", "devver.rake", "
|
13
|
+
s.extra_rdoc_files = ["README.rdoc", "bin/webbynode", "bin/wn", "lib/templates/api_token", "lib/templates/backup", "lib/templates/gitignore", "lib/templates/help", "lib/webbynode.rb", "lib/webbynode/api_client.rb", "lib/webbynode/application.rb", "lib/webbynode/command.rb", "lib/webbynode/commands/add_backup.rb", "lib/webbynode/commands/add_key.rb", "lib/webbynode/commands/alias.rb", "lib/webbynode/commands/apps.rb", "lib/webbynode/commands/change_dns.rb", "lib/webbynode/commands/config.rb", "lib/webbynode/commands/delete.rb", "lib/webbynode/commands/help.rb", "lib/webbynode/commands/init.rb", "lib/webbynode/commands/push.rb", "lib/webbynode/commands/remote.rb", "lib/webbynode/commands/restart.rb", "lib/webbynode/commands/start.rb", "lib/webbynode/commands/stop.rb", "lib/webbynode/commands/tasks.rb", "lib/webbynode/commands/version.rb", "lib/webbynode/commands/webbies.rb", "lib/webbynode/gemfile.rb", "lib/webbynode/git.rb", "lib/webbynode/io.rb", "lib/webbynode/notify.rb", "lib/webbynode/option.rb", "lib/webbynode/parameter.rb", "lib/webbynode/properties.rb", "lib/webbynode/push_and.rb", "lib/webbynode/remote_executor.rb", "lib/webbynode/server.rb", "lib/webbynode/ssh.rb", "lib/webbynode/ssh_keys.rb", "lib/webbynode/updater.rb"]
|
14
|
+
s.files = ["History.txt", "Manifest", "Manifest.txt", "PostInstall.txt", "README.rdoc", "Rakefile", "assets/webbynode.png", "bin/webbynode", "bin/wn", "changelog.rdoc", "cucumber.yml.old", "devver.rake", "inactive_features/bootstrap.feature", "inactive_features/step_definitions/command_steps.rb", "inactive_features/support/env.rb", "inactive_features/support/hooks.rb", "inactive_features/support/io_features.rb", "inactive_features/support/mocha.rb", "lib/templates/api_token", "lib/templates/backup", "lib/templates/gitignore", "lib/templates/help", "lib/webbynode.rb", "lib/webbynode/api_client.rb", "lib/webbynode/application.rb", "lib/webbynode/command.rb", "lib/webbynode/commands/add_backup.rb", "lib/webbynode/commands/add_key.rb", "lib/webbynode/commands/alias.rb", "lib/webbynode/commands/apps.rb", "lib/webbynode/commands/change_dns.rb", "lib/webbynode/commands/config.rb", "lib/webbynode/commands/delete.rb", "lib/webbynode/commands/help.rb", "lib/webbynode/commands/init.rb", "lib/webbynode/commands/push.rb", "lib/webbynode/commands/remote.rb", "lib/webbynode/commands/restart.rb", "lib/webbynode/commands/start.rb", "lib/webbynode/commands/stop.rb", "lib/webbynode/commands/tasks.rb", "lib/webbynode/commands/version.rb", "lib/webbynode/commands/webbies.rb", "lib/webbynode/gemfile.rb", "lib/webbynode/git.rb", "lib/webbynode/io.rb", "lib/webbynode/notify.rb", "lib/webbynode/option.rb", "lib/webbynode/parameter.rb", "lib/webbynode/properties.rb", "lib/webbynode/push_and.rb", "lib/webbynode/remote_executor.rb", "lib/webbynode/server.rb", "lib/webbynode/ssh.rb", "lib/webbynode/ssh_keys.rb", "lib/webbynode/updater.rb", "spec/fixtures/aliases", "spec/fixtures/api/credentials", "spec/fixtures/api/dns", "spec/fixtures/api/dns_a_record", "spec/fixtures/api/dns_a_record_already_exists", "spec/fixtures/api/dns_a_record_error", "spec/fixtures/api/dns_new_zone", "spec/fixtures/api/webbies", "spec/fixtures/api/webbies_unauthorized", "spec/fixtures/api/webby", "spec/fixtures/commands/tasks/after_push", "spec/fixtures/fixture_helpers", "spec/fixtures/git/config/210.11.13.12", "spec/fixtures/git/config/67.23.79.31", "spec/fixtures/git/config/67.23.79.32", "spec/fixtures/git/config/config", "spec/fixtures/git/config/config_5", "spec/fixtures/git/status/clean", "spec/fixtures/git/status/dirty", "spec/fixtures/pushand", "spec/spec_helper.rb", "spec/webbynode/api_client_spec.rb", "spec/webbynode/application_spec.rb", "spec/webbynode/command_spec.rb", "spec/webbynode/commands/add_backup_spec.rb", "spec/webbynode/commands/add_key_spec.rb", "spec/webbynode/commands/alias_spec.rb", "spec/webbynode/commands/apps_spec.rb", "spec/webbynode/commands/change_dns_spec.rb", "spec/webbynode/commands/config_spec.rb", "spec/webbynode/commands/delete_spec.rb", "spec/webbynode/commands/help_spec.rb", "spec/webbynode/commands/init_spec.rb", "spec/webbynode/commands/push_spec.rb", "spec/webbynode/commands/remote_spec.rb", "spec/webbynode/commands/tasks_spec.rb", "spec/webbynode/commands/version_spec.rb", "spec/webbynode/commands/webbies_spec.rb", "spec/webbynode/gemfile_spec.rb", "spec/webbynode/git_spec.rb", "spec/webbynode/io_spec.rb", "spec/webbynode/option_spec.rb", "spec/webbynode/parameter_spec.rb", "spec/webbynode/push_and_spec.rb", "spec/webbynode/remote_executor_spec.rb", "spec/webbynode/server_spec.rb", "webbynode.gemspec"]
|
15
15
|
s.homepage = %q{http://webbynode.com}
|
16
16
|
s.post_install_message = %q{
|
17
17
|
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webbynode
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: -1848230071
|
5
|
+
prerelease: true
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
-
|
11
|
-
version: 0.2.
|
9
|
+
- 5
|
10
|
+
- beta1
|
11
|
+
version: 0.2.5.beta1
|
12
12
|
platform: ruby
|
13
13
|
authors:
|
14
14
|
- Felipe Coury
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-06-
|
19
|
+
date: 2010-06-30 00:00:00 -03:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -121,6 +121,7 @@ extra_rdoc_files:
|
|
121
121
|
- lib/webbynode/commands/add_backup.rb
|
122
122
|
- lib/webbynode/commands/add_key.rb
|
123
123
|
- lib/webbynode/commands/alias.rb
|
124
|
+
- lib/webbynode/commands/apps.rb
|
124
125
|
- lib/webbynode/commands/change_dns.rb
|
125
126
|
- lib/webbynode/commands/config.rb
|
126
127
|
- lib/webbynode/commands/delete.rb
|
@@ -146,6 +147,7 @@ extra_rdoc_files:
|
|
146
147
|
- lib/webbynode/server.rb
|
147
148
|
- lib/webbynode/ssh.rb
|
148
149
|
- lib/webbynode/ssh_keys.rb
|
150
|
+
- lib/webbynode/updater.rb
|
149
151
|
files:
|
150
152
|
- History.txt
|
151
153
|
- Manifest
|
@@ -157,14 +159,14 @@ files:
|
|
157
159
|
- bin/webbynode
|
158
160
|
- bin/wn
|
159
161
|
- changelog.rdoc
|
160
|
-
- cucumber.yml
|
162
|
+
- cucumber.yml.old
|
161
163
|
- devver.rake
|
162
|
-
-
|
163
|
-
-
|
164
|
-
-
|
165
|
-
-
|
166
|
-
-
|
167
|
-
-
|
164
|
+
- inactive_features/bootstrap.feature
|
165
|
+
- inactive_features/step_definitions/command_steps.rb
|
166
|
+
- inactive_features/support/env.rb
|
167
|
+
- inactive_features/support/hooks.rb
|
168
|
+
- inactive_features/support/io_features.rb
|
169
|
+
- inactive_features/support/mocha.rb
|
168
170
|
- lib/templates/api_token
|
169
171
|
- lib/templates/backup
|
170
172
|
- lib/templates/gitignore
|
@@ -176,6 +178,7 @@ files:
|
|
176
178
|
- lib/webbynode/commands/add_backup.rb
|
177
179
|
- lib/webbynode/commands/add_key.rb
|
178
180
|
- lib/webbynode/commands/alias.rb
|
181
|
+
- lib/webbynode/commands/apps.rb
|
179
182
|
- lib/webbynode/commands/change_dns.rb
|
180
183
|
- lib/webbynode/commands/config.rb
|
181
184
|
- lib/webbynode/commands/delete.rb
|
@@ -201,6 +204,7 @@ files:
|
|
201
204
|
- lib/webbynode/server.rb
|
202
205
|
- lib/webbynode/ssh.rb
|
203
206
|
- lib/webbynode/ssh_keys.rb
|
207
|
+
- lib/webbynode/updater.rb
|
204
208
|
- spec/fixtures/aliases
|
205
209
|
- spec/fixtures/api/credentials
|
206
210
|
- spec/fixtures/api/dns
|
@@ -228,6 +232,7 @@ files:
|
|
228
232
|
- spec/webbynode/commands/add_backup_spec.rb
|
229
233
|
- spec/webbynode/commands/add_key_spec.rb
|
230
234
|
- spec/webbynode/commands/alias_spec.rb
|
235
|
+
- spec/webbynode/commands/apps_spec.rb
|
231
236
|
- spec/webbynode/commands/change_dns_spec.rb
|
232
237
|
- spec/webbynode/commands/config_spec.rb
|
233
238
|
- spec/webbynode/commands/delete_spec.rb
|