bundler-multilock 1.0.3 → 1.0.5

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: caaabd6305d7178a0f13e9892ad6c3ef7a87de1c18cc2098ee76761820dfee5d
4
- data.tar.gz: c1cf4f2100eeeba5882a073e6db8db7b287e2a891bb6e8991d62f6f6512ac52b
3
+ metadata.gz: 3acaa706bf6ffde2f5fb070a729895371cfbebf2dbe2c97d249acbb698a0b6c0
4
+ data.tar.gz: 416ddd8252d1254472dfe5ee60b2cb7eb54e88b0ea25f58d2f34888dbe6b6f2a
5
5
  SHA512:
6
- metadata.gz: ec3b461286a3f046a12f2ec0539b441ba15c8367037994c53ece2f8c679a17788e93dfe85c88046b1e8ddeca6303b3d8be968edb12ffcaec9a900e80aeb756ba
7
- data.tar.gz: 8c1e2d525bc7c6955d750be9ef8c30cf5f120cb07d65fa844a0fcfa61ea54eecdb7faf10e38a7e5a4591a928c3aaaa2574dc7156207c8135976bd611c8497cb1
6
+ metadata.gz: 7adc856fa4149e2f814d7aac9181addc3a7ad378a44b9d1f9855d277e84ef58e56d59aab99d81a59f0ad539a6735c1a233e58be86fe7f887d01bb6cf4d60c1fb
7
+ data.tar.gz: 60f364edd123e881827ab24c9bf18cb6e2bccad0156b8346096a8ed221ed4f8409ce5bab2a8752e2aedc1cc6a0d8c9ca5035490ccb41a014242c57817c92dc64
@@ -19,13 +19,27 @@ module Bundler
19
19
  end
20
20
  end
21
21
 
22
- def run
22
+ def run(skip_base_checks: false)
23
23
  return true unless Bundler.default_lockfile.exist?
24
24
 
25
25
  success = true
26
+ unless skip_base_checks
27
+ missing_specs = base_check({ gemfile: Bundler.default_gemfile, lockfile: Bundler.default_lockfile },
28
+ return_missing: true).to_set
29
+ end
26
30
  Multilock.lockfile_definitions.each do |lockfile_definition|
27
- next unless lockfile_definition[:lockfile].exist?
31
+ next if lockfile_definition[:lockfile] == Bundler.default_lockfile
32
+
33
+ unless lockfile_definition[:lockfile].exist?
34
+ Bundler.ui.error("Lockfile #{lockfile_definition[:lockfile]} does not exist.")
35
+ success = false
36
+ end
28
37
 
38
+ unless skip_base_checks
39
+ new_missing = base_check(lockfile_definition, log_missing: missing_specs, return_missing: true)
40
+ success = false unless new_missing.empty?
41
+ missing_specs.merge(new_missing)
42
+ end
29
43
  success = false unless check(lockfile_definition)
30
44
  end
31
45
  success
@@ -33,21 +47,34 @@ module Bundler
33
47
 
34
48
  # this is mostly equivalent to the built in checks in `bundle check`, but even
35
49
  # more conservative, and returns false instead of exiting on failure
36
- def base_check(lockfile_definition)
37
- return false unless lockfile_definition[:lockfile].file?
50
+ def base_check(lockfile_definition, log_missing: false, return_missing: false)
51
+ return return_missing ? [] : false unless lockfile_definition[:lockfile].file?
38
52
 
39
53
  Multilock.prepare_block = lockfile_definition[:prepare]
40
54
  definition = Definition.build(lockfile_definition[:gemfile], lockfile_definition[:lockfile], false)
41
- return false unless definition.send(:current_platform_locked?)
55
+ return return_missing ? [] : false unless definition.send(:current_platform_locked?)
42
56
 
43
57
  begin
44
58
  definition.validate_runtime!
45
- definition.resolve_only_locally!
59
+ Bundler.ui.silence do
60
+ definition.resolve_only_locally!
61
+ end
46
62
  not_installed = definition.missing_specs
47
63
  rescue RubyVersionMismatch, GemNotFound, SolveFailure
48
- return false
64
+ return return_missing ? [] : false
49
65
  end
50
66
 
67
+ if log_missing
68
+ not_installed.each do |spec|
69
+ next if log_missing.include?(spec)
70
+
71
+ Bundler.ui.error "The following gems are missing" if log_missing.empty?
72
+ Bundler.ui.error(" * #{spec.name} (#{spec.version})")
73
+ end
74
+ end
75
+
76
+ return not_installed if return_missing
77
+
51
78
  not_installed.empty? && definition.no_resolve_needed?
