xploy 0.1.0.beta → 0.1.1.beta
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/CHANGELOG.md +23 -0
- data/README.md +34 -1
- data/bin/xploy +1 -1
- data/lib/xploy.rb +5 -0
- data/lib/xploy/api/endpoints.rb +13 -34
- data/lib/xploy/cli.rb +13 -4
- data/lib/xploy/template.rb +20 -0
- data/lib/xploy/version.rb +1 -1
- data/spec/assets/template.json +11 -0
- data/spec/lib/xploy/api/endpoints_spec.rb +0 -2
- data/spec/lib/xploy/cli_spec.rb +33 -3
- data/spec/lib/xploy/template_spec.rb +6 -0
- data/spec/lib/xploy_spec.rb +14 -0
- data/xploy.gemspec +1 -0
- metadata +24 -4
- data/spec/integration/lib/xploy/cli_spec.rb +0 -9
data/CHANGELOG.md
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# 0.1.1.beta
|
2
|
+
|
3
|
+
* Generate manifest template using `xploy new app.json`
|
4
|
+
|
5
|
+
# 0.1.0.beta
|
6
|
+
|
7
|
+
* Project rename from 'xway' to 'xploy'
|
8
|
+
|
9
|
+
# 0.0.3.beta
|
10
|
+
|
11
|
+
* Bugfixes
|
12
|
+
|
13
|
+
# 0.0.2.beta
|
14
|
+
|
15
|
+
* Bugfixes
|
16
|
+
|
17
|
+
# 0.0.1.beta
|
18
|
+
|
19
|
+
* Partially working CLI that integrates with appway
|
20
|
+
|
21
|
+
# 0.0.1.alpha
|
22
|
+
|
23
|
+
* Architecture / coding draft
|
data/README.md
CHANGED
@@ -24,9 +24,20 @@ Or install it yourself as:
|
|
24
24
|
|
25
25
|
## Usage
|
26
26
|
|
27
|
+
Print usage with:
|
28
|
+
|
27
29
|
$ xploy
|
28
30
|
|
29
|
-
|
31
|
+
Generate a new app manifest with:
|
32
|
+
|
33
|
+
$ xploy new example.json
|
34
|
+
|
35
|
+
Deploy it to your appway instance on `http://localhost:8000` with:
|
36
|
+
|
37
|
+
$ xploy --servers=http://localhost:8000 --app.name=example --app.manifest=example.json
|
38
|
+
OK
|
39
|
+
|
40
|
+
### Recommended Setup
|
30
41
|
|
31
42
|
You can store default parameters like `app.name` and `app.manifest` in a file named `.xploy` located in your current working dir.
|
32
43
|
|
@@ -38,6 +49,28 @@ Here you can just redeploy the preconfigured app like so:
|
|
38
49
|
|
39
50
|
$ xploy redeploy
|
40
51
|
|
52
|
+
### Configuration
|
53
|
+
|
54
|
+
#### --app.name
|
55
|
+
|
56
|
+
The application name
|
57
|
+
|
58
|
+
#### --app.manifest
|
59
|
+
|
60
|
+
The path to the application manifest
|
61
|
+
|
62
|
+
#### --servers
|
63
|
+
|
64
|
+
A list of appway servers that the client must communicate with
|
65
|
+
|
66
|
+
#### --debug
|
67
|
+
|
68
|
+
When set to `true` it will debug all http traffic
|
69
|
+
|
70
|
+
#### --version
|
71
|
+
|
72
|
+
Print version
|
73
|
+
|
41
74
|
## Development
|
42
75
|
|
43
76
|
To run the binary from the repository use the following command with ruby libray path:
|
data/bin/xploy
CHANGED
data/lib/xploy.rb
CHANGED
@@ -3,9 +3,14 @@ require 'xploy/error'
|
|
3
3
|
require 'xploy/parameter'
|
4
4
|
require 'xploy/api'
|
5
5
|
require 'xploy/cli'
|
6
|
+
require 'xploy/template'
|
6
7
|
|
7
8
|
module Xploy
|
8
9
|
def self.parameter
|
9
10
|
@parameter ||= Parameter.new.reload!
|
10
11
|
end
|
12
|
+
|
13
|
+
def self.build_cli
|
14
|
+
Cli.new Api.new, STDOUT, Template
|
15
|
+
end
|
11
16
|
end
|
data/lib/xploy/api/endpoints.rb
CHANGED
@@ -10,65 +10,44 @@ module Xploy
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def find options={}
|
13
|
-
|
14
|
-
options[:name] ||= ':name'
|
15
|
-
Request.new 'get', "/applications/#{options[:name]}"
|
13
|
+
Request.new 'get', "/applications/#{extract(options, :name)}"
|
16
14
|
end
|
17
15
|
|
18
16
|
def update options={}
|
19
|
-
|
20
|
-
options[:name] ||= ':name'
|
21
|
-
Request.new 'put', "/applications/#{options[:name]}"
|
17
|
+
Request.new 'put', "/applications/#{extract(options, :name)}"
|
22
18
|
end
|
23
19
|
|
24
20
|
def delete options={}
|
25
|
-
|
26
|
-
options[:name] ||= ':name'
|
27
|
-
Request.new 'delete', "/applications/#{options[:name]}"
|
21
|
+
Request.new 'delete', "/applications/#{extract(options, :name)}"
|
28
22
|
end
|
29
23
|
|
30
24
|
def log options={}
|
31
|
-
|
32
|
-
options[:name] ||= ':name'
|
33
|
-
Request.new 'get', "/applications/#{options[:name]}/log"
|
25
|
+
Request.new 'get', "/applications/#{extract(options, :name)}/log"
|
34
26
|
end
|
35
27
|
|
36
28
|
def start options={}
|
37
|
-
|
38
|
-
options[:name] ||= ':name'
|
39
|
-
Request.new 'post', "/applications/#{options[:name]}/start"
|
29
|
+
Request.new 'post', "/applications/#{extract(options, :name)}/start"
|
40
30
|
end
|
41
31
|
|
42
32
|
def stop options={}
|
43
|
-
|
44
|
-
options[:name] ||= ':name'
|
45
|
-
Request.new 'post', "/applications/#{options[:name]}/stop"
|
33
|
+
Request.new 'post', "/applications/#{extract(options, :name)}/stop"
|
46
34
|
end
|
47
35
|
|
48
36
|
def restart options={}
|
49
|
-
|
50
|
-
options[:name] ||= ':name'
|
51
|
-
Request.new 'post', "/applications/#{options[:name]}/restart"
|
37
|
+
Request.new 'post', "/applications/#{extract(options, :name)}/restart"
|
52
38
|
end
|
53
39
|
|
54
40
|
def redeploy options={}
|
55
|
-
|
56
|
-
options[:name] ||= ':name'
|
57
|
-
Request.new 'post', "/applications/#{options[:name]}/redeploy"
|
41
|
+
Request.new 'post', "/applications/#{extract(options, :name)}/redeploy"
|
58
42
|
end
|
59
43
|
|
60
44
|
private
|
61
45
|
|
62
|
-
def
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
end
|
68
|
-
end
|
69
|
-
unless missing_keys.empty?
|
70
|
-
raise MissingParameter, "Missing app parameter(s): "\
|
71
|
-
"#{missing_keys.map(&:to_s).join(', ')}"
|
46
|
+
def extract options, key
|
47
|
+
if !options.is_a?(Hash) || options[key] == nil || options[key] == ''
|
48
|
+
raise MissingParameter, "Missing app parameter '#{key}'"
|
49
|
+
else
|
50
|
+
options[key]
|
72
51
|
end
|
73
52
|
end
|
74
53
|
end
|
data/lib/xploy/cli.rb
CHANGED
@@ -1,16 +1,25 @@
|
|
1
1
|
module Xploy
|
2
2
|
class Cli
|
3
|
-
def initialize api
|
3
|
+
def initialize api, out, template_class
|
4
4
|
@api = api
|
5
5
|
@out = out
|
6
|
+
@template_class = template_class
|
6
7
|
end
|
7
8
|
|
8
9
|
def start
|
9
|
-
|
10
|
-
|
10
|
+
parameter = Xploy.parameter
|
11
|
+
commands = parameter.rest
|
12
|
+
if parameter[:version]
|
11
13
|
@out.puts "xploy #{VERSION}"
|
12
14
|
elsif commands.empty?
|
13
|
-
|
15
|
+
parameter.print_help!
|
16
|
+
elsif commands.first == 'new'
|
17
|
+
template_data = @template_class.new.to_s
|
18
|
+
if path = commands[1]
|
19
|
+
File.open(path, 'w') { |f| f.write template_data }
|
20
|
+
else
|
21
|
+
@out.puts template_data
|
22
|
+
end
|
14
23
|
else
|
15
24
|
@out.puts @api.request(*commands)
|
16
25
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Xploy
|
2
|
+
class Template
|
3
|
+
def to_s
|
4
|
+
File.read(__FILE__).split("__END__\n").last
|
5
|
+
end
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
__END__
|
10
|
+
{
|
11
|
+
"name": "example",
|
12
|
+
"repo": {
|
13
|
+
"url": "git://github.com/threez/appway-example.git",
|
14
|
+
"branch": "master"
|
15
|
+
},
|
16
|
+
"packages": {},
|
17
|
+
"install": [
|
18
|
+
"npm install"
|
19
|
+
]
|
20
|
+
}
|
data/lib/xploy/version.rb
CHANGED
data/spec/lib/xploy/cli_spec.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'xploy/cli'
|
3
|
+
require 'xploy/error'
|
3
4
|
require 'xploy/version'
|
5
|
+
require 'fakefs/safe'
|
4
6
|
|
5
7
|
describe Xploy::Cli do
|
6
8
|
let('parameter') do
|
@@ -9,11 +11,19 @@ describe Xploy::Cli do
|
|
9
11
|
mock.stub('[]').with(:version).and_return(nil)
|
10
12
|
end
|
11
13
|
end
|
12
|
-
let('api') { double('
|
14
|
+
let('api') { double('Xploy::Api') }
|
13
15
|
let('out') { double('stdout').tap { |o| o.stub('puts') } }
|
16
|
+
let('template_class') do
|
17
|
+
double('Xway::Template').tap do |mock|
|
18
|
+
template = double('template').tap do |mock|
|
19
|
+
mock.stub('to_s').and_return('template data...')
|
20
|
+
end
|
21
|
+
mock.stub('new').and_return(template)
|
22
|
+
end
|
23
|
+
end
|
14
24
|
before { Xploy.stub('parameter').and_return(parameter) }
|
15
|
-
subject { described_class.new api, out }
|
16
|
-
|
25
|
+
subject { described_class.new api, out, template_class }
|
26
|
+
|
17
27
|
it 'prints usage per default' do
|
18
28
|
parameter.should_receive('print_help!')
|
19
29
|
subject.start
|
@@ -25,10 +35,30 @@ describe Xploy::Cli do
|
|
25
35
|
subject.start
|
26
36
|
end
|
27
37
|
|
38
|
+
it 'prints template on new without path' do
|
39
|
+
out.should_receive('puts').with('template data...')
|
40
|
+
parameter.stub('rest').and_return(['new'])
|
41
|
+
subject.start
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'writes template on new with path' do
|
45
|
+
FakeFS do
|
46
|
+
parameter.stub('rest').and_return(['new', 'foo.xploy'])
|
47
|
+
subject.start
|
48
|
+
File.read('foo.xploy').should eq('template data...')
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
28
52
|
it 'executes commands on api' do
|
29
53
|
api.should_receive('request').with('list').and_return('list result')
|
30
54
|
out.should_receive('puts').with('list result')
|
31
55
|
parameter.stub('rest').and_return(['list'])
|
32
56
|
subject.start
|
33
57
|
end
|
58
|
+
|
59
|
+
it 'rescues MissingParameter' do
|
60
|
+
parameter.stub('rest') { raise Xploy::MissingParameter, 'foo' }
|
61
|
+
out.should_receive('puts').with('foo')
|
62
|
+
subject.start
|
63
|
+
end
|
34
64
|
end
|
data/spec/lib/xploy_spec.rb
CHANGED
@@ -3,4 +3,18 @@ require 'xploy'
|
|
3
3
|
|
4
4
|
describe Xploy do
|
5
5
|
its('parameter') { should be_kind_of(Xploy::Parameter) }
|
6
|
+
|
7
|
+
describe 'build_cli' do
|
8
|
+
subject { described_class.build_cli }
|
9
|
+
|
10
|
+
it { should be_kind_of(Xploy::Cli) }
|
11
|
+
|
12
|
+
it 'uses Api' do
|
13
|
+
subject.instance_variable_get('@api').should be_kind_of(Xploy::Api)
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'uses STDOUT' do
|
17
|
+
subject.instance_variable_get('@out').should eq STDOUT
|
18
|
+
end
|
19
|
+
end
|
6
20
|
end
|
data/xploy.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xploy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1.beta
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: configliere
|
@@ -155,6 +155,22 @@ dependencies:
|
|
155
155
|
- - ! '>='
|
156
156
|
- !ruby/object:Gem::Version
|
157
157
|
version: '0'
|
158
|
+
- !ruby/object:Gem::Dependency
|
159
|
+
name: fakefs
|
160
|
+
requirement: !ruby/object:Gem::Requirement
|
161
|
+
none: false
|
162
|
+
requirements:
|
163
|
+
- - ! '>='
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
|
+
type: :development
|
167
|
+
prerelease: false
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
none: false
|
170
|
+
requirements:
|
171
|
+
- - ! '>='
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
158
174
|
description: Appway client.
|
159
175
|
email:
|
160
176
|
- mail@jens-bissinger.de
|
@@ -167,6 +183,7 @@ files:
|
|
167
183
|
- .gitignore
|
168
184
|
- .rspec
|
169
185
|
- .travis.yml
|
186
|
+
- CHANGELOG.md
|
170
187
|
- Gemfile
|
171
188
|
- Guardfile
|
172
189
|
- LICENSE.txt
|
@@ -184,11 +201,12 @@ files:
|
|
184
201
|
- lib/xploy/cli.rb
|
185
202
|
- lib/xploy/error.rb
|
186
203
|
- lib/xploy/parameter.rb
|
204
|
+
- lib/xploy/template.rb
|
187
205
|
- lib/xploy/version.rb
|
188
206
|
- spec/assets/appway-example.json
|
189
207
|
- spec/assets/custom.xway
|
208
|
+
- spec/assets/template.json
|
190
209
|
- spec/integration/bin/xploy_binary_spec.rb
|
191
|
-
- spec/integration/lib/xploy/cli_spec.rb
|
192
210
|
- spec/lib/xploy/api/endpoints_spec.rb
|
193
211
|
- spec/lib/xploy/api/http_spec.rb
|
194
212
|
- spec/lib/xploy/api/request/body_spec.rb
|
@@ -197,6 +215,7 @@ files:
|
|
197
215
|
- spec/lib/xploy/cli_spec.rb
|
198
216
|
- spec/lib/xploy/error_spec.rb
|
199
217
|
- spec/lib/xploy/parameter_spec.rb
|
218
|
+
- spec/lib/xploy/template_spec.rb
|
200
219
|
- spec/lib/xploy_spec.rb
|
201
220
|
- spec/spec_helper.rb
|
202
221
|
- xploy.gemspec
|
@@ -227,8 +246,8 @@ summary: Provides the xploy command. See github.com/threez/appway.
|
|
227
246
|
test_files:
|
228
247
|
- spec/assets/appway-example.json
|
229
248
|
- spec/assets/custom.xway
|
249
|
+
- spec/assets/template.json
|
230
250
|
- spec/integration/bin/xploy_binary_spec.rb
|
231
|
-
- spec/integration/lib/xploy/cli_spec.rb
|
232
251
|
- spec/lib/xploy/api/endpoints_spec.rb
|
233
252
|
- spec/lib/xploy/api/http_spec.rb
|
234
253
|
- spec/lib/xploy/api/request/body_spec.rb
|
@@ -237,6 +256,7 @@ test_files:
|
|
237
256
|
- spec/lib/xploy/cli_spec.rb
|
238
257
|
- spec/lib/xploy/error_spec.rb
|
239
258
|
- spec/lib/xploy/parameter_spec.rb
|
259
|
+
- spec/lib/xploy/template_spec.rb
|
240
260
|
- spec/lib/xploy_spec.rb
|
241
261
|
- spec/spec_helper.rb
|
242
262
|
has_rdoc:
|