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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ad2556137eeec88cc813f9ac79cbb7062a4a16b067bf88a61cfacb03d1ae9add
4
- data.tar.gz: 58c7c976aa0e57f426b80152f213d069ee7f24ea5b9da1ee0c1ef115a8208e64
3
+ metadata.gz: 514c6dd3f4961f833ea20dee15047941b649cdbe787f94808d9547e310ac7ff0
4
+ data.tar.gz: 79b046545b14b3b29c33a629e528cf9bf60712337052b0381fc1b6bf240228c1
5
5
  SHA512:
6
- metadata.gz: 84e3cd4a4b12513f2a5ea4d0d214abb9e1a061bf96d041d1bea16c833131941ce8da7f9109018dd2bc5b2ddc4afc363e68caae7948707ec7d3a68ac8dea745f3
7
- data.tar.gz: cb8d45a52af7437ab6192809711531df051f7da2343b91087d4522f520441ab90476c822499d6e0c13d015923bf0701a75c9cead68f52bc49026de439cd0fbbe
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 unless lockfile_definition[:lockfile].exist?
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
@@ -15,6 +15,12 @@ module Bundler
15
15
  end
16
16
  super
17
17
  end
18
+
19
+ def validate_runtime!
20
+ Multilock.loaded! unless Multilock.lockfile_definitions.empty?
21
+
22
+ super
23
+ end
18
24
  end
19
25
  end
20
26
  end
@@ -27,6 +27,7 @@ module Bundler
27
27
  def initialize
28
28
  super
29
29
  @gemfiles = Set.new
30
+ Multilock.loaded! unless Multilock.lockfile_definitions.empty?
30
31
  end
31
32
 
32
33
  # Significant changes:
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Bundler
4
4
  module Multilock
5
- VERSION = "1.0.2"
5
+ VERSION = "1.0.4"
6
6
  end
7
7
  end
@@ -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
- return if lockfile_definitions.none? do |definition|
289
- definition[:lockfile] == Bundler.default_lockfile(force_original: true)
290
- end
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
- self.prepare_block = lockfile_definition[:prepare]
359
- definition = build_definition(lockfile_definition, lockfile, dependency_changes: dependency_changes)
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 = build_definition(lockfile_definition, lockfile, dependency_changes: dependency_changes)
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.2
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-12 00:00:00.000000000 Z
11
+ date: 2023-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler