webbynode 1.0.4.3 → 1.0.5.beta2

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/Gemfile CHANGED
@@ -4,6 +4,7 @@ gem 'httparty'
4
4
  gem 'domainatrix'
5
5
  gem 'net-ssh'
6
6
  gem 'highline'
7
+ gem 'rainbow'
7
8
 
8
9
  group :development do
9
10
  gem 'rspec'
@@ -17,4 +18,5 @@ group :development do
17
18
  gem 'fakeweb'
18
19
  gem 'echoe'
19
20
  gem 'rcov'
21
+ gem 'rb-fsevent'
20
22
  end
@@ -34,7 +34,9 @@ GEM
34
34
  net-ssh (2.1.0)
35
35
  open_gem (1.4.2)
36
36
  launchy (~> 0.3.5)
37
+ rainbow (1.1.1)
37
38
  rake (0.8.7)
39
+ rb-fsevent (0.4.0)
38
40
  rcov (0.9.9)
39
41
  rspec (2.5.0)
40
42
  rspec-core (~> 2.5.0)
@@ -65,5 +67,7 @@ DEPENDENCIES
65
67
  highline
66
68
  httparty
67
69
  net-ssh
70
+ rainbow
71
+ rb-fsevent
68
72
  rcov
69
73
  rspec
data/Guardfile CHANGED
@@ -1,5 +1,5 @@
1
1
  guard 'rspec' do
2
2
  watch(%r{spec/(.*)_spec.rb})
