bld 0.1.2 → 0.1.6
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 +4 -4
- data/bin/bld +3 -1
- data/bin/build +3 -1
- data/lib/commands.rb +303 -99
- metadata +35 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23ca92095150f9e2e36d9a2b64946ab21047349387aa7a6eebefc10e7f8227d3
|
4
|
+
data.tar.gz: f46aba8b557a61ee3ac3b41c366a1be1ea3c608e82e8cbf5ef8d1851fca7022d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ca6e41446dbceea06b380d9e47b57e5b5b585f3b6a238c8c50d8a24c4bd6b613619771aa13d538cc7fe5c9f0c2cf63024a78a88a5d46f61048b05969fd089b7
|
7
|
+
data.tar.gz: d5a535ce8825b02b2d91f4df6fea86f71ccd3f58b285708cd3b21ecff065d8f58be849d973838f208a6cba5f7c79756f3227cfce9cae885acdeb06aad0206856
|
data/bin/bld
CHANGED
@@ -5,6 +5,7 @@ require 'cli/ui'
|
|
5
5
|
require 'launchy'
|
6
6
|
require 'netrc'
|
7
7
|
require 'httparty'
|
8
|
+
require 'net/ssh'
|
8
9
|
require_relative '../lib/commands'
|
9
10
|
|
10
11
|
ANTIMONY_HOST = "https://app.build.io"
|
@@ -19,9 +20,10 @@ class BuildCLI
|
|
19
20
|
|
20
21
|
def run
|
21
22
|
program :name, 'Build CLI'
|
22
|
-
program :version, '1.
|
23
|
+
program :version, '0.1.6'
|
23
24
|
program :description, "Build's Command Line Interface"
|
24
25
|
program :int_block, -> { exit }
|
26
|
+
default_command :help
|
25
27
|
|
26
28
|
BuildCLICommands.index.each do |name, entry|
|
27
29
|
command name.to_sym do |c|
|
data/bin/build
CHANGED
@@ -5,6 +5,7 @@ require 'cli/ui'
|
|
5
5
|
require 'launchy'
|
6
6
|
require 'netrc'
|
7
7
|
require 'httparty'
|
8
|
+
require 'net/ssh'
|
8
9
|
require_relative '../lib/commands'
|
9
10
|
|
10
11
|
ANTIMONY_HOST = "https://app.build.io"
|
@@ -19,9 +20,10 @@ class BuildCLI
|
|
19
20
|
|
20
21
|
def run
|
21
22
|
program :name, 'Build CLI'
|
22
|
-
program :version, '1.
|
23
|
+
program :version, '0.1.6'
|
23
24
|
program :description, "Build's Command Line Interface"
|
24
25
|
program :int_block, -> { exit }
|
26
|
+
default_command :help
|
25
27
|
|
26
28
|
BuildCLICommands.index.each do |name, entry|
|
27
29
|
command name.to_sym do |c|
|
data/lib/commands.rb
CHANGED
@@ -2,79 +2,247 @@
|
|
2
2
|
class BuildCLICommands
|
3
3
|
def self.index
|
4
4
|
return {
|
5
|
+
"config": {
|
6
|
+
cli_details: { :syntax => "build config -a <app>", :description => "Get the config variables for an app",
|
7
|
+
:options => [["-a", "--app=<value>", String, "(required) app to run command against"]] },
|
8
|
+
cli_perform: Proc.new { |args, options|
|
9
|
+
app_name = options.app
|
10
|
+
if app_name.nil? || app_name.strip == ""
|
11
|
+
puts(CLI::UI.fmt("{{red:›}} Error: The following error occurred:"))
|
12
|
+
puts(CLI::UI.fmt("{{red:›}} {{gray:Missing required flag app}}"))
|
13
|
+
puts(CLI::UI.fmt("{{red:›}} See more help with --help"))
|
14
|
+
exit(1)
|
15
|
+
end
|
16
|
+
user_netrc = Netrc.read
|
17
|
+
user_token = user_netrc.[]("build.io")&.password
|
18
|
+
if user_token.nil?
|
19
|
+
puts(CLI::UI.fmt("{{red:›}} Error: not logged in"))
|
20
|
+
exit(1)
|
21
|
+
end
|
22
|
+
auth = "Bearer #{user_token}"
|
23
|
+
query_params = {}
|
24
|
+
query_params.[]=(:app, app_name)
|
25
|
+
query_string = URI.encode_www_form(query_params)
|
26
|
+
res = HTTParty.get("#{ANTIMONY_HOST}/api/cli/command/config?#{query_string}",
|
27
|
+
{ headers: { "Authorization" => auth } })
|
28
|
+
if res.code != 200
|
29
|
+
if res.body.[]("error")
|
30
|
+
puts(CLI::UI.fmt("{{red:›}} Error: #{res.body.[]("error")}"))
|
31
|
+
exit(1)
|
32
|
+
else
|
33
|
+
puts(CLI::UI.fmt("{{red:›}} Error: An unknown error occurred"))
|
34
|
+
exit(1)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
JSON.parse(res.body).each { |key, value|
|
38
|
+
puts("#{key}=#{value}")
|
39
|
+
}
|
40
|
+
},
|
41
|
+
},
|
42
|
+
"config:get": {
|
43
|
+
cli_details: { :syntax => "build config:get VARIABLE -a <app>", :description => "Get a config variable for an app",
|
44
|
+
:options => [["-a", "--app=<value>", String, "(required) app to run command against"]] },
|
45
|
+
cli_perform: Proc.new { |args, options|
|
46
|
+
app_name = options.app
|
47
|
+
if app_name.nil? || app_name.strip == ""
|
48
|
+
puts(CLI::UI.fmt("{{red:›}} Error: The following error occurred:"))
|
49
|
+
puts(CLI::UI.fmt("{{red:›}} {{gray:Missing required flag app}}"))
|
50
|
+
puts(CLI::UI.fmt("{{red:›}} See more help with --help"))
|
51
|
+
exit(1)
|
52
|
+
end
|
53
|
+
config_variable = args.[](0)
|
54
|
+
if config_variable.nil? || config_variable.strip == ""
|
55
|
+
puts(CLI::UI.fmt("{{red:›}} Error: The following error occurred:"))
|
56
|
+
puts(CLI::UI.fmt("{{red:›}} {{gray:Missing required argument VARIABLE}}"))
|
57
|
+
puts(CLI::UI.fmt("{{red:›}} See more help with --help"))
|
58
|
+
exit(1)
|
59
|
+
end
|
60
|
+
user_netrc = Netrc.read
|
61
|
+
user_token = user_netrc.[]("build.io")&.password
|
62
|
+
if user_token.nil?
|
63
|
+
puts(CLI::UI.fmt("{{red:›}} Error: not logged in"))
|
64
|
+
exit(1)
|
65
|
+
end
|
66
|
+
auth = "Bearer #{user_token}"
|
67
|
+
query_params = {}
|
68
|
+
query_params.[]=(:app, app_name)
|
69
|
+
query_params.[]=(:key, config_variable)
|
70
|
+
query_string = URI.encode_www_form(query_params)
|
71
|
+
res = HTTParty.get("#{ANTIMONY_HOST}/api/cli/command/config/get?#{query_string}",
|
72
|
+
{ headers: { "Authorization" => auth } })
|
73
|
+
if res.code != 200
|
74
|
+
if res.body.[]("error")
|
75
|
+
puts(CLI::UI.fmt("{{red:›}} Error: #{res.body.[]("error")}"))
|
76
|
+
exit(1)
|
77
|
+
else
|
78
|
+
puts(CLI::UI.fmt("{{red:›}} Error: An unknown error occurred"))
|
79
|
+
exit(1)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
puts(res.body)
|
83
|
+
},
|
84
|
+
},
|
85
|
+
"config:set": {
|
86
|
+
cli_details: { :syntax => "build config:set VARIABLE=VALUE -a <app>", :description => "Set config variables for an app",
|
87
|
+
:options => [["-a", "--app=<value>", String, "(required) app to run command against"]] },
|
88
|
+
cli_perform: Proc.new { |args, options|
|
89
|
+
app_name = options.app
|
90
|
+
if app_name.nil? || app_name.strip == ""
|
91
|
+
puts(CLI::UI.fmt("{{red:›}} Error: The following error occurred:"))
|
92
|
+
puts(CLI::UI.fmt("{{red:›}} {{gray:Missing required flag app}}"))
|
93
|
+
puts(CLI::UI.fmt("{{red:›}} See more help with --help"))
|
94
|
+
exit(1)
|
95
|
+
end
|
96
|
+
config_variables = args.map { |arg,|
|
97
|
+
arg.split("=")
|
98
|
+
}.to_h
|
99
|
+
if config_variables.empty?
|
100
|
+
puts(CLI::UI.fmt("{{red:›}} Error: The following error occurred:"))
|
101
|
+
puts(CLI::UI.fmt("{{red:›}} {{gray:No config variables provided}}"))
|
102
|
+
puts(CLI::UI.fmt("{{red:›}} See more help with --help"))
|
103
|
+
exit(1)
|
104
|
+
end
|
105
|
+
user_netrc = Netrc.read
|
106
|
+
user_token = user_netrc.[]("build.io")&.password
|
107
|
+
if user_token.nil?
|
108
|
+
puts(CLI::UI.fmt("{{red:›}} Error: not logged in"))
|
109
|
+
exit(1)
|
110
|
+
end
|
111
|
+
auth = "Bearer #{user_token}"
|
112
|
+
query_params = {}
|
113
|
+
query_params.[]=(:app, app_name)
|
114
|
+
query_params.[]=(:config, config_variables.to_json)
|
115
|
+
query_string = URI.encode_www_form(query_params)
|
116
|
+
res = HTTParty.get("#{ANTIMONY_HOST}/api/cli/command/config/set?#{query_string}",
|
117
|
+
{ headers: { "Authorization" => auth } })
|
118
|
+
if res.code != 200
|
119
|
+
if res.body && res.body.[]("error")
|
120
|
+
puts(CLI::UI.fmt("{{red:›}} Error: #{res.body.[]("error")}"))
|
121
|
+
else
|
122
|
+
puts(CLI::UI.fmt("{{red:›}} Error: An unknown error occurred"))
|
123
|
+
end
|
124
|
+
exit(1)
|
125
|
+
end
|
126
|
+
puts(CLI::UI.fmt("{{green:›}} Config variable(s) set successfully"))
|
127
|
+
},
|
128
|
+
},
|
129
|
+
"config:unset": {
|
130
|
+
cli_details: { :syntax => "build config:unset VARIABLE -a <app>", :description => "Un-Set config variables for an app",
|
131
|
+
:options => [["-a", "--app=<value>", String, "(required) app to run command against"]] },
|
132
|
+
cli_perform: Proc.new { |args, options|
|
133
|
+
app_name = options.app
|
134
|
+
if app_name.nil? || app_name.strip == ""
|
135
|
+
puts(CLI::UI.fmt("{{red:›}} Error: The following error occurred:"))
|
136
|
+
puts(CLI::UI.fmt("{{red:›}} {{gray:Missing required flag app}}"))
|
137
|
+
puts(CLI::UI.fmt("{{red:›}} See more help with --help"))
|
138
|
+
exit(1)
|
139
|
+
end
|
140
|
+
config_variables = args.compact
|
141
|
+
if config_variables.empty?
|
142
|
+
puts(CLI::UI.fmt("{{red:›}} Error: The following error occurred:"))
|
143
|
+
puts(CLI::UI.fmt("{{red:›}} {{gray:No config variables provided}}"))
|
144
|
+
puts(CLI::UI.fmt("{{red:›}} See more help with --help"))
|
145
|
+
exit(1)
|
146
|
+
end
|
147
|
+
user_netrc = Netrc.read
|
148
|
+
user_token = user_netrc.[]("build.io")&.password
|
149
|
+
if user_token.nil?
|
150
|
+
puts(CLI::UI.fmt("{{red:›}} Error: not logged in"))
|
151
|
+
exit(1)
|
152
|
+
end
|
153
|
+
auth = "Bearer #{user_token}"
|
154
|
+
query_params = {}
|
155
|
+
query_params.[]=(:app, app_name)
|
156
|
+
query_params.[]=(:config, config_variables)
|
157
|
+
query_string = URI.encode_www_form(query_params)
|
158
|
+
res = HTTParty.get("#{ANTIMONY_HOST}/api/cli/command/config/unset?#{query_string}",
|
159
|
+
{ headers: { "Authorization" => auth } })
|
160
|
+
if res.code != 200
|
161
|
+
if res.body && res.body.[]("error")
|
162
|
+
puts(CLI::UI.fmt("{{red:›}} Error: #{res.body.[]("error")}"))
|
163
|
+
else
|
164
|
+
puts(CLI::UI.fmt("{{red:›}} Error: An unknown error occurred"))
|
165
|
+
end
|
166
|
+
exit(1)
|
167
|
+
end
|
168
|
+
puts(CLI::UI.fmt("{{green:›}} Config variable(s) unset successfully"))
|
169
|
+
},
|
170
|
+
},
|
5
171
|
"apps:create": {
|
6
172
|
cli_details: { :syntax => "apps:create [options] -a <app>", :description => "Create a new app",
|
7
173
|
:options => [["-t", "--team=<value>", String, "team to use"], ["-r", "--region=<value>", String, "specify region for the app to run in"], ["-s", "--stack=<value>", String, "the stack to create the app on"], ["-a", "--app=<value>", String, "(required) the name of the app to create"]] },
|
8
174
|
cli_perform: Proc.new { |args, options|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
query_params = {}
|
21
|
-
query_params[:app] = app_name
|
22
|
-
query_params[:team] = options.team if options.team
|
23
|
-
query_params[:region] = options.region if options.region
|
24
|
-
query_params[:stack] = options.stack if options.stack
|
25
|
-
|
26
|
-
query_string = URI.encode_www_form(query_params)
|
27
|
-
|
28
|
-
res = HTTParty.get("#{ANTIMONY_HOST}/api/cli/command/apps/create?#{query_string}",
|
29
|
-
headers: { "Authorization" => auth })
|
30
|
-
if res.code != 200
|
31
|
-
puts CLI::UI.fmt "{{red:›}} Error: not authorized to create app (#{app_name})"
|
32
|
-
exit 1
|
33
|
-
end
|
34
|
-
app_name = JSON.parse(res.body)["name"]
|
35
|
-
puts "https://#{app_name}.#{region}.antimony.io | #{app_name}"
|
36
|
-
rescue
|
37
|
-
puts CLI::UI.fmt "{{red:›}} Error: not logged in"
|
38
|
-
exit 1
|
175
|
+
user_netrc = Netrc.read
|
176
|
+
user_token = user_netrc.[]("build.io")&.password
|
177
|
+
if user_token.nil?
|
178
|
+
puts(CLI::UI.fmt("{{red:›}} Error: not logged in"))
|
179
|
+
exit(1)
|
180
|
+
end
|
181
|
+
auth = "Bearer #{user_token}"
|
182
|
+
app_name = options.app
|
183
|
+
if app_name.nil?
|
184
|
+
puts(CLI::UI.fmt("{{red:›}} Error: no app name specified"))
|
185
|
+
exit(1)
|
39
186
|
end
|
187
|
+
query_params = {}
|
188
|
+
query_params.[]=(:app, app_name)
|
189
|
+
if options.team
|
190
|
+
query_params.[]=(:team, options.team)
|
191
|
+
end
|
192
|
+
if options.region
|
193
|
+
query_params.[]=(:region, options.region)
|
194
|
+
end
|
195
|
+
if options.stack
|
196
|
+
query_params.[]=(:stack, options.stack)
|
197
|
+
end
|
198
|
+
query_string = URI.encode_www_form(query_params)
|
199
|
+
res = HTTParty.get("#{ANTIMONY_HOST}/api/cli/command/apps/create?#{query_string}",
|
200
|
+
{ headers: { "Authorization" => auth } })
|
201
|
+
if res.code != 200
|
202
|
+
puts(CLI::UI.fmt("{{red:›}} Error: not authorized to create app (#{app_name})"))
|
203
|
+
exit(1)
|
204
|
+
end
|
205
|
+
app_name = JSON.parse(res.body).[]("name")
|
206
|
+
puts("https://#{app_name}.#{region}.antimony.io | #{app_name}")
|
40
207
|
},
|
41
208
|
},
|
42
209
|
"login": {
|
43
210
|
cli_details: { :syntax => "build login", :description => "Login to your Build account", :options => [] },
|
44
211
|
cli_perform: Proc.new { |args, options|
|
45
|
-
input = CLI::UI.any_key(
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
212
|
+
input = CLI::UI.any_key("Press any key to open up the browser to login or q to exit")
|
213
|
+
if input.downcase == "q"
|
214
|
+
exit
|
215
|
+
end
|
216
|
+
(user_token, user_email) = nil
|
217
|
+
CLI::UI::Spinner.spin("Waiting for login") { |spinner,|
|
50
218
|
client_secret = SecureRandom.uuid
|
51
|
-
|
52
219
|
oauth_url = "#{ANTIMONY_HOST}/cli_auth/authorize/#{client_secret}"
|
53
220
|
Launchy.open(oauth_url)
|
54
|
-
|
55
221
|
poll_interval = 1
|
56
222
|
timeout = (5 * 60)
|
57
223
|
start_time = Time.now
|
58
|
-
loop
|
224
|
+
loop {
|
59
225
|
response = HTTParty.get("#{ANTIMONY_HOST}/api/cli_auth/resolve/#{client_secret}")
|
60
|
-
if response.code == 200 && response[
|
226
|
+
if response.code == 200 && response.[]("code") == "unresolved"
|
61
227
|
sleep(poll_interval)
|
62
|
-
elsif response.code == 200 && response['code'] == 'resolved'
|
63
|
-
user_token = response["token"]
|
64
|
-
user_email = response["email"]
|
65
|
-
break
|
66
228
|
else
|
67
|
-
|
229
|
+
if response.code == 200 && response.[]("code") == "resolved"
|
230
|
+
user_token = response.[]("token")
|
231
|
+
user_email = response.[]("email")
|
232
|
+
break
|
233
|
+
else
|
234
|
+
raise("Error: #{response.code}")
|
235
|
+
end
|
68
236
|
end
|
69
|
-
|
70
|
-
|
71
|
-
|
237
|
+
if Time.now - start_time > timeout
|
238
|
+
break
|
239
|
+
end
|
240
|
+
}
|
72
241
|
user_netrc = Netrc.read
|
73
|
-
user_netrc["build.io"
|
242
|
+
user_netrc.[]=("build.io", ["#{user_email}", "#{user_token}"])
|
74
243
|
user_netrc.save
|
75
|
-
|
76
|
-
|
77
|
-
puts CLI::UI.fmt "Logged in as {{green:#{user_email}}}"
|
244
|
+
}
|
245
|
+
puts(CLI::UI.fmt("Logged in as {{green:#{user_email}}}"))
|
78
246
|
},
|
79
247
|
},
|
80
248
|
"logs": {
|
@@ -83,48 +251,54 @@ class BuildCLICommands
|
|
83
251
|
cli_perform: Proc.new { |args, options|
|
84
252
|
app_name = options.app
|
85
253
|
if app_name.nil? || app_name.strip == ""
|
86
|
-
puts
|
87
|
-
puts
|
88
|
-
puts
|
89
|
-
exit
|
254
|
+
puts(CLI::UI.fmt("{{red:›}} Error: The following error occurred:"))
|
255
|
+
puts(CLI::UI.fmt("{{red:›}} {{gray:Missing required flag app}}"))
|
256
|
+
puts(CLI::UI.fmt("{{red:›}} See more help with --help"))
|
257
|
+
exit(1)
|
90
258
|
end
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
rescue
|
97
|
-
puts CLI::UI.fmt "{{red:›}} Error: not logged in"
|
98
|
-
exit 1
|
259
|
+
user_netrc = Netrc.read
|
260
|
+
user_token = user_netrc.[]("build.io")&.password
|
261
|
+
if user_token.nil?
|
262
|
+
puts(CLI::UI.fmt("{{red:›}} Error: not logged in"))
|
263
|
+
exit(1)
|
99
264
|
end
|
100
|
-
|
265
|
+
auth = "Bearer #{user_token}"
|
101
266
|
query_params = {}
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
267
|
+
if options.num
|
268
|
+
query_params.[]=(:num, options.num)
|
269
|
+
end
|
270
|
+
if options.process
|
271
|
+
query_params.[]=(:process, options.process)
|
272
|
+
end
|
273
|
+
if options.source
|
274
|
+
query_params.[]=(:source, options.source)
|
275
|
+
end
|
276
|
+
if options.trace
|
277
|
+
query_params.[]=(:tail, options.trace)
|
278
|
+
end
|
279
|
+
if options.tail
|
280
|
+
query_params.[]=(:tail, options.tail)
|
281
|
+
end
|
108
282
|
query_string = URI.encode_www_form(query_params)
|
109
|
-
|
110
283
|
res = HTTParty.get("#{ANTIMONY_HOST}/api/apps/#{app_name}/logs/log_url?#{query_string}",
|
111
|
-
headers: { "Authorization" => auth })
|
284
|
+
{ headers: { "Authorization" => auth } })
|
112
285
|
if res.code != 200
|
113
|
-
puts
|
114
|
-
puts
|
115
|
-
puts
|
116
|
-
exit
|
117
|
-
end
|
118
|
-
log_url = res["url"]
|
119
|
-
|
120
|
-
res = HTTParty.get(log_url, timeout: 1_000_000) do |fragment|
|
121
|
-
puts fragment unless fragment.empty?
|
286
|
+
puts(CLI::UI.fmt("{{red:›}} Error: Couldn't find that app."))
|
287
|
+
puts(CLI::UI.fmt("{{red:›}}"))
|
288
|
+
puts(CLI::UI.fmt("{{red:›}} Error ID: not_found"))
|
289
|
+
exit(1)
|
122
290
|
end
|
291
|
+
log_url = res.[]("url")
|
292
|
+
res = HTTParty.get(log_url, { timeout: 1000000 }) { |fragment,|
|
293
|
+
unless fragment.empty?
|
294
|
+
puts(fragment)
|
295
|
+
end
|
296
|
+
}
|
123
297
|
if res.code != 200
|
124
|
-
puts
|
125
|
-
puts
|
126
|
-
puts
|
127
|
-
exit
|
298
|
+
puts(CLI::UI.fmt("{{red:›}} Error: Connection to logs failed."))
|
299
|
+
puts(CLI::UI.fmt("{{red:›}}"))
|
300
|
+
puts(CLI::UI.fmt("{{red:›}} Error ID: connection_failed"))
|
301
|
+
exit(1)
|
128
302
|
end
|
129
303
|
},
|
130
304
|
},
|
@@ -132,22 +306,52 @@ class BuildCLICommands
|
|
132
306
|
cli_details: { :syntax => "build whoami", :description => "Display the current logged in user",
|
133
307
|
:options => [] },
|
134
308
|
cli_perform: Proc.new { |args, options|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
309
|
+
user_netrc = Netrc.read
|
310
|
+
user_token = user_netrc.[]("build.io")&.password
|
311
|
+
if user_token.nil?
|
312
|
+
puts(CLI::UI.fmt("{{red:›}} Error: not logged in"))
|
313
|
+
exit(1)
|
314
|
+
end
|
315
|
+
auth = "Bearer #{user_token}"
|
316
|
+
res = HTTParty.get("#{ANTIMONY_HOST}/api/cli/command/whoami",
|
317
|
+
{ headers: { "Authorization" => auth } })
|
318
|
+
if res.code != 200
|
319
|
+
puts(CLI::UI.fmt("{{red:›}} Error: not logged in"))
|
320
|
+
exit(1)
|
321
|
+
end
|
322
|
+
puts(JSON.parse(res.body).[]("email"))
|
323
|
+
},
|
324
|
+
},
|
325
|
+
"run": {
|
326
|
+
cli_details: { :syntax => "build run COMMAND -a <app>", :description => "Run a once-off process in an app",
|
327
|
+
:options => [["-a", "--app=<value>", String, "(required) app to run command against"]] },
|
328
|
+
cli_perform: Proc.new { |args, options|
|
329
|
+
if args.empty?
|
330
|
+
puts(CLI::UI.fmt("{{red:›}} Error: no command provided"))
|
331
|
+
exit(1)
|
332
|
+
end
|
333
|
+
user_netrc = Netrc.read
|
334
|
+
user_token = user_netrc.[]("build.io").[](1)
|
335
|
+
auth = "Bearer #{user_token}"
|
336
|
+
query_params = {}
|
337
|
+
if options.app
|
338
|
+
query_params.[]=(:app, options.app)
|
339
|
+
end
|
340
|
+
query_string = URI.encode_www_form(query_params)
|
341
|
+
res = HTTParty.get("#{ANTIMONY_HOST}/api/cli/command/run?#{query_string}",
|
342
|
+
{ headers: { "Authorization" => auth } })
|
343
|
+
if res.code != 200
|
344
|
+
if res.body.[]("error")
|
345
|
+
puts(CLI::UI.fmt("{{red:›}} Error: #{res.body.[]("error")}"))
|
346
|
+
else
|
347
|
+
puts(CLI::UI.fmt("{{red:›}} Error: not logged in"))
|
145
348
|
end
|
146
|
-
|
147
|
-
rescue
|
148
|
-
puts CLI::UI.fmt "{{red:›}} Error: not logged in"
|
149
|
-
exit 1
|
349
|
+
exit(1)
|
150
350
|
end
|
351
|
+
ruby = JSON.parse(res.body).[]("ruby")
|
352
|
+
require("shellwords")
|
353
|
+
command = "/cnb/lifecycle/launcher #{Shellwords.join(args)}"
|
354
|
+
eval(ruby)
|
151
355
|
},
|
152
356
|
}
|
153
357
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bld
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- usiegl00
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-01
|
11
|
+
date: 2024-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: public_suffix
|
@@ -120,6 +120,26 @@ dependencies:
|
|
120
120
|
- - ">="
|
121
121
|
- !ruby/object:Gem::Version
|
122
122
|
version: 2.5.2
|
123
|
+
- !ruby/object:Gem::Dependency
|
124
|
+
name: net-ssh
|
125
|
+
requirement: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - "~>"
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '6.1'
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: 6.1.0
|
133
|
+
type: :runtime
|
134
|
+
prerelease: false
|
135
|
+
version_requirements: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - "~>"
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '6.1'
|
140
|
+
- - ">="
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: 6.1.0
|
123
143
|
description: CLI for build.io
|
124
144
|
email: 50933431+usiegl00@users.noreply.github.com
|
125
145
|
executables:
|
@@ -135,7 +155,18 @@ homepage: https://build.io
|
|
135
155
|
licenses:
|
136
156
|
- ''
|
137
157
|
metadata: {}
|
138
|
-
post_install_message:
|
158
|
+
post_install_message: |2+
|
159
|
+
|
160
|
+
|
161
|
+
|
162
|
+
██████╗ ██╗ ██╗██╗██╗ ██████╗
|
163
|
+
██╔══██╗██║ ██║██║██║ ██╔══██╗
|
164
|
+
██████╔╝██║ ██║██║██║ ██║ ██║
|
165
|
+
██╔══██╗██║ ██║██║██║ ██║ ██║
|
166
|
+
██████╔╝╚██████╔╝██║███████╗██████╔╝
|
167
|
+
╚═════╝ ╚═════╝ ╚═╝╚══════╝╚═════╝
|
168
|
+
Use `build login` to get started.
|
169
|
+
|
139
170
|
rdoc_options: []
|
140
171
|
require_paths:
|
141
172
|
- lib
|
@@ -155,3 +186,4 @@ signing_key:
|
|
155
186
|
specification_version: 4
|
156
187
|
summary: build cli
|
157
188
|
test_files: []
|
189
|
+
...
|