bootboot 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a660b842166734ab9e7a05d31ac2a4ed989628737715b66ece5c1842a05a897e
4
- data.tar.gz: 87e2fe884bf5757b777556d33d2e055c4dbac0f6e4e861488bc68af4add5656c
3
+ metadata.gz: e9d43952cbfd83694c174233e724fadcd4003f1ddaf8a33b79089782334cb74f
4
+ data.tar.gz: c569400d898e2d7ed519579d595c3ea79e0cc96e13300e3176c28728af49b001
5
5
  SHA512:
6
- metadata.gz: bb199cfc6cd3f26b4ff430acdf99269d7d94a07d5270610a9504550380a331f75e800980bcace2ae26ce734511f9476b5bda3c89426e25d9658c5b09c63b2114
7
- data.tar.gz: 37e249e6377c0b148e7326ff40deaaa6df0244f86ab098407f96e29d7f4aa0aa70be936575a66b3c07f5ea1ba603b2909bde174152e72ae2591405ae08928eb7
6
+ metadata.gz: 00ed13d606f63cc3eed624aab9dd314b33e9b227716524c2f891ac7089acc6d6ae50e5ba68f7644af94246eaf58da7c373e76dfdc05b603d092685a9450ae746
7
+ data.tar.gz: 99bd2435970d06ea198ca27e53be25d438cb1a633cc2df6a76f551be94b8f5fc893400774b5b98d2497e3843399a708f65665230178afde35bf3f0475b61bc5c
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- ## 👢👢 Bootboot - [![Build Status](https://travis-ci.com/Shopify/bootboot.svg?branch=master)](https://travis-ci.com/Shopify/bootboot)
1
+ ## 👢👢 Bootboot - [![Build Status](https://github.com/Shopify/bootboot/actions/workflows/ci.yml/badge.svg)](https://github.com/Shopify/bootboot/actions/workflows/ci.yml)
2
2
 
3
3
  Introduction
4
4
  ------------
@@ -44,7 +44,7 @@ Installation
44
44
  ------------
45
45
  1) In your Gemfile, add this
46
46
  ```ruby
47
- plugin 'bootboot', '~> 0.1.1'
47
+ plugin 'bootboot', '~> 0.2.1'
48
48
  ```
49
49
  2) Run `bundle install && bundle bootboot`
50
50
  3) You're done. Commit the Gemfile and the Gemfile_next.lock
@@ -4,7 +4,7 @@ require "bootboot/ruby_source"
4
4
 
5
5
  module DefinitionPatch
6
6
  def initialize(wrong_lock, *args)
7
- lockfile = if ENV['BOOTBOOT_UPDATING_ALTERNATE_LOCKFILE']
7
+ lockfile = if ENV["BOOTBOOT_UPDATING_ALTERNATE_LOCKFILE"]
8
8
  wrong_lock
9
9
  else
10
10
  Bootboot::GEMFILE_NEXT_LOCK
@@ -16,15 +16,17 @@ end
16
16
 
17
17
  module RubyVersionPatch
18
18
  def system
19
- if ENV['BOOTBOOT_UPDATING_ALTERNATE_LOCKFILE']
20
- # If we're updating the alternate file and the ruby version specified in
21
- # the Gemfile is different from the Ruby version currently running, we
22
- # want to write the version specified in `Gemfile` for the current
23
- # dependency set to the lock file
24
- Bundler::Definition.build(Bootboot::GEMFILE, nil, false).ruby_version || super
25
- else
26
- super
27
- end
19
+ # Only monkey-patch if we're updating the alternate file
20
+ return super unless ENV["BOOTBOOT_UPDATING_ALTERNATE_LOCKFILE"]
21
+
22
+ # Bail out if the Gemfile doesn't specify a Ruby requirement
23
+ requested_ruby = Bundler::Definition.build(Bootboot::GEMFILE, nil, false).ruby_version
24
+ return super unless requested_ruby
25
+
26
+ # If the requirement is for an exact Ruby version, we should substitute the
27
+ # system version with the requirement so that it gets written to the lock file
28
+ requirement = Gem::Requirement.new(requested_ruby.versions)
29
+ requirement.exact? ? requested_ruby : super
28
30
  end
29
31
  end
30
32
 
