diff options
| author | mo khan <mo.khan@gmail.com> | 2020-07-06 11:03:35 -0600 |
|---|---|---|
| committer | mo khan <mo.khan@gmail.com> | 2020-07-06 17:30:37 -0600 |
| commit | 7162e1ae684b44ec3fe6e56b98f9313c85ca88a6 (patch) | |
| tree | 785b0afbd0d59bc3d8e3a8b50b430bba1cd3274f /lib | |
| parent | 6beda629bccc8617812f7b04fc6c14f69a6b508e (diff) | |
Install gems from custom source with custom CA
* Bump version and add CHANGELOG entry
* Configure Bundler logging
* Include install_path of gem
* Use gem summary and full_gem_path
* Specify a vendor path to install dependencies to prevent leakage between tests and take advantage of build job cache
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/license/finder/ext.rb | 1 | ||||
| -rw-r--r-- | lib/license/finder/ext/bundler.rb | 61 | ||||
| -rw-r--r-- | lib/license/management/version.rb | 2 |
3 files changed, 63 insertions, 1 deletions
diff --git a/lib/license/finder/ext.rb b/lib/license/finder/ext.rb index 8d76172..da6a006 100644 --- a/lib/license/finder/ext.rb +++ b/lib/license/finder/ext.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require 'license/finder/ext/bower' +require 'license/finder/ext/bundler' require 'license/finder/ext/conan' require 'license/finder/ext/dependency' require 'license/finder/ext/go_modules' diff --git a/lib/license/finder/ext/bundler.rb b/lib/license/finder/ext/bundler.rb new file mode 100644 index 0000000..08ab3ac --- /dev/null +++ b/lib/license/finder/ext/bundler.rb @@ -0,0 +1,61 @@ +# frozen_string_literal: true + +module LicenseFinder + class Bundler < PackageManager + def prepare + vendor_path = Pathname.pwd.join('.gitlab', 'cache', 'vendor') + shell.execute([:mkdir, '-p', vendor_path.to_s]) + + Dir.chdir(project_path) do + with_clean_bundler do + shell.execute([:bundle, :config, '--local', :path, vendor_path.to_s]) + shell.execute([:bundle, :install, '--verbose'], env: default_env) + end + end + end + + def current_packages + Dir.chdir(project_path) do + gem_details.map do |gem| + Dependency.new( + 'Bundler', + gem.name, + gem.version.to_s, + description: gem.description, + detection_path: lockfile_path, + homepage: gem.homepage, + install_path: gem.full_gem_path || '/dev/null', + spec_licenses: gem.licenses, + summary: gem.summary + ) + end + end + end + + private + + def default_env + @default_env ||= { + 'BUNDLE_ALLOW_OFFLINE_INSTALL' => 'true', + 'BUNDLE_SUPPRESS_INSTALL_USING_MESSAGES' => 'true', + 'BUNDLE_DISABLE_VERSION_CHECK' => 'true', + 'BUNDLE_ERROR_ON_STDERR' => 'true', + 'BUNDLE_IGNORE_MESSAGES' => 'true', + 'BUNDLE_JOBS' => ENV.fetch('BUNDLE_JOBS', `nproc`.chomp), + 'BUNDLE_SILENCE_ROOT_WARNING' => 'true', + 'BUNDLE_WITH' => ENV.fetch('BUNDLE_WITH', included_groups.to_a.join(':')) + }.tap do |env| + env['BUNDLE_FROZEN'] = 'true' if lockfile_path.exist? + env['BUNDLE_SSL_CA_CERT'] = shell.custom_certificate_path.to_s if shell.custom_certificate_installed? + end + end + + def with_clean_bundler + if ::Bundler.respond_to?(:with_unbundled_env) + ::Bundler.with_unbundled_env { yield } + else + ::Bundler.with_clean_env { yield } + end + end + end +end diff --git a/lib/license/management/version.rb b/lib/license/management/version.rb index eb4ecd4..de5715a 100644 --- a/lib/license/management/version.rb +++ b/lib/license/management/version.rb @@ -2,6 +2,6 @@ module License module Management - VERSION = '3.13.0' + VERSION = '3.14.0' end end |
