pagoda 0.3.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.DS_Store +0 -0
- data/Gemfile +3 -3
- data/Gemfile.lock +33 -24
- data/README.md +68 -0
- data/Rakefile +4 -7
- data/bin/pagoda +100 -8
- data/lib/pagoda/cli/commands/clone.rb +13 -0
- data/lib/pagoda/cli/commands/create.rb +13 -0
- data/lib/pagoda/cli/commands/deploy.rb +12 -0
- data/lib/pagoda/cli/commands/destroy.rb +16 -0
- data/lib/pagoda/cli/commands/info.rb +13 -0
- data/lib/pagoda/cli/commands/init.rb +13 -0
- data/lib/pagoda/cli/commands/list.rb +20 -0
- data/lib/pagoda/cli/commands/rename.rb +17 -0
- data/lib/pagoda/cli/commands/rollback.rb +12 -0
- data/lib/pagoda/cli/commands/ssh_key.rb +27 -0
- data/lib/pagoda/cli/commands/tunnel.rb +18 -0
- data/lib/pagoda/cli/commands.rb +11 -0
- data/lib/pagoda/{helpers.rb → cli/core_ext.rb} +10 -118
- data/lib/pagoda/cli/helpers/app.rb +143 -0
- data/lib/pagoda/cli/helpers/base.rb +199 -0
- data/lib/pagoda/cli/helpers/key.rb +69 -0
- data/lib/pagoda/cli/helpers/tunnel.rb +36 -0
- data/lib/pagoda/cli/helpers.rb +127 -0
- data/lib/pagoda/cli/override.rb +23 -0
- data/lib/pagoda/cli/version.rb +5 -0
- data/lib/pagoda/cli.rb +11 -0
- data/lib/pagoda-cli.rb +1 -0
- data/pagoda.gemspec +20 -24
- data/pagoda.rdoc +139 -0
- data/pkg/newpagoda-0.1.10.gem +0 -0
- data/pkg/newpagoda-0.1.11.gem +0 -0
- data/pkg/newpagoda-0.1.12.gem +0 -0
- data/pkg/newpagoda-0.1.13.gem +0 -0
- data/pkg/newpagoda-0.1.15.gem +0 -0
- data/pkg/newpagoda-0.1.4.gem +0 -0
- data/pkg/newpagoda-0.1.6.gem +0 -0
- data/pkg/newpagoda-0.1.7.gem +0 -0
- data/pkg/newpagoda-0.1.8.gem +0 -0
- data/pkg/newpagoda-0.1.9.gem +0 -0
- data/pkg/newpagoda-0.5.0.gem +0 -0
- data/spec/lib/helper_spec.rb +32 -0
- data/spec/lib/helpers/app_spec.rb +104 -0
- data/spec/lib/helpers/base_spec.rb +27 -0
- data/spec/lib/helpers/key_spec.rb +42 -0
- data/spec/lib/helpers/tunnel_spec.rb +30 -0
- data/spec/spec_helper.rb +17 -0
- metadata +74 -50
- data/.bundle/config +0 -1
- data/README +0 -3
- data/lib/pagoda/client.rb +0 -225
- data/lib/pagoda/command.rb +0 -96
- data/lib/pagoda/commands/app.rb +0 -247
- data/lib/pagoda/commands/auth.rb +0 -149
- data/lib/pagoda/commands/base.rb +0 -184
- data/lib/pagoda/commands/db.rb +0 -18
- data/lib/pagoda/commands/help.rb +0 -100
- data/lib/pagoda/commands/tunnel.rb +0 -49
- data/lib/pagoda/tunnel_proxy.rb +0 -130
- data/lib/pagoda/version.rb +0 -3
- data/lib/pagoda.rb +0 -3
- data/spec/base.rb +0 -21
- data/spec/client_spec.rb +0 -255
- data/spec/command_spec.rb +0 -26
- data/spec/commands/auth_spec.rb +0 -57
data/.DS_Store
ADDED
Binary file
|
data/Gemfile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
source
|
1
|
+
source 'http://rubygems.org'
|
2
2
|
|
3
|
-
# Specify your gem's dependencies in pagoda.gemspec
|
4
|
-
gemspec
|
3
|
+
# Specify your gem's dependencies in pagoda-cli.gemspec
|
4
|
+
gemspec
|
data/Gemfile.lock
CHANGED
@@ -1,41 +1,50 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
pagoda (0.
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
rest-client
|
4
|
+
pagoda (0.1.15)
|
5
|
+
gli
|
6
|
+
pagoda-client
|
7
|
+
pagoda-tunnel
|
9
8
|
|
10
9
|
GEM
|
11
10
|
remote: http://rubygems.org/
|
12
11
|
specs:
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
mime-types (1.
|
12
|
+
coderay (0.9.8)
|
13
|
+
diff-lcs (1.1.3)
|
14
|
+
gli (1.3.5)
|
15
|
+
json_pure (1.6.1)
|
16
|
+
method_source (0.6.7)
|
17
|
+
ruby_parser (>= 2.3.1)
|
18
|
+
mime-types (1.17.2)
|
19
|
+
pagoda-client (0.1.2)
|
20
|
+
json_pure
|
21
|
+
rest-client
|
22
|
+
pagoda-tunnel (0.1.2)
|
23
|
+
rest-client
|
24
|
+
pry (0.9.7.3)
|
25
|
+
coderay (~> 0.9.8)
|
26
|
+
method_source (~> 0.6.7)
|
27
|
+
ruby_parser (>= 2.3.1)
|
28
|
+
slop (~> 2.1.0)
|
20
29
|
rest-client (1.6.7)
|
21
30
|
mime-types (>= 1.16)
|
22
|
-
rspec (2.
|
23
|
-
rspec-core (~> 2.
|
24
|
-
rspec-expectations (~> 2.
|
25
|
-
rspec-mocks (~> 2.
|
26
|
-
rspec-core (2.
|
27
|
-
rspec-expectations (2.
|
31
|
+
rspec (2.7.0)
|
32
|
+
rspec-core (~> 2.7.0)
|
33
|
+
rspec-expectations (~> 2.7.0)
|
34
|
+
rspec-mocks (~> 2.7.0)
|
35
|
+
rspec-core (2.7.1)
|
36
|
+
rspec-expectations (2.7.0)
|
28
37
|
diff-lcs (~> 1.1.2)
|
29
|
-
rspec-mocks (2.
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
38
|
+
rspec-mocks (2.7.0)
|
39
|
+
ruby_parser (2.3.1)
|
40
|
+
sexp_processor (~> 3.0)
|
41
|
+
sexp_processor (3.0.7)
|
42
|
+
slop (2.1.0)
|
34
43
|
|
35
44
|
PLATFORMS
|
36
45
|
ruby
|
37
46
|
|
38
47
|
DEPENDENCIES
|
39
48
|
pagoda!
|
49
|
+
pry
|
40
50
|
rspec
|
41
|
-
webmock
|
data/README.md
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
# Pagoda Box Command Line Interface
|
2
|
+
|
3
|
+
Thank you for choosing pagodabox [Pagoda Box](http://www.pagodabox.com).
|
4
|
+
|
5
|
+
## Features
|
6
|
+
|
7
|
+
This client currently supports:
|
8
|
+
|
9
|
+
* Application functions
|
10
|
+
* Creation
|
11
|
+
* Clone
|
12
|
+
* init
|
13
|
+
* Deploy
|
14
|
+
* Rollback
|
15
|
+
* Tunnel to live database
|
16
|
+
|
17
|
+
## How to use:
|
18
|
+
|
19
|
+
Using the command line interface can be fun!
|
20
|
+
|
21
|
+
$ gem install pagoda
|
22
|
+
|
23
|
+
Fetching: pagoda-0.3.2.gem (100%)
|
24
|
+
Successfully installed pagoda-0.3.2
|
25
|
+
1 gem installed
|
26
|
+
Installing ri documentation for pagoda-0.3.2...
|
27
|
+
Installing RDoc documentation for pagoda-0.3.2...
|
28
|
+
|
29
|
+
$ pagoda launch workflowdemo
|
30
|
+
|
31
|
+
+> Registering workflowdemo
|
32
|
+
+> Launching........
|
33
|
+
+> workflowdemo launched
|
34
|
+
|
35
|
+
+> deploying to match current branch and commit.....
|
36
|
+
+> deployed
|
37
|
+
|
38
|
+
-----------------------------------------------
|
39
|
+
|
40
|
+
LIVE URL : http://workflowdemo.pagodabox.com
|
41
|
+
ADMIN PANEL : http://dashboard.pagodabox.com
|
42
|
+
|
43
|
+
-----------------------------------------------
|
44
|
+
|
45
|
+
|
46
|
+
## Get Started
|
47
|
+
|
48
|
+
### Install Pagoda
|
49
|
+
|
50
|
+
Install ruby and the gem thing. then do "gem install pagoda"
|
51
|
+
|
52
|
+
### Navigate
|
53
|
+
|
54
|
+
Navigate into the folder of your repo
|
55
|
+
|
56
|
+
$ cd /path/to/repo
|
57
|
+
|
58
|
+
### Launch your app
|
59
|
+
|
60
|
+
Select a app name and launch it
|
61
|
+
|
62
|
+
$ pagoda launch <appname>
|
63
|
+
|
64
|
+
|
65
|
+
## More Information
|
66
|
+
|
67
|
+
More information can be found in our [Guides](http://guides.pagodabox.com/getting-started/pagoda-terminal-client)
|
68
|
+
|
data/Rakefile
CHANGED
@@ -1,11 +1,8 @@
|
|
1
|
-
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
require "bundler/gem_tasks"
|
2
3
|
require "rspec/core/rake_task"
|
3
4
|
|
4
|
-
Bundler::GemHelper.install_tasks
|
5
|
-
|
6
5
|
desc "Run all specs"
|
7
6
|
RSpec::Core::RakeTask.new('spec') do |t|
|
8
|
-
t.rspec_opts = ['--colour --format
|
9
|
-
end
|
10
|
-
|
11
|
-
task :default => :spec
|
7
|
+
t.rspec_opts = ['--colour --format documentation']
|
8
|
+
end
|
data/bin/pagoda
CHANGED
@@ -1,13 +1,105 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
require 'rubygems'
|
4
|
+
require 'rest_client'
|
5
|
+
require 'gli'
|
5
6
|
|
6
|
-
require 'pagoda/
|
7
|
-
require 'pagoda/
|
7
|
+
require 'pagoda/cli/version'
|
8
|
+
require 'pagoda/cli/override'
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
10
|
+
# command = ARGV.shift.strip rescue 'help'
|
11
|
+
include GLI
|
12
|
+
config_file '.pagodarc'
|
12
13
|
|
13
|
-
|
14
|
+
program_desc 'Command line client for Pagoda Box'
|
15
|
+
|
16
|
+
version Pagoda::CLI::VERSION
|
17
|
+
|
18
|
+
desc "Username created on pagoda Box"
|
19
|
+
arg_name "Username"
|
20
|
+
flag [:u, :username]
|
21
|
+
|
22
|
+
desc "Password to connect to Pagoda Box"
|
23
|
+
arg_name "Password"
|
24
|
+
flag [:p, :password]
|
25
|
+
|
26
|
+
desc 'The app name for Pagoda Box'
|
27
|
+
arg_name 'APP_NAME'
|
28
|
+
flag [:a, :app]
|
29
|
+
|
30
|
+
desc "Help"
|
31
|
+
switch [:h, :help]
|
32
|
+
|
33
|
+
require 'pagoda/cli'
|
34
|
+
|
35
|
+
GLI::DefaultHelpCommand.skips_pre = true
|
36
|
+
|
37
|
+
pre do |global,command,options,args|
|
38
|
+
# Pre logic here
|
39
|
+
# Return true to proceed; false to abourt and not call the
|
40
|
+
# chosen command
|
41
|
+
# Use skips_pre before a command to skip this block
|
42
|
+
# on that command only
|
43
|
+
if global[:help] or options[:help]
|
44
|
+
if command
|
45
|
+
GLI.commands[:help].execute(global, {}, [ command.name ])
|
46
|
+
else
|
47
|
+
GLI.commands[:help].execute(global, {}, [])
|
48
|
+
end
|
49
|
+
false
|
50
|
+
else
|
51
|
+
if command and not global[:username] and not global[:password]
|
52
|
+
puts "it appears this is the first time you have used our client"
|
53
|
+
user, password = Pagoda::Command::Base.ask_for_credentials
|
54
|
+
GLI.run(["-u",user,'-p',password,'initconfig', '--force'])
|
55
|
+
global.merge!(:username => user, :password => password)
|
56
|
+
end
|
57
|
+
|
58
|
+
true
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
post do |global,command,options,args|
|
63
|
+
# Post logic here
|
64
|
+
# Use skips_post before a command to skip this
|
65
|
+
# block on that command only
|
66
|
+
end
|
67
|
+
|
68
|
+
on_error do |exception|
|
69
|
+
if exception.class == RestClient::Unauthorized
|
70
|
+
Pagoda::Command::Base.error "Username or Password is invald"
|
71
|
+
elsif exception.class == RestClient::ResourceNotFound
|
72
|
+
Pagoda::Command::Base.error "It appears we cant find your 'resource', please try again later"
|
73
|
+
elsif exception.class == RestClient::InternalServerError
|
74
|
+
Pagoda::Command::Base.error "It appears pagodabox is having some trouble, please try again later"
|
75
|
+
elsif exception.class == GLI::UnknownGlobalArgument or exception.class == GLI::UnknownCommandArgument or exception.class == GLI::UnknownCommand
|
76
|
+
Pagoda::Command::Base.error " -- #{exception.message} -- "
|
77
|
+
elsif exception.class == RestClient::UnprocessableEntity
|
78
|
+
errors = []
|
79
|
+
errors << ":: Unable to process your request"
|
80
|
+
body = JSON.load(exception.response.body)
|
81
|
+
body.each do |key, value|
|
82
|
+
value.each do |problem|
|
83
|
+
errors << " +> #{key.gsub(/\_/, "-")} #{problem}"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
Pagoda::Command::Base.error errors
|
87
|
+
elsif exception.class == SystemExit or exception.class == Interrupt
|
88
|
+
else
|
89
|
+
errors = [
|
90
|
+
"The Client has had an unexpected error:",
|
91
|
+
" -- #{exception.message} -- ",
|
92
|
+
exception.backtrace.join("\n"),
|
93
|
+
"Please report this error to support@pagodabox.com so we can fix it.",
|
94
|
+
"Thank you."
|
95
|
+
]
|
96
|
+
Pagoda::Command::Base.error errors
|
97
|
+
end
|
98
|
+
|
99
|
+
# Error logic here
|
100
|
+
# return false to skip default error handling
|
101
|
+
# ENV['GLI_DEBUG'] = 'true'
|
102
|
+
# false
|
103
|
+
end
|
104
|
+
|
105
|
+
exit GLI.run(ARGV)
|
@@ -0,0 +1,13 @@
|
|
1
|
+
desc 'Clone an application from pagodabox'
|
2
|
+
arg_name 'Application Name'
|
3
|
+
command :clone do |c|
|
4
|
+
|
5
|
+
c.desc 'Your application name on pagodabox'
|
6
|
+
c.arg_name 'APP_NAME'
|
7
|
+
c.flag [:a, :app]
|
8
|
+
|
9
|
+
c.action do |global_options,options,args|
|
10
|
+
require 'pagoda/cli/helpers/app'
|
11
|
+
Pagoda::Command::App.new(global_options,options,args).clone
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
desc 'Create a new application on pagodabox'
|
2
|
+
arg_name 'new-application-name'
|
3
|
+
command :create do |c|
|
4
|
+
|
5
|
+
c.desc 'New app name'
|
6
|
+
c.arg_name 'APP_NAME'
|
7
|
+
c.flag [:a, :app]
|
8
|
+
|
9
|
+
c.action do |global_options,options,args|
|
10
|
+
require 'pagoda/cli/helpers/app'
|
11
|
+
Pagoda::Command::App.new(global_options,options,args).create
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
desc 'Deploy your current code branch and commit to your Pagoda Box app'
|
2
|
+
command :deploy do |c|
|
3
|
+
|
4
|
+
c.desc 'Your application name on pagodabox'
|
5
|
+
c.arg_name 'APP_NAME'
|
6
|
+
c.flag [:a, :app]
|
7
|
+
|
8
|
+
c.action do |global_options,options,args|
|
9
|
+
require 'pagoda/cli/helpers/app'
|
10
|
+
Pagoda::Command::App.new(global_options,options,args).deploy
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
desc 'Destroy your application'
|
2
|
+
arg_name 'Describe arguments to destroy here'
|
3
|
+
command :destroy do |c|
|
4
|
+
|
5
|
+
c.desc "Force without confirmation"
|
6
|
+
c.switch [:f, :force]
|
7
|
+
|
8
|
+
c.desc 'New app name'
|
9
|
+
c.arg_name 'APP_NAME'
|
10
|
+
c.flag [:a, :app]
|
11
|
+
|
12
|
+
c.action do |global_options,options,args|
|
13
|
+
require 'pagoda/cli/helpers/app'
|
14
|
+
Pagoda::Command::App.new(global_options,options,args).destroy
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
desc 'Get information for a specific app'
|
2
|
+
arg_name 'Application Name'
|
3
|
+
command :info do |c|
|
4
|
+
|
5
|
+
c.desc 'App on pagodabox'
|
6
|
+
c.arg_name 'APP_NAME'
|
7
|
+
c.flag [:a, :app]
|
8
|
+
|
9
|
+
c.action do |global_options,options,args|
|
10
|
+
require 'pagoda/cli/helpers/app'
|
11
|
+
::Pagoda::Command::App.new(global_options,options,args).info
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
desc 'Connect your local repo with your pagodabox repo.'
|
2
|
+
arg_name 'APP_NAME'
|
3
|
+
command :init do |c|
|
4
|
+
|
5
|
+
c.desc 'App name initializing to'
|
6
|
+
c.arg_name 'APP_NAME'
|
7
|
+
c.flag [:a, :app]
|
8
|
+
|
9
|
+
c.action do |global_options,options,args|
|
10
|
+
require 'pagoda/cli/helpers/app'
|
11
|
+
Pagoda::Command::App.new(global_options,options,args).init
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
desc 'List information on pagodabox'
|
2
|
+
command :list do |c|
|
3
|
+
|
4
|
+
c.desc "Web Components"
|
5
|
+
c.switch [:w, :web]
|
6
|
+
|
7
|
+
c.desc "Database Components"
|
8
|
+
c.switch [:d, :database]
|
9
|
+
|
10
|
+
c.desc "Cache Components"
|
11
|
+
c.switch [:c, :cache]
|
12
|
+
|
13
|
+
c.desc "Worker Components"
|
14
|
+
c.switch [:r, :worker]
|
15
|
+
|
16
|
+
c.action do |global_options,options,args|
|
17
|
+
require 'pagoda/cli/helpers/app'
|
18
|
+
::Pagoda::Command::App.new(global_options,options,args).list
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# desc 'Rename your application'
|
2
|
+
# command :rename do |c|
|
3
|
+
|
4
|
+
# c.desc 'New name to apply to application'
|
5
|
+
# c.arg_name 'APP_NAME'
|
6
|
+
# c.flag [:n, :new]
|
7
|
+
|
8
|
+
# c.desc 'Old name of application'
|
9
|
+
# c.arg_name 'APP_NAME'
|
10
|
+
# c.flag [:o, :old]
|
11
|
+
|
12
|
+
|
13
|
+
# c.action do |global_options,options,args|
|
14
|
+
# require 'pagoda/cli/helpers/app'
|
15
|
+
# Pagoda::Command::App.new(global_options,options,args).rename
|
16
|
+
# end
|
17
|
+
# end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
desc 'Rollback your repo to the deploy it was on last'
|
2
|
+
command :rollback do |c|
|
3
|
+
|
4
|
+
c.desc 'Application to be rolled back'
|
5
|
+
c.arg_name 'APP_NAME'
|
6
|
+
c.flag [:a, :app]
|
7
|
+
|
8
|
+
c.action do |global_options,options,args|
|
9
|
+
require 'pagoda/cli/helpers/app'
|
10
|
+
Pagoda::Command::App.new(global_options, options, args).rollback
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
desc 'Generate an ssh key and post it to pagodabox'
|
2
|
+
arg_name 'Describe arguments to destroy here'
|
3
|
+
command 'key:gen' do |c|
|
4
|
+
|
5
|
+
c.desc 'File that will contain your ssh key'
|
6
|
+
c.arg_name 'FILE_NAME'
|
7
|
+
c.flag [:f, :file]
|
8
|
+
|
9
|
+
c.action do |global_options,options,args|
|
10
|
+
require 'pagoda/cli/helpers/key'
|
11
|
+
Pagoda::Command::Key.new(global_options,options,args).generate_key_and_push
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
desc 'Post an existiong ssh key to pagodabox'
|
16
|
+
command 'key:push' do |c|
|
17
|
+
|
18
|
+
c.desc 'File that contains your ssh key'
|
19
|
+
c.arg_name 'FILE_NAME'
|
20
|
+
c.flag [:f, :file]
|
21
|
+
|
22
|
+
|
23
|
+
c.action do |global_options,options,args|
|
24
|
+
require 'pagoda/cli/helpers/key'
|
25
|
+
Pagoda::Command::Key.new(global_options,options,args).push_existing_key
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
desc 'Tunnel to a component in your application'
|
2
|
+
arg_name 'Component name'
|
3
|
+
command :tunnel do |c|
|
4
|
+
|
5
|
+
c.desc 'Component name you want to connect to'
|
6
|
+
c.arg_name 'COMPONENT_NAME'
|
7
|
+
c.flag [:c, :component]
|
8
|
+
|
9
|
+
c.desc 'New app name'
|
10
|
+
c.arg_name 'APP_NAME'
|
11
|
+
c.flag [:a, :app]
|
12
|
+
|
13
|
+
|
14
|
+
c.action do |global_options,options,args|
|
15
|
+
require 'pagoda/cli/helpers/tunnel'
|
16
|
+
Pagoda::Command::Tunnel.new(global_options,options,args).run
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'pagoda/cli/commands/clone'
|
2
|
+
require 'pagoda/cli/commands/create'
|
3
|
+
require 'pagoda/cli/commands/deploy'
|
4
|
+
require 'pagoda/cli/commands/destroy'
|
5
|
+
require 'pagoda/cli/commands/info'
|
6
|
+
require 'pagoda/cli/commands/init'
|
7
|
+
require 'pagoda/cli/commands/ssh_key'
|
8
|
+
require 'pagoda/cli/commands/list'
|
9
|
+
require 'pagoda/cli/commands/rename'
|
10
|
+
require 'pagoda/cli/commands/rollback'
|
11
|
+
require 'pagoda/cli/commands/tunnel'
|
@@ -1,122 +1,15 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
end
|
10
|
-
|
11
|
-
def running_on_windows?
|
12
|
-
RUBY_PLATFORM =~ /mswin32|mingw32/
|
13
|
-
end
|
14
|
-
|
15
|
-
def running_on_a_mac?
|
16
|
-
RUBY_PLATFORM =~ /-darwin\d/
|
17
|
-
end
|
18
|
-
|
19
|
-
def display(msg="", newline=true, level=1)
|
20
|
-
indent = build_indent(level)
|
21
|
-
if newline
|
22
|
-
(running_on_windows?) ? puts("#{indent}#{msg}") : puts("#{indent}#{msg}".green)
|
23
|
-
else
|
24
|
-
(running_on_windows?) ? print("#{indent}#{msg}") : print("#{indent}#{msg}".green)
|
25
|
-
STDOUT.flush
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def option_value(short_hand = nil, long_hand = nil)
|
30
|
-
match = false
|
31
|
-
value = nil
|
32
|
-
|
33
|
-
if short_hand
|
34
|
-
if args.include?(short_hand)
|
35
|
-
value = args[args.index(short_hand) + 1]
|
36
|
-
match = true
|
37
|
-
end
|
38
|
-
end
|
39
|
-
if long_hand && !match
|
40
|
-
if match = args.grep(/#{long_hand}.*/).first
|
41
|
-
if match.include? "="
|
42
|
-
value = match.split("=").last
|
43
|
-
else
|
44
|
-
value = true
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
value
|
50
|
-
end
|
51
|
-
|
52
|
-
def format_date(date)
|
53
|
-
date = Time.parse(date) if date.is_a?(String)
|
54
|
-
date.strftime("%Y-%m-%d %H:%M %Z")
|
55
|
-
end
|
56
|
-
|
57
|
-
def ask(message=nil, level=1)
|
58
|
-
display("#{message}", false, level) if message
|
59
|
-
gets.strip
|
1
|
+
# 1.9 adds realpath to resolve symlinks; 1.8 doesn't
|
2
|
+
# have this method, so we add it so we get resolved symlinks
|
3
|
+
# and compatibility
|
4
|
+
unless File.respond_to? :realpath
|
5
|
+
class File #:nodoc:
|
6
|
+
def self.realpath path
|
7
|
+
return realpath(File.readlink(path)) if symlink?(path)
|
8
|
+
path
|
60
9
|
end
|
61
|
-
|
62
|
-
def confirm(message="Are you sure you wish to continue? (y/n)?", level=1)
|
63
|
-
return true if args.include? "-f"
|
64
|
-
case message
|
65
|
-
when Array
|
66
|
-
count = message.length
|
67
|
-
iteration = 0
|
68
|
-
message.each do |m|
|
69
|
-
if iteration == count - 1
|
70
|
-
(running_on_windows?) ? display("#{m} ", false, level) : display("#{m} ".blue, false, level)
|
71
|
-
else
|
72
|
-
(running_on_windows?) ? display("#{m} ", false, level) : display("#{m} ".blue, true, level)
|
73
|
-
end
|
74
|
-
iteration += 1
|
75
|
-
end
|
76
|
-
when String
|
77
|
-
(running_on_windows?) ? display("#{message} ", false, level) : display("#{message} ".blue, false, level)
|
78
|
-
end
|
79
|
-
ask.downcase == 'y'
|
80
|
-
end
|
81
|
-
|
82
|
-
def error(msg, exit=true, level=1)
|
83
|
-
indent = build_indent(level)
|
84
|
-
STDERR.puts
|
85
|
-
case msg
|
86
|
-
when Array
|
87
|
-
(running_on_windows?) ? STDERR.puts("#{indent}** Error:") : STDERR.puts("#{indent}** Error:".red)
|
88
|
-
msg.each do |m|
|
89
|
-
(running_on_windows?) ? STDERR.puts("#{indent}** #{m}") : STDERR.puts("#{indent}** #{m}".red)
|
90
|
-
end
|
91
|
-
when String
|
92
|
-
(running_on_windows?) ? STDERR.puts("#{indent}** Error:") : STDERR.puts("#{indent}** Error:".red)
|
93
|
-
end
|
94
|
-
STDERR.puts
|
95
|
-
exit 1 if exit
|
96
|
-
end
|
97
|
-
|
98
|
-
def loop_transaction(app_name = nil)
|
99
|
-
finished = false
|
100
|
-
until finished
|
101
|
-
display ".", false, 0
|
102
|
-
sleep 1
|
103
|
-
if client.app_info(app_name || app)[:transactions].count < 1
|
104
|
-
finished = true
|
105
|
-
display
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
def build_indent(level=1)
|
111
|
-
indent = ""
|
112
|
-
level.times do
|
113
|
-
indent += INDENT
|
114
|
-
end
|
115
|
-
indent
|
116
|
-
end
|
117
|
-
|
118
10
|
end
|
119
11
|
end
|
12
|
+
$: << File.expand_path(File.dirname(File.realpath(__FILE__)) + '/../lib')
|
120
13
|
|
121
14
|
unless String.method_defined?(:shellescape)
|
122
15
|
class String
|
@@ -126,7 +19,6 @@ unless String.method_defined?(:shellescape)
|
|
126
19
|
end
|
127
20
|
end
|
128
21
|
|
129
|
-
|
130
22
|
class String
|
131
23
|
|
132
24
|
#
|
@@ -314,4 +206,4 @@ class String
|
|
314
206
|
""
|
315
207
|
end
|
316
208
|
end
|
317
|
-
end
|
209
|
+
end
|