bundler-multilock 1.3.1 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bundler/multilock/cache.rb +18 -2
- data/lib/bundler/multilock/check.rb +3 -2
- data/lib/bundler/multilock/ext/cli.rb +20 -0
- data/lib/bundler/multilock/lockfile_generator.rb +2 -0
- data/lib/bundler/multilock/version.rb +1 -1
- data/lib/bundler/multilock.rb +38 -48
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7796ee7b54f841aa9c6d127e05f878a1045078c94e842f04bf4e4f0ebb09ac1d
|
4
|
+
data.tar.gz: f1a35917e5fcfdf2eab572b4052d14766506e13253130c373114779d4598420e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1b5840035aab37b5a54bcb289649c40e6dd9451aff3d5858d45faea4750452381e7af904ac7c96146edd595e173143db07c827aa4f590701a513ac9e426979a
|
7
|
+
data.tar.gz: 9abece5b78beb3c5005a96577bf714ca3477865a4bfa897899628a2fd7556596f0697b2cef5cd530866079483e01c5aa46d1511a69343c3229fcebe7fe65acd4
|
@@ -57,11 +57,27 @@ module Bundler
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def specs(lockfile_name)
|
60
|
-
@specs[lockfile_name] ||=
|
61
|
-
|
60
|
+
@specs[lockfile_name] ||= begin
|
61
|
+
specs = {}
|
62
|
+
parser(lockfile_name).specs.each do |spec|
|
63
|
+
(specs[spec.name] ||= {})[spec.platform] = spec
|
64
|
+
end
|
65
|
+
specs
|
62
66
|
end
|
63
67
|
end
|
64
68
|
|
69
|
+
# sometimes a gem changes platforms with a new version, such as from aarch64-linux
|
70
|
+
# to aarch64-linux-gnu. we need to still sync it
|
71
|
+
def find_matching_spec(specs, spec)
|
72
|
+
specs = self.specs(specs) unless specs.is_a?(Hash)
|
73
|
+
platform_specs = specs[spec.name]
|
74
|
+
return unless platform_specs
|
75
|
+
|
76
|
+
parent_spec = platform_specs[spec.platform]
|
77
|
+
parent_spec ||= platform_specs.find { |platform, _| platform =~ spec.platform }&.last
|
78
|
+
parent_spec || platform_specs.find { |platform, _| platform == "ruby" }&.last
|
79
|
+
end
|
80
|
+
|
65
81
|
# @param lockfile_name [Pathname]
|
66
82
|
# @return [Hash<String, Set<String>>] hash of gem name to set of gem names that depend on it
|
67
83
|
def reverse_dependencies(lockfile_name)
|
@@ -88,7 +88,7 @@ module Bundler
|
|
88
88
|
|
89
89
|
# this checks for mismatches between the parent lockfile and the given lockfile,
|
90
90
|
# and for pinned dependencies in lockfiles requiring them
|
91
|
-
def deep_check(lockfile_definition)
|
91
|
+
def deep_check(lockfile_definition, conflicts: nil)
|
92
92
|
lockfile_name = lockfile_definition[:lockfile]
|
93
93
|
@cache.deep_check(lockfile_name) do
|
94
94
|
success = true
|
@@ -120,7 +120,7 @@ module Bundler
|
|
120
120
|
|
121
121
|
# check for conflicting requirements (and build list of pins, in the same loop)
|
122
122
|
parser.specs.each do |spec|
|
123
|
-
parent_spec = @cache.
|
123
|
+
parent_spec = @cache.find_matching_spec(parent_lockfile_name, spec)
|
124
124
|
|
125
125
|
if lockfile_definition[:enforce_pinned_additional_dependencies]
|
126
126
|
# look through what this spec depends on, and keep track of all pinned requirements
|
@@ -156,6 +156,7 @@ module Bundler
|
|
156
156
|
"does not match the parent lockfile's version " \
|
157
157
|
"(@#{parent_spec.version}#{parent_spec.git_version}); " \
|
158
158
|
"this may be due to a conflicting requirement, which would require manual resolution.")
|
159
|
+
conflicts&.add(spec.name)
|
159
160
|
success = false
|
160
161
|
end
|
161
162
|
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bundler
|
4
|
+
module Multilock
|
5
|
+
module Ext
|
6
|
+
module CLI
|
7
|
+
module ClassMethods
|
8
|
+
def instance
|
9
|
+
return @instance if instance_variable_defined?(:@instance)
|
10
|
+
|
11
|
+
# this is a little icky, but there's no other way to determine which command was run
|
12
|
+
@instance = ObjectSpace.each_object(::Bundler::CLI).first
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
::Bundler::CLI.extend(ClassMethods)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/bundler/multilock.rb
CHANGED
@@ -82,17 +82,13 @@ module Bundler
|
|
82
82
|
enforce_pinned_additional_dependencies: enforce_pinned_additional_dependencies
|
83
83
|
})
|
84
84
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
85
|
+
# If they're using BUNDLE_LOCKFILE, then they really do want to
|
86
|
+
# use a particular lockfile, and it overrides whatever they
|
87
|
+
# dynamically set in their gemfile
|
88
|
+
if !env_lockfile && defined?(CLI) &&
|
89
|
+
%i[check install lock update].include?(CLI.instance&.current_command_chain&.first)
|
90
90
|
# always use Gemfile.lock for `bundle check`, `bundle install`,
|
91
|
-
# `bundle lock`, and `bundle update`.
|
92
|
-
# `bundle install`, but we want that to run as normal.
|
93
|
-
# If they're using BUNDLE_LOCKFILE, then they really do want to
|
94
|
-
# use a particular lockfile, and it overrides whatever they
|
95
|
-
# dynamically set in their gemfile
|
91
|
+
# `bundle lock`, and `bundle update`.
|
96
92
|
active = lockfile == Bundler.default_lockfile(force_original: true)
|
97
93
|
end
|
98
94
|
|
@@ -179,10 +175,11 @@ module Bundler
|
|
179
175
|
|
180
176
|
# already up to date?
|
181
177
|
up_to_date = false
|
178
|
+
conflicts = Set.new
|
182
179
|
Bundler.settings.temporary(frozen: true) do
|
183
180
|
Bundler.ui.silence do
|
184
181
|
up_to_date = checker.base_check(lockfile_definition, check_missing_deps: true) &&
|
185
|
-
checker.deep_check(lockfile_definition)
|
182
|
+
checker.deep_check(lockfile_definition, conflicts: conflicts)
|
186
183
|
end
|
187
184
|
end
|
188
185
|
if up_to_date
|
@@ -206,7 +203,6 @@ module Bundler
|
|
206
203
|
Bundler.ui.info("Syncing to #{relative_lockfile}...") if attempts == 1
|
207
204
|
synced_any = true
|
208
205
|
|
209
|
-
specs = lockfile_name.exist? ? cache.specs(lockfile_name) : {}
|
210
206
|
parent_lockfile_name = lockfile_definition[:parent]
|
211
207
|
parent_root = parent_lockfile_name.dirname
|
212
208
|
parent_specs = cache.specs(parent_lockfile_name)
|
@@ -222,7 +218,7 @@ module Bundler
|
|
222
218
|
end
|
223
219
|
|
224
220
|
# add a source for the current gem
|
225
|
-
gem_spec = parent_specs
|
221
|
+
gem_spec = parent_specs.dig(File.basename(Bundler.root), "ruby")
|
226
222
|
|
227
223
|
if gem_spec
|
228
224
|
adjusted_parent_lockfile_contents += <<~TEXT
|
@@ -252,32 +248,22 @@ module Bundler
|
|
252
248
|
next :self if parent_spec.nil?
|
253
249
|
next spec_precedences[spec.name] if spec_precedences.key?(spec.name)
|
254
250
|
|
255
|
-
precedence =
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
[cache.reverse_dependencies(lockfile_name),
|
264
|
-
cache.reverse_dependencies(parent_lockfile_name)].each do |reverse_dependencies|
|
265
|
-
break if precedence == :self
|
266
|
-
|
267
|
-
reverse_dependencies[spec.name].each do |dep_name|
|
268
|
-
precedence = check_precedence.call(specs[dep_name], parent_specs[dep_name])
|
269
|
-
break if precedence == :self
|
270
|
-
end
|
271
|
-
end
|
251
|
+
precedence = if !(cache.reverse_dependencies(lockfile_name)[spec.name] & conflicts).empty?
|
252
|
+
:parent
|
253
|
+
elsif cache.conflicting_requirements?(lockfile_name,
|
254
|
+
parent_lockfile_name,
|
255
|
+
spec,
|
256
|
+
parent_spec)
|
257
|
+
:self
|
258
|
+
end
|
272
259
|
|
273
260
|
spec_precedences[spec.name] = precedence || :parent
|
274
261
|
end
|
275
262
|
|
276
263
|
# replace any duplicate specs with what's in the parent lockfile
|
277
264
|
lockfile.specs.map! do |spec|
|
278
|
-
parent_spec = parent_specs
|
265
|
+
parent_spec = cache.find_matching_spec(parent_specs, spec)
|
279
266
|
next spec unless parent_spec
|
280
|
-
|
281
267
|
next spec if check_precedence.call(spec, parent_spec) == :self
|
282
268
|
|
283
269
|
dependency_changes ||= spec != parent_spec
|
@@ -577,25 +563,29 @@ end
|
|
577
563
|
Bundler::LazySpecification.include(Bundler::MatchMetadata) if defined?(Bundler::MatchMetadata)
|
578
564
|
Bundler::Multilock.inject_preamble unless Bundler::Multilock.loaded?
|
579
565
|
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
566
|
+
if defined?(Bundler::CLI)
|
567
|
+
require_relative "multilock/ext/cli"
|
568
|
+
|
569
|
+
# this is terrible, but we can't prepend into these modules because we only load
|
570
|
+
# _inside_ of the CLI commands already running
|
571
|
+
if Bundler::CLI.instance&.current_command_chain&.first == :check
|
572
|
+
require_relative "multilock/check"
|
573
|
+
at_exit do
|
574
|
+
next unless $!.nil?
|
575
|
+
next if $!.is_a?(SystemExit) && !$!.success?
|
587
576
|
|
588
|
-
|
577
|
+
next if Bundler::Multilock::Check.run
|
589
578
|
|
590
|
-
|
591
|
-
|
579
|
+
Bundler.ui.warn("You can attempt to fix by running `bundle install`")
|
580
|
+
exit 1
|
581
|
+
end
|
592
582
|
end
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
next if $!.is_a?(SystemExit) && !$!.success?
|
583
|
+
if Bundler::CLI.instance&.current_command_chain&.first == :lock
|
584
|
+
at_exit do
|
585
|
+
next unless $!.nil?
|
586
|
+
next if $!.is_a?(SystemExit) && !$!.success?
|
598
587
|
|
599
|
-
|
588
|
+
Bundler::Multilock.after_install_all(install: false)
|
589
|
+
end
|
600
590
|
end
|
601
591
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bundler-multilock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Instructure
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -82,6 +82,7 @@ files:
|
|
82
82
|
- lib/bundler/multilock/cache.rb
|
83
83
|
- lib/bundler/multilock/check.rb
|
84
84
|
- lib/bundler/multilock/ext/bundler.rb
|
85
|
+
- lib/bundler/multilock/ext/cli.rb
|
85
86
|
- lib/bundler/multilock/ext/definition.rb
|
86
87
|
- lib/bundler/multilock/ext/dsl.rb
|
87
88
|
- lib/bundler/multilock/ext/plugin.rb
|
@@ -113,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
113
114
|
- !ruby/object:Gem::Version
|
114
115
|
version: '0'
|
115
116
|
requirements: []
|
116
|
-
rubygems_version: 3.5.
|
117
|
+
rubygems_version: 3.5.10
|
117
118
|
signing_key:
|
118
119
|
specification_version: 4
|
119
120
|
summary: Support Multiple Lockfiles
|