peas-cli 0.0.2 → 0.1.0
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.
- checksums.yaml +4 -4
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/bin/peas +17 -75
- data/bin/peas-dev +8 -0
- data/lib/peas/api.rb +24 -7
- data/lib/peas/commands/admin.rb +33 -0
- data/lib/peas/commands/app.rb +37 -0
- data/lib/peas/commands/config.rb +35 -0
- data/lib/peas/config.rb +24 -2
- data/lib/peas/git.rb +1 -1
- data/lib/peas.rb +5 -4
- data/peas-cli.gemspec +9 -5
- data/spec/cli_spec.rb +39 -7
- data/spec/spec_helper.rb +13 -1
- metadata +19 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1563acd00068fb352671fc5d5116dda66d42fb15
|
4
|
+
data.tar.gz: e8f6d84f6a545e3d0d6e2b8fd5f8a38a48c44b73
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0fcdcb620bef4ab17b0852c73e17fb464f5b06ccd65a9e2846312febe1fa88fc1f98a340329aa52a13ad820511e3f9dd7189641ecf4abd800bf132a9f757e9b
|
7
|
+
data.tar.gz: f0ec4fdaf8822a33d3dd7cd3c7c4e5467030818b98d93ef18c6bfd6edcd599cfd35a2d6fd3d7f4f3a345d287b15621563eaf643797007829cf459540cb1e05c8
|
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
0.1.0
|
data/bin/peas
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'gli'
|
3
|
-
|
3
|
+
|
4
|
+
root_path = File.join(File.dirname(__FILE__), "../")
|
5
|
+
$LOAD_PATH.unshift(root_path)
|
6
|
+
require 'lib/peas'
|
4
7
|
|
5
8
|
@api = API.new
|
6
9
|
|
@@ -11,78 +14,8 @@ program_desc 'CLI client for Peas'
|
|
11
14
|
|
12
15
|
version Peas::VERSION
|
13
16
|
|
14
|
-
|
15
|
-
|
16
|
-
c.action do |global_options, options, args|
|
17
|
-
@api.request :post, :create, {
|
18
|
-
first_sha: Git.first_sha,
|
19
|
-
remote: Git.remote
|
20
|
-
}
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
desc 'Deploy an app'
|
25
|
-
command :deploy do |c|
|
26
|
-
c.action do |global_options, options, args|
|
27
|
-
@api.request :get, :deploy, {first_sha: Git.first_sha}
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
desc 'Scale an app'
|
32
|
-
long_desc <<-EOF
|
33
|
-
For example: peas scale web=3 worker=2
|
34
|
-
EOF
|
35
|
-
command :scale do |c|
|
36
|
-
c.action do |global_options, options, args|
|
37
|
-
if args.length == 0
|
38
|
-
exit_now! "Please provide scaling arguments in the form: web=3 worker=2"
|
39
|
-
end
|
40
|
-
scaling_hash = {}
|
41
|
-
args.each do |arg|
|
42
|
-
parts = arg.split('=')
|
43
|
-
process_type = parts[0]
|
44
|
-
quantity = parts[1]
|
45
|
-
scaling_hash[process_type] = quantity
|
46
|
-
end
|
47
|
-
@api.request :put, :scale, {
|
48
|
-
first_sha: Git.first_sha,
|
49
|
-
scaling_hash: scaling_hash.to_json
|
50
|
-
}
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
desc 'Set Peas global settings'
|
55
|
-
command :settings do |c|
|
56
|
-
c.flag 'domain',
|
57
|
-
type: String,
|
58
|
-
desc: 'The FQDN for the Peas server'
|
59
|
-
c.action do |global_options, options, args|
|
60
|
-
if options['domain']
|
61
|
-
if !options['domain'].start_with? 'http://'
|
62
|
-
options['domain'] = "http://#{options['domain']}"
|
63
|
-
end
|
64
|
-
end
|
65
|
-
# Gli seems to provide a String and Symbol key for every option, so the options hash needs
|
66
|
-
# de-duplicating
|
67
|
-
deduped = {}
|
68
|
-
options.each do |k, v|
|
69
|
-
deduped[k] = v if k.is_a? String
|
70
|
-
end
|
71
|
-
# Merge existing settings with current settings
|
72
|
-
content = Peas.config.merge(deduped).to_json
|
73
|
-
File.open(Peas.config_file, 'w+'){|f| f.write(content) }
|
74
|
-
# Save the settings on the server as well
|
75
|
-
@api.request :put, :settings, options
|
76
|
-
puts "New settings:"
|
77
|
-
puts JSON.pretty_generate(Peas.config)
|
78
|
-
end
|
79
|
-
desc 'Display the current settings'
|
80
|
-
c.command :display do |c|
|
81
|
-
c.action do |global_options, options, args|
|
82
|
-
puts JSON.pretty_generate(Peas.config)
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
17
|
+
# Load all the commands
|
18
|
+
Dir["#{root_path}/lib/peas/commands/**/*.rb"].each { |f| load f }
|
86
19
|
|
87
20
|
pre do |global, command, options, args|
|
88
21
|
# Pre logic here
|
@@ -100,8 +33,17 @@ post do |global, command, options, args|
|
|
100
33
|
end
|
101
34
|
|
102
35
|
on_error do |exception|
|
103
|
-
#
|
104
|
-
|
36
|
+
# Show a custom error message with backtrace if it's not a GLI error
|
37
|
+
if exception.class.to_s.split('::').first != 'GLI'
|
38
|
+
if exception.class == Errno::ECONNREFUSED
|
39
|
+
Peas.error_message "Couldn't connect to the Peas API. The current endpoint is '#{Peas.config['domain']}', make " +
|
40
|
+
"sure it is up and accessible."
|
41
|
+
else
|
42
|
+
Peas.error_message "Unexpected error: #{exception.class}"
|
43
|
+
Peas.error_message "#{exception.message} @ #{exception.backtrace.last}"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
# GLI needs this to do its default error reporting things
|
105
47
|
true
|
106
48
|
end
|
107
49
|
|
data/bin/peas-dev
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
# This script lets you use the development version of the Peas CLI rather than the Rubygems version
|
3
|
+
# installed via `gem install peas-cli`.
|
4
|
+
# Install by symlinking this file into your executbales path, eg;
|
5
|
+
# `sudo ln -s $(pwd)/peas-dev /usr/local/bin/peas-dev'
|
6
|
+
set -e
|
7
|
+
PEAS_ROOT="$(dirname "$(test -L "$0" && readlink "$0" || echo "$0")")/../.."
|
8
|
+
BUNDLE_GEMFILE=$PEAS_ROOT/cli/Gemfile GLI_DEBUG=true bundle exec $PEAS_ROOT/cli/bin/peas $@
|
data/lib/peas/api.rb
CHANGED
@@ -8,12 +8,12 @@ class API
|
|
8
8
|
|
9
9
|
# This allows base_uri to be dynamically set. Useful for testing
|
10
10
|
def initialize
|
11
|
-
self.class.base_uri Peas.
|
11
|
+
self.class.base_uri Peas.api_domain
|
12
12
|
end
|
13
13
|
|
14
14
|
# Generic wrapper to the Peas API
|
15
|
-
def request verb, method, params
|
16
|
-
response = self.class.send(verb, "
|
15
|
+
def request verb, method, params = nil
|
16
|
+
response = self.class.send(verb, "#{method}", {query: params}).body
|
17
17
|
if response
|
18
18
|
json = JSON.parse(response)
|
19
19
|
else
|
@@ -26,7 +26,24 @@ class API
|
|
26
26
|
# Long-running jobs need to poll a job status endpoint
|
27
27
|
long_running_output json['job']
|
28
28
|
else
|
29
|
-
#
|
29
|
+
# Check CLI client is up to date.
|
30
|
+
# Only check major and minor versions
|
31
|
+
version_mismatch = false
|
32
|
+
api_version = json['version'].split('.')
|
33
|
+
client_version = Peas::VERSION.split('.')
|
34
|
+
if api_version[0] != client_version[0]
|
35
|
+
version_mismatch = true
|
36
|
+
else
|
37
|
+
if api_version[1] != client_version[1]
|
38
|
+
version_mismatch = true
|
39
|
+
end
|
40
|
+
end
|
41
|
+
if version_mismatch
|
42
|
+
Peas.warning_message "Your version of the CLI client is out of date " +
|
43
|
+
"(Client: #{Peas::VERSION}, API: #{json['version']}). " +
|
44
|
+
"Please update using `gem install peas-cli`."
|
45
|
+
end
|
46
|
+
# Normal API response
|
30
47
|
puts json['message']
|
31
48
|
end
|
32
49
|
end
|
@@ -61,9 +78,9 @@ class API
|
|
61
78
|
# the 'total' output on every long-polled request. We just want to output any *new* log lines.
|
62
79
|
def output_diff log_so_far
|
63
80
|
@accumulated_output ||= ''
|
64
|
-
old_count = @accumulated_output.lines.
|
65
|
-
new_count = log_so_far.lines.
|
66
|
-
diff = log_so_far.lines[old_count..new_count]
|
81
|
+
old_count = @accumulated_output.lines.count
|
82
|
+
new_count = log_so_far.lines.count
|
83
|
+
diff = log_so_far.lines.to_a[old_count..new_count]
|
67
84
|
@accumulated_output = log_so_far
|
68
85
|
puts diff.join if diff.length > 0
|
69
86
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
desc 'Set Peas global settings'
|
2
|
+
command :settings do |c|
|
3
|
+
c.flag 'domain',
|
4
|
+
type: String,
|
5
|
+
desc: 'The FQDN for the Peas server'
|
6
|
+
c.action do |global_options, options, args|
|
7
|
+
if options['domain']
|
8
|
+
if !options['domain'].start_with? 'http://'
|
9
|
+
options['domain'] = "http://#{options['domain']}"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
# Gli seems to provide a String and Symbol key for every option, so the options hash needs
|
13
|
+
# de-duplicating
|
14
|
+
deduped = {}
|
15
|
+
options.each do |k, v|
|
16
|
+
deduped[k] = v if k.is_a? String
|
17
|
+
end
|
18
|
+
# Merge existing settings with current settings
|
19
|
+
content = Peas.config.merge(deduped).to_json
|
20
|
+
File.open(Peas.config_file, 'w+'){|f| f.write(content) }
|
21
|
+
# Save the settings on the server as well
|
22
|
+
@api = API.new # Refresh settings from file
|
23
|
+
@api.request :put, '/admin/settings', options
|
24
|
+
puts "New settings:"
|
25
|
+
puts JSON.pretty_generate(Peas.config)
|
26
|
+
end
|
27
|
+
desc 'Display the current settings'
|
28
|
+
c.command :display do |c|
|
29
|
+
c.action do |global_options, options, args|
|
30
|
+
puts JSON.pretty_generate(Peas.config)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
desc 'Create an app'
|
2
|
+
command :create do |c|
|
3
|
+
c.action do |global_options, options, args|
|
4
|
+
@api.request :post, "/app/#{Git.first_sha}", {
|
5
|
+
remote: Git.remote
|
6
|
+
}
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
desc 'Deploy an app'
|
11
|
+
command :deploy do |c|
|
12
|
+
c.action do |global_options, options, args|
|
13
|
+
@api.request :get, "/app/#{Git.first_sha}/deploy"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
desc 'Scale an app'
|
18
|
+
long_desc <<-EOF
|
19
|
+
For example: peas scale web=3 worker=2
|
20
|
+
EOF
|
21
|
+
command :scale do |c|
|
22
|
+
c.action do |global_options, options, args|
|
23
|
+
if args.length == 0
|
24
|
+
exit_now! "Please provide scaling arguments in the form: web=3 worker=2"
|
25
|
+
end
|
26
|
+
scaling_hash = {}
|
27
|
+
args.each do |arg|
|
28
|
+
parts = arg.split('=', 2)
|
29
|
+
process_type = parts[0]
|
30
|
+
quantity = parts[1]
|
31
|
+
scaling_hash[process_type] = quantity
|
32
|
+
end
|
33
|
+
@api.request :put, "/app/#{Git.first_sha}/scale", {
|
34
|
+
scaling_hash: scaling_hash.to_json
|
35
|
+
}
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
desc 'Add, remove and list config for an app'
|
2
|
+
command :config do |c|
|
3
|
+
c.default_desc 'List all config'
|
4
|
+
c.action do |global_options, options, args|
|
5
|
+
@api.request :get, "/app/#{Git.first_sha}/config"
|
6
|
+
end
|
7
|
+
|
8
|
+
c.desc 'Delete config by keys'
|
9
|
+
c.command :rm do |sc|
|
10
|
+
sc.action do |global_options, options, args|
|
11
|
+
@api.request :delete, "/app/#{Git.first_sha}/config", {
|
12
|
+
keys: args.to_json
|
13
|
+
}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
c.desc 'Set config for an app'
|
18
|
+
c.command :set do |sc|
|
19
|
+
sc.action do |global_options, options, args|
|
20
|
+
if args.length == 0
|
21
|
+
exit_now! "Please provide config in the form: FOO=BAR ENV=production"
|
22
|
+
end
|
23
|
+
vars = {}
|
24
|
+
args.each do |arg|
|
25
|
+
parts = arg.split('=', 2)
|
26
|
+
key = parts[0]
|
27
|
+
value = parts[1]
|
28
|
+
vars[key] = value
|
29
|
+
end
|
30
|
+
@api.request :put, "/app/#{Git.first_sha}/config", {
|
31
|
+
vars: vars.to_json
|
32
|
+
}
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/peas/config.rb
CHANGED
@@ -1,4 +1,10 @@
|
|
1
1
|
module Peas
|
2
|
+
|
3
|
+
def self.config_file
|
4
|
+
"#{ENV['HOME']}/.peas"
|
5
|
+
end
|
6
|
+
|
7
|
+
# Read JSON config from file
|
2
8
|
def self.config
|
3
9
|
file = File.open config_file, "a+"
|
4
10
|
contents = file.read
|
@@ -6,7 +12,23 @@ module Peas
|
|
6
12
|
JSON.parse contents
|
7
13
|
end
|
8
14
|
|
9
|
-
|
10
|
-
|
15
|
+
# Hierarchy of sources for the Peas API domain
|
16
|
+
def self.api_domain
|
17
|
+
if ENV['PEAS_API_ENDPOINT']
|
18
|
+
ENV['PEAS_API_ENDPOINT']
|
19
|
+
elsif Peas.config['domain']
|
20
|
+
Peas.config['domain']
|
21
|
+
else
|
22
|
+
'localhost:4000'
|
23
|
+
end
|
11
24
|
end
|
25
|
+
|
26
|
+
def self.error_message string
|
27
|
+
puts string.color(:red)
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.warning_message string
|
31
|
+
puts string.color(:magenta)
|
32
|
+
end
|
33
|
+
|
12
34
|
end
|
data/lib/peas/git.rb
CHANGED
data/lib/peas.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "../lib"))
|
1
2
|
require 'json'
|
2
|
-
require 'peas/version
|
3
|
-
require 'peas/config
|
4
|
-
require 'peas/git
|
5
|
-
require 'peas/api
|
3
|
+
require 'peas/version'
|
4
|
+
require 'peas/config'
|
5
|
+
require 'peas/git'
|
6
|
+
require 'peas/api'
|
6
7
|
require 'rainbow'
|
7
8
|
require 'rainbow/ext/string'
|
8
9
|
|
data/peas-cli.gemspec
CHANGED
@@ -2,17 +2,19 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
+
# stub: peas-cli 0.1.0 ruby lib
|
5
6
|
|
6
7
|
Gem::Specification.new do |s|
|
7
8
|
s.name = "peas-cli"
|
8
|
-
s.version = "0.0
|
9
|
+
s.version = "0.1.0"
|
9
10
|
|
10
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
+
s.require_paths = ["lib"]
|
11
13
|
s.authors = ["Tom Buckley-Houston"]
|
12
|
-
s.date = "2014-
|
14
|
+
s.date = "2014-05-30"
|
13
15
|
s.description = "Peas is an open source Heroku-style PaaS written in Ruby and using Docker"
|
14
16
|
s.email = "tom@tombh.co.uk"
|
15
|
-
s.executables = ["peas"]
|
17
|
+
s.executables = ["peas", "peas-dev"]
|
16
18
|
s.extra_rdoc_files = [
|
17
19
|
"README.md"
|
18
20
|
]
|
@@ -26,6 +28,9 @@ Gem::Specification.new do |s|
|
|
26
28
|
"bin/peas",
|
27
29
|
"lib/peas.rb",
|
28
30
|
"lib/peas/api.rb",
|
31
|
+
"lib/peas/commands/admin.rb",
|
32
|
+
"lib/peas/commands/app.rb",
|
33
|
+
"lib/peas/commands/config.rb",
|
29
34
|
"lib/peas/config.rb",
|
30
35
|
"lib/peas/git.rb",
|
31
36
|
"lib/peas/version.rb",
|
@@ -35,8 +40,7 @@ Gem::Specification.new do |s|
|
|
35
40
|
]
|
36
41
|
s.homepage = "http://github.com/tombh/peas"
|
37
42
|
s.licenses = ["GPL v2"]
|
38
|
-
s.
|
39
|
-
s.rubygems_version = "2.0.14"
|
43
|
+
s.rubygems_version = "2.2.2"
|
40
44
|
s.summary = "CLI client for Peas"
|
41
45
|
|
42
46
|
if s.respond_to? :specification_version then
|
data/spec/cli_spec.rb
CHANGED
@@ -7,29 +7,31 @@ describe 'Peas CLI' do
|
|
7
7
|
Git.stub(:first_sha).and_return('fakesha')
|
8
8
|
API.any_instance.stub(:sleep).and_return(nil)
|
9
9
|
Peas.stub(:config_file).and_return('/tmp/.peas')
|
10
|
+
File.delete '/tmp/.peas' if File.exists? '/tmp/.peas'
|
10
11
|
end
|
11
12
|
|
12
13
|
describe 'Settings' do
|
13
14
|
it 'should set settings' do
|
14
|
-
|
15
|
-
|
15
|
+
stub_request(:put, 'http://new-domain.com:4000/admin/settings?domain=new-domain.com:4000')
|
16
|
+
.to_return(body: response_mock(nil))
|
16
17
|
output = cli %w(settings --domain=new-domain.com:4000)
|
17
18
|
expect(output).to eq "\nNew settings:\n{\n \"domain\": \"http://new-domain.com:4000\"\n}\n"
|
18
19
|
config = JSON.parse File.open('/tmp/.peas').read
|
19
|
-
expect(config).to eq
|
20
|
+
expect(config).to eq({"domain"=>"http://new-domain.com:4000"})
|
20
21
|
end
|
21
22
|
|
22
23
|
it 'should use the domain setting' do
|
23
24
|
File.open('/tmp/.peas', 'w'){|f| f.write('{"domain":"test.com"}') }
|
24
25
|
stub_request(:get, /test.com/)
|
26
|
+
.to_return(body: response_mock(nil))
|
25
27
|
cli %w(deploy)
|
26
28
|
end
|
27
29
|
end
|
28
30
|
|
29
|
-
describe '
|
31
|
+
describe 'App methods' do
|
30
32
|
it 'should create an app' do
|
31
|
-
stub_request(:post, /
|
32
|
-
.to_return(body:
|
33
|
+
stub_request(:post, TEST_DOMAIN + '/app/fakesha?remote=git@github.com:test/test.git')
|
34
|
+
.to_return(body: response_mock("App 'test' successfully created"))
|
33
35
|
output = cli ['create']
|
34
36
|
expect(output).to eq "App 'test' successfully created\n"
|
35
37
|
end
|
@@ -46,7 +48,7 @@ describe 'Peas CLI' do
|
|
46
48
|
it 'should scale an app' do
|
47
49
|
stub_request(
|
48
50
|
:put,
|
49
|
-
/scale
|
51
|
+
TEST_DOMAIN + '/app/fakesha/scale?scaling_hash=%7B%22web%22:%223%22,%22worker%22:%222%22%7D'
|
50
52
|
).to_return(body: '{"job": "123"}')
|
51
53
|
stub_request(:get, /status/).to_return(
|
52
54
|
{body: '{"status": "working", "output": "scaling\n"}'}
|
@@ -54,6 +56,29 @@ describe 'Peas CLI' do
|
|
54
56
|
output = cli %w(scale web=3 worker=2)
|
55
57
|
expect(output).to eq "scaling\n"
|
56
58
|
end
|
59
|
+
|
60
|
+
describe 'Config' do
|
61
|
+
it 'should set config for an app' do
|
62
|
+
stub_request(:put, TEST_DOMAIN + '/app/fakesha/config?vars=%7B%22FOO%22:%22BAR%22%7D')
|
63
|
+
.to_return(body: response_mock("{'FOO' => 'BAR'}"))
|
64
|
+
output = cli %w(config set FOO=BAR)
|
65
|
+
expect(output).to eq "{'FOO' => 'BAR'}\n"
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'delete config for an app' do
|
69
|
+
stub_request(:delete, TEST_DOMAIN + '/app/fakesha/config?keys=%5B%22FOO%22%5D')
|
70
|
+
.to_return(body: response_mock(nil))
|
71
|
+
output = cli %w(config rm FOO)
|
72
|
+
expect(output).to eq "\n"
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'should list all config for an app' do
|
76
|
+
stub_request(:get, TEST_DOMAIN + '/app/fakesha/config')
|
77
|
+
.to_return(body: response_mock("{'FOO' => 'BAR'}\n{'MOO' => 'CAR'}"))
|
78
|
+
output = cli %w(config)
|
79
|
+
expect(output).to eq "{'FOO' => 'BAR'}\n{'MOO' => 'CAR'}\n"
|
80
|
+
end
|
81
|
+
end
|
57
82
|
end
|
58
83
|
|
59
84
|
it 'should retrieve and output a long-running command' do
|
@@ -67,4 +92,11 @@ describe 'Peas CLI' do
|
|
67
92
|
output = cli ['deploy']
|
68
93
|
expect(output).to eq "doing\nsomething\ndone\n"
|
69
94
|
end
|
95
|
+
|
96
|
+
it 'should show a warning when there is a version mismatch' do
|
97
|
+
stub_request(:get, TEST_DOMAIN + '/app/fakesha/config')
|
98
|
+
.to_return(body: '{"version": "100000.1000000.100000"}')
|
99
|
+
output = cli %w(config)
|
100
|
+
expect(output).to include 'Your version of the CLI client is out of date'
|
101
|
+
end
|
70
102
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'stringio'
|
3
3
|
require 'webmock/rspec'
|
4
|
-
|
4
|
+
|
5
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "../"))
|
6
|
+
require 'lib/peas'
|
5
7
|
|
6
8
|
ENV['GLI_ENV'] = 'test'
|
7
9
|
ROOT = File.join(File.expand_path(File.dirname(__FILE__)), '..')
|
8
10
|
$LOAD_PATH.unshift(File.join(ROOT, 'lib'))
|
11
|
+
TEST_DOMAIN = 'http://localhost:4000'
|
9
12
|
|
10
13
|
RSpec.configure do |config|
|
11
14
|
config.mock_with :rspec
|
@@ -22,6 +25,15 @@ ensure
|
|
22
25
|
$stdout = old
|
23
26
|
end
|
24
27
|
|
28
|
+
# Form a response as the API would. Useful as you only need to provide a string without any JSON
|
29
|
+
# formatting
|
30
|
+
def response_mock response, key=:message
|
31
|
+
{
|
32
|
+
'version' => Peas::VERSION,
|
33
|
+
key => response
|
34
|
+
}.to_json
|
35
|
+
end
|
36
|
+
|
25
37
|
# Clever little function to simulate CLI requests.
|
26
38
|
# Usage: cli(['create', '--flag', '--switch']).
|
27
39
|
# Output is suppressed, captured and returned.
|
metadata
CHANGED
@@ -1,88 +1,93 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: peas-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Buckley-Houston
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gli
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: httparty
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rainbow
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: jeweler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
description: Peas is an open source Heroku-style PaaS written in Ruby and using Docker
|
70
70
|
email: tom@tombh.co.uk
|
71
71
|
executables:
|
72
72
|
- peas
|
73
|
+
- peas-dev
|
73
74
|
extensions: []
|
74
75
|
extra_rdoc_files:
|
75
76
|
- README.md
|
76
77
|
files:
|
77
|
-
- .rspec
|
78
|
+
- ".rspec"
|
78
79
|
- Gemfile
|
79
80
|
- Gemfile.lock
|
80
81
|
- README.md
|
81
82
|
- Rakefile
|
82
83
|
- VERSION
|
83
84
|
- bin/peas
|
85
|
+
- bin/peas-dev
|
84
86
|
- lib/peas.rb
|
85
87
|
- lib/peas/api.rb
|
88
|
+
- lib/peas/commands/admin.rb
|
89
|
+
- lib/peas/commands/app.rb
|
90
|
+
- lib/peas/commands/config.rb
|
86
91
|
- lib/peas/config.rb
|
87
92
|
- lib/peas/git.rb
|
88
93
|
- lib/peas/version.rb
|
@@ -99,17 +104,17 @@ require_paths:
|
|
99
104
|
- lib
|
100
105
|
required_ruby_version: !ruby/object:Gem::Requirement
|
101
106
|
requirements:
|
102
|
-
- -
|
107
|
+
- - ">="
|
103
108
|
- !ruby/object:Gem::Version
|
104
109
|
version: '0'
|
105
110
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
111
|
requirements:
|
107
|
-
- -
|
112
|
+
- - ">="
|
108
113
|
- !ruby/object:Gem::Version
|
109
114
|
version: '0'
|
110
115
|
requirements: []
|
111
116
|
rubyforge_project:
|
112
|
-
rubygems_version: 2.
|
117
|
+
rubygems_version: 2.2.2
|
113
118
|
signing_key:
|
114
119
|
specification_version: 4
|
115
120
|
summary: CLI client for Peas
|