bundler-multilock 1.0.2 → 1.0.4
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/check.rb +27 -5
- data/lib/bundler/multilock/ext/definition.rb +6 -0
- data/lib/bundler/multilock/ext/dsl.rb +1 -0
- data/lib/bundler/multilock/version.rb +1 -1
- data/lib/bundler/multilock.rb +41 -18
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 514c6dd3f4961f833ea20dee15047941b649cdbe787f94808d9547e310ac7ff0
|
4
|
+
data.tar.gz: 79b046545b14b3b29c33a629e528cf9bf60712337052b0381fc1b6bf240228c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d071c456f788219cfb144b70cfb3161f1b53d9add8d9a2d5395be1bceb56f1681abd787047ec1e6f109c2937944756cf9b7f4cd85ff6ad9483666d46f3acfa2d
|
7
|
+
data.tar.gz: 887dbb68890c5f643fdfb925eade83055afd262115a3a8970dd900955d1793ba4109569a56f9d4f273229023a051b63aec86c05fce2c6bf7ecc6bfe59f00e95b
|
@@ -23,9 +23,20 @@ module Bundler
|
|
23
23
|
return true unless Bundler.default_lockfile.exist?
|
24
24
|
|
25
25
|
success = true
|
26
|
+
missing_specs = base_check({ gemfile: Bundler.default_gemfile, lockfile: Bundler.default_lockfile },
|
27
|
+
return_missing: true).to_set
|
28
|
+
|
26
29
|
Multilock.lockfile_definitions.each do |lockfile_definition|
|
27
|
-
next
|
30
|
+
next if lockfile_definition[:lockfile] == Bundler.default_lockfile
|
31
|
+
|
32
|
+
unless lockfile_definition[:lockfile].exist?
|
33
|
+
Bundler.ui.error("Lockfile #{lockfile_definition[:lockfile]} does not exist.")
|
34
|
+
success = false
|
35
|
+
end
|
28
36
|
|
37
|
+
new_missing = base_check(lockfile_definition, log_missing: missing_specs, return_missing: true)
|
38
|
+
success = false unless new_missing.empty?
|
39
|
+
missing_specs.merge(new_missing)
|
29
40
|
success = false unless check(lockfile_definition)
|
30
41
|
end
|
31
42
|
success
|
@@ -33,21 +44,32 @@ module Bundler
|
|
33
44
|
|
34
45
|
# this is mostly equivalent to the built in checks in `bundle check`, but even
|
35
46
|
# more conservative, and returns false instead of exiting on failure
|
36
|
-
def base_check(lockfile_definition)
|
37
|
-
return false unless lockfile_definition[:lockfile].file?
|
47
|
+
def base_check(lockfile_definition, log_missing: false, return_missing: false)
|
48
|
+
return return_missing ? [] : false unless lockfile_definition[:lockfile].file?
|
38
49
|
|
39
50
|
Multilock.prepare_block = lockfile_definition[:prepare]
|
40
51
|
definition = Definition.build(lockfile_definition[:gemfile], lockfile_definition[:lockfile], false)
|
41
|
-
return false unless definition.send(:current_platform_locked?)
|
52
|
+
return return_missing ? [] : false unless definition.send(:current_platform_locked?)
|
42
53
|
|
43
54
|
begin
|
44
55
|
definition.validate_runtime!
|
45
56
|
definition.resolve_only_locally!
|
46
57
|
not_installed = definition.missing_specs
|
47
58
|
rescue RubyVersionMismatch, GemNotFound, SolveFailure
|
48
|
-
return false
|
59
|
+
return return_missing ? [] : false
|
60
|
+
end
|
61
|
+
|
62
|
+
if log_missing
|
63
|
+
not_installed.each do |spec|
|
64
|
+
next if log_missing.include?(spec)
|
65
|
+
|
66
|
+
Bundler.ui.error "The following gems are missing" if log_missing.empty?
|
67
|
+
Bundler.ui.error(" * #{spec.name} (#{spec.version})")
|
68
|
+
end
|
49
69
|
end
|
50
70
|
|
71
|
+
return not_installed if return_missing
|
72
|
+
|
51
73
|
not_installed.empty? && definition.no_resolve_needed?
|
52
74
|
ensure
|
53
75
|
Multilock.prepare_block = nil
|
data/lib/bundler/multilock.rb
CHANGED
@@ -283,14 +283,21 @@ module Bundler
|
|
283
283
|
|
284
284
|
@loaded = true
|
285
285
|
return if lockfile_definitions.empty?
|
286
|
+
|
286
287
|
return unless lockfile_definitions.none? { |definition| definition[:current] }
|
288
|
+
|
287
289
|
# Gemfile.lock isn't explicitly specified, otherwise it would be current
|
288
|
-
|
289
|
-
|
290
|
-
|
290
|
+
default_lockfile_definition = lockfile_definitions.find do |definition|
|
291
|
+
definition[:lockfile] == Bundler.default_lockfile(force_original: true)
|
292
|
+
end
|
293
|
+
if ENV["BUNDLE_LOCKFILE"] == Bundler.default_lockfile(force_original: true) && default_lockfile_definition
|
294
|
+
return
|
295
|
+
end
|
291
296
|
|
292
297
|
raise GemfileNotFound, "Could not locate lockfile #{ENV["BUNDLE_LOCKFILE"].inspect}" if ENV["BUNDLE_LOCKFILE"]
|
293
298
|
|
299
|
+
return unless default_lockfile_definition && default_lockfile_definition[:current] == false
|
300
|
+
|
294
301
|
raise GemfileEvalError, "No lockfiles marked as default"
|
295
302
|
end
|
296
303
|
|
@@ -355,8 +362,36 @@ module Bundler
|
|
355
362
|
end
|
356
363
|
|
357
364
|
def write_lockfile(lockfile_definition, lockfile, install:, dependency_changes: false)
|
358
|
-
|
359
|
-
|
365
|
+
prepare_block = lockfile_definition[:prepare]
|
366
|
+
|
367
|
+
gemfile = lockfile_definition[:gemfile]
|
368
|
+
# use avoid Definition.build, so that we don't have to evaluate
|
369
|
+
# the gemfile multiple times, each time we need a separate definition
|
370
|
+
builder = Dsl.new
|
371
|
+
builder.eval_gemfile(gemfile, &prepare_block) if prepare_block
|
372
|
+
builder.eval_gemfile(gemfile)
|
373
|
+
|
374
|
+
definition = builder.to_definition(lockfile, {})
|
375
|
+
definition.instance_variable_set(:@dependency_changes, dependency_changes) if dependency_changes
|
376
|
+
orig_definition = definition.dup # we might need it twice
|
377
|
+
|
378
|
+
current_lockfile = lockfile_definition[:lockfile]
|
379
|
+
if current_lockfile.exist?
|
380
|
+
definition.instance_variable_set(:@lockfile_contents, current_lockfile.read)
|
381
|
+
if install
|
382
|
+
current_definition = builder.to_definition(current_lockfile, {})
|
383
|
+
begin
|
384
|
+
current_definition.resolve_only_locally!
|
385
|
+
if current_definition.missing_specs.any?
|
386
|
+
Bundler.with_default_lockfile(current_lockfile) do
|
387
|
+
Installer.install(gemfile.dirname, current_definition, {})
|
388
|
+
end
|
389
|
+
end
|
390
|
+
rescue RubyVersionMismatch, GemNotFound, SolveFailure
|
391
|
+
# ignore
|
392
|
+
end
|
393
|
+
end
|
394
|
+
end
|
360
395
|
|
361
396
|
resolved_remotely = false
|
362
397
|
begin
|
@@ -365,7 +400,7 @@ module Bundler
|
|
365
400
|
begin
|
366
401
|
definition.resolve_with_cache!
|
367
402
|
rescue GemNotFound, SolveFailure
|
368
|
-
definition =
|
403
|
+
definition = orig_definition
|
369
404
|
|
370
405
|
definition.resolve_remotely!
|
371
406
|
resolved_remotely = true
|
@@ -384,18 +419,6 @@ module Bundler
|
|
384
419
|
end
|
385
420
|
|
386
421
|
!definition.nothing_changed?
|
387
|
-
ensure
|
388
|
-
self.prepare_block = nil
|
389
|
-
end
|
390
|
-
|
391
|
-
def build_definition(lockfile_definition, lockfile, dependency_changes:)
|
392
|
-
definition = Definition.build(lockfile_definition[:gemfile], lockfile, false)
|
393
|
-
definition.instance_variable_set(:@dependency_changes, dependency_changes) if dependency_changes
|
394
|
-
if lockfile_definition[:lockfile].exist?
|
395
|
-
definition.instance_variable_set(:@lockfile_contents,
|
396
|
-
lockfile_definition[:lockfile].read)
|
397
|
-
end
|
398
|
-
definition
|
399
422
|
end
|
400
423
|
end
|
401
424
|
|
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.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Instructure
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-09-
|
11
|
+
date: 2023-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|