codebase 3.1.4 → 3.1.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/lib/codebase/command.rb +4 -0
- data/lib/codebase/commands/setup.rb +5 -33
- metadata +1 -1
data/lib/codebase/command.rb
CHANGED
@@ -75,8 +75,12 @@ module Codebase
|
|
75
75
|
case res
|
76
76
|
when Net::HTTPSuccess
|
77
77
|
return res.body
|
78
|
+
when Net::HTTPForbidden, Net::HTTPUnauthorized
|
79
|
+
puts "Access Denied. Ensure you have correctly configured your local Gem installation using the 'cb setup' command."
|
80
|
+
Process.exit(1)
|
78
81
|
else
|
79
82
|
puts res.body
|
83
|
+
|
80
84
|
return false
|
81
85
|
end
|
82
86
|
end
|
@@ -8,20 +8,14 @@ module Codebase
|
|
8
8
|
def setup
|
9
9
|
puts "\e[33;44mWelcome to the CodebaseHQ Initial Setup Tool\e[0m"
|
10
10
|
puts "This tool will get your local computer configured to use your codebase account. It will automatically configure"
|
11
|
-
puts "the gem for API access
|
11
|
+
puts "the gem for API access so you can use many of the gem functions."
|
12
12
|
puts
|
13
13
|
|
14
14
|
## Is this configured?
|
15
15
|
if u = git_config_variable(:username)
|
16
16
|
puts "This system is already configured as \e[32m#{u}\e[0m."
|
17
|
-
|
18
|
-
|
19
|
-
api_key = git_config_variable(:apikey)
|
20
|
-
|
21
|
-
unless agree("Are you sure you wish to continue with uploading your public keys?")
|
22
|
-
puts "OK, no problem."
|
23
|
-
return
|
24
|
-
end
|
17
|
+
puts "You can run 'cb unsetup' to clear settings."
|
18
|
+
return
|
25
19
|
else
|
26
20
|
## Get some details
|
27
21
|
domain = ask_with_validation("CodebaseHQ domain (e.g. widgetinc.codebasehq.com): ", /\A(\w+).(codebasehq|cbhqdev).(com|local)\z/)
|
@@ -41,22 +35,7 @@ module Codebase
|
|
41
35
|
return
|
42
36
|
end
|
43
37
|
end
|
44
|
-
|
45
|
-
## Send the user's public key to the server if they don't already have keys...
|
46
|
-
key_file = File.expand_path(File.join('~', '.ssh', 'id_rsa.pub'))
|
47
|
-
if File.exist?(key_file)
|
48
|
-
key = File.read(key_file)
|
49
|
-
description = "Key from #{machine_hostname}"
|
50
|
-
if api_request("http://#{domain}/users/#{username}/public_keys", username, api_key, "<public-key><description>#{description}</description><key>#{key}</key></public-key>")
|
51
|
-
puts "\e[32mPublic key from #{key_file} uploaded to your Codebase account on #{domain}.\e[0m"
|
52
|
-
else
|
53
|
-
puts "\e[37;41mWe couldn't upload your public key at this file. Please try later and verify your API key is correct.\e[0m"
|
54
|
-
end
|
55
|
-
|
56
|
-
else
|
57
|
-
puts "No key file found at #{key_file}. Nothing to upload to Codebase."
|
58
|
-
end
|
59
|
-
|
38
|
+
|
60
39
|
end
|
61
40
|
|
62
41
|
def unsetup
|
@@ -79,14 +58,7 @@ module Codebase
|
|
79
58
|
puts
|
80
59
|
password
|
81
60
|
end
|
82
|
-
|
83
|
-
def machine_hostname
|
84
|
-
require 'socket'
|
85
|
-
Socket.gethostname
|
86
|
-
rescue
|
87
|
-
"local computer"
|
88
|
-
end
|
89
|
-
|
61
|
+
|
90
62
|
end
|
91
63
|
end
|
92
64
|
end
|