serverlessgems 0.4.1 → 0.4.3

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: f45e4781de3600f9c61880c3b508a2955a393332efff18d980bbc2ef0ebc88ab
4
- data.tar.gz: f3d78701b967fb4fc01a0ad7f332ec83690a38f0f86a0549a210d984e8b362ae
3
+ metadata.gz: 3bf2582904ec4259bc6d3b6d0ebcf407e2a3061c5c32c49f1c96c23d46d28048
4
+ data.tar.gz: fb74483267d8a14301e6bb9f1ff1b9f8eae28227ae0b9895ad7853426103a46d
5
5
  SHA512:
6
- metadata.gz: f7182eb8a6bafde793df547b4e8aa93a09160dfdc01181f5909fe6327971186f1c45e9d1e42d82ca65afcb98c8bf52785b877f9f9c6eb1385a8a3f4fd5b97ab4
7
- data.tar.gz: 8d6d08fdc726541ce96b1d3a7fc56a2e324f816018e5f96705883994b2a084160bbe213d91ba043f3ab5e9dcbbc20e85cfca2227df68458810f40b2307a22cfd
6
+ metadata.gz: 8ee67a43c0eb68cbddab1a0e7b1aa3b7739c56d43df9f0e1aa91e6a5f9d23630b325ffe01ced97febf178cb991a4068499c07d938221f6c7577965b974809ed9
7
+ data.tar.gz: 9bf66559b45718864229297600d8e4d9b85a341d5e63d20f34c61ebde5ac66c467b4d34dbb9f41b296a97cda5833f7540c6e76d0d217bd229743909d02d759b5
data/CHANGELOG.md CHANGED
@@ -3,6 +3,12 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project *loosely tries* to adhere to [Semantic Versioning](http://semver.org/).
5
5
 
6
+ ## [0.4.3] - 2025-10-11
7
+ - fix clean up gem variants
8
+
9
+ ## [0.4.2] - 2025-10-10
10
+ - fix gem detection ffi - gnu suffix and clean up incompatible platform variants
11
+
6
12
  ## [0.4.1] - 2024-06-22
7
13
  - standardrb and updates
8
14
 
@@ -56,9 +56,9 @@ module Jets::Gems
56
56
  * Unavailable: <%= missing_gem['gem_name'] -%> Available versions: <%= available.join(' ') %>
57
57
  <% end %>
58
58
  Your current serverlessgems source: #{gems_source}
59
-
59
+
60
60
  Jets is unable to build a deployment package that will work on AWS Lambda without the required pre-compiled gems. To remedy this, you can:
61
-
61
+
62
62
  * Use another gem that does not require compilation.
63
63
  * Create your own custom layer with the gem: http://rubyonjets.com/docs/extras/custom-lambda-layers/
64
64
  <% if agree.yes? -%>
@@ -72,10 +72,10 @@ module Jets::Gems
72
72
  * You can try redeploying again after a few minutes.
73
73
  * Non-reported gems may take days or even longer to be built.
74
74
  <% end -%>
75
-
75
+
76
76
  Compiled gems usually take some time to figure out how to build as they each depend on different libraries and packages.
77
77
  More info: http://rubyonjets.com/docs/serverlessgems/
78
-
78
+
79
79
  EOL
80
80
  erb = ERB.new(template, trim_mode: "-") # trim mode https://stackoverflow.com/questions/4632879/erb-template-removing-the-trailing-line
81
81
  erb.result(binding)
@@ -156,9 +156,9 @@ module Jets::Gems
156
156
  # On new 2021 macbook with m1 chip: the gems are being saved in a folder like so:
157
157
  # nokogiri-1.12.5-arm64-darwin
158
158
  # The GEM_REGEXP accounts for this case.
159
- GEM_REGEXP = /-(arm|x)\d+.*-(darwin|linux)/
159
+ GEM_REGEXP = /-(arm|x|aarch)\d+.*-(darwin|linux)(?:-gnu)?/
160
160
  def other_compiled_gems
161
- paths = Dir.glob("#{Jets.build_root}/stage/opt/ruby/gems/#{Jets::Gems.ruby_folder}/gems/*{-darwin,-linux}")
161
+ paths = Dir.glob("#{Jets.build_root}/stage/opt/ruby/gems/#{Jets::Gems.ruby_folder}/gems/*{-darwin,-linux}*")
162
162
  paths.map { |p| File.basename(p).sub(GEM_REGEXP, "") }
163
163
  end
164
164
 
@@ -19,6 +19,62 @@ module Jets::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::Gems.ruby_folder}/gems"
29
+ specs_dir = "#{Jets.build_root}/stage/opt/ruby/gems/#{Jets::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, clean up platform variants
48
+ gem_groups.each { |base_name, variants| cleanup_gem_variants(base_name, variants, specs_dir) }
49
+ end
50
+
51
+ # Clean up platform variants for a specific gem group
52
+ def cleanup_gem_variants(base_name, variants, specs_dir)
53
+ return if variants.size <= 1 # No cleanup needed if only one variant
54
+
55
+ say "Found #{variants.size} platform variants for #{base_name}:"
56
+ variants.each { |v| say " - #{v[:name]}" }
57
+
58
+ # Always favor base gem variants (without platform suffix) - these are from Jets API
59
+ # Remove all platform-specific variants
60
+ base_variants = variants.select { |v| !v[:name].match(/-[^-]+-[^-]+$/) }
61
+ platform_variants = variants - base_variants
62
+
63
+ keep_variants = base_variants.any? ? base_variants : variants
64
+ remove_variants = platform_variants
65
+
66
+ say "Keeping: #{keep_variants.map { |v| v[:name] }.join(", ")}"
67
+ say "Removing: #{remove_variants.map { |v| v[:name] }.join(", ")}"
68
+
69
+ # Remove incompatible variants
70
+ remove_variants.each do |variant|
71
+ say "Removing incompatible variant: #{variant[:name]}"
72
+ FileUtils.rm_rf(variant[:dir])
73
+
74
+ # Also remove the corresponding gemspec
75
+ gemspec_path = "#{specs_dir}/#{variant[:name]}.gemspec"
76
+ FileUtils.rm_f(gemspec_path) if File.exist?(gemspec_path)
77
+ end
22
78
  end
23
79
 
24
80
  # ensure that we always have the full gem name
@@ -1,5 +1,5 @@
1
1
  module Jets
2
2
  module Gems
3
- VERSION = "0.4.1"
3
+ VERSION = "0.4.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: serverlessgems
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-06-22 00:00:00.000000000 Z
11
+ date: 2025-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gems
@@ -146,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
146
146
  - !ruby/object:Gem::Version
147
147
  version: '0'
148
148
  requirements: []
149
- rubygems_version: 3.5.13
149
+ rubygems_version: 3.4.19
150
150
  signing_key:
151
151
  specification_version: 4
152
152
  summary: Client Library works with Serverless Gems API for Jets Ruby Serverless Framework