Sha256: 8cb35d3a6546d41c3c5df91bf4960631a538807e4799ab6475d58b10b8490521

Contents?: true

Size: 1.73 KB

Versions: 1

Compression:

Stored size: 1.73 KB

Contents

require_relative 'ruby_version'

Capistrano::Configuration.instance(:must_exist).load do
  namespace :ndr_dev_support do
    desc 'Ensure gems outside the bundle are up to date'
    task :update_out_of_bundle_gems, except: { no_release: true } do
      # You can seed this list in your configuration with something like:
      #
      #   before 'ndr_dev_support:update_out_of_bundle_gems' do
      #     set :out_of_bundle_gems, webapp_deployment ? %w[puma] : %[god]
      #   end
      #
      gem_list = Array(fetch(:out_of_bundle_gems, []))

      # By default, gems are installed using passwordless sudo as the application
      # user; set to false if you want to install gems as the deploying user.
      gem_install =
        if fetch(:out_of_bundle_gems_use_sudo, true)
          "sudo -i -n -u #{fetch(:application_user)} RBENV_VERSION=$RBENV_VERSION gem install"
        else
          'gem install'
        end

      # TODO: Add `gem install bundler`, move this to before bundle:install instead of after

      # Extract the current version requirements for each of the gems from the lockfile,
      # and then check they're installed. If not, install them from the vendored cache.
      run <<~CMD if gem_list.any?
        set -e;
        export RBENV_VERSION=`cat "#{latest_release}/.ruby-version"`;
        cat "#{latest_release}/Gemfile.lock" | egrep "^    (#{gem_list.join('|')}) " | tr -d '()' | \
        while read gem ver; do
          gem list -i "$gem" --version "$ver" > /dev/null || \
          #{gem_install} "#{latest_release}/vendor/cache/$gem-$ver.gem" \
            --ignore-dependencies --conservative --no-document --local;
        done
      CMD
    end
  end

  after 'bundle:install', 'ndr_dev_support:update_out_of_bundle_gems'
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ndr_dev_support-7.2.5 lib/ndr_dev_support/capistrano/standalone_gems.rb