bundleup 0.3.0 → 0.4.0

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
  SHA1:
3
- metadata.gz: 245fefcb714dea09da4249386faf7d427c4042f1
4
- data.tar.gz: fb6a1589a8253f9db5bcb85d036b795581f572ad
3
+ metadata.gz: 2042941c3836df1dff0b80b1b85122edb2c9dc6f
4
+ data.tar.gz: 4bed7910cd47f5613cd5feaff7cfe133e949ca9e
5
5
  SHA512:
6
- metadata.gz: b2a63df2aee21d9a55cf8173c1becf3e897cf23ed4d0547849676c1c2ec36c4dec450d03bc055054f5579baeb60503726ca6099265c8836fdbe90e087e404481
7
- data.tar.gz: 952d65e4e3a7a5fb023022fe017933e9d7295da1697e5d7102cc1bf400c1657161426fd9325042c906c1e491164b404d6ce9f5ce69fa3073265a4ab563666fe0
6
+ metadata.gz: 4edde92228db4dd91b754baa92e9b5719c168fea1536e6922b8c8437c9c75c8090cdecb11afdfda8e06737dffa5f67108a44b814c4e64390508e6d8d45541661
7
+ data.tar.gz: 21a13add9532fde6fa8c3c00796300fed0074dd1a597ab98a9fe92893eb9ffd107c2c8d304100541f3fcf1d9795e9a69eaa1edc07f8ed239ec83f46119118844
data/.travis.yml CHANGED
@@ -1,5 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.1.8
4
- - 2.2.4
3
+ - 2.1
4
+ - 2.2
5
+ - 2.3.0
5
6
  before_install: gem install bundler -v 1.11.2
data/CHANGELOG.md CHANGED
@@ -8,6 +8,15 @@ bundleup is in a pre-1.0 state. This means that its APIs and behavior are subjec
8
8
 
9
9
  * Your contribution here!
10
10
 
11
+ ## [0.4.0][] (2016-02-19)
12
+
13
+ * **Change the upgrade process to modify the Gemfile.lock in place, with the
14
+ option to "undo" (i.e. restore from backup) if the changes are not desired.**
15
+ This makes bundleup much faster since it doesn't have to run `bundle update`
16
+ twice.
17
+ * Fixed a bug where color was mistakenly based on the newest version of a gem,
18
+ even if a restriction prevented upgrading to that version.
19
+
11
20
  ## [0.3.0][] (2016-01-08)
12
21
 
13
22
  * Always show SHA changes in red. If a dependency is tracking a
@@ -27,6 +36,7 @@ bundleup is in a pre-1.0 state. This means that its APIs and behavior are subjec
27
36
  * Initial release
28
37
 
29
38
  [Semver]: http://semver.org
30
- [Unreleased]: https://github.com/mattbrictson/bundleup/compare/v0.3.0...HEAD
39
+ [Unreleased]: https://github.com/mattbrictson/bundleup/compare/v0.4.0...HEAD
40
+ [0.4.0]: https://github.com/mattbrictson/bundleup/compare/v0.3.0...v0.4.0
31
41
  [0.3.0]: https://github.com/mattbrictson/bundleup/compare/v0.2.0...v0.3.0
32
42
  [0.2.0]: https://github.com/mattbrictson/bundleup/compare/v0.1.0...v0.2.0
data/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  You might like bundleup because it:
10
10
 
11
- * shows you exactly what gems will be updated *before* making any changes to your Gemfile.lock
11
+ * shows you exactly what gems will be updated lets you decide whether to proceed
12
12
  * uses color to call your attention to important gem updates (based on [Semver][])
13
13
  * lets you know when a version "pin" in your Gemfile is preventing an update
14
14
  * relies on standard Bundler output and does not patch code or use Bundler internals
@@ -39,9 +39,9 @@ That’s it!
39
39
 
