hanzo 0.6.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +8 -1
- data/README.md +112 -25
- data/bin/hanzo +1 -1
- data/hanzo.gemspec +1 -1
- data/lib/hanzo.rb +6 -6
- data/lib/hanzo/modules/config.rb +1 -1
- data/lib/hanzo/modules/deploy.rb +1 -1
- data/lib/hanzo/modules/install.rb +1 -1
- data/lib/hanzo/modules/installers/labs.rb +1 -1
- data/lib/hanzo/version.rb +1 -1
- data/spec/cli/deploy_spec.rb +4 -4
- data/spec/cli/install_spec.rb +2 -2
- data/spec/spec_helper.rb +1 -1
- metadata +15 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bee1eec974365dfa0ec1f64e66e815bf1fdc12cf
|
4
|
+
data.tar.gz: 7f6232230bb005fd4d839e76f627cc1a25db4873
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c0666923ca775c15f98f3fba16b86ca679459c8a68319420e5caada843ee16d409e4d8d41b5d264cfa3c101fcd363f64720ec06a7f73d82996506a4e22642bd3
|
7
|
+
data.tar.gz: 989a4281de8b8ec204ff0e767dd894ea43c80d429bd6f53ca6655d97057959cb7fc6d6ed96216a09d21ae5f4e1d69f88999b5a5f132ccfb9fdda8436bebc85bd
|
data/.rubocop.yml
CHANGED
@@ -4,6 +4,9 @@ Documentation:
|
|
4
4
|
Encoding:
|
5
5
|
Enabled: false
|
6
6
|
|
7
|
+
BlockLength:
|
8
|
+
Max: 100
|
9
|
+
|
7
10
|
LineLength:
|
8
11
|
Max: 200
|
9
12
|
|
@@ -17,7 +20,7 @@ IfUnlessModifier:
|
|
17
20
|
Enabled: false
|
18
21
|
|
19
22
|
CaseIndentation:
|
20
|
-
|
23
|
+
EnforcedStyle: case
|
21
24
|
IndentOneStep: true
|
22
25
|
|
23
26
|
MethodLength:
|
@@ -56,3 +59,7 @@ DoubleNegation:
|
|
56
59
|
|
57
60
|
TrivialAccessors:
|
58
61
|
ExactNameMatch: true
|
62
|
+
|
63
|
+
Style/PercentLiteralDelimiters:
|
64
|
+
PreferredDelimiters:
|
65
|
+
'%w': '()'
|
data/README.md
CHANGED
@@ -3,10 +3,9 @@
|
|
3
3
|
<img src="http://i.imgur.com/RZbJy1u.png" alt="Hanzo" />
|
4
4
|
</a>
|
5
5
|
<br />
|
6
|
-
Hanzo is a sharp tool to handle
|
6
|
+
Hanzo is a sharp tool to handle deploying an application on Heroku on multiple environments.
|
7
7
|
<br /><br />
|
8
8
|
<a href="https://rubygems.org/gems/hanzo"><img src="http://img.shields.io/gem/v/hanzo.svg" /></a>
|
9
|
-
<a href="https://codeclimate.com/github/mirego/hanzo"><img src="http://img.shields.io/codeclimate/github/mirego/hanzo.svg" /></a>
|
10
9
|
<a href='https://gemnasium.com/mirego/hanzo'><img src="http://img.shields.io/gemnasium/mirego/hanzo.svg" /></a>
|
11
10
|
<a href="https://travis-ci.org/mirego/hanzo"><img src="http://img.shields.io/travis/mirego/hanzo.svg" /></a>
|
12
11
|
</p>
|
@@ -23,30 +22,35 @@ gem 'hanzo'
|
|
23
22
|
|
24
23
|
## Usage
|
25
24
|
|
26
|
-
Create
|
25
|
+
Create a `.hanzo.yml` file at the root of your app that will contain a map of
|
27
26
|
remotes, with the remote as the key and the Heroku application name as the value.
|
28
27
|
|
29
|
-
You can also specify commands that
|
30
|
-
successful
|
31
|
-
|
28
|
+
You can also use `after_deploy` to specify commands that will be run on the application
|
29
|
+
after a successful deployment. Hanzo will prompt you before running each command,
|
30
|
+
then use `heroku run` to execute it. The application is restarted afterwards.
|
32
31
|
|
33
32
|
```yaml
|
34
33
|
remotes:
|
35
34
|
qa: heroku-app-name-qa
|
36
35
|
staging: heroku-app-name-staging
|
37
36
|
production: heroku-app-name-production
|
37
|
+
|
38
38
|
after_deploy:
|
39
39
|
- rake db:migrate
|
40
40
|
```
|
41
41
|
|
42
|
-
###
|
42
|
+
### `hanzo install`
|
43
|
+
|
44
|
+
#### Remotes
|
43
45
|
|
44
|
-
Whenever you add
|
45
|
-
|
46
|
+
Whenever you add new remotes to your `.hanzo.yml` file, you'll have to install
|
47
|
+
them locally by running `hanzo install remotes`.
|
46
48
|
|
47
49
|
```bash
|
48
|
-
|
50
|
+
$ hanzo install remotes
|
51
|
+
```
|
49
52
|
|
53
|
+
```
|
50
54
|
-----> Creating git remotes
|
51
55
|
Adding qa
|
52
56
|
git remote rm qa 2>&1 > /dev/null
|
@@ -59,22 +63,16 @@ remotes locally by running `hanzo install`.
|
|
59
63
|
git remote add production git@heroku.com:heroku-app-name-production.git
|
60
64
|
```
|
61
65
|
|
62
|
-
|
66
|
+
#### Labs
|
63
67
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
-----> Branch to deploy: |HEAD|
|
68
|
-
```
|
69
|
-
|
70
|
-
### Install labs
|
71
|
-
|
72
|
-
Once all your remotes are installed, you might want to enable some
|
73
|
-
Heroku labs feature for all of them.
|
68
|
+
Once all your remotes are installed, you might want to enable Heroku labs
|
69
|
+
features:
|
74
70
|
|
75
71
|
```bash
|
76
|
-
|
72
|
+
$ hanzo install labs
|
73
|
+
```
|
77
74
|
|
75
|
+
```
|
78
76
|
-----> Activating Heroku Labs
|
79
77
|
Add preboot? yes
|
80
78
|
- Enabled for qa
|
@@ -86,12 +84,101 @@ Heroku labs feature for all of them.
|
|
86
84
|
- Enabled for production
|
87
85
|
```
|
88
86
|
|
87
|
+
### `hanzo deploy`
|
88
|
+
|
89
|
+
You can deploy to a specific remote using `hanzo deploy <remote>` and an
|
90
|
+
optional reference to deploy. If no reference is specified, Hanzo will prompt
|
91
|
+
for one (with `HEAD` as the default value).
|
92
|
+
|
93
|
+
```bash
|
94
|
+
$ hanzo deploy qa release/qa
|
95
|
+
```
|
96
|
+
|
97
|
+
```
|
98
|
+
git push -f qa release/qa:master
|
99
|
+
|
100
|
+
…
|
101
|
+
|
102
|
+
remote: Verifying deploy... done.
|
103
|
+
To heroku.com:heroku-app-name-qa.git
|
104
|
+
550c719..27e3538 release/qa -> master
|
105
|
+
|
106
|
+
Run `rake db:migrate` on qa? y
|
107
|
+
heroku run rake db:migrate --remote qa
|
108
|
+
|
109
|
+
Running rake db:migrate on heroku-app-name-qa...
|
110
|
+
15:45:26.380 [info] Already up
|
111
|
+
heroku ps:restart --remote qa
|
112
|
+
|
113
|
+
Restarting dynos on heroku-app-name-qa...
|
114
|
+
```
|
115
|
+
|
116
|
+
### `hanzo diff`
|
117
|
+
|
118
|
+
You can use `hanzo diff <remote>` to compare the current repository state to the code
|
119
|
+
that is currently deployed in the specified remote.
|
120
|
+
|
121
|
+
Warning: This uses Heroku’s git repository references so its output might be
|
122
|
+
wrong if the application was rollbacked.
|
123
|
+
|
124
|
+
```
|
125
|
+
$ hanzo diff qa
|
126
|
+
git remote update qa && git diff qa/master...HEAD
|
127
|
+
```
|
128
|
+
|
129
|
+
```diff
|
130
|
+
────────────────────────────────────────────────────────────────────────────────────────────
|
131
|
+
-- a/lib/my_app/router.ex
|
132
|
+
++ b/lib/my_app/router.ex
|
133
|
+
────────────────────────────────────────────────────────────────────────────────────────────
|
134
|
+
@@ -30,6 +30,8 @@ defmodule MyApp.Router do
|
135
|
+
plug(:fetch_flash)
|
136
|
+
+ plug(:protect_from_forgery)
|
137
|
+
+ plug(:put_secure_browser_headers)
|
138
|
+
```
|
139
|
+
|
140
|
+
### `hanzo config`
|
141
|
+
|
142
|
+
#### Compare
|
143
|
+
|
144
|
+
You can use `hanzo config compare` to find out which environment variables are
|
145
|
+
present in only some of your environments.
|
146
|
+
|
147
|
+
```
|
148
|
+
$ hanzo config compare
|
149
|
+
```
|
150
|
+
|
151
|
+
```
|
152
|
+
-----> Fetching environment variables
|
153
|
+
heroku config -r qa
|
154
|
+
heroku config -r staging
|
155
|
+
heroku config -r production
|
156
|
+
|
157
|
+
-----> Comparing environment variables
|
158
|
+
Missing variables in qa
|
159
|
+
- ASSET_HOST
|
160
|
+
Missing variables in staging
|
161
|
+
- SMTP_PASSWORD
|
162
|
+
- SMTP_PORT
|
163
|
+
- SMTP_SERVER
|
164
|
+
- SMTP_USER
|
165
|
+
Missing variables in production
|
166
|
+
- SMTP_PASSWORD
|
167
|
+
- SMTP_PORT
|
168
|
+
- SMTP_SERVER
|
169
|
+
- SMTP_USER
|
170
|
+
```
|
171
|
+
|
89
172
|
## License
|
90
173
|
|
91
|
-
`Hanzo` is © 2013-
|
174
|
+
`Hanzo` is © 2013-2018 [Mirego](http://www.mirego.com) and may be freely
|
175
|
+
distributed under the [New BSD license](http://opensource.org/licenses/BSD-3-Clause). See the
|
176
|
+
[`LICENSE.md`](https://github.com/mirego/hanzo/blob/master/LICENSE.md) file.
|
92
177
|
|
93
178
|
## About Mirego
|
94
179
|
|
95
|
-
[Mirego](
|
180
|
+
[Mirego](https://www.mirego.com) is a team of passionate people who believe that
|
181
|
+
work is a place where you can innovate and have fun. We're a team of [talented people](https://life.mirego.com)
|
182
|
+
who imagine and build beautiful Web and mobile applications. We come together to share ideas and [change the world](http://mirego.org).
|
96
183
|
|
97
|
-
We also [love open-source software](
|
184
|
+
We also [love open-source software](https://open.mirego.com) and we try to give back to the community as much as we can.
|
data/bin/hanzo
CHANGED
data/hanzo.gemspec
CHANGED
@@ -21,9 +21,9 @@ Gem::Specification.new do |spec|
|
|
21
21
|
|
22
22
|
spec.add_development_dependency 'bundler', '~> 1.3'
|
23
23
|
spec.add_development_dependency 'phare', '~> 0.6'
|
24
|
-
spec.add_development_dependency 'rubocop', '~> 0.24'
|
25
24
|
spec.add_development_dependency 'rake'
|
26
25
|
spec.add_development_dependency 'rspec', '~> 3.1'
|
26
|
+
spec.add_development_dependency 'rubocop', '~> 0.49'
|
27
27
|
|
28
28
|
spec.add_dependency 'highline', '>= 1.6.19'
|
29
29
|
end
|
data/lib/hanzo.rb
CHANGED
@@ -15,11 +15,11 @@ module Hanzo
|
|
15
15
|
output = true
|
16
16
|
|
17
17
|
_run do
|
18
|
-
if fetch_output
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
output = if fetch_output
|
19
|
+
`#{command}`
|
20
|
+
else
|
21
|
+
system(command)
|
22
|
+
end
|
23
23
|
end
|
24
24
|
|
25
25
|
output
|
@@ -68,6 +68,6 @@ end
|
|
68
68
|
|
69
69
|
class String
|
70
70
|
def unindent
|
71
|
-
gsub(/^#{scan(/^\s*/).min_by
|
71
|
+
gsub(/^#{scan(/^\s*/).min_by(&:length)}/, '')
|
72
72
|
end
|
73
73
|
end
|
data/lib/hanzo/modules/config.rb
CHANGED
@@ -52,7 +52,7 @@ module Hanzo
|
|
52
52
|
@variables.each_pair do |env, variables|
|
53
53
|
missing_variables = all_variables - variables
|
54
54
|
Hanzo.print "Missing variables in #{env}", :yellow
|
55
|
-
Hanzo.print
|
55
|
+
Hanzo.print(missing_variables.map { |v| "- #{v}" })
|
56
56
|
end
|
57
57
|
end
|
58
58
|
end
|
data/lib/hanzo/modules/deploy.rb
CHANGED
@@ -18,7 +18,7 @@ module Hanzo
|
|
18
18
|
deploy && run_after_deploy_commands
|
19
19
|
rescue UnknownEnvironment
|
20
20
|
Hanzo.unindent_print "Environment `#{@env}` doesn't exist. Add it to .hanzo.yml and run:\n hanzo install remotes", :red
|
21
|
-
Hanzo.unindent_print "\nFor more information, read https://github.com/mirego/hanzo#
|
21
|
+
Hanzo.unindent_print "\nFor more information, read https://github.com/mirego/hanzo#remotes", :red
|
22
22
|
rescue UninstalledEnvironment
|
23
23
|
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
|
24
24
|
end
|
@@ -4,7 +4,7 @@ module Hanzo
|
|
4
4
|
def install_labs
|
5
5
|
Hanzo.title('Activating Heroku Labs')
|
6
6
|
|
7
|
-
Hanzo::Heroku.available_labs.
|
7
|
+
Hanzo::Heroku.available_labs.each_key do |name|
|
8
8
|
next unless Hanzo.agree("Add #{name}?")
|
9
9
|
|
10
10
|
Hanzo::Installers::Remotes.environments.each_pair do |env, _|
|
data/lib/hanzo/version.rb
CHANGED
data/spec/cli/deploy_spec.rb
CHANGED
@@ -2,9 +2,9 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Hanzo::CLI do
|
4
4
|
describe :deploy do
|
5
|
-
let(:deploy!) { Hanzo::CLI.new(
|
5
|
+
let(:deploy!) { Hanzo::CLI.new(%w(deploy production)) }
|
6
6
|
let(:deploy_question) { 'Branch to deploy in production:' }
|
7
|
-
let(:deploy_command) {
|
7
|
+
let(:deploy_command) { 'git push -f production 1.0.0:master' }
|
8
8
|
|
9
9
|
before do
|
10
10
|
expect(Hanzo::Installers::Remotes).to receive(:environments).and_return(['production'])
|
@@ -12,8 +12,8 @@ describe Hanzo::CLI do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
context 'deploy with specific branch' do
|
15
|
-
let(:deploy!) { Hanzo::CLI.new(
|
16
|
-
let(:deploy_command) {
|
15
|
+
let(:deploy!) { Hanzo::CLI.new(%w(deploy production 2.0.0)) }
|
16
|
+
let(:deploy_command) { 'git push -f production 2.0.0:master' }
|
17
17
|
let(:deploy_result) { true }
|
18
18
|
let(:config) { {} }
|
19
19
|
|
data/spec/cli/install_spec.rb
CHANGED
@@ -18,10 +18,10 @@ describe Hanzo::CLI do
|
|
18
18
|
expect(Hanzo::Heroku).to receive(:available_labs).and_return(available_labs)
|
19
19
|
expect(Hanzo).to receive(:title).with(labs_title)
|
20
20
|
|
21
|
-
available_labs.
|
21
|
+
available_labs.each_key do |name|
|
22
22
|
expect(Hanzo).to receive(:agree).with("Add #{name}?").and_return(true)
|
23
23
|
|
24
|
-
heroku_remotes.
|
24
|
+
heroku_remotes.each_key do |env|
|
25
25
|
expect(Hanzo).to receive(:run).with("#{enable_labs_cmd} #{name} --remote #{env}")
|
26
26
|
expect(Hanzo).to receive(:print).with("#{enable_labs_info} #{env}")
|
27
27
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hanzo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Garneau
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -39,47 +39,47 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0.6'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '0
|
47
|
+
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '0
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '3.1'
|
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
|
-
version: '
|
68
|
+
version: '3.1'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: rubocop
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '0.49'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '0.49'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: highline
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|