shelly 0.0.48 → 0.0.49.pre
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/shelly/app.rb +20 -4
- data/lib/shelly/cli/main.rb +15 -9
- data/lib/shelly/version.rb +1 -1
- data/spec/shelly/app_spec.rb +26 -4
- data/spec/shelly/cli/main_spec.rb +41 -11
- metadata +32 -32
data/lib/shelly/app.rb
CHANGED
@@ -13,12 +13,16 @@ module Shelly
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def add_git_remote
|
16
|
-
system("git remote rm
|
17
|
-
system("git remote add
|
16
|
+
system("git remote rm #{code_name} > /dev/null 2>&1")
|
17
|
+
system("git remote add #{code_name} #{git_url}")
|
18
|
+
end
|
19
|
+
|
20
|
+
def git_remote_exist?
|
21
|
+
IO.popen("git remote").read.include?(code_name)
|
18
22
|
end
|
19
23
|
|
20
24
|
def remove_git_remote
|
21
|
-
system("git remote rm
|
25
|
+
system("git remote rm #{code_name} > /dev/null 2>&1")
|
22
26
|
end
|
23
27
|
|
24
28
|
def generate_cloudfile
|
@@ -102,7 +106,19 @@ module Shelly
|
|
102
106
|
end
|
103
107
|
|
104
108
|
def self.guess_code_name
|
105
|
-
|
109
|
+
guessed = nil
|
110
|
+
if Cloudfile.present?
|
111
|
+
clouds = Cloudfile.new.clouds
|
112
|
+
if clouds.grep(/staging/)
|
113
|
+
guessed = "production"
|
114
|
+
production_clouds = clouds.grep(/production/)
|
115
|
+
production_clouds.sort.each do |cloud|
|
116
|
+
cloud =~ /production(\d*)/
|
117
|
+
guessed = "production#{$1.to_i+1}"
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
"#{File.basename(Dir.pwd)}-#{guessed || 'staging'}"
|
106
122
|
end
|
107
123
|
|
108
124
|
def users
|
data/lib/shelly/cli/main.rb
CHANGED
@@ -85,8 +85,14 @@ module Shelly
|
|
85
85
|
@app.domains = options["domains"] || ["#{@app.code_name}.shellyapp.com"]
|
86
86
|
@app.create
|
87
87
|
|
88
|
-
|
89
|
-
@app
|
88
|
+
git_remote = @app.git_remote_exist?
|
89
|
+
if !git_remote or (git_remote and yes?("Git remote #{@app} exists, overwrite (yes/no): "))
|
90
|
+
say "Adding remote #{@app} #{@app.git_url}", :green
|
91
|
+
@app.add_git_remote
|
92
|
+
else
|
93
|
+
say "You have to manually add git remote:"
|
94
|
+
say "`git remote add NAME #{@app.git_url}`"
|
95
|
+
end
|
90
96
|
|
91
97
|
say "Creating Cloudfile", :green
|
92
98
|
@app.create_cloudfile
|
@@ -95,12 +101,12 @@ module Shelly
|
|
95
101
|
say "Billing information", :green
|
96
102
|
say "Cloud created with 20 Euro credit."
|
97
103
|
say "Remember to provide billing details before trial ends."
|
98
|
-
url = "#{@app.shelly.shellyapp_url}/apps/#{@app.code_name}/
|
104
|
+
url = "#{@app.shelly.shellyapp_url}/apps/#{@app.code_name}/billing/edit"
|
99
105
|
say url
|
100
106
|
end
|
101
107
|
|
102
108
|
info_adding_cloudfile_to_repository
|
103
|
-
info_deploying_to_shellycloud
|
109
|
+
info_deploying_to_shellycloud(@app)
|
104
110
|
|
105
111
|
rescue Client::ValidationException => e
|
106
112
|
e.each_error { |error| say_error error, :with_exit => false }
|
@@ -344,8 +350,8 @@ module Shelly
|
|
344
350
|
end
|
345
351
|
|
346
352
|
def ask_for_code_name
|
347
|
-
default_code_name =
|
348
|
-
code_name = ask("Cloud code name (#{
|
353
|
+
default_code_name = Shelly::App.guess_code_name
|
354
|
+
code_name = ask("Cloud code name (#{Shelly::App.guess_code_name} - default):")
|
349
355
|
code_name.blank? ? default_code_name : code_name
|
350
356
|
end
|
351
357
|
|
@@ -369,15 +375,15 @@ module Shelly
|
|
369
375
|
say " git status"
|
370
376
|
end
|
371
377
|
|
372
|
-
def info_deploying_to_shellycloud
|
378
|
+
def info_deploying_to_shellycloud(remote)
|
373
379
|
say_new_line
|
374
380
|
say "When you make sure all settings are correct please issue following commands:", :green
|
375
381
|
say " git add ."
|
376
382
|
say ' git commit -m "Application added to Shelly Cloud"'
|
377
383
|
say " git push"
|
378
384
|
say_new_line
|
379
|
-
say "Deploy to
|
380
|
-
say " git push
|
385
|
+
say "Deploy to your cloud using:", :green
|
386
|
+
say " git push #{remote} master"
|
381
387
|
say_new_line
|
382
388
|
end
|
383
389
|
end
|
data/lib/shelly/version.rb
CHANGED
data/spec/shelly/app_spec.rb
CHANGED
@@ -12,8 +12,22 @@ describe Shelly::App do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
describe ".guess_code_name" do
|
15
|
-
|
16
|
-
|
15
|
+
context "no Cloudfile" do
|
16
|
+
it "should return name of current working directory" do
|
17
|
+
Shelly::App.guess_code_name.should == "foo-staging"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context "with Cloudfile" do
|
22
|
+
it "should return production" do
|
23
|
+
File.open("Cloudfile", 'w') {|f| f.write("foo-staging:\n") }
|
24
|
+
Shelly::App.guess_code_name.should == "foo-production"
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should return productionNUMBER" do
|
28
|
+
File.open("Cloudfile", 'w') {|f| f.write("foo-staging:\nfoo-production:\n") }
|
29
|
+
Shelly::App.guess_code_name.should == "foo-production1"
|
30
|
+
end
|
17
31
|
end
|
18
32
|
end
|
19
33
|
|
@@ -31,16 +45,24 @@ describe Shelly::App do
|
|
31
45
|
end
|
32
46
|
|
33
47
|
it "should try to remove existing git remote" do
|
34
|
-
@app.should_receive(:system).with("git remote rm
|
48
|
+
@app.should_receive(:system).with("git remote rm foo-staging > /dev/null 2>&1")
|
35
49
|
@app.add_git_remote
|
36
50
|
end
|
37
51
|
|
38
52
|
it "should add git remote with proper name and git repository" do
|
39
|
-
@app.should_receive(:system).with("git remote add
|
53
|
+
@app.should_receive(:system).with("git remote add foo-staging git@git.shellycloud.com:foo-staging.git")
|
40
54
|
@app.add_git_remote
|
41
55
|
end
|
42
56
|
end
|
43
57
|
|
58
|
+
describe "git_remote_exist" do
|
59
|
+
it "should return true if git remote exist" do
|
60
|
+
io = mock(:read => "origin\nfoo-staging")
|
61
|
+
IO.should_receive(:popen).with("git remote").and_return(io)
|
62
|
+
@app.git_remote_exist?.should be_true
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
44
66
|
describe "#configs" do
|
45
67
|
it "should get configs from client" do
|
46
68
|
@client.should_receive(:app_configs).with("foo-staging").and_return(config_response)
|
@@ -274,6 +274,7 @@ OUT
|
|
274
274
|
Shelly::App.stub(:new).and_return(@app)
|
275
275
|
@client.stub(:token).and_return("abc")
|
276
276
|
@app.stub(:attributes).and_return({"trial" => false})
|
277
|
+
@app.stub(:git_remote_exist?).and_return(false)
|
277
278
|
end
|
278
279
|
|
279
280
|
# This spec tests inside_git_repository? hook
|
@@ -328,7 +329,7 @@ OUT
|
|
328
329
|
end
|
329
330
|
|
330
331
|
it "should use code name provided by user" do
|
331
|
-
$stdout.should_receive(:print).with("Cloud code name (foo-
|
332
|
+
$stdout.should_receive(:print).with("Cloud code name (foo-staging - default): ")
|
332
333
|
@app.should_receive(:code_name=).with("mycodename")
|
333
334
|
fake_stdin(["mycodename", ""]) do
|
334
335
|
invoke(@main, :add)
|
@@ -337,8 +338,8 @@ OUT
|
|
337
338
|
|
338
339
|
context "when user provided empty code name" do
|
339
340
|
it "should use 'current_dirname-purpose' as default" do
|
340
|
-
$stdout.should_receive(:print).with("Cloud code name (foo-
|
341
|
-
@app.should_receive(:code_name=).with("foo-
|
341
|
+
$stdout.should_receive(:print).with("Cloud code name (foo-staging - default): ")
|
342
|
+
@app.should_receive(:code_name=).with("foo-staging")
|
342
343
|
fake_stdin(["", ""]) do
|
343
344
|
invoke(@main, :add)
|
344
345
|
end
|
@@ -393,6 +394,7 @@ OUT
|
|
393
394
|
$stdout.should_receive(:puts).with(green "Billing information")
|
394
395
|
$stdout.should_receive(:puts).with("Cloud created with 20 Euro credit.")
|
395
396
|
$stdout.should_receive(:puts).with("Remember to provide billing details before trial ends.")
|
397
|
+
$stdout.should_receive(:puts).with("http://example.com/apps/foo-staging/billing/edit")
|
396
398
|
|
397
399
|
fake_stdin(["", ""]) do
|
398
400
|
invoke(@main, :add)
|
@@ -414,7 +416,7 @@ OUT
|
|
414
416
|
@app.should_receive(:create).and_raise(exception)
|
415
417
|
$stdout.should_receive(:puts).with("\e[31mCode name has been already taken\e[0m")
|
416
418
|
$stdout.should_receive(:puts).with("\e[31mFix erros in the below command and type it again to create your cloud\e[0m")
|
417
|
-
$stdout.should_receive(:puts).with("\e[31mshelly add --code-name=foo-
|
419
|
+
$stdout.should_receive(:puts).with("\e[31mshelly add --code-name=foo-staging --databases=postgresql --domains=foo-staging.shellyapp.com\e[0m")
|
418
420
|
lambda {
|
419
421
|
fake_stdin(["", ""]) do
|
420
422
|
invoke(@main, :add)
|
@@ -435,11 +437,39 @@ OUT
|
|
435
437
|
}.should raise_error(SystemExit)
|
436
438
|
end
|
437
439
|
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
440
|
+
context "git remote" do
|
441
|
+
it "should add one if it doesn't exist" do
|
442
|
+
$stdout.should_receive(:puts).with("\e[32mAdding remote foooo git@git.shellycloud.com:foooo.git\e[0m")
|
443
|
+
@app.should_receive(:add_git_remote)
|
444
|
+
fake_stdin(["foooo", ""]) do
|
445
|
+
invoke(@main, :add)
|
446
|
+
end
|
447
|
+
end
|
448
|
+
|
449
|
+
context "does exist" do
|
450
|
+
before do
|
451
|
+
@app.stub(:git_remote_exist?).and_return(true)
|
452
|
+
end
|
453
|
+
|
454
|
+
it "should ask if one exist and overwrite" do
|
455
|
+
$stdout.should_receive(:print).with("Git remote foooo exists, overwrite (yes/no): ")
|
456
|
+
$stdout.should_receive(:puts).with(green "Adding remote foooo git@git.shellycloud.com:foooo.git")
|
457
|
+
@app.should_receive(:add_git_remote)
|
458
|
+
fake_stdin(["foooo", "", "yes"]) do
|
459
|
+
invoke(@main, :add)
|
460
|
+
end
|
461
|
+
end
|
462
|
+
|
463
|
+
it "should ask if one exist and not overwrite" do
|
464
|
+
$stdout.should_receive(:print).with("Git remote foooo exists, overwrite (yes/no): ")
|
465
|
+
$stdout.should_receive(:puts).with("You have to manually add git remote:")
|
466
|
+
$stdout.should_receive(:puts).with("`git remote add NAME git@git.shellycloud.com:foooo.git`")
|
467
|
+
@app.should_not_receive(:add_git_remote)
|
468
|
+
fake_stdin(["foooo", "", "no"]) do
|
469
|
+
invoke(@main, :add)
|
470
|
+
end
|
471
|
+
end
|
472
|
+
|
443
473
|
end
|
444
474
|
end
|
445
475
|
|
@@ -465,8 +495,8 @@ OUT
|
|
465
495
|
$stdout.should_receive(:puts).with(" git add .")
|
466
496
|
$stdout.should_receive(:puts).with(' git commit -m "Application added to Shelly Cloud"')
|
467
497
|
$stdout.should_receive(:puts).with(" git push")
|
468
|
-
$stdout.should_receive(:puts).with("\e[32mDeploy to
|
469
|
-
$stdout.should_receive(:puts).with(" git push
|
498
|
+
$stdout.should_receive(:puts).with("\e[32mDeploy to your cloud using:\e[0m")
|
499
|
+
$stdout.should_receive(:puts).with(" git push foooo master")
|
470
500
|
fake_stdin(["foooo", "none"]) do
|
471
501
|
invoke(@main, :add)
|
472
502
|
end
|
metadata
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shelly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.49.pre
|
5
|
+
prerelease: 7
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Shelly Cloud team
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02-
|
12
|
+
date: 2012-02-21 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70139660816540 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70139660816540
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &70139660816120 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70139660816120
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: guard
|
38
|
-
requirement: &
|
38
|
+
requirement: &70139660815700 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70139660815700
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: guard-rspec
|
49
|
-
requirement: &
|
49
|
+
requirement: &70139660815280 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70139660815280
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: simplecov
|
60
|
-
requirement: &
|
60
|
+
requirement: &70139660814860 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70139660814860
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: ruby_gntp
|
71
|
-
requirement: &
|
71
|
+
requirement: &70139660814380 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70139660814380
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: rb-fsevent
|
82
|
-
requirement: &
|
82
|
+
requirement: &70139660813920 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70139660813920
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: fakefs
|
93
|
-
requirement: &
|
93
|
+
requirement: &70139660813400 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,10 +98,10 @@ dependencies:
|
|
98
98
|
version: '0'
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *70139660813400
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: fakeweb
|
104
|
-
requirement: &
|
104
|
+
requirement: &70139660812900 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ! '>='
|
@@ -109,10 +109,10 @@ dependencies:
|
|
109
109
|
version: '0'
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *70139660812900
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: wijet-thor
|
115
|
-
requirement: &
|
115
|
+
requirement: &70139660812180 !ruby/object:Gem::Requirement
|
116
116
|
none: false
|
117
117
|
requirements:
|
118
118
|
- - ~>
|
@@ -120,10 +120,10 @@ dependencies:
|
|
120
120
|
version: 0.14.7
|
121
121
|
type: :runtime
|
122
122
|
prerelease: false
|
123
|
-
version_requirements: *
|
123
|
+
version_requirements: *70139660812180
|
124
124
|
- !ruby/object:Gem::Dependency
|
125
125
|
name: rest-client
|
126
|
-
requirement: &
|
126
|
+
requirement: &70139660811420 !ruby/object:Gem::Requirement
|
127
127
|
none: false
|
128
128
|
requirements:
|
129
129
|
- - ! '>='
|
@@ -131,10 +131,10 @@ dependencies:
|
|
131
131
|
version: '0'
|
132
132
|
type: :runtime
|
133
133
|
prerelease: false
|
134
|
-
version_requirements: *
|
134
|
+
version_requirements: *70139660811420
|
135
135
|
- !ruby/object:Gem::Dependency
|
136
136
|
name: json
|
137
|
-
requirement: &
|
137
|
+
requirement: &70139660810960 !ruby/object:Gem::Requirement
|
138
138
|
none: false
|
139
139
|
requirements:
|
140
140
|
- - ! '>='
|
@@ -142,10 +142,10 @@ dependencies:
|
|
142
142
|
version: '0'
|
143
143
|
type: :runtime
|
144
144
|
prerelease: false
|
145
|
-
version_requirements: *
|
145
|
+
version_requirements: *70139660810960
|
146
146
|
- !ruby/object:Gem::Dependency
|
147
147
|
name: progressbar
|
148
|
-
requirement: &
|
148
|
+
requirement: &70139660810520 !ruby/object:Gem::Requirement
|
149
149
|
none: false
|
150
150
|
requirements:
|
151
151
|
- - ! '>='
|
@@ -153,7 +153,7 @@ dependencies:
|
|
153
153
|
version: '0'
|
154
154
|
type: :runtime
|
155
155
|
prerelease: false
|
156
|
-
version_requirements: *
|
156
|
+
version_requirements: *70139660810520
|
157
157
|
description: Tool for managing applications and clouds at shellycloud.com
|
158
158
|
email:
|
159
159
|
- support@shellycloud.com
|
@@ -226,12 +226,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
226
226
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
227
227
|
none: false
|
228
228
|
requirements:
|
229
|
-
- - ! '
|
229
|
+
- - ! '>'
|
230
230
|
- !ruby/object:Gem::Version
|
231
|
-
version:
|
231
|
+
version: 1.3.1
|
232
232
|
requirements: []
|
233
233
|
rubyforge_project: shelly
|
234
|
-
rubygems_version: 1.8.
|
234
|
+
rubygems_version: 1.8.10
|
235
235
|
signing_key:
|
236
236
|
specification_version: 3
|
237
237
|
summary: Shelly Cloud command line tool
|