40
40
  bundleup starts by making a backup copy of your Gemfile.lock. Next it runs `bundle show`, then `bundle update` and `bundle show` again to find what gems versions are being used before and after Bundler does its updating magic. (Since gems are actually being installed into your Ruby environment during these steps, the process may take a few moments to complete, especially if gems with native extensions need to be compiled.)
41
41
 
42
- Finally, bundleup runs `bundle outdated` to see the gems that were *not* updated due to Gemfile restrictions. It then restores your original Gemfile.lock from the backup, leaving your project as it started.
42
+ Finally, bundleup runs `bundle outdated` to see the gems that were *not* updated due to Gemfile restrictions.
43
43
 
44
- After displaying its findings, bundleup gives you the option of running `bundle update` once more against your project. This time your Gemfile.lock *will* be changed. You can skip this step if you want.
44
+ After displaying its findings, bundleup gives you the option of keeping the changes. If you answer "no", bundleup will restore your original Gemfile.lock from its backup, leaving your project untouched.
45
45
 
46
46
 
47
47
  ## Roadmap
data/bundleup.gemspec CHANGED
@@ -25,5 +25,5 @@ Gem::Specification.new do |spec|
25
25
  spec.add_development_dependency "minitest", "~> 5.0"
26
26
  spec.add_development_dependency "minitest-reporters"
27
27
  spec.add_development_dependency "rake", "~> 10.0"
28
- spec.add_development_dependency "rubocop"
28
+ spec.add_development_dependency "rubocop", ">= 0.37.2"
29
29
  end
data/lib/bundleup.rb CHANGED
@@ -2,5 +2,5 @@ require "bundleup/version"
2
2
  require "bundleup/console"
3
3
  require "bundleup/bundle_commands"
4
4
  require "bundleup/gem_status"
5
- require "bundleup/gemfile"
5
+ require "bundleup/upgrade"
6
6
  require "bundleup/cli"
@@ -23,7 +23,7 @@ module Bundleup
23
23
  out, err, status = Open3.capture3(cmd)
24
24
  next(out) if status.success? || fail_silently
25
25
 
26
- fail ["Failed to execute: #{cmd}", out, err].compact.join("\n")
26
+ raise ["Failed to execute: #{cmd}", out, err].compact.join("\n")
27
27
  end
28
28
  end
29
29
  end
data/lib/bundleup/cli.rb CHANGED
@@ -4,11 +4,15 @@ module Bundleup
4
4
 
5
5
  def run
6
6
  puts \
7
- "Please wait a moment while I try upgrading a copy of your Gemfile..."
7
+ "Please wait a moment while I upgrade your Gemfile.lock..."
8
8
 
9
+ committed = false
9
10
  review_upgrades
10
11
  review_pins
11
- offer_bundle_update if upgrades.any?
12
+ committed = upgrades.any? && confirm_commit
13
+ puts "Done!" if committed
14
+ ensure
15
+ restore_lockfile unless committed
12
16
  end
13
17
 
14
18
  private
@@ -28,20 +32,26 @@ module Bundleup
28
32
  print_pins_table
29
33
  end
30
34
 
31
- def offer_bundle_update
32
- exec "bundle update" if confirm("\nShall I run `bundle update` for you?")
35
+ def confirm_commit
36
+ confirm("\nDo you want to apply these changes?")
33
37
  end
34
38
 
35
- def gemfile
36
- @gemfile ||= Gemfile.new
39
+ def restore_lockfile
40
+ return unless upgrade.lockfile_changed?
41
+ upgrade.undo
42
+ puts "Your original Gemfile.lock has been restored."
43
+ end
44
+
45
+ def upgrade
46
+ @upgrade ||= Upgrade.new
37
47
  end
38
48
 
39
49
  def upgrades
40
- gemfile.upgrades
50
+ upgrade.upgrades
41
51
  end
42
52
 
43
53
  def pins
44
- gemfile.pins
54
+ upgrade.pins
45
55
  end
46
56
 
47
57
  def print_upgrades_table
@@ -4,7 +4,7 @@ module Bundleup
4
4
  :red => 31,
5
5
  :green => 32,
