Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Support heroku config --json ONLY #42

Merged
merged 1 commit into from
Jul 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ It assumes a standard project layout (see the default value for the globs-option
The easiest/quickest is to run:

```
$ heroku config | bundle exec envied check:heroku
$ heroku config --json | bundle exec envied check:heroku
```

This is equivalent to having the heroku config as your local environment and running `envied check:heroku --groups default production`.
Expand Down
15 changes: 6 additions & 9 deletions lib/envied/cli.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'thor'
require 'json'
require 'envied/env_var_extractor'

class ENVied
Expand Down Expand Up @@ -84,7 +85,7 @@ def check

The Heroku config should be piped to this task:

heroku config | bundle exec envied check:heroku
heroku config --json | bundle exec envied check:heroku

Use the check:heroku:binstub-task to turn this into a bash-script.

Expand All @@ -96,16 +97,12 @@ def check
define_method "check:heroku" do
if STDIN.tty?
error <<-ERR
Please pipe the contents of `heroku config` to this task.
I.e. `heroku config | bundle exec envied check:heroku`"
Please pipe the contents of `heroku config --json` to this task.
I.e. `heroku config --json | bundle exec envied check:heroku`"
ERR
exit 1
end
config = STDIN.read
heroku_env = Hash[config.split("\n")[1..-1].each_with_object([]) do |i, res|
res << i.split(":", 2).map(&:strip)
end]

heroku_env = JSON.parse(STDIN.read)
ENV.replace({}).update(heroku_env)

requested_groups = ENV['ENVIED_GROUPS'] || options[:groups]
Expand All @@ -119,7 +116,7 @@ def check
long_desc <<-LONG
Generates a shell script to check the Heroku config against the local Envfile.

The same as the check:heroku-task, but all in one script (no need to pipe `heroku config` to it etc.).
The same as the check:heroku-task, but all in one script (no need to pipe `heroku config --json` to it etc.).

LONG
option :dest, banner: "where to put the script", desc: "Default: bin/<app>-env-check or bin/heroku-env-check"
Expand Down
4 changes: 2 additions & 2 deletions lib/envied/templates/heroku-env-check.tt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Check the config of a Heroku app against the defined variables in `Envfile`

<%- if @app %>
HEROKU_APP=<%= @app %> exec heroku config | bundle exec envied check:heroku --groups <%= @groups.join(" ") %>
HEROKU_APP=<%= @app %> exec heroku config --json | bundle exec envied check:heroku --groups <%= @groups.join(" ") %>
<%- else %>
exec heroku config | bundle exec envied check:heroku --groups <%= @groups.join(" ") %>
exec heroku config --json | bundle exec envied check:heroku --groups <%= @groups.join(" ") %>
<%- end %>