@@ -54,7 +56,7 @@ Bundler::Dsl.class_eval do
54
56
  Bundler::SharedHelpers.singleton_class.prepend(SharedHelpersPatch)
55
57
  Bundler::Settings.prepend(Module.new do
56
58
  def app_cache_path
57
- 'vendor/cache-next'
59
+ "vendor/cache-next"
58
60
  end
59
61
  end)
60
62
  end
@@ -1,27 +1,27 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'fileutils'
3
+ require "fileutils"
4
4
 
5
5
  module Bootboot
6
6
  class Command < Bundler::Plugin::API
7
7
  def setup
8
- self.class.command('bootboot')
8
+ self.class.command("bootboot")
9
9
  end
10
10
 
11
11
  def exec(_cmd, _args)
12
12
  FileUtils.cp(GEMFILE_LOCK, GEMFILE_NEXT_LOCK)
13
13
 
14
- File.open(GEMFILE, 'a+') do |f|
15
- f.write(<<-EOM)
16
- Plugin.send(:load_plugin, 'bootboot') if Plugin.installed?('bootboot')
14
+ File.open(GEMFILE, "a+") do |f|
15
+ f.write(<<~EOM)
16
+ Plugin.send(:load_plugin, 'bootboot') if Plugin.installed?('bootboot')
17
17
 
18
- if ENV['#{Bootboot.env_next}']
19
- enable_dual_booting if Plugin.installed?('bootboot')
18
+ if ENV['#{Bootboot.env_next}']
19
+ enable_dual_booting if Plugin.installed?('bootboot')
20
20
 
21
- # Add any gem you want here, they will be loaded only when running
22
- # bundler command prefixed with `#{Bootboot.env_next}=1`.
23
- end
24
- EOM
21
+ # Add any gem you want here, they will be loaded only when running
22
+ # bundler command prefixed with `#{Bootboot.env_next}=1`.
23
+ end
24
+ EOM
25
25
  end
26
26
  end
27
27
  end
@@ -23,7 +23,7 @@ module Bootboot
23
23
  end
24
24
 
25
25
  def opt_in
26
- self.class.hook('before-install-all') do
26
+ self.class.hook("before-install-all") do
27
27
  @previous_lock = Bundler.default_lockfile.read
28
28
  end
29
29
 
@@ -31,9 +31,9 @@ module Bootboot
31
31
  current_definition = Bundler.definition
32
32
 
33
33
  next if !GEMFILE_NEXT_LOCK.exist? ||
34
- nothing_changed?(current_definition) ||
35
- ENV[Bootboot.env_next] ||
36
- ENV[Bootboot.env_previous]
34
+ nothing_changed?(current_definition) ||
35
+ ENV[Bootboot.env_next] ||
36
+ ENV[Bootboot.env_previous]
37
37
 
38
38
  update!(current_definition)
39
39
  end
@@ -48,8 +48,8 @@ module Bootboot
48
48
  lock = which_lock
49
49
 
50
50
  Bundler.ui.confirm("Updating the #{lock}")
51
- ENV[env] = '1'
52
- ENV['BOOTBOOT_UPDATING_ALTERNATE_LOCKFILE'] = '1'
51
+ ENV[env] = "1"
52
+ ENV["BOOTBOOT_UPDATING_ALTERNATE_LOCKFILE"] = "1"
53
53
 
54
54
  unlock = current_definition.instance_variable_get(:@unlock)
55
55
  definition = Bundler::Definition.build(GEMFILE, lock, unlock)
@@ -57,7 +57,7 @@ module Bootboot
57
57
  definition.lock(lock)
58
58
  ensure
59
59
  ENV.delete(env)
60
- ENV.delete('BOOTBOOT_UPDATING_ALTERNATE_LOCKFILE')
60
+ ENV.delete("BOOTBOOT_UPDATING_ALTERNATE_LOCKFILE")
61
61
  end
62
62
 
63
63
  def which_env
@@ -18,15 +18,30 @@ module Bootboot
18
18
 
19
19
  def specs
20
20
  Bundler::Index.build do |idx|
