hanzo 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bee1eec974365dfa0ec1f64e66e815bf1fdc12cf
4
- data.tar.gz: 7f6232230bb005fd4d839e76f627cc1a25db4873
3
+ metadata.gz: 06cc1fe7d71c8594d349eab399e17e9d60496fdb
4
+ data.tar.gz: 771984e5aab716ad657b107181139b8aea3e539e
5
5
  SHA512:
6
- metadata.gz: c0666923ca775c15f98f3fba16b86ca679459c8a68319420e5caada843ee16d409e4d8d41b5d264cfa3c101fcd363f64720ec06a7f73d82996506a4e22642bd3
7
- data.tar.gz: 989a4281de8b8ec204ff0e767dd894ea43c80d429bd6f53ca6655d97057959cb7fc6d6ed96216a09d21ae5f4e1d69f88999b5a5f132ccfb9fdda8436bebc85bd
6
+ metadata.gz: acfc7c7c91cb1815a02149800921185be9ff92ea76c48e12afc8f758fb2a5bfa27c3a74335f45bc9577cf904bb9a6d71f6892702f08182215113ceeb70a1924a
7
+ data.tar.gz: 8c45a59faf8c4894bdf802ba12f860b4122caada58f77a8bacecffcbf22b0997162d1dafe8317e72c3d9233f655a7693295873b57cf55c601ddd152c11c8852a
data/README.md CHANGED
@@ -37,6 +37,8 @@ remotes:
37
37
 
38
38
  after_deploy:
39
39
  - rake db:migrate
40
+
41
+ console: rails console
40
42
  ```
41
43
 
42
44
  ### `hanzo install`
@@ -169,6 +171,20 @@ $ hanzo config compare
169
171
  - SMTP_USER
170
172
  ```
171
173
 
174
+ ### `hanzo console`
175
+
176
+ You can define a `console` command in `.hanzo.yml` to quickly spawn a console
177
+ process using `heroku run`.
178
+
179
+ ```bash
180
+ $ hanzo console qa
181
+ ```
182
+
183
+ ```
184
+ Running iex -S mix on heroku-app-name-qa... up
185
+ > |
186
+ ```
187
+
172
188
  ## License
173
189
 
174
190
  `Hanzo` is © 2013-2018 [Mirego](http://www.mirego.com) and may be freely
data/lib/hanzo/cli.rb CHANGED
@@ -2,6 +2,7 @@ require 'hanzo/modules/deploy'
2
2
  require 'hanzo/modules/diff'
3
3
  require 'hanzo/modules/install'
4
4
  require 'hanzo/modules/config'
5
+ require 'hanzo/modules/console'
5
6
 
6
7
  module Hanzo
7
8
  class CLI < Base
@@ -35,6 +36,7 @@ module Hanzo
35
36
  diff - Show the diff between HEAD and the current release
36
37
  install - Install Hanzo configuration
37
38
  config - Manage Heroku configuration variables
39
+ console - Run a console command
38
40
 
39
41
  Options:
40
42
  BANNER
@@ -0,0 +1,57 @@
1
+ module Hanzo
2
+ class Console < Base
3
+ # Classes
4
+ UnknownEnvironment = Class.new(StandardError)
5
+ UninstalledEnvironment = Class.new(StandardError)
6
+ UnknownCommand = Class.new(StandardError)
7
+
8
+ def initialize_variables
9
+ @env = extract_argument(1)
10
+ end
11
+
12
+ def initialize_cli
13
+ initialize_help && return if @env.nil?
14
+
15
+ validate_environment_existence!
16
+
17
+ console
18
+ rescue UnknownCommand
19
+ Hanzo.unindent_print 'A “console” command is needed in `.hanzo.yml`', :red
20
+ rescue UnknownEnvironment
21
+ Hanzo.unindent_print "Environment `#{@env}` doesn't exist. Add it to .hanzo.yml and run:\n hanzo install remotes", :red
22
+ Hanzo.unindent_print "\nFor more information, read https://github.com/mirego/hanzo#remotes", :red
23
+ rescue UninstalledEnvironment
24
+ Hanzo.unindent_print "Environment `#{@env}` has been found in your .hanzo.yml file. Before using it, you must install it:\n hanzo install remotes", :red
25
+ end
26
+
27
+ def console
28
+ command = Hanzo.config['console']
29
+ raise UnknownCommand unless command
30
+
31
+ Hanzo.run "heroku run --remote #{@env} #{command}"
32
+ end
33
+
34
+ protected
35
+
36
+ def initialize_help
37
+ @options.banner = <<-BANNER.unindent
38
+ Usage: hanzo console ENVIRONMENT
39
+
40
+ Available environments
41
+ BANNER
42
+
43
+ Hanzo::Installers::Remotes.environments.each do |env|
44
+ @options.banner << " - #{env.first}\n"
45
+ end
46
+ end
47
+
48
+ def validate_environment_existence!
49
+ raise UnknownEnvironment unless fetcher.exist?
50
+ raise UninstalledEnvironment unless fetcher.installed?
51
+ end
52
+
53
+ def fetcher
54
+ @fetcher ||= Hanzo::Fetchers::Environment.new(@env)
55
+ end
56
+ end
57
+ end
data/lib/hanzo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Hanzo
2
- VERSION = '1.0.0'.freeze
2
+ VERSION = '1.0.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hanzo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Garneau
@@ -118,6 +118,7 @@ files:
118
118
  - lib/hanzo/fetchers/environment.rb
119
119
  - lib/hanzo/heroku.rb
120
120
  - lib/hanzo/modules/config.rb
121
+ - lib/hanzo/modules/console.rb
121
122
  - lib/hanzo/modules/deploy.rb
122
123
  - lib/hanzo/modules/diff.rb
123
124
  - lib/hanzo/modules/install.rb