envirobly 1.1.0 → 1.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4069ab1f0da67a7bc06444c1d32cef454c23924f125925f1bc00bcd56419b94f
4
- data.tar.gz: e5f5628338e7b9deda59a6c26f6e95b967f8ecbbfa0a1b41994aa3834f92a77a
3
+ metadata.gz: 58cece10b3dc2908e0bce6a78f509463c8261fa34d54c9a45059b95205c494d3
4
+ data.tar.gz: 71b06913da6f29967a5f779c62a76423f30242474daeda744b34be44f7ba494a
5
5
  SHA512:
6
- metadata.gz: de515ea959bef33ba5a1e89ffa6862d3a8f116a8f4cab2249b97042e7a92e19020daeba4c5a93babbee793656f1f34b86850924cf97cb22b17f0a739333de4a1
7
- data.tar.gz: af5c4e4b6d08d1c08a06be9089a9e0f0d790915efafbf0cf0694a0e0ff90c68fbfdebdcb78c2921a3f7dd571561132968839832c0c5c5cb8be7a5b13b59afba0
6
+ metadata.gz: d67d5afc046a25396f822f86d17d584172468e277ff5626efbb1d11fadffdad86e821118b2d8dc0ee89f33b9d316d999fce182f5001be7e7029977aeb3a9604c
7
+ data.tar.gz: 224f58f13842244a423fbef3ab69540a97969a15c168e09a090f8a8c255340ec65657db6bf680d6c384d2dbda804d51708dc2bc99928ac03785495e00341837f
@@ -69,7 +69,7 @@ class Envirobly::AccessToken
69
69
  exit
70
70
  end
71
71
 
72
- api = Envirobly::Api.new(access_token: self)
72
+ api = Envirobly::Api.new(access_token: self, exit_on_error: false)
73
73
 
74
74
  # TODO: Eventually replace with custom `whoami` API that returns name, email...
75
75
  if api.list_accounts.success?
data/lib/envirobly/api.rb CHANGED
@@ -8,7 +8,8 @@ class Envirobly::Api
8
8
  USER_AGENT = "Envirobly CLI v#{Envirobly::VERSION}"
9
9
  CONTENT_TYPE = "application/json"
10
10
 
11
- def initialize(access_token: Envirobly::AccessToken.new)
11
+ def initialize(access_token: Envirobly::AccessToken.new, exit_on_error: true)
12
+ @exit_on_error = exit_on_error
12
13
  @access_token = access_token
13
14
  end
14
15
 
@@ -117,11 +118,18 @@ class Envirobly::Api
117
118
  http.request(request).tap do |response|
118
119
  def response.object
119
120
  @json_parsed_body ||= JSON.parse(body)
121
+ rescue
122
+ @json_parsed_body = { error_message: body }
120
123
  end
121
124
 
122
125
  def response.success?
123
126
  (200..299).include?(code.to_i)
124
127
  end
128
+
129
+ if @exit_on_error && !response.success? && response.object[:error_message].present?
130
+ puts response.object[:error_message] # TODO: Replace with shell.say_error
131
+ exit 1
132
+ end
125
133
  end
126
134
  end
127
135
 
@@ -80,7 +80,8 @@ class Envirobly::Cli::Main < Envirobly::Base
80
80
  TXT
81
81
  method_option :account_id, type: :numeric
82
82
  method_option :region, type: :string
83
- method_option :project, type: :string
83
+ method_option :project_id, type: :numeric
84
+ method_option :project_name, type: :string
84
85
  method_option :commit, type: :string, default: "HEAD"
85
86
  method_option :dry_run, type: :boolean, default: false
86
87
  def deploy(environ_name = nil)
@@ -93,31 +94,19 @@ class Envirobly::Cli::Main < Envirobly::Base
93
94
 
94
95
  Envirobly::AccessToken.new(shell:).require!
95
96
 
96
- environ_name = environ_name.presence || commit.current_branch
97
- project_name = nil
98
- project_id = nil
99
-
100
- if options.project.present?
101
- if options.project =~ Envirobly::Defaults::Project.regexp
102
- project_id = $1.to_i
103
- else
104
- project_name = options.project
105
- end
106
- end
107
-
108
97
  deployment = Envirobly::Deployment.new(
109
98
  account_id: options.account_id,
110
99
  region: options.region,
111
- project_name:,
112
- environ_name:,
113
- project_id:,
100
+ project_id: options.project_id,
101
+ project_name: options.project_name,
102
+ environ_name: environ_name.presence || commit.current_branch,
114
103
  commit:,
115
104
  shell:
116
105
  )
117
106
  deployment.perform(dry_run: options.dry_run)
118
107
  end
119
108
 
120
- desc "pull", "Download build context"
109
+ desc "pull [REGION] [BUCKET] [REF] [PATH]", "Download build context. Used by Envirobly builders."
121
110
  def pull(region, bucket, ref, path)
122
111
  Envirobly::Duration.measure("Build context download took %s") do
123
112
  s3 = Envirobly::Aws::S3.new(region:, bucket:)
@@ -1,3 +1,3 @@
1
1
  module Envirobly
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: envirobly
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Starsi