3
- watch(%r{lib/(.*)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" }
3
+ watch(%r{lib/(.*)\.rb}) { |m| "spec/#{m[1]}_spec.rb" }
4
4
  watch('spec/spec_helper.rb') { "spec" }
5
5
  end
data/Manifest CHANGED
@@ -26,6 +26,7 @@ lib/webbynode/api_client.rb
26
26
  lib/webbynode/application.rb
27
27
  lib/webbynode/attribute_accessors.rb
28
28
  lib/webbynode/command.rb
29
+ lib/webbynode/commands/accounts.rb
29
30
  lib/webbynode/commands/add_backup.rb
30
31
  lib/webbynode/commands/add_key.rb
31
32
  lib/webbynode/commands/addons.rb
@@ -36,6 +37,7 @@ lib/webbynode/commands/change_dns.rb
36
37
  lib/webbynode/commands/config.rb
37
38
  lib/webbynode/commands/console.rb
38
39
  lib/webbynode/commands/delete.rb
40
+ lib/webbynode/commands/guides.rb
39
41
  lib/webbynode/commands/help.rb
40
42
  lib/webbynode/commands/init.rb
41
43
  lib/webbynode/commands/logs.rb
@@ -99,12 +101,12 @@ spec/fixtures/git/status/clean
99
101
  spec/fixtures/git/status/dirty
100
102
  spec/fixtures/nodejs/server.js
101
103
  spec/fixtures/pushand
102
- spec/fixtures/settings.py
103
104
  spec/fixtures/trial/user_add
104
105
  spec/spec_helper.rb
105
106
  spec/webbynode/api_client_spec.rb
106
107
  spec/webbynode/application_spec.rb
107
108
  spec/webbynode/command_spec.rb
109
+ spec/webbynode/commands/accounts_spec.rb
108
110
  spec/webbynode/commands/add_backup_spec.rb
109
111
  spec/webbynode/commands/add_key_spec.rb
110
112
  spec/webbynode/commands/addons_spec.rb
@@ -115,6 +117,7 @@ spec/webbynode/commands/change_dns_spec.rb
115
117
  spec/webbynode/commands/config_spec.rb
116
118
  spec/webbynode/commands/console_spec.rb
117
119
  spec/webbynode/commands/delete_spec.rb
120
+ spec/webbynode/commands/guides_spec.rb
118
121
  spec/webbynode/commands/help_spec.rb
119
122
  spec/webbynode/commands/init_spec.rb
120
123
  spec/webbynode/commands/logs_spec.rb
@@ -146,3 +149,4 @@ spec/webbynode/remote_executor_spec.rb
146
149
  spec/webbynode/server_spec.rb
147
150
  spec/webbynode/ssh_spec.rb
148
151
  spec/webbynode/trial_spec.rb
152
+ webbynode.gemspec
data/Rakefile CHANGED
@@ -4,7 +4,7 @@ require 'rake/testtask'
4
4
 
5
5
  require 'echoe'
6
6
 
7
- Echoe.new('webbynode', '1.0.4.3') do |p|
7
+ Echoe.new('webbynode', '1.0.5.beta2') do |p|
8
8
  p.description = "Webbynode Deployment Gem"
9
9
  p.url = "http://webbynode.com"
10
10
  p.author = "Felipe Coury"
@@ -17,6 +17,7 @@ Echoe.new('webbynode', '1.0.4.3') do |p|
17
17
  ['httparty', '>=0.4.5'],
18
18
  ['launchy', '>=0.3.7'],
19
19
  ['domainatrix','>=0.0.7'],
20
+ ['rainbow','1.1.1'],
20
21
  ]
21
22
  # p.dependencies = [
22
23
  # ['activeresource','>= 2.3.4'],
@@ -37,6 +38,10 @@ the comfort of your command line.
37
38
  Please read our guide for a quickstart:
38
39
  http://guides.webbynode.com/articles/rapidapps/
39
40
 
41
+ For more information use the commands:
42
+ wn help
43
+ wn guides
44
+
40
45
  "
41
46
  end
42
47
 
@@ -7,7 +7,15 @@ require 'domainatrix'
7
7
  require 'net/ssh'
8
8
  require 'highline/import'
9
9
  require 'readline'
10
- require 'pp'
10
+ require 'rainbow'
11
+
12
+ begin
13
+ require 'Win32/Console/ANSI' if RUBY_PLATFORM =~ /mswin/
14
+ rescue LoadError
15
+ puts "Hint: if you want to make your output better in windows, install the win32console gem:"
16
+ puts " gem install win32console"
17
+ puts ""
18
+ end
11
19
 
12
20
  require File.join(File.dirname(__FILE__), 'webbynode', 'io')
13
21
  require File.join(File.dirname(__FILE__), 'webbynode', 'git')
@@ -35,6 +43,7 @@ require File.join(File.dirname(__FILE__), 'webbynode', 'engines', 'nodejs')
35
43
  require File.join(File.dirname(__FILE__), 'webbynode', 'engines', 'wsgi')
36
44
  require File.join(File.dirname(__FILE__), 'webbynode', 'engines', 'html')
37
45
  require File.join(File.dirname(__FILE__), 'webbynode', 'engines', 'all')
46
+ require File.join(File.dirname(__FILE__), 'webbynode', 'commands', 'accounts')
38
47
  require File.join(File.dirname(__FILE__), 'webbynode', 'commands', 'apps')
39
48
  require File.join(File.dirname(__FILE__), 'webbynode', 'commands', 'addons')
40
49
  require File.join(File.dirname(__FILE__), 'webbynode', 'commands', 'init')
@@ -59,10 +68,11 @@ require File.join(File.dirname(__FILE__), 'webbynode', 'commands', 'settings')
59
68
  require File.join(File.dirname(__FILE__), 'webbynode', 'commands', 'authorize_root')
60
69
  require File.join(File.dirname(__FILE__), 'webbynode', 'commands', 'console')
61
70
  require File.join(File.dirname(__FILE__), 'webbynode', 'commands', 'logs')
71
+ require File.join(File.dirname(__FILE__), 'webbynode', 'commands', 'guides')
62
72
  require File.join(File.dirname(__FILE__), 'webbynode', 'application')
63
73
 
64
74
  module Webbynode
65
- VERSION = '1.0.4.3'
75
+ VERSION = '1.0.5.beta2'
66
76
  end
67
77
 
68
78
  class Array
@@ -76,4 +86,13 @@ class Array
76
86
 
77
87
  "#{array.join(", ")} #{last_join} #{last}"
78
88
  end
89
+ end
90
+
91
+ class Net::HTTP
92
+ alias_method :old_initialize, :initialize
93
+ def initialize(*args)
94
+ old_initialize(*args)
95
+ @ssl_context = OpenSSL::SSL::SSLContext.new
96
+ @ssl_context.verify_mode = OpenSSL::SSL::VERIFY_NONE
97
+ end
79
98
  end
@@ -280,6 +280,32 @@ module Webbynode
280
280
  end
281
281
 
282
282
  private
283
+
284
+ def spinner(&code)
285
+ chars = %w{ | / - \\ }
286
+
287
+ result = nil
288
+ t = Thread.new {
289
+ result = code.call
290
+ }
291
+ while t.alive?
292
+ print chars[0]
293
+ STDOUT.flush
294
+
295
+ sleep 0.1
296
+
297
+ print "\b"
298
+ STDOUT.flush
299
+
300
+ chars.push chars.shift
301
+ end
302
+
303
+ print " \b"
304
+ STDOUT.flush
305
+
306
+ t.join
307
+ result
308
+ end
283
309
 
284
310
  def parse_args(args)
285
311
  settings[:options].each { |o| o.reset! }
@@ -0,0 +1,77 @@
1
+ module Webbynode::Commands
2
+ class Accounts < Webbynode::Command
3
+ summary "Manages multiple Webbynode accounts"
4
+ add_alias "account"
5
+
6
+ parameter :action, String, "use, new, save, delete or list.",
7
+ :validate => { :in => ["use", "new", "save", "delete", "list"] },
8
+ :default => "list",
9
+ :required => false
10
+ parameter :name, String, "account name", :required => false
11
+
12
+ Prefix = "#{Webbynode::Io.home_dir}/.webbynode"
13
+
14
+ attr_accessor :action
15
+
16
+ def execute
17
+ @action = param(:action) || "default"
18
+ send(action)
19
+ end
20
+
21
+ private
22
+
23
+ def missing_target?
24
+ unless io.file_exists?(target)
25
+ io.log "Account alias '#{param(:name)}' not found. Use 'wn account list' for a full list."
26
+ return true
27
+ end
28
+ end
29
+
30
+ def target
31
+ @target ||= "#{Prefix}_#{param(:name)}"
32
+ end
33
+
34
+ def default
35
+ credentials = api.credentials
36
+ io.log "Current account: #{credentials["email"]}"
37
+ end
38
+
39
+ def list
40
+ files = io.list_files "#{Prefix}_*"
41
+
42
+ unless files.any?
43
+ io.log "No accounts found. Use 'wn accounts save' to save current account with an alias."
44
+ return
45
+ end
46
+
47
+ files.each do |f|
48
+ if f =~ /\.webbynode_(.*)/
49
+ io.log $1
50
+ end
51
+ end
52
+ end
53
+
54
+ def save
55
+ if io.file_exists?(target) and ask("Do you want to overwrite saved account name (y/n)? ").downcase != "y"
56
+ io.log "Save aborted."
57
+ return
58
+ end
59
+
60
+ io.copy_file "#{Prefix}", target
61
+ end
62
+
63
+ def use
64
+ return if missing_target?
65
+ io.copy_file target, "#{Prefix}"
66
+ end
67
+
68
+ def new
69
+ api.init_credentials true
70
+ end
71
+
72
+ def delete
73
+ return if missing_target?
74
+ io.delete_file target
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,11 @@
1
+ require 'launchy'
2
+
3
+ module Webbynode::Commands
4
+ class Guides < Webbynode::Command
5
+ summary "Opens the Rapp Guides in your browser"
6
+
7
+ def execute
8
+ Launchy.open "http://wbno.de/rapp"
9
+ end
10
+ end
11
+ end
@@ -5,7 +5,7 @@ module Webbynode::Commands
5
5
 
6
6
  def execute
7
7
  if param(:command) == "commands"
8
- puts "usage: webbynode COMMAND"
8
+ puts "usage: #{"webbynode".color(:white).bright} #{"COMMAND".color(:green)}"
9
9
  puts
10
10
  puts "Available commands:"
11
11
  dir = File.join(File.expand_path(File.dirname(__FILE__)), "/*.rb")
@@ -13,10 +13,10 @@ module Webbynode::Commands
13
13
  command = file.split("/").last
14
14
  command.gsub!(/\.rb/, "")
15
15
 
16
- puts " #{command.ljust(10)} #{Webbynode::Command.class_for(command).setting(:summary)}"
16
+ puts " #{command.ljust(15).color(:green)} #{Webbynode::Command.class_for(command).setting(:summary)}"
17
17
  end
18
18
  puts
19
- puts "Try 'webbynode help COMMAND' for more information."
19
+ puts "Try '#{"webbynode help".color(:white).bright} #{"COMMAND".color(:green)}' for more information."
20
20
  else
21
21
  kls = Help.for(param(:command))
22
22
  if kls
@@ -14,7 +14,7 @@ module Webbynode::Commands
14
14
  return
15
15
  end
16
16
 
17
- io.log "Webbynode Rapp - http://rapp.webbynode.com"
17
+ io.log "#{"Webbynode Rapp".color(:white).bright} - #{"http://rapp.webbynode.com".underline}"
18
18
 
19
19
  @overwrite = false
20
20
 
@@ -22,7 +22,7 @@ module Webbynode::Commands
22
22
  check_initialized
23
23
 
24
24
  @webby = param(:webby)
25
- @app_name = io.app_name
25
+ @app_name = spinner { io.app_name }
26
26
  @git_present = git.present?
27
27
  @dns_entry = option(:dns) ? "#{option(:dns)}" : @app_name
28
28
 
@@ -30,7 +30,7 @@ module Webbynode::Commands
30
30
 
31
31
  check_git_clean if @git_present
32
32
 
33
- io.log "Initializing application #{@app_name} #{@dns_entry ? "with dns #{@dns_entry}" : ""}", :start
33
+ io.log "Initializing application #{@app_name.color(:yellow)} #{@dns_entry ? "with dns #{@dns_entry.color(:yellow)}" : ""}"
34
34
 
35
35
  detect_engine
36
36
 
@@ -44,12 +44,12 @@ module Webbynode::Commands
44
44
 
45
45
  handle_dns option(:dns) if option(:adddns)
46
46
 
47
- io.log "Application #{@app_name} ready for Rapid Deployment", :finish
47
+ io.log "Application #{@app_name.color(:yellow)} ready for Rapid Deployment", :finish
48
48
 
49
49
  rescue Net::SSH::HostKeyMismatch
50
50
  io.log ""
51
51
  io.log "Error pushing to your server:"
52
- io.log " #{$!}"
52
+ io.log " #{$!.to_s.color(:red)}"
53
53
  io.log ""
54
54
  io.log "This usually happens because you redeployed the server and the fingerprint changed."
55
55
  io.log ""
@@ -60,21 +60,22 @@ module Webbynode::Commands
60
60
  io.log ""
61
61
 
62
62
  rescue Webbynode::InvalidAuthentication
63
- io.log "Could not connect to webby: invalid authentication.", true
63
+ io.log "Could not connect to webby: invalid authentication.".color(:red), true
64
64
 
65
65
  rescue Webbynode::PermissionError
66
- io.log "Could not create an SSH key: permission error.", true
66
+ io.log "Could not create an SSH key: permission error.".color(:red), true
67
67
 
68
68
  rescue Webbynode::GitRemoteAlreadyExistsError
69
- io.log "Application already initialized."
69
+ io.log "Application already initialized.".color(:red)
70
70
  end
71
71
 
72
72
  private
73
73
 
74
74
  def check_git_clean
75
75
  unless git.clean?
76
+ io.log ""
76
77
  raise CommandError,
77
- "Cannot initialize: git has pending changes. Execute a git commit or add changes to .gitignore and try again."
78
+ "#{"Cannot initialize:".color(:red)} #{"git has pending changes.".color(:yellow)}\nExecute a git commit or add changes to .gitignore and try again."
78
79
  end
79
80
  end
80
81
 
@@ -82,7 +83,7 @@ module Webbynode::Commands
82
83
  return unless pushand_exists?
83
84
 
84
85
  io.log ""
85
- io.log "It seems this application was initialized before."
86
+ io.log "It seems this application was initialized before.".color(:yellow)
86
87
 
87
88
  unless ask('Do you want to initialize it again (y/n)?').downcase == 'y'
88
89
  puts ""
@@ -130,8 +131,7 @@ module Webbynode::Commands
130
131
  def delete_remote
131
132
  return unless git.remote_exists?('webbynode')
132
133
 
133
- io.log ""
134
- io.log "Webbynode git integration already initialized."
134
+ io.log "Webbynode git integration already initialized.".color(:yellow)
135
135
  if @overwrite || ask('Do you want to overwrite the current settings (y/n)?').downcase == 'y'
136
136
  git.delete_remote('webbynode')
137
137
  end
@@ -147,16 +147,17 @@ module Webbynode::Commands
147
147
  end
148
148
 
149
149
  def add_remote
150
- io.log "Adding webbynode as git remote..."
150
+ io.log "Adding webbynode as git remote, please wait..."
151
151
  options = {}
152
152
  options[:port] = option(:port).to_i if option(:port)
153
153
  options[:home] = @git_home if @git_home
154
154
 
155
155
  params = [@git_user, "webbynode", @webby_ip, @app_name, options]
156
156
 
157
- Webbynode::Server.new(@webby_ip, @git_user, option(:port) || 22).add_ssh_key LocalSshKey, nil
158
-
159
- git.add_remote *params
157
+ spinner {
158
+ Webbynode::Server.new(@webby_ip, @git_user, option(:port) || 22).add_ssh_key LocalSshKey, nil
159
+ git.add_remote *params
160
+ }
160
161
  end
161
162
 
162
163
  def create_git_remote
@@ -168,7 +169,7 @@ module Webbynode::Commands
168
169
  def get_ip(webby)
169
170
  return webby if webby =~ /\b(?:\d{1,3}\.){3}\d{1,3}\b/
170
171
 
171
- api_webbies = api.webbies
172
+ api_webbies = spinner { api.webbies }
172
173
 
173
174
  unless webby
174
175
  # TODO: raise CommandError id size = 0
@@ -176,14 +177,14 @@ module Webbynode::Commands
176
177
  webby = api_webbies[api_webbies.keys.first]
177
178
  else
178
179
  io.log ""
179
- io.log "Current Webbies in your account:"
180
+ io.log "Current Webbies in your account:".color(:yellow)
180
181
  io.log ""
181
182
 
182
183
  choices = []
183
184
  api_webbies.keys.sort.each_with_index do |webby_key, i|
184
185
  webby = api_webbies[webby_key]
185
186
  choices << webby
186
- io.log " #{i+1}. #{webby['name']} (#{webby['ip']})"
187
+ io.log " #{i+1}. #{webby['name'].color(:yellow)} (#{webby['ip']})"
187
188
  end
188
189
 
189
190
  io.log "", :simple
@@ -192,7 +193,7 @@ module Webbynode::Commands
192
193
  end
193
194
 
194
195
  io.log "", :simple
195
- io.log "Set deployment Webby to #{webby['name']}."
196
+ io.log "Set deployment Webby to #{webby['name'].color(:yellow)}."
196
197
 
197
198
  return webby['ip']
198
199
  end
@@ -244,7 +245,6 @@ module Webbynode::Commands
244
245
  choice = ask("Select the engine your app uses:", Integer) { |q| q.in = 1..(engines.size+1) }
245
246
  engine = engines[choice-1]
246
247
 
247
- io.log ""
248
248
  io.log "Initializing with #{engine.engine_name} engine..."
249
249
 
250
250
  engine