52
79
  ensure
53
80
  Multilock.prepare_block = nil
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Bundler
4
4
  module Multilock
5
- VERSION = "1.0.3"
5
+ VERSION = "1.0.5"
6
6
  end
7
7
  end
@@ -152,6 +152,7 @@ module Bundler
152
152
  attempts = 1
153
153
 
154
154
  checker = Check.new
155
+ synced_any = false
155
156
  Bundler.settings.temporary(cache_all_platforms: true, suppress_install_using_messages: true) do
156
157
  lockfile_definitions.each do |lockfile_definition|
157
158
  # we already wrote the default lockfile
@@ -188,6 +189,7 @@ module Bundler
188
189
  write_lockfile(lockfile_definition, lockfile_definition[:lockfile], install: install)
189
190
  else
190
191
  Bundler.ui.info("Syncing to #{relative_lockfile}...") if attempts == 1
192
+ synced_any = true
191
193
 
192
194
  # adjust locked paths from the default lockfile to be relative to _this_ gemfile
193
195
  adjusted_default_lockfile_contents =
@@ -272,7 +274,7 @@ module Bundler
272
274
  end
273
275
  end
274
276
 
275
- exit 1 unless checker.run
277
+ exit 1 unless checker.run(skip_base_checks: !synced_any)
276
278
  ensure
277
279
  @recursive = previous_recursive
278
280
  end
@@ -362,8 +364,36 @@ module Bundler
362
364
  end
363
365
 
364
366
  def write_lockfile(lockfile_definition, lockfile, install:, dependency_changes: false)
365
- self.prepare_block = lockfile_definition[:prepare]
366
- definition = build_definition(lockfile_definition, lockfile, dependency_changes: dependency_changes)
367
+ prepare_block = lockfile_definition[:prepare]
368
+
369
+ gemfile = lockfile_definition[:gemfile]
370
+ # use avoid Definition.build, so that we don't have to evaluate
371
+ # the gemfile multiple times, each time we need a separate definition
372
+ builder = Dsl.new
373
+ builder.eval_gemfile(gemfile, &prepare_block) if prepare_block
374
+ builder.eval_gemfile(gemfile)
375
+
376
+ definition = builder.to_definition(lockfile, {})
377
+ definition.instance_variable_set(:@dependency_changes, dependency_changes) if dependency_changes
378
+ orig_definition = definition.dup # we might need it twice
379
+
380
+ current_lockfile = lockfile_definition[:lockfile]
381
+ if current_lockfile.exist?
382
+ definition.instance_variable_set(:@lockfile_contents, current_lockfile.read)
383
+ if install
384
+ current_definition = builder.to_definition(current_lockfile, {})
385
+ begin
386
+ current_definition.resolve_only_locally!
387
+ if current_definition.missing_specs.any?
388
+ Bundler.with_default_lockfile(current_lockfile) do
389
+ Installer.install(gemfile.dirname, current_definition, {})
390
+ end
391
+ end
392
+ rescue RubyVersionMismatch, GemNotFound, SolveFailure
393
+ # ignore
394
+ end
395
+ end
396
+ end
367
397
 
368
398
  resolved_remotely = false
369
399
  begin
@@ -372,7 +402,7 @@ module Bundler
372
402
  begin
373
403
  definition.resolve_with_cache!
374
404
  rescue GemNotFound, SolveFailure
375
- definition = build_definition(lockfile_definition, lockfile, dependency_changes: dependency_changes)
405
+ definition = orig_definition
376
406
 
377
407
  definition.resolve_remotely!
378
408
  resolved_remotely = true
@@ -391,18 +421,6 @@ module Bundler
391
421
  end
392
422
 
393
423
  !definition.nothing_changed?
394
- ensure
395
- self.prepare_block = nil
396
- end
397
-
398
- def build_definition(lockfile_definition, lockfile, dependency_changes:)
399
- definition = Definition.build(lockfile_definition[:gemfile], lockfile, false)
400
- definition.instance_variable_set(:@dependency_changes, dependency_changes) if dependency_changes
401
- if lockfile_definition[:lockfile].exist?
402
- definition.instance_variable_set(:@lockfile_contents,
403
- lockfile_definition[:lockfile].read)
404
- end
405
- definition
406
424
  end
407
425
  end
408
426
 
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.3
4
+ version: 1.0.5
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-13 00:00:00.000000000 Z
11
+ date: 2023-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler