Skip to content

Commit

Permalink
Add Next Gemfile Support
Browse files Browse the repository at this point in the history
Closes #1
  • Loading branch information
JuanVqz committed Mar 20, 2024
1 parent 7866d1e commit 6dda70b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 3 additions & 2 deletions lib/language_pack/helpers/bundler_wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ def initialize(version_hash, major_minor)
def initialize(options = {})
@bundler_tmp = Pathname.new(Dir.mktmpdir)
@fetcher = options[:fetcher] || LanguagePack::Fetcher.new(LanguagePack::Base::VENDOR_URL) # coupling
@gemfile_path = options[:gemfile_path] || Pathname.new("./Gemfile")
@gemfile_path = options[:gemfile_path] || Pathname.new("./Gemfile.next")
# @gemfile_path = options[:gemfile_path] || Pathname.new("./Gemfile")
@gemfile_lock_path = Pathname.new("#{@gemfile_path}.lock")

@version = self.class.detect_bundler_version(contents: @gemfile_lock_path.read(mode: "rt"))
Expand Down Expand Up @@ -223,7 +224,7 @@ def needs_ruby_global_append_path?
end

def bundler_version_escape_valve!
topic("Removing BUNDLED WITH version in the Gemfile.lock")
topic("Removing BUNDLED WITH version in the #{@gemfile_lock_path}")
contents = File.read(@gemfile_lock_path, mode: "rt")
File.open(@gemfile_lock_path, "w") do |f|
f.write contents.sub(/^BUNDLED WITH$(\r?\n) (?<major>\d+)\.\d+\.\d+/m, '')
Expand Down
10 changes: 8 additions & 2 deletions lib/language_pack/ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def best_practice_warnings

def compile
# check for new app at the beginning of the compile
warn("JUAN starting compile #{env('BUNDLE_GEMFILE')}", inline: true)
new_app?
Dir.chdir(build_path)
remove_vendor_bundle
Expand All @@ -93,6 +94,7 @@ def compile
bundle_path: "vendor/bundle",
bundle_default_without: "development:test"
)
warn("JUAN starting compile allow_git #{env('BUNDLE_GEMFILE')}", inline: true)
allow_git do
install_bundler_in_app(slug_vendor_base)
load_bundler_cache
Expand All @@ -102,12 +104,14 @@ def compile
install_binaries
run_assets_precompile_rake_task
end
warn("JUAN ending compile allow_git #{env('BUNDLE_GEMFILE')}", inline: true)
config_detect
best_practice_warnings
warn_outdated_ruby
setup_profiled(ruby_layer_path: "$HOME", gem_layer_path: "$HOME") # $HOME is set to /app at run time
setup_export
cleanup
warn("JUAN ending compile #{env('BUNDLE_GEMFILE')}", inline: true)
super
rescue => e
warn_outdated_ruby
Expand All @@ -116,6 +120,7 @@ def compile


def build
warn("JUAN starting build #{ENV['BUNDLE_GEMFILE']}", inline: true)
new_app?
remove_vendor_bundle
warn_bad_binstubs
Expand Down Expand Up @@ -144,7 +149,7 @@ def build
build_bundler
# TODO post_bundler might need to be done in a new layer
bundler.clean
gem_layer.metadata[:gems] = Digest::SHA2.hexdigest(File.read("Gemfile.lock"))
gem_layer.metadata[:gems] = Digest::SHA2.hexdigest(File.read("Gemfile.next.lock"))
gem_layer.metadata[:stack] = @stack
gem_layer.metadata[:ruby_version] = run_stdout(%q(ruby -v)).strip
gem_layer.metadata[:rubygems_version] = run_stdout(%q(gem -v)).strip
Expand All @@ -162,6 +167,7 @@ def build
best_practice_warnings
cleanup

warn("JUAN ending build", inline: true)
super
end

Expand Down Expand Up @@ -816,7 +822,7 @@ def build_bundler

# we need to set BUNDLE_CONFIG and BUNDLE_GEMFILE for
# codon since it uses bundler.
env_vars["BUNDLE_GEMFILE"] = "#{pwd}/Gemfile"
env_vars["BUNDLE_GEMFILE"] = "#{pwd}/Gemfile.next"
env_vars["BUNDLE_CONFIG"] = "#{pwd}/.bundle/config"
env_vars["CPATH"] = noshellescape("#{yaml_include}:$CPATH")
env_vars["CPPATH"] = noshellescape("#{yaml_include}:$CPPATH")
Expand Down

0 comments on commit 6dda70b

Please sign in to comment.