Module: Bundler::Multilock
- Defined in:
- lib/bundler/multilock.rb,
lib/bundler/multilock/cache.rb,
lib/bundler/multilock/check.rb,
lib/bundler/multilock/ext/cli.rb,
lib/bundler/multilock/ext/dsl.rb,
lib/bundler/multilock/version.rb,
lib/bundler/multilock/ext/plugin.rb,
lib/bundler/multilock/ext/source.rb,
lib/bundler/multilock/ui/capture.rb,
lib/bundler/multilock/ext/bundler.rb,
lib/bundler/multilock/ext/definition.rb,
lib/bundler/multilock/ext/plugin/dsl.rb,
lib/bundler/multilock/ext/source_list.rb,
lib/bundler/multilock/ext/shared_helpers.rb,
lib/bundler/multilock/lockfile_generator.rb
Defined Under Namespace
Modules: Ext, UI Classes: Cache, Check, LockfileGenerator
Constant Summary collapse
- VERSION =
"1.3.4"
Class Method Summary collapse
-
.add_lockfile(lockfile = nil, builder:, gemfile: nil, active: nil, default: nil, parent: nil, allow_mismatched_dependencies: nil, enforce_pinned_additional_dependencies: false) { ... } ⇒ true, false
If the lockfile is the active lockfile.
Class Method Details
.add_lockfile(lockfile = nil, builder:, gemfile: nil, active: nil, default: nil, parent: nil, allow_mismatched_dependencies: nil, enforce_pinned_additional_dependencies: false) { ... } ⇒ true, false
Returns if the lockfile is the active lockfile.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/bundler/multilock.rb', line 36 def add_lockfile(lockfile = nil, builder:, gemfile: nil, active: nil, default: nil, parent: nil, allow_mismatched_dependencies: nil, enforce_pinned_additional_dependencies: false, &block) # backcompat active = default if active.nil? Bundler.ui.warn("lockfile(default:) is deprecated. Use lockfile(active:) instead.") if default unless allow_mismatched_dependencies.nil? Bundler.ui.warn("lockfile(allow_mismatched_dependencies:) is deprecated.") end active = true if active.nil? && lockfile_definitions.empty? && lockfile.nil? && gemfile.nil? # if a gemfile was provided, but not a lockfile, infer the default lockfile for that gemfile lockfile ||= "#{gemfile}.lock" if gemfile # allow short-form lockfile names lockfile = (lockfile) raise ArgumentError, "Lockfile #{lockfile} is already defined" if lockfile_definitions.key?(lockfile) env_lockfile = lockfile if active && ENV["BUNDLE_LOCKFILE"] == "active" env_lockfile ||= ENV["BUNDLE_LOCKFILE"]&.then { |l| (l) } active = env_lockfile == lockfile if env_lockfile if active && (old_active = lockfile_definitions.each_value.find { |definition| definition[:active] }) raise ArgumentError, "Only one lockfile (#{old_active[:lockfile]}) can be flagged as active" end parent = (parent) if parent != Bundler.default_lockfile(force_original: true) && !lockfile_definitions.key?(parent) && !parent.exist? raise ArgumentError, "Parent lockfile #{parent} is not defined" end lockfile_definitions[lockfile] = (lockfile_def = { gemfile: (gemfile && Bundler.root.join(gemfile).) || Bundler.default_gemfile, lockfile: lockfile, active: active, prepare: block, parent: parent, enforce_pinned_additional_dependencies: enforce_pinned_additional_dependencies }) # If they're using BUNDLE_LOCKFILE, then they really do want to # use a particular lockfile, and it overrides whatever they # dynamically set in their gemfile if !env_lockfile && defined?(CLI) && %i[check install lock update].include?(CLI.instance&.current_command_chain&.first) # always use Gemfile.lock for `bundle check`, `bundle install`, # `bundle lock`, and `bundle update`. active = lockfile == Bundler.default_lockfile(force_original: true) end if active block&.call Bundler.default_lockfile = lockfile # we started evaluating the project's primary gemfile, but got told to use a lockfile # associated with a different Gemfile. so we need to evaluate that Gemfile instead if lockfile_def[:gemfile] != Bundler.default_gemfile # share a cache between all lockfiles Bundler.cache_root = Bundler.root ENV["BUNDLE_GEMFILE"] = lockfile_def[:gemfile].to_s Bundler.root = Bundler.default_gemfile.dirname Bundler.default_lockfile = lockfile builder.eval_gemfile(Bundler.default_gemfile) return false end end true end |