bld 0.1.1 → 0.1.4
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 +119 -76
- metadata +30 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e58ad6d7f83190c1e03e61c08d300cf30d34ca0a565935c902739712968999b4
|
|
4
|
+
data.tar.gz: e9836c61883993fac85828620cf0129ea2b6fe5e3b2939742189bdd833389c88
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2d103b0fad23903d458d79a6b6b6d5a23ab72ea117ef248511bb7e733d4b9622f91fd11c77b845ec4096ee5024b87f63e45d393ea58762165b6e3976aeb614c7
|
|
7
|
+
data.tar.gz: 9f6a7f68f081c9e66667cf3cb345727e528df706040d6006cdd6e5fc2bffa2dab7bb7bda05e4611d4659fb0780ccfb696e1830770b18b027401d691df011c72a
|
data/bin/bld
CHANGED
|
@@ -19,9 +19,10 @@ class BuildCLI
|
|
|
19
19
|
|
|
20
20
|
def run
|
|
21
21
|
program :name, 'Build CLI'
|
|
22
|
-
program :version, '1.
|
|
22
|
+
program :version, '0.1.4'
|
|
23
23
|
program :description, "Build's Command Line Interface"
|
|
24
24
|
program :int_block, -> { exit }
|
|
25
|
+
default_command :help
|
|
25
26
|
|
|
26
27
|
BuildCLICommands.index.each do |name, entry|
|
|
27
28
|
command name.to_sym do |c|
|
data/bin/build
CHANGED
|
@@ -19,9 +19,10 @@ class BuildCLI
|
|
|
19
19
|
|
|
20
20
|
def run
|
|
21
21
|
program :name, 'Build CLI'
|
|
22
|
-
program :version, '1.
|
|
22
|
+
program :version, '0.1.4'
|
|
23
23
|
program :description, "Build's Command Line Interface"
|
|
24
24
|
program :int_block, -> { exit }
|
|
25
|
+
default_command :help
|
|
25
26
|
|
|
26
27
|
BuildCLICommands.index.each do |name, entry|
|
|
27
28
|
command name.to_sym do |c|
|
data/lib/commands.rb
CHANGED
|
@@ -8,73 +8,76 @@ class BuildCLICommands
|
|
|
8
8
|
cli_perform: Proc.new { |args, options|
|
|
9
9
|
begin
|
|
10
10
|
user_netrc = Netrc.read
|
|
11
|
-
user_token = user_netrc["build.io"]
|
|
11
|
+
user_token = user_netrc.[]("build.io").[](1)
|
|
12
12
|
auth = "Bearer #{user_token}"
|
|
13
|
-
|
|
14
13
|
app_name = options.app
|
|
15
14
|
if app_name.nil?
|
|
16
|
-
puts
|
|
17
|
-
exit
|
|
15
|
+
puts(CLI::UI.fmt("{{red:›}} Error: no app name specified"))
|
|
16
|
+
exit(1)
|
|
18
17
|
end
|
|
19
|
-
|
|
20
18
|
query_params = {}
|
|
21
|
-
query_params[:app
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
query_params.[]=(:app, app_name)
|
|
20
|
+
if options.team
|
|
21
|
+
query_params.[]=(:team, options.team)
|
|
22
|
+
end
|
|
23
|
+
if options.region
|
|
24
|
+
query_params.[]=(:region, options.region)
|
|
25
|
+
end
|
|
26
|
+
if options.stack
|
|
27
|
+
query_params.[]=(:stack, options.stack)
|
|
28
|
+
end
|
|
26
29
|
query_string = URI.encode_www_form(query_params)
|
|
27
|
-
|
|
28
30
|
res = HTTParty.get("#{ANTIMONY_HOST}/api/cli/command/apps/create?#{query_string}",
|
|
29
|
-
headers: { "Authorization" => auth })
|
|
31
|
+
{ headers: { "Authorization" => auth } })
|
|
30
32
|
if res.code != 200
|
|
31
|
-
puts
|
|
32
|
-
exit
|
|
33
|
+
puts(CLI::UI.fmt("{{red:›}} Error: not authorized to create app (#{app_name})"))
|
|
34
|
+
exit(1)
|
|
33
35
|
end
|
|
34
|
-
app_name = JSON.parse(res.body)["name"
|
|
35
|
-
puts
|
|
36
|
+
app_name = JSON.parse(res.body).[]("name")
|
|
37
|
+
puts("https://#{app_name}.#{region}.antimony.io | #{app_name}")
|
|
36
38
|
rescue
|
|
37
|
-
puts
|
|
38
|
-
exit
|
|
39
|
+
puts(CLI::UI.fmt("{{red:›}} Error: not logged in"))
|
|
40
|
+
exit(1)
|
|
39
41
|
end
|
|
40
42
|
},
|
|
41
43
|
},
|
|
42
44
|
"login": {
|
|
43
45
|
cli_details: { :syntax => "build login", :description => "Login to your Build account", :options => [] },
|
|
44
46
|
cli_perform: Proc.new { |args, options|
|
|
45
|
-
input = CLI::UI.any_key(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
input = CLI::UI.any_key("Press any key to open up the browser to login or q to exit")
|
|
48
|
+
if input.downcase == "q"
|
|
49
|
+
exit
|
|
50
|
+
end
|
|
51
|
+
(user_token, user_email) = nil
|
|
52
|
+
CLI::UI::Spinner.spin("Waiting for login") { |spinner,|
|
|
50
53
|
client_secret = SecureRandom.uuid
|
|
51
|
-
|
|
52
54
|
oauth_url = "#{ANTIMONY_HOST}/cli_auth/authorize/#{client_secret}"
|
|
53
55
|
Launchy.open(oauth_url)
|
|
54
|
-
|
|
55
56
|
poll_interval = 1
|
|
56
57
|
timeout = (5 * 60)
|
|
57
58
|
start_time = Time.now
|
|
58
|
-
loop
|
|
59
|
+
loop {
|
|
59
60
|
response = HTTParty.get("#{ANTIMONY_HOST}/api/cli_auth/resolve/#{client_secret}")
|
|
60
|
-
if response.code == 200 && response[
|
|
61
|
+
if response.code == 200 && response.[]("code") == "unresolved"
|
|
61
62
|
sleep(poll_interval)
|
|
62
|
-
elsif response.code == 200 && response['code'] == 'resolved'
|
|
63
|
-
user_token = response["token"]
|
|
64
|
-
user_email = response["email"]
|
|
65
|
-
break
|
|
66
63
|
else
|
|
67
|
-
|
|
64
|
+
if response.code == 200 && response.[]("code") == "resolved"
|
|
65
|
+
user_token = response.[]("token")
|
|
66
|
+
user_email = response.[]("email")
|
|
67
|
+
break
|
|
68
|
+
else
|
|
69
|
+
raise("Error: #{response.code}")
|
|
70
|
+
end
|
|
68
71
|
end
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
+
if Time.now - start_time > timeout
|
|
73
|
+
break
|
|
74
|
+
end
|
|
75
|
+
}
|
|
72
76
|
user_netrc = Netrc.read
|
|
73
|
-
user_netrc["build.io"
|
|
77
|
+
user_netrc.[]=("build.io", ["#{user_email}", "#{user_token}"])
|
|
74
78
|
user_netrc.save
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
puts CLI::UI.fmt "Logged in as {{green:#{user_email}}}"
|
|
79
|
+
}
|
|
80
|
+
puts(CLI::UI.fmt("Logged in as {{green:#{user_email}}}"))
|
|
78
81
|
},
|
|
79
82
|
},
|
|
80
83
|
"logs": {
|
|
@@ -83,48 +86,56 @@ class BuildCLICommands
|
|
|
83
86
|
cli_perform: Proc.new { |args, options|
|
|
84
87
|
app_name = options.app
|
|
85
88
|
if app_name.nil? || app_name.strip == ""
|
|
86
|
-
puts
|
|
87
|
-
puts
|
|
88
|
-
puts
|
|
89
|
-
exit
|
|
89
|
+
puts(CLI::UI.fmt("{{red:›}} Error: The following error occurred:"))
|
|
90
|
+
puts(CLI::UI.fmt("{{red:›}} {{gray:Missing required flag app}}"))
|
|
91
|
+
puts(CLI::UI.fmt("{{red:›}} See more help with --help"))
|
|
92
|
+
exit(1)
|
|
90
93
|
end
|
|
91
94
|
|
|
92
95
|
begin
|
|
93
96
|
user_netrc = Netrc.read
|
|
94
|
-
user_token = user_netrc["build.io"]
|
|
97
|
+
user_token = user_netrc.[]("build.io").[](1)
|
|
95
98
|
auth = "Bearer #{user_token}"
|
|
96
99
|
rescue
|
|
97
|
-
puts
|
|
98
|
-
exit
|
|
100
|
+
puts(CLI::UI.fmt("{{red:›}} Error: not logged in"))
|
|
101
|
+
exit(1)
|
|
99
102
|
end
|
|
100
|
-
|
|
101
103
|
query_params = {}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
104
|
+
if options.num
|
|
105
|
+
query_params.[]=(:num, options.num)
|
|
106
|
+
end
|
|
107
|
+
if options.process
|
|
108
|
+
query_params.[]=(:process, options.process)
|
|
109
|
+
end
|
|
110
|
+
if options.source
|
|
111
|
+
query_params.[]=(:source, options.source)
|
|
112
|
+
end
|
|
113
|
+
if options.trace
|
|
114
|
+
query_params.[]=(:tail, options.trace)
|
|
115
|
+
end
|
|
116
|
+
if options.tail
|
|
117
|
+
query_params.[]=(:tail, options.tail)
|
|
118
|
+
end
|
|
108
119
|
query_string = URI.encode_www_form(query_params)
|
|
109
|
-
|
|
110
120
|
res = HTTParty.get("#{ANTIMONY_HOST}/api/apps/#{app_name}/logs/log_url?#{query_string}",
|
|
111
|
-
headers: { "Authorization" => auth })
|
|
121
|
+
{ headers: { "Authorization" => auth } })
|
|
112
122
|
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?
|
|
123
|
+
puts(CLI::UI.fmt("{{red:›}} Error: Couldn't find that app."))
|
|
124
|
+
puts(CLI::UI.fmt("{{red:›}}"))
|
|
125
|
+
puts(CLI::UI.fmt("{{red:›}} Error ID: not_found"))
|
|
126
|
+
exit(1)
|
|
122
127
|
end
|
|
128
|
+
log_url = res.[]("url")
|
|
129
|
+
res = HTTParty.get(log_url, { timeout: 1000000 }) { |fragment,|
|
|
130
|
+
unless fragment.empty?
|
|
131
|
+
puts(fragment)
|
|
132
|
+
end
|
|
133
|
+
}
|
|
123
134
|
if res.code != 200
|
|
124
|
-
puts
|
|
125
|
-
puts
|
|
126
|
-
puts
|
|
127
|
-
exit
|
|
135
|
+
puts(CLI::UI.fmt("{{red:›}} Error: Connection to logs failed."))
|
|
136
|
+
puts(CLI::UI.fmt("{{red:›}}"))
|
|
137
|
+
puts(CLI::UI.fmt("{{red:›}} Error ID: connection_failed"))
|
|
138
|
+
exit(1)
|
|
128
139
|
end
|
|
129
140
|
},
|
|
130
141
|
},
|
|
@@ -134,19 +145,51 @@ class BuildCLICommands
|
|
|
134
145
|
cli_perform: Proc.new { |args, options|
|
|
135
146
|
begin
|
|
136
147
|
user_netrc = Netrc.read
|
|
137
|
-
user_token = user_netrc["build.io"]
|
|
148
|
+
user_token = user_netrc.[]("build.io").[](1)
|
|
138
149
|
auth = "Bearer #{user_token}"
|
|
139
|
-
|
|
140
150
|
res = HTTParty.get("#{ANTIMONY_HOST}/api/cli/command/whoami",
|
|
141
|
-
headers: { "Authorization" => auth })
|
|
151
|
+
{ headers: { "Authorization" => auth } })
|
|
152
|
+
if res.code != 200
|
|
153
|
+
puts(CLI::UI.fmt("{{red:›}} Error: not logged in"))
|
|
154
|
+
exit(1)
|
|
155
|
+
end
|
|
156
|
+
puts(JSON.parse(res.body).[]("email"))
|
|
157
|
+
rescue
|
|
158
|
+
puts(CLI::UI.fmt("{{red:›}} Error: not logged in"))
|
|
159
|
+
exit(1)
|
|
160
|
+
end
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
"run": {
|
|
164
|
+
cli_details: { :syntax => "build run COMMAND -a <app>", :description => "Run a once-off process in an app",
|
|
165
|
+
:options => [["-a", "--app=<value>", String, "(required) app to run command against"]] },
|
|
166
|
+
cli_perform: Proc.new { |args, options|
|
|
167
|
+
begin
|
|
168
|
+
if args.empty?
|
|
169
|
+
puts(CLI::UI.fmt("{{red:›}} Error: no command provided"))
|
|
170
|
+
exit(1)
|
|
171
|
+
end
|
|
172
|
+
user_netrc = Netrc.read
|
|
173
|
+
user_token = user_netrc.[]("build.io").[](1)
|
|
174
|
+
auth = "Bearer #{user_token}"
|
|
175
|
+
query_params = {}
|
|
176
|
+
if options.app
|
|
177
|
+
query_params.[]=(:app, options.app)
|
|
178
|
+
end
|
|
179
|
+
query_string = URI.encode_www_form(query_params)
|
|
180
|
+
res = HTTParty.get("#{ANTIMONY_HOST}/api/cli/command/run?#{query_string}",
|
|
181
|
+
{ headers: { "Authorization" => auth } })
|
|
142
182
|
if res.code != 200
|
|
143
|
-
puts
|
|
144
|
-
exit
|
|
183
|
+
puts(CLI::UI.fmt("{{red:›}} Error: app not found"))
|
|
184
|
+
exit(1)
|
|
145
185
|
end
|
|
146
|
-
|
|
186
|
+
ruby = JSON.parse(res.body).[]("ruby")
|
|
187
|
+
require("shellwords")
|
|
188
|
+
command = "/cnb/lifecycle/launcher #{Shellwords.join(args)}"
|
|
189
|
+
eval(ruby)
|
|
147
190
|
rescue
|
|
148
|
-
puts
|
|
149
|
-
exit
|
|
191
|
+
puts(CLI::UI.fmt("{{red:›}} Error: not logged in"))
|
|
192
|
+
exit(1)
|
|
150
193
|
end
|
|
151
194
|
},
|
|
152
195
|
}
|
metadata
CHANGED
|
@@ -1,15 +1,29 @@
|
|
|
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.4
|
|
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-01-30 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: public_suffix
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - '='
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: 4.0.7
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - '='
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: 4.0.7
|
|
13
27
|
- !ruby/object:Gem::Dependency
|
|
14
28
|
name: mini_mime
|
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -121,7 +135,18 @@ homepage: https://build.io
|
|
|
121
135
|
licenses:
|
|
122
136
|
- ''
|
|
123
137
|
metadata: {}
|
|
124
|
-
post_install_message:
|
|
138
|
+
post_install_message: |2+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
██████╗ ██╗ ██╗██╗██╗ ██████╗
|
|
143
|
+
██╔══██╗██║ ██║██║██║ ██╔══██╗
|
|
144
|
+
██████╔╝██║ ██║██║██║ ██║ ██║
|
|
145
|
+
██╔══██╗██║ ██║██║██║ ██║ ██║
|
|
146
|
+
██████╔╝╚██████╔╝██║███████╗██████╔╝
|
|
147
|
+
╚═════╝ ╚═════╝ ╚═╝╚══════╝╚═════╝
|
|
148
|
+
Use `build login` to get started.
|
|
149
|
+
|
|
125
150
|
rdoc_options: []
|
|
126
151
|
require_paths:
|
|
127
152
|
- lib
|
|
@@ -136,8 +161,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
136
161
|
- !ruby/object:Gem::Version
|
|
137
162
|
version: '0'
|
|
138
163
|
requirements: []
|
|
139
|
-
rubygems_version: 3.
|
|
164
|
+
rubygems_version: 3.4.21
|
|
140
165
|
signing_key:
|
|
141
166
|
specification_version: 4
|
|
142
167
|
summary: build cli
|
|
143
168
|
test_files: []
|
|
169
|
+
...
|