webbynode 1.0.3.beta4 → 1.0.3
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/Rakefile +1 -1
- data/lib/webbynode/commands/init.rb +13 -0
- data/lib/webbynode/engines/all.rb +2 -1
- data/lib/webbynode/engines/nodejs.rb +37 -0
- data/lib/webbynode.rb +1 -1
- data/spec/webbynode/commands/init_spec.rb +23 -0
- data/spec/webbynode/engines/engine_spec.rb +1 -0
- data/spec/webbynode/engines/nodejs_spec.rb +80 -0
- data/webbynode.gemspec +2 -2
- metadata +4 -5
data/Rakefile
CHANGED
@@ -46,6 +46,19 @@ module Webbynode::Commands
|
|
46
46
|
|
47
47
|
io.log "Application #{@app_name} ready for Rapid Deployment", :finish
|
48
48
|
|
49
|
+
rescue Net::SSH::HostKeyMismatch
|
50
|
+
io.log ""
|
51
|
+
io.log "Error pushing to your server:"
|
52
|
+
io.log " #{$!}"
|
53
|
+
io.log ""
|
54
|
+
io.log "This usually happens because you redeployed the server and the fingerprint changed."
|
55
|
+
io.log ""
|
56
|
+
io.log "To fix this error:"
|
57
|
+
io.log " 1. Edit #{Webbynode::Io.home_dir}/.ssh/known_hosts file"
|
58
|
+
io.log " or the proper known hosts file for your SSH service."
|
59
|
+
io.log " 2. Remove the line that starts with the IP #{@webby_ip}."
|
60
|
+
io.log ""
|
61
|
+
|
49
62
|
rescue Webbynode::InvalidAuthentication
|
50
63
|
io.log "Could not connect to webby: invalid authentication.", true
|
51
64
|
|
@@ -2,5 +2,42 @@ module Webbynode::Engines
|
|
2
2
|
class NodeJS
|
3
3
|
include Engine
|
4
4
|
set_name "NodeJS"
|
5
|
+
|
6
|
+
def detected?
|
7
|
+
io.file_exists?('server.js')
|
8
|
+
end
|
9
|
+
|
10
|
+
def prepare
|
11
|
+
default_port = 8000
|
12
|
+
if io.file_exists?('server.js')
|
13
|
+
contents = io.read_file('server.js')
|
14
|
+
if contents =~ /listen\((\d+)\)/
|
15
|
+
default_port = $1
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
io.log ""
|
20
|
+
io.log "Configure NodeJS Application"
|
21
|
+
io.log ""
|
22
|
+
|
23
|
+
while true
|
24
|
+
proxy = ask(" Proxy requests (Y/n) [Y]? ")
|
25
|
+
proxy = 'Y' if proxy.blank?
|
26
|
+
break if "YN".include?(proxy.to_s.upcase)
|
27
|
+
io.log ""
|
28
|
+
io.log " Please answer Y=use proxy or N=don't use proxy (standalone NodeJS app)"
|
29
|
+
end
|
30
|
+
|
31
|
+
while true
|
32
|
+
port = ask(" Listening port [#{default_port}]: ")
|
33
|
+
port = "#{default_port}" if port.blank?
|
34
|
+
break if port.to_i.to_s == port.to_s
|
35
|
+
io.log ""
|
36
|
+
io.log " Please enter a numeric value for port"
|
37
|
+
end
|
38
|
+
|
39
|
+
io.add_setting('nodejs_proxy', proxy)
|
40
|
+
io.add_setting('nodejs_port', port.to_s)
|
41
|
+
end
|
5
42
|
end
|
6
43
|
end
|
data/lib/webbynode.rb
CHANGED
@@ -79,6 +79,29 @@ describe Webbynode::Commands::Init do
|
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
|
+
describe 'when the SSH known_hosts key differs' do
|
83
|
+
it "gives an user friendly explanation" do
|
84
|
+
io_handler.stub!(:file_exists?).with(".pushand").and_return(false)
|
85
|
+
|
86
|
+
git_handler.stub!(:present?).and_return(:false)
|
87
|
+
|
88
|
+
subject.stub!(:git).and_return(git_handler)
|
89
|
+
subject.stub!(:detect_engine).and_return(Webbynode::Engines::Rails)
|
90
|
+
|
91
|
+
subject.should_receive(:add_remote).and_raise(Net::SSH::HostKeyMismatch.new("fingerprint 91:b5:b6:08:91:61:f7:d7:66:ec:c0:a9:53:16:c6:84 does not match for \"208.88.124.171\""))
|
92
|
+
|
93
|
+
io_handler.should_receive(:log).with("Error pushing to your server:")
|
94
|
+
io_handler.should_receive(:log).with(" fingerprint 91:b5:b6:08:91:61:f7:d7:66:ec:c0:a9:53:16:c6:84 does not match for \"208.88.124.171\"")
|
95
|
+
io_handler.should_receive(:log).with("This usually happens because you redeployed the server and the fingerprint changed.")
|
96
|
+
io_handler.should_receive(:log).with("To fix this error:")
|
97
|
+
io_handler.should_receive(:log).with(" 1. Edit #{Webbynode::Io.home_dir}/.ssh/known_hosts file")
|
98
|
+
io_handler.should_receive(:log).with(" or the proper known hosts file for your SSH service.")
|
99
|
+
io_handler.should_receive(:log).with(" 2. Remove the line that starts with the IP 201.81.121.201.")
|
100
|
+
|
101
|
+
subject.run
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
82
105
|
describe 'using alternate port' do
|
83
106
|
subject do
|
84
107
|
Webbynode::Commands::Init.new('2.1.2.3', '--port=2020').tap do |cmd|
|
@@ -8,6 +8,7 @@ describe Webbynode::Engines do
|
|
8
8
|
subject.find('rails').should == Webbynode::Engines::Rails
|
9
9
|
subject.find('rails3').should == Webbynode::Engines::Rails3
|
10
10
|
subject.find('django').should == Webbynode::Engines::Django
|
11
|
+
subject.find('nodejs').should == Webbynode::Engines::NodeJS
|
11
12
|
subject.find('rack').should == Webbynode::Engines::Rack
|
12
13
|
subject.find('php').should == Webbynode::Engines::Php
|
13
14
|
end
|
@@ -2,6 +2,14 @@
|
|
2
2
|
require File.join(File.expand_path(File.dirname(__FILE__)), '../..', 'spec_helper')
|
3
3
|
|
4
4
|
describe Webbynode::Engines::NodeJS do
|
5
|
+
let(:io) { double("io").as_null_object }
|
6
|
+
|
7
|
+
subject do
|
8
|
+
Webbynode::Engines::NodeJS.new.tap do |engine|
|
9
|
+
engine.stub!(:io).and_return(io)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
5
13
|
describe 'class methods' do
|
6
14
|
subject { Webbynode::Engines::NodeJS }
|
7
15
|
|
@@ -9,4 +17,76 @@ describe Webbynode::Engines::NodeJS do
|
|
9
17
|
its(:engine_name) { should == 'NodeJS' }
|
10
18
|
its(:git_excluded) { should be_empty }
|
11
19
|
end
|
20
|
+
|
21
|
+
describe '#detect' do
|
22
|
+
it "returns true if server.js is found" do
|
23
|
+
io.stub!(:file_exists?).with('server.js').and_return(true)
|
24
|
+
|
25
|
+
subject.should be_detected
|
26
|
+
end
|
27
|
+
|
28
|
+
it "returns false if any isn't found" do
|
29
|
+
io.stub!(:file_exists?).with('server.js').and_return(false)
|
30
|
+
|
31
|
+
subject.should_not be_detected
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#prepare' do
|
36
|
+
before(:each) do
|
37
|
+
io.stub!(:file_exists?).with('server.js').and_return(false)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "tries to get the listen port" do
|
41
|
+
io.stub!(:file_exists?).with('server.js').and_return(true)
|
42
|
+
io.should_receive(:read_file).with("server.js").and_return(read_fixture("nodejs/server.js"))
|
43
|
+
subject.should_receive(:ask).with(" Proxy requests (Y/n) [Y]? ").and_return('Y')
|
44
|
+
subject.should_receive(:ask).with(" Listening port [1234]: ").and_return('')
|
45
|
+
|
46
|
+
io.should_receive(:add_setting).with('nodejs_port', '1234')
|
47
|
+
|
48
|
+
subject.prepare
|
49
|
+
end
|
50
|
+
|
51
|
+
it "shows a title" do
|
52
|
+
io.should_receive(:log).with("Configure NodeJS Application")
|
53
|
+
subject.should_receive(:ask).with(" Proxy requests (Y/n) [Y]? ").and_return('Y')
|
54
|
+
subject.should_receive(:ask).with(" Listening port [8000]: ").and_return(8080)
|
55
|
+
subject.prepare
|
56
|
+
end
|
57
|
+
|
58
|
+
it "validates y/n for proxy" do
|
59
|
+
subject.should_receive(:ask).with(" Proxy requests (Y/n) [Y]? ").and_return('abcdef')
|
60
|
+
io.should_receive(:log).with(" Please answer Y=use proxy or N=don't use proxy (standalone NodeJS app)")
|
61
|
+
subject.should_receive(:ask).with(" Proxy requests (Y/n) [Y]? ").and_return('N')
|
62
|
+
subject.should_receive(:ask).with(" Listening port [8000]: ").and_return(8080)
|
63
|
+
subject.prepare
|
64
|
+
end
|
65
|
+
|
66
|
+
it "validates numeric for port" do
|
67
|
+
subject.should_receive(:ask).with(" Proxy requests (Y/n) [Y]? ").and_return('N')
|
68
|
+
subject.should_receive(:ask).with(" Listening port [8000]: ").and_return('abcdef')
|
69
|
+
io.should_receive(:log).with(" Please enter a numeric value for port")
|
70
|
+
subject.should_receive(:ask).with(" Listening port [8000]: ").and_return("8080")
|
71
|
+
subject.prepare
|
72
|
+
end
|
73
|
+
|
74
|
+
it "asks if user wants to proxy requests and the port" do
|
75
|
+
io.should_receive(:add_setting).with('nodejs_proxy', 'Y')
|
76
|
+
io.should_receive(:add_setting).with('nodejs_port', '8080')
|
77
|
+
|
78
|
+
subject.should_receive(:ask).with(" Proxy requests (Y/n) [Y]? ").and_return('Y')
|
79
|
+
subject.should_receive(:ask).with(" Listening port [8000]: ").and_return(8080)
|
80
|
+
subject.prepare
|
81
|
+
end
|
82
|
+
|
83
|
+
it "assumes default values" do
|
84
|
+
io.should_receive(:add_setting).with('nodejs_proxy', 'Y')
|
85
|
+
io.should_receive(:add_setting).with('nodejs_port', '8000')
|
86
|
+
|
87
|
+
subject.should_receive(:ask).with(" Proxy requests (Y/n) [Y]? ").and_return('')
|
88
|
+
subject.should_receive(:ask).with(" Listening port [8000]: ").and_return('')
|
89
|
+
subject.prepare
|
90
|
+
end
|
91
|
+
end
|
12
92
|
end
|
data/webbynode.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{webbynode}
|
5
|
-
s.version = "1.0.3
|
5
|
+
s.version = "1.0.3"
|
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-09-
|
9
|
+
s.date = %q{2010-09-22}
|
10
10
|
s.description = %q{Webbynode Deployment Gem}
|
11
11
|
s.email = %q{felipe@webbynode.com}
|
12
12
|
s.executables = ["webbynode", "wn"]
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webbynode
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 17
|
5
|
+
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
9
|
- 3
|
10
|
-
|
11
|
-
version: 1.0.3.beta4
|
10
|
+
version: 1.0.3
|
12
11
|
platform: ruby
|
13
12
|
authors:
|
14
13
|
- Felipe Coury
|
@@ -16,7 +15,7 @@ autorequire:
|
|
16
15
|
bindir: bin
|
17
16
|
cert_chain: []
|
18
17
|
|
19
|
-
date: 2010-09-
|
18
|
+
date: 2010-09-22 00:00:00 -03:00
|
20
19
|
default_executable:
|
21
20
|
dependencies:
|
22
21
|
- !ruby/object:Gem::Dependency
|