6
6
  :yellow => 33,
7
- :blue => 34,
7
+ :blue => 34,
8
8
  :gray => 90
9
9
  }.freeze
10
10
 
@@ -63,7 +63,7 @@ module Bundleup
63
63
  private
64
64
 
65
65
  def max_length_of_each_column(rows)
66
- rows.first.count.times.map do |i|
66
+ Array.new(rows.first.count) do |i|
67
67
  rows.map { |values| values[i].to_s.length }.max
68
68
  end
69
69
  end
@@ -33,15 +33,13 @@ module Bundleup
33
33
  end
34
34
 
35
35
  def major_upgrade?
36
- new = newest_version || new_version
37
- return false if new.nil? || old_version.nil?
38
- major(new) != major(old_version)
36
+ return false if new_version.nil? || old_version.nil?
37
+ major(new_version) != major(old_version)
39
38
  end
40
39
 
41
40
  def minor_upgrade?
42
- new = newest_version || new_version
43
- return false if new.nil? || old_version.nil?
44
- !major_upgrade? && minor(new) != minor(old_version)
41
+ return false if new_version.nil? || old_version.nil?
42
+ !major_upgrade? && minor(new_version) != minor(old_version)
45
43
  end
46
44
 
47
45
  private
@@ -1,12 +1,10 @@
1
- require "fileutils"
2
- require "tmpdir"
3
-
4
1
  module Bundleup
5
- class Gemfile
2
+ class Upgrade
6
3
  def initialize(commands=BundleCommands.new)
7
4
  @commands = commands
8
5
  @gem_statuses = {}
9
- load
6
+ @original_lockfile_contents = IO.read(lockfile)
7
+ run
10
8
  end
11
9
 
12
10
  def upgrades
@@ -17,25 +15,27 @@ module Bundleup
17
15
  @gem_statuses.values.select(&:pinned?).sort_by(&:name)
18
16
  end
19
17
 
18
+ def lockfile_changed?
19
+ IO.read(lockfile) != original_lockfile_contents
20
+ end
21
+
22
+ def undo
23
+ IO.write(lockfile, original_lockfile_contents)
24
+ end
25
+
20
26
  private
21
27
 
22
- attr_reader :commands
28
+ attr_reader :commands, :original_lockfile_contents
23
29
 
24
- def load
25
- with_copy_of_lockfile do
26
- find_versions(:old)
27
- commands.update
28
- find_versions(:new)
29
- find_pinned_versions
30
- end
30
+ def run
31
+ find_versions(:old)
32
+ commands.update
33
+ find_versions(:new)
34
+ find_pinned_versions
31
35
  end
32
36
 
33
- def with_copy_of_lockfile
34
- backup = ".Gemfile.lock.#{rand(1_000_000_000).to_s(36)}"
35
- FileUtils.cp("Gemfile.lock", backup)
36
- yield
37
- ensure
38
- FileUtils.mv(backup, "Gemfile.lock")
37
+ def lockfile
38
+ "Gemfile.lock"
39
39
  end
40
40
 
41
41
  def find_pinned_versions
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Bundleup
2
- VERSION = "0.3.0"
3
+ VERSION = "0.4.0".freeze
3
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bundleup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Brictson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-01-08 00:00:00.000000000 Z
11
+ date: 2016-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - ">="
102
102
  - !ruby/object:Gem::Version
103
- version: '0'
103
+ version: 0.37.2
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
- version: '0'
110
+ version: 0.37.2
111
111
  description:
112
112
  email:
113
113
  - bundleup@mattbrictson.com
@@ -135,7 +135,7 @@ files:
135
135
  - lib/bundleup/cli.rb
136
136
  - lib/bundleup/console.rb
137
137
  - lib/bundleup/gem_status.rb
138
- - lib/bundleup/gemfile.rb
138
+ - lib/bundleup/upgrade.rb
139
139
  - lib/bundleup/version.rb
140
140
  - sample.png
141
141
  homepage: https://github.com/mattbrictson/bundleup