21
- # If the ruby version specified in the Gemfile is different from the
22
- # Ruby version currently running, we want to build a definition without
23
- # a lockfile (so that `ruby_version` in the Gemfile isn't overridden by
24
- # the lockfile) and get its `ruby_version`. This will be used both
25
- # during dependency resolution so that we can pretend the intended Ruby
26
- # version is present, as well as when updating the lockfile itself.
27
- ruby_version = Bundler::Definition.build(Bootboot::GEMFILE, nil, false).ruby_version
28
- ruby_version ||= Bundler::RubyVersion.system
29
- ruby_spec = Gem::Specification.new(ruby_spec_name, ruby_version.to_gem_version_with_patchlevel)
21
+ requested_ruby = Bundler::Definition.build(Bootboot::GEMFILE, nil, false).ruby_version
22
+ system_version = Bundler::RubyVersion.system.gem_version
23
+ requirement = Gem::Requirement.new(requested_ruby.versions) if requested_ruby
24
+
25
+ # This will be used both during dependency resolution so that we can pretend
26
+ # the intended Ruby version is present, as well as when updating the lock file.
27
+ ruby_spec_version = if requested_ruby.nil?
28
+ # if the Gemfile doesn't request a specific Ruby version, just use system
29
+ system_version
30
+ elsif !requirement.exact? && requirement.satisfied_by?(system_version)
31
+ # if the Gemfile requests a non-exact Ruby version which is satisfied by
32
+ # the currently running Ruby, use that when updating the lock file
33
+ system_version
34
+ else
35
+ # If we're here, there's either an exact requirement for the Ruby version
36
+ # (in which case we should substitue it instead of current Ruby version),
37
+ # else the currently running Ruby doesn't satisfy the non-exact requirement
38
+ # (in which case an error will be thrown by bundler). Not sure how we can
39
+ # improve the error message, which will be vague due to using #gem_version
40
+ # of the unsatisified requirement.
41
+ requested_ruby.gem_version
42
+ end
43
+
44
+ ruby_spec = Gem::Specification.new(ruby_spec_name, ruby_spec_version)
30
45
  ruby_spec.source = self
31
46
  idx << ruby_spec
32
47
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bootboot
4
- VERSION = "0.2.0"
4
+ VERSION = "0.2.2"
5
5
  end
data/lib/bootboot.rb CHANGED
@@ -8,22 +8,22 @@ module Bootboot
8
8
  GEMFILE_LOCK = Pathname("#{GEMFILE}.lock")
9
9
  GEMFILE_NEXT_LOCK = Pathname("#{GEMFILE}_next.lock")
10
10
 
11
- autoload :GemfileNextAutoSync, 'bootboot/gemfile_next_auto_sync'
12
- autoload :Command, 'bootboot/command'
11
+ autoload :GemfileNextAutoSync, "bootboot/gemfile_next_auto_sync"
12
+ autoload :Command, "bootboot/command"
13
13
 
14
14
  class << self
15
15
  def env_next
16
- env_prefix + '_NEXT'
16
+ env_prefix + "_NEXT"
17
17
  end
18
18
 
19
19
  def env_previous
20
- env_prefix + '_PREVIOUS'
20
+ env_prefix + "_PREVIOUS"
21
21
  end
22
22
 
23
23
  private
24
24
 
25
25
  def env_prefix
26
- Bundler.settings['bootboot_env_prefix'] || 'DEPENDENCIES'
26
+ Bundler.settings["bootboot_env_prefix"] || "DEPENDENCIES"
27
27
  end
28
28
  end
29
29
  end
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootboot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-14 00:00:00.000000000 Z
11
+ date: 2023-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rake
14
+ name: minitest
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '10.0'
19
+ version: '5.0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '10.0'
26
+ version: '5.0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: minitest
28
+ name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '5.0'
33
+ version: '10.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '5.0'
40
+ version: '10.0'
41
41
  description: " This gem remove the overhead of monkeypatching your Gemfile in order
42
42
  to dualboot your app using the Gemfile_next lock strategy It also ensure that dependencies
43
43
  in the Gemfile lock and Gemfile_next lock are in sync whenever someone updates a
@@ -82,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0'
84
84
  requirements: []
85
- rubygems_version: 3.0.3
85
+ rubygems_version: 3.3.3
86
86
  signing_key:
87
87
  specification_version: 4
88
88
  summary: Dualbooting your ruby app made easy.