bld 0.1.4 → 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 +2 -1
- data/bin/build +2 -1
- data/lib/commands.rb +231 -70
- metadata +22 -2
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,7 +20,7 @@ class BuildCLI
|
|
19
20
|
|
20
21
|
def run
|
21
22
|
program :name, 'Build CLI'
|
22
|
-
program :version, '0.1.
|
23
|
+
program :version, '0.1.6'
|
23
24
|
program :description, "Build's Command Line Interface"
|
24
25
|
program :int_block, -> { exit }
|
25
26
|
default_command :help
|
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,7 +20,7 @@ class BuildCLI
|
|
19
20
|
|
20
21
|
def run
|
21
22
|
program :name, 'Build CLI'
|
22
|
-
program :version, '0.1.
|
23
|
+
program :version, '0.1.6'
|
23
24
|
program :description, "Build's Command Line Interface"
|
24
25
|
program :int_block, -> { exit }
|
25
26
|
default_command :help
|
data/lib/commands.rb
CHANGED
@@ -2,43 +2,208 @@
|
|
2
2
|
class BuildCLICommands
|
3
3
|
def self.index
|
4
4
|
return {
|
5
|
-
"
|
6
|
-
cli_details: { :syntax => "
|
7
|
-
:options => [["-
|
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
8
|
cli_perform: Proc.new { |args, options|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
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"))
|
16
34
|
exit(1)
|
17
35
|
end
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
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)
|
25
80
|
end
|
26
|
-
|
27
|
-
|
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"))
|
28
123
|
end
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
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"))
|
35
165
|
end
|
36
|
-
|
37
|
-
|
38
|
-
|
166
|
+
exit(1)
|
167
|
+
end
|
168
|
+
puts(CLI::UI.fmt("{{green:›}} Config variable(s) unset successfully"))
|
169
|
+
},
|
170
|
+
},
|
171
|
+
"apps:create": {
|
172
|
+
cli_details: { :syntax => "apps:create [options] -a <app>", :description => "Create a new app",
|
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"]] },
|
174
|
+
cli_perform: Proc.new { |args, options|
|
175
|
+
user_netrc = Netrc.read
|
176
|
+
user_token = user_netrc.[]("build.io")&.password
|
177
|
+
if user_token.nil?
|
39
178
|
puts(CLI::UI.fmt("{{red:›}} Error: not logged in"))
|
40
179
|
exit(1)
|
41
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)
|
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}")
|
42
207
|
},
|
43
208
|
},
|
44
209
|
"login": {
|
@@ -91,15 +256,13 @@ class BuildCLICommands
|
|
91
256
|
puts(CLI::UI.fmt("{{red:›}} See more help with --help"))
|
92
257
|
exit(1)
|
93
258
|
end
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
user_token = user_netrc.[]("build.io").[](1)
|
98
|
-
auth = "Bearer #{user_token}"
|
99
|
-
rescue
|
259
|
+
user_netrc = Netrc.read
|
260
|
+
user_token = user_netrc.[]("build.io")&.password
|
261
|
+
if user_token.nil?
|
100
262
|
puts(CLI::UI.fmt("{{red:›}} Error: not logged in"))
|
101
263
|
exit(1)
|
102
264
|
end
|
265
|
+
auth = "Bearer #{user_token}"
|
103
266
|
query_params = {}
|
104
267
|
if options.num
|
105
268
|
query_params.[]=(:num, options.num)
|
@@ -143,54 +306,52 @@ class BuildCLICommands
|
|
143
306
|
cli_details: { :syntax => "build whoami", :description => "Display the current logged in user",
|
144
307
|
:options => [] },
|
145
308
|
cli_perform: Proc.new { |args, options|
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
puts(JSON.parse(res.body).[]("email"))
|
157
|
-
rescue
|
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
|
158
319
|
puts(CLI::UI.fmt("{{red:›}} Error: not logged in"))
|
159
320
|
exit(1)
|
160
321
|
end
|
322
|
+
puts(JSON.parse(res.body).[]("email"))
|
161
323
|
},
|
162
324
|
},
|
163
325
|
"run": {
|
164
326
|
cli_details: { :syntax => "build run COMMAND -a <app>", :description => "Run a once-off process in an app",
|
165
327
|
:options => [["-a", "--app=<value>", String, "(required) app to run command against"]] },
|
166
328
|
cli_perform: Proc.new { |args, options|
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
if res.
|
183
|
-
puts(CLI::UI.fmt("{{red:›}} Error:
|
184
|
-
|
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"))
|
185
348
|
end
|
186
|
-
ruby = JSON.parse(res.body).[]("ruby")
|
187
|
-
require("shellwords")
|
188
|
-
command = "/cnb/lifecycle/launcher #{Shellwords.join(args)}"
|
189
|
-
eval(ruby)
|
190
|
-
rescue
|
191
|
-
puts(CLI::UI.fmt("{{red:›}} Error: not logged in"))
|
192
349
|
exit(1)
|
193
350
|
end
|
351
|
+
ruby = JSON.parse(res.body).[]("ruby")
|
352
|
+
require("shellwords")
|
353
|
+
command = "/cnb/lifecycle/launcher #{Shellwords.join(args)}"
|
354
|
+
eval(ruby)
|
194
355
|
},
|
195
356
|
}
|
196
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:
|