jets-api 0.2.0 → 0.2.1
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/CHANGELOG.md +4 -0
- data/lib/jets/api/agree.rb +7 -7
- data/lib/jets/api/autoloader.rb +2 -2
- data/lib/jets/api/client.rb +1 -1
- data/lib/jets/api/config.rb +6 -6
- data/lib/jets/api/core.rb +17 -15
- data/lib/jets/api/gems/check.rb +40 -40
- data/lib/jets/api/gems/exist.rb +1 -1
- data/lib/jets/api/gems/extract/base.rb +5 -5
- data/lib/jets/api/gems/extract/gem.rb +65 -7
- data/lib/jets/api/gems/registered.rb +1 -1
- data/lib/jets/api/gems/report.rb +1 -1
- data/lib/jets/api/gems.rb +6 -6
- data/lib/jets/api/project.rb +1 -1
- data/lib/jets/api/release.rb +3 -3
- data/lib/jets/api/stack.rb +3 -3
- data/lib/jets/api/version.rb +1 -1
- data/lib/jets/api.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e69a0ae2689dddcba856316946b3d2819837d05a542b69bf33bbf025f7117d08
|
4
|
+
data.tar.gz: 0cf8e60cd2423ff63e8aed0f083ae25712a01d2245becae511fcd206dff00a15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b85423d5ffa43da256e6429f98efd7c0371cefe43c15091604f0e25790ac6551ee6292e22290982468fe5964570954ee163f657a2f25ec103d20e4ad82f10801
|
7
|
+
data.tar.gz: 3e0297e48ab73fbab862d65de8240ceaa26bc4d7f175860d26d46d49cf6f898618a0c0776401f4d6c2ac9b1af62dfd255daec5294f278b0ea875ae0f788168d8
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,10 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
This project *tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
|
5
5
|
|
6
|
+
## [0.2.1] - 2025-10-11
|
7
|
+
- fix gem detection ffi - gnu suffix and clean up incompatible platform variants
|
8
|
+
- standardrb
|
9
|
+
|
6
10
|
## [0.2.0] - 2024-01-09
|
7
11
|
- [#2](https://github.com/rubyonjets/jets-api/pull/2) improve gem check with arm aarch64-linux
|
8
12
|
|
data/lib/jets/api/agree.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Jets::Api
|
2
2
|
class Agree
|
3
3
|
def initialize
|
4
|
-
@agree_file = "#{ENV[
|
4
|
+
@agree_file = "#{ENV["HOME"]}/.jets/agree"
|
5
5
|
end
|
6
6
|
|
7
7
|
# Only prompts if hasnt prompted before and saved a ~/.jets/agree file
|
@@ -32,7 +32,7 @@ module Jets::Api
|
|
32
32
|
EOL
|
33
33
|
|
34
34
|
answer = $stdin.gets.strip
|
35
|
-
value =
|
35
|
+
value = /y/i.match?(answer) ? "yes" : "no"
|
36
36
|
|
37
37
|
write_file(value)
|
38
38
|
end
|
@@ -40,24 +40,24 @@ module Jets::Api
|
|
40
40
|
# Allow user to bypass prompt with JETS_AGREE=1 JETS_AGREE=yes etc
|
41
41
|
# Useful for CI/CD pipelines.
|
42
42
|
def bypass_prompt
|
43
|
-
agree = ENV[
|
43
|
+
agree = ENV["JETS_AGREE"]
|
44
44
|
return false unless agree
|
45
45
|
|
46
46
|
if %w[1 yes true].include?(agree.downcase)
|
47
|
-
write_file(
|
47
|
+
write_file("yes")
|
48
48
|
else
|
49
|
-
write_file(
|
49
|
+
write_file("no")
|
50
50
|
end
|
51
51
|
|
52
52
|
true
|
53
53
|
end
|
54
54
|
|
55
55
|
def yes?
|
56
|
-
File.exist?(@agree_file) && IO.read(@agree_file).strip ==
|
56
|
+
File.exist?(@agree_file) && IO.read(@agree_file).strip == "yes"
|
57
57
|
end
|
58
58
|
|
59
59
|
def no?
|
60
|
-
File.exist?(@agree_file) && IO.read(@agree_file).strip ==
|
60
|
+
File.exist?(@agree_file) && IO.read(@agree_file).strip == "no"
|
61
61
|
end
|
62
62
|
|
63
63
|
def yes!
|
data/lib/jets/api/autoloader.rb
CHANGED
@@ -6,7 +6,7 @@ module Jets
|
|
6
6
|
class Autoloader
|
7
7
|
class Inflector < Zeitwerk::Inflector
|
8
8
|
def camelize(basename, _abspath)
|
9
|
-
map = {
|
9
|
+
map = {cli: "CLI", version: "VERSION"}
|
10
10
|
map[basename.to_sym] || super
|
11
11
|
end
|
12
12
|
end
|
@@ -15,7 +15,7 @@ module Jets
|
|
15
15
|
def setup
|
16
16
|
loader = Zeitwerk::Loader.new
|
17
17
|
loader.inflector = Inflector.new
|
18
|
-
lib = File.expand_path(
|
18
|
+
lib = File.expand_path("../..", __dir__)
|
19
19
|
loader.push_dir(lib) # lib
|
20
20
|
loader.ignore("#{lib}/jets-api.rb")
|
21
21
|
loader.setup
|
data/lib/jets/api/client.rb
CHANGED
data/lib/jets/api/config.rb
CHANGED
@@ -5,13 +5,13 @@ module Jets::Api
|
|
5
5
|
include Singleton
|
6
6
|
extend Memoist
|
7
7
|
|
8
|
-
def initialize(options={})
|
8
|
+
def initialize(options = {})
|
9
9
|
@options = options
|
10
|
-
@config_path = "#{ENV[
|
10
|
+
@config_path = "#{ENV["HOME"]}/.jets/config.yml"
|
11
11
|
end
|
12
12
|
|
13
13
|
def token
|
14
|
-
data[
|
14
|
+
data["token"] || data["key"] # keep key for backwards compatibility
|
15
15
|
end
|
16
16
|
|
17
17
|
def data
|
@@ -41,12 +41,12 @@ module Jets::Api
|
|
41
41
|
end
|
42
42
|
|
43
43
|
# interface method: do not remove
|
44
|
-
def update_token(token=nil)
|
44
|
+
def update_token(token = nil)
|
45
45
|
token ||= prompt
|
46
46
|
write(key: token) # specify keys to allow
|
47
47
|
end
|
48
48
|
|
49
|
-
def write(values={})
|
49
|
+
def write(values = {})
|
50
50
|
data = load
|
51
51
|
data.merge!(values.deep_stringify_keys)
|
52
52
|
FileUtils.mkdir_p(File.dirname(@config_path))
|
@@ -55,7 +55,7 @@ module Jets::Api
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def pretty_path(path)
|
58
|
-
path.sub(ENV[
|
58
|
+
path.sub(ENV["HOME"], "~")
|
59
59
|
end
|
60
60
|
end
|
61
61
|
end
|
data/lib/jets/api/core.rb
CHANGED
@@ -7,7 +7,7 @@ module Jets::Api
|
|
7
7
|
@@max_retries = 3
|
8
8
|
|
9
9
|
# Always translate raw json response to ruby Hash
|
10
|
-
def request(klass, path, data={})
|
10
|
+
def request(klass, path, data = {})
|
11
11
|
raw_response = data.delete(:raw_response)
|
12
12
|
url = url(path)
|
13
13
|
req = build_request(klass, url, data)
|
@@ -19,7 +19,7 @@ module Jets::Api
|
|
19
19
|
@retries += 1
|
20
20
|
if @retries <= @@max_retries
|
21
21
|
delay = 2**@retries
|
22
|
-
puts "Error: #{e.class} #{e.message} retrying after #{delay} seconds..." if ENV[
|
22
|
+
puts "Error: #{e.class} #{e.message} retrying after #{delay} seconds..." if ENV["JETS_API_DEBUG"]
|
23
23
|
sleep delay
|
24
24
|
retry
|
25
25
|
else
|
@@ -29,7 +29,7 @@ module Jets::Api
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
def build_request(klass, url, data={})
|
32
|
+
def build_request(klass, url, data = {})
|
33
33
|
req = klass.new(url) # url includes query string and uri.path does not, must used url
|
34
34
|
set_headers!(req)
|
35
35
|
if [Net::HTTP::Delete, Net::HTTP::Patch, Net::HTTP::Post, Net::HTTP::Put].include?(klass)
|
@@ -41,9 +41,9 @@ module Jets::Api
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def set_headers!(req)
|
44
|
-
req[
|
45
|
-
req[
|
46
|
-
req[
|
44
|
+
req["Authorization"] = token if token
|
45
|
+
req["x-account"] = account if account
|
46
|
+
req["Content-Type"] = "application/vnd.api+json"
|
47
47
|
end
|
48
48
|
|
49
49
|
def token
|
@@ -52,7 +52,7 @@ module Jets::Api
|
|
52
52
|
|
53
53
|
def load_json(url, res)
|
54
54
|
uri = URI(url)
|
55
|
-
if ENV[
|
55
|
+
if ENV["JETS_API_DEBUG"]
|
56
56
|
puts "res.code #{res.code}"
|
57
57
|
puts "res.body #{res.body}"
|
58
58
|
end
|
@@ -61,7 +61,7 @@ module Jets::Api
|
|
61
61
|
else
|
62
62
|
puts "Error: Non-successful http response status code: #{res.code}"
|
63
63
|
puts "headers: #{res.each_header.to_h.inspect}"
|
64
|
-
puts "Jets API #{url}" if ENV[
|
64
|
+
puts "Jets API #{url}" if ENV["JETS_API_DEBUG"]
|
65
65
|
raise "Jets API called failed: #{uri.host}"
|
66
66
|
end
|
67
67
|
end
|
@@ -77,7 +77,7 @@ module Jets::Api
|
|
77
77
|
uri = URI(endpoint)
|
78
78
|
http = Net::HTTP.new(uri.host, uri.port)
|
79
79
|
http.open_timeout = http.read_timeout = 30
|
80
|
-
http.use_ssl = true if uri.scheme ==
|
80
|
+
http.use_ssl = true if uri.scheme == "https"
|
81
81
|
http
|
82
82
|
end
|
83
83
|
memoize :http
|
@@ -87,31 +87,33 @@ module Jets::Api
|
|
87
87
|
"#{endpoint}/#{path}"
|
88
88
|
end
|
89
89
|
|
90
|
-
def get(path, query={})
|
90
|
+
def get(path, query = {})
|
91
91
|
path = path_with_query(path, query)
|
92
92
|
request(Net::HTTP::Get, path, raw_response: query[:raw_response])
|
93
93
|
end
|
94
94
|
|
95
|
-
def path_with_query(path, query={})
|
95
|
+
def path_with_query(path, query = {})
|
96
96
|
return path if query.empty?
|
97
97
|
separator = path.include?("?") ? "&" : "?"
|
98
98
|
"#{path}#{separator}#{query.to_query}"
|
99
99
|
end
|
100
100
|
|
101
|
-
def post(path, data={})
|
101
|
+
def post(path, data = {})
|
102
102
|
request(Net::HTTP::Post, path, data)
|
103
103
|
end
|
104
104
|
|
105
|
-
def patch(path, data={})
|
105
|
+
def patch(path, data = {})
|
106
106
|
request(Net::HTTP::Patch, path, data)
|
107
107
|
end
|
108
108
|
|
109
|
-
def delete(path, data={})
|
109
|
+
def delete(path, data = {})
|
110
110
|
request(Net::HTTP::Delete, path, data)
|
111
111
|
end
|
112
112
|
|
113
113
|
def account
|
114
|
-
sts.get_caller_identity.account
|
114
|
+
sts.get_caller_identity.account
|
115
|
+
rescue
|
116
|
+
nil
|
115
117
|
end
|
116
118
|
memoize :account
|
117
119
|
|
data/lib/jets/api/gems/check.rb
CHANGED
@@ -6,7 +6,7 @@ class Jets::Api::Gems
|
|
6
6
|
extend Memoist
|
7
7
|
|
8
8
|
attr_reader :missing_gems
|
9
|
-
def initialize(options={})
|
9
|
+
def initialize(options = {})
|
10
10
|
@options = options
|
11
11
|
@missing_gems = [] # keeps track of gems that are not found in any of the Jets Api source
|
12
12
|
end
|
@@ -33,7 +33,7 @@ class Jets::Api::Gems
|
|
33
33
|
# Better to error now than deploy a broken package to AWS Lambda.
|
34
34
|
# Apivide users with message about missing gems.
|
35
35
|
puts missing_message
|
36
|
-
names = @missing_gems.map {|i| i[
|
36
|
+
names = @missing_gems.map { |i| i["gem_name"] }
|
37
37
|
Report.new(@options).report(names) if agree.yes?
|
38
38
|
exit 1
|
39
39
|
end
|
@@ -46,37 +46,37 @@ class Jets::Api::Gems
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def missing_message
|
49
|
-
template =
|
50
|
-
Your project requires compiled gems that are not currently available. Unavailable precompiled gems:
|
51
|
-
<% missing_gems.each do |missing_gem|
|
52
|
-
|
53
|
-
%>
|
54
|
-
* Unavailable: <%= missing_gem['gem_name'] -%> Available versions: <%= available.join(' ') %>
|
55
|
-
<% end %>
|
56
|
-
Your current Jets API endpoint: #{endpoint}
|
57
|
-
|
58
|
-
Jets is unable to build a deployment package that will work on AWS Lambda without the required precompiled gems.
|
59
|
-
To remedy this, you can:
|
60
|
-
|
61
|
-
* Use another gem that does not require compilation.
|
62
|
-
* Create your own custom layer with the gem: http://rubyonjets.com/docs/extras/custom-lambda-layers/
|
63
|
-
<% if agree.yes? -%>
|
64
|
-
* No need to report this to us, as we've already been notified.
|
65
|
-
* Usually, missing gems can be built within a few minutes.
|
66
|
-
* Some gems may take days or even longer.
|
67
|
-
<% elsif agree.no? -%>
|
68
|
-
* You have choosen not to report data to Jets Api so we will not be notified about these missing gems.
|
69
|
-
* You can edit ~/.jets/agree to change this.
|
70
|
-
* Reporting gems generally allows Jets Api to build the missing gems within a few minutes.
|
71
|
-
* You can try redeploying again after a few minutes.
|
72
|
-
* Non-reported gems may take days or even longer to be built.
|
73
|
-
<% end -%>
|
74
|
-
|
75
|
-
Compiled gems usually take some time to figure out how to build as they each depend on different libraries and packages.
|
76
|
-
More info: https://docs.rubyonjets.com/docs/pro/
|
77
|
-
|
78
|
-
EOL
|
79
|
-
erb = ERB.new(template, trim_mode:
|
49
|
+
template = <<~EOL
|
50
|
+
Your project requires compiled gems that are not currently available. Unavailable precompiled gems:
|
51
|
+
<% missing_gems.each do |missing_gem|
|
52
|
+
available = missing_gem['available'].reject { |v| missing_gem['gem_name'].include?(v) }
|
53
|
+
%>
|
54
|
+
* Unavailable: <%= missing_gem['gem_name'] -%> Available versions: <%= available.join(' ') %>
|
55
|
+
<% end %>
|
56
|
+
Your current Jets API endpoint: #{endpoint}
|
57
|
+
|
58
|
+
Jets is unable to build a deployment package that will work on AWS Lambda without the required precompiled gems.
|
59
|
+
To remedy this, you can:
|
60
|
+
|
61
|
+
* Use another gem that does not require compilation.
|
62
|
+
* Create your own custom layer with the gem: http://rubyonjets.com/docs/extras/custom-lambda-layers/
|
63
|
+
<% if agree.yes? -%>
|
64
|
+
* No need to report this to us, as we've already been notified.
|
65
|
+
* Usually, missing gems can be built within a few minutes.
|
66
|
+
* Some gems may take days or even longer.
|
67
|
+
<% elsif agree.no? -%>
|
68
|
+
* You have choosen not to report data to Jets Api so we will not be notified about these missing gems.
|
69
|
+
* You can edit ~/.jets/agree to change this.
|
70
|
+
* Reporting gems generally allows Jets Api to build the missing gems within a few minutes.
|
71
|
+
* You can try redeploying again after a few minutes.
|
72
|
+
* Non-reported gems may take days or even longer to be built.
|
73
|
+
<% end -%>
|
74
|
+
|
75
|
+
Compiled gems usually take some time to figure out how to build as they each depend on different libraries and packages.
|
76
|
+
More info: https://docs.rubyonjets.com/docs/pro/
|
77
|
+
|
78
|
+
EOL
|
79
|
+
erb = ERB.new(template, trim_mode: "-") # trim mode https://stackoverflow.com/questions/4632879/erb-template-removing-the-trailing-line
|
80
80
|
erb.result(binding)
|
81
81
|
end
|
82
82
|
|
@@ -122,7 +122,7 @@ EOL
|
|
122
122
|
# gems though that exhibit this behavior.
|
123
123
|
if @options[:use_gemspec] == false
|
124
124
|
# Afterburner mode
|
125
|
-
|
125
|
+
compiled_gem_paths.map { |p| gem_name_from_path(p) }.uniq
|
126
126
|
# Double check that the gems are also in the gemspec list since that
|
127
127
|
# one is scoped to Bundler and will only included gems used in the project.
|
128
128
|
# This handles the possiblity of stale gems leftover from previous builds
|
@@ -157,10 +157,10 @@ EOL
|
|
157
157
|
# On new 2021 macbook with m1 chip: the gems are being saved in a folder like so:
|
158
158
|
# nokogiri-1.12.5-arm64-darwin
|
159
159
|
# The GEM_REGEXP accounts for this case.
|
160
|
-
GEM_REGEXP = /-(arm|x|aarch)\d+.*-(darwin|linux)
|
160
|
+
GEM_REGEXP = /-(arm|x|aarch)\d+.*-(darwin|linux)(?:-gnu)?/
|
161
161
|
def other_compiled_gems
|
162
|
-
paths = Dir.glob("#{Jets.build_root}/stage/opt/ruby/gems/#{Jets::Api::Gems.ruby_folder}/gems/*{-darwin,-linux}")
|
163
|
-
paths.map { |p| File.basename(p).sub(GEM_REGEXP,
|
162
|
+
paths = Dir.glob("#{Jets.build_root}/stage/opt/ruby/gems/#{Jets::Api::Gems.ruby_folder}/gems/*{-darwin,-linux}*")
|
163
|
+
paths.map { |p| File.basename(p).sub(GEM_REGEXP, "") }
|
164
164
|
end
|
165
165
|
|
166
166
|
def registered_compiled_gems
|
@@ -168,9 +168,9 @@ EOL
|
|
168
168
|
registered_gems = registered.all # no version numbers in this list
|
169
169
|
|
170
170
|
paths = Dir.glob("#{Jets.build_root}/stage/opt/ruby/gems/#{Jets::Api::Gems.ruby_folder}/gems/*")
|
171
|
-
project_gems = paths.map { |p| File.basename(p).sub(GEM_REGEXP,
|
171
|
+
project_gems = paths.map { |p| File.basename(p).sub(GEM_REGEXP, "") }
|
172
172
|
project_gems.select do |name|
|
173
|
-
name_only = name.sub(/-\d+\.\d+\.\d+.*/,
|
173
|
+
name_only = name.sub(/-\d+\.\d+\.\d+.*/, "")
|
174
174
|
registered_gems.include?(name_only)
|
175
175
|
end
|
176
176
|
end
|
@@ -211,7 +211,7 @@ EOL
|
|
211
211
|
# Thanks: https://gist.github.com/aelesbao/1414b169a79162b1d795 and
|
212
212
|
# https://stackoverflow.com/questions/5165950/how-do-i-get-a-list-of-gems-that-are-installed-that-have-native-extensions
|
213
213
|
def gemspec_compiled_gems
|
214
|
-
specs = Gem::Specification.each.select { |spec| spec.extensions.any?
|
214
|
+
specs = Gem::Specification.each.select { |spec| spec.extensions.any? }
|
215
215
|
specs.reject! { |spec| weird_gem?(spec.name) }
|
216
216
|
specs.map(&:full_name)
|
217
217
|
end
|
data/lib/jets/api/gems/exist.rb
CHANGED
@@ -7,7 +7,7 @@ class Jets::Api::Gems
|
|
7
7
|
Jets::Api::Gems.exist(gem_name: gem_name) # data = {"exist": ..., "available"}
|
8
8
|
rescue Jets::Api::RequestError => e
|
9
9
|
puts "WARNING: #{e.class}: #{e.message}"
|
10
|
-
{"exist" => false, gem_name
|
10
|
+
{"exist" => false, :gem_name => gem_name, :available => []}
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
@@ -5,7 +5,7 @@ module Jets::Api::Gems::Extract
|
|
5
5
|
class NotFound < RuntimeError; end
|
6
6
|
|
7
7
|
attr_reader :project_root
|
8
|
-
def initialize(name, options={})
|
8
|
+
def initialize(name, options = {})
|
9
9
|
@name = name
|
10
10
|
@options = options
|
11
11
|
ruby_folder = Jets::Api::Gems.ruby_folder
|
@@ -35,17 +35,17 @@ module Jets::Api::Gems::Extract
|
|
35
35
|
|
36
36
|
# Returns the dest path
|
37
37
|
def download_file(url, dest)
|
38
|
-
if File.exist?(dest) && ENV[
|
38
|
+
if File.exist?(dest) && ENV["JETS_API_FORCE_DOWNLOAD"].blank?
|
39
39
|
say "File already downloaded #{dest}"
|
40
40
|
return dest
|
41
41
|
end
|
42
42
|
|
43
43
|
say "Downloading..."
|
44
|
-
downloaded = URI.open(url,
|
44
|
+
downloaded = URI.open(url, "rb") { |read_file| read_file.read }
|
45
45
|
|
46
46
|
FileUtils.mkdir_p(File.dirname(dest)) # ensure parent folder exists
|
47
47
|
|
48
|
-
File.
|
48
|
+
File.binwrite(dest, downloaded)
|
49
49
|
|
50
50
|
dest
|
51
51
|
end
|
@@ -56,7 +56,7 @@ module Jets::Api::Gems::Extract
|
|
56
56
|
@@log_level = val
|
57
57
|
end
|
58
58
|
|
59
|
-
def say(message, level
|
59
|
+
def say(message, level = :info)
|
60
60
|
enabled = @@log_level == :debug || level == :debug
|
61
61
|
puts(message) if enabled
|
62
62
|
end
|
@@ -19,6 +19,64 @@ module Jets::Api::Gems::Extract
|
|
19
19
|
say "Unpacking into #{dest}"
|
20
20
|
FileUtils.mkdir_p(dest)
|
21
21
|
unzip(zipfile_path, dest)
|
22
|
+
cleanup_incompatible_platform_variants
|
23
|
+
end
|
24
|
+
|
25
|
+
# Removes incompatible platform variants to prevent RubyGems from choosing the wrong one
|
26
|
+
# For AWS Lambda, we want to keep only x86_64-linux variants and remove others
|
27
|
+
def cleanup_incompatible_platform_variants
|
28
|
+
gems_dir = "#{Jets.build_root}/stage/opt/ruby/gems/#{Jets::Api::Gems.ruby_folder}/gems"
|
29
|
+
specs_dir = "#{Jets.build_root}/stage/opt/ruby/gems/#{Jets::Api::Gems.ruby_folder}/specifications"
|
30
|
+
return unless Dir.exist?(gems_dir)
|
31
|
+
|
32
|
+
# Find all gem directories for this gem name
|
33
|
+
gem_dirs = Dir.glob("#{gems_dir}/#{gem_name}-*").select do |path|
|
34
|
+
File.directory?(path) && File.basename(path).start_with?(gem_name)
|
35
|
+
end
|
36
|
+
|
37
|
+
# Group by base gem name (without platform suffix)
|
38
|
+
gem_groups = {}
|
39
|
+
gem_dirs.each do |dir|
|
40
|
+
name = File.basename(dir)
|
41
|
+
# Handle platform-specific gem names like nokogiri-1.18.10-x86_64-linux-gnu
|
42
|
+
base_name = name.sub(/-(x86_64-linux-gnu|aarch64-linux-gnu|arm64-linux-gnu|i386-linux-gnu|powerpc-linux-gnu|sparc-linux-gnu|mips-linux-gnu|riscv-linux-gnu|loongarch-linux-gnu|sw_64-linux-gnu|hppa-linux-gnu|ia64-linux-gnu|s390-linux-gnu|x86_64|arm64|aarch64|i386|powerpc|sparc|mips|riscv|loongarch|sw_64|hppa|ia64|s390).*/, "")
|
43
|
+
gem_groups[base_name] ||= []
|
44
|
+
gem_groups[base_name] << {dir: dir, name: name}
|
45
|
+
end
|
46
|
+
|
47
|
+
# For each gem group, keep only x86_64-linux variants
|
48
|
+
gem_groups.each do |base_name, variants|
|
49
|
+
next if variants.size <= 1 # No cleanup needed if only one variant
|
50
|
+
|
51
|
+
say "Found #{variants.size} platform variants for #{base_name}:"
|
52
|
+
variants.each { |v| say " - #{v[:name]}" }
|
53
|
+
|
54
|
+
# Find x86_64-linux variants (preferred for AWS Lambda)
|
55
|
+
x86_64_variants = variants.select { |v| v[:name].include?("-x86_64-linux-gnu") || v[:name].include?("-x86_64-linux") }
|
56
|
+
|
57
|
+
if x86_64_variants.any?
|
58
|
+
# Keep x86_64-linux variants, remove others
|
59
|
+
keep_variants = x86_64_variants
|
60
|
+
remove_variants = variants - x86_64_variants
|
61
|
+
else
|
62
|
+
# If no x86_64-linux variants, keep the first one alphabetically
|
63
|
+
keep_variants = [variants.min_by { |v| v[:name] }]
|
64
|
+
remove_variants = variants - keep_variants
|
65
|
+
end
|
66
|
+
|
67
|
+
say "Keeping: #{keep_variants.map { |v| v[:name] }.join(", ")}"
|
68
|
+
say "Removing: #{remove_variants.map { |v| v[:name] }.join(", ")}"
|
69
|
+
|
70
|
+
# Remove incompatible variants
|
71
|
+
remove_variants.each do |variant|
|
72
|
+
say "Removing incompatible variant: #{variant[:name]}"
|
73
|
+
FileUtils.rm_rf(variant[:dir])
|
74
|
+
|
75
|
+
# Also remove the corresponding gemspec
|
76
|
+
gemspec_path = "#{specs_dir}/#{variant[:name]}.gemspec"
|
77
|
+
FileUtils.rm_f(gemspec_path) if File.exist?(gemspec_path)
|
78
|
+
end
|
79
|
+
end
|
22
80
|
end
|
23
81
|
|
24
82
|
# ensure that we always have the full gem name
|
@@ -36,7 +94,7 @@ module Jets::Api::Gems::Extract
|
|
36
94
|
end
|
37
95
|
|
38
96
|
def gem_name
|
39
|
-
full_gem_name.gsub(VERSION_PATTERN,
|
97
|
+
full_gem_name.gsub(VERSION_PATTERN, "") # folder: byebug
|
40
98
|
end
|
41
99
|
|
42
100
|
# Downloads and extracts the linux gem into the proper directory.
|
@@ -53,10 +111,10 @@ module Jets::Api::Gems::Extract
|
|
53
111
|
begin
|
54
112
|
@retries ||= 0
|
55
113
|
url = gem_url
|
56
|
-
basename = File.basename(url).gsub(/\?.*/,
|
114
|
+
basename = File.basename(url).gsub(/\?.*/, "") # remove query string info
|
57
115
|
tarball_dest = download_file(url, download_path(basename))
|
58
116
|
rescue OpenURI::HTTPError => e
|
59
|
-
url_without_query = url.gsub(/\?.*/,
|
117
|
+
url_without_query = url.gsub(/\?.*/, "")
|
60
118
|
puts "Error downloading #{url_without_query}"
|
61
119
|
@retries += 1
|
62
120
|
if @retries < 3
|
@@ -104,10 +162,10 @@ module Jets::Api::Gems::Extract
|
|
104
162
|
def remove_current_gem
|
105
163
|
say "Removing current #{full_gem_name} gem installation:"
|
106
164
|
gem_dirs = Dir.glob("#{project_root}/**/*").select do |path|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
165
|
+
File.directory?(path) &&
|
166
|
+
path =~ %r{vendor/gems} &&
|
167
|
+
File.basename(path) == full_gem_name
|
168
|
+
end
|
111
169
|
gem_dirs.each do |dir|
|
112
170
|
say " rm -rf #{dir}"
|
113
171
|
FileUtils.rm_rf(dir)
|
data/lib/jets/api/gems/report.rb
CHANGED
data/lib/jets/api/gems.rb
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
module Jets::Api
|
2
2
|
class Gems < Base
|
3
3
|
class << self
|
4
|
-
def download(params={})
|
4
|
+
def download(params = {})
|
5
5
|
params = global_params.merge(params)
|
6
6
|
api.post("gems/download", params)
|
7
7
|
end
|
8
8
|
|
9
|
-
def exist(params={})
|
9
|
+
def exist(params = {})
|
10
10
|
params = global_params.merge(params)
|
11
11
|
api.post("gems/exist", params)
|
12
12
|
end
|
13
13
|
|
14
|
-
def report(params={})
|
14
|
+
def report(params = {})
|
15
15
|
params = global_params.merge(params)
|
16
16
|
api.post("gems/report", params)
|
17
17
|
end
|
18
18
|
|
19
|
-
def registered(params={})
|
19
|
+
def registered(params = {})
|
20
20
|
params = global_params.merge(params)
|
21
21
|
api.post("gems/registered", params)
|
22
22
|
end
|
23
23
|
|
24
24
|
def ruby_folder
|
25
|
-
major, minor, _ = RUBY_VERSION.split(
|
26
|
-
[major, minor,
|
25
|
+
major, minor, _ = RUBY_VERSION.split(".")
|
26
|
+
[major, minor, "0"].join(".") # 2.5.1 => 2.5.0
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
data/lib/jets/api/project.rb
CHANGED
data/lib/jets/api/release.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
module Jets::Api
|
2
2
|
class Release < Base
|
3
3
|
class << self
|
4
|
-
def list(params={})
|
4
|
+
def list(params = {})
|
5
5
|
params = global_params.merge(params)
|
6
6
|
api.get("releases", params)
|
7
7
|
end
|
8
8
|
|
9
|
-
def retrieve(id, params={})
|
9
|
+
def retrieve(id, params = {})
|
10
10
|
params = global_params.merge(params)
|
11
11
|
api.get("releases/#{id}", params)
|
12
12
|
end
|
13
13
|
|
14
|
-
def create(params={})
|
14
|
+
def create(params = {})
|
15
15
|
params = global_params.merge(params)
|
16
16
|
api.post("releases", params)
|
17
17
|
end
|
data/lib/jets/api/stack.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
module Jets::Api
|
2
2
|
class Stack < Base
|
3
3
|
class << self
|
4
|
-
def list(params={})
|
4
|
+
def list(params = {})
|
5
5
|
params = global_params.merge(params)
|
6
6
|
api.get("stacks", params)
|
7
7
|
end
|
8
8
|
|
9
|
-
def retrieve(id, params={})
|
9
|
+
def retrieve(id, params = {})
|
10
10
|
params = global_params.merge(params)
|
11
11
|
api.get("stacks/#{id}", params)
|
12
12
|
end
|
13
13
|
|
14
|
-
def delete(id, params={})
|
14
|
+
def delete(id, params = {})
|
15
15
|
params = global_params.merge(params)
|
16
16
|
api.delete("stacks/#{id}", params)
|
17
17
|
end
|
data/lib/jets/api/version.rb
CHANGED
data/lib/jets/api.rb
CHANGED
@@ -31,7 +31,7 @@ module Jets
|
|
31
31
|
module_function :token
|
32
32
|
|
33
33
|
def endpoint
|
34
|
-
ENV[
|
34
|
+
ENV["JETS_API"] || Jets.config.pro.endpoint || "https://api.rubyonjets.com/v1"
|
35
35
|
end
|
36
36
|
module_function :endpoint
|
37
37
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jets-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tung Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -60,7 +60,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
requirements: []
|
63
|
-
rubygems_version: 3.
|
63
|
+
rubygems_version: 3.4.19
|
64
64
|
signing_key:
|
65
65
|
specification_version: 4
|
66
66
|
summary: Jets API Client Library for Jets Ruby Serverless Framework
|