jiveapps 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +8 -0
- data/lib/jiveapps.rb +1 -0
- data/lib/jiveapps/client.rb +1 -1
- data/lib/jiveapps/commands/app.rb +47 -7
- data/lib/jiveapps/commands/auth.rb +0 -2
- data/lib/jiveapps/commands/help.rb +3 -3
- data/lib/jiveapps/commands/keys.rb +2 -2
- data/lib/jiveapps/version.rb +1 -1
- data/spec/commands/app_spec.rb +21 -3
- metadata +7 -17
data/History.txt
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
=== 1.0.6 2012-02-08
|
2
|
+
* Enhancements
|
3
|
+
* ADT-26: Prompt to delete files and delete if so
|
4
|
+
* Update error message display logic to handle an array of multiple errors per field.
|
5
|
+
* ADT-16: Implement jiveapps delete command
|
6
|
+
* Rename KEY_REGEX to SSH_KEY_REGEX, avoid name conflict warning in tests.
|
7
|
+
* ADT-27: Check for existance of app dir before create. If it does, halt and display error.
|
8
|
+
|
1
9
|
=== 1.0.5 2011-07-29
|
2
10
|
* Enhancements
|
3
11
|
* Update app template to use preferred height of 400 px on home view
|
data/lib/jiveapps.rb
CHANGED
data/lib/jiveapps/client.rb
CHANGED
@@ -173,7 +173,7 @@ class Jiveapps::Client
|
|
173
173
|
def process(method, uri, extra_headers={}, payload=nil)
|
174
174
|
headers = jiveapps_headers.merge(extra_headers)
|
175
175
|
args = [method, payload, headers].compact
|
176
|
-
|
176
|
+
|
177
177
|
begin
|
178
178
|
response = resource(uri).send(*args)
|
179
179
|
extract_warning(response)
|
@@ -24,7 +24,7 @@ module Jiveapps::Command
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def info
|
27
|
-
name =
|
27
|
+
name = determine_app_name
|
28
28
|
app = jiveapps.info(name)
|
29
29
|
if app == nil
|
30
30
|
display "App not found."
|
@@ -58,6 +58,7 @@ module Jiveapps::Command
|
|
58
58
|
|
59
59
|
debug "Running in debug mode."
|
60
60
|
check_git_version
|
61
|
+
check_if_dir_already_exists
|
61
62
|
app_list = Jiveapps::Command.run_internal('auth:check', []) # check auth credentials and ssh key before generating app
|
62
63
|
return unless app_list.class == Array
|
63
64
|
Jiveapps::Command.run_internal('keys:add', ["--silent"])
|
@@ -71,7 +72,7 @@ module Jiveapps::Command
|
|
71
72
|
end
|
72
73
|
|
73
74
|
def install
|
74
|
-
name =
|
75
|
+
name = determine_app_name
|
75
76
|
display "=== Installing \"#{name}\" on the Jive App Sandbox: ", false
|
76
77
|
app = jiveapps.install(name)
|
77
78
|
handle_response_errors
|
@@ -83,6 +84,34 @@ module Jiveapps::Command
|
|
83
84
|
end
|
84
85
|
end
|
85
86
|
|
87
|
+
def delete
|
88
|
+
name = determine_app_name
|
89
|
+
app = jiveapps.info(name)
|
90
|
+
if app == nil
|
91
|
+
display "App not found."
|
92
|
+
else
|
93
|
+
if confirm("Are you sure you want to delete the app \"#{name}\" [y/N]? ")
|
94
|
+
display "=== Deleting \"#{name}\": ", false
|
95
|
+
@current_app = jiveapps.delete_app(name)
|
96
|
+
handle_response_errors
|
97
|
+
|
98
|
+
dir_delete_text = "Would you like to delete the local directory \"#{name}\" [y/N]? "
|
99
|
+
|
100
|
+
# if we're in the app directory now
|
101
|
+
if File.split(Dir.pwd).last == name && File.directory?(".git") && confirm(dir_delete_text)
|
102
|
+
Dir.chdir("..")
|
103
|
+
FileUtils.rm_rf(name)
|
104
|
+
display "Local directory \"#{name}\" deleted."
|
105
|
+
# otherwise if that directory exists below the current one
|
106
|
+
elsif File.directory?(name) && confirm(dir_delete_text)
|
107
|
+
FileUtils.rm_rf(name)
|
108
|
+
display "Local directory \"#{name}\" deleted."
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
86
115
|
private
|
87
116
|
|
88
117
|
def create_remote_app
|
@@ -119,7 +148,7 @@ module Jiveapps::Command
|
|
119
148
|
display "FAILURE"
|
120
149
|
display result.error
|
121
150
|
display_git_push_fail_info
|
122
|
-
|
151
|
+
delete_app_and_dir
|
123
152
|
else
|
124
153
|
display "SUCCESS"
|
125
154
|
Dir.chdir(File.join(Dir.pwd, @appname)) do
|
@@ -133,7 +162,7 @@ module Jiveapps::Command
|
|
133
162
|
response_code = get_response_code(current_app['app_url'])
|
134
163
|
if response_code != 200
|
135
164
|
display_git_push_fail_info
|
136
|
-
|
165
|
+
delete_app_and_dir
|
137
166
|
end
|
138
167
|
end
|
139
168
|
|
@@ -145,7 +174,7 @@ module Jiveapps::Command
|
|
145
174
|
handle_response_errors
|
146
175
|
end
|
147
176
|
|
148
|
-
def
|
177
|
+
def delete_app_and_dir
|
149
178
|
run("rm -rf #{@appname}")
|
150
179
|
jiveapps.delete_app(@appname)
|
151
180
|
@current_app = nil # halt further actions
|
@@ -189,10 +218,11 @@ module Jiveapps::Command
|
|
189
218
|
display "FAILURE"
|
190
219
|
@current_app["errors"].each do |key, value|
|
191
220
|
if key == 'base'
|
192
|
-
display "Error:
|
221
|
+
display "Error: ", false
|
193
222
|
else
|
194
|
-
display "Error on \"#{key}\":
|
223
|
+
display "Error on \"#{key}\": ", false
|
195
224
|
end
|
225
|
+
display value.to_yaml.gsub(/^--- /, '') # to_yaml easily displays an array as a multiline list. gsub() to get rid of first "---" that to_yaml puts out.
|
196
226
|
end
|
197
227
|
@current_app = nil
|
198
228
|
else
|
@@ -208,5 +238,15 @@ module Jiveapps::Command
|
|
208
238
|
end
|
209
239
|
end
|
210
240
|
|
241
|
+
def check_if_dir_already_exists
|
242
|
+
if File.directory?(@appname)
|
243
|
+
error("A directory named \"#{@appname}\" already exists. Please delete or move directory and try again.")
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
def determine_app_name
|
248
|
+
args.first && args.first !~ /^\-\-/ ? args.first : extract_app
|
249
|
+
end
|
250
|
+
|
211
251
|
end
|
212
252
|
end
|
@@ -18,8 +18,10 @@ module Jiveapps::Command
|
|
18
18
|
display "=== App Specific Commands"
|
19
19
|
display " NOTE: run these within app directory, or pass app name with: --app <app_name>"
|
20
20
|
display ""
|
21
|
-
display "info #
|
21
|
+
display "info # display information about an app"
|
22
22
|
display "install # install an app on the sandbox (if you removed it, you can reinstall)"
|
23
|
+
display "livedev # start livedev mode"
|
24
|
+
display "delete # delete app"
|
23
25
|
display ""
|
24
26
|
display "keys # show your user\'s public keys"
|
25
27
|
display "keys:add [<path to keyfile>] # add a public key. optionally include path"
|
@@ -33,8 +35,6 @@ module Jiveapps::Command
|
|
33
35
|
display "sharing:add <username> # add a collaborator"
|
34
36
|
display "sharing:remove <username> # remove a collaborator"
|
35
37
|
display ""
|
36
|
-
display "livedev # start livedev mode"
|
37
|
-
display ""
|
38
38
|
display "=== Simple Workflow Example:"
|
39
39
|
display ""
|
40
40
|
display "$ jiveapps create myapp # create a new app named \"myapp\""
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Jiveapps::Command
|
2
2
|
class Keys < Base
|
3
3
|
|
4
|
-
|
4
|
+
SSH_KEY_REGEX = /^((?:[A-Za-z0-9-]+(?:="[^"]+")?,?)+ *)?(ssh-(?:dss|rsa)) *([^ ]*) *(.*)/
|
5
5
|
|
6
6
|
# Lists uploaded SSH keys
|
7
7
|
def list
|
@@ -76,7 +76,7 @@ module Jiveapps::Command
|
|
76
76
|
end
|
77
77
|
|
78
78
|
def validate_key(key, keyfile)
|
79
|
-
if
|
79
|
+
if SSH_KEY_REGEX.match(key.strip).nil?
|
80
80
|
fake_key = "ssh-rsa NAyG4kbVIZyokH/hMDkLbrFBktxPgsQKBgQDshif7w5RgOTK0eaNC6AJbjX0NTOgoTtbjQIX0s9fAUiakcxU3Qqna9ONXlL1mgf+WZ3KgOyUyNcgz2JPWinZseoTDNukRixqcLS9HO8qOWoLUHJZID1q1xf/btESt4UylEMiykEn712YGqCpVdFxX+q7z7b6Z5G/9n49hKWN22wKBgQCBDM1DUeqOX5Li2Hnj/EF/PfhGypAlhz/Klh40foNq7TziwFtkTZz06HpRNIhK2VcoLhU49f2v6CrcaEmll9Zs5Hw2VMrSeTNReO5gRfxlrId1imhfBkYUaZImEKSWAe3HgdyihCmXqf5SCQOtVmm5lxbgaSBjz== your.name@machine.name"
|
81
81
|
|
82
82
|
raise CommandFailed, "Invalid SSH public key format found at \"#{keyfile}\":\n\n#{key}\n\nExample of correct format:\n\n#{fake_key}\n\nCheck and fix, or regenerate key with this command:\n$ ssh-keygen -t rsa"
|
data/lib/jiveapps/version.rb
CHANGED
data/spec/commands/app_spec.rb
CHANGED
@@ -27,10 +27,10 @@ module Jiveapps::Command
|
|
27
27
|
describe "app info" do
|
28
28
|
it "shows info when name specified and rest client returns an app" do
|
29
29
|
@cli.stub!(:args).and_return(['myapp'])
|
30
|
-
@cli.jiveapps.should_receive(:info).with('myapp').and_return({
|
31
|
-
'name' => 'myapp',
|
30
|
+
@cli.jiveapps.should_receive(:info).with('myapp').and_return({
|
31
|
+
'name' => 'myapp',
|
32
32
|
'app_url' => 'http://app_url',
|
33
|
-
'git_url' => 'http://git_url'
|
33
|
+
'git_url' => 'http://git_url'
|
34
34
|
})
|
35
35
|
@cli.should_receive(:display).with('=== myapp')
|
36
36
|
@cli.should_receive(:display).with("App URL: http://app_url")
|
@@ -59,5 +59,23 @@ module Jiveapps::Command
|
|
59
59
|
|
60
60
|
end
|
61
61
|
|
62
|
+
describe "check_if_dir_already_exists" do
|
63
|
+
it "should throw an error if dir exists" do
|
64
|
+
name = "random-name-#{(rand * 100000).to_i}"
|
65
|
+
FileUtils.mkdir(name)
|
66
|
+
@cli.instance_variable_set("@appname", name)
|
67
|
+
@cli.should_receive(:error).with("A directory named \"#{name}\" already exists. Please delete or move directory and try again.")
|
68
|
+
@cli.send :check_if_dir_already_exists
|
69
|
+
FileUtils.rm_rf(name)
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should not throw an error if dir does not exist" do
|
73
|
+
name = "random-name-#{(rand * 100000).to_i}"
|
74
|
+
@cli.instance_variable_set("@appname", name)
|
75
|
+
@cli.should_not_receive(:error)
|
76
|
+
@cli.send :check_if_dir_already_exists
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
62
80
|
end
|
63
81
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jiveapps
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 6
|
10
|
+
version: 1.0.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Scott Becker
|
@@ -15,8 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
19
|
-
default_executable:
|
18
|
+
date: 2012-02-08 00:00:00 Z
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
21
|
name: activesupport
|
@@ -224,7 +223,6 @@ files:
|
|
224
223
|
- spec/commands/oauth_spec.rb
|
225
224
|
- spec/commands/sharing_spec.rb
|
226
225
|
- spec/spec_helper.rb
|
227
|
-
has_rdoc: true
|
228
226
|
homepage: https://github.com/jivesoftware/jiveapps-gem
|
229
227
|
licenses: []
|
230
228
|
|
@@ -254,17 +252,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
254
252
|
requirements: []
|
255
253
|
|
256
254
|
rubyforge_project:
|
257
|
-
rubygems_version: 1.
|
255
|
+
rubygems_version: 1.8.10
|
258
256
|
signing_key:
|
259
257
|
specification_version: 3
|
260
258
|
summary: The "jiveapps" gem is a set of command line tools for building and hosting Jive App front-ends.
|
261
|
-
test_files:
|
262
|
-
|
263
|
-
- spec/commands/app_spec.rb
|
264
|
-
- spec/commands/base_spec.rb
|
265
|
-
- spec/commands/help_spec.rb
|
266
|
-
- spec/commands/keys_spec.rb
|
267
|
-
- spec/commands/livedev_spec.rb
|
268
|
-
- spec/commands/oauth_spec.rb
|
269
|
-
- spec/commands/sharing_spec.rb
|
270
|
-
- spec/spec_helper.rb
|
259
|
+
test_files: []
|
260